Implement ReadOrchestrator class, add highly optimized UrlSource

This commit is contained in:
Vanilagy
2025-08-29 19:39:50 +02:00
parent 641cdd02e3
commit c93755def1
15 changed files with 704 additions and 824 deletions
+1 -6
View File
@@ -44,7 +44,6 @@ export class AdtsDemuxer extends Demuxer {
readingMutex = new AsyncMutex();
lastSampleLoaded = false;
lastLoadedPos = 0;
fileSize = 0;
nextTimestampInSamples = 0;
constructor(input: Input) {
@@ -55,10 +54,6 @@ export class AdtsDemuxer extends Demuxer {
async readMetadata() {
return this.metadataPromise ??= (async () => {
let fileSize = this.reader.requestSize();
if (fileSize instanceof Promise) fileSize = await fileSize;
this.fileSize = fileSize;
// Keep loading until we find the first frame header
while (!this.firstFrameHeader && !this.lastSampleLoaded) {
await this.advanceReader();
@@ -86,7 +81,7 @@ export class AdtsDemuxer extends Demuxer {
return;
}
if (header.startPos + header.frameLength > this.fileSize) {
if (header.startPos + header.frameLength > this.reader.fileSize) {
// Frame doesn't fit in the rest of the file
this.lastSampleLoaded = true;
return;