| <!DOCTYPE html> |
| <html> |
| <head> |
| <title>media-source-samples-out-of-order</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(); |
| |
| window.addEventListener('load', async event => { |
| findMediaElement(); |
| |
| source = new MediaSource(); |
| run('video.src = URL.createObjectURL(source)'); |
| await waitFor(source, 'sourceopen'); |
| |
| run('sourceBuffer = source.addSourceBuffer("video/mock; codecs=mock")'); |
| consoleWrite('First segment has normal, monotonically increasing samples.') |
| mediaSegment = concatenateSamples([ |
| makeAInit(2, [makeATrack(1, 'mock', TRACK_KIND.AUDIO)]), |
| makeASample(1, 1, 1, 1, 1, SAMPLE_FLAG.SYNC, 0), |
| makeASample(2, 2, 1, 1, 1, SAMPLE_FLAG.NONE, 0), |
| makeASample(3, 3, 1, 1, 1, SAMPLE_FLAG.NONE, 0), |
| ]); |
| run('sourceBuffer.appendBuffer(mediaSegment)'); |
| await waitFor(sourceBuffer, 'updateend'); |
| |
| bufferedSamples = await internals.bufferedSamplesForTrackId(sourceBuffer, 1); |
| testExpected("bufferedSamples.length", 3); |
| bufferedSamples.forEach(consoleWrite); |
| |
| consoleWrite('Second, overlapping segment has out-of-display-order samples. This append should replace the last sample from the previous append.') |
| mediaSegment = concatenateSamples([ |
| makeAInit(2, [makeATrack(1, 'mock', TRACK_KIND.AUDIO)]), |
| makeASample(4, 2, 1, 1, 1, SAMPLE_FLAG.SYNC, 1), |
| ]); |
| run('sourceBuffer.appendBuffer(mediaSegment)'); |
| await waitFor(sourceBuffer, 'updateend'); |
| |
| bufferedSamples = await internals.bufferedSamplesForTrackId(sourceBuffer, 1); |
| testExpected("bufferedSamples.length", 3); |
| bufferedSamples.forEach(consoleWrite); |
| |
| endTest(); |
| }); |
| </script> |
| </head> |
| <body> |
| <video></video> |
| </body> |
| </html> |