mirror of
https://github.com/arcodange-org/mediabunny.git
synced 2026-09-29 11:53:52 +02:00
SampleCursor code cleanup & couple of more fixes
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { expect, test } from 'vitest';
|
||||
import { Input } from '../../src/input.js';
|
||||
import { Input, InputDisposedError } from '../../src/input.js';
|
||||
import { BufferSource, FilePathSource } from '../../src/source.js';
|
||||
import path from 'node:path';
|
||||
import fs from 'node:fs';
|
||||
@@ -37,6 +37,26 @@ test('Packet reader', async () => {
|
||||
expect(packet6.timestamp).toBeLessThanOrEqual(2.4);
|
||||
});
|
||||
|
||||
test('Packet reading throwing after Input disposal', async () => {
|
||||
const input = new Input({
|
||||
source: new BufferSource(fs.readFileSync(path.join(__dirname, '../public/trim-buck-bunny.mov'))),
|
||||
formats: ALL_FORMATS,
|
||||
});
|
||||
|
||||
const videoTrack = (await input.getPrimaryVideoTrack())!;
|
||||
const reader = new PacketReader(videoTrack);
|
||||
|
||||
const first = await reader.readFirst();
|
||||
|
||||
input.dispose();
|
||||
|
||||
expect(() => reader.readFirst()).toThrow(InputDisposedError);
|
||||
expect(() => reader.readAt(0)).toThrow(InputDisposedError);
|
||||
expect(() => reader.readKeyAt(0)).toThrow(InputDisposedError);
|
||||
expect(() => reader.readNext(first!)).toThrow(InputDisposedError);
|
||||
expect(() => reader.readNextKey(first!)).toThrow(InputDisposedError);
|
||||
});
|
||||
|
||||
test('Packet cursor seeking', async () => {
|
||||
using input = new Input({
|
||||
source: new FilePathSource(path.join(__dirname, '../public/trim-buck-bunny.mov')),
|
||||
|
||||
Reference in New Issue
Block a user