From cfcd9ffac631bd019b33444add5fda8d126628d7 Mon Sep 17 00:00:00 2001 From: Gianluca Gennari Date: Wed, 24 Oct 2012 14:24:05 +0200 Subject: [PATCH] dashdemux: reworked gst_dash_demux_get_buffering_time() to return the effective buffering time do not assume the Fragment duration is constant --- ext/dash/gstdashdemux.c | 29 +++++++++++++++++++++++------ 1 file changed, 23 insertions(+), 6 deletions(-) diff --git a/ext/dash/gstdashdemux.c b/ext/dash/gstdashdemux.c index baea346328..23826f61ce 100644 --- a/ext/dash/gstdashdemux.c +++ b/ext/dash/gstdashdemux.c @@ -174,10 +174,10 @@ enum }; /* Default values for properties */ -#define DEFAULT_MIN_BUFFERING_TIME 5 /* in seconds */ -#define DEFAULT_MAX_BUFFERING_TIME 30 /* in seconds */ -#define DEFAULT_BANDWIDTH_USAGE 0.8 /* 0 to 1 */ -#define DEFAULT_MAX_BITRATE 24000000 /* in Mbit/s */ +#define DEFAULT_MIN_BUFFERING_TIME 5 /* in seconds */ +#define DEFAULT_MAX_BUFFERING_TIME 30 /* in seconds */ +#define DEFAULT_BANDWIDTH_USAGE 0.8 /* 0 to 1 */ +#define DEFAULT_MAX_BITRATE 24000000 /* in bit/s */ #define DEFAULT_FAILED_COUNT 3 @@ -1076,8 +1076,25 @@ gst_dash_demux_reset (GstDashDemux * demux, gboolean dispose) static GstClockTime gst_dash_demux_get_buffering_time (GstDashDemux * demux) { - return (g_queue_get_length (demux->queue)) * - gst_mpd_client_get_target_duration (demux->client); + GstClockTime buffer_time = 0; + GList *listfragment; + GstFragment *first_fragment, *last_fragment; + + if (g_queue_is_empty (demux->queue)) + return 0; + + /* get first fragment */ + listfragment = g_queue_peek_head (demux->queue); + first_fragment = listfragment->data; + /* get last fragment */ + listfragment = g_queue_peek_tail (demux->queue); + last_fragment = listfragment->data; + + if (first_fragment && last_fragment) { + buffer_time = last_fragment->stop_time - first_fragment->start_time; + } + + return buffer_time; } static float