blob: 54e7111ba195111d58ce681a8604cef24b91859b [file] [log] [blame]
<!DOCTYPE html>
<html>
<head>
<title>mock-media-source</title>
<script src="mock-media-source.js"></script>
<script src="../video-test.js"></script>
<script>
var source;
var sourceBuffer;
var initSegment;
if (window.internals)
internals.initializeMockMediaSource();
function runTest() {
findMediaElement();
source = new MediaSource();
waitForEventOn(source, 'sourceopen', sourceOpen);
run('video.src = URL.createObjectURL(source)');
}
function sourceOpen() {
run('sourceBuffer = source.addSourceBuffer("video/mock; codecs=mock")');
waitForEventOn(sourceBuffer, 'updateend', loadSamples, false, true);
initSegment = makeAInit(8, [makeATrack(1, 'mock', TRACK_KIND.VIDEO)]);
run('sourceBuffer.appendBuffer(initSegment)');
}
function loadSamples() {
samples = concatenateSamples([
makeASample(0, 0, 1, 1, 1, SAMPLE_FLAG.SYNC),
makeASample(1, 1, 1, 1, 1, SAMPLE_FLAG.NONE),
makeASample(2, 2, 1, 1, 1, SAMPLE_FLAG.NONE),
makeASample(3, 3, 1, 1, 1, SAMPLE_FLAG.NONE),
makeASample(4, 4, 1, 1, 1, SAMPLE_FLAG.SYNC),
makeASample(5, 5, 1, 1, 1, SAMPLE_FLAG.NONE),
makeASample(6, 6, 1, 1, 1, SAMPLE_FLAG.NONE),
makeASample(7, 7, 1, 1, 1, SAMPLE_FLAG.NONE),
]);
waitForEventOn(sourceBuffer, 'updateend', remove, false, true);
run('sourceBuffer.appendBuffer(samples)');
}
function remove() {
waitForEventOn(sourceBuffer, 'updateend', checkRemoved, false, true);
run('sourceBuffer.remove(0, 2)');
}
function checkRemoved() {
testExpected('sourceBuffer.buffered.start(0)', 4);
endTest();
}
</script>
</head>
<body onload="runTest()">
<div>This tests the SourceBuffer.remove() API. The test will remove samples from the given startTime (0) up to but not including the presentation start time of the sync sample (4) after endTime (2).</div>
<video></video>
</body>
</html>