mirror of
https://github.com/arcodange-org/mediabunny.git
synced 2026-09-27 19:03:46 +02:00
Move PacketReader elsewhere
This commit is contained in:
@@ -3,7 +3,6 @@ import { Input } from '../../src/input.js';
|
||||
import { BufferSource, UrlSource } from '../../src/source.js';
|
||||
import { ALL_FORMATS } from '../../src/input-format.js';
|
||||
import {
|
||||
audioBufferTransformer,
|
||||
AudioSampleCursor,
|
||||
canvasTransformer,
|
||||
VideoSampleCursor,
|
||||
@@ -1115,33 +1114,6 @@ test('Canvas transformer', async () => {
|
||||
await cursor2.close();
|
||||
});
|
||||
|
||||
test('AudioBuffer transformer', async () => {
|
||||
using input = new Input({
|
||||
source: new UrlSource('/trim-buck-bunny.mov'),
|
||||
formats: ALL_FORMATS,
|
||||
});
|
||||
|
||||
const audioTrack = (await input.getPrimaryAudioTrack())!;
|
||||
|
||||
const cursor = new AudioSampleCursor(audioTrack, {
|
||||
transform: audioBufferTransformer(),
|
||||
});
|
||||
|
||||
const firstSample = (await cursor.seekToFirst())!;
|
||||
expect(firstSample.buffer).toBeInstanceOf(AudioBuffer);
|
||||
expect(firstSample.timestamp).toBe(0);
|
||||
expect(firstSample.duration).toBeGreaterThan(0);
|
||||
expect(firstSample.buffer.duration).toBe(firstSample.duration);
|
||||
|
||||
const nextSample = (await cursor.next())!;
|
||||
expect(nextSample.buffer).toBeInstanceOf(AudioBuffer);
|
||||
expect(nextSample.timestamp).toBeGreaterThan(firstSample.timestamp);
|
||||
expect(nextSample.buffer).not.toBe(firstSample.buffer);
|
||||
expect(nextSample.buffer.duration).toBe(nextSample.duration);
|
||||
|
||||
await cursor.close();
|
||||
});
|
||||
|
||||
test('Unthrottled decoder', async () => {
|
||||
// While the decoder is throttled in practice, these tests simulate what happens when the decoder naturally reaches
|
||||
// the end of the encodable packets without having been stopped; in this case, we still expect the cursor to keep
|
||||
|
||||
Reference in New Issue
Block a user