mirror of
https://github.com/arcodange-org/mediabunny.git
synced 2026-10-10 01:03:45 +02:00
A BUNCH of HLS (and related) progress
- Add support for fMP4 segments - Add initInput (supported by ISOBMFF and MPEG-TS) - Input.isSupported() - Refactored file size retrieval logic, the file size can now be retrieved alongside the first read. - Add support for unsized UrlSources - Add support for multiple trun boxes in a row for the same track (as the spec literally says lol) - Add support for more M3U8 features - Fix faulty line reader - MPEG-TS improvements: support video parameters not in first packet, support better key frame detection, support extension PES packets without PTS - Fix reorder buffer being 1 element too small
This commit is contained in:
+19
-2
@@ -132,7 +132,7 @@ export class EncodedPacketSink {
|
||||
|
||||
/**
|
||||
* Retrieves the track's first packet (in decode order), or null if it has no packets. The first packet is very
|
||||
* likely to be a key packet.
|
||||
* likely to be a key packet, but it doesn't have to be.
|
||||
*/
|
||||
getFirstPacket(options: PacketRetrievalOptions = {}) {
|
||||
validatePacketRetrievalOptions(options);
|
||||
@@ -144,6 +144,23 @@ export class EncodedPacketSink {
|
||||
return maybeFixPacketType(this._track, this._track._backing.getFirstPacket(options), options);
|
||||
}
|
||||
|
||||
/** Retrieves the track's first key packet (in decode order), or null if it has no key packets. */
|
||||
async getFirstKeyPacket(options: PacketRetrievalOptions = {}) {
|
||||
validatePacketRetrievalOptions(options);
|
||||
|
||||
const firstPacket = await this.getFirstPacket(options);
|
||||
if (!firstPacket) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (firstPacket.type === 'key') {
|
||||
// Great
|
||||
return firstPacket;
|
||||
}
|
||||
|
||||
return this.getNextKeyPacket(firstPacket, options);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the packet corresponding to the given timestamp, in seconds. More specifically, returns the last packet
|
||||
* (in presentation order) with a start timestamp less than or equal to the given timestamp. This method can be
|
||||
@@ -476,7 +493,7 @@ export abstract class BaseMediaSampleSink<
|
||||
|
||||
const packetSink = this._createPacketSink();
|
||||
const keyPacket = await packetSink.getKeyPacket(startTimestamp, { verifyKeyPackets: true })
|
||||
?? await packetSink.getFirstPacket();
|
||||
?? await packetSink.getFirstKeyPacket();
|
||||
|
||||
let currentPacket: EncodedPacket | null = keyPacket;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user