| ... | ... | @@ -34,10 +34,10 @@ The default timing source in dash.js uses the following schemeIdUri/value combin |
|
|
|
```
|
|
|
|
`UTCTiming` elements in the MPD take precedence over the default timing source specified in the settings.
|
|
|
|
|
|
|
|
### Default synchronization
|
|
|
|
### Regular synchronization
|
|
|
|
By default, dash.js performs a clock synchronization at playback start and after each MPD update.
|
|
|
|
|
|
|
|
#### Startup synchronization
|
|
|
|
#### Synchronization at startup
|
|
|
|
At playback start an initial request to the timing server is issued. The offset between the client and the server clock is calculated as described in Section _Offset calculation_.
|
|
|
|
|
|
|
|
In addition, dash.js performs a predefined number of background requests to verify the initially calculated offset. The number of background attempts can be adjusted in the settings:
|
| ... | ... | @@ -54,13 +54,62 @@ player.updateSettings({ |
|
|
|
|
|
|
|
For further details on background synchronization check the Section _Background synchronization_
|
|
|
|
|
|
|
|
### Error synchronization
|
|
|
|
#### Synchronization after MPD updates
|
|
|
|
By default, dash.js initiates a synchronization request after each MPD update. This behavior is modified by certain settings parameters. The general workflow is as follows:
|
|
|
|
|
|
|
|
An MPD update triggers an event to attempt a clock synchronization. The `TimeSyncController` handles the event and checks if a synchronization request is to be made:
|
|
|
|
|
|
|
|
```javascript
|
|
|
|
function _shouldPerformSynchronization() {
|
|
|
|
try {
|
|
|
|
const timeBetweenSyncAttempts = settings.get().streaming.utcSynchronization.timeBetweenSyncAttempts;
|
|
|
|
|
|
|
|
if (!timeOfLastSync || !timeBetweenSyncAttempts || isNaN(timeBetweenSyncAttempts)) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return ((Date.now() - timeOfLastSync) / 1000) >= timeBetweenSyncAttempts;
|
|
|
|
} catch (e) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
`_shouldPerformSynchronization()` compares the current wallclock time against the time of the last sync attempt. If the difference is larger than `timeBetweenSyncAttempts` a synchronization request is issued.
|
|
|
|
|
|
|
|
The initial time between the sync attempts can be configured the following way:
|
|
|
|
|
|
|
|
```javascript
|
|
|
|
player.updateSettings({
|
|
|
|
streaming: {
|
|
|
|
utcSynchronization: {
|
|
|
|
timeBetweenSyncAttempts: 30
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
```
|
|
|
|
#### Post-synchronization parameter adjustment
|
|
|
|
After each regular synchronization attempt dash.js adjusts the `timeBetweenSyncAttempts` parameter based
|
|
|
|
|
|
|
|
### Synchronization after download errors
|
|
|
|
In addition to regular synchronization attempts dash.js triggers a background synchronization in case requests to media segments result in errors (e.g 404 errors). This is to make sure that the client clock is still synchronized and the request error is not caused by an erroneous offset.
|
|
|
|
|
|
|
|
This feature can be enabled/disabled by adjusting the settings:
|
|
|
|
```javascript
|
|
|
|
player.updateSettings({
|
|
|
|
streaming: {
|
|
|
|
utcSynchronization: {
|
|
|
|
enableBackgroundSyncAfterSegmentDownloadError: true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
```
|
|
|
|
|
|
|
|
### Background synchronization
|
|
|
|
|
|
|
|
### Offset calculation
|
|
|
|
|
|
|
|
### Complete Configuration
|
|
|
|
### Configuration example
|
|
|
|
|
|
|
|
## References
|
|
|
|
* [1] [DASH-IF Implementation Guidelines](https://dashif-documents.azurewebsites.net/Guidelines-TimingModel/master/Guidelines-TimingModel.html#clock-sync)
|
| ... | ... | |
| ... | ... | |