Skip to content

Commit 82c5149

Browse files
authored
feat(DASH): Add MPD Chaining support (#6641)
Close #3926
1 parent ec4bc1d commit 82c5149

20 files changed

+176
-4
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ DASH features supported:
106106
- WebVTT and TTML
107107
- CEA-608/708 captions
108108
- Multi-codec variants (on platforms with changeType support)
109+
- MPD chaining
109110

110111
DASH features **not** supported:
111112
- Xlink with actuate=onRequest

demo/common/assets.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,9 @@ shakaAssets.Feature = {
170170

171171
// Set if the asset is VR.
172172
VR: 'VR',
173+
174+
// Set if the asset has MPD Chaining.
175+
MPD_CHAINING: 'MPD Chaining',
173176
};
174177

175178

@@ -303,6 +306,20 @@ shakaAssets.testAssets = [
303306
.addFeature(shakaAssets.Feature.SUBTITLES)
304307
.addFeature(shakaAssets.Feature.WEBM)
305308
.addFeature(shakaAssets.Feature.OFFLINE),
309+
new ShakaDemoAssetInfo(
310+
/* name= */ 'Angel One (multicodec, multilingual, mpd chaining)',
311+
/* iconUri= */ 'https://storage.googleapis.com/shaka-asset-icons/angel_one.png',
312+
/* manifestUri= */ 'https://storage.googleapis.com/shaka-demo-assets/angel-one/dash_chaining.mpd',
313+
/* source= */ shakaAssets.Source.SHAKA)
314+
.addDescription('A clip from a classic Star Trek TNG episode, presented in MPEG-DASH.')
315+
.markAsFeatured('Angel One')
316+
.addFeature(shakaAssets.Feature.DASH)
317+
.addFeature(shakaAssets.Feature.MP4)
318+
.addFeature(shakaAssets.Feature.MULTIPLE_LANGUAGES)
319+
.addFeature(shakaAssets.Feature.SUBTITLES)
320+
.addFeature(shakaAssets.Feature.WEBM)
321+
.addFeature(shakaAssets.Feature.OFFLINE)
322+
.addFeature(shakaAssets.Feature.MPD_CHAINING),
306323
new ShakaDemoAssetInfo(
307324
/* name= */ 'Angel One (multicodec, multilingual, Widevine)',
308325
/* iconUri= */ 'https://storage.googleapis.com/shaka-asset-icons/angel_one.png',
@@ -994,6 +1011,15 @@ shakaAssets.testAssets = [
9941011
.addFeature(shakaAssets.Feature.MP4)
9951012
.addFeature(shakaAssets.Feature.LIVE)
9961013
.addFeature(shakaAssets.Feature.THUMBNAILS),
1014+
new ShakaDemoAssetInfo(
1015+
/* name= */ 'DASH-IF - Regular chaining, Live',
1016+
/* iconUri= */ '',
1017+
/* manifestUri= */ 'https://dash.akamaized.net/dash264/TestCasesIOP33/MPDChaining/regular_chain/1/manifest_regular_MPDChaining_live.mpd',
1018+
/* source= */ shakaAssets.Source.DASH_IF)
1019+
.addFeature(shakaAssets.Feature.DASH)
1020+
.addFeature(shakaAssets.Feature.MP4)
1021+
.addFeature(shakaAssets.Feature.LIVE)
1022+
.addFeature(shakaAssets.Feature.MPD_CHAINING),
9971023
// End DASH-IF Assets }}}
9981024

9991025
// bitcodin assets {{{

demo/config.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -564,7 +564,11 @@ shakaDemo.Config = class {
564564
.addBoolInput_('Use native HLS on Safari (Clear)',
565565
'streaming.useNativeHlsOnSafari')
566566
.addBoolInput_('Use native HLS for FairPlay',
567-
'streaming.useNativeHlsForFairPlay');
567+
'streaming.useNativeHlsForFairPlay')
568+
.addNumberInput_('Time window at end to preload next URL',
569+
'streaming.preloadNextUrlWindow',
570+
/* canBeDecimal= */ true,
571+
/* canBeZero= */ true);
568572
this.addRetrySection_('streaming', 'Streaming Retry Parameters');
569573
}
570574

demo/search.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -399,6 +399,8 @@ shakaDemo.Search = class {
399399
'Filters for assets that use Content Steering.');
400400
this.makeBooleanInput_(specialContainer, Feature.VR, FEATURE,
401401
'Filters for assets that are VR.');
402+
this.makeBooleanInput_(specialContainer, Feature.MPD_CHAINING, FEATURE,
403+
'Filters for assets that have MPD Chaining');
402404

403405
container.appendChild(this.resultsDiv_);
404406
}

externs/shaka/manifest.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@
2121
* sequenceMode: boolean,
2222
* ignoreManifestTimestampsInSegmentsMode: boolean,
2323
* type: string,
24-
* serviceDescription: ?shaka.extern.ServiceDescription
24+
* serviceDescription: ?shaka.extern.ServiceDescription,
25+
* nextUrl: ?string
2526
* }}
2627
*
2728
* @description
@@ -93,6 +94,8 @@
9394
* @property {?shaka.extern.ServiceDescription} serviceDescription
9495
* The service description for the manifest. Used to adapt playbackRate to
9596
* decrease latency.
97+
* @property {?string} nextUrl
98+
* The next url to play.
9699
*
97100
* @exportDoc
98101
*/

externs/shaka/player.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1252,7 +1252,8 @@ shaka.extern.ManifestConfiguration;
12521252
* vodDynamicPlaybackRate: boolean,
12531253
* vodDynamicPlaybackRateLowBufferRate: number,
12541254
* vodDynamicPlaybackRateBufferRatio: number,
1255-
* infiniteLiveStreamDuration: boolean
1255+
* infiniteLiveStreamDuration: boolean,
1256+
* preloadNextUrlWindow: number
12561257
* }}
12571258
*
12581259
* @description
@@ -1442,6 +1443,12 @@ shaka.extern.ManifestConfiguration;
14421443
* If <code>true</code>, the media source live duration
14431444
* set as a<code>Infinity</code>
14441445
* Defaults to <code> false </code>.
1446+
* @property {number} preloadNextUrlWindow
1447+
* The window of time at the end of the presentation to begin preloading the
1448+
* next URL, such as one specified by a urn:mpeg:dash:chaining:2016 element
1449+
* in DASH. Measured in seconds. If the value is 0, the next URL will not
1450+
* be preloaded at all.
1451+
* Defaults to <code> 30 </code>.
14451452
* @exportDoc
14461453
*/
14471454
shaka.extern.StreamingConfiguration;

lib/dash/dash_parser.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -697,6 +697,7 @@ shaka.dash.DashParser = class {
697697
ignoreManifestTimestampsInSegmentsMode: false,
698698
type: shaka.media.ManifestParser.DASH,
699699
serviceDescription: this.parseServiceDescription_(mpd),
700+
nextUrl: this.parseMpdChaining_(mpd),
700701
};
701702

702703
// We only need to do clock sync when we're using presentation start
@@ -782,6 +783,32 @@ shaka.dash.DashParser = class {
782783
return null;
783784
}
784785

786+
/**
787+
* Reads chaining url.
788+
*
789+
* @param {!shaka.extern.xml.Node} mpd
790+
* @return {?string}
791+
* @private
792+
*/
793+
parseMpdChaining_(mpd) {
794+
const TXml = shaka.util.TXml;
795+
const supplementalProperties =
796+
TXml.findChildren(mpd, 'SupplementalProperty');
797+
798+
if (!supplementalProperties.length) {
799+
return null;
800+
}
801+
802+
for (const prop of supplementalProperties) {
803+
const schemeId = prop.attributes['schemeIdUri'];
804+
if (schemeId == 'urn:mpeg:dash:chaining:2016') {
805+
return prop.attributes['value'];
806+
}
807+
}
808+
809+
return null;
810+
}
811+
785812
/**
786813
* Reads and parses the periods from the manifest. This first does some
787814
* partial parsing so the start and duration is available when parsing

lib/hls/hls_parser.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -880,6 +880,7 @@ shaka.hls.HlsParser = class {
880880
this.config_.hls.ignoreManifestTimestampsInSegmentsMode,
881881
type: shaka.media.ManifestParser.HLS,
882882
serviceDescription: null,
883+
nextUrl: null,
883884
};
884885

885886
// If there is no 'CODECS' attribute in the manifest and codec guessing is

lib/mss/mss_parser.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -419,6 +419,7 @@ shaka.mss.MssParser = class {
419419
ignoreManifestTimestampsInSegmentsMode: false,
420420
type: shaka.media.ManifestParser.MSS,
421421
serviceDescription: null,
422+
nextUrl: null,
422423
};
423424

424425
// This is the first point where we have a meaningful presentation start

lib/offline/manifest_converter.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ shaka.offline.ManifestConverter = class {
9393
ignoreManifestTimestampsInSegmentsMode: false,
9494
type: manifestDB.type || shaka.media.ManifestParser.UNKNOWN,
9595
serviceDescription: null,
96+
nextUrl: null,
9697
};
9798
}
9899

0 commit comments

Comments
 (0)