diff options
author | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
---|---|---|
committer | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
commit | 5f8de423f190bbb79a62f804151bc24824fa32d8 (patch) | |
tree | 10027f336435511475e392454359edea8e25895d /dom/media/mediasource/test/test_TimestampOffset_mp4.html | |
parent | 49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff) | |
download | UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip |
Add m-esr52 at 52.6.0
Diffstat (limited to 'dom/media/mediasource/test/test_TimestampOffset_mp4.html')
-rw-r--r-- | dom/media/mediasource/test/test_TimestampOffset_mp4.html | 86 |
1 files changed, 86 insertions, 0 deletions
diff --git a/dom/media/mediasource/test/test_TimestampOffset_mp4.html b/dom/media/mediasource/test/test_TimestampOffset_mp4.html new file mode 100644 index 000000000..2a80e3e5c --- /dev/null +++ b/dom/media/mediasource/test/test_TimestampOffset_mp4.html @@ -0,0 +1,86 @@ +<!DOCTYPE HTML> +<html> +<head> + <title>MSE: basic functionality</title> + <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> + <script type="text/javascript" src="mediasource.js"></script> + <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" /> +</head> +<body> +<pre id="test"> +<script class="testbody" type="text/javascript"> + +SimpleTest.waitForExplicitFinish(); + +function range(start, end) { + var rv = []; + for (var i = start; i < end; ++i) { + rv.push(i); + } + return rv; +} + +var eps = 0.01; +runWithMSE(function(ms, el) { + + once(ms, 'sourceopen').then(function() { + ok(true, "Receive a sourceopen event"); + var audiosb = ms.addSourceBuffer("audio/mp4"); + var videosb = ms.addSourceBuffer("video/mp4"); + // We divide the video into 3 chunks: + // chunk 0: segments 1-4 + // chunk 1: segments 5-8 + // chunk 2: segments 9-13 + // We then fill the timeline so that it seamlessly plays the chunks in order 0, 2, 1. + var vchunks = [ {start: 0, end: 3.2033}, { start: 3.2033, end: 6.4066}, { start: 6.4066, end: 10.01} ]; + var firstvoffset = vchunks[2].end - vchunks[2].start; // Duration of chunk 2 + var secondvoffset = -(vchunks[1].end - vchunks[1].start); // -(Duration of chunk 1) + + fetchAndLoad(videosb, 'bipbop/bipbop_video', ['init'], '.mp4') + .then(fetchAndLoad.bind(null, videosb, 'bipbop/bipbop_video', range(1, 5), '.m4s')) + .then(function() { + is(videosb.buffered.length, 1, "No discontinuity"); + isfuzzy(videosb.buffered.start(0), vchunks[0].start, eps, "Chunk start"); + isfuzzy(videosb.buffered.end(0), vchunks[0].end, eps, "Chunk end"); + videosb.timestampOffset = firstvoffset; + return fetchAndLoad(videosb, 'bipbop/bipbop_video', range(5, 9), '.m4s'); + }) + .then(function(data) { + is(videosb.buffered.length, 2, "One discontinuity"); + isfuzzy(videosb.buffered.start(0), vchunks[0].start, eps, "First Chunk start"); + isfuzzy(videosb.buffered.end(0), vchunks[0].end, eps, "First chunk end"); + isfuzzy(videosb.buffered.start(1), vchunks[1].start + firstvoffset, eps, "Second chunk start"); + isfuzzy(videosb.buffered.end(1), vchunks[1].end + firstvoffset, eps, "Second chunk end"); + videosb.timestampOffset = secondvoffset; + return fetchAndLoad(videosb, 'bipbop/bipbop_video', range(9, 14), '.m4s'); + }) + .then(function() { + is(videosb.buffered.length, 1, "No discontinuity (end)"); + isfuzzy(videosb.buffered.start(0), vchunks[0].start, eps, "Chunk start"); + isfuzzy(videosb.buffered.end(0), vchunks[2].end, eps, "Chunk end"); + audiosb.timestampOffset = 3; + }).then(fetchAndLoad.bind(null, audiosb, 'bipbop/bipbop_audio', ['init'], '.mp4')) + .then(fetchAndLoad.bind(null, audiosb, 'bipbop/bipbop_audio', range(1, 12), '.m4s')) + .then(function() { + is(audiosb.buffered.length, 1, "No audio discontinuity"); + isfuzzy(audiosb.buffered.start(0), 3, eps, "Audio starts at 3"); + + // Trim the rest of the audio. + audiosb.remove(videosb.buffered.end(0), Infinity); + videosb.remove(videosb.buffered.end(0), Infinity); + return Promise.all([audiosb.updating ? once(audiosb, 'updateend') : Promise.resolve(), + videosb.updating ? once(videosb, 'updateend') : Promise.resolve()]); + }).then(function() { + info("waiting for play to complete"); + el.play(); + el.currentTime = el.buffered.start(0); + ms.endOfStream(); + Promise.all([once(el, 'ended'), once(el, 'seeked')]).then(SimpleTest.finish.bind(SimpleTest)); + }); + }); +}); + +</script> +</pre> +</body> +</html> |