Skip to content

Commit

Permalink
Handling (2/3) of reviewer comments.
Browse files Browse the repository at this point in the history
  • Loading branch information
JulianDomingo committed Oct 4, 2022
1 parent 7728847 commit 66d572e
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 10 deletions.
3 changes: 2 additions & 1 deletion lib/media/media_source_engine.js
Original file line number Diff line number Diff line change
Expand Up @@ -551,7 +551,8 @@ shaka.media.MediaSourceEngine = class {
* @return {!Promise}
*/
async appendBuffer(
contentType, data, reference, hasClosedCaptions, seeked, adaptation) {
contentType, data, reference, hasClosedCaptions, seeked = false,
adaptation = false) {
const ContentType = shaka.util.ManifestParserUtils.ContentType;

if (contentType == ContentType.TEXT) {
Expand Down
28 changes: 19 additions & 9 deletions test/media/media_source_engine_unit.js
Original file line number Diff line number Diff line change
Expand Up @@ -651,7 +651,7 @@ describe('MediaSourceEngine', () => {
});

it('calls abort before setting timestampOffset', async () => {
const delay = async () => {
const simulateUpdate = async () => {
await Util.shortDelay();
videoSourceBuffer.updateend();
};
Expand All @@ -667,14 +667,19 @@ describe('MediaSourceEngine', () => {
let appendVideo = mediaSourceEngine.appendBuffer(
ContentType.VIDEO, buffer, reference, /* hasClosedCaptions= */ false);
// Wait for the first appendBuffer(), in segments mode.
await delay();
await simulateUpdate();
// Next, wait for abort(), used to reset the parser state for a safe
// setting of timestampOffset.
await delay();
// setting of timestampOffset. Shaka fakes an updateend event on abort(),
// so simulateUpdate() isn't needed.
await Util.shortDelay();
// Next, wait for remove(), used to clear the SourceBuffer from the
// initial append.
await delay();
// Lastly, wait for the resolved mediaSourceEngine.appendBuffer() promise.
await simulateUpdate();
// Next, wait for the second appendBuffer(), falling through to normal
// operations.
await simulateUpdate();
// Lastly, wait for the function-scoped MediaSourceEngine#appendBuffer()
// promise to resolve.
await appendVideo;
expect(videoSourceBuffer.abort).toHaveBeenCalledTimes(1);

Expand All @@ -686,10 +691,15 @@ describe('MediaSourceEngine', () => {
/* seeked= */ true);
// First, wait for abort(), used to reset the parser state for a safe
// setting of timestampOffset.
await delay();
await Util.shortDelay();
// The subsequent setTimestampOffset() fakes an updateend event for us, so
// another delay() isn't needed.
// Lastly, wait for the resolved mediaSourceEngine.appendBuffer() promise.
// simulateUpdate() isn't needed.
await Util.shortDelay();
// Next, wait for the second appendBuffer(), falling through to normal
// operations.
await simulateUpdate();
// Lastly, wait for the function-scoped MediaSourceEngine#appendBuffer()
// promise to resolve.
await appendVideo;
expect(videoSourceBuffer.abort).toHaveBeenCalledTimes(2);
});
Expand Down

0 comments on commit 66d572e

Please sign in to comment.