dasha 4.4.5 → 4.4.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +8 -2
- package/dist/index.mjs +13 -13
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AudioCodec as AudioCodec$1, DurationMetadataRequestOptions, EncodedPacket, FilePathSource, HLS, HLS_FORMATS, Input as Input$1, InputAudioTrack as InputAudioTrack$1, InputFormat, InputOptions, InputTrack as InputTrack$2, InputTrackQuery, InputTrackQuery as InputTrackQuery$1, InputVideoTrack as InputVideoTrack$1, MP3, MP4, MaybePromise, MediaCodec as MediaCodec$1, MetadataTags, PacketRetrievalOptions, PathedSource, Source, SourceRef, SubtitleCodec as SubtitleCodec$1, TrackDisposition, UrlSource, VideoCodec as VideoCodec$1, asc, desc, prefer } from "mediabunny";
|
|
1
|
+
import { AudioCodec as AudioCodec$1, DurationMetadataRequestOptions, EncodedPacket, FilePathSource, HLS, HLS_FORMATS, Input as Input$1, InputAudioTrack as InputAudioTrack$1, InputFormat, InputOptions, InputTrack as InputTrack$2, InputTrackQuery, InputTrackQuery as InputTrackQuery$1, InputVideoTrack as InputVideoTrack$1, MP3, MP4, MaybePromise, MaybePromise as MaybePromise$1, MediaCodec as MediaCodec$1, MetadataTags, PacketRetrievalOptions, PathedSource, Source, SourceRef, SubtitleCodec as SubtitleCodec$1, TrackDisposition, UrlSource, VideoCodec as VideoCodec$1, asc, desc, prefer } from "mediabunny";
|
|
2
2
|
|
|
3
3
|
//#region src/mediabunny.d.ts
|
|
4
4
|
type Segment$1 = {
|
|
@@ -439,12 +439,18 @@ declare const DASH: DashInputFormat;
|
|
|
439
439
|
declare const DASH_FORMATS: InputFormat[];
|
|
440
440
|
//#endregion
|
|
441
441
|
//#region src/hls/hls-subtitles.d.ts
|
|
442
|
-
type
|
|
442
|
+
type ReadResult = {
|
|
443
|
+
bytes: Uint8Array;
|
|
444
|
+
view: DataView; /** The offset of the bytes in the file. */
|
|
445
|
+
offset: number;
|
|
446
|
+
};
|
|
447
|
+
type SourceWithRootPath = Source & {
|
|
443
448
|
rootPath: string;
|
|
444
449
|
_options?: {
|
|
445
450
|
requestInit?: RequestInit;
|
|
446
451
|
};
|
|
447
452
|
_url?: string | URL | Request;
|
|
453
|
+
_read(start: number, end: number, minReadPosition: number, maxReadPosition: number): MaybePromise$1<ReadResult | null>;
|
|
448
454
|
};
|
|
449
455
|
type HlsSubtitleMediaTag = {
|
|
450
456
|
autoselect: boolean;
|
package/dist/index.mjs
CHANGED
|
@@ -662,6 +662,17 @@ const loadPlaylistText = async (source, path) => {
|
|
|
662
662
|
path,
|
|
663
663
|
text: await readFile(new URL(path), "utf8")
|
|
664
664
|
};
|
|
665
|
+
if (path === source.rootPath && typeof source.getSize === "function" && typeof source._read === "function") {
|
|
666
|
+
const size = await source.getSize();
|
|
667
|
+
const result = await source._read(0, size, 0, Infinity);
|
|
668
|
+
if (result) {
|
|
669
|
+
const data = result.bytes.subarray(result.offset, result.offset + size);
|
|
670
|
+
return {
|
|
671
|
+
path,
|
|
672
|
+
text: new TextDecoder().decode(data)
|
|
673
|
+
};
|
|
674
|
+
}
|
|
675
|
+
}
|
|
665
676
|
return {
|
|
666
677
|
path,
|
|
667
678
|
text: await readFile(path, "utf8")
|
|
@@ -2326,6 +2337,7 @@ const getRoleType = (roleValue) => {
|
|
|
2326
2337
|
const capitalize = (word) => word.charAt(0).toUpperCase() + word.slice(1);
|
|
2327
2338
|
return ROLE_TYPE[roleValue.split("-").map(capitalize).join("")];
|
|
2328
2339
|
};
|
|
2340
|
+
const getDashTrackName = (representation, adaptationSet) => representation.getAttribute("label") || representation.getAttribute("bitmovin:label") || adaptationSet.getAttribute("label") || adaptationSet.getAttribute("bitmovin:label");
|
|
2329
2341
|
const createDashTrack = (params) => {
|
|
2330
2342
|
const { adaptationSet, contentType, frameRate, isLive, mimeType, period, representation, timeShiftBufferDepth } = params;
|
|
2331
2343
|
const bitrate = params.bitrate;
|
|
@@ -2340,7 +2352,7 @@ const createDashTrack = (params) => {
|
|
|
2340
2352
|
codecString: descriptor.codecString,
|
|
2341
2353
|
peakBitrate: bitrate,
|
|
2342
2354
|
averageBitrate: bitrate,
|
|
2343
|
-
name:
|
|
2355
|
+
name: getDashTrackName(representation, adaptationSet),
|
|
2344
2356
|
default: false,
|
|
2345
2357
|
groupId: representation.getAttribute("id"),
|
|
2346
2358
|
periodId: period.getAttribute("id"),
|
|
@@ -2626,17 +2638,6 @@ const mergeDashPeriodTrack = (tracks, track, isLive) => {
|
|
|
2626
2638
|
}
|
|
2627
2639
|
lastSegment.duration += incomingSegments.reduce((sum, segment) => sum + segment.duration, 0);
|
|
2628
2640
|
};
|
|
2629
|
-
const linkDefaultDashGroups = (tracks) => {
|
|
2630
|
-
const audioList = tracks.filter((track) => track.type === "audio");
|
|
2631
|
-
const subtitleList = tracks.filter((track) => track.type === "subtitle");
|
|
2632
|
-
const videoList = tracks.filter((track) => track.type === "video");
|
|
2633
|
-
for (const video of videoList) {
|
|
2634
|
-
const audioGroupId = audioList.toSorted((a, b) => (b.peakBitrate || 0) - (a.peakBitrate || 0)).at(0)?.groupId;
|
|
2635
|
-
const subtitleGroupId = subtitleList.toSorted((a, b) => (b.peakBitrate || 0) - (a.peakBitrate || 0)).at(0)?.groupId;
|
|
2636
|
-
if (audioGroupId) video.audioGroupId = audioGroupId;
|
|
2637
|
-
if (subtitleGroupId) video.subtitleGroupId = subtitleGroupId;
|
|
2638
|
-
}
|
|
2639
|
-
};
|
|
2640
2641
|
var DashDemuxer = class {
|
|
2641
2642
|
input;
|
|
2642
2643
|
metadataPromise = null;
|
|
@@ -2696,7 +2697,6 @@ var DashDemuxer = class {
|
|
|
2696
2697
|
const manifest = this.parseManifest(rawText);
|
|
2697
2698
|
const tracks = [];
|
|
2698
2699
|
for (const period of getDirectDashChildren(manifest.mpdElement, "Period")) this.appendPeriodTracks(tracks, manifest, period);
|
|
2699
|
-
linkDefaultDashGroups(tracks);
|
|
2700
2700
|
return tracks;
|
|
2701
2701
|
}
|
|
2702
2702
|
parseManifest(rawText) {
|