| ... | ... | @@ -60,7 +60,7 @@ An MPD update triggers an event to attempt a clock synchronization. The `TimeSyn |
|
|
|
```javascript
|
|
|
|
function _shouldPerformSynchronization() {
|
|
|
|
try {
|
|
|
|
const timeBetweenSyncAttempts = settings.get().streaming.utcSynchronization.timeBetweenSyncAttempts;
|
|
|
|
const timeBetweenSyncAttempts = !isNaN(internalTimeBetweenSyncAttempts) ? internalTimeBetweenSyncAttempts : DEFAULT_TIME_BETWEEN_SYNC_ATTEMPTS;
|
|
|
|
|
|
|
|
if (!timeOfLastSync || !timeBetweenSyncAttempts || isNaN(timeBetweenSyncAttempts)) {
|
|
|
|
return true;
|
| ... | ... | @@ -87,13 +87,12 @@ player.updateSettings({ |
|
|
|
})
|
|
|
|
```
|
|
|
|
#### Post-synchronization parameter adjustment
|
|
|
|
After each regular synchronization attempt, dash.js adjusts the `timeBetweenSyncAttempts` parameter based on certain criteria:
|
|
|
|
After each regular synchronization attempt, dash.js adjusts its internal `internalTimeBetweenSyncAttempts` parameter based on certain criteria:
|
|
|
|
|
|
|
|
```javascript
|
|
|
|
function _adjustTimeBetweenSyncAttempts(offset) {
|
|
|
|
try {
|
|
|
|
const isOffsetDriftWithinThreshold = _isOffsetDriftWithinThreshold(offset);
|
|
|
|
const timeBetweenSyncAttempts = !isNaN(settings.get().streaming.utcSynchronization.timeBetweenSyncAttempts) ? settings.get().streaming.utcSynchronization.timeBetweenSyncAttempts : DEFAULT_TIME_BETWEEN_SYNC_ATTEMPTS;
|
|
|
|
const timeBetweenSyncAttempts = !isNaN(internalTimeBetweenSyncAttempts) ? internalTimeBetweenSyncAttempts : DEFAULT_TIME_BETWEEN_SYNC_ATTEMPTS;
|
|
|
|
const timeBetweenSyncAttemptsAdjustmentFactor = !isNaN(settings.get().streaming.utcSynchronization.timeBetweenSyncAttemptsAdjustmentFactor) ? settings.get().streaming.utcSynchronization.timeBetweenSyncAttemptsAdjustmentFactor : DEFAULT_TIME_BETWEEN_SYNC_ATTEMPTS_ADJUSTMENT_FACTOR;
|
|
|
|
const maximumTimeBetweenSyncAttempts = !isNaN(settings.get().streaming.utcSynchronization.maximumTimeBetweenSyncAttempts) ? settings.get().streaming.utcSynchronization.maximumTimeBetweenSyncAttempts : DEFAULT_MAXIMUM_TIME_BETWEEN_SYNC;
|
|
|
|
const minimumTimeBetweenSyncAttempts = !isNaN(settings.get().streaming.utcSynchronization.minimumTimeBetweenSyncAttempts) ? settings.get().streaming.utcSynchronization.minimumTimeBetweenSyncAttempts : DEFAULT_MINIMUM_TIME_BETWEEN_SYNC;
|
| ... | ... | @@ -109,11 +108,7 @@ After each regular synchronization attempt, dash.js adjusts the `timeBetweenSync |
|
|
|
logger.debug(`Decreasing timeBetweenSyncAttempts to ${adjustedTimeBetweenSyncAttempts}`);
|
|
|
|
}
|
|
|
|
|
|
|
|
settings.update({ streaming: { utcSynchronization: { timeBetweenSyncAttempts: adjustedTimeBetweenSyncAttempts } } });
|
|
|
|
} catch (e) {
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
internalTimeBetweenSyncAttempts = adjustedTimeBetweenSyncAttempts;
|
|
|
|
```
|
|
|
|
|
|
|
|
In the first step the player checks if the offset is within certain boundaries:
|
| ... | ... | @@ -137,7 +132,7 @@ In the first step the player checks if the offset is within certain boundaries: |
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
Depending on whether the offset is included in the calculated boundaries, `timeBetweenSyncAttempts` is either multiplied or divided by `timeBetweenSyncAttemptsAdjustmentFactor`. By assigning specific values to `maximumTimeBetweenSyncAttempts` and `minimumTimeBetweenSyncAttempts` upper and lower bounds for `timeBetweenSyncAttempts` can be set.
|
|
|
|
Depending on whether the offset is included in the calculated boundaries, `adjustedTimeBetweenSyncAttempts` is derived by either multiplying or dividing the current `internalTimeBetweenSyncAttempts` by `timeBetweenSyncAttemptsAdjustmentFactor`. By assigning specific values to `maximumTimeBetweenSyncAttempts` and `minimumTimeBetweenSyncAttempts` upper and lower bounds for `internalTimeBetweenSyncAttempts` can be set.
|
|
|
|
|
|
|
|
The parameters can be adjusted in the settings:
|
|
|
|
```javascript
|
| ... | ... | @@ -186,7 +181,7 @@ The available configuration parameters: |
|
|
|
| Parameter | Description |
|
|
|
|
| ------------- |:-------------:|
|
|
|
|
| backgroundAttempts | Number of synchronization attempts to perform in the background after an initial synchronization request has been done. This is used to verify that the derived client-server offset is correct. |
|
|
|
|
| timeBetweenSyncAttempts | The time in seconds between two consecutive sync attempts. |
|
|
|
|
| timeBetweenSyncAttempts | The time in seconds between two consecutive sync attempts. Note: This value is used as an initial starting value. The internal value of the TimeSyncController is adjusted during playback based on the drift between two consecutive synchronization attempts. |
|
|
|
|
| maximumTimeBetweenSyncAttempts | The maximum time in seconds between two consecutive sync attempts. |
|
|
|
|
| minimumTimeBetweenSyncAttempts | The minimum time in seconds between two consecutive sync attempts|
|
|
|
|
| timeBetweenSyncAttemptsAdjustmentFactor | The factor used to multiply or divide the timeBetweenSyncAttempts parameter after a sync. The maximumAllowedDrift defines whether this value is used as a factor or a dividend. |
|
| ... | ... | |
| ... | ... | |