Slightly adjust validated key packet retrieval logic

This commit is contained in:
Vanilagy
2025-12-05 23:00:40 +01:00
parent d6c223b0f6
commit 11970675c6
+5 -6
View File
@@ -201,9 +201,10 @@ export class EncodedPacketSink {
}
const packet = await this._track._backing.getKeyPacket(timestamp, options);
if (!packet || packet.type === 'delta') {
if (!packet) {
return packet;
}
assert(packet.type === 'key');
const determinedType = await this._track.determinePacketType(packet);
if (determinedType === 'delta') {
@@ -235,9 +236,10 @@ export class EncodedPacketSink {
}
const nextPacket = await this._track._backing.getNextKeyPacket(packet, options);
if (!nextPacket || nextPacket.type === 'delta') {
if (!nextPacket) {
return nextPacket;
}
assert(nextPacket.type === 'key');
const determinedType = await this._track.determinePacketType(nextPacket);
if (determinedType === 'delta') {
@@ -474,9 +476,6 @@ export abstract class BaseMediaSampleSink<
const packetSink = this._createPacketSink();
const keyPacket = await packetSink.getKeyPacket(startTimestamp, { verifyKeyPackets: true })
?? await packetSink.getFirstPacket();
if (!keyPacket) {
return;
}
let currentPacket: EncodedPacket | null = keyPacket;
@@ -498,7 +497,7 @@ export abstract class BaseMediaSampleSink<
}
}
const packets = packetSink.packets(keyPacket, endPacket);
const packets = packetSink.packets(keyPacket ?? undefined, endPacket);
await packets.next(); // Skip the start packet as we already have it
while (currentPacket && !ended && !this._track.input._disposed) {