From d9b700392662d31c7ffacdd0f86c7bd2a0b54d7f Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Fri, 30 Apr 2010 18:03:37 +0200 Subject: [PATCH] oggdemux: refactor for seeking in pushmode refactor the code a little to prepare for seeking in push mode --- ext/ogg/gstoggdemux.c | 53 ++++++++++++++++++++++++--------------------------- 1 file changed, 25 insertions(+), 28 deletions(-) diff --git a/ext/ogg/gstoggdemux.c b/ext/ogg/gstoggdemux.c index bf4072f..9b140cb 100644 --- a/ext/ogg/gstoggdemux.c +++ b/ext/ogg/gstoggdemux.c @@ -311,14 +311,6 @@ gst_ogg_demux_receive_event (GstElement * element, GstEvent * event) switch (GST_EVENT_TYPE (event)) { case GST_EVENT_SEEK: - /* can't seek if we are not pullmode, FIXME could pass the - * seek query upstream after converting it to bytes using - * the average bitrate of the stream. */ - if (!ogg->pullmode) { - GST_DEBUG_OBJECT (ogg, "seek on push mode stream not implemented yet"); - goto error; - } - /* now do the seek */ res = gst_ogg_demux_perform_seek (ogg, event); gst_event_unref (event); @@ -349,14 +341,6 @@ gst_ogg_pad_event (GstPad * pad, GstEvent * event) switch (GST_EVENT_TYPE (event)) { case GST_EVENT_SEEK: - /* can't seek if we are not pullmode, FIXME could pass the - * seek query upstream after converting it to bytes using - * the average bitrate of the stream. */ - if (!ogg->pullmode) { - GST_DEBUG_OBJECT (ogg, "seek on pull mode stream not implemented yet"); - goto error; - } - /* now do the seek */ res = gst_ogg_demux_perform_seek (ogg, event); gst_event_unref (event); @@ -365,19 +349,9 @@ gst_ogg_pad_event (GstPad * pad, GstEvent * event) res = gst_pad_event_default (pad, event); break; } -done: gst_object_unref (ogg); return res; - - /* ERRORS */ -error: - { - GST_DEBUG_OBJECT (ogg, "error handling event"); - gst_event_unref (event); - res = FALSE; - goto done; - } } static void @@ -2039,7 +2013,7 @@ seek_error: /* does not take ownership of the event */ static gboolean -gst_ogg_demux_perform_seek (GstOggDemux * ogg, GstEvent * event) +gst_ogg_demux_perform_seek_pull (GstOggDemux * ogg, GstEvent * event) { GstOggChain *chain = NULL; gboolean res; @@ -2284,6 +2258,29 @@ no_chain: } } +static gboolean +gst_ogg_demux_perform_seek_push (GstOggDemux * ogg, GstEvent * event) +{ + /* can't seek if we are not pullmode, FIXME could pass the + * seek query upstream after converting it to bytes using + * the average bitrate of the stream. */ + return FALSE; +} + +static gboolean +gst_ogg_demux_perform_seek (GstOggDemux * ogg, GstEvent * event) +{ + gboolean res; + + if (ogg->pullmode) { + res = gst_ogg_demux_perform_seek_pull (ogg, event); + } else { + res = gst_ogg_demux_perform_seek_push (ogg, event); + } + return res; +} + + /* finds each bitstream link one at a time using a bisection search * (has to begin by knowing the offset of the lb's initial page). * Recurses for each link so it can alloc the link storage after @@ -3154,7 +3151,7 @@ gst_ogg_demux_loop (GstOggPad * pad) GST_OBJECT_UNLOCK (ogg); /* and seek to configured positions without FLUSH */ - res = gst_ogg_demux_perform_seek (ogg, event); + res = gst_ogg_demux_perform_seek_pull (ogg, event); if (event) gst_event_unref (event); -- 2.7.4