blob: 787490945e7661132954a2ff5cf6371cf7558722 [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 mediaSegment;
if (window.internals)
internals.initializeMockMediaSource();
function runTest() {
findMediaElement();
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")');
waitForEventOn(sourceBuffer, 'updateend', updateEnd1, false, true);
mediaSegment = concatenateSamples([
makeAInit(10, [makeATrack(1, 'mock', TRACK_KIND.VIDEO)]),
makeASample(0, 0, 5, 1, 1, SAMPLE_FLAG.SYNC, 0),
]);
run('sourceBuffer.appendBuffer(mediaSegment)');
}
function updateEnd1() {
testExpected('source.duration.toFixed(3)', 10);
testExpected('sourceBuffer.buffered.end(0).toFixed(3)', 5);
waitForEventOn(source, 'sourceopen', function() { failTest("Should not transit to 'open' state during endOfStream().") }, false, true);
run('source.endOfStream()');
testExpected('source.duration.toFixed(3)', 5);
testExpected('sourceBuffer.updating', false);
endTest();
}
</script>
</head>
<body onload="runTest()">
<video></video>
</body>
</html>