mirror of
https://github.com/arcodange-org/mediabunny.git
synced 2026-10-09 08:43:49 +02:00
Fix HLS demuxer parsing bug, extract HLS mime type out, add TargetRequest.mimeType
This commit is contained in:
+12
-4
@@ -20,7 +20,7 @@ import { TrackType } from '../output';
|
||||
import { assert, joinPaths, MaybePromise, Rotation, UNDETERMINED_LANGUAGE } from '../misc';
|
||||
import { EncodedPacket } from '../packet';
|
||||
import { readAllLines } from '../reader';
|
||||
import { AttributeList, canIgnoreLine } from './hls-misc';
|
||||
import { AttributeList, canIgnoreLine, HLS_MIME_TYPE } from './hls-misc';
|
||||
import { HlsSegmentedInput } from './hls-segmented-input';
|
||||
import { PathedSource } from '../source';
|
||||
import { SegmentedInputTrackDeclaration } from '../segmented-input';
|
||||
@@ -105,7 +105,7 @@ export class HlsDemuxer extends Demuxer {
|
||||
if (bandwidth === null) {
|
||||
throw new Error(
|
||||
'Invalid M3U8 file; #EXT-X-STREAM-INF tag requires a BANDWIDTH attribute with a valid'
|
||||
+ ' number value.',
|
||||
+ ' numerical value.',
|
||||
);
|
||||
}
|
||||
|
||||
@@ -116,7 +116,7 @@ export class HlsDemuxer extends Demuxer {
|
||||
hasOnlyKeyPackets: false,
|
||||
});
|
||||
} else if (line.startsWith('#EXT-X-I-FRAME-STREAM-INF:')) {
|
||||
const attributes = new AttributeList(line.slice(18));
|
||||
const attributes = new AttributeList(line.slice(26));
|
||||
const playlistPath = attributes.get('uri');
|
||||
|
||||
if (playlistPath === null) {
|
||||
@@ -125,6 +125,14 @@ export class HlsDemuxer extends Demuxer {
|
||||
);
|
||||
}
|
||||
|
||||
const bandwidth = attributes.getAsNumber('bandwidth');
|
||||
if (bandwidth === null) {
|
||||
throw new Error(
|
||||
'Invalid M3U8 file; #EXT-X-I-FRAME-STREAM-INF tag requires a BANDWIDTH attribute with a'
|
||||
+ ' valid numerical value.',
|
||||
);
|
||||
}
|
||||
|
||||
const fullPath = joinPaths(source.rootPath, playlistPath);
|
||||
|
||||
variantStreams.push({
|
||||
@@ -610,7 +618,7 @@ export class HlsDemuxer extends Demuxer {
|
||||
}
|
||||
|
||||
async getMimeType(): Promise<string> {
|
||||
return 'application/vnd.apple.mpegurl';
|
||||
return HLS_MIME_TYPE;
|
||||
}
|
||||
|
||||
override dispose(): void {
|
||||
|
||||
Reference in New Issue
Block a user