From ea3568d7261237a571f23524012072008d01c1ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81lvaro=20Velad=20Galv=C3=A1n?= Date: Tue, 12 Oct 2021 23:22:11 +0200 Subject: [PATCH] feat: Add a config to dispatch all emsg boxes. (#3653) Closes #3348 --- demo/common/message_ids.js | 1 + demo/config.js | 4 +++- demo/locales/en.json | 1 + demo/locales/source.json | 4 ++++ externs/shaka/player.js | 5 ++++- lib/media/streaming_engine.js | 7 +++++-- lib/util/player_configuration.js | 1 + 7 files changed, 19 insertions(+), 4 deletions(-) diff --git a/demo/common/message_ids.js b/demo/common/message_ids.js index 15520f2552..1cc30e4425 100644 --- a/demo/common/message_ids.js +++ b/demo/common/message_ids.js @@ -167,6 +167,7 @@ shakaDemo.MessageIds = { DISABLE_THUMBNAILS: 'DEMO_DISABLE_THUMBNAILS', DISABLE_VIDEO: 'DEMO_DISABLE_VIDEO', DISABLE_XLINK_PROCESSING: 'DEMO_DISABLE_XLINK_PROCESSING', + DISPATCH_ALL_EMSG_BOXES: 'DEMO_DISPATCH_ALL_EMSG_BOXES', DRM_RETRY_SECTION_HEADER: 'DEMO_DRM_RETRY_SECTION_HEADER', DRM_SECTION_HEADER: 'DEMO_DRM_SECTION_HEADER', DRM_SESSION_TYPE: 'DEMO_DRM_SESSION_TYPE', diff --git a/demo/config.js b/demo/config.js index cc56d26de6..425855df8f 100644 --- a/demo/config.js +++ b/demo/config.js @@ -366,7 +366,9 @@ shakaDemo.Config = class { 'streaming.preferNativeHls') .addNumberInput_(MessageIds.UPDATE_INTERVAL_SECONDS, 'streaming.updateIntervalSeconds', - /* canBeDecimal= */ true); + /* canBeDecimal= */ true) + .addBoolInput_(MessageIds.DISPATCH_ALL_EMSG_BOXES, + 'streaming.dispatchAllEmsgBoxes'); if (!shakaDemoMain.getNativeControlsEnabled()) { this.addBoolInput_(MessageIds.ALWAYS_STREAM_TEXT, diff --git a/demo/locales/en.json b/demo/locales/en.json index 665c2039ca..ed53e24a99 100644 --- a/demo/locales/en.json +++ b/demo/locales/en.json @@ -58,6 +58,7 @@ "DEMO_DISABLE_THUMBNAILS": "Disable Thumbnails", "DEMO_DISABLE_VIDEO": "Disable Video", "DEMO_DISABLE_XLINK_PROCESSING": "Disable Xlink processing", + "DEMO_DISPATCH_ALL_EMSG_BOXES": "Dispatch all emsg boxes", "DEMO_DOCUMENTATION": "Documentation", "DEMO_DRM_RETRY_SECTION_HEADER": "DRM Retry Parameters", "DEMO_DRM_SEARCH": "DRM", diff --git a/demo/locales/source.json b/demo/locales/source.json index 453cbfcbdc..a7fb17995a 100644 --- a/demo/locales/source.json +++ b/demo/locales/source.json @@ -235,6 +235,10 @@ "description": "The name of a configuration value.", "message": "Disable [JARGON:Xlink] processing" }, + "DEMO_DISPATCH_ALL_EMSG_BOXES": { + "description": "The name of a configuration value.", + "message": "Dispatch all [JARGON:emsg] boxes" + }, "DEMO_DOCUMENTATION": { "description": "A link in the footer, to the Shaka Player documentation.", "message": "Documentation" diff --git a/externs/shaka/player.js b/externs/shaka/player.js index 8691bf76e6..40044ea3bc 100644 --- a/externs/shaka/player.js +++ b/externs/shaka/player.js @@ -798,7 +798,8 @@ shaka.extern.ManifestConfiguration; * autoLowLatencyMode: boolean, * forceHTTPS: boolean, * preferNativeHls: boolean, - * updateIntervalSeconds: number + * updateIntervalSeconds: number, + * dispatchAllEmsgBoxes: boolean * }} * * @description @@ -907,6 +908,8 @@ shaka.extern.ManifestConfiguration; * If true, prefer native HLS playback when possible, regardless of platform. * @property {number} updateIntervalSeconds * The minimum number of seconds to see if the manifest has changes. + * @property {boolean} dispatchAllEmsgBoxes + * If true, all emsg boxes are parsed and dispatched. * * @exportDoc */ diff --git a/lib/media/streaming_engine.js b/lib/media/streaming_engine.js index c32a3426db..1a7e3ee9b7 100644 --- a/lib/media/streaming_engine.js +++ b/lib/media/streaming_engine.js @@ -1566,7 +1566,9 @@ shaka.media.StreamingEngine = class { const hasClosedCaptions = stream.closedCaptions && stream.closedCaptions.size > 0; - if (stream.emsgSchemeIdUris != null && stream.emsgSchemeIdUris.length > 0) { + if ((stream.emsgSchemeIdUris != null && + stream.emsgSchemeIdUris.length > 0) || + this.config_.dispatchAllEmsgBoxes) { new shaka.util.Mp4Parser() .fullBox( 'emsg', @@ -1652,7 +1654,8 @@ shaka.media.StreamingEngine = class { // See DASH sec. 5.10.3.3.1 // If a DASH client detects an event message box with a scheme that is not // defined in MPD, the client is expected to ignore it. - if (emsgSchemeIdUris.includes(schemeId)) { + if (emsgSchemeIdUris.includes(schemeId) || + this.config_.dispatchAllEmsgBoxes) { // See DASH sec. 5.10.4.1 // A special scheme in DASH used to signal manifest updates. if (schemeId == 'urn:mpeg:dash:event:2012') { diff --git a/lib/util/player_configuration.js b/lib/util/player_configuration.js index a90afbfb89..e941e4f47d 100644 --- a/lib/util/player_configuration.js +++ b/lib/util/player_configuration.js @@ -165,6 +165,7 @@ shaka.util.PlayerConfiguration = class { forceHTTPS: false, preferNativeHls: false, updateIntervalSeconds: 1, + dispatchAllEmsgBoxes: false, }; // Some browsers will stop earlier than others before a gap (e.g., Edge