dashdemux: make timestamps start from 0
Non-live streams should timestamp buffers with a running-time starting from 0. Since we already push a 0 -> -1 segment, bring the timestamps to 0 by subtracting the initial timestamp.
This commit is contained in:
parent
4ab58e0fb1
commit
4f9f0b84cf
@ -1119,7 +1119,6 @@ gst_dash_demux_stream_loop (GstDashDemux * demux)
|
|||||||
|
|
||||||
if (selected_stream) {
|
if (selected_stream) {
|
||||||
GstDataQueueItem *item;
|
GstDataQueueItem *item;
|
||||||
GstBuffer *buffer;
|
|
||||||
|
|
||||||
GST_DEBUG_OBJECT (demux, "Selected stream %p %d", selected_stream,
|
GST_DEBUG_OBJECT (demux, "Selected stream %p %d", selected_stream,
|
||||||
selected_stream->index);
|
selected_stream->index);
|
||||||
@ -1128,11 +1127,19 @@ gst_dash_demux_stream_loop (GstDashDemux * demux)
|
|||||||
goto end;
|
goto end;
|
||||||
|
|
||||||
if (G_LIKELY (GST_IS_BUFFER (item->object))) {
|
if (G_LIKELY (GST_IS_BUFFER (item->object))) {
|
||||||
|
GstBuffer *buffer;
|
||||||
|
GstClockTime timestamp;
|
||||||
|
|
||||||
buffer = GST_BUFFER_CAST (item->object);
|
buffer = GST_BUFFER_CAST (item->object);
|
||||||
active_stream =
|
active_stream =
|
||||||
gst_mpdparser_get_active_stream_by_index (demux->client,
|
gst_mpdparser_get_active_stream_by_index (demux->client,
|
||||||
selected_stream->index);
|
selected_stream->index);
|
||||||
|
|
||||||
|
timestamp = GST_BUFFER_TIMESTAMP (buffer);
|
||||||
|
|
||||||
if (demux->need_segment) {
|
if (demux->need_segment) {
|
||||||
|
demux->timestamp_offset = timestamp;
|
||||||
|
|
||||||
/* And send a newsegment */
|
/* And send a newsegment */
|
||||||
for (iter = demux->streams; iter; iter = g_slist_next (iter)) {
|
for (iter = demux->streams; iter; iter = g_slist_next (iter)) {
|
||||||
GstDashDemuxStream *stream = iter->data;
|
GstDashDemuxStream *stream = iter->data;
|
||||||
@ -1143,11 +1150,14 @@ gst_dash_demux_stream_loop (GstDashDemux * demux)
|
|||||||
}
|
}
|
||||||
demux->need_segment = FALSE;
|
demux->need_segment = FALSE;
|
||||||
}
|
}
|
||||||
|
/* make timestamp start from 0 by subtracting the offset */
|
||||||
|
timestamp -= demux->timestamp_offset;
|
||||||
|
|
||||||
|
GST_BUFFER_TIMESTAMP (buffer) = timestamp;
|
||||||
|
|
||||||
GST_DEBUG_OBJECT (demux,
|
GST_DEBUG_OBJECT (demux,
|
||||||
"Pushing fragment ts: %" GST_TIME_FORMAT " at pad %s",
|
"Pushing fragment ts: %" GST_TIME_FORMAT " at pad %s",
|
||||||
GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (buffer)),
|
GST_TIME_ARGS (timestamp), GST_PAD_NAME (selected_stream->pad));
|
||||||
GST_PAD_NAME (selected_stream->pad));
|
|
||||||
#if 0
|
#if 0
|
||||||
GST_DEBUG_OBJECT (demux,
|
GST_DEBUG_OBJECT (demux,
|
||||||
"Pushing fragment %p #%d (stream %i) ts:%" GST_TIME_FORMAT " dur:%"
|
"Pushing fragment %p #%d (stream %i) ts:%" GST_TIME_FORMAT " dur:%"
|
||||||
@ -1157,8 +1167,8 @@ gst_dash_demux_stream_loop (GstDashDemux * demux)
|
|||||||
GST_DEBUG_PAD_NAME (selected_stream->pad));
|
GST_DEBUG_PAD_NAME (selected_stream->pad));
|
||||||
#endif
|
#endif
|
||||||
ret = gst_pad_push (selected_stream->pad, gst_buffer_ref (buffer));
|
ret = gst_pad_push (selected_stream->pad, gst_buffer_ref (buffer));
|
||||||
gst_segment_set_last_stop (&demux->segment, GST_FORMAT_TIME,
|
gst_segment_set_last_stop (&demux->segment, GST_FORMAT_TIME, timestamp);
|
||||||
GST_BUFFER_TIMESTAMP (buffer));
|
|
||||||
item->destroy (item);
|
item->destroy (item);
|
||||||
if ((ret != GST_FLOW_OK) && (active_stream
|
if ((ret != GST_FLOW_OK) && (active_stream
|
||||||
&& active_stream->mimeType == GST_STREAM_VIDEO))
|
&& active_stream->mimeType == GST_STREAM_VIDEO))
|
||||||
|
@ -112,6 +112,7 @@ struct _GstDashDemux
|
|||||||
|
|
||||||
GstSegment segment;
|
GstSegment segment;
|
||||||
gboolean need_segment;
|
gboolean need_segment;
|
||||||
|
GstClockTime timestamp_offset;
|
||||||
|
|
||||||
GstBuffer *manifest;
|
GstBuffer *manifest;
|
||||||
GstUriDownloader *downloader;
|
GstUriDownloader *downloader;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user