Skip to content

Commit

Permalink
Stabilize the new duration truncation test using timeStampOffset
Browse files Browse the repository at this point in the history
  • Loading branch information
wolenetz committed Sep 7, 2016
1 parent 529c6ca commit c21af2b
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions media-source/mediasource-duration.html
Original file line number Diff line number Diff line change
Expand Up @@ -305,27 +305,32 @@
var sourceBufferVideo = mediaSource.addSourceBuffer(typeVideo);

// Buffer audio [0.8,1.8)
sourceBufferAudio.appendWindowStart = 0.8;
sourceBufferAudio.timestampOffset = 0.8;
sourceBufferAudio.appendWindowEnd = 1.8;
sourceBufferAudio.appendBuffer(dataAudio);

// Buffer video [1.5,2.5)
sourceBufferVideo.appendWindowStart = 1.5;
sourceBufferVideo.appendWindowEnd = 2.5;
// Buffer video [1.5,3)
sourceBufferVideo.timestampOffset = 1.5;
sourceBufferVideo.appendWindowEnd = 3;
sourceBufferVideo.appendBuffer(dataVideo);

test.expectEvent(sourceBufferAudio, "updateend");
test.expectEvent(sourceBufferVideo, "updateend");
test.waitForExpectedEvents(function()
{
var newDuration = 2.0;

// Verify the test setup
assert_equals(sourceBufferAudio.buffered.length, 1);
assert_equals(sourceBufferVideo.buffered.length, 1);
assert_greater_than(sourceBufferAudio.buffered.end(0), 1.5);
assert_less_than(sourceBufferAudio.buffered.end(0), newDuration);
assert_greater_than(sourceBufferVideo.buffered.end(0), newDuration);
assert_less_than(sourceBufferVideo.buffered.start(0), newDuration);
assert_greater_than(sourceBufferVideo.buffered.end(0), newDuration + 0.5);

// Verify the expected error
// We assume relocated test video has at least one coded
// frame presentation interval which fits in [>2.0,2.5)
// frame presentation interval which fits in [>2.0,>2.5)
assert_throws("InvalidStateError", function () { mediaSource.duration = newDuration; });
test.done();
});
Expand Down

0 comments on commit c21af2b

Please sign in to comment.