-
Notifications
You must be signed in to change notification settings - Fork 426
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: only append init segment on change #1128
Changes from all commits
a12e38a
172c7d8
c6d9ee8
e9b73cb
a61d7f2
f7aab4d
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 |
---|---|---|
|
@@ -3079,7 +3079,7 @@ QUnit.module('SegmentLoader', function(hooks) { | |
origAppendToSourceBuffer(config); | ||
}; | ||
|
||
const playlist = playlistWithDuration(30); | ||
const playlist = playlistWithDuration(40); | ||
|
||
playlist.segments[0].map = { | ||
resolvedUri: 'init.mp4', | ||
|
@@ -3096,6 +3096,11 @@ QUnit.module('SegmentLoader', function(hooks) { | |
byterange: { length: Infinity, offset: 0 } | ||
}; | ||
|
||
playlist.segments[3].map = { | ||
resolvedUri: 'init.mp4', | ||
byterange: { length: Infinity, offset: 0 } | ||
}; | ||
|
||
loader.playlist(playlist); | ||
loader.load(); | ||
this.clock.tick(1); | ||
|
@@ -3142,6 +3147,9 @@ QUnit.module('SegmentLoader', function(hooks) { | |
appends[1].initSegment, | ||
'appended a different init segment' | ||
); | ||
// force init segment append to prove that init segments are not | ||
// re-requested, but will be re-appended when needed. | ||
loader.appendInitSegment_.audio = true; | ||
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. These tests were relying on re-appending init segments, which shoudn't happen here, but I think these tests are still valuable. 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's probably worth adding those details to the comment (here and below) to ensure we don't forget why we force it in the future. |
||
|
||
// no init segment request, as it should be the same (and cached) segment | ||
standardXHRResponse(this.requests.shift(), mp4AudioSegment()); | ||
|
@@ -3150,6 +3158,7 @@ QUnit.module('SegmentLoader', function(hooks) { | |
loader.one('error', reject); | ||
}); | ||
}).then(() => { | ||
this.clock.tick(1); | ||
|
||
assert.equal(appends.length, 3, 'one more append'); | ||
assert.equal(appends[2].type, 'audio', 'appended to audio buffer'); | ||
|
@@ -3159,6 +3168,17 @@ QUnit.module('SegmentLoader', function(hooks) { | |
appends[2].initSegment, | ||
'reused the init segment' | ||
); | ||
|
||
// no init segment request, as it should be the same (and cached) segment | ||
standardXHRResponse(this.requests.shift(), mp4AudioSegment()); | ||
return new Promise((resolve, reject) => { | ||
loader.one('appended', resolve); | ||
loader.one('error', reject); | ||
}); | ||
}).then(() => { | ||
assert.equal(appends.length, 4, 'one more append'); | ||
assert.equal(appends[3].type, 'audio', 'appended to audio buffer'); | ||
assert.notOk(appends[3].initSegment, 'did not append audio init segment'); | ||
}); | ||
}); | ||
|
||
|
@@ -3176,7 +3196,7 @@ QUnit.module('SegmentLoader', function(hooks) { | |
origAppendToSourceBuffer(config); | ||
}; | ||
|
||
const playlist = playlistWithDuration(30); | ||
const playlist = playlistWithDuration(40); | ||
|
||
playlist.segments[0].map = { | ||
resolvedUri: 'init.mp4', | ||
|
@@ -3193,6 +3213,11 @@ QUnit.module('SegmentLoader', function(hooks) { | |
byterange: { length: Infinity, offset: 0 } | ||
}; | ||
|
||
playlist.segments[3].map = { | ||
resolvedUri: 'init.mp4', | ||
byterange: { length: Infinity, offset: 0 } | ||
}; | ||
|
||
loader.playlist(playlist); | ||
loader.load(); | ||
this.clock.tick(1); | ||
|
@@ -3229,13 +3254,18 @@ QUnit.module('SegmentLoader', function(hooks) { | |
'appended a different init segment' | ||
); | ||
|
||
// force init segment append to prove that init segments are not | ||
// re-requested, but will be re-appended when needed. | ||
loader.appendInitSegment_.video = true; | ||
|
||
// no init segment request, as it should be the same (and cached) segment | ||
standardXHRResponse(this.requests.shift(), mp4VideoSegment()); | ||
return new Promise((resolve, reject) => { | ||
loader.one('appended', resolve); | ||
loader.one('error', reject); | ||
}); | ||
}).then(() => { | ||
this.clock.tick(1); | ||
|
||
assert.equal(appends.length, 3, 'one more append'); | ||
assert.equal(appends[2].type, 'video', 'appended to video buffer'); | ||
|
@@ -3245,6 +3275,17 @@ QUnit.module('SegmentLoader', function(hooks) { | |
appends[2].initSegment, | ||
'reused the init segment' | ||
); | ||
|
||
// no init segment request, as it should be the same (and cached) segment | ||
standardXHRResponse(this.requests.shift(), mp4VideoSegment()); | ||
return new Promise((resolve, reject) => { | ||
loader.one('appended', resolve); | ||
loader.one('error', reject); | ||
}); | ||
}).then(() => { | ||
assert.equal(appends.length, 4, 'one more append'); | ||
assert.equal(appends[3].type, 'video', 'appended to video buffer'); | ||
assert.notOk(appends[3].initSegment, 'did not append video init segment'); | ||
}); | ||
}); | ||
|
||
|
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.
Should this be dependent on the type that this loader is handling?
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.
I don't think it should because if we get an audio or video init segment on this segment loader, we should re-append it. It won't likely happen for a video only loader or an audio only loader, but at this point we won't actually know what type of content we are requesting, as we get that in trackinfo.