Skip to content

Commit

Permalink
feat: Add a config to dispatch all emsg boxes. (shaka-project#3653)
Browse files Browse the repository at this point in the history
  • Loading branch information
Álvaro Velad Galván authored Oct 12, 2021
1 parent 31c0cd4 commit ea3568d
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 4 deletions.
1 change: 1 addition & 0 deletions demo/common/message_ids.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
4 changes: 3 additions & 1 deletion demo/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
1 change: 1 addition & 0 deletions demo/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
4 changes: 4 additions & 0 deletions demo/locales/source.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
5 changes: 4 additions & 1 deletion externs/shaka/player.js
Original file line number Diff line number Diff line change
Expand Up @@ -798,7 +798,8 @@ shaka.extern.ManifestConfiguration;
* autoLowLatencyMode: boolean,
* forceHTTPS: boolean,
* preferNativeHls: boolean,
* updateIntervalSeconds: number
* updateIntervalSeconds: number,
* dispatchAllEmsgBoxes: boolean
* }}
*
* @description
Expand Down Expand Up @@ -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
*/
Expand Down
7 changes: 5 additions & 2 deletions lib/media/streaming_engine.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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') {
Expand Down
1 change: 1 addition & 0 deletions lib/util/player_configuration.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit ea3568d

Please sign in to comment.