Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: don't clear DASH minimum update period timeout on pause of a media loader #1118

Merged
merged 2 commits into from
Apr 20, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions src/dash-playlist-loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -517,9 +517,11 @@ export default class DashPlaylistLoader extends EventTarget {
}
this.stopRequest();
window.clearTimeout(this.mediaUpdateTimeout);
window.clearTimeout(this.masterPlaylistLoader_.minimumUpdatePeriodTimeout_);
this.masterPlaylistLoader_.minimumUpdatePeriodTimeout_ = null;
this.mediaUpdateTimeout = null;
if (this.isMaster_) {
window.clearTimeout(this.masterPlaylistLoader_.minimumUpdatePeriodTimeout_);
this.masterPlaylistLoader_.minimumUpdatePeriodTimeout_ = null;
}
if (this.state === 'HAVE_NOTHING') {
// If we pause the loader before any data has been retrieved, its as if we never
// started, so reset to an unstarted state.
Expand Down Expand Up @@ -548,6 +550,15 @@ export default class DashPlaylistLoader extends EventTarget {
}

if (media && !media.endList) {
// Check to see if this is the master loader and the MUP was cleared (this happens
// when the loader was paused). `media` should be set at this point since one is always
// set during `start()`.
if (this.isMaster_ && !this.minimumUpdatePeriodTimeout_) {
// Trigger minimumUpdatePeriod to refresh the master manifest
this.trigger('minimumUpdatePeriod');
// Since there was no prior minimumUpdatePeriodTimeout it should be recreated
this.updateMinimumUpdatePeriodTimeout_();
}
this.trigger('mediaupdatetimeout');
} else {
this.trigger('loadedplaylist');
Expand Down
68 changes: 68 additions & 0 deletions test/dash-playlist-loader.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2690,3 +2690,71 @@ QUnit.test('load does not resume the media update timer for non live playlists',

assert.notOk(loader.mediaUpdateTimeout, 'media update timeout not set');
});

QUnit.test('pause removes minimum update period timeout', function(assert) {
const loader = new DashPlaylistLoader('dash-live.mpd', this.fakeVhs);

loader.load();
this.standardXHRResponse(this.requests.shift());
this.clock.tick(1);

assert.ok(loader.minimumUpdatePeriodTimeout_, 'minimum update period timeout set');

loader.pause();

assert.notOk(
loader.minimumUpdatePeriodTimeout_,
'minimum update period timeout not set'
);
});

QUnit.test('load resumes minimum update period timeout for live', function(assert) {
const loader = new DashPlaylistLoader('dash-live.mpd', this.fakeVhs);

loader.load();
this.standardXHRResponse(this.requests.shift());
this.clock.tick(1);

// media should be selected at this point
loader.media(loader.master.playlists[0]);

assert.ok(loader.minimumUpdatePeriodTimeout_, 'minimum update period timeout set');

loader.pause();

assert.notOk(
loader.minimumUpdatePeriodTimeout_,
'minimum update period timeout not set'
);

loader.load();

assert.ok(loader.minimumUpdatePeriodTimeout_, 'minimum update period timeout set');
});

QUnit.test('pause does not remove minimum update period timeout when not master', function(assert) {
const masterLoader = new DashPlaylistLoader('dash-live.mpd', this.fakeVhs);

masterLoader.load();
this.standardXHRResponse(this.requests.shift());
this.clock.tick(1);

const media = masterLoader.master.playlists[0];
// media should be selected at this point

masterLoader.media(media);

const mediaLoader = new DashPlaylistLoader(media, this.fakeVhs, {}, masterLoader);

assert.ok(
masterLoader.minimumUpdatePeriodTimeout_,
'minimum update period timeout set'
);

mediaLoader.pause();

assert.ok(
masterLoader.minimumUpdatePeriodTimeout_,
'minimum update period timeout set'
);
});