From a06d81ef6067dfa308e45a5cb7a90f6f4449adaa Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Fri, 2 Aug 2002 11:43:25 +0000 Subject: [PATCH] Added segment seeking experiment Original commit message from CVS: Added segment seeking experiment --- tests/Makefile.am | 4 +- tests/seeking/Makefile.am | 4 ++ tests/seeking/seeking1.c | 97 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 103 insertions(+), 2 deletions(-) create mode 100644 tests/seeking/Makefile.am create mode 100644 tests/seeking/seeking1.c diff --git a/tests/Makefile.am b/tests/Makefile.am index 1b1efc6b5c..c6e32a1784 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -6,7 +6,7 @@ else NASMDEP_DIR= endif -SUBDIRS = $(NASMDEP_DIR) muxing sched threadstate +SUBDIRS = $(NASMDEP_DIR) muxing sched threadstate seeking noinst_PROGRAMS = lat @@ -14,4 +14,4 @@ lat_CFLAGS = $(GST_CFLAGS) lat_LDFLAGS = $(GST_LIBS) EXTRA_DIST = README -DIST_SUBDIRS= bufspeed memchunk muxing sched threadstate +DIST_SUBDIRS= bufspeed memchunk muxing sched threadstate seeking diff --git a/tests/seeking/Makefile.am b/tests/seeking/Makefile.am new file mode 100644 index 0000000000..e51e5df27f --- /dev/null +++ b/tests/seeking/Makefile.am @@ -0,0 +1,4 @@ +noinst_PROGRAMS = seeking1 + +LDADD = $(GST_LIBS) +AM_CFLAGS = $(GST_CFLAGS) diff --git a/tests/seeking/seeking1.c b/tests/seeking/seeking1.c new file mode 100644 index 0000000000..be58289f2a --- /dev/null +++ b/tests/seeking/seeking1.c @@ -0,0 +1,97 @@ +#include + +static gint looping; +static GstEvent *event; +static GstPad *pad; + +static void +event_received (GObject *object, GstEvent *event, GstElement *pipeline) +{ + if (GST_EVENT_TYPE (event) == GST_EVENT_SEGMENT_DONE) { + g_print ("segment done\n"); + if (--looping == 1) { + event = gst_event_new_segment_seek (GST_FORMAT_DEFAULT | + GST_SEEK_METHOD_SET | + GST_SEEK_FLAG_FLUSH, 20, 25); + } + else { + event = gst_event_new_segment_seek (GST_FORMAT_DEFAULT | + GST_SEEK_METHOD_SET | + GST_SEEK_FLAG_FLUSH | + GST_SEEK_FLAG_SEGMENT_LOOP, 50, 55); + } + gst_pad_send_event (pad, event); + } +} + +gint +main (gint argc, gchar *argv[]) +{ + GstElement *pipeline; + GstElement *fakesrc; + GstElement *fakesink; + guint64 value; + GstFormat format; + + gst_init (&argc, &argv); + + pipeline = gst_pipeline_new ("pipeline"); + + fakesrc = gst_element_factory_make ("fakesrc", "src"); + + fakesink = gst_element_factory_make ("fakesink", "sink"); + + gst_bin_add (GST_BIN (pipeline), fakesrc); + gst_bin_add (GST_BIN (pipeline), fakesink); + + gst_element_connect_pads (fakesrc, "src", fakesink, "sink"); + + gst_element_set_state (pipeline, GST_STATE_READY); + + pad = gst_element_get_pad (fakesrc, "src"); + + g_print ("doing segment seek from 5 to 10\n"); + + gst_pad_send_event (pad, + gst_event_new_segment_seek (GST_FORMAT_DEFAULT | + GST_SEEK_METHOD_SET | + GST_SEEK_FLAG_FLUSH, 5, 10)); + + format = GST_FORMAT_DEFAULT; + + gst_pad_query (pad, GST_PAD_QUERY_START, &format, &value); + g_print ("configured for start %lld\n", value); + gst_pad_query (pad, GST_PAD_QUERY_SEGMENT_END, &format, &value); + g_print ("configured segment end %lld\n", value); + + + gst_element_set_state (pipeline, GST_STATE_PLAYING); + + g_signal_connect (G_OBJECT (pipeline), "deep_notify", G_CALLBACK (gst_element_default_deep_notify), NULL); + + while (gst_bin_iterate (GST_BIN (pipeline))); + + g_print ("doing segment seek from 50 to 55 with looping (2 times), then 20 to 25 without looping\n"); + looping = 3; + + event = gst_event_new_segment_seek (GST_FORMAT_DEFAULT | + GST_SEEK_METHOD_SET | + GST_SEEK_FLAG_FLUSH | + GST_SEEK_FLAG_SEGMENT_LOOP, 50, 55); + gst_pad_send_event (pad, event); + + g_signal_connect (G_OBJECT (gst_element_get_pad (fakesink, "sink")), "event_received", G_CALLBACK (event_received), event); + + gst_pad_query (pad, GST_PAD_QUERY_START, &format, &value); + g_print ("configured for start %lld\n", value); + gst_pad_query (pad, GST_PAD_QUERY_SEGMENT_END, &format, &value); + g_print ("configured segment end %lld\n", value); + + gst_element_set_state (pipeline, GST_STATE_PLAYING); + + while (gst_bin_iterate (GST_BIN (pipeline))); + + gst_element_set_state (pipeline, GST_STATE_NULL); + + return 0; +}