From 160f666981d47c549cb42a0759ddb8712791e9ad Mon Sep 17 00:00:00 2001 From: Sebastian Dröge Date: Mon, 17 Apr 2017 14:43:49 +0300 Subject: dashdemux: Use correct (sub) fragment start when clipping chunk size If we didn't download anything yet, we shouldn't use fragment.start but the start position of the current sidx entry. --- ext/dash/gstdashdemux.c | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/ext/dash/gstdashdemux.c b/ext/dash/gstdashdemux.c index 0eadbcc6c..94b25a868 100644 --- a/ext/dash/gstdashdemux.c +++ b/ext/dash/gstdashdemux.c @@ -2701,20 +2701,23 @@ gst_dash_demux_need_another_chunk (GstAdaptiveDemuxStream * stream) if (gst_mpd_client_has_isoff_ondemand_profile (dashdemux->client) && dashstream->sidx_parser.sidx.entries) { - guint64 sidx_end_offset = + guint64 sidx_start_offset = dashstream->sidx_base_offset + - SIDX_CURRENT_ENTRY (dashstream)->offset + - SIDX_CURRENT_ENTRY (dashstream)->size; + SIDX_CURRENT_ENTRY (dashstream)->offset; + guint64 sidx_end_offset = + sidx_start_offset + SIDX_CURRENT_ENTRY (dashstream)->size; guint64 downloaded_end_offset; if (dashstream->current_offset == GST_CLOCK_TIME_NONE) { - downloaded_end_offset = stream->fragment.range_start; + downloaded_end_offset = sidx_start_offset; } else { downloaded_end_offset = dashstream->current_offset + gst_adapter_available (dashstream->adapter); } + downloaded_end_offset = MAX (downloaded_end_offset, sidx_start_offset); + if (stream->fragment.chunk_size + downloaded_end_offset > sidx_end_offset) { stream->fragment.chunk_size = sidx_end_offset - downloaded_end_offset; @@ -2731,13 +2734,9 @@ gst_dash_demux_need_another_chunk (GstAdaptiveDemuxStream * stream) guint64 end_offset = sync_sample->end_offset + 1; guint64 downloaded_end_offset; - if (dashstream->current_offset == GST_CLOCK_TIME_NONE) { - downloaded_end_offset = stream->fragment.range_start; - } else { - downloaded_end_offset = - dashstream->current_offset + - gst_adapter_available (dashstream->adapter); - } + downloaded_end_offset = + dashstream->current_offset + + gst_adapter_available (dashstream->adapter); if (gst_mpd_client_has_isoff_ondemand_profile (dashdemux->client) && dashstream->sidx_parser.sidx.entries) { -- cgit v1.2.3