Skip to content

Commit

Permalink
Added liveUpdateTimeThreshold to control time syncing during live str…
Browse files Browse the repository at this point in the history
…eams (#4382)

* Added liveUpdateTimeThresholdInMilliseconds in order to control the frequency of time updates during live streams
  • Loading branch information
matvp91 committed Feb 6, 2024
1 parent db643ad commit 9e3da3c
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 5 deletions.
1 change: 1 addition & 0 deletions index.d.ts
Expand Up @@ -963,6 +963,7 @@ declare namespace dashjs {
abandonLoadTimeout?: number,
wallclockTimeUpdateInterval?: number,
manifestUpdateRetryInterval?: number,
liveUpdateTimeThresholdInMilliseconds?: number,
applyServiceDescription?: boolean,
applyProducerReferenceTime?: boolean,
applyContentSteering?: boolean,
Expand Down
4 changes: 4 additions & 0 deletions src/core/Settings.js
Expand Up @@ -62,6 +62,7 @@ import Events from './events/Events';
* abandonLoadTimeout: 10000,
* wallclockTimeUpdateInterval: 100,
* manifestUpdateRetryInterval: 100,
* liveUpdateTimeThresholdInMilliseconds: 0,
* cacheInitSegments: false,
* applyServiceDescription: true,
* applyProducerReferenceTime: true,
Expand Down Expand Up @@ -744,6 +745,8 @@ import Events from './events/Events';
* How frequently the wallclockTimeUpdated internal event is triggered (in milliseconds).
* @property {number} [manifestUpdateRetryInterval=100]
* For live streams, set the interval-frequency in milliseconds at which dash.js will check if the current manifest is still processed before downloading the next manifest once the minimumUpdatePeriod time has.
* @property {number} [liveUpdateTimeThresholdInMilliseconds=0]
* For live streams, postpone syncing time updates until the threshold is passed. Increase if problems occurs during live streams on low end devices.
* @property {boolean} [cacheInitSegments=false]
* Enables the caching of init segments to avoid requesting the init segments before each representation switch.
* @property {boolean} [applyServiceDescription=true]
Expand Down Expand Up @@ -874,6 +877,7 @@ function Settings() {
abandonLoadTimeout: 10000,
wallclockTimeUpdateInterval: 100,
manifestUpdateRetryInterval: 100,
liveUpdateTimeThresholdInMilliseconds: 0,
cacheInitSegments: false,
applyServiceDescription: true,
applyProducerReferenceTime: true,
Expand Down
16 changes: 11 additions & 5 deletions src/streaming/controllers/PlaybackController.js
Expand Up @@ -58,6 +58,7 @@ function PlaybackController() {
isDynamic,
playOnceInitialized,
lastLivePlaybackTime,
lastLiveUpdateTime,
availabilityStartTime,
availabilityTimeComplete,
lowLatencyModeEnabled,
Expand Down Expand Up @@ -88,6 +89,7 @@ function PlaybackController() {
lowLatencyModeEnabled = false;
initialCatchupModeActivated = false;
seekTarget = NaN;
lastLiveUpdateTime = NaN;

if (videoModel) {
eventBus.off(Events.DATA_UPDATE_COMPLETED, _onDataUpdateCompleted, instance);
Expand Down Expand Up @@ -723,11 +725,15 @@ function PlaybackController() {
// Updates playback time for paused dynamic streams
// (video element doesn't call timeupdate when the playback is paused)
if (getIsDynamic()) {
streamController.addDVRMetric();
if (isPaused()) {
_updateLivePlaybackTime();
} else {
updateCurrentTime();
const now = Date.now();
if (isNaN(lastLiveUpdateTime) || now > lastLiveUpdateTime + settings.get().streaming.liveUpdateTimeThresholdInMilliseconds) {
streamController.addDVRMetric();
if (isPaused()) {
_updateLivePlaybackTime();
} else {
updateCurrentTime();
}
lastLiveUpdateTime = now;
}
}
}
Expand Down

0 comments on commit 9e3da3c

Please sign in to comment.