jer.noble@apple.com | 8186af5 | 2014-07-21 20:47:03 +0000 | [diff] [blame] | 1 | <!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.com | ace4003 | 2018-10-31 21:04:07 +0000 | [diff] [blame] | 37 | 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.com | 8186af5 | 2014-07-21 20:47:03 +0000 | [diff] [blame] | 43 | ]); |
| 44 | waitForEventOn(sourceBuffer, 'updateend', loadMoreOrderedSamples, false, true); |
| 45 | run('sourceBuffer.appendBuffer(samples)'); |
| 46 | } |
| 47 | |
| 48 | function loadMoreOrderedSamples() |
| 49 | { |
| 50 | samples = concatenateSamples([ |
aboya@igalia.com | ace4003 | 2018-10-31 21:04:07 +0000 | [diff] [blame] | 51 | 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.com | 8186af5 | 2014-07-21 20:47:03 +0000 | [diff] [blame] | 54 | ]); |
| 55 | waitForEventOn(sourceBuffer, 'updateend', samplesAdded, false, true); |
| 56 | run('sourceBuffer.appendBuffer(samples)'); |
| 57 | } |
| 58 | |
peng.liu6@apple.com | 9369f11 | 2020-12-17 02:19:07 +0000 | [diff] [blame] | 59 | async function samplesAdded() |
jer.noble@apple.com | 8186af5 | 2014-07-21 20:47:03 +0000 | [diff] [blame] | 60 | { |
peng.liu6@apple.com | 9369f11 | 2020-12-17 02:19:07 +0000 | [diff] [blame] | 61 | bufferedSamples = await internals.bufferedSamplesForTrackId(sourceBuffer, 1); |
jer.noble@apple.com | 8186af5 | 2014-07-21 20:47:03 +0000 | [diff] [blame] | 62 | 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> |