Add seeking support to asfdemux in push mode

Fixes bug #568836.
This commit is contained in:
Hans de Goede 2009-01-26 10:00:57 +01:00 committed by Sebastian Dröge
parent 4ff0d1fe52
commit 3bcd050fab
3 changed files with 32 additions and 4 deletions

View file

@ -127,6 +127,11 @@ gst_asf_payload_queue_for_stream (GstASFDemux * demux, AsfPayload * payload,
GST_DEBUG_OBJECT (demux, "first ts: %" GST_TIME_FORMAT, GST_DEBUG_OBJECT (demux, "first ts: %" GST_TIME_FORMAT,
GST_TIME_ARGS (payload->ts)); GST_TIME_ARGS (payload->ts));
demux->first_ts = payload->ts; demux->first_ts = payload->ts;
if (demux->push_mode) {
gst_segment_set_seek (&demux->segment, demux->segment.rate,
GST_FORMAT_TIME, demux->segment.flags, GST_SEEK_TYPE_SET,
demux->first_ts, GST_SEEK_TYPE_NONE, 0, NULL);
}
} }
/* better drop a few frames at the beginning than send bogus timestamps */ /* better drop a few frames at the beginning than send bogus timestamps */
@ -140,7 +145,8 @@ gst_asf_payload_queue_for_stream (GstASFDemux * demux, AsfPayload * payload,
} }
/* make timestamps start from 0 */ /* make timestamps start from 0 */
payload->ts -= demux->first_ts; if (!demux->push_mode)
payload->ts -= demux->first_ts;
/* remove any incomplete payloads that will never be completed */ /* remove any incomplete payloads that will never be completed */
while (stream->payloads->len > 0) { while (stream->payloads->len > 0) {

View file

@ -23,9 +23,6 @@
* - _loop(): * - _loop():
* stop if at end of segment if != end of file, ie. demux->segment.stop * stop if at end of segment if != end of file, ie. demux->segment.stop
* *
* - _chain(): fix newsegment events for live streams where timestamps don't
* start at zero (need sample files/streams for this)
*
* - fix packet parsing: * - fix packet parsing:
* there's something wrong with timestamps for packets with keyframes, * there's something wrong with timestamps for packets with keyframes,
* and durations too. * and durations too.
@ -264,6 +261,7 @@ gst_asf_demux_activate_push (GstPad * sinkpad, gboolean active)
demux = GST_ASF_DEMUX (GST_OBJECT_PARENT (sinkpad)); demux = GST_ASF_DEMUX (GST_OBJECT_PARENT (sinkpad));
demux->push_mode = TRUE;
demux->state = GST_ASF_DEMUX_STATE_HEADER; demux->state = GST_ASF_DEMUX_STATE_HEADER;
demux->streaming = TRUE; demux->streaming = TRUE;
@ -276,6 +274,7 @@ gst_asf_demux_activate_pull (GstPad * pad, gboolean active)
GstASFDemux *demux; GstASFDemux *demux;
demux = GST_ASF_DEMUX (GST_OBJECT_PARENT (pad)); demux = GST_ASF_DEMUX (GST_OBJECT_PARENT (pad));
demux->push_mode = FALSE;
if (active) { if (active) {
demux->state = GST_ASF_DEMUX_STATE_HEADER; demux->state = GST_ASF_DEMUX_STATE_HEADER;
@ -313,8 +312,17 @@ gst_asf_demux_sink_event (GstPad * pad, GstEvent * event)
} }
GST_OBJECT_LOCK (demux); GST_OBJECT_LOCK (demux);
if (demux->packet_size && newsegment_start > demux->data_offset)
demux->packet = (newsegment_start - demux->data_offset) /
demux->packet_size;
else
demux->packet = 0;
demux->first_ts = GST_CLOCK_TIME_NONE;
demux->need_newsegment = TRUE;
gst_asf_demux_reset_stream_state_after_discont (demux); gst_asf_demux_reset_stream_state_after_discont (demux);
GST_OBJECT_UNLOCK (demux); GST_OBJECT_UNLOCK (demux);
gst_event_unref (event);
break; break;
} }
case GST_EVENT_EOS:{ case GST_EVENT_EOS:{
@ -331,6 +339,14 @@ gst_asf_demux_sink_event (GstPad * pad, GstEvent * event)
break; break;
} }
case GST_EVENT_FLUSH_START:
case GST_EVENT_FLUSH_STOP:
GST_OBJECT_LOCK (demux);
gst_asf_demux_reset_stream_state_after_discont (demux);
GST_OBJECT_UNLOCK (demux);
gst_asf_demux_send_event_unlocked (demux, event);
break;
default: default:
ret = gst_pad_event_default (pad, event); ret = gst_pad_event_default (pad, event);
break; break;
@ -450,6 +466,11 @@ gst_asf_demux_handle_seek_event (GstASFDemux * demux, GstEvent * event)
accurate = ((flags & GST_SEEK_FLAG_ACCURATE) == GST_SEEK_FLAG_ACCURATE); accurate = ((flags & GST_SEEK_FLAG_ACCURATE) == GST_SEEK_FLAG_ACCURATE);
keyunit_sync = ((flags & GST_SEEK_FLAG_KEY_UNIT) == GST_SEEK_FLAG_KEY_UNIT); keyunit_sync = ((flags & GST_SEEK_FLAG_KEY_UNIT) == GST_SEEK_FLAG_KEY_UNIT);
if (demux->push_mode) {
gst_event_ref (event);
return gst_pad_push_event (demux->sinkpad, event);
}
/* unlock the streaming thread */ /* unlock the streaming thread */
if (flush) { if (flush) {
gst_pad_push_event (demux->sinkpad, gst_event_new_flush_start ()); gst_pad_push_event (demux->sinkpad, gst_event_new_flush_start ());

View file

@ -171,6 +171,7 @@ struct _GstASFDemux {
gboolean need_newsegment; /* do we need to send a new-segment event? */ gboolean need_newsegment; /* do we need to send a new-segment event? */
gboolean segment_running; /* if we've started the current segment */ gboolean segment_running; /* if we've started the current segment */
gboolean streaming; /* TRUE if we are operating chain-based */ gboolean streaming; /* TRUE if we are operating chain-based */
gboolean push_mode; /* are we operating in push_mode? */
/* Descrambler settings */ /* Descrambler settings */
guint8 span; guint8 span;