diff options
author | Edward Hervey <bilboed@bilboed.com> | 2009-06-28 17:43:12 +0200 |
---|---|---|
committer | Edward Hervey <bilboed@bilboed.com> | 2009-06-28 17:52:38 +0200 |
commit | d451dff520a8459cff2c766a777f7b99e91b7f92 (patch) | |
tree | b90cab1d44d63d9fbfb133ba9b33a1e6c2357d23 | |
parent | 3b63c95450973da5b5dd6c6cb595569dbea0faf9 (diff) |
asfdemux: Delay newsegment handling until we have a keyframe.
We now have a chance for packets to be collected before we send out the
newsegment. If we're not in accurate seeking (keyunit) it will set
the segment start/time to the keyframe's timestamp.
-rw-r--r-- | gst/asfdemux/gstasfdemux.c | 77 |
1 files changed, 43 insertions, 34 deletions
diff --git a/gst/asfdemux/gstasfdemux.c b/gst/asfdemux/gstasfdemux.c index 0673b41b..8b76265a 100644 --- a/gst/asfdemux/gstasfdemux.c +++ b/gst/asfdemux/gstasfdemux.c @@ -1219,52 +1219,61 @@ gst_asf_demux_push_complete_payloads (GstASFDemux * demux, gboolean force) /* streams are now activated */ } - /* do we need to send a newsegment event */ - if (demux->need_newsegment) { + /* wait until we had a chance to "lock on" some payload's timestamp */ + if (G_UNLIKELY (demux->need_newsegment + && !GST_CLOCK_TIME_IS_VALID (demux->segment_ts))) + return GST_FLOW_OK; + + while ((stream = gst_asf_demux_find_stream_with_complete_payload (demux))) { + AsfPayload *payload; + + payload = &g_array_index (stream->payloads, AsfPayload, 0); + + /* do we need to send a newsegment event */ + if ((G_UNLIKELY (demux->need_newsegment))) { - /* wait until we had a chance to "lock on" some payload's timestamp */ - if (!GST_CLOCK_TIME_IS_VALID (demux->segment_ts)) - return GST_FLOW_OK; - else { /* safe default if insufficient upstream info */ if (!GST_CLOCK_TIME_IS_VALID (demux->in_gap)) demux->in_gap = 0; - } - if (demux->segment.stop == GST_CLOCK_TIME_NONE && - demux->segment.duration > 0) { - /* slight HACK; prevent clipping of last bit */ - demux->segment.stop = demux->segment.duration + demux->in_gap; - } + if (demux->segment.stop == GST_CLOCK_TIME_NONE && + demux->segment.duration > 0) { + /* slight HACK; prevent clipping of last bit */ + demux->segment.stop = demux->segment.duration + demux->in_gap; + } - GST_DEBUG_OBJECT (demux, "sending new-segment event %" GST_SEGMENT_FORMAT, - &demux->segment); + /* FIXME : only if ACCURATE ! */ + if (G_LIKELY (!demux->accurate + && (GST_CLOCK_TIME_IS_VALID (payload->ts)))) { + GST_DEBUG ("Adjusting newsegment start to %" GST_TIME_FORMAT, + GST_TIME_ARGS (payload->ts)); + demux->segment.start = payload->ts; + demux->segment.time = payload->ts; + } - /* note: we fix up all timestamps to start from 0, so this should be ok */ - gst_asf_demux_send_event_unlocked (demux, - gst_event_new_new_segment (FALSE, demux->segment.rate, - GST_FORMAT_TIME, demux->segment.start, demux->segment.stop, - demux->segment.start)); + GST_DEBUG_OBJECT (demux, "sending new-segment event %" GST_SEGMENT_FORMAT, + &demux->segment); - /* now post any global tags we may have found */ - if (demux->taglist == NULL) - demux->taglist = gst_tag_list_new (); + /* note: we fix up all timestamps to start from 0, so this should be ok */ + gst_asf_demux_send_event_unlocked (demux, + gst_event_new_new_segment (FALSE, demux->segment.rate, + GST_FORMAT_TIME, demux->segment.start, demux->segment.stop, + demux->segment.start)); - gst_tag_list_add (demux->taglist, GST_TAG_MERGE_REPLACE, - GST_TAG_CONTAINER_FORMAT, "ASF", NULL); + /* now post any global tags we may have found */ + if (demux->taglist == NULL) + demux->taglist = gst_tag_list_new (); - GST_DEBUG_OBJECT (demux, "global tags: %" GST_PTR_FORMAT, demux->taglist); - gst_element_found_tags (GST_ELEMENT (demux), demux->taglist); - demux->taglist = NULL; + gst_tag_list_add (demux->taglist, GST_TAG_MERGE_REPLACE, + GST_TAG_CONTAINER_FORMAT, "ASF", NULL); - demux->need_newsegment = FALSE; - demux->segment_running = TRUE; - } + GST_DEBUG_OBJECT (demux, "global tags: %" GST_PTR_FORMAT, demux->taglist); + gst_element_found_tags (GST_ELEMENT (demux), demux->taglist); + demux->taglist = NULL; - while ((stream = gst_asf_demux_find_stream_with_complete_payload (demux))) { - AsfPayload *payload; - - payload = &g_array_index (stream->payloads, AsfPayload, 0); + demux->need_newsegment = FALSE; + demux->segment_running = TRUE; + } /* Do we have tags pending for this stream? */ if (stream->pending_tags) { |