Skip to content

Commit

Permalink
Add text.imsc settings for rollUp and displayForcedOnly (#4336)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
nigelmegitt committed Jan 11, 2024
1 parent 81baa66 commit 427b2e7
Show file tree
Hide file tree
Showing 5 changed files with 62 additions and 3 deletions.
4 changes: 4 additions & 0 deletions index.d.ts
Expand Up @@ -1024,6 +1024,10 @@ declare namespace dashjs {
text?: {
defaultEnabled?: boolean,
extendSegmentedCues?: boolean,
imsc?: {
displayForcedOnlyMode?: boolean,
enableRollUp?: boolean
},
webvtt?: {
customRenderingEnabled?: number
}
Expand Down
18 changes: 18 additions & 0 deletions samples/dash-if-reference-player/app/main.js
Expand Up @@ -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 = [];
Expand Down Expand Up @@ -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: {
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -2335,6 +2352,7 @@ app.controller('DashController', ['$scope', '$window', 'sources', 'contributors'
setAdditionalPlaybackOptions();
setAdditionalAbrOptions();
setDrmOptions();
setTextOptions();
setLiveDelayOptions();
setInitialSettings();
setTrackSwitchModeSettings();
Expand Down
24 changes: 24 additions & 0 deletions samples/dash-if-reference-player/index.html
Expand Up @@ -698,6 +698,30 @@
</label>
</div>
</div>
<div class="options-item">
<div class="options-item-title">Text</div>
<div class="options-item-body">
<div class="sub-options-item">
<div class="sub-options-item-title">IMSC</div>
<div class="sub-options-item-body">
<label data-toggle="tooltip" data-placement="right"
title="Enable Roll-up mode">
<input type="checkbox" id="imscEnableRollUp" ng-model="imscEnableRollUp" autocomplete="off" ng-checked="imscEnableRollUp"
ng-change="toggleImscEnableRollUp()" name="inputMode">
Enable Roll-up
</label>
</div>
<div class="sub-options-item-body">
<label data-toggle="tooltip" data-placement="right"
title="Forced Only Mode">
<input type="checkbox" id="imscdisplayForcedOnlyMode" ng-model="imscdisplayForcedOnlyMode" ng-checked="imscdisplayForcedOnlyMode" autocomplete="off"
ng-change="toggleImscdisplayForcedOnlyMode()" name="inputMode">
Forced Only
</label>
</div>
</div>
</div>
</div>
<div class="options-item">
<div class="options-item-title">Initial Settings</div>
<div class="options-item-body">
Expand Down
15 changes: 14 additions & 1 deletion src/core/Settings.js
Expand Up @@ -143,6 +143,10 @@ import Events from './events/Events';
* text: {
* defaultEnabled: true,
* extendSegmentedCues: true,
* imsc: {
* displayForcedOnlyMode: false,
* enableRollUp: true
* },
* webvtt: {
* customRenderingEnabled: false
* }
Expand Down Expand Up @@ -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.
*/
Expand Down Expand Up @@ -943,6 +952,10 @@ function Settings() {
text: {
defaultEnabled: true,
extendSegmentedCues: true,
imsc: {
displayForcedOnlyMode: false,
enableRollUp: true
},
webvtt: {
customRenderingEnabled: false
}
Expand Down
4 changes: 2 additions & 2 deletions src/streaming/text/TextTracks.js
Expand Up @@ -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 });
}
Expand Down

0 comments on commit 427b2e7

Please sign in to comment.