From 2e75d2ae7e75d05d4dcd41448da25d940792668f Mon Sep 17 00:00:00 2001 From: Edward Hervey Date: Tue, 28 Jun 2005 10:45:48 +0000 Subject: [PATCH] gst/gstpipeline.c: Wheen a seek was successful on a pipeline, set the stream_time to the seek offset in order to have... Original commit message from CVS: * gst/gstpipeline.c: (gst_pipeline_send_event): Wheen a seek was successful on a pipeline, set the stream_time to the seek offset in order to have a synchronized stream_time. --- ChangeLog | 6 ++++++ gst/gstpipeline.c | 21 +++++++++++++++++---- 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index e21b749..c5e9d77 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2005-06-28 Edward Hervey + + * gst/gstpipeline.c: (gst_pipeline_send_event): + Wheen a seek was successful on a pipeline, set the stream_time to the + seek offset in order to have a synchronized stream_time. + 2005-06-28 Wim Taymans * gst/gstghostpad.c: (gst_proxy_pad_do_bufferalloc), diff --git a/gst/gstpipeline.c b/gst/gstpipeline.c index 693a017..5675ff8 100644 --- a/gst/gstpipeline.c +++ b/gst/gstpipeline.c @@ -286,6 +286,7 @@ gst_pipeline_send_event (GstElement * element, GstEvent * event) GstElementState state; GstEventType event_type = GST_EVENT_TYPE (event); GTimeVal timeout; + gint64 offset = -1; /* need to call _get_state() since a bin state is only updated * with this call. */ @@ -294,13 +295,25 @@ gst_pipeline_send_event (GstElement * element, GstEvent * event) gst_element_get_state (element, &state, NULL, &timeout); was_playing = state == GST_STATE_PLAYING; - if (was_playing && event_type == GST_EVENT_SEEK) - gst_element_set_state (element, GST_STATE_PAUSED); + if (event_type == GST_EVENT_SEEK) { + if (GST_EVENT_SEEK_FORMAT (event) != GST_FORMAT_TIME) { + GST_WARNING ("Pipelines only accept seek events with TIME format"); + g_warning ("Pipelines only accept seek events with TIME format"); + return FALSE; + } + offset = GST_EVENT_SEEK_OFFSET (event); + if (was_playing) + gst_element_set_state (element, GST_STATE_PAUSED); + } res = GST_ELEMENT_CLASS (parent_class)->send_event (element, event); - if (was_playing && event_type == GST_EVENT_SEEK) - gst_element_set_state (element, GST_STATE_PLAYING); + if (res && event_type == GST_EVENT_SEEK) { + /* need to set the stream time to the seek time */ + GST_PIPELINE (element)->stream_time = offset; + if (was_playing) + gst_element_set_state (element, GST_STATE_PLAYING); + } return res; } -- 2.7.4