rx-player 4.0.0-dev.202402213 → 4.0.0-dev.2024022300
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/VERSION +1 -1
- package/dist/commonjs/__GENERATED_CODE/embedded_dash_wasm.js +1 -1
- package/dist/commonjs/__GENERATED_CODE/embedded_worker.js +1 -1
- package/dist/commonjs/core/main/worker/worker_main.js +8 -9
- package/dist/commonjs/features/features_object.js +1 -1
- package/dist/commonjs/features/list/dash.js +2 -2
- package/dist/commonjs/features/types.d.ts +8 -3
- package/dist/commonjs/main_thread/api/public_api.js +2 -7
- package/dist/commonjs/multithread_types.d.ts +1 -1
- package/dist/commonjs/parsers/manifest/dash/common/indexes/timeline/construct_timeline_from_elements.d.ts +4 -3
- package/dist/commonjs/parsers/manifest/dash/common/indexes/timeline/construct_timeline_from_elements.js +11 -4
- package/dist/commonjs/parsers/manifest/dash/common/indexes/timeline/construct_timeline_from_previous_timeline.d.ts +2 -1
- package/dist/commonjs/parsers/manifest/dash/common/indexes/timeline/construct_timeline_from_previous_timeline.js +12 -3
- package/dist/commonjs/parsers/manifest/dash/common/indexes/timeline/find_first_common_start_time.d.ts +3 -2
- package/dist/commonjs/parsers/manifest/dash/common/indexes/timeline/find_first_common_start_time.js +22 -11
- package/dist/commonjs/parsers/manifest/dash/common/indexes/timeline/parse_s_element.d.ts +11 -2
- package/dist/commonjs/parsers/manifest/dash/common/indexes/timeline/parse_s_element.js +74 -3
- package/dist/commonjs/parsers/manifest/dash/common/indexes/timeline/timeline_representation_index.d.ts +2 -1
- package/dist/commonjs/parsers/manifest/dash/common/parse_periods.js +3 -1
- package/dist/commonjs/parsers/manifest/dash/fast-js-parser/index.d.ts +17 -0
- package/dist/commonjs/parsers/manifest/dash/fast-js-parser/index.js +19 -0
- package/dist/commonjs/parsers/manifest/dash/fast-js-parser/node_parsers/AdaptationSet.d.ts +24 -0
- package/dist/commonjs/parsers/manifest/dash/fast-js-parser/node_parsers/AdaptationSet.js +400 -0
- package/dist/commonjs/parsers/manifest/dash/fast-js-parser/node_parsers/BaseURL.d.ts +24 -0
- package/dist/commonjs/parsers/manifest/dash/fast-js-parser/node_parsers/BaseURL.js +33 -0
- package/dist/commonjs/parsers/manifest/dash/fast-js-parser/node_parsers/ContentComponent.d.ts +23 -0
- package/dist/commonjs/parsers/manifest/dash/fast-js-parser/node_parsers/ContentComponent.js +70 -0
- package/dist/commonjs/parsers/manifest/dash/fast-js-parser/node_parsers/ContentProtection.d.ts +22 -0
- package/dist/commonjs/parsers/manifest/dash/fast-js-parser/node_parsers/ContentProtection.js +118 -0
- package/dist/commonjs/parsers/manifest/dash/fast-js-parser/node_parsers/EventStream.d.ts +23 -0
- package/dist/commonjs/parsers/manifest/dash/fast-js-parser/node_parsers/EventStream.js +154 -0
- package/dist/commonjs/parsers/manifest/dash/fast-js-parser/node_parsers/Initialization.d.ts +22 -0
- package/dist/commonjs/parsers/manifest/dash/fast-js-parser/node_parsers/Initialization.js +70 -0
- package/dist/commonjs/parsers/manifest/dash/fast-js-parser/node_parsers/MPD.d.ts +23 -0
- package/dist/commonjs/parsers/manifest/dash/fast-js-parser/node_parsers/MPD.js +221 -0
- package/dist/commonjs/parsers/manifest/dash/fast-js-parser/node_parsers/Period.d.ts +23 -0
- package/dist/commonjs/parsers/manifest/dash/fast-js-parser/node_parsers/Period.js +179 -0
- package/dist/commonjs/parsers/manifest/dash/fast-js-parser/node_parsers/Representation.d.ts +22 -0
- package/dist/commonjs/parsers/manifest/dash/fast-js-parser/node_parsers/Representation.js +256 -0
- package/dist/commonjs/parsers/manifest/dash/fast-js-parser/node_parsers/SegmentBase.d.ts +23 -0
- package/dist/commonjs/parsers/manifest/dash/fast-js-parser/node_parsers/SegmentBase.js +152 -0
- package/dist/commonjs/parsers/manifest/dash/fast-js-parser/node_parsers/SegmentList.d.ts +22 -0
- package/dist/commonjs/parsers/manifest/dash/fast-js-parser/node_parsers/SegmentList.js +60 -0
- package/dist/commonjs/parsers/manifest/dash/fast-js-parser/node_parsers/SegmentTemplate.d.ts +24 -0
- package/dist/commonjs/parsers/manifest/dash/fast-js-parser/node_parsers/SegmentTemplate.js +125 -0
- package/dist/commonjs/parsers/manifest/dash/fast-js-parser/node_parsers/SegmentTimeline.d.ts +22 -0
- package/dist/commonjs/parsers/manifest/dash/fast-js-parser/node_parsers/SegmentTimeline.js +36 -0
- package/dist/commonjs/parsers/manifest/dash/fast-js-parser/node_parsers/SegmentURL.d.ts +24 -0
- package/dist/commonjs/parsers/manifest/dash/fast-js-parser/node_parsers/SegmentURL.js +82 -0
- package/dist/commonjs/parsers/manifest/dash/fast-js-parser/node_parsers/utils.d.ts +176 -0
- package/dist/commonjs/parsers/manifest/dash/fast-js-parser/node_parsers/utils.js +382 -0
- package/dist/commonjs/parsers/manifest/dash/fast-js-parser/parse_from_xml_string.d.ts +24 -0
- package/dist/commonjs/parsers/manifest/dash/fast-js-parser/parse_from_xml_string.js +142 -0
- package/dist/commonjs/parsers/manifest/dash/node_parser_types.d.ts +5 -3
- package/dist/commonjs/public_types.d.ts +1 -1
- package/dist/commonjs/transports/dash/manifest_parser.js +33 -4
- package/dist/commonjs/utils/xml-parser.d.ts +70 -0
- package/dist/commonjs/utils/xml-parser.js +357 -0
- package/dist/es2017/__GENERATED_CODE/embedded_dash_wasm.js +1 -1
- package/dist/es2017/__GENERATED_CODE/embedded_worker.js +1 -1
- package/dist/es2017/core/main/worker/worker_main.js +8 -9
- package/dist/es2017/features/features_object.js +1 -1
- package/dist/es2017/features/list/dash.js +2 -2
- package/dist/es2017/features/types.d.ts +8 -3
- package/dist/es2017/main_thread/api/public_api.js +2 -7
- package/dist/es2017/multithread_types.d.ts +1 -1
- package/dist/es2017/parsers/manifest/dash/common/indexes/timeline/construct_timeline_from_elements.d.ts +4 -3
- package/dist/es2017/parsers/manifest/dash/common/indexes/timeline/construct_timeline_from_elements.js +12 -5
- package/dist/es2017/parsers/manifest/dash/common/indexes/timeline/construct_timeline_from_previous_timeline.d.ts +2 -1
- package/dist/es2017/parsers/manifest/dash/common/indexes/timeline/construct_timeline_from_previous_timeline.js +13 -4
- package/dist/es2017/parsers/manifest/dash/common/indexes/timeline/find_first_common_start_time.d.ts +3 -2
- package/dist/es2017/parsers/manifest/dash/common/indexes/timeline/find_first_common_start_time.js +22 -11
- package/dist/es2017/parsers/manifest/dash/common/indexes/timeline/parse_s_element.d.ts +11 -2
- package/dist/es2017/parsers/manifest/dash/common/indexes/timeline/parse_s_element.js +49 -2
- package/dist/es2017/parsers/manifest/dash/common/indexes/timeline/timeline_representation_index.d.ts +2 -1
- package/dist/es2017/parsers/manifest/dash/common/parse_periods.js +3 -1
- package/dist/es2017/parsers/manifest/dash/fast-js-parser/index.d.ts +17 -0
- package/dist/es2017/parsers/manifest/dash/fast-js-parser/index.js +17 -0
- package/dist/es2017/parsers/manifest/dash/fast-js-parser/node_parsers/AdaptationSet.d.ts +24 -0
- package/dist/es2017/parsers/manifest/dash/fast-js-parser/node_parsers/AdaptationSet.js +358 -0
- package/dist/es2017/parsers/manifest/dash/fast-js-parser/node_parsers/BaseURL.d.ts +24 -0
- package/dist/es2017/parsers/manifest/dash/fast-js-parser/node_parsers/BaseURL.js +30 -0
- package/dist/es2017/parsers/manifest/dash/fast-js-parser/node_parsers/ContentComponent.d.ts +23 -0
- package/dist/es2017/parsers/manifest/dash/fast-js-parser/node_parsers/ContentComponent.js +45 -0
- package/dist/es2017/parsers/manifest/dash/fast-js-parser/node_parsers/ContentProtection.d.ts +22 -0
- package/dist/es2017/parsers/manifest/dash/fast-js-parser/node_parsers/ContentProtection.js +77 -0
- package/dist/es2017/parsers/manifest/dash/fast-js-parser/node_parsers/EventStream.d.ts +23 -0
- package/dist/es2017/parsers/manifest/dash/fast-js-parser/node_parsers/EventStream.js +101 -0
- package/dist/es2017/parsers/manifest/dash/fast-js-parser/node_parsers/Initialization.d.ts +22 -0
- package/dist/es2017/parsers/manifest/dash/fast-js-parser/node_parsers/Initialization.js +45 -0
- package/dist/es2017/parsers/manifest/dash/fast-js-parser/node_parsers/MPD.d.ts +23 -0
- package/dist/es2017/parsers/manifest/dash/fast-js-parser/node_parsers/MPD.js +179 -0
- package/dist/es2017/parsers/manifest/dash/fast-js-parser/node_parsers/Period.d.ts +23 -0
- package/dist/es2017/parsers/manifest/dash/fast-js-parser/node_parsers/Period.js +137 -0
- package/dist/es2017/parsers/manifest/dash/fast-js-parser/node_parsers/Representation.d.ts +22 -0
- package/dist/es2017/parsers/manifest/dash/fast-js-parser/node_parsers/Representation.js +214 -0
- package/dist/es2017/parsers/manifest/dash/fast-js-parser/node_parsers/SegmentBase.d.ts +23 -0
- package/dist/es2017/parsers/manifest/dash/fast-js-parser/node_parsers/SegmentBase.js +111 -0
- package/dist/es2017/parsers/manifest/dash/fast-js-parser/node_parsers/SegmentList.d.ts +22 -0
- package/dist/es2017/parsers/manifest/dash/fast-js-parser/node_parsers/SegmentList.js +41 -0
- package/dist/es2017/parsers/manifest/dash/fast-js-parser/node_parsers/SegmentTemplate.d.ts +24 -0
- package/dist/es2017/parsers/manifest/dash/fast-js-parser/node_parsers/SegmentTemplate.js +84 -0
- package/dist/es2017/parsers/manifest/dash/fast-js-parser/node_parsers/SegmentTimeline.d.ts +22 -0
- package/dist/es2017/parsers/manifest/dash/fast-js-parser/node_parsers/SegmentTimeline.js +33 -0
- package/dist/es2017/parsers/manifest/dash/fast-js-parser/node_parsers/SegmentURL.d.ts +24 -0
- package/dist/es2017/parsers/manifest/dash/fast-js-parser/node_parsers/SegmentURL.js +57 -0
- package/dist/es2017/parsers/manifest/dash/fast-js-parser/node_parsers/utils.d.ts +176 -0
- package/dist/es2017/parsers/manifest/dash/fast-js-parser/node_parsers/utils.js +310 -0
- package/dist/es2017/parsers/manifest/dash/fast-js-parser/parse_from_xml_string.d.ts +24 -0
- package/dist/es2017/parsers/manifest/dash/fast-js-parser/parse_from_xml_string.js +114 -0
- package/dist/es2017/parsers/manifest/dash/node_parser_types.d.ts +5 -3
- package/dist/es2017/public_types.d.ts +1 -1
- package/dist/es2017/transports/dash/manifest_parser.js +33 -4
- package/dist/es2017/utils/xml-parser.d.ts +70 -0
- package/dist/es2017/utils/xml-parser.js +322 -0
- package/dist/mpd-parser.wasm +0 -0
- package/dist/rx-player.js +141 -65
- package/dist/rx-player.min.js +1 -1
- package/dist/worker.js +8 -3
- package/package.json +1 -1
- package/.vscode/settings.json +0 -9
- /package/dist/commonjs/parsers/manifest/dash/{js-parser → native-parser}/index.d.ts +0 -0
- /package/dist/commonjs/parsers/manifest/dash/{js-parser → native-parser}/index.js +0 -0
- /package/dist/commonjs/parsers/manifest/dash/{js-parser → native-parser}/node_parsers/AdaptationSet.d.ts +0 -0
- /package/dist/commonjs/parsers/manifest/dash/{js-parser → native-parser}/node_parsers/AdaptationSet.js +0 -0
- /package/dist/commonjs/parsers/manifest/dash/{js-parser → native-parser}/node_parsers/BaseURL.d.ts +0 -0
- /package/dist/commonjs/parsers/manifest/dash/{js-parser → native-parser}/node_parsers/BaseURL.js +0 -0
- /package/dist/commonjs/parsers/manifest/dash/{js-parser → native-parser}/node_parsers/ContentComponent.d.ts +0 -0
- /package/dist/commonjs/parsers/manifest/dash/{js-parser → native-parser}/node_parsers/ContentComponent.js +0 -0
- /package/dist/commonjs/parsers/manifest/dash/{js-parser → native-parser}/node_parsers/ContentProtection.d.ts +0 -0
- /package/dist/commonjs/parsers/manifest/dash/{js-parser → native-parser}/node_parsers/ContentProtection.js +0 -0
- /package/dist/commonjs/parsers/manifest/dash/{js-parser → native-parser}/node_parsers/EventStream.d.ts +0 -0
- /package/dist/commonjs/parsers/manifest/dash/{js-parser → native-parser}/node_parsers/EventStream.js +0 -0
- /package/dist/commonjs/parsers/manifest/dash/{js-parser → native-parser}/node_parsers/Initialization.d.ts +0 -0
- /package/dist/commonjs/parsers/manifest/dash/{js-parser → native-parser}/node_parsers/Initialization.js +0 -0
- /package/dist/commonjs/parsers/manifest/dash/{js-parser → native-parser}/node_parsers/MPD.d.ts +0 -0
- /package/dist/commonjs/parsers/manifest/dash/{js-parser → native-parser}/node_parsers/MPD.js +0 -0
- /package/dist/commonjs/parsers/manifest/dash/{js-parser → native-parser}/node_parsers/Period.d.ts +0 -0
- /package/dist/commonjs/parsers/manifest/dash/{js-parser → native-parser}/node_parsers/Period.js +0 -0
- /package/dist/commonjs/parsers/manifest/dash/{js-parser → native-parser}/node_parsers/Representation.d.ts +0 -0
- /package/dist/commonjs/parsers/manifest/dash/{js-parser → native-parser}/node_parsers/Representation.js +0 -0
- /package/dist/commonjs/parsers/manifest/dash/{js-parser → native-parser}/node_parsers/SegmentBase.d.ts +0 -0
- /package/dist/commonjs/parsers/manifest/dash/{js-parser → native-parser}/node_parsers/SegmentBase.js +0 -0
- /package/dist/commonjs/parsers/manifest/dash/{js-parser → native-parser}/node_parsers/SegmentList.d.ts +0 -0
- /package/dist/commonjs/parsers/manifest/dash/{js-parser → native-parser}/node_parsers/SegmentList.js +0 -0
- /package/dist/commonjs/parsers/manifest/dash/{js-parser → native-parser}/node_parsers/SegmentTemplate.d.ts +0 -0
- /package/dist/commonjs/parsers/manifest/dash/{js-parser → native-parser}/node_parsers/SegmentTemplate.js +0 -0
- /package/dist/commonjs/parsers/manifest/dash/{js-parser → native-parser}/node_parsers/SegmentTimeline.d.ts +0 -0
- /package/dist/commonjs/parsers/manifest/dash/{js-parser → native-parser}/node_parsers/SegmentTimeline.js +0 -0
- /package/dist/commonjs/parsers/manifest/dash/{js-parser → native-parser}/node_parsers/SegmentURL.d.ts +0 -0
- /package/dist/commonjs/parsers/manifest/dash/{js-parser → native-parser}/node_parsers/SegmentURL.js +0 -0
- /package/dist/commonjs/parsers/manifest/dash/{js-parser → native-parser}/node_parsers/utils.d.ts +0 -0
- /package/dist/commonjs/parsers/manifest/dash/{js-parser → native-parser}/node_parsers/utils.js +0 -0
- /package/dist/commonjs/parsers/manifest/dash/{js-parser → native-parser}/parse_from_document.d.ts +0 -0
- /package/dist/commonjs/parsers/manifest/dash/{js-parser → native-parser}/parse_from_document.js +0 -0
- /package/dist/es2017/parsers/manifest/dash/{js-parser → native-parser}/index.d.ts +0 -0
- /package/dist/es2017/parsers/manifest/dash/{js-parser → native-parser}/index.js +0 -0
- /package/dist/es2017/parsers/manifest/dash/{js-parser → native-parser}/node_parsers/AdaptationSet.d.ts +0 -0
- /package/dist/es2017/parsers/manifest/dash/{js-parser → native-parser}/node_parsers/AdaptationSet.js +0 -0
- /package/dist/es2017/parsers/manifest/dash/{js-parser → native-parser}/node_parsers/BaseURL.d.ts +0 -0
- /package/dist/es2017/parsers/manifest/dash/{js-parser → native-parser}/node_parsers/BaseURL.js +0 -0
- /package/dist/es2017/parsers/manifest/dash/{js-parser → native-parser}/node_parsers/ContentComponent.d.ts +0 -0
- /package/dist/es2017/parsers/manifest/dash/{js-parser → native-parser}/node_parsers/ContentComponent.js +0 -0
- /package/dist/es2017/parsers/manifest/dash/{js-parser → native-parser}/node_parsers/ContentProtection.d.ts +0 -0
- /package/dist/es2017/parsers/manifest/dash/{js-parser → native-parser}/node_parsers/ContentProtection.js +0 -0
- /package/dist/es2017/parsers/manifest/dash/{js-parser → native-parser}/node_parsers/EventStream.d.ts +0 -0
- /package/dist/es2017/parsers/manifest/dash/{js-parser → native-parser}/node_parsers/EventStream.js +0 -0
- /package/dist/es2017/parsers/manifest/dash/{js-parser → native-parser}/node_parsers/Initialization.d.ts +0 -0
- /package/dist/es2017/parsers/manifest/dash/{js-parser → native-parser}/node_parsers/Initialization.js +0 -0
- /package/dist/es2017/parsers/manifest/dash/{js-parser → native-parser}/node_parsers/MPD.d.ts +0 -0
- /package/dist/es2017/parsers/manifest/dash/{js-parser → native-parser}/node_parsers/MPD.js +0 -0
- /package/dist/es2017/parsers/manifest/dash/{js-parser → native-parser}/node_parsers/Period.d.ts +0 -0
- /package/dist/es2017/parsers/manifest/dash/{js-parser → native-parser}/node_parsers/Period.js +0 -0
- /package/dist/es2017/parsers/manifest/dash/{js-parser → native-parser}/node_parsers/Representation.d.ts +0 -0
- /package/dist/es2017/parsers/manifest/dash/{js-parser → native-parser}/node_parsers/Representation.js +0 -0
- /package/dist/es2017/parsers/manifest/dash/{js-parser → native-parser}/node_parsers/SegmentBase.d.ts +0 -0
- /package/dist/es2017/parsers/manifest/dash/{js-parser → native-parser}/node_parsers/SegmentBase.js +0 -0
- /package/dist/es2017/parsers/manifest/dash/{js-parser → native-parser}/node_parsers/SegmentList.d.ts +0 -0
- /package/dist/es2017/parsers/manifest/dash/{js-parser → native-parser}/node_parsers/SegmentList.js +0 -0
- /package/dist/es2017/parsers/manifest/dash/{js-parser → native-parser}/node_parsers/SegmentTemplate.d.ts +0 -0
- /package/dist/es2017/parsers/manifest/dash/{js-parser → native-parser}/node_parsers/SegmentTemplate.js +0 -0
- /package/dist/es2017/parsers/manifest/dash/{js-parser → native-parser}/node_parsers/SegmentTimeline.d.ts +0 -0
- /package/dist/es2017/parsers/manifest/dash/{js-parser → native-parser}/node_parsers/SegmentTimeline.js +0 -0
- /package/dist/es2017/parsers/manifest/dash/{js-parser → native-parser}/node_parsers/SegmentURL.d.ts +0 -0
- /package/dist/es2017/parsers/manifest/dash/{js-parser → native-parser}/node_parsers/SegmentURL.js +0 -0
- /package/dist/es2017/parsers/manifest/dash/{js-parser → native-parser}/node_parsers/utils.d.ts +0 -0
- /package/dist/es2017/parsers/manifest/dash/{js-parser → native-parser}/node_parsers/utils.js +0 -0
- /package/dist/es2017/parsers/manifest/dash/{js-parser → native-parser}/parse_from_document.d.ts +0 -0
- /package/dist/es2017/parsers/manifest/dash/{js-parser → native-parser}/parse_from_document.js +0 -0
|
@@ -0,0 +1,358 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2015 CANAL+ Group
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
import isNullOrUndefined from "../../../../../utils/is_null_or_undefined";
|
|
17
|
+
import parseBaseURL from "./BaseURL";
|
|
18
|
+
import parseContentComponent from "./ContentComponent";
|
|
19
|
+
import parseContentProtection from "./ContentProtection";
|
|
20
|
+
import { createRepresentationIntermediateRepresentation } from "./Representation";
|
|
21
|
+
import parseSegmentBase from "./SegmentBase";
|
|
22
|
+
import parseSegmentList from "./SegmentList";
|
|
23
|
+
import parseSegmentTemplate from "./SegmentTemplate";
|
|
24
|
+
import { parseBoolean, parseIntOrBoolean, parseMaybeDividedNumber, parseMPDFloat, parseMPDInteger, parseScheme, textContent, ValueParser, } from "./utils";
|
|
25
|
+
/**
|
|
26
|
+
* Parse child nodes from an AdaptationSet.
|
|
27
|
+
* @param {Array.<ITNode | string>} adaptationSetChildren - The AdaptationSet child nodes.
|
|
28
|
+
* @returns {Array.<Object>}
|
|
29
|
+
*/
|
|
30
|
+
function parseAdaptationSetChildren(adaptationSetChildren) {
|
|
31
|
+
const children = {
|
|
32
|
+
baseURLs: [],
|
|
33
|
+
representations: [],
|
|
34
|
+
};
|
|
35
|
+
const contentProtections = [];
|
|
36
|
+
let warnings = [];
|
|
37
|
+
for (let i = 0; i < adaptationSetChildren.length; i++) {
|
|
38
|
+
const currentNode = adaptationSetChildren[i];
|
|
39
|
+
if (typeof currentNode === "string") {
|
|
40
|
+
continue;
|
|
41
|
+
}
|
|
42
|
+
switch (currentNode.tagName) {
|
|
43
|
+
case "Accessibility":
|
|
44
|
+
if (children.accessibilities === undefined) {
|
|
45
|
+
children.accessibilities = [parseScheme(currentNode)];
|
|
46
|
+
}
|
|
47
|
+
else {
|
|
48
|
+
children.accessibilities.push(parseScheme(currentNode));
|
|
49
|
+
}
|
|
50
|
+
break;
|
|
51
|
+
case "BaseURL":
|
|
52
|
+
const [baseURLObj, baseURLWarnings] = parseBaseURL(currentNode);
|
|
53
|
+
if (baseURLObj !== undefined) {
|
|
54
|
+
children.baseURLs.push(baseURLObj);
|
|
55
|
+
}
|
|
56
|
+
if (baseURLWarnings.length > 0) {
|
|
57
|
+
warnings = warnings.concat(baseURLWarnings);
|
|
58
|
+
}
|
|
59
|
+
break;
|
|
60
|
+
case "ContentComponent":
|
|
61
|
+
children.contentComponent = parseContentComponent(currentNode);
|
|
62
|
+
break;
|
|
63
|
+
case "EssentialProperty":
|
|
64
|
+
if (isNullOrUndefined(children.essentialProperties)) {
|
|
65
|
+
children.essentialProperties = [parseScheme(currentNode)];
|
|
66
|
+
}
|
|
67
|
+
else {
|
|
68
|
+
children.essentialProperties.push(parseScheme(currentNode));
|
|
69
|
+
}
|
|
70
|
+
break;
|
|
71
|
+
case "InbandEventStream":
|
|
72
|
+
if (children.inbandEventStreams === undefined) {
|
|
73
|
+
children.inbandEventStreams = [];
|
|
74
|
+
}
|
|
75
|
+
children.inbandEventStreams.push(parseScheme(currentNode));
|
|
76
|
+
break;
|
|
77
|
+
case "Label":
|
|
78
|
+
const label = textContent(currentNode.children);
|
|
79
|
+
if (label !== null && label !== undefined) {
|
|
80
|
+
children.label = label;
|
|
81
|
+
}
|
|
82
|
+
break;
|
|
83
|
+
case "Representation":
|
|
84
|
+
const [representation, representationWarnings] = createRepresentationIntermediateRepresentation(currentNode);
|
|
85
|
+
children.representations.push(representation);
|
|
86
|
+
if (representationWarnings.length > 0) {
|
|
87
|
+
warnings = warnings.concat(representationWarnings);
|
|
88
|
+
}
|
|
89
|
+
break;
|
|
90
|
+
case "Role":
|
|
91
|
+
if (isNullOrUndefined(children.roles)) {
|
|
92
|
+
children.roles = [parseScheme(currentNode)];
|
|
93
|
+
}
|
|
94
|
+
else {
|
|
95
|
+
children.roles.push(parseScheme(currentNode));
|
|
96
|
+
}
|
|
97
|
+
break;
|
|
98
|
+
case "SupplementalProperty":
|
|
99
|
+
if (isNullOrUndefined(children.supplementalProperties)) {
|
|
100
|
+
children.supplementalProperties = [parseScheme(currentNode)];
|
|
101
|
+
}
|
|
102
|
+
else {
|
|
103
|
+
children.supplementalProperties.push(parseScheme(currentNode));
|
|
104
|
+
}
|
|
105
|
+
break;
|
|
106
|
+
case "SegmentBase":
|
|
107
|
+
const [segmentBase, segmentBaseWarnings] = parseSegmentBase(currentNode);
|
|
108
|
+
children.segmentBase = segmentBase;
|
|
109
|
+
if (segmentBaseWarnings.length > 0) {
|
|
110
|
+
warnings = warnings.concat(segmentBaseWarnings);
|
|
111
|
+
}
|
|
112
|
+
break;
|
|
113
|
+
case "SegmentList":
|
|
114
|
+
const [segmentList, segmentListWarnings] = parseSegmentList(currentNode);
|
|
115
|
+
children.segmentList = segmentList;
|
|
116
|
+
if (segmentListWarnings.length > 0) {
|
|
117
|
+
warnings = warnings.concat(segmentListWarnings);
|
|
118
|
+
}
|
|
119
|
+
break;
|
|
120
|
+
case "SegmentTemplate":
|
|
121
|
+
const [segmentTemplate, segmentTemplateWarnings] = parseSegmentTemplate(currentNode);
|
|
122
|
+
children.segmentTemplate = segmentTemplate;
|
|
123
|
+
if (segmentTemplateWarnings.length > 0) {
|
|
124
|
+
warnings = warnings.concat(segmentTemplateWarnings);
|
|
125
|
+
}
|
|
126
|
+
break;
|
|
127
|
+
case "ContentProtection":
|
|
128
|
+
const [contentProtection, contentProtectionWarnings] = parseContentProtection(currentNode);
|
|
129
|
+
if (contentProtectionWarnings.length > 0) {
|
|
130
|
+
warnings = warnings.concat(contentProtectionWarnings);
|
|
131
|
+
}
|
|
132
|
+
if (contentProtection !== undefined) {
|
|
133
|
+
contentProtections.push(contentProtection);
|
|
134
|
+
}
|
|
135
|
+
break;
|
|
136
|
+
// case "Rating":
|
|
137
|
+
// children.rating = currentNode;
|
|
138
|
+
// break;
|
|
139
|
+
// case "Viewpoint":
|
|
140
|
+
// children.viewpoint = currentNode;
|
|
141
|
+
// break;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
if (contentProtections.length > 0) {
|
|
145
|
+
children.contentProtections = contentProtections;
|
|
146
|
+
}
|
|
147
|
+
return [children, warnings];
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* Parse every attributes from an AdaptationSet root element into a simple JS
|
|
151
|
+
* object.
|
|
152
|
+
* @param {Object} root - The AdaptationSet root element.
|
|
153
|
+
* @returns {Array.<Object>}
|
|
154
|
+
*/
|
|
155
|
+
function parseAdaptationSetAttributes(root) {
|
|
156
|
+
const parsedAdaptation = {};
|
|
157
|
+
const warnings = [];
|
|
158
|
+
const parseValue = ValueParser(parsedAdaptation, warnings);
|
|
159
|
+
for (const attributeName of Object.keys(root.attributes)) {
|
|
160
|
+
const attributeVal = root.attributes[attributeName];
|
|
161
|
+
if (isNullOrUndefined(attributeVal)) {
|
|
162
|
+
continue;
|
|
163
|
+
}
|
|
164
|
+
switch (attributeName) {
|
|
165
|
+
case "id":
|
|
166
|
+
parsedAdaptation.id = attributeVal;
|
|
167
|
+
break;
|
|
168
|
+
case "group":
|
|
169
|
+
parseValue(attributeVal, {
|
|
170
|
+
asKey: "group",
|
|
171
|
+
parser: parseMPDInteger,
|
|
172
|
+
dashName: "group",
|
|
173
|
+
});
|
|
174
|
+
break;
|
|
175
|
+
case "lang":
|
|
176
|
+
parsedAdaptation.language = attributeVal;
|
|
177
|
+
break;
|
|
178
|
+
case "contentType":
|
|
179
|
+
parsedAdaptation.contentType = attributeVal;
|
|
180
|
+
break;
|
|
181
|
+
case "par":
|
|
182
|
+
parsedAdaptation.par = attributeVal;
|
|
183
|
+
break;
|
|
184
|
+
case "minBandwidth":
|
|
185
|
+
parseValue(attributeVal, {
|
|
186
|
+
asKey: "minBitrate",
|
|
187
|
+
parser: parseMPDInteger,
|
|
188
|
+
dashName: "minBandwidth",
|
|
189
|
+
});
|
|
190
|
+
break;
|
|
191
|
+
case "maxBandwidth":
|
|
192
|
+
parseValue(attributeVal, {
|
|
193
|
+
asKey: "maxBitrate",
|
|
194
|
+
parser: parseMPDInteger,
|
|
195
|
+
dashName: "maxBandwidth",
|
|
196
|
+
});
|
|
197
|
+
break;
|
|
198
|
+
case "minWidth":
|
|
199
|
+
parseValue(attributeVal, {
|
|
200
|
+
asKey: "minWidth",
|
|
201
|
+
parser: parseMPDInteger,
|
|
202
|
+
dashName: "minWidth",
|
|
203
|
+
});
|
|
204
|
+
break;
|
|
205
|
+
case "maxWidth":
|
|
206
|
+
parseValue(attributeVal, {
|
|
207
|
+
asKey: "maxWidth",
|
|
208
|
+
parser: parseMPDInteger,
|
|
209
|
+
dashName: "maxWidth",
|
|
210
|
+
});
|
|
211
|
+
break;
|
|
212
|
+
case "minHeight":
|
|
213
|
+
parseValue(attributeVal, {
|
|
214
|
+
asKey: "minHeight",
|
|
215
|
+
parser: parseMPDInteger,
|
|
216
|
+
dashName: "minHeight",
|
|
217
|
+
});
|
|
218
|
+
break;
|
|
219
|
+
case "maxHeight":
|
|
220
|
+
parseValue(attributeVal, {
|
|
221
|
+
asKey: "maxHeight",
|
|
222
|
+
parser: parseMPDInteger,
|
|
223
|
+
dashName: "maxHeight",
|
|
224
|
+
});
|
|
225
|
+
break;
|
|
226
|
+
case "minFrameRate":
|
|
227
|
+
parseValue(attributeVal, {
|
|
228
|
+
asKey: "minFrameRate",
|
|
229
|
+
parser: parseMaybeDividedNumber,
|
|
230
|
+
dashName: "minFrameRate",
|
|
231
|
+
});
|
|
232
|
+
break;
|
|
233
|
+
case "maxFrameRate":
|
|
234
|
+
parseValue(attributeVal, {
|
|
235
|
+
asKey: "maxFrameRate",
|
|
236
|
+
parser: parseMaybeDividedNumber,
|
|
237
|
+
dashName: "maxFrameRate",
|
|
238
|
+
});
|
|
239
|
+
break;
|
|
240
|
+
case "selectionPriority":
|
|
241
|
+
parseValue(attributeVal, {
|
|
242
|
+
asKey: "selectionPriority",
|
|
243
|
+
parser: parseMPDInteger,
|
|
244
|
+
dashName: "selectionPriority",
|
|
245
|
+
});
|
|
246
|
+
break;
|
|
247
|
+
case "segmentAlignment":
|
|
248
|
+
parseValue(attributeVal, {
|
|
249
|
+
asKey: "segmentAlignment",
|
|
250
|
+
parser: parseIntOrBoolean,
|
|
251
|
+
dashName: "segmentAlignment",
|
|
252
|
+
});
|
|
253
|
+
break;
|
|
254
|
+
case "subsegmentAlignment":
|
|
255
|
+
parseValue(attributeVal, {
|
|
256
|
+
asKey: "subsegmentAlignment",
|
|
257
|
+
parser: parseIntOrBoolean,
|
|
258
|
+
dashName: "subsegmentAlignment",
|
|
259
|
+
});
|
|
260
|
+
break;
|
|
261
|
+
case "bitstreamSwitching":
|
|
262
|
+
parseValue(attributeVal, {
|
|
263
|
+
asKey: "bitstreamSwitching",
|
|
264
|
+
parser: parseBoolean,
|
|
265
|
+
dashName: "bitstreamSwitching",
|
|
266
|
+
});
|
|
267
|
+
break;
|
|
268
|
+
case "audioSamplingRate":
|
|
269
|
+
parsedAdaptation.audioSamplingRate = attributeVal;
|
|
270
|
+
break;
|
|
271
|
+
case "codecs":
|
|
272
|
+
parsedAdaptation.codecs = attributeVal;
|
|
273
|
+
break;
|
|
274
|
+
case "scte214:supplementalCodecs":
|
|
275
|
+
parsedAdaptation.supplementalCodecs = attributeVal;
|
|
276
|
+
break;
|
|
277
|
+
case "codingDependency":
|
|
278
|
+
parseValue(attributeVal, {
|
|
279
|
+
asKey: "codingDependency",
|
|
280
|
+
parser: parseBoolean,
|
|
281
|
+
dashName: "codingDependency",
|
|
282
|
+
});
|
|
283
|
+
break;
|
|
284
|
+
case "frameRate":
|
|
285
|
+
parseValue(attributeVal, {
|
|
286
|
+
asKey: "frameRate",
|
|
287
|
+
parser: parseMaybeDividedNumber,
|
|
288
|
+
dashName: "frameRate",
|
|
289
|
+
});
|
|
290
|
+
break;
|
|
291
|
+
case "height":
|
|
292
|
+
parseValue(attributeVal, {
|
|
293
|
+
asKey: "height",
|
|
294
|
+
parser: parseMPDInteger,
|
|
295
|
+
dashName: "height",
|
|
296
|
+
});
|
|
297
|
+
break;
|
|
298
|
+
case "maxPlayoutRate":
|
|
299
|
+
parseValue(attributeVal, {
|
|
300
|
+
asKey: "maxPlayoutRate",
|
|
301
|
+
parser: parseMPDFloat,
|
|
302
|
+
dashName: "maxPlayoutRate",
|
|
303
|
+
});
|
|
304
|
+
break;
|
|
305
|
+
case "maximumSAPPeriod":
|
|
306
|
+
parseValue(attributeVal, {
|
|
307
|
+
asKey: "maximumSAPPeriod",
|
|
308
|
+
parser: parseMPDFloat,
|
|
309
|
+
dashName: "maximumSAPPeriod",
|
|
310
|
+
});
|
|
311
|
+
break;
|
|
312
|
+
case "mimeType":
|
|
313
|
+
parsedAdaptation.mimeType = attributeVal;
|
|
314
|
+
break;
|
|
315
|
+
case "profiles":
|
|
316
|
+
parsedAdaptation.profiles = attributeVal;
|
|
317
|
+
break;
|
|
318
|
+
case "segmentProfiles":
|
|
319
|
+
parsedAdaptation.segmentProfiles = attributeVal;
|
|
320
|
+
break;
|
|
321
|
+
case "width":
|
|
322
|
+
parseValue(attributeVal, {
|
|
323
|
+
asKey: "width",
|
|
324
|
+
parser: parseMPDInteger,
|
|
325
|
+
dashName: "width",
|
|
326
|
+
});
|
|
327
|
+
break;
|
|
328
|
+
case "availabilityTimeOffset":
|
|
329
|
+
parseValue(attributeVal, {
|
|
330
|
+
asKey: "availabilityTimeOffset",
|
|
331
|
+
parser: parseMPDFloat,
|
|
332
|
+
dashName: "availabilityTimeOffset",
|
|
333
|
+
});
|
|
334
|
+
break;
|
|
335
|
+
case "availabilityTimeComplete":
|
|
336
|
+
parseValue(attributeVal, {
|
|
337
|
+
asKey: "availabilityTimeComplete",
|
|
338
|
+
parser: parseBoolean,
|
|
339
|
+
dashName: "availabilityTimeComplete",
|
|
340
|
+
});
|
|
341
|
+
break;
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
return [parsedAdaptation, warnings];
|
|
345
|
+
}
|
|
346
|
+
/**
|
|
347
|
+
* Parse an AdaptationSet element into an AdaptationSet intermediate
|
|
348
|
+
* representation.
|
|
349
|
+
* @param {Object} adaptationSetElement - The AdaptationSet root element.
|
|
350
|
+
* @returns {Array.<Object>}
|
|
351
|
+
*/
|
|
352
|
+
export function createAdaptationSetIntermediateRepresentation(adaptationSetElement) {
|
|
353
|
+
const childNodes = adaptationSetElement.children;
|
|
354
|
+
const [children, childrenWarnings] = parseAdaptationSetChildren(childNodes);
|
|
355
|
+
const [attributes, attrsWarnings] = parseAdaptationSetAttributes(adaptationSetElement);
|
|
356
|
+
const warnings = childrenWarnings.concat(attrsWarnings);
|
|
357
|
+
return [{ children, attributes }, warnings];
|
|
358
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2015 CANAL+ Group
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
import type { ITNode } from "../../../../../utils/xml-parser";
|
|
17
|
+
import type { IBaseUrlIntermediateRepresentation } from "../../node_parser_types";
|
|
18
|
+
/**
|
|
19
|
+
* Parse an BaseURL element into an BaseURL intermediate
|
|
20
|
+
* representation.
|
|
21
|
+
* @param {Object | string} root - The BaseURL root element.
|
|
22
|
+
* @returns {Array.<Object|undefined>}
|
|
23
|
+
*/
|
|
24
|
+
export default function parseBaseURL(root: ITNode | string): [IBaseUrlIntermediateRepresentation | undefined, Error[]];
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2015 CANAL+ Group
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
import { textContent } from "./utils";
|
|
17
|
+
/**
|
|
18
|
+
* Parse an BaseURL element into an BaseURL intermediate
|
|
19
|
+
* representation.
|
|
20
|
+
* @param {Object | string} root - The BaseURL root element.
|
|
21
|
+
* @returns {Array.<Object|undefined>}
|
|
22
|
+
*/
|
|
23
|
+
export default function parseBaseURL(root) {
|
|
24
|
+
const value = typeof root === "string" ? root : textContent(root.children);
|
|
25
|
+
const warnings = [];
|
|
26
|
+
if (value === null || value.length === 0) {
|
|
27
|
+
return [undefined, warnings];
|
|
28
|
+
}
|
|
29
|
+
return [{ value }, warnings];
|
|
30
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2015 CANAL+ Group
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
import type { ITNode } from "../../../../../utils/xml-parser";
|
|
17
|
+
import type { IContentComponentAttributes } from "../../node_parser_types";
|
|
18
|
+
/**
|
|
19
|
+
* Parse a "ContentComponent" Element in a DASH MPD.
|
|
20
|
+
* @param {Object} root
|
|
21
|
+
* @returns {Object}
|
|
22
|
+
*/
|
|
23
|
+
export default function parseContentComponent(root: ITNode): IContentComponentAttributes;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2015 CANAL+ Group
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
import isNullOrUndefined from "../../../../../utils/is_null_or_undefined";
|
|
17
|
+
/**
|
|
18
|
+
* Parse a "ContentComponent" Element in a DASH MPD.
|
|
19
|
+
* @param {Object} root
|
|
20
|
+
* @returns {Object}
|
|
21
|
+
*/
|
|
22
|
+
export default function parseContentComponent(root) {
|
|
23
|
+
const ret = {};
|
|
24
|
+
for (const attributeName of Object.keys(root.attributes)) {
|
|
25
|
+
const attributeVal = root.attributes[attributeName];
|
|
26
|
+
if (isNullOrUndefined(attributeVal)) {
|
|
27
|
+
continue;
|
|
28
|
+
}
|
|
29
|
+
switch (attributeName) {
|
|
30
|
+
case "id":
|
|
31
|
+
ret.id = attributeVal;
|
|
32
|
+
break;
|
|
33
|
+
case "lang":
|
|
34
|
+
ret.language = attributeVal;
|
|
35
|
+
break;
|
|
36
|
+
case "contentType":
|
|
37
|
+
ret.contentType = attributeVal;
|
|
38
|
+
break;
|
|
39
|
+
case "par":
|
|
40
|
+
ret.par = attributeVal;
|
|
41
|
+
break;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
return ret;
|
|
45
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2015 CANAL+ Group
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
import type { ITNode } from "../../../../../utils/xml-parser";
|
|
17
|
+
import type { IContentProtectionIntermediateRepresentation } from "../../node_parser_types";
|
|
18
|
+
/**
|
|
19
|
+
* @param {Object} contentProtectionElement
|
|
20
|
+
* @returns {Object}
|
|
21
|
+
*/
|
|
22
|
+
export default function parseContentProtection(contentProtectionElement: ITNode): [IContentProtectionIntermediateRepresentation, Error[]];
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2015 CANAL+ Group
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
import log from "../../../../../log";
|
|
17
|
+
import isNullOrUndefined from "../../../../../utils/is_null_or_undefined";
|
|
18
|
+
import { hexToBytes } from "../../../../../utils/string_parsing";
|
|
19
|
+
import { parseBase64, textContent } from "./utils";
|
|
20
|
+
/**
|
|
21
|
+
* @param {Array.<Object | string>} contentProtectionChildren
|
|
22
|
+
* @Returns {Object}
|
|
23
|
+
*/
|
|
24
|
+
function parseContentProtectionChildren(contentProtectionChildren) {
|
|
25
|
+
const warnings = [];
|
|
26
|
+
const cencPssh = [];
|
|
27
|
+
for (let i = 0; i < contentProtectionChildren.length; i++) {
|
|
28
|
+
const currentElement = contentProtectionChildren[i];
|
|
29
|
+
if (typeof currentElement !== "string" && currentElement.tagName === "cenc:pssh") {
|
|
30
|
+
const content = textContent(currentElement.children);
|
|
31
|
+
if (content !== null && content.length > 0) {
|
|
32
|
+
const [toUint8Array, error] = parseBase64(content, "cenc:pssh");
|
|
33
|
+
if (error !== null) {
|
|
34
|
+
log.warn(error.message);
|
|
35
|
+
warnings.push(error);
|
|
36
|
+
}
|
|
37
|
+
if (toUint8Array !== null) {
|
|
38
|
+
cencPssh.push(toUint8Array);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
return [{ cencPssh }, warnings];
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* @param {Object} root
|
|
47
|
+
* @returns {Object}
|
|
48
|
+
*/
|
|
49
|
+
function parseContentProtectionAttributes(root) {
|
|
50
|
+
const ret = {};
|
|
51
|
+
for (const attributeName of Object.keys(root.attributes)) {
|
|
52
|
+
const attributeVal = root.attributes[attributeName];
|
|
53
|
+
if (isNullOrUndefined(attributeVal)) {
|
|
54
|
+
continue;
|
|
55
|
+
}
|
|
56
|
+
switch (attributeName) {
|
|
57
|
+
case "schemeIdUri":
|
|
58
|
+
ret.schemeIdUri = attributeVal;
|
|
59
|
+
break;
|
|
60
|
+
case "value":
|
|
61
|
+
ret.value = attributeVal;
|
|
62
|
+
break;
|
|
63
|
+
case "cenc:default_KID":
|
|
64
|
+
ret.keyId = hexToBytes(attributeVal.replace(/-/g, ""));
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
return ret;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* @param {Object} contentProtectionElement
|
|
71
|
+
* @returns {Object}
|
|
72
|
+
*/
|
|
73
|
+
export default function parseContentProtection(contentProtectionElement) {
|
|
74
|
+
const [children, childrenWarnings] = parseContentProtectionChildren(contentProtectionElement.children);
|
|
75
|
+
const attributes = parseContentProtectionAttributes(contentProtectionElement);
|
|
76
|
+
return [{ children, attributes }, childrenWarnings];
|
|
77
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2015 CANAL+ Group
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
import type { ITNode } from "../../../../../utils/xml-parser";
|
|
17
|
+
import type { IEventStreamIntermediateRepresentation } from "../../node_parser_types";
|
|
18
|
+
/**
|
|
19
|
+
* @param {Object} root
|
|
20
|
+
* @param {string} fullMpd
|
|
21
|
+
* @returns {Array}
|
|
22
|
+
*/
|
|
23
|
+
export declare function createEventStreamIntermediateRepresentation(root: ITNode, fullMpd: string): [IEventStreamIntermediateRepresentation, Error[]];
|