Skip to content

Commit ea3568d

Browse files
author
Álvaro Velad Galván
authored
feat: Add a config to dispatch all emsg boxes. (shaka-project#3653)
Closes shaka-project#3348
1 parent 31c0cd4 commit ea3568d

File tree

7 files changed

+19
-4
lines changed

7 files changed

+19
-4
lines changed

demo/common/message_ids.js

+1
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,7 @@ shakaDemo.MessageIds = {
167167
DISABLE_THUMBNAILS: 'DEMO_DISABLE_THUMBNAILS',
168168
DISABLE_VIDEO: 'DEMO_DISABLE_VIDEO',
169169
DISABLE_XLINK_PROCESSING: 'DEMO_DISABLE_XLINK_PROCESSING',
170+
DISPATCH_ALL_EMSG_BOXES: 'DEMO_DISPATCH_ALL_EMSG_BOXES',
170171
DRM_RETRY_SECTION_HEADER: 'DEMO_DRM_RETRY_SECTION_HEADER',
171172
DRM_SECTION_HEADER: 'DEMO_DRM_SECTION_HEADER',
172173
DRM_SESSION_TYPE: 'DEMO_DRM_SESSION_TYPE',

demo/config.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,9 @@ shakaDemo.Config = class {
366366
'streaming.preferNativeHls')
367367
.addNumberInput_(MessageIds.UPDATE_INTERVAL_SECONDS,
368368
'streaming.updateIntervalSeconds',
369-
/* canBeDecimal= */ true);
369+
/* canBeDecimal= */ true)
370+
.addBoolInput_(MessageIds.DISPATCH_ALL_EMSG_BOXES,
371+
'streaming.dispatchAllEmsgBoxes');
370372

371373
if (!shakaDemoMain.getNativeControlsEnabled()) {
372374
this.addBoolInput_(MessageIds.ALWAYS_STREAM_TEXT,

demo/locales/en.json

+1
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@
5858
"DEMO_DISABLE_THUMBNAILS": "Disable Thumbnails",
5959
"DEMO_DISABLE_VIDEO": "Disable Video",
6060
"DEMO_DISABLE_XLINK_PROCESSING": "Disable Xlink processing",
61+
"DEMO_DISPATCH_ALL_EMSG_BOXES": "Dispatch all emsg boxes",
6162
"DEMO_DOCUMENTATION": "Documentation",
6263
"DEMO_DRM_RETRY_SECTION_HEADER": "DRM Retry Parameters",
6364
"DEMO_DRM_SEARCH": "DRM",

demo/locales/source.json

+4
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,10 @@
235235
"description": "The name of a configuration value.",
236236
"message": "Disable [JARGON:Xlink] processing"
237237
},
238+
"DEMO_DISPATCH_ALL_EMSG_BOXES": {
239+
"description": "The name of a configuration value.",
240+
"message": "Dispatch all [JARGON:emsg] boxes"
241+
},
238242
"DEMO_DOCUMENTATION": {
239243
"description": "A link in the footer, to the Shaka Player documentation.",
240244
"message": "Documentation"

externs/shaka/player.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -798,7 +798,8 @@ shaka.extern.ManifestConfiguration;
798798
* autoLowLatencyMode: boolean,
799799
* forceHTTPS: boolean,
800800
* preferNativeHls: boolean,
801-
* updateIntervalSeconds: number
801+
* updateIntervalSeconds: number,
802+
* dispatchAllEmsgBoxes: boolean
802803
* }}
803804
*
804805
* @description
@@ -907,6 +908,8 @@ shaka.extern.ManifestConfiguration;
907908
* If true, prefer native HLS playback when possible, regardless of platform.
908909
* @property {number} updateIntervalSeconds
909910
* The minimum number of seconds to see if the manifest has changes.
911+
* @property {boolean} dispatchAllEmsgBoxes
912+
* If true, all emsg boxes are parsed and dispatched.
910913
*
911914
* @exportDoc
912915
*/

lib/media/streaming_engine.js

+5-2
Original file line numberDiff line numberDiff line change
@@ -1566,7 +1566,9 @@ shaka.media.StreamingEngine = class {
15661566

15671567
const hasClosedCaptions = stream.closedCaptions &&
15681568
stream.closedCaptions.size > 0;
1569-
if (stream.emsgSchemeIdUris != null && stream.emsgSchemeIdUris.length > 0) {
1569+
if ((stream.emsgSchemeIdUris != null &&
1570+
stream.emsgSchemeIdUris.length > 0) ||
1571+
this.config_.dispatchAllEmsgBoxes) {
15701572
new shaka.util.Mp4Parser()
15711573
.fullBox(
15721574
'emsg',
@@ -1652,7 +1654,8 @@ shaka.media.StreamingEngine = class {
16521654
// See DASH sec. 5.10.3.3.1
16531655
// If a DASH client detects an event message box with a scheme that is not
16541656
// defined in MPD, the client is expected to ignore it.
1655-
if (emsgSchemeIdUris.includes(schemeId)) {
1657+
if (emsgSchemeIdUris.includes(schemeId) ||
1658+
this.config_.dispatchAllEmsgBoxes) {
16561659
// See DASH sec. 5.10.4.1
16571660
// A special scheme in DASH used to signal manifest updates.
16581661
if (schemeId == 'urn:mpeg:dash:event:2012') {

lib/util/player_configuration.js

+1
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,7 @@ shaka.util.PlayerConfiguration = class {
165165
forceHTTPS: false,
166166
preferNativeHls: false,
167167
updateIntervalSeconds: 1,
168+
dispatchAllEmsgBoxes: false,
168169
};
169170

170171
// Some browsers will stop earlier than others before a gap (e.g., Edge

0 commit comments

Comments
 (0)