From b4d8c04f08dce9f720fd4df3237d4f9986f98c43 Mon Sep 17 00:00:00 2001 From: Mathieu Duponchelle Date: Mon, 2 Mar 2015 13:53:03 +0100 Subject: [PATCH] adaptivedemux: [API]: get_presentation_offset virtual method. Asks the subclass for a potential time offset to apply to each separate stream, in dash streams can have "presentation time offsets", which can be different for each stream. https://bugzilla.gnome.org/show_bug.cgi?id=745455 --- gst-libs/gst/adaptivedemux/gstadaptivedemux.c | 21 +++++++++++++++++++ gst-libs/gst/adaptivedemux/gstadaptivedemux.h | 12 +++++++++++ 2 files changed, 33 insertions(+) diff --git a/gst-libs/gst/adaptivedemux/gstadaptivedemux.c b/gst-libs/gst/adaptivedemux/gstadaptivedemux.c index 97eee51b98..e06c14bc37 100644 --- a/gst-libs/gst/adaptivedemux/gstadaptivedemux.c +++ b/gst-libs/gst/adaptivedemux/gstadaptivedemux.c @@ -701,6 +701,19 @@ gst_adaptive_demux_expose_stream (GstAdaptiveDemux * demux, return gst_element_add_pad (GST_ELEMENT_CAST (demux), pad); } +static GstClockTime +gst_adaptive_demux_stream_get_presentation_offset (GstAdaptiveDemux * demux, + GstAdaptiveDemuxStream * stream) +{ + GstAdaptiveDemuxClass *klass; + + klass = GST_ADAPTIVE_DEMUX_GET_CLASS (demux); + + g_return_val_if_fail (klass->get_presentation_offset, FALSE); + + return klass->get_presentation_offset (demux, stream); +} + static gboolean gst_adaptive_demux_expose_streams (GstAdaptiveDemux * demux, gboolean first_segment) @@ -741,8 +754,12 @@ gst_adaptive_demux_expose_streams (GstAdaptiveDemux * demux, min_pts; for (iter = demux->streams; iter; iter = g_list_next (iter)) { GstAdaptiveDemuxStream *stream = iter->data; + GstClockTime offset; + offset = gst_adaptive_demux_stream_get_presentation_offset (demux, stream); stream->segment = demux->segment; + stream->segment.start = stream->segment.position = + stream->fragment.timestamp + offset; stream->pending_segment = gst_event_new_segment (&stream->segment); } @@ -1347,6 +1364,8 @@ gst_adaptive_demux_stream_push_buffer (GstAdaptiveDemuxStream * stream, GstAdaptiveDemux *demux = stream->demux; GstFlowReturn ret = GST_FLOW_OK; gboolean discont = FALSE; + GstClockTime offset = + gst_adaptive_demux_stream_get_presentation_offset (demux, stream); if (stream->first_fragment_buffer) { if (demux->segment.rate < 0) @@ -1375,6 +1394,8 @@ gst_adaptive_demux_stream_push_buffer (GstAdaptiveDemuxStream * stream, stream->first_fragment_buffer = FALSE; + if (GST_BUFFER_PTS (buffer) != GST_CLOCK_TIME_NONE) + GST_BUFFER_PTS (buffer) += offset; GST_BUFFER_DURATION (buffer) = GST_CLOCK_TIME_NONE; GST_BUFFER_DTS (buffer) = GST_CLOCK_TIME_NONE; diff --git a/gst-libs/gst/adaptivedemux/gstadaptivedemux.h b/gst-libs/gst/adaptivedemux/gstadaptivedemux.h index 6169af7577..36e20ef7ea 100644 --- a/gst-libs/gst/adaptivedemux/gstadaptivedemux.h +++ b/gst-libs/gst/adaptivedemux/gstadaptivedemux.h @@ -377,6 +377,18 @@ struct _GstAdaptiveDemuxClass * Return: %TRUE if successful */ gboolean (*get_live_seek_range) (GstAdaptiveDemux * demux, gint64 * start, gint64 * stop); + + /** + * get_presentation_offset: + * @demux: #GstAdaptiveDemux + * @stream: #GstAdaptiveDemuxStream + * + * Gets the delay to apply to @stream. + * + * Return: a #GstClockTime representing the (positive) time offset to apply to + * @stream. + */ + GstClockTime (*get_presentation_offset) (GstAdaptiveDemux *demux, GstAdaptiveDemuxStream *stream); }; GType gst_adaptive_demux_get_type (void);