summaryrefslogtreecommitdiff
path: root/ext/hls
diff options
context:
space:
mode:
authorHosang Lee <hosang10.lee@lge.com>2017-11-25 22:24:39 +0900
committerNicolas Dufresne <nicolas.dufresne@collabora.com>2017-12-06 15:02:40 -0500
commit6a5bae5343305b0284cd79d5081ba92c272a519b (patch)
treed74609931f9201f8c802b2634791fe0048b374b1 /ext/hls
parent9667ba688ee590fc36098d4bda78df72a173205a (diff)
downloadgstreamer-plugins-bad-6a5bae5343305b0284cd79d5081ba92c272a519b.tar.gz
m3u8: Parse and use AVERAGE-BANDWIDTH attribute if available
The AVERAGE-BANDWIDTH attribute in the EXT-X-STREAM-INF tag represents the average segment bit rate of the Variant Stream, while the BANDWIDTH attribute represents the peak segment bit rate of the Variant Stream. (https://tools.ietf.org/html/draft-pantos-http-live-streaming-23#section-4.3.4.2) Using the average bit rate instead of the peak bit rate for variant switching is more efficient and appropriate. Sometimes due to VBR encoding, the BANDWIDTH may represent a value way above the average bit rate, which could result to players not switching to that variant stream although network bandwidth is sufficiently available. https://bugzilla.gnome.org/show_bug.cgi?id=790821
Diffstat (limited to 'ext/hls')
-rw-r--r--ext/hls/m3u8.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/ext/hls/m3u8.c b/ext/hls/m3u8.c
index 1d210c325..594a963eb 100644
--- a/ext/hls/m3u8.c
+++ b/ext/hls/m3u8.c
@@ -1529,8 +1529,15 @@ gst_hls_master_playlist_new_from_data (gchar * data, const gchar * base_uri)
data += stream->iframe ? 26 : 18;
while (data && parse_attributes (&data, &a, &v)) {
if (g_str_equal (a, "BANDWIDTH")) {
+ if (!stream->bandwidth) {
+ if (!int_from_string (v, NULL, &stream->bandwidth))
+ GST_WARNING ("Error while reading BANDWIDTH");
+ }
+ } else if (g_str_equal (a, "AVERAGE-BANDWIDTH")) {
+ GST_DEBUG
+ ("AVERAGE-BANDWIDTH attribute available. Using it as stream bandwidth");
if (!int_from_string (v, NULL, &stream->bandwidth))
- GST_WARNING ("Error while reading BANDWIDTH");
+ GST_WARNING ("Error while reading AVERAGE-BANDWIDTH");
} else if (g_str_equal (a, "PROGRAM-ID")) {
if (!int_from_string (v, NULL, &stream->program_id))
GST_WARNING ("Error while reading PROGRAM-ID");