diff options
author | Edward Hervey <edward@centricular.com> | 2016-08-26 17:05:39 +0200 |
---|---|---|
committer | Edward Hervey <bilboed@bilboed.com> | 2016-08-26 17:05:39 +0200 |
commit | a830c13e622b1991eec5f0c36270c5e75d80384c (patch) | |
tree | e1671ea25507520b4482cc0598ba616761c53a2c | |
parent | 7898bc581053b1716e9d7ecaeb148ec8d60d1c29 (diff) |
WIP: dashdemux: Implement skipping propertydash-skip
NOTE/FIXME: This is not meant to be exposed/controllable. It's just
exposed for debugging purposes so far
When dealing with key-trick-mode use-cases, there are cases where we
want to be able to throttle the amount of keyframes downloaded. To do
that we use a "skipping" property, which specifies by how many keyframes
we should advance every-time.
The default value of 1 means we advance by 1 every time (i.e. get all
keyframes). 2 would only get 1 out of 2, etc...
-rw-r--r-- | ext/dash/gstdashdemux.c | 56 | ||||
-rw-r--r-- | ext/dash/gstdashdemux.h | 11 |
2 files changed, 59 insertions, 8 deletions
diff --git a/ext/dash/gstdashdemux.c b/ext/dash/gstdashdemux.c index 2b29a1de8..44f8bf37c 100644 --- a/ext/dash/gstdashdemux.c +++ b/ext/dash/gstdashdemux.c @@ -190,6 +190,7 @@ enum PROP_BANDWIDTH_USAGE, PROP_MAX_BITRATE, PROP_PRESENTATION_DELAY, + PROP_INCREMENT_VALUE, PROP_LAST }; @@ -198,6 +199,7 @@ enum #define DEFAULT_BANDWIDTH_USAGE 0.8 /* 0 to 1 */ #define DEFAULT_MAX_BITRATE 24000000 /* in bit/s */ #define DEFAULT_PRESENTATION_DELAY NULL /* zero */ +#define DEFAULT_INCREMENT_VALUE 1 /* read everything */ /* Clock drift compensation for live streams */ #define SLOW_CLOCK_UPDATE_INTERVAL (1000000 * 30 * 60) /* 30 minutes */ @@ -428,6 +430,12 @@ gst_dash_demux_class_init (GstDashDemuxClass * klass) DEFAULT_PRESENTATION_DELAY, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); + g_object_class_install_property (gobject_class, PROP_INCREMENT_VALUE, + g_param_spec_uint ("increment-value", "Increment Value", + "(DEBUG) By how much to increment when advancing in key-frame mode", + 1, G_MAXUINT, DEFAULT_INCREMENT_VALUE, + G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); + gst_element_class_add_static_pad_template (gstelement_class, &gst_dash_demux_audiosrc_template); gst_element_class_add_static_pad_template (gstelement_class, @@ -494,6 +502,8 @@ gst_dash_demux_init (GstDashDemux * demux) demux->max_bitrate = DEFAULT_MAX_BITRATE; demux->default_presentation_delay = DEFAULT_PRESENTATION_DELAY; + demux->increment_value = DEFAULT_INCREMENT_VALUE; + g_mutex_init (&demux->client_lock); gst_adaptive_demux_set_stream_struct_size (GST_ADAPTIVE_DEMUX_CAST (demux), @@ -521,6 +531,9 @@ gst_dash_demux_set_property (GObject * object, guint prop_id, g_free (demux->default_presentation_delay); demux->default_presentation_delay = g_value_dup_string (value); break; + case PROP_INCREMENT_VALUE: + demux->increment_value = g_value_get_uint (value); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; @@ -550,6 +563,9 @@ gst_dash_demux_get_property (GObject * object, guint prop_id, GValue * value, else g_value_set_string (value, demux->default_presentation_delay); break; + case PROP_INCREMENT_VALUE: + g_value_set_uint (value, demux->increment_value); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; @@ -670,6 +686,10 @@ gst_dash_demux_setup_all_streams (GstDashDemux * demux) stream); } + /* FIXME : HARDCODED VALUES FOR DEBUGGIN */ + stream->increment_value = stream->increment_leftover = + demux->increment_value; + gst_isoff_sidx_parser_init (&stream->sidx_parser); if (gst_mpd_client_has_isoff_ondemand_profile (demux->client)) stream->sidx_adapter = gst_adapter_new (); @@ -1240,11 +1260,11 @@ gst_dash_demux_stream_has_next_sync_sample (GstAdaptiveDemuxStream * stream) && GST_ADAPTIVE_DEMUX (stream->demux)-> segment.flags & GST_SEGMENT_FLAG_TRICKMODE_KEY_UNITS) { if (stream->demux->segment.rate > 0.0) { - if (dashstream->current_sync_sample + 1 < + if (dashstream->current_sync_sample + dashstream->increment_leftover < dashstream->moof_sync_samples->len) return TRUE; } else { - if (dashstream->current_sync_sample >= 1) + if (dashstream->current_sync_sample >= dashstream->increment_leftover) return TRUE; } } @@ -1259,7 +1279,8 @@ gst_dash_demux_stream_has_next_subfragment (GstAdaptiveDemuxStream * stream) if (dashstream->sidx_parser.status == GST_ISOFF_SIDX_PARSER_FINISHED) { if (stream->demux->segment.rate > 0.0) { - if (sidx->entry_index + 1 < sidx->entries_count) + if (sidx->entry_index + dashstream->increment_leftover < + sidx->entries_count) return TRUE; } else { if (sidx->entry_index >= 1) @@ -1275,15 +1296,28 @@ gst_dash_demux_stream_advance_sync_sample (GstAdaptiveDemuxStream * stream) GstDashDemuxStream *dashstream = (GstDashDemuxStream *) stream; gboolean fragment_finished = FALSE; + GST_DEBUG_OBJECT (stream->pad, + "Advancing sync sample #%d/#%d leftover:%d", + dashstream->current_sync_sample, + dashstream->moof_sync_samples->len, dashstream->increment_leftover); + if (dashstream->moof_sync_samples && GST_ADAPTIVE_DEMUX (stream->demux)-> segment.flags & GST_SEGMENT_FLAG_TRICKMODE_KEY_UNITS) { if (stream->demux->segment.rate > 0.0) { - dashstream->current_sync_sample++; + if (dashstream->current_sync_sample == -1) + dashstream->current_sync_sample = dashstream->increment_leftover; + else + dashstream->current_sync_sample += dashstream->increment_leftover; if (dashstream->current_sync_sample >= dashstream->moof_sync_samples->len) { fragment_finished = TRUE; - } + dashstream->increment_leftover = + dashstream->current_sync_sample - + dashstream->moof_sync_samples->len + 1; + } else + dashstream->increment_leftover = dashstream->increment_value; } else { + /* FIXME : REVERSE INCREMENT HANDLING !! */ if (dashstream->current_sync_sample == -1) { dashstream->current_sync_sample = dashstream->moof_sync_samples->len - 1; @@ -1297,8 +1331,9 @@ gst_dash_demux_stream_advance_sync_sample (GstAdaptiveDemuxStream * stream) } GST_DEBUG_OBJECT (stream->pad, - "Advancing sync sample #%d fragment_finished:%d", - dashstream->current_sync_sample, fragment_finished); + "Advanced sync sample #%d/#%d fragment_finished:%d", + dashstream->current_sync_sample, + dashstream->moof_sync_samples->len, fragment_finished); if (!fragment_finished) stream->discont = TRUE; @@ -2365,12 +2400,17 @@ gst_dash_demux_handle_isobmff_buffer (GstAdaptiveDemux * demux, GST_ADAPTIVE_DEMUX (stream->demux)-> segment.flags & GST_SEGMENT_FLAG_TRICKMODE_KEY_UNITS) { - if (dash_stream->first_sync_sample_after_moof) { + if (dash_stream->first_sync_sample_after_moof && + dash_stream->increment_value == dash_stream->increment_leftover) { /* If we're here, don't throw away data but collect sync * sample while we're at it below. We're doing chunked * downloading so might need to adjust the next chunk size for * the remainder */ dash_stream->current_sync_sample = 0; + GST_DEBUG ("current #%d / %d (skip %d)", + dash_stream->current_sync_sample, + dash_stream->moof_sync_samples->len, + dash_stream->increment_leftover); } else { gst_adapter_clear (dash_stream->isobmff_adapter); } diff --git a/ext/dash/gstdashdemux.h b/ext/dash/gstdashdemux.h index e32b7b4a8..7678c0355 100644 --- a/ext/dash/gstdashdemux.h +++ b/ext/dash/gstdashdemux.h @@ -96,6 +96,13 @@ struct _GstDashDemuxStream guint64 moof_average_size, first_sync_sample_average_size; gboolean first_sync_sample_after_moof, first_sync_sample_always_after_moof; + + /* By how much we should advance for the next sync_sample. + * Default is 1, which means we advance normally */ + guint32 increment_value; + /* Actual value used for increments, gets resetted to increment_value + * once it reaches 0 */ + guint32 increment_leftover; }; /** @@ -128,6 +135,10 @@ struct _GstDashDemux gboolean trickmode_no_audio; gboolean allow_trickmode_key_units; + + /* By how much we should advance for the next sync_sample. + * Default is 1, which means we advance normally */ + guint32 increment_value; }; struct _GstDashDemuxClass |