oggdemux: implement seeking in pushmode

Convert seek requests to bytes using the bitrate and forward them upstream. Does
not quite work because the flushing and resyncing is not implemented yet.
This commit is contained in:
Wim Taymans 2010-04-30 18:37:17 +02:00
parent d9b7003926
commit c4ec1c4c62

View file

@ -1046,6 +1046,13 @@ gst_ogg_chain_free (GstOggChain * chain)
g_free (chain); g_free (chain);
} }
static void
gst_ogg_pad_mark_discont (GstOggPad * pad)
{
pad->discont = TRUE;
pad->map.last_size = 0;
}
static void static void
gst_ogg_chain_mark_discont (GstOggChain * chain) gst_ogg_chain_mark_discont (GstOggChain * chain)
{ {
@ -1054,8 +1061,7 @@ gst_ogg_chain_mark_discont (GstOggChain * chain)
for (i = 0; i < chain->streams->len; i++) { for (i = 0; i < chain->streams->len; i++) {
GstOggPad *pad = g_array_index (chain->streams, GstOggPad *, i); GstOggPad *pad = g_array_index (chain->streams, GstOggPad *, i);
pad->discont = TRUE; gst_ogg_pad_mark_discont (pad);
pad->map.last_size = 0;
} }
} }
@ -1087,8 +1093,7 @@ gst_ogg_chain_new_stream (GstOggChain * chain, glong serialno)
gst_object_sink (ret); gst_object_sink (ret);
GST_PAD_DIRECTION (ret) = GST_PAD_SRC; GST_PAD_DIRECTION (ret) = GST_PAD_SRC;
ret->discont = TRUE; gst_ogg_pad_mark_discont (ret);
ret->map.last_size = 0;
ret->chain = chain; ret->chain = chain;
ret->ogg = chain->ogg; ret->ogg = chain->ogg;
@ -1640,8 +1645,7 @@ gst_ogg_demux_activate_chain (GstOggDemux * ogg, GstOggChain * chain,
GST_DEBUG_OBJECT (ogg, "adding pad %" GST_PTR_FORMAT, pad); GST_DEBUG_OBJECT (ogg, "adding pad %" GST_PTR_FORMAT, pad);
/* mark discont */ /* mark discont */
pad->discont = TRUE; gst_ogg_pad_mark_discont (pad);
pad->map.last_size = 0;
pad->last_ret = GST_FLOW_OK; pad->last_ret = GST_FLOW_OK;
pad->added = TRUE; pad->added = TRUE;
@ -2261,10 +2265,37 @@ no_chain:
static gboolean static gboolean
gst_ogg_demux_perform_seek_push (GstOggDemux * ogg, GstEvent * event) gst_ogg_demux_perform_seek_push (GstOggDemux * ogg, GstEvent * event)
{ {
/* can't seek if we are not pullmode, FIXME could pass the gint bitrate;
* seek query upstream after converting it to bytes using gboolean res;
* the average bitrate of the stream. */
return FALSE; bitrate = ogg->bitrate;
if (bitrate > 0) {
GstFormat format;
gdouble rate;
GstSeekFlags flags;
GstSeekType start_type, stop_type;
gint64 start, stop;
GstEvent *sevent;
gst_event_parse_seek (event, &rate, &format, &flags,
&start_type, &start, &stop_type, &stop);
/* convert the seek positions to bytes */
if (start_type != GST_SEEK_TYPE_NONE) {
start = gst_util_uint64_scale (start, bitrate, 8 * GST_SECOND);
}
if (stop_type != GST_SEEK_TYPE_NONE) {
stop = gst_util_uint64_scale (stop, bitrate, 8 * GST_SECOND);
}
sevent = gst_event_new_seek (rate, GST_FORMAT_BYTES, flags,
start_type, start, stop_type, stop);
res = gst_pad_push_event (ogg->sinkpad, sevent);
} else {
res = FALSE;
}
return res;
} }
static gboolean static gboolean
@ -2284,7 +2315,7 @@ gst_ogg_demux_perform_seek (GstOggDemux * ogg, GstEvent * event)
/* finds each bitstream link one at a time using a bisection search /* 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). * (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 * Recurses for each link so it can alloc the link storage after
* finding them all, then unroll and fill the cache at the same time * finding them all, then unroll and fill the cache at the same time
*/ */
static GstFlowReturn static GstFlowReturn
gst_ogg_demux_bisect_forward_serialno (GstOggDemux * ogg, gst_ogg_demux_bisect_forward_serialno (GstOggDemux * ogg,