From 427b2e790f670d449d532ef60b003bad8ed5ec92 Mon Sep 17 00:00:00 2001 From: Nigel Megitt Date: Thu, 11 Jan 2024 07:33:17 +0000 Subject: [PATCH] Add text.imsc settings for rollUp and displayForcedOnly (#4336) * Add text.imsc settings for rollUp and displayForcedOnly * Add settings to index.d.ts Also change `displayForcedOnly` to `displayForcedOnlyMode` throughout, so it's consistent, because that was a vector for hard-to-spot coding errors. * Address feedback - remove unnecessary player settings --- index.d.ts | 4 ++++ samples/dash-if-reference-player/app/main.js | 18 +++++++++++++++ samples/dash-if-reference-player/index.html | 24 ++++++++++++++++++++ src/core/Settings.js | 15 +++++++++++- src/streaming/text/TextTracks.js | 4 ++-- 5 files changed, 62 insertions(+), 3 deletions(-) diff --git a/index.d.ts b/index.d.ts index 2982b838f4..2c738d4fdf 100644 --- a/index.d.ts +++ b/index.d.ts @@ -1024,6 +1024,10 @@ declare namespace dashjs { text?: { defaultEnabled?: boolean, extendSegmentedCues?: boolean, + imsc?: { + displayForcedOnlyMode?: boolean, + enableRollUp?: boolean + }, webvtt?: { customRenderingEnabled?: number } diff --git a/samples/dash-if-reference-player/app/main.js b/samples/dash-if-reference-player/app/main.js index 37a4d26d86..0f256116d1 100644 --- a/samples/dash-if-reference-player/app/main.js +++ b/samples/dash-if-reference-player/app/main.js @@ -233,6 +233,9 @@ app.controller('DashController', ['$scope', '$window', 'sources', 'contributors' $scope.drmToday = false; + $scope.imscEnableRollUp = true; + $scope.imscdisplayForcedOnlyMode = false; + $scope.isDynamic = false; $scope.conformanceViolations = []; @@ -821,6 +824,14 @@ app.controller('DashController', ['$scope', '$window', 'sources', 'contributors' $scope.player.enableForcedTextStreaming($scope.initialSettings.forceTextStreaming); } + $scope.toggleImscEnableRollUp = function() { + $scope.player.updateSettings({ streaming: { text: { imsc: { enableRollUp: $scope.imscEnableRollUp }}}}); + } + + $scope.toggleImscdisplayForcedOnlyMode = function() { + $scope.player.updateSettings({ streaming: { text: { imsc: { displayForcedOnlyMode: $scope.imscdisplayForcedOnlyMode }}}}); + } + $scope.updateCmcdSessionId = function () { $scope.player.updateSettings({ streaming: { @@ -2180,6 +2191,12 @@ app.controller('DashController', ['$scope', '$window', 'sources', 'contributors' $scope.drmClearkey.priority = $scope.drmClearkey.priority.toString(); } + function setTextOptions() { + var currentConfig = $scope.player.getSettings(); + $scope.imscEnableRollUp = currentConfig.streaming.text.imsc.enableRollUp; + $scope.imscdisplayForcedOnlyMode = currentConfig.streaming.text.imsc.displayForcedOnlyMode; + } + function setLiveDelayOptions() { var currentConfig = $scope.player.getSettings(); $scope.initialLiveDelay = currentConfig.streaming.delay.liveDelay; @@ -2335,6 +2352,7 @@ app.controller('DashController', ['$scope', '$window', 'sources', 'contributors' setAdditionalPlaybackOptions(); setAdditionalAbrOptions(); setDrmOptions(); + setTextOptions(); setLiveDelayOptions(); setInitialSettings(); setTrackSwitchModeSettings(); diff --git a/samples/dash-if-reference-player/index.html b/samples/dash-if-reference-player/index.html index 1876add8b7..bd7feac9a8 100644 --- a/samples/dash-if-reference-player/index.html +++ b/samples/dash-if-reference-player/index.html @@ -698,6 +698,30 @@ +
+
Text
+
+
+
IMSC
+
+ +
+
+ +
+
+
+
Initial Settings
diff --git a/src/core/Settings.js b/src/core/Settings.js index 94486152bc..59ad6982c7 100644 --- a/src/core/Settings.js +++ b/src/core/Settings.js @@ -143,6 +143,10 @@ import Events from './events/Events'; * text: { * defaultEnabled: true, * extendSegmentedCues: true, + * imsc: { + * displayForcedOnlyMode: false, + * enableRollUp: true + * }, * webvtt: { * customRenderingEnabled: false * } @@ -480,7 +484,12 @@ import Events from './events/Events'; * Enable/disable subtitle rendering by default. * @property {boolean} [extendSegmentedCues=true] * Enable/disable patching of segmented cues in order to merge as a single cue by extending cue end time. - * @property {object} [webvtt={customRenderingEnabled=false}] + * @property {boolean} [imsc.displayForcedOnlyMode=false] + * Enable/disable forced only mode in IMSC captions. + * When true, only those captions where itts:forcedDisplay="true" will be displayed. + * @property {boolean} [imsc.enableRollUp=true] + * Enable/disable rollUp style display of IMSC captions. + * @property {object} [webvtt.customRenderingEnabled=false] * Enables the custom rendering for WebVTT captions. For details refer to the "Subtitles and Captions" sample section of dash.js. * Custom WebVTT rendering requires the external library vtt.js that can be found in the contrib folder. */ @@ -943,6 +952,10 @@ function Settings() { text: { defaultEnabled: true, extendSegmentedCues: true, + imsc: { + displayForcedOnlyMode: false, + enableRollUp: true + }, webvtt: { customRenderingEnabled: false } diff --git a/src/streaming/text/TextTracks.js b/src/streaming/text/TextTracks.js index 762407e722..fdcb097731 100644 --- a/src/streaming/text/TextTracks.js +++ b/src/streaming/text/TextTracks.js @@ -413,10 +413,10 @@ function TextTracks(config) { captionContainer.appendChild(finalCue); previousISDState = renderHTML(cue.isd, finalCue, function (src) { return _resolveImageSrc(cue, src); - }, captionContainer.clientHeight, captionContainer.clientWidth, false/*displayForcedOnlyMode*/, function (err) { + }, captionContainer.clientHeight, captionContainer.clientWidth, settings.get().streaming.text.imsc.displayForcedOnlyMode, function (err) { logger.info('renderCaption :', err); //TODO add ErrorHandler management - }, previousISDState, true /*enableRollUp*/); + }, previousISDState, settings.get().streaming.text.imsc.enableRollUp); finalCue.id = cue.cueID; eventBus.trigger(MediaPlayerEvents.CAPTION_RENDERED, { captionDiv: finalCue, currentTrackIdx }); }