From 28074e5c96da2f98cc57e1a99bd41a3d88e71871 Mon Sep 17 00:00:00 2001 From: koln67 <67125539+koln67@users.noreply.github.com> Date: Wed, 19 Aug 2020 18:17:21 +0000 Subject: [PATCH] [HLS] Add support for independent segments tag Fixes #564. --- .../output.m3u8 | 2 + .../output.m3u8 | 2 + .../test/testdata/av1-mp4-to-webm/output.m3u8 | 2 + .../av1-mp4-with-encryption/output.m3u8 | 2 + .../app/test/testdata/av1-mp4/output.m3u8 | 2 + .../av1-webm-with-encryption/output.m3u8 | 2 + .../app/test/testdata/av1-webm/output.m3u8 | 2 + .../app/test/testdata/avc-aac-ts/output.m3u8 | 2 + .../testdata/avc-ac3-ts-to-mp4/output.m3u8 | 2 + .../avc-ac3-ts-with-encryption/output.m3u8 | 2 + .../app/test/testdata/avc-ac3-ts/output.m3u8 | 2 + .../output.m3u8 | 2 + .../output.m3u8 | 2 + .../avc-ts-event-playlist/output.m3u8 | 2 + .../output.m3u8 | 2 + .../output.m3u8 | 2 + .../testdata/avc-ts-live-playlist/output.m3u8 | 2 + .../output.m3u8 | 2 + .../output.m3u8 | 2 + .../avc-ts-with-encryption/output.m3u8 | 2 + .../testdata/bandwidth-override/output.m3u8 | 2 + .../output.m3u8 | 2 + .../output.m3u8 | 2 + .../output.m3u8 | 2 + .../ec3-packed-audio-encrypted/output.m3u8 | 2 + .../output.m3u8 | 2 + .../encryption-and-ad-cues/output.m3u8 | 2 + .../encryption-with-multi-drms/output.m3u8 | 2 + .../testdata/flac-with-encryption/output.m3u8 | 2 + .../hdr10-with-encryption/output.m3u8 | 2 + .../output.m3u8 | 2 + .../output.m3u8 | 2 + .../hls-only-dash-only-captions/output.m3u8 | 2 + .../testdata/hls-only-dash-only/output.m3u8 | 2 + .../testdata/hls-segmented-webvtt/output.m3u8 | 2 + .../output.m3u8 | 2 + .../live-profile-with-webm/output.m3u8 | 2 + .../testdata/mp4-trailing-moov/output.m3u8 | 2 + .../video-non-square-pixel/output.m3u8 | 2 + .../vtt-text-to-mp4-with-ad-cues/output.m3u8 | 2 + packager/hls/base/master_playlist.cc | 10 ++- packager/hls/base/master_playlist.h | 4 +- packager/hls/base/master_playlist_unittest.cc | 73 ++++++++++++++----- packager/hls/base/simple_hls_notifier.cc | 3 +- .../hls/base/simple_hls_notifier_unittest.cc | 4 +- packager/hls/public/hls_params.h | 3 + packager/packager.cc | 4 +- 47 files changed, 157 insertions(+), 24 deletions(-) diff --git a/packager/app/test/testdata/audio-video-with-language-override-with-subtag/output.m3u8 b/packager/app/test/testdata/audio-video-with-language-override-with-subtag/output.m3u8 index e9d65fe8da..7ee03f5540 100644 --- a/packager/app/test/testdata/audio-video-with-language-override-with-subtag/output.m3u8 +++ b/packager/app/test/testdata/audio-video-with-language-override-with-subtag/output.m3u8 @@ -1,6 +1,8 @@ #EXTM3U ## Generated with https://github.com/google/shaka-packager version -- +#EXT-X-INDEPENDENT-SEGMENTS + #EXT-X-MEDIA:TYPE=AUDIO,URI="bear-640x360-audio.m3u8",GROUP-ID="default-audio-group",LANGUAGE="pt-BR",NAME="stream_0",AUTOSELECT=YES,CHANNELS="2" #EXT-X-STREAM-INF:BANDWIDTH=1106817,AVERAGE-BANDWIDTH=1004632,CODECS="avc1.64001e,mp4a.40.2",RESOLUTION=640x360,FRAME-RATE=29.970,AUDIO="default-audio-group" diff --git a/packager/app/test/testdata/audio-video-with-language-override/output.m3u8 b/packager/app/test/testdata/audio-video-with-language-override/output.m3u8 index 5b1d8b3b5e..d62e7e6c8b 100644 --- a/packager/app/test/testdata/audio-video-with-language-override/output.m3u8 +++ b/packager/app/test/testdata/audio-video-with-language-override/output.m3u8 @@ -1,6 +1,8 @@ #EXTM3U ## Generated with https://github.com/google/shaka-packager version -- +#EXT-X-INDEPENDENT-SEGMENTS + #EXT-X-MEDIA:TYPE=AUDIO,URI="bear-640x360-audio.m3u8",GROUP-ID="default-audio-group",LANGUAGE="pt",NAME="stream_0",DEFAULT=YES,AUTOSELECT=YES,CHANNELS="2" #EXT-X-STREAM-INF:BANDWIDTH=1106817,AVERAGE-BANDWIDTH=1004632,CODECS="avc1.64001e,mp4a.40.2",RESOLUTION=640x360,FRAME-RATE=29.970,AUDIO="default-audio-group" diff --git a/packager/app/test/testdata/av1-mp4-to-webm/output.m3u8 b/packager/app/test/testdata/av1-mp4-to-webm/output.m3u8 index 75cea099f4..2e7cbfa9b5 100644 --- a/packager/app/test/testdata/av1-mp4-to-webm/output.m3u8 +++ b/packager/app/test/testdata/av1-mp4-to-webm/output.m3u8 @@ -1,5 +1,7 @@ #EXTM3U ## Generated with https://github.com/google/shaka-packager version -- +#EXT-X-INDEPENDENT-SEGMENTS + #EXT-X-STREAM-INF:BANDWIDTH=69160,AVERAGE-BANDWIDTH=69160,CODECS="av01.0.00M.08",RESOLUTION=320x240,FRAME-RATE=29.970 stream_0.m3u8 diff --git a/packager/app/test/testdata/av1-mp4-with-encryption/output.m3u8 b/packager/app/test/testdata/av1-mp4-with-encryption/output.m3u8 index cbcc012795..5f1343fded 100644 --- a/packager/app/test/testdata/av1-mp4-with-encryption/output.m3u8 +++ b/packager/app/test/testdata/av1-mp4-with-encryption/output.m3u8 @@ -1,5 +1,7 @@ #EXTM3U ## Generated with https://github.com/google/shaka-packager version -- +#EXT-X-INDEPENDENT-SEGMENTS + #EXT-X-STREAM-INF:BANDWIDTH=69777,AVERAGE-BANDWIDTH=69777,CODECS="av01.0.00M.08",RESOLUTION=320x240,FRAME-RATE=29.970 stream_0.m3u8 diff --git a/packager/app/test/testdata/av1-mp4/output.m3u8 b/packager/app/test/testdata/av1-mp4/output.m3u8 index cbcc012795..5f1343fded 100644 --- a/packager/app/test/testdata/av1-mp4/output.m3u8 +++ b/packager/app/test/testdata/av1-mp4/output.m3u8 @@ -1,5 +1,7 @@ #EXTM3U ## Generated with https://github.com/google/shaka-packager version -- +#EXT-X-INDEPENDENT-SEGMENTS + #EXT-X-STREAM-INF:BANDWIDTH=69777,AVERAGE-BANDWIDTH=69777,CODECS="av01.0.00M.08",RESOLUTION=320x240,FRAME-RATE=29.970 stream_0.m3u8 diff --git a/packager/app/test/testdata/av1-webm-with-encryption/output.m3u8 b/packager/app/test/testdata/av1-webm-with-encryption/output.m3u8 index 6c7884e549..0e98dfd8b7 100644 --- a/packager/app/test/testdata/av1-webm-with-encryption/output.m3u8 +++ b/packager/app/test/testdata/av1-webm-with-encryption/output.m3u8 @@ -1,5 +1,7 @@ #EXTM3U ## Generated with https://github.com/google/shaka-packager version -- +#EXT-X-INDEPENDENT-SEGMENTS + #EXT-X-STREAM-INF:BANDWIDTH=69426,AVERAGE-BANDWIDTH=69426,CODECS="av01.0.00M.08",RESOLUTION=320x240,FRAME-RATE=30.303 stream_0.m3u8 diff --git a/packager/app/test/testdata/av1-webm/output.m3u8 b/packager/app/test/testdata/av1-webm/output.m3u8 index 32a6032b0f..44654d758c 100644 --- a/packager/app/test/testdata/av1-webm/output.m3u8 +++ b/packager/app/test/testdata/av1-webm/output.m3u8 @@ -1,5 +1,7 @@ #EXTM3U ## Generated with https://github.com/google/shaka-packager version -- +#EXT-X-INDEPENDENT-SEGMENTS + #EXT-X-STREAM-INF:BANDWIDTH=70752,AVERAGE-BANDWIDTH=70752,CODECS="av01.0.00M.08",RESOLUTION=320x240,FRAME-RATE=30.303 stream_0.m3u8 diff --git a/packager/app/test/testdata/avc-aac-ts/output.m3u8 b/packager/app/test/testdata/avc-aac-ts/output.m3u8 index d6e778dce2..ae7f43acf1 100644 --- a/packager/app/test/testdata/avc-aac-ts/output.m3u8 +++ b/packager/app/test/testdata/avc-aac-ts/output.m3u8 @@ -1,6 +1,8 @@ #EXTM3U ## Generated with https://github.com/google/shaka-packager version -- +#EXT-X-INDEPENDENT-SEGMENTS + #EXT-X-MEDIA:TYPE=AUDIO,URI="bear-640x360-audio.m3u8",GROUP-ID="default-audio-group",NAME="stream_0",AUTOSELECT=YES,CHANNELS="2" #EXT-X-STREAM-INF:BANDWIDTH=1217520,AVERAGE-BANDWIDTH=1117320,CODECS="avc1.64001e,mp4a.40.2",RESOLUTION=640x360,AUDIO="default-audio-group" diff --git a/packager/app/test/testdata/avc-ac3-ts-to-mp4/output.m3u8 b/packager/app/test/testdata/avc-ac3-ts-to-mp4/output.m3u8 index 00bd8f5b76..31ff0b2e81 100644 --- a/packager/app/test/testdata/avc-ac3-ts-to-mp4/output.m3u8 +++ b/packager/app/test/testdata/avc-ac3-ts-to-mp4/output.m3u8 @@ -1,6 +1,8 @@ #EXTM3U ## Generated with https://github.com/google/shaka-packager version -- +#EXT-X-INDEPENDENT-SEGMENTS + #EXT-X-MEDIA:TYPE=AUDIO,URI="bear-640x360-ac3-audio.m3u8",GROUP-ID="default-audio-group",NAME="stream_0",AUTOSELECT=YES,CHANNELS="2" #EXT-X-STREAM-INF:BANDWIDTH=1168321,AVERAGE-BANDWIDTH=1074156,CODECS="avc1.64001e,ac-3",RESOLUTION=640x360,FRAME-RATE=29.970,AUDIO="default-audio-group" diff --git a/packager/app/test/testdata/avc-ac3-ts-with-encryption/output.m3u8 b/packager/app/test/testdata/avc-ac3-ts-with-encryption/output.m3u8 index db9f321732..097f2676d9 100644 --- a/packager/app/test/testdata/avc-ac3-ts-with-encryption/output.m3u8 +++ b/packager/app/test/testdata/avc-ac3-ts-with-encryption/output.m3u8 @@ -1,6 +1,8 @@ #EXTM3U ## Generated with https://github.com/google/shaka-packager version -- +#EXT-X-INDEPENDENT-SEGMENTS + #EXT-X-MEDIA:TYPE=AUDIO,URI="bear-640x360-ac3-audio.m3u8",GROUP-ID="default-audio-group",NAME="stream_0",AUTOSELECT=YES,CHANNELS="2" #EXT-X-STREAM-INF:BANDWIDTH=1242863,AVERAGE-BANDWIDTH=1148679,CODECS="avc1.64001e,ac-3",RESOLUTION=640x360,AUDIO="default-audio-group" diff --git a/packager/app/test/testdata/avc-ac3-ts/output.m3u8 b/packager/app/test/testdata/avc-ac3-ts/output.m3u8 index db9f321732..097f2676d9 100644 --- a/packager/app/test/testdata/avc-ac3-ts/output.m3u8 +++ b/packager/app/test/testdata/avc-ac3-ts/output.m3u8 @@ -1,6 +1,8 @@ #EXTM3U ## Generated with https://github.com/google/shaka-packager version -- +#EXT-X-INDEPENDENT-SEGMENTS + #EXT-X-MEDIA:TYPE=AUDIO,URI="bear-640x360-ac3-audio.m3u8",GROUP-ID="default-audio-group",NAME="stream_0",AUTOSELECT=YES,CHANNELS="2" #EXT-X-STREAM-INF:BANDWIDTH=1242863,AVERAGE-BANDWIDTH=1148679,CODECS="avc1.64001e,ac-3",RESOLUTION=640x360,AUDIO="default-audio-group" diff --git a/packager/app/test/testdata/avc-ts-aac-packed-audio-with-encryption/output.m3u8 b/packager/app/test/testdata/avc-ts-aac-packed-audio-with-encryption/output.m3u8 index 18aac65af5..2b0ca67220 100644 --- a/packager/app/test/testdata/avc-ts-aac-packed-audio-with-encryption/output.m3u8 +++ b/packager/app/test/testdata/avc-ts-aac-packed-audio-with-encryption/output.m3u8 @@ -1,6 +1,8 @@ #EXTM3U ## Generated with https://github.com/google/shaka-packager version -- +#EXT-X-INDEPENDENT-SEGMENTS + #EXT-X-MEDIA:TYPE=AUDIO,URI="bear-640x360-audio.m3u8",GROUP-ID="default-audio-group",NAME="stream_0",AUTOSELECT=YES,CHANNELS="2" #EXT-X-STREAM-INF:BANDWIDTH=1154999,AVERAGE-BANDWIDTH=1054750,CODECS="avc1.64001e,mp4a.40.2",RESOLUTION=640x360,AUDIO="default-audio-group" diff --git a/packager/app/test/testdata/avc-ts-ac3-packed-audio-with-encryption/output.m3u8 b/packager/app/test/testdata/avc-ts-ac3-packed-audio-with-encryption/output.m3u8 index 0ca6fd46d5..e77a2f0b5c 100644 --- a/packager/app/test/testdata/avc-ts-ac3-packed-audio-with-encryption/output.m3u8 +++ b/packager/app/test/testdata/avc-ts-ac3-packed-audio-with-encryption/output.m3u8 @@ -1,6 +1,8 @@ #EXTM3U ## Generated with https://github.com/google/shaka-packager version -- +#EXT-X-INDEPENDENT-SEGMENTS + #EXT-X-MEDIA:TYPE=AUDIO,URI="bear-640x360-ac3-audio.m3u8",GROUP-ID="default-audio-group",NAME="stream_0",AUTOSELECT=YES,CHANNELS="2" #EXT-X-STREAM-INF:BANDWIDTH=1216578,AVERAGE-BANDWIDTH=1122532,CODECS="avc1.64001e,ac-3",RESOLUTION=640x360,AUDIO="default-audio-group" diff --git a/packager/app/test/testdata/avc-ts-event-playlist/output.m3u8 b/packager/app/test/testdata/avc-ts-event-playlist/output.m3u8 index d6e778dce2..ae7f43acf1 100644 --- a/packager/app/test/testdata/avc-ts-event-playlist/output.m3u8 +++ b/packager/app/test/testdata/avc-ts-event-playlist/output.m3u8 @@ -1,6 +1,8 @@ #EXTM3U ## Generated with https://github.com/google/shaka-packager version -- +#EXT-X-INDEPENDENT-SEGMENTS + #EXT-X-MEDIA:TYPE=AUDIO,URI="bear-640x360-audio.m3u8",GROUP-ID="default-audio-group",NAME="stream_0",AUTOSELECT=YES,CHANNELS="2" #EXT-X-STREAM-INF:BANDWIDTH=1217520,AVERAGE-BANDWIDTH=1117320,CODECS="avc1.64001e,mp4a.40.2",RESOLUTION=640x360,AUDIO="default-audio-group" diff --git a/packager/app/test/testdata/avc-ts-live-playlist-dash-dynamic-with-segment-deletion/output.m3u8 b/packager/app/test/testdata/avc-ts-live-playlist-dash-dynamic-with-segment-deletion/output.m3u8 index bd66ab30ce..eba3cb65c3 100644 --- a/packager/app/test/testdata/avc-ts-live-playlist-dash-dynamic-with-segment-deletion/output.m3u8 +++ b/packager/app/test/testdata/avc-ts-live-playlist-dash-dynamic-with-segment-deletion/output.m3u8 @@ -1,6 +1,8 @@ #EXTM3U ## Generated with https://github.com/google/shaka-packager version -- +#EXT-X-INDEPENDENT-SEGMENTS + #EXT-X-MEDIA:TYPE=AUDIO,URI="bear-640x360-audio.m3u8",GROUP-ID="default-audio-group",NAME="stream_0",AUTOSELECT=YES,CHANNELS="2" #EXT-X-STREAM-INF:BANDWIDTH=133850,AVERAGE-BANDWIDTH=126393,CODECS="mp4a.40.2",AUDIO="default-audio-group" diff --git a/packager/app/test/testdata/avc-ts-live-playlist-with-key-rotation/output.m3u8 b/packager/app/test/testdata/avc-ts-live-playlist-with-key-rotation/output.m3u8 index d6e778dce2..ae7f43acf1 100644 --- a/packager/app/test/testdata/avc-ts-live-playlist-with-key-rotation/output.m3u8 +++ b/packager/app/test/testdata/avc-ts-live-playlist-with-key-rotation/output.m3u8 @@ -1,6 +1,8 @@ #EXTM3U ## Generated with https://github.com/google/shaka-packager version -- +#EXT-X-INDEPENDENT-SEGMENTS + #EXT-X-MEDIA:TYPE=AUDIO,URI="bear-640x360-audio.m3u8",GROUP-ID="default-audio-group",NAME="stream_0",AUTOSELECT=YES,CHANNELS="2" #EXT-X-STREAM-INF:BANDWIDTH=1217520,AVERAGE-BANDWIDTH=1117320,CODECS="avc1.64001e,mp4a.40.2",RESOLUTION=640x360,AUDIO="default-audio-group" diff --git a/packager/app/test/testdata/avc-ts-live-playlist/output.m3u8 b/packager/app/test/testdata/avc-ts-live-playlist/output.m3u8 index d6e778dce2..ae7f43acf1 100644 --- a/packager/app/test/testdata/avc-ts-live-playlist/output.m3u8 +++ b/packager/app/test/testdata/avc-ts-live-playlist/output.m3u8 @@ -1,6 +1,8 @@ #EXTM3U ## Generated with https://github.com/google/shaka-packager version -- +#EXT-X-INDEPENDENT-SEGMENTS + #EXT-X-MEDIA:TYPE=AUDIO,URI="bear-640x360-audio.m3u8",GROUP-ID="default-audio-group",NAME="stream_0",AUTOSELECT=YES,CHANNELS="2" #EXT-X-STREAM-INF:BANDWIDTH=1217520,AVERAGE-BANDWIDTH=1117320,CODECS="avc1.64001e,mp4a.40.2",RESOLUTION=640x360,AUDIO="default-audio-group" diff --git a/packager/app/test/testdata/avc-ts-with-encryption-and-fairplay/output.m3u8 b/packager/app/test/testdata/avc-ts-with-encryption-and-fairplay/output.m3u8 index d6e778dce2..ae7f43acf1 100644 --- a/packager/app/test/testdata/avc-ts-with-encryption-and-fairplay/output.m3u8 +++ b/packager/app/test/testdata/avc-ts-with-encryption-and-fairplay/output.m3u8 @@ -1,6 +1,8 @@ #EXTM3U ## Generated with https://github.com/google/shaka-packager version -- +#EXT-X-INDEPENDENT-SEGMENTS + #EXT-X-MEDIA:TYPE=AUDIO,URI="bear-640x360-audio.m3u8",GROUP-ID="default-audio-group",NAME="stream_0",AUTOSELECT=YES,CHANNELS="2" #EXT-X-STREAM-INF:BANDWIDTH=1217520,AVERAGE-BANDWIDTH=1117320,CODECS="avc1.64001e,mp4a.40.2",RESOLUTION=640x360,AUDIO="default-audio-group" diff --git a/packager/app/test/testdata/avc-ts-with-encryption-exercise-emulation-prevention/output.m3u8 b/packager/app/test/testdata/avc-ts-with-encryption-exercise-emulation-prevention/output.m3u8 index 12ee20533f..9c0f04387d 100644 --- a/packager/app/test/testdata/avc-ts-with-encryption-exercise-emulation-prevention/output.m3u8 +++ b/packager/app/test/testdata/avc-ts-with-encryption-exercise-emulation-prevention/output.m3u8 @@ -1,6 +1,8 @@ #EXTM3U ## Generated with https://github.com/google/shaka-packager version -- +#EXT-X-INDEPENDENT-SEGMENTS + #EXT-X-STREAM-INF:BANDWIDTH=863296,AVERAGE-BANDWIDTH=390288,CODECS="avc1.64001f",RESOLUTION=1024x436 sintel-1024x436-video.m3u8 diff --git a/packager/app/test/testdata/avc-ts-with-encryption/output.m3u8 b/packager/app/test/testdata/avc-ts-with-encryption/output.m3u8 index d6e778dce2..ae7f43acf1 100644 --- a/packager/app/test/testdata/avc-ts-with-encryption/output.m3u8 +++ b/packager/app/test/testdata/avc-ts-with-encryption/output.m3u8 @@ -1,6 +1,8 @@ #EXTM3U ## Generated with https://github.com/google/shaka-packager version -- +#EXT-X-INDEPENDENT-SEGMENTS + #EXT-X-MEDIA:TYPE=AUDIO,URI="bear-640x360-audio.m3u8",GROUP-ID="default-audio-group",NAME="stream_0",AUTOSELECT=YES,CHANNELS="2" #EXT-X-STREAM-INF:BANDWIDTH=1217520,AVERAGE-BANDWIDTH=1117320,CODECS="avc1.64001e,mp4a.40.2",RESOLUTION=640x360,AUDIO="default-audio-group" diff --git a/packager/app/test/testdata/bandwidth-override/output.m3u8 b/packager/app/test/testdata/bandwidth-override/output.m3u8 index a8f552a931..29a57f300e 100644 --- a/packager/app/test/testdata/bandwidth-override/output.m3u8 +++ b/packager/app/test/testdata/bandwidth-override/output.m3u8 @@ -1,6 +1,8 @@ #EXTM3U ## Generated with https://github.com/google/shaka-packager version -- +#EXT-X-INDEPENDENT-SEGMENTS + #EXT-X-MEDIA:TYPE=AUDIO,URI="bear-640x360-audio.m3u8",GROUP-ID="default-audio-group",NAME="stream_0",AUTOSELECT=YES,CHANNELS="2" #EXT-X-STREAM-INF:BANDWIDTH=55555,AVERAGE-BANDWIDTH=1004632,CODECS="avc1.64001e,mp4a.40.2",RESOLUTION=640x360,FRAME-RATE=29.970,AUDIO="default-audio-group" diff --git a/packager/app/test/testdata/dolby-vision-profile-5-with-encryption/output.m3u8 b/packager/app/test/testdata/dolby-vision-profile-5-with-encryption/output.m3u8 index 36fd01d95c..a6bdbb2a3c 100644 --- a/packager/app/test/testdata/dolby-vision-profile-5-with-encryption/output.m3u8 +++ b/packager/app/test/testdata/dolby-vision-profile-5-with-encryption/output.m3u8 @@ -1,5 +1,7 @@ #EXTM3U ## Generated with https://github.com/google/shaka-packager version -- +#EXT-X-INDEPENDENT-SEGMENTS + #EXT-X-STREAM-INF:BANDWIDTH=820260,AVERAGE-BANDWIDTH=785273,CODECS="dvh1.05.01",RESOLUTION=640x360,FRAME-RATE=59.940,VIDEO-RANGE=PQ stream_0.m3u8 diff --git a/packager/app/test/testdata/dolby-vision-profile-8-with-encryption/output.m3u8 b/packager/app/test/testdata/dolby-vision-profile-8-with-encryption/output.m3u8 index a101fe73f2..b8a3a1bb95 100644 --- a/packager/app/test/testdata/dolby-vision-profile-8-with-encryption/output.m3u8 +++ b/packager/app/test/testdata/dolby-vision-profile-8-with-encryption/output.m3u8 @@ -1,6 +1,8 @@ #EXTM3U ## Generated with https://github.com/google/shaka-packager version -- +#EXT-X-INDEPENDENT-SEGMENTS + #EXT-X-STREAM-INF:BANDWIDTH=818598,AVERAGE-BANDWIDTH=755328,CODECS="hvc1.2.4.L90.90",RESOLUTION=640x360,FRAME-RATE=59.940,VIDEO-RANGE=PQ stream_0.m3u8 #EXT-X-STREAM-INF:BANDWIDTH=818598,AVERAGE-BANDWIDTH=755328,CODECS="dvh1.08.01",RESOLUTION=640x360,FRAME-RATE=59.940,VIDEO-RANGE=PQ diff --git a/packager/app/test/testdata/ec3-and-hls-single-segment-mp4-encrypted/output.m3u8 b/packager/app/test/testdata/ec3-and-hls-single-segment-mp4-encrypted/output.m3u8 index 1db8a4df84..e9f0f91a99 100644 --- a/packager/app/test/testdata/ec3-and-hls-single-segment-mp4-encrypted/output.m3u8 +++ b/packager/app/test/testdata/ec3-and-hls-single-segment-mp4-encrypted/output.m3u8 @@ -1,6 +1,8 @@ #EXTM3U ## Generated with https://github.com/google/shaka-packager version -- +#EXT-X-INDEPENDENT-SEGMENTS + #EXT-X-MEDIA:TYPE=AUDIO,URI="bear-640x360-ec3-audio.m3u8",GROUP-ID="default-audio-group",NAME="stream_0",AUTOSELECT=YES,CHANNELS="2" #EXT-X-STREAM-INF:BANDWIDTH=1174214,AVERAGE-BANDWIDTH=1061802,CODECS="avc1.64001e,ec-3",RESOLUTION=640x360,FRAME-RATE=9.990,AUDIO="default-audio-group" diff --git a/packager/app/test/testdata/ec3-packed-audio-encrypted/output.m3u8 b/packager/app/test/testdata/ec3-packed-audio-encrypted/output.m3u8 index 4233dd42a3..b805513ab3 100644 --- a/packager/app/test/testdata/ec3-packed-audio-encrypted/output.m3u8 +++ b/packager/app/test/testdata/ec3-packed-audio-encrypted/output.m3u8 @@ -1,6 +1,8 @@ #EXTM3U ## Generated with https://github.com/google/shaka-packager version -- +#EXT-X-INDEPENDENT-SEGMENTS + #EXT-X-MEDIA:TYPE=AUDIO,URI="bear-640x360-ec3-audio.m3u8",GROUP-ID="default-audio-group",NAME="stream_0",AUTOSELECT=YES,CHANNELS="2" #EXT-X-STREAM-INF:BANDWIDTH=1216655,AVERAGE-BANDWIDTH=1104925,CODECS="avc1.64001e,ec-3",RESOLUTION=640x360,AUDIO="default-audio-group" diff --git a/packager/app/test/testdata/encryption-and-ad-cues-split-content/output.m3u8 b/packager/app/test/testdata/encryption-and-ad-cues-split-content/output.m3u8 index d8bb42a8a9..0589741e88 100644 --- a/packager/app/test/testdata/encryption-and-ad-cues-split-content/output.m3u8 +++ b/packager/app/test/testdata/encryption-and-ad-cues-split-content/output.m3u8 @@ -1,6 +1,8 @@ #EXTM3U ## Generated with https://github.com/google/shaka-packager version -- +#EXT-X-INDEPENDENT-SEGMENTS + #EXT-X-MEDIA:TYPE=AUDIO,URI="bear-640x360-audio.m3u8",GROUP-ID="default-audio-group",NAME="stream_0",AUTOSELECT=YES,CHANNELS="2" #EXT-X-STREAM-INF:BANDWIDTH=1111200,AVERAGE-BANDWIDTH=1009412,CODECS="avc1.64001e,mp4a.40.2",RESOLUTION=640x360,FRAME-RATE=29.970,AUDIO="default-audio-group" diff --git a/packager/app/test/testdata/encryption-and-ad-cues/output.m3u8 b/packager/app/test/testdata/encryption-and-ad-cues/output.m3u8 index d8bb42a8a9..0589741e88 100644 --- a/packager/app/test/testdata/encryption-and-ad-cues/output.m3u8 +++ b/packager/app/test/testdata/encryption-and-ad-cues/output.m3u8 @@ -1,6 +1,8 @@ #EXTM3U ## Generated with https://github.com/google/shaka-packager version -- +#EXT-X-INDEPENDENT-SEGMENTS + #EXT-X-MEDIA:TYPE=AUDIO,URI="bear-640x360-audio.m3u8",GROUP-ID="default-audio-group",NAME="stream_0",AUTOSELECT=YES,CHANNELS="2" #EXT-X-STREAM-INF:BANDWIDTH=1111200,AVERAGE-BANDWIDTH=1009412,CODECS="avc1.64001e,mp4a.40.2",RESOLUTION=640x360,FRAME-RATE=29.970,AUDIO="default-audio-group" diff --git a/packager/app/test/testdata/encryption-with-multi-drms/output.m3u8 b/packager/app/test/testdata/encryption-with-multi-drms/output.m3u8 index ef6c35c353..dc8c2888eb 100644 --- a/packager/app/test/testdata/encryption-with-multi-drms/output.m3u8 +++ b/packager/app/test/testdata/encryption-with-multi-drms/output.m3u8 @@ -1,6 +1,8 @@ #EXTM3U ## Generated with https://github.com/google/shaka-packager version -- +#EXT-X-INDEPENDENT-SEGMENTS + #EXT-X-MEDIA:TYPE=AUDIO,URI="stream_0.m3u8",GROUP-ID="default-audio-group",NAME="stream_0",AUTOSELECT=YES,CHANNELS="2" #EXT-X-STREAM-INF:BANDWIDTH=1111406,AVERAGE-BANDWIDTH=1009412,CODECS="avc1.64001e,mp4a.40.2",RESOLUTION=640x360,FRAME-RATE=29.970,AUDIO="default-audio-group" diff --git a/packager/app/test/testdata/flac-with-encryption/output.m3u8 b/packager/app/test/testdata/flac-with-encryption/output.m3u8 index 08fc9157eb..acac518905 100644 --- a/packager/app/test/testdata/flac-with-encryption/output.m3u8 +++ b/packager/app/test/testdata/flac-with-encryption/output.m3u8 @@ -1,6 +1,8 @@ #EXTM3U ## Generated with https://github.com/google/shaka-packager version -- +#EXT-X-INDEPENDENT-SEGMENTS + #EXT-X-MEDIA:TYPE=AUDIO,URI="stream_0.m3u8",GROUP-ID="default-audio-group",NAME="stream_0",AUTOSELECT=YES,CHANNELS="2" #EXT-X-STREAM-INF:BANDWIDTH=672924,AVERAGE-BANDWIDTH=631380,CODECS="flac",AUDIO="default-audio-group" diff --git a/packager/app/test/testdata/hdr10-with-encryption/output.m3u8 b/packager/app/test/testdata/hdr10-with-encryption/output.m3u8 index a4217de48e..de9ba63db3 100644 --- a/packager/app/test/testdata/hdr10-with-encryption/output.m3u8 +++ b/packager/app/test/testdata/hdr10-with-encryption/output.m3u8 @@ -1,5 +1,7 @@ #EXTM3U ## Generated with https://github.com/google/shaka-packager version -- +#EXT-X-INDEPENDENT-SEGMENTS + #EXT-X-STREAM-INF:BANDWIDTH=317223,AVERAGE-BANDWIDTH=317223,CODECS="hvc1.2.4.L63.90",RESOLUTION=640x360,FRAME-RATE=29.970,VIDEO-RANGE=PQ stream_0.m3u8 diff --git a/packager/app/test/testdata/hls-audio-video-text-with-ad-cues/output.m3u8 b/packager/app/test/testdata/hls-audio-video-text-with-ad-cues/output.m3u8 index c42bc7cb6e..d0ecedb6ff 100644 --- a/packager/app/test/testdata/hls-audio-video-text-with-ad-cues/output.m3u8 +++ b/packager/app/test/testdata/hls-audio-video-text-with-ad-cues/output.m3u8 @@ -1,6 +1,8 @@ #EXTM3U ## Generated with https://github.com/google/shaka-packager version -- +#EXT-X-INDEPENDENT-SEGMENTS + #EXT-X-MEDIA:TYPE=AUDIO,URI="bear-640x360-audio.m3u8",GROUP-ID="default-audio-group",NAME="stream_1",AUTOSELECT=YES,CHANNELS="2" #EXT-X-MEDIA:TYPE=SUBTITLES,URI="bear-english-text.m3u8",GROUP-ID="default-text-group",NAME="stream_0",AUTOSELECT=YES diff --git a/packager/app/test/testdata/hls-multi-segment-mp4-with-custom-path/output.m3u8 b/packager/app/test/testdata/hls-multi-segment-mp4-with-custom-path/output.m3u8 index 71588c770b..4afd3b2540 100644 --- a/packager/app/test/testdata/hls-multi-segment-mp4-with-custom-path/output.m3u8 +++ b/packager/app/test/testdata/hls-multi-segment-mp4-with-custom-path/output.m3u8 @@ -1,6 +1,8 @@ #EXTM3U ## Generated with https://github.com/google/shaka-packager version -- +#EXT-X-INDEPENDENT-SEGMENTS + #EXT-X-MEDIA:TYPE=AUDIO,URI="audio/audio.m3u8",GROUP-ID="default-audio-group",NAME="stream_0",AUTOSELECT=YES,CHANNELS="2" #EXT-X-STREAM-INF:BANDWIDTH=1108051,AVERAGE-BANDWIDTH=1005999,CODECS="avc1.64001e,mp4a.40.2",RESOLUTION=640x360,FRAME-RATE=29.970,AUDIO="default-audio-group" diff --git a/packager/app/test/testdata/hls-only-dash-only-captions/output.m3u8 b/packager/app/test/testdata/hls-only-dash-only-captions/output.m3u8 index 6c732455fd..718bd865b5 100644 --- a/packager/app/test/testdata/hls-only-dash-only-captions/output.m3u8 +++ b/packager/app/test/testdata/hls-only-dash-only-captions/output.m3u8 @@ -1,6 +1,8 @@ #EXTM3U ## Generated with https://github.com/google/shaka-packager version -- +#EXT-X-INDEPENDENT-SEGMENTS + #EXT-X-MEDIA:TYPE=AUDIO,URI="stream_2.m3u8",GROUP-ID="default-audio-group",NAME="stream_2",AUTOSELECT=YES,CHANNELS="2" #EXT-X-MEDIA:TYPE=SUBTITLES,URI="stream_1.m3u8",GROUP-ID="default-text-group",NAME="stream_1",AUTOSELECT=YES diff --git a/packager/app/test/testdata/hls-only-dash-only/output.m3u8 b/packager/app/test/testdata/hls-only-dash-only/output.m3u8 index e0789dccf6..50dc9869f9 100644 --- a/packager/app/test/testdata/hls-only-dash-only/output.m3u8 +++ b/packager/app/test/testdata/hls-only-dash-only/output.m3u8 @@ -1,5 +1,7 @@ #EXTM3U ## Generated with https://github.com/google/shaka-packager version -- +#EXT-X-INDEPENDENT-SEGMENTS + #EXT-X-STREAM-INF:BANDWIDTH=973483,AVERAGE-BANDWIDTH=879459,CODECS="avc1.64001e",RESOLUTION=640x360,FRAME-RATE=29.970 stream_1.m3u8 diff --git a/packager/app/test/testdata/hls-segmented-webvtt/output.m3u8 b/packager/app/test/testdata/hls-segmented-webvtt/output.m3u8 index ed0e9b67d9..b73ecd3c65 100644 --- a/packager/app/test/testdata/hls-segmented-webvtt/output.m3u8 +++ b/packager/app/test/testdata/hls-segmented-webvtt/output.m3u8 @@ -1,6 +1,8 @@ #EXTM3U ## Generated with https://github.com/google/shaka-packager version -- +#EXT-X-INDEPENDENT-SEGMENTS + #EXT-X-MEDIA:TYPE=AUDIO,URI="stream_1.m3u8",GROUP-ID="default-audio-group",NAME="stream_1",AUTOSELECT=YES,CHANNELS="2" #EXT-X-MEDIA:TYPE=SUBTITLES,URI="stream_0.m3u8",GROUP-ID="default-text-group",NAME="stream_0",AUTOSELECT=YES,CHARACTERISTICS="public.accessibility.transcribes-spoken-dialog,private.accessibility.widevine-special" diff --git a/packager/app/test/testdata/hls-single-segment-mp4-encrypted/output.m3u8 b/packager/app/test/testdata/hls-single-segment-mp4-encrypted/output.m3u8 index 44e1c1beec..97639fc774 100644 --- a/packager/app/test/testdata/hls-single-segment-mp4-encrypted/output.m3u8 +++ b/packager/app/test/testdata/hls-single-segment-mp4-encrypted/output.m3u8 @@ -1,6 +1,8 @@ #EXTM3U ## Generated with https://github.com/google/shaka-packager version -- +#EXT-X-INDEPENDENT-SEGMENTS + #EXT-X-MEDIA:TYPE=AUDIO,URI="bear-640x360-audio.m3u8",GROUP-ID="default-audio-group",NAME="stream_0",AUTOSELECT=YES,CHANNELS="2" #EXT-X-STREAM-INF:BANDWIDTH=1111406,AVERAGE-BANDWIDTH=1009412,CODECS="avc1.64001e,mp4a.40.2",RESOLUTION=640x360,FRAME-RATE=29.970,AUDIO="default-audio-group" diff --git a/packager/app/test/testdata/live-profile-with-webm/output.m3u8 b/packager/app/test/testdata/live-profile-with-webm/output.m3u8 index 1c32890e7a..491aaf1b4a 100644 --- a/packager/app/test/testdata/live-profile-with-webm/output.m3u8 +++ b/packager/app/test/testdata/live-profile-with-webm/output.m3u8 @@ -1,6 +1,8 @@ #EXTM3U ## Generated with https://github.com/google/shaka-packager version -- +#EXT-X-INDEPENDENT-SEGMENTS + #EXT-X-MEDIA:TYPE=AUDIO,URI="stream_0.m3u8",GROUP-ID="default-audio-group",NAME="stream_0",AUTOSELECT=YES,CHANNELS="2" #EXT-X-STREAM-INF:BANDWIDTH=556353,AVERAGE-BANDWIDTH=412719,CODECS="vp08.00.10.08.01.02.02.02.00,vorbis",RESOLUTION=640x360,FRAME-RATE=30.303,AUDIO="default-audio-group" diff --git a/packager/app/test/testdata/mp4-trailing-moov/output.m3u8 b/packager/app/test/testdata/mp4-trailing-moov/output.m3u8 index 31596b92f5..8c02e6b456 100644 --- a/packager/app/test/testdata/mp4-trailing-moov/output.m3u8 +++ b/packager/app/test/testdata/mp4-trailing-moov/output.m3u8 @@ -1,6 +1,8 @@ #EXTM3U ## Generated with https://github.com/google/shaka-packager version -- +#EXT-X-INDEPENDENT-SEGMENTS + #EXT-X-MEDIA:TYPE=AUDIO,URI="stream_0.m3u8",GROUP-ID="default-audio-group",NAME="stream_0",AUTOSELECT=YES,CHANNELS="2" #EXT-X-STREAM-INF:BANDWIDTH=1106817,AVERAGE-BANDWIDTH=1004632,CODECS="avc1.64001e,mp4a.40.2",RESOLUTION=640x360,FRAME-RATE=29.970,AUDIO="default-audio-group" diff --git a/packager/app/test/testdata/video-non-square-pixel/output.m3u8 b/packager/app/test/testdata/video-non-square-pixel/output.m3u8 index 658f190c52..f7a49d54ad 100644 --- a/packager/app/test/testdata/video-non-square-pixel/output.m3u8 +++ b/packager/app/test/testdata/video-non-square-pixel/output.m3u8 @@ -1,5 +1,7 @@ #EXTM3U ## Generated with https://github.com/google/shaka-packager version -- +#EXT-X-INDEPENDENT-SEGMENTS + #EXT-X-STREAM-INF:BANDWIDTH=761207,AVERAGE-BANDWIDTH=761207,CODECS="avc1.64001e",RESOLUTION=640x360,FRAME-RATE=29.970 stream_0.m3u8 diff --git a/packager/app/test/testdata/vtt-text-to-mp4-with-ad-cues/output.m3u8 b/packager/app/test/testdata/vtt-text-to-mp4-with-ad-cues/output.m3u8 index c42bc7cb6e..d0ecedb6ff 100644 --- a/packager/app/test/testdata/vtt-text-to-mp4-with-ad-cues/output.m3u8 +++ b/packager/app/test/testdata/vtt-text-to-mp4-with-ad-cues/output.m3u8 @@ -1,6 +1,8 @@ #EXTM3U ## Generated with https://github.com/google/shaka-packager version -- +#EXT-X-INDEPENDENT-SEGMENTS + #EXT-X-MEDIA:TYPE=AUDIO,URI="bear-640x360-audio.m3u8",GROUP-ID="default-audio-group",NAME="stream_1",AUTOSELECT=YES,CHANNELS="2" #EXT-X-MEDIA:TYPE=SUBTITLES,URI="bear-english-text.m3u8",GROUP-ID="default-text-group",NAME="stream_0",AUTOSELECT=YES diff --git a/packager/hls/base/master_playlist.cc b/packager/hls/base/master_playlist.cc index 60e3319c3b..e1c336cc80 100644 --- a/packager/hls/base/master_playlist.cc +++ b/packager/hls/base/master_playlist.cc @@ -463,10 +463,12 @@ void AppendPlaylists(const std::string& default_audio_language, MasterPlaylist::MasterPlaylist(const std::string& file_name, const std::string& default_audio_language, - const std::string& default_text_language) + const std::string& default_text_language, + bool is_independent_segments) : file_name_(file_name), default_audio_language_(default_audio_language), - default_text_language_(default_text_language) {} + default_text_language_(default_text_language), + is_independent_segments_(is_independent_segments) {} MasterPlaylist::~MasterPlaylist() {} @@ -476,6 +478,10 @@ bool MasterPlaylist::WriteMasterPlaylist( const std::list& playlists) { std::string content = "#EXTM3U\n"; AppendVersionString(&content); + + if (is_independent_segments_) { + content.append("\n#EXT-X-INDEPENDENT-SEGMENTS\n"); + } AppendPlaylists(default_audio_language_, default_text_language_, base_url, playlists, &content); diff --git a/packager/hls/base/master_playlist.h b/packager/hls/base/master_playlist.h index a758806f03..f58d050bae 100644 --- a/packager/hls/base/master_playlist.h +++ b/packager/hls/base/master_playlist.h @@ -26,7 +26,8 @@ class MasterPlaylist { /// tagged with 'DEFAULT'. MasterPlaylist(const std::string& file_name, const std::string& default_audio_language, - const std::string& default_text_language); + const std::string& default_text_language, + const bool is_independent_segments); virtual ~MasterPlaylist(); /// Writes Master Playlist to output_dir + . @@ -50,6 +51,7 @@ class MasterPlaylist { const std::string file_name_; const std::string default_audio_language_; const std::string default_text_language_; + bool is_independent_segments_; }; } // namespace hls diff --git a/packager/hls/base/master_playlist_unittest.cc b/packager/hls/base/master_playlist_unittest.cc index 9a2f4f7d9d..9f0f0cf741 100644 --- a/packager/hls/base/master_playlist_unittest.cc +++ b/packager/hls/base/master_playlist_unittest.cc @@ -30,6 +30,7 @@ namespace { const char kDefaultMasterPlaylistName[] = "playlist.m3u8"; const char kDefaultAudioLanguage[] = "en"; const char kDefaultTextLanguage[] = "fr"; +const bool kIsIndependentSegments = true; const uint32_t kWidth = 800; const uint32_t kHeight = 600; const uint32_t kEC3JocComplexityZero = 0; @@ -136,9 +137,10 @@ std::unique_ptr CreateTextPlaylist( class MasterPlaylistTest : public ::testing::Test { protected: MasterPlaylistTest() - : master_playlist_(kDefaultMasterPlaylistName, + : master_playlist_(new MasterPlaylist(kDefaultMasterPlaylistName, kDefaultAudioLanguage, - kDefaultTextLanguage), + kDefaultTextLanguage, + !kIsIndependentSegments)), test_output_dir_("memory://test_dir"), master_playlist_path_( FilePath::FromUTF8Unsafe(test_output_dir_) @@ -147,7 +149,7 @@ class MasterPlaylistTest : public ::testing::Test { void SetUp() override { SetPackagerVersionForTesting("test"); } - MasterPlaylist master_playlist_; + std::unique_ptr master_playlist_; std::string test_output_dir_; std::string master_playlist_path_; }; @@ -160,7 +162,7 @@ TEST_F(MasterPlaylistTest, WriteMasterPlaylistOneVideo) { CreateVideoPlaylist("media1.m3u8", "avc1", kMaxBitrate, kAvgBitrate); const char kBaseUrl[] = "http://myplaylistdomain.com/"; - EXPECT_TRUE(master_playlist_.WriteMasterPlaylist(kBaseUrl, test_output_dir_, + EXPECT_TRUE(master_playlist_->WriteMasterPlaylist(kBaseUrl, test_output_dir_, {mock_playlist.get()})); std::string actual; @@ -178,6 +180,41 @@ TEST_F(MasterPlaylistTest, WriteMasterPlaylistOneVideo) { ASSERT_EQ(expected, actual); } +TEST_F(MasterPlaylistTest, + WriteMasterPlaylistOneVideoWithIndependentSegments) { + const uint64_t kMaxBitrate = 435889; + const uint64_t kAvgBitrate = 235889; + + master_playlist_.reset(new MasterPlaylist( + kDefaultMasterPlaylistName, + kDefaultAudioLanguage, + kDefaultTextLanguage, + kIsIndependentSegments)); + + std::unique_ptr mock_playlist = + CreateVideoPlaylist("media1.m3u8", "avc1", kMaxBitrate, kAvgBitrate); + + const char kBaseUrl[] = "http://myplaylistdomain.com/"; + EXPECT_TRUE(master_playlist_->WriteMasterPlaylist(kBaseUrl, + test_output_dir_, + {mock_playlist.get()})); + + std::string actual; + ASSERT_TRUE(File::ReadFileToString(master_playlist_path_.c_str(), &actual)); + + const std::string expected = + "#EXTM3U\n" + "## Generated with https://github.com/google/shaka-packager version " + "test\n" + "\n#EXT-X-INDEPENDENT-SEGMENTS\n" + "\n" + "#EXT-X-STREAM-INF:BANDWIDTH=435889,AVERAGE-BANDWIDTH=235889," + "CODECS=\"avc1\",RESOLUTION=800x600\n" + "http://myplaylistdomain.com/media1.m3u8\n"; + + ASSERT_EQ(expected, actual); +} + TEST_F(MasterPlaylistTest, WriteMasterPlaylistOneVideoWithFrameRate) { const uint64_t kMaxBitrate = 435889; const uint64_t kAvgBitrate = 235889; @@ -188,7 +225,7 @@ TEST_F(MasterPlaylistTest, WriteMasterPlaylistOneVideoWithFrameRate) { EXPECT_CALL(*mock_playlist, GetFrameRate()).WillOnce(Return(kFrameRate)); const char kBaseUrl[] = "http://myplaylistdomain.com/"; - EXPECT_TRUE(master_playlist_.WriteMasterPlaylist(kBaseUrl, test_output_dir_, + EXPECT_TRUE(master_playlist_->WriteMasterPlaylist(kBaseUrl, test_output_dir_, {mock_playlist.get()})); std::string actual; @@ -215,7 +252,7 @@ TEST_F(MasterPlaylistTest, WriteMasterPlaylistOneIframePlaylist) { EXPECT_CALL(*mock_playlist, GetFrameRate()).Times(0); const char kBaseUrl[] = "http://myplaylistdomain.com/"; - EXPECT_TRUE(master_playlist_.WriteMasterPlaylist(kBaseUrl, test_output_dir_, + EXPECT_TRUE(master_playlist_->WriteMasterPlaylist(kBaseUrl, test_output_dir_, {mock_playlist.get()})); std::string actual; @@ -268,7 +305,7 @@ TEST_F(MasterPlaylistTest, WriteMasterPlaylistVideoAndAudio) { !kAC4IMSFlagEnabled, !kAC4CBIFlagEnabled); const char kBaseUrl[] = "http://playlists.org/"; - EXPECT_TRUE(master_playlist_.WriteMasterPlaylist( + EXPECT_TRUE(master_playlist_->WriteMasterPlaylist( kBaseUrl, test_output_dir_, {sd_video_playlist.get(), hd_video_playlist.get(), english_playlist.get(), spanish_playlist.get()})); @@ -329,7 +366,7 @@ TEST_F(MasterPlaylistTest, WriteMasterPlaylistMultipleAudioGroups) { kEC3JocComplexityZero, !kAC4IMSFlagEnabled, !kAC4CBIFlagEnabled); const char kBaseUrl[] = "http://anydomain.com/"; - EXPECT_TRUE(master_playlist_.WriteMasterPlaylist( + EXPECT_TRUE(master_playlist_->WriteMasterPlaylist( kBaseUrl, test_output_dir_, {video_playlist.get(), eng_lo_playlist.get(), eng_hi_playlist.get()})); @@ -376,7 +413,7 @@ TEST_F(MasterPlaylistTest, WriteMasterPlaylistSameAudioGroupSameLanguage) { kEC3JocComplexityZero, !kAC4IMSFlagEnabled, !kAC4CBIFlagEnabled); const char kBaseUrl[] = "http://anydomain.com/"; - EXPECT_TRUE(master_playlist_.WriteMasterPlaylist( + EXPECT_TRUE(master_playlist_->WriteMasterPlaylist( kBaseUrl, test_output_dir_, {video_playlist.get(), eng_lo_playlist.get(), eng_hi_playlist.get()})); @@ -419,7 +456,7 @@ TEST_F(MasterPlaylistTest, WriteMasterPlaylistVideosAndTexts) { CreateTextPlaylist("fr.m3u8", "french", "textgroup", "textcodec", "fr"); const char kBaseUrl[] = "http://playlists.org/"; - EXPECT_TRUE(master_playlist_.WriteMasterPlaylist( + EXPECT_TRUE(master_playlist_->WriteMasterPlaylist( kBaseUrl, test_output_dir_, {video1.get(), video2.get(), text_eng.get(), text_fr.get()})); @@ -462,7 +499,7 @@ TEST_F(MasterPlaylistTest, WriteMasterPlaylistVideoAndTextWithCharacteritics) { "public.accessibility.transcribes-spoken-dialog", "public.easy-to-read"}); const char kBaseUrl[] = "http://playlists.org/"; - EXPECT_TRUE(master_playlist_.WriteMasterPlaylist(kBaseUrl, test_output_dir_, + EXPECT_TRUE(master_playlist_->WriteMasterPlaylist(kBaseUrl, test_output_dir_, {video.get(), text.get()})); std::string actual; @@ -500,7 +537,7 @@ TEST_F(MasterPlaylistTest, WriteMasterPlaylistVideoAndTextGroups) { "fr.m3u8", "french", "fr-text-group", "textcodec", "fr"); const char kBaseUrl[] = "http://playlists.org/"; - EXPECT_TRUE(master_playlist_.WriteMasterPlaylist( + EXPECT_TRUE(master_playlist_->WriteMasterPlaylist( kBaseUrl, test_output_dir_, {video.get(), text_eng.get(), text_fr.get()})); @@ -547,7 +584,7 @@ TEST_F(MasterPlaylistTest, WriteMasterPlaylistVideoAndAudioAndText) { CreateTextPlaylist("eng.m3u8", "english", "textgroup", "textcodec", "en"); const char kBaseUrl[] = "http://playlists.org/"; - EXPECT_TRUE(master_playlist_.WriteMasterPlaylist( + EXPECT_TRUE(master_playlist_->WriteMasterPlaylist( kBaseUrl, test_output_dir_, {video.get(), audio.get(), text.get()})); std::string actual; @@ -620,7 +657,7 @@ TEST_F(MasterPlaylistTest, WriteMasterPlaylistMixedPlaylistsDifferentGroups) { } const char kBaseUrl[] = "http://playlists.org/"; - EXPECT_TRUE(master_playlist_.WriteMasterPlaylist(kBaseUrl, test_output_dir_, + EXPECT_TRUE(master_playlist_->WriteMasterPlaylist(kBaseUrl, test_output_dir_, media_playlist_list)); std::string actual; @@ -715,7 +752,7 @@ TEST_F(MasterPlaylistTest, WriteMasterPlaylistAudioOnly) { } const char kBaseUrl[] = "http://playlists.org/"; - EXPECT_TRUE(master_playlist_.WriteMasterPlaylist(kBaseUrl, test_output_dir_, + EXPECT_TRUE(master_playlist_->WriteMasterPlaylist(kBaseUrl, test_output_dir_, media_playlist_list)); std::string actual; @@ -767,7 +804,7 @@ TEST_F(MasterPlaylistTest, WriteMasterPlaylistAudioOnlyJOC) { } const char kBaseUrl[] = "http://playlists.org/"; - EXPECT_TRUE(master_playlist_.WriteMasterPlaylist(kBaseUrl, test_output_dir_, + EXPECT_TRUE(master_playlist_->WriteMasterPlaylist(kBaseUrl, test_output_dir_, media_playlist_list)); std::string actual; @@ -819,7 +856,7 @@ TEST_F(MasterPlaylistTest, WriteMasterPlaylistAudioOnlyAC4IMS) { } const char kBaseUrl[] = "http://playlists.org/"; - EXPECT_TRUE(master_playlist_.WriteMasterPlaylist(kBaseUrl, test_output_dir_, + EXPECT_TRUE(master_playlist_->WriteMasterPlaylist(kBaseUrl, test_output_dir_, media_playlist_list)); std::string actual; @@ -872,7 +909,7 @@ TEST_F(MasterPlaylistTest, WriteMasterPlaylistAudioOnlyAC4CBI) { } const char kBaseUrl[] = "http://playlists.org/"; - EXPECT_TRUE(master_playlist_.WriteMasterPlaylist(kBaseUrl, test_output_dir_, + EXPECT_TRUE(master_playlist_->WriteMasterPlaylist(kBaseUrl, test_output_dir_, media_playlist_list)); std::string actual; diff --git a/packager/hls/base/simple_hls_notifier.cc b/packager/hls/base/simple_hls_notifier.cc index d6d8363080..0867631e33 100644 --- a/packager/hls/base/simple_hls_notifier.cc +++ b/packager/hls/base/simple_hls_notifier.cc @@ -290,7 +290,8 @@ SimpleHlsNotifier::SimpleHlsNotifier(const HlsParams& hls_params) : hls_params.default_text_language; master_playlist_.reset( new MasterPlaylist(master_playlist_path.BaseName().AsUTF8Unsafe(), - default_audio_langauge, default_text_language)); + default_audio_langauge, default_text_language, + hls_params.is_independent_segments)); } SimpleHlsNotifier::~SimpleHlsNotifier() {} diff --git a/packager/hls/base/simple_hls_notifier_unittest.cc b/packager/hls/base/simple_hls_notifier_unittest.cc index f816be95b4..c498113264 100644 --- a/packager/hls/base/simple_hls_notifier_unittest.cc +++ b/packager/hls/base/simple_hls_notifier_unittest.cc @@ -37,6 +37,7 @@ namespace { const char kMasterPlaylistName[] = "master.m3u8"; const char kDefaultAudioLanguage[] = "en"; const char kDefaultTextLanguage[] = "fr"; +const bool kIsIndependentSegments = true; const char kEmptyKeyUri[] = ""; const char kFairPlayKeyUri[] = "skd://www.license.com/getkey?key_id=testing"; const char kIdentityKeyUri[] = "https://www.license.com/getkey?key_id=testing"; @@ -48,7 +49,8 @@ class MockMasterPlaylist : public MasterPlaylist { MockMasterPlaylist() : MasterPlaylist(kMasterPlaylistName, kDefaultAudioLanguage, - kDefaultTextLanguage) {} + kDefaultTextLanguage, + kIsIndependentSegments) {} MOCK_METHOD3(WriteMasterPlaylist, bool(const std::string& prefix, diff --git a/packager/hls/public/hls_params.h b/packager/hls/public/hls_params.h index 0100fb7969..d1f7200f43 100644 --- a/packager/hls/public/hls_params.h +++ b/packager/hls/public/hls_params.h @@ -51,6 +51,9 @@ struct HlsParams { /// Same as above, but this overrides the default language for text tracks, /// i.e. subtitles or close-captions. std::string default_text_language; + // Indicates that all media samples in the media segments can be decoded + // without information from other segments. + bool is_independent_segments; /// This is the target segment duration requested by the user. The actual /// segment duration may be different to the target segment duration. It will /// be populated from segment duration specified in ChunkingParams if not diff --git a/packager/packager.cc b/packager/packager.cc index 18671b0e34..b46d6e7f57 100644 --- a/packager/packager.cc +++ b/packager/packager.cc @@ -929,7 +929,9 @@ Status Packager::Initialize( LanguageToShortestForm(hls_params.default_language); hls_params.default_text_language = LanguageToShortestForm(hls_params.default_text_language); - + hls_params.is_independent_segments = + packaging_params.chunking_params.segment_sap_aligned; + if (!mpd_params.mpd_output.empty()) { const bool on_demand_dash_profile = stream_descriptors.begin()->segment_template.empty();