summaryrefslogtreecommitdiff
path: root/testsuite/states
diff options
context:
space:
mode:
authorWim Taymans <wim.taymans@gmail.com>2005-03-21 17:34:02 +0000
committerWim Taymans <wim.taymans@gmail.com>2005-03-21 17:34:02 +0000
commitc2f41a8906da4d2694eb111154283c6c9334b9de (patch)
tree49386a31a456a9b3d18b148894f96c353f683a27 /testsuite/states
parent007cff6d75995bda6ab24c9f7be7137686bc163d (diff)
Next big merge.
Original commit message from CVS: Next big merge. Added GstBus for mainloop integration. Added GstMessage for sending notifications on the bus. Added GstTask as an abstraction for pipeline entry points. Removed GstThread. Removed Schedulers. Simplified GstQueue for multithreaded core. Made _link threadsafe, removed old capsnego. Added STREAM_LOCK and PREROLL_LOCK in GstPad. Added pad blocking functions. Reworked scheduling functions in GstPad to prepare for scheduling updates soon. Moved events out of data stream. Simplified GstEvent types. Added return values to push/pull. Removed clocking from GstElement. Added prototypes for state change function for next merge. Removed iterate from bins and state change management. Fixed some elements, disabled others for now. Fixed -inspect and -launch. Added check for GstBus.
Diffstat (limited to 'testsuite/states')
-rw-r--r--testsuite/states/locked.c51
-rw-r--r--testsuite/states/parent.c22
2 files changed, 56 insertions, 17 deletions
diff --git a/testsuite/states/locked.c b/testsuite/states/locked.c
index ecf969ec3..d66565dde 100644
--- a/testsuite/states/locked.c
+++ b/testsuite/states/locked.c
@@ -17,50 +17,85 @@
* Boston, MA 02111-1307, USA.
*/
+#include "unistd.h"
+
#include <gst/gst.h>
+static GMainLoop *loop;
+
+static gboolean
+message_received (GstBus * bus, GstMessage * message, GstPipeline * pipeline)
+{
+ g_print ("message %p\n", message);
+
+ if (message->type == GST_MESSAGE_EOS) {
+ g_print ("EOS!!\n");
+ if (g_main_loop_is_running (loop))
+ g_main_loop_quit (loop);
+ }
+ gst_message_unref (message);
+
+ return TRUE;
+}
+
gint
main (gint argc, gchar * argv[])
{
GstElement *pipeline;
GstElement *fakesrc1, *fakesink1;
GstElement *fakesrc2, *fakesink2;
+ GstBus *bus;
gst_init (&argc, &argv);
pipeline = gst_pipeline_new ("pipeline");
+ loop = g_main_loop_new (NULL, FALSE);
+ bus = gst_element_get_bus (pipeline);
+ gst_bus_add_watch (bus, (GstBusHandler) message_received, pipeline);
+ gst_object_unref (GST_OBJECT (bus));
+
fakesrc1 = gst_element_factory_make ("fakesrc", "fakesrc1");
g_object_set (G_OBJECT (fakesrc1), "num_buffers", 5, NULL);
fakesink1 = gst_element_factory_make ("fakesink", "fakesink1");
- gst_bin_add_many (GST_BIN (pipeline), fakesrc1, fakesink1, NULL);
- gst_element_link_pads (fakesrc1, "src", fakesink1, "sink");
+ gst_bin_add (GST_BIN (pipeline), fakesrc1);
+ gst_bin_add (GST_BIN (pipeline), fakesink1);
+ gst_pad_link (gst_element_get_pad (fakesrc1, "src"),
+ gst_element_get_pad (fakesink1, "sink"));
fakesrc2 = gst_element_factory_make ("fakesrc", "fakesrc2");
g_object_set (G_OBJECT (fakesrc2), "num_buffers", 5, NULL);
fakesink2 = gst_element_factory_make ("fakesink", "fakesink2");
- gst_bin_add_many (GST_BIN (pipeline), fakesrc2, fakesink2, NULL);
- gst_element_link_pads (fakesrc2, "src", fakesink2, "sink");
+ gst_bin_add (GST_BIN (pipeline), fakesrc2);
+ gst_bin_add (GST_BIN (pipeline), fakesink2);
+ gst_pad_link (gst_element_get_pad (fakesrc2, "src"),
+ gst_element_get_pad (fakesink2, "sink"));
g_signal_connect (G_OBJECT (pipeline), "deep_notify",
- G_CALLBACK (gst_element_default_deep_notify), NULL);
+ G_CALLBACK (gst_object_default_deep_notify), NULL);
GST_FLAG_SET (fakesrc2, GST_ELEMENT_LOCKED_STATE);
GST_FLAG_SET (fakesink2, GST_ELEMENT_LOCKED_STATE);
+ g_print ("play..\n");
gst_element_set_state (pipeline, GST_STATE_PLAYING);
- while (gst_bin_iterate (GST_BIN (pipeline)));
- gst_element_set_state (pipeline, GST_STATE_READY);
+
+ g_main_loop_run (loop);
g_object_set (G_OBJECT (fakesrc1), "num_buffers", 5, NULL);
+ gst_element_set_state (pipeline, GST_STATE_READY);
+
GST_FLAG_UNSET (fakesrc2, GST_ELEMENT_LOCKED_STATE);
GST_FLAG_UNSET (fakesink2, GST_ELEMENT_LOCKED_STATE);
+ g_print ("play..\n");
gst_element_set_state (pipeline, GST_STATE_PLAYING);
- while (gst_bin_iterate (GST_BIN (pipeline)));
+
+ g_main_loop_run (loop);
+
gst_element_set_state (pipeline, GST_STATE_NULL);
gst_object_unref (GST_OBJECT (pipeline));
diff --git a/testsuite/states/parent.c b/testsuite/states/parent.c
index aa583c5aa..fe8b2441c 100644
--- a/testsuite/states/parent.c
+++ b/testsuite/states/parent.c
@@ -67,7 +67,7 @@ main (gint argc, gchar * argv[])
gst_bin_add (GST_BIN (pipeline), bin2);
g_signal_connect (G_OBJECT (pipeline), "deep_notify",
- G_CALLBACK (gst_element_default_deep_notify), NULL);
+ G_CALLBACK (gst_object_default_deep_notify), NULL);
/* setting pipeline to READY should bring in all children to READY */
gst_element_set_state (pipeline, GST_STATE_READY);
@@ -77,31 +77,35 @@ main (gint argc, gchar * argv[])
g_assert (GST_STATE (identity) == GST_STATE_READY);
g_assert (GST_STATE (fakesink) == GST_STATE_READY);
- /* setting fakesink to PAUSED should set pipeline and bin2 to PAUSED */
+ /* setting fakesink to PAUSED should not affect pipeline and bin2 */
gst_element_set_state (fakesink, GST_STATE_PAUSED);
g_assert (GST_STATE (bin1) == GST_STATE_READY);
- g_assert (GST_STATE (bin2) == GST_STATE_PAUSED);
+ g_assert (GST_STATE (bin2) == GST_STATE_READY);
g_assert (GST_STATE (fakesrc) == GST_STATE_READY);
g_assert (GST_STATE (identity) == GST_STATE_READY);
- g_assert (GST_STATE (fakesink) == GST_STATE_PAUSED);
+ g_assert (GST_STATE (fakesink) == GST_STATE_READY);
- /* setting fakesrc to PAUSED should set bin1 and fakesrc to PAUSED */
+ /* setting fakesrc to PAUSED should not affect bin1 */
gst_element_set_state (fakesrc, GST_STATE_PAUSED);
- g_assert (GST_STATE (bin1) == GST_STATE_PAUSED);
- g_assert (GST_STATE (bin2) == GST_STATE_PAUSED);
+ g_assert (GST_STATE (bin1) == GST_STATE_READY);
+ g_assert (GST_STATE (bin2) == GST_STATE_READY);
g_assert (GST_STATE (fakesrc) == GST_STATE_PAUSED);
g_assert (GST_STATE (identity) == GST_STATE_READY);
- g_assert (GST_STATE (fakesink) == GST_STATE_PAUSED);
+ g_assert (GST_STATE (fakesink) == GST_STATE_READY);
/* setting bin1 to PAUSED, even though it is already, should set
* identity to PAUSED as well */
gst_element_set_state (bin1, GST_STATE_PAUSED);
+ gst_element_get_state (bin2, NULL, NULL, NULL);
g_assert (GST_STATE (bin1) == GST_STATE_PAUSED);
- g_assert (GST_STATE (bin2) == GST_STATE_PAUSED);
+ g_assert (GST_STATE (bin2) == GST_STATE_READY);
g_assert (GST_STATE (fakesrc) == GST_STATE_PAUSED);
g_assert (GST_STATE (identity) == GST_STATE_PAUSED);
g_assert (GST_STATE (fakesink) == GST_STATE_PAUSED);
+ gst_element_set_state (pipeline, GST_STATE_PLAYING);
+ g_usleep (1000000);
+
g_print ("passed.\n");
return 0;
}