blob: 904fb0404acd2636e3256c60d1521c39c95650a0 [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;
var mediaSegment;
if (window.internals)
internals.initializeMockMediaSource();
function runTest() {
findMediaElement();
mediaSegment = concatenateSamples([
makeAInit(0, [makeATrack(1, 'mock', TRACK_KIND.VIDEO)])
, makeASample(0, 0, 1, 1, 1, SAMPLE_FLAG.SYNC, 0)
, makeASample(1, 1, 1, 1, 1, SAMPLE_FLAG.NONE, 0)
, makeASample(2, 2, 1, 1, 1, SAMPLE_FLAG.NONE, 0)
, makeASample(3, 3, 1, 1, 1, SAMPLE_FLAG.NONE, 0)
, makeASample(4, 4, 1, 1, 1, SAMPLE_FLAG.SYNC, 0)
, makeASample(5, 5, 1, 1, 1, SAMPLE_FLAG.NONE, 0)
, makeASample(6, 6, 1, 1, 1, SAMPLE_FLAG.NONE, 0)
, makeASample(7, 7, 1, 1, 1, SAMPLE_FLAG.NONE, 0)
, makeASample(8, 8, 1, 1, 1, SAMPLE_FLAG.SYNC, 0)
, makeASample(9, 9, 1, 1, 1, SAMPLE_FLAG.NONE, 0)
, makeASample(10, 10, 1, 1, 1, SAMPLE_FLAG.NONE, 0)
, makeASample(11, 11, 1, 1, 1, SAMPLE_FLAG.NONE, 0)
, makeASample(12, 12, 1, 1, 1, SAMPLE_FLAG.SYNC, 0)
, makeASample(13, 13, 1, 1, 1, SAMPLE_FLAG.NONE, 0)
, makeASample(14, 14, 1, 1, 1, SAMPLE_FLAG.NONE, 0)
, makeASample(15, 15, 1, 1, 1, SAMPLE_FLAG.NONE, 0)
]);
source = new MediaSource();
waitForEventOn(source, 'sourceopen', sourceOpen, false, true);
run('video.src = URL.createObjectURL(source)');
}
function sourceOpen() {
run('sourceBuffer = source.addSourceBuffer("video/mock; codecs=mock")');
testExpected('sourceBuffer.appendWindowStart', 0);
testExpected('sourceBuffer.appendWindowEnd', Number.POSITIVE_INFINITY);
run('sourceBuffer.appendWindowEnd = 7.5');
run('sourceBuffer.appendWindowStart = 3.5');
waitForEventOn(sourceBuffer, 'updateend', updateEnd1, false, true);
run('sourceBuffer.appendBuffer(mediaSegment)');
}
function updateEnd1() {
testExpected('sourceBuffer.buffered.start(0)', 4);
testExpected('sourceBuffer.buffered.end(0)' , 7.5, "<"); // because of microsecond added to buffered we don't use equality here
run('sourceBuffer.appendWindowStart = 0');
waitForEventOn(sourceBuffer, 'updateend', updateEnd2, false, true);
run('sourceBuffer.appendBuffer(mediaSegment)');
}
function updateEnd2() {
testExpected('sourceBuffer.buffered.length', 1);
testExpected('sourceBuffer.buffered.start(0)', 0);
testExpected('sourceBuffer.buffered.end(0)' , 7.5, "<");
run('sourceBuffer.appendWindowEnd = 14.5');
run('sourceBuffer.appendWindowStart = 11');
waitForEventOn(sourceBuffer, 'updateend', updateEnd3, false, true);
run('sourceBuffer.appendBuffer(mediaSegment)');
}
function updateEnd3() {
testExpected('sourceBuffer.buffered.length', 2);
testExpected('sourceBuffer.buffered.start(1)', 12);
testExpected('sourceBuffer.buffered.end(1)' , 14.5, "<");
endTest();
}
</script>
</head>
<body onload="runTest()">
<video></video>
</body>
</html>