blob: 446576105fb889d4d0f7864a0498ca806e29ee8c [file] [log] [blame]
jer.noble@apple.com8186af52014-07-21 20:47:03 +00001<!DOCTYPE html>
2<html>
3<head>
4 <title>mock-media-source</title>
5 <script src="mock-media-source.js"></script>
6 <script src="../video-test.js"></script>
7 <script>
8 var source;
9 var sourceBuffer;
10 var initSegment;
11 var samples;
12 var bufferedSamples;
13
14 if (window.internals)
15 internals.initializeMockMediaSource();
16
17 function runTest()
18 {
19 findMediaElement();
20
21 source = new MediaSource();
22 waitForEventOn(source, 'sourceopen', sourceOpen);
23 run('video.src = URL.createObjectURL(source)');
24 }
25
26 function sourceOpen()
27 {
28 run('sourceBuffer = source.addSourceBuffer("video/mock; codecs=mock")');
29 waitForEventOn(sourceBuffer, 'updateend', loadOrderedSamples, false, true);
30 initSegment = makeAInit(8, [makeATrack(1, 'mock', TRACK_KIND.VIDEO)]);
31 run('sourceBuffer.appendBuffer(initSegment)');
32 }
33
34 function loadOrderedSamples()
35 {
36 samples = concatenateSamples([
aboya@igalia.comace40032018-10-31 21:04:07 +000037 makeASample(0, 0, 1, 1, 1, SAMPLE_FLAG.SYNC, 0),
38 makeASample(1, 1, 1, 1, 1, SAMPLE_FLAG.NONE, 0),
39 makeASample(2, 2, 1, 1, 1, SAMPLE_FLAG.NONE, 0),
40 makeASample(3, 3, 1, 1, 1, SAMPLE_FLAG.SYNC, 0),
41 makeASample(4, 4, 1, 1, 1, SAMPLE_FLAG.NONE, 0),
42 makeASample(5, 5, 1, 1, 1, SAMPLE_FLAG.NONE, 0),
jer.noble@apple.com8186af52014-07-21 20:47:03 +000043 ]);
44 waitForEventOn(sourceBuffer, 'updateend', loadMoreOrderedSamples, false, true);
45 run('sourceBuffer.appendBuffer(samples)');
46 }
47
48 function loadMoreOrderedSamples()
49 {
50 samples = concatenateSamples([
aboya@igalia.comace40032018-10-31 21:04:07 +000051 makeASample(4, 3, 1, 1, 1, SAMPLE_FLAG.SYNC, 1),
52 makeASample(5, 4, 1, 1, 1, SAMPLE_FLAG.NONE, 1),
53 makeASample(6, 5, 1, 1, 1, SAMPLE_FLAG.NONE, 1),
jer.noble@apple.com8186af52014-07-21 20:47:03 +000054 ]);
55 waitForEventOn(sourceBuffer, 'updateend', samplesAdded, false, true);
56 run('sourceBuffer.appendBuffer(samples)');
57 }
58
peng.liu6@apple.com9369f112020-12-17 02:19:07 +000059 async function samplesAdded()
jer.noble@apple.com8186af52014-07-21 20:47:03 +000060 {
peng.liu6@apple.com9369f112020-12-17 02:19:07 +000061 bufferedSamples = await internals.bufferedSamplesForTrackId(sourceBuffer, 1);
jer.noble@apple.com8186af52014-07-21 20:47:03 +000062 testExpected("bufferedSamples.length", 7);
63 bufferedSamples.forEach(consoleWrite);
64
65 endTest();
66 }
67 </script>
68</head>
69<body onload="runTest()">
70 <video></video>
71</body>