dasha 3.1.2 → 3.1.3
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/dasha.js +45 -3
- package/dist/dasha.mjs +45 -3
- package/package.json +8 -8
package/dist/dasha.js
CHANGED
|
@@ -467,6 +467,13 @@ var require_video = __commonJS({
|
|
|
467
467
|
`No MIME types matched any supported Video Codecs in ${codecs}`
|
|
468
468
|
);
|
|
469
469
|
};
|
|
470
|
+
var tryParseVideoCodec = (codecs) => {
|
|
471
|
+
try {
|
|
472
|
+
return parseVideoCodec(codecs);
|
|
473
|
+
} catch (e) {
|
|
474
|
+
return null;
|
|
475
|
+
}
|
|
476
|
+
};
|
|
470
477
|
var parseDynamicRange = (codecs, supplementalProps = [], essentialProps = []) => {
|
|
471
478
|
const dv = ["dva1", "dvav", "dvhe", "dvh1"];
|
|
472
479
|
if (dv.some((value) => codecs.startsWith(value))) return DYNAMIC_RANGE.dv;
|
|
@@ -491,6 +498,7 @@ var require_video = __commonJS({
|
|
|
491
498
|
};
|
|
492
499
|
module2.exports = {
|
|
493
500
|
parseVideoCodec,
|
|
501
|
+
tryParseVideoCodec,
|
|
494
502
|
parseDynamicRange,
|
|
495
503
|
createVideoTrack,
|
|
496
504
|
VIDEO_CODECS
|
|
@@ -660,6 +668,13 @@ var require_audio = __commonJS({
|
|
|
660
668
|
`No MIME types matched any supported Audio Codecs in ${codecs}`
|
|
661
669
|
);
|
|
662
670
|
};
|
|
671
|
+
var tryParseAudioCodec = (codecs) => {
|
|
672
|
+
try {
|
|
673
|
+
return parseAudioCodec(codecs);
|
|
674
|
+
} catch (e) {
|
|
675
|
+
return null;
|
|
676
|
+
}
|
|
677
|
+
};
|
|
663
678
|
var getDolbyDigitalPlusComplexityIndex = (supplementalProps = []) => {
|
|
664
679
|
const targetScheme = "tag:dolby.com,2018:dash:EC3_ExtensionComplexityIndex:2018";
|
|
665
680
|
for (const prop of supplementalProps)
|
|
@@ -693,6 +708,7 @@ var require_audio = __commonJS({
|
|
|
693
708
|
type,
|
|
694
709
|
codec,
|
|
695
710
|
channels,
|
|
711
|
+
contentProtection,
|
|
696
712
|
bitrate,
|
|
697
713
|
duration,
|
|
698
714
|
jointObjectCoding = 0,
|
|
@@ -710,6 +726,7 @@ var require_audio = __commonJS({
|
|
|
710
726
|
codec,
|
|
711
727
|
bitrate: parsedBitrate,
|
|
712
728
|
size,
|
|
729
|
+
protection: contentProtection,
|
|
713
730
|
language,
|
|
714
731
|
segments,
|
|
715
732
|
channels: parsedChannels,
|
|
@@ -729,6 +746,7 @@ var require_audio = __commonJS({
|
|
|
729
746
|
module2.exports = {
|
|
730
747
|
AUDIO_CODECS,
|
|
731
748
|
parseAudioCodec,
|
|
749
|
+
tryParseAudioCodec,
|
|
732
750
|
createAudioTrack,
|
|
733
751
|
getDolbyDigitalPlusComplexityIndex,
|
|
734
752
|
checkIsDescriptive
|
|
@@ -794,6 +812,13 @@ var require_subtitle = __commonJS({
|
|
|
794
812
|
`No MIME types matched any supported Subtitle Codecs in ${codecs}`
|
|
795
813
|
);
|
|
796
814
|
};
|
|
815
|
+
var tryParseSubtitleCodec = (codecs) => {
|
|
816
|
+
try {
|
|
817
|
+
return parseSubtitleCodec(codecs);
|
|
818
|
+
} catch (e) {
|
|
819
|
+
return null;
|
|
820
|
+
}
|
|
821
|
+
};
|
|
797
822
|
var checkIsClosedCaption = (roles = []) => {
|
|
798
823
|
for (const role of roles) {
|
|
799
824
|
const isClosedCaption = role.attributes.schemeIdUri === "urn:mpeg:dash:role:2011" && role.attributes.value === "caption";
|
|
@@ -850,6 +875,7 @@ var require_subtitle = __commonJS({
|
|
|
850
875
|
};
|
|
851
876
|
module2.exports = {
|
|
852
877
|
parseSubtitleCodec,
|
|
878
|
+
tryParseSubtitleCodec,
|
|
853
879
|
checkIsClosedCaption,
|
|
854
880
|
checkIsSdh,
|
|
855
881
|
checkIsForced,
|
|
@@ -866,17 +892,20 @@ var require_dash = __commonJS({
|
|
|
866
892
|
var { parseDuration, isLanguageTagValid } = require_util();
|
|
867
893
|
var {
|
|
868
894
|
parseVideoCodec,
|
|
895
|
+
tryParseVideoCodec,
|
|
869
896
|
parseDynamicRange,
|
|
870
897
|
createVideoTrack
|
|
871
898
|
} = require_video();
|
|
872
899
|
var {
|
|
873
900
|
parseAudioCodec,
|
|
901
|
+
tryParseAudioCodec,
|
|
874
902
|
createAudioTrack,
|
|
875
903
|
getDolbyDigitalPlusComplexityIndex,
|
|
876
904
|
checkIsDescriptive
|
|
877
905
|
} = require_audio();
|
|
878
906
|
var {
|
|
879
907
|
parseSubtitleCodec,
|
|
908
|
+
tryParseSubtitleCodec,
|
|
880
909
|
checkIsClosedCaption,
|
|
881
910
|
checkIsSdh,
|
|
882
911
|
checkIsForced,
|
|
@@ -930,14 +959,22 @@ var require_dash = __commonJS({
|
|
|
930
959
|
const baseUrl = new URL(representation.getBaseUrl() || "", base).toString();
|
|
931
960
|
return baseUrl;
|
|
932
961
|
};
|
|
962
|
+
var getTrackTypeByCodecs = (codecs) => {
|
|
963
|
+
if (tryParseVideoCodec(codecs)) return "video";
|
|
964
|
+
else if (tryParseAudioCodec(codecs)) return "audio";
|
|
965
|
+
else if (tryParseSubtitleCodec(codecs)) return "text";
|
|
966
|
+
return null;
|
|
967
|
+
};
|
|
933
968
|
var parseContentTypes = (representation) => {
|
|
969
|
+
const codecs = representation.get("codecs");
|
|
934
970
|
const mimeType = representation.get("mimeType");
|
|
971
|
+
const contentTypeByCodecs = getTrackTypeByCodecs(codecs);
|
|
935
972
|
const contentType = representation.get("contentType") || mimeType?.split("/")[0];
|
|
936
973
|
if (!contentType && !mimeType)
|
|
937
974
|
throw new Error(
|
|
938
975
|
"Unable to determine the format of a Representation, cannot continue..."
|
|
939
976
|
);
|
|
940
|
-
return { contentType, mimeType };
|
|
977
|
+
return { contentType: contentTypeByCodecs || contentType, mimeType };
|
|
941
978
|
};
|
|
942
979
|
var parseCodecs = (representation, contentType, mimeType) => {
|
|
943
980
|
const shouldUseCodecsFromMime = contentType === "text" && !mimeType.includes("mp4");
|
|
@@ -1030,6 +1067,7 @@ var require_dash = __commonJS({
|
|
|
1030
1067
|
const segmentsCount = duration ? Math.ceil(duration / (segmentDuration / segmentTimescale)) : DEFAULT_SEGMENTS_COUNT;
|
|
1031
1068
|
const bandwidth = representation.get("bandwidth");
|
|
1032
1069
|
const id = representation.get("id");
|
|
1070
|
+
const sanitizeTemplate = (template) => template?.replace(/\$.*?(RepresentationID|Number|Time).*?\$/g, "$$$1$$");
|
|
1033
1071
|
const segments = [];
|
|
1034
1072
|
if (segmentTimeline) {
|
|
1035
1073
|
segments.push(
|
|
@@ -1041,8 +1079,9 @@ var require_dash = __commonJS({
|
|
|
1041
1079
|
)
|
|
1042
1080
|
);
|
|
1043
1081
|
} else {
|
|
1082
|
+
const template = sanitizeTemplate(segmentTemplate.get("media"));
|
|
1044
1083
|
for (let i = startNumber; i < startNumber + segmentsCount; i++) {
|
|
1045
|
-
const url = buildSegmentUrl(
|
|
1084
|
+
const url = buildSegmentUrl(template, {
|
|
1046
1085
|
Bandwidth: bandwidth,
|
|
1047
1086
|
RepresentationID: id,
|
|
1048
1087
|
Number: i,
|
|
@@ -1051,7 +1090,9 @@ var require_dash = __commonJS({
|
|
|
1051
1090
|
segments.push({ url });
|
|
1052
1091
|
}
|
|
1053
1092
|
}
|
|
1054
|
-
const initialization =
|
|
1093
|
+
const initialization = sanitizeTemplate(
|
|
1094
|
+
segmentTemplate.get("initialization")
|
|
1095
|
+
);
|
|
1055
1096
|
if (initialization) {
|
|
1056
1097
|
const url = buildSegmentUrl(initialization, {
|
|
1057
1098
|
Bandwidth: bandwidth,
|
|
@@ -1216,6 +1257,7 @@ var require_dash = __commonJS({
|
|
|
1216
1257
|
channels: get("AudioChannelConfiguration")?.get("value"),
|
|
1217
1258
|
jointObjectCoding: getDolbyDigitalPlusComplexityIndex(supplementalProps),
|
|
1218
1259
|
isDescriptive: checkIsDescriptive(accessibilities),
|
|
1260
|
+
contentProtection: parseContentProtection(contentProtections),
|
|
1219
1261
|
bitrate,
|
|
1220
1262
|
duration,
|
|
1221
1263
|
language,
|
package/dist/dasha.mjs
CHANGED
|
@@ -472,6 +472,13 @@ var require_video = __commonJS({
|
|
|
472
472
|
`No MIME types matched any supported Video Codecs in ${codecs}`
|
|
473
473
|
);
|
|
474
474
|
};
|
|
475
|
+
var tryParseVideoCodec = (codecs) => {
|
|
476
|
+
try {
|
|
477
|
+
return parseVideoCodec(codecs);
|
|
478
|
+
} catch (e) {
|
|
479
|
+
return null;
|
|
480
|
+
}
|
|
481
|
+
};
|
|
475
482
|
var parseDynamicRange = (codecs, supplementalProps = [], essentialProps = []) => {
|
|
476
483
|
const dv = ["dva1", "dvav", "dvhe", "dvh1"];
|
|
477
484
|
if (dv.some((value) => codecs.startsWith(value))) return DYNAMIC_RANGE.dv;
|
|
@@ -496,6 +503,7 @@ var require_video = __commonJS({
|
|
|
496
503
|
};
|
|
497
504
|
module.exports = {
|
|
498
505
|
parseVideoCodec,
|
|
506
|
+
tryParseVideoCodec,
|
|
499
507
|
parseDynamicRange,
|
|
500
508
|
createVideoTrack,
|
|
501
509
|
VIDEO_CODECS
|
|
@@ -665,6 +673,13 @@ var require_audio = __commonJS({
|
|
|
665
673
|
`No MIME types matched any supported Audio Codecs in ${codecs}`
|
|
666
674
|
);
|
|
667
675
|
};
|
|
676
|
+
var tryParseAudioCodec = (codecs) => {
|
|
677
|
+
try {
|
|
678
|
+
return parseAudioCodec(codecs);
|
|
679
|
+
} catch (e) {
|
|
680
|
+
return null;
|
|
681
|
+
}
|
|
682
|
+
};
|
|
668
683
|
var getDolbyDigitalPlusComplexityIndex = (supplementalProps = []) => {
|
|
669
684
|
const targetScheme = "tag:dolby.com,2018:dash:EC3_ExtensionComplexityIndex:2018";
|
|
670
685
|
for (const prop of supplementalProps)
|
|
@@ -698,6 +713,7 @@ var require_audio = __commonJS({
|
|
|
698
713
|
type,
|
|
699
714
|
codec,
|
|
700
715
|
channels,
|
|
716
|
+
contentProtection,
|
|
701
717
|
bitrate,
|
|
702
718
|
duration,
|
|
703
719
|
jointObjectCoding = 0,
|
|
@@ -715,6 +731,7 @@ var require_audio = __commonJS({
|
|
|
715
731
|
codec,
|
|
716
732
|
bitrate: parsedBitrate,
|
|
717
733
|
size,
|
|
734
|
+
protection: contentProtection,
|
|
718
735
|
language,
|
|
719
736
|
segments,
|
|
720
737
|
channels: parsedChannels,
|
|
@@ -734,6 +751,7 @@ var require_audio = __commonJS({
|
|
|
734
751
|
module.exports = {
|
|
735
752
|
AUDIO_CODECS,
|
|
736
753
|
parseAudioCodec,
|
|
754
|
+
tryParseAudioCodec,
|
|
737
755
|
createAudioTrack,
|
|
738
756
|
getDolbyDigitalPlusComplexityIndex,
|
|
739
757
|
checkIsDescriptive
|
|
@@ -799,6 +817,13 @@ var require_subtitle = __commonJS({
|
|
|
799
817
|
`No MIME types matched any supported Subtitle Codecs in ${codecs}`
|
|
800
818
|
);
|
|
801
819
|
};
|
|
820
|
+
var tryParseSubtitleCodec = (codecs) => {
|
|
821
|
+
try {
|
|
822
|
+
return parseSubtitleCodec(codecs);
|
|
823
|
+
} catch (e) {
|
|
824
|
+
return null;
|
|
825
|
+
}
|
|
826
|
+
};
|
|
802
827
|
var checkIsClosedCaption = (roles = []) => {
|
|
803
828
|
for (const role of roles) {
|
|
804
829
|
const isClosedCaption = role.attributes.schemeIdUri === "urn:mpeg:dash:role:2011" && role.attributes.value === "caption";
|
|
@@ -855,6 +880,7 @@ var require_subtitle = __commonJS({
|
|
|
855
880
|
};
|
|
856
881
|
module.exports = {
|
|
857
882
|
parseSubtitleCodec,
|
|
883
|
+
tryParseSubtitleCodec,
|
|
858
884
|
checkIsClosedCaption,
|
|
859
885
|
checkIsSdh,
|
|
860
886
|
checkIsForced,
|
|
@@ -871,17 +897,20 @@ var require_dash = __commonJS({
|
|
|
871
897
|
var { parseDuration, isLanguageTagValid } = require_util();
|
|
872
898
|
var {
|
|
873
899
|
parseVideoCodec,
|
|
900
|
+
tryParseVideoCodec,
|
|
874
901
|
parseDynamicRange,
|
|
875
902
|
createVideoTrack
|
|
876
903
|
} = require_video();
|
|
877
904
|
var {
|
|
878
905
|
parseAudioCodec,
|
|
906
|
+
tryParseAudioCodec,
|
|
879
907
|
createAudioTrack,
|
|
880
908
|
getDolbyDigitalPlusComplexityIndex,
|
|
881
909
|
checkIsDescriptive
|
|
882
910
|
} = require_audio();
|
|
883
911
|
var {
|
|
884
912
|
parseSubtitleCodec,
|
|
913
|
+
tryParseSubtitleCodec,
|
|
885
914
|
checkIsClosedCaption,
|
|
886
915
|
checkIsSdh,
|
|
887
916
|
checkIsForced,
|
|
@@ -935,14 +964,22 @@ var require_dash = __commonJS({
|
|
|
935
964
|
const baseUrl = new URL(representation.getBaseUrl() || "", base).toString();
|
|
936
965
|
return baseUrl;
|
|
937
966
|
};
|
|
967
|
+
var getTrackTypeByCodecs = (codecs) => {
|
|
968
|
+
if (tryParseVideoCodec(codecs)) return "video";
|
|
969
|
+
else if (tryParseAudioCodec(codecs)) return "audio";
|
|
970
|
+
else if (tryParseSubtitleCodec(codecs)) return "text";
|
|
971
|
+
return null;
|
|
972
|
+
};
|
|
938
973
|
var parseContentTypes = (representation) => {
|
|
974
|
+
const codecs = representation.get("codecs");
|
|
939
975
|
const mimeType = representation.get("mimeType");
|
|
976
|
+
const contentTypeByCodecs = getTrackTypeByCodecs(codecs);
|
|
940
977
|
const contentType = representation.get("contentType") || mimeType?.split("/")[0];
|
|
941
978
|
if (!contentType && !mimeType)
|
|
942
979
|
throw new Error(
|
|
943
980
|
"Unable to determine the format of a Representation, cannot continue..."
|
|
944
981
|
);
|
|
945
|
-
return { contentType, mimeType };
|
|
982
|
+
return { contentType: contentTypeByCodecs || contentType, mimeType };
|
|
946
983
|
};
|
|
947
984
|
var parseCodecs = (representation, contentType, mimeType) => {
|
|
948
985
|
const shouldUseCodecsFromMime = contentType === "text" && !mimeType.includes("mp4");
|
|
@@ -1035,6 +1072,7 @@ var require_dash = __commonJS({
|
|
|
1035
1072
|
const segmentsCount = duration ? Math.ceil(duration / (segmentDuration / segmentTimescale)) : DEFAULT_SEGMENTS_COUNT;
|
|
1036
1073
|
const bandwidth = representation.get("bandwidth");
|
|
1037
1074
|
const id = representation.get("id");
|
|
1075
|
+
const sanitizeTemplate = (template) => template?.replace(/\$.*?(RepresentationID|Number|Time).*?\$/g, "$$$1$$");
|
|
1038
1076
|
const segments = [];
|
|
1039
1077
|
if (segmentTimeline) {
|
|
1040
1078
|
segments.push(
|
|
@@ -1046,8 +1084,9 @@ var require_dash = __commonJS({
|
|
|
1046
1084
|
)
|
|
1047
1085
|
);
|
|
1048
1086
|
} else {
|
|
1087
|
+
const template = sanitizeTemplate(segmentTemplate.get("media"));
|
|
1049
1088
|
for (let i = startNumber; i < startNumber + segmentsCount; i++) {
|
|
1050
|
-
const url = buildSegmentUrl(
|
|
1089
|
+
const url = buildSegmentUrl(template, {
|
|
1051
1090
|
Bandwidth: bandwidth,
|
|
1052
1091
|
RepresentationID: id,
|
|
1053
1092
|
Number: i,
|
|
@@ -1056,7 +1095,9 @@ var require_dash = __commonJS({
|
|
|
1056
1095
|
segments.push({ url });
|
|
1057
1096
|
}
|
|
1058
1097
|
}
|
|
1059
|
-
const initialization =
|
|
1098
|
+
const initialization = sanitizeTemplate(
|
|
1099
|
+
segmentTemplate.get("initialization")
|
|
1100
|
+
);
|
|
1060
1101
|
if (initialization) {
|
|
1061
1102
|
const url = buildSegmentUrl(initialization, {
|
|
1062
1103
|
Bandwidth: bandwidth,
|
|
@@ -1221,6 +1262,7 @@ var require_dash = __commonJS({
|
|
|
1221
1262
|
channels: get("AudioChannelConfiguration")?.get("value"),
|
|
1222
1263
|
jointObjectCoding: getDolbyDigitalPlusComplexityIndex(supplementalProps),
|
|
1223
1264
|
isDescriptive: checkIsDescriptive(accessibilities),
|
|
1265
|
+
contentProtection: parseContentProtection(contentProtections),
|
|
1224
1266
|
bitrate,
|
|
1225
1267
|
duration,
|
|
1226
1268
|
language,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dasha",
|
|
3
|
-
"version": "3.1.
|
|
3
|
+
"version": "3.1.3",
|
|
4
4
|
"description": "Streaming manifest parser",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist",
|
|
@@ -55,14 +55,14 @@
|
|
|
55
55
|
"m3u8-parser": "^7.2.0"
|
|
56
56
|
},
|
|
57
57
|
"devDependencies": {
|
|
58
|
-
"@eslint/js": "^9.
|
|
59
|
-
"@types/node": "^22.
|
|
60
|
-
"eslint": "^9.
|
|
58
|
+
"@eslint/js": "^9.15.0",
|
|
59
|
+
"@types/node": "^22.10.0",
|
|
60
|
+
"eslint": "^9.15.0",
|
|
61
61
|
"eslint-config-prettier": "^9.1.0",
|
|
62
62
|
"eslint-plugin-prettier": "^5.2.1",
|
|
63
|
-
"globals": "^15.
|
|
64
|
-
"prettier": "^3.
|
|
65
|
-
"tsup": "^8.3.
|
|
66
|
-
"typescript": "^5.
|
|
63
|
+
"globals": "^15.12.0",
|
|
64
|
+
"prettier": "^3.4.1",
|
|
65
|
+
"tsup": "^8.3.5",
|
|
66
|
+
"typescript": "^5.7.2"
|
|
67
67
|
}
|
|
68
68
|
}
|