-
Notifications
You must be signed in to change notification settings - Fork 425
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: check sidx on sidxmapping, check that end > start on remove #1121
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1154,6 +1154,14 @@ export default class SegmentLoader extends videojs.EventTarget { | |
end = this.duration_(); | ||
} | ||
|
||
// skip removes that would throw an error | ||
// commonly happens during a rendition switch at the start of a video | ||
// from start 0 to end 0 | ||
if (end <= start) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I was seeing a sourcebuffer remove error being thrown when trying to remove from 0 -> 0 at the start of a video, as end is <= start. |
||
this.logger_('skipping remove because end ${end} is <= start ${start}'); | ||
return; | ||
} | ||
|
||
if (!this.sourceUpdater_ || !this.startingMediaInfo_) { | ||
this.logger_('skipping remove because no source updater or starting media info'); | ||
// nothing to remove if we haven't processed any media | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2633,8 +2633,48 @@ QUnit.module('SegmentLoader', function(hooks) { | |
}); | ||
}); | ||
|
||
QUnit.test('triggers appenderror when append errors', function(assert) { | ||
QUnit.test('does not remove when end <= start', function(assert) { | ||
let audioRemoves = 0; | ||
let videoRemoves = 0; | ||
|
||
return setupMediaSource(loader.mediaSource_, loader.sourceUpdater_).then(() => { | ||
const playlist = playlistWithDuration(40); | ||
|
||
loader.playlist(playlist); | ||
loader.load(); | ||
this.clock.tick(1); | ||
|
||
loader.sourceUpdater_.removeAudio = (start, end) => { | ||
audioRemoves++; | ||
}; | ||
loader.sourceUpdater_.removeVideo = (start, end) => { | ||
videoRemoves++; | ||
}; | ||
|
||
assert.equal(audioRemoves, 0, 'no audio removes'); | ||
assert.equal(videoRemoves, 0, 'no video removes'); | ||
|
||
standardXHRResponse(this.requests.shift(), muxedSegment()); | ||
return new Promise((resolve, reject) => { | ||
loader.one('appended', resolve); | ||
loader.one('error', reject); | ||
}); | ||
}).then(() => { | ||
loader.remove(0, 0, () => {}); | ||
assert.equal(audioRemoves, 0, 'no audio remove'); | ||
assert.equal(videoRemoves, 0, 'no video remove'); | ||
|
||
loader.remove(5, 4, () => {}); | ||
assert.equal(audioRemoves, 0, 'no audio remove'); | ||
assert.equal(videoRemoves, 0, 'no video remove'); | ||
Comment on lines
+2663
to
+2669
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It may be worth having one positive case after to ensure that the removes would be incremented appropriately. |
||
|
||
loader.remove(0, 4, () => {}); | ||
assert.equal(audioRemoves, 1, 'valid remove works'); | ||
assert.equal(videoRemoves, 1, 'valid remove works'); | ||
}); | ||
}); | ||
|
||
QUnit.test('triggers appenderror when append errors', function(assert) { | ||
return setupMediaSource(loader.mediaSource_, loader.sourceUpdater_).then(() => { | ||
return new Promise((resolve, reject) => { | ||
loader.one('appenderror', resolve); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in
addSidxSegmentsToPlaylist
we try to usesidxMappind[sidxKey].sidx
but it can be undefined if the request for sidx and parsing is still in progress (at which point it will be added). So we need to add the additional key check here.