Skip to content

Commit

Permalink
Enable/Disable UTC sync via settings flag (#3802)
Browse files Browse the repository at this point in the history
  • Loading branch information
dsilhavy authored Nov 2, 2021
1 parent 5965ab6 commit c760875
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
1 change: 1 addition & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,7 @@ declare namespace dashjs {
enableSeekFix?: boolean
},
utcSynchronization?: {
enabled?: boolean,
useManifestDateHeaderTimeSource?: boolean,
backgroundAttempts?: number,
timeBetweenSyncAttempts?: number,
Expand Down
5 changes: 4 additions & 1 deletion src/core/Settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ import {HTTPRequest} from '../streaming/vo/metrics/HTTPRequest';
* enableSeekFix: false
* },
* utcSynchronization: {
* enabled: true,
* useManifestDateHeaderTimeSource: true,
* backgroundAttempts: 2,
* timeBetweenSyncAttempts: 30,
Expand Down Expand Up @@ -378,7 +379,8 @@ import {HTTPRequest} from '../streaming/vo/metrics/HTTPRequest';

/**
* @typedef {Object} UtcSynchronizationSettings
*
* @property {boolean} [enabled=true]
* Enables or disables the UTC clock synchronization
* @property {boolean} [useManifestDateHeaderTimeSource=true]
* Allows you to enable the use of the Date Header, if exposed with CORS, as a timing source for live edge detection.
*
Expand Down Expand Up @@ -802,6 +804,7 @@ function Settings() {
enableSeekFix: false
},
utcSynchronization: {
enabled: true,
useManifestDateHeaderTimeSource: true,
backgroundAttempts: 2,
timeBetweenSyncAttempts: 30,
Expand Down
4 changes: 2 additions & 2 deletions src/streaming/controllers/TimeSyncController.js
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ function TimeSyncController() {
* Does a synchronization in the background in case the last offset should be verified or a 404 occurs
*/
function _onAttemptBackgroundSync() {
if (isSynchronizing || isBackgroundSynchronizing || !lastTimingSource || !lastTimingSource.value || !lastTimingSource.schemeIdUri || isNaN(lastOffset) || isNaN(settings.get().streaming.utcSynchronization.backgroundAttempts)) {
if (!settings.get().streaming.utcSynchronization.enabled || isSynchronizing || isBackgroundSynchronizing || !lastTimingSource || !lastTimingSource.value || !lastTimingSource.schemeIdUri || isNaN(lastOffset) || isNaN(settings.get().streaming.utcSynchronization.backgroundAttempts)) {
return;
}

Expand Down Expand Up @@ -287,7 +287,7 @@ function TimeSyncController() {
*/
function _shouldPerformSynchronization(isDynamic) {
try {
if (!isDynamic) {
if (!isDynamic || !settings.get().streaming.utcSynchronization.enabled) {
return false;
}
const timeBetweenSyncAttempts = !isNaN(internalTimeBetweenSyncAttempts) ? internalTimeBetweenSyncAttempts : DEFAULT_TIME_BETWEEN_SYNC_ATTEMPTS;
Expand Down

0 comments on commit c760875

Please sign in to comment.