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,176 @@
|
|
|
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 { IScheme } from "../../node_parser_types";
|
|
18
|
+
/**
|
|
19
|
+
* Parse MPD boolean attributes.
|
|
20
|
+
*
|
|
21
|
+
* The returned value is a tuple of two elements where:
|
|
22
|
+
* 1. the first value is the parsed boolean - or `null` if we could not parse
|
|
23
|
+
* it
|
|
24
|
+
* 2. the second value is a possible error encountered while parsing this
|
|
25
|
+
* value - set to `null` if no error was encountered.
|
|
26
|
+
* @param {string} val - The value to parse
|
|
27
|
+
* @param {string} displayName - The name of the property. Used for error
|
|
28
|
+
* formatting.
|
|
29
|
+
* @returns {Array.<Boolean | Error | null>}
|
|
30
|
+
*/
|
|
31
|
+
declare function parseBoolean(val: string, displayName: string): [boolean, MPDError | null];
|
|
32
|
+
/**
|
|
33
|
+
* Parse MPD integer attributes.
|
|
34
|
+
*
|
|
35
|
+
* The returned value is a tuple of two elements where:
|
|
36
|
+
* 1. the first value is the parsed boolean - or `null` if we could not parse
|
|
37
|
+
* it
|
|
38
|
+
* 2. the second value is a possible error encountered while parsing this
|
|
39
|
+
* value - set to `null` if no error was encountered.
|
|
40
|
+
* @param {string} val - The value to parse
|
|
41
|
+
* @param {string} displayName - The name of the property. Used for error
|
|
42
|
+
* formatting.
|
|
43
|
+
* @returns {Array.<number | Error | null>}
|
|
44
|
+
*/
|
|
45
|
+
declare function parseMPDInteger(val: string, displayName: string): [number | null, MPDError | null];
|
|
46
|
+
/**
|
|
47
|
+
* Parse MPD float attributes.
|
|
48
|
+
*
|
|
49
|
+
* The returned value is a tuple of two elements where:
|
|
50
|
+
* 1. the first value is the parsed boolean - or `null` if we could not parse
|
|
51
|
+
* it
|
|
52
|
+
* 2. the second value is a possible error encountered while parsing this
|
|
53
|
+
* value - set to `null` if no error was encountered.
|
|
54
|
+
* @param {string} val - The value to parse
|
|
55
|
+
* @param {string} displayName - The name of the property. Used for error
|
|
56
|
+
* formatting.
|
|
57
|
+
* @returns {Array.<number | Error | null>}
|
|
58
|
+
*/
|
|
59
|
+
declare function parseMPDFloat(val: string, displayName: string): [number | null, MPDError | null];
|
|
60
|
+
/**
|
|
61
|
+
* Parse MPD attributes which are either integer or boolean values.
|
|
62
|
+
*
|
|
63
|
+
* The returned value is a tuple of two elements where:
|
|
64
|
+
* 1. the first value is the parsed value - or `null` if we could not parse
|
|
65
|
+
* it
|
|
66
|
+
* 2. the second value is a possible error encountered while parsing this
|
|
67
|
+
* value - set to `null` if no error was encountered.
|
|
68
|
+
* @param {string} val - The value to parse
|
|
69
|
+
* @param {string} displayName - The name of the property. Used for error
|
|
70
|
+
* formatting.
|
|
71
|
+
* @returns {Array.<Boolean | number | Error | null>}
|
|
72
|
+
*/
|
|
73
|
+
declare function parseIntOrBoolean(val: string, displayName: string): [boolean | number | null, MPDError | null];
|
|
74
|
+
/**
|
|
75
|
+
* Parse MPD date attributes.
|
|
76
|
+
*
|
|
77
|
+
* The returned value is a tuple of two elements where:
|
|
78
|
+
* 1. the first value is the parsed value - or `null` if we could not parse
|
|
79
|
+
* it
|
|
80
|
+
* 2. the second value is a possible error encountered while parsing this
|
|
81
|
+
* value - set to `null` if no error was encountered.
|
|
82
|
+
* @param {string} val - The value to parse
|
|
83
|
+
* @param {string} displayName - The name of the property. Used for error
|
|
84
|
+
* formatting.
|
|
85
|
+
* @returns {Array.<Date | null | Error>}
|
|
86
|
+
*/
|
|
87
|
+
declare function parseDateTime(val: string, displayName: string): [number | null, MPDError | null];
|
|
88
|
+
/**
|
|
89
|
+
* Parse MPD ISO8601 duration attributes into seconds.
|
|
90
|
+
*
|
|
91
|
+
* The returned value is a tuple of two elements where:
|
|
92
|
+
* 1. the first value is the parsed value - or `null` if we could not parse
|
|
93
|
+
* it
|
|
94
|
+
* 2. the second value is a possible error encountered while parsing this
|
|
95
|
+
* value - set to `null` if no error was encountered.
|
|
96
|
+
* @param {string} val - The value to parse
|
|
97
|
+
* @param {string} displayName - The name of the property. Used for error
|
|
98
|
+
* formatting.
|
|
99
|
+
* @returns {Array.<number | Error | null>}
|
|
100
|
+
*/
|
|
101
|
+
declare function parseDuration(val: string, displayName: string): [number | null, MPDError | null];
|
|
102
|
+
/**
|
|
103
|
+
* Parse MPD byterange attributes into arrays of two elements: the start and
|
|
104
|
+
* the end.
|
|
105
|
+
*
|
|
106
|
+
* The returned value is a tuple of two elements where:
|
|
107
|
+
* 1. the first value is the parsed value - or `null` if we could not parse
|
|
108
|
+
* it
|
|
109
|
+
* 2. the second value is a possible error encountered while parsing this
|
|
110
|
+
* value - set to `null` if no error was encountered.
|
|
111
|
+
* @param {string} val
|
|
112
|
+
* @param {string} displayName
|
|
113
|
+
* @returns {Array.<Array.<number> | Error | null>}
|
|
114
|
+
*/
|
|
115
|
+
declare function parseByteRange(val: string, displayName: string): [[number, number] | null, MPDError | null];
|
|
116
|
+
/**
|
|
117
|
+
* Parse MPD base64 attribute into an Uint8Array.
|
|
118
|
+
* the end.
|
|
119
|
+
*
|
|
120
|
+
* The returned value is a tuple of two elements where:
|
|
121
|
+
* 1. the first value is the parsed value - or `null` if we could not parse
|
|
122
|
+
* it
|
|
123
|
+
* 2. the second value is a possible error encountered while parsing this
|
|
124
|
+
* value - set to `null` if no error was encountered.
|
|
125
|
+
* @param {string} val
|
|
126
|
+
* @param {string} displayName
|
|
127
|
+
* @returns {Uint8Array | Error | null>}
|
|
128
|
+
*/
|
|
129
|
+
declare function parseBase64(val: string, displayName: string): [Uint8Array | null, MPDError | null];
|
|
130
|
+
/**
|
|
131
|
+
* Some values in the MPD can be expressed as divisions of integers (e.g. frame
|
|
132
|
+
* rates).
|
|
133
|
+
* This function tries to convert it to a floating point value.
|
|
134
|
+
* @param {string} val
|
|
135
|
+
* @param {string} displayName
|
|
136
|
+
* @returns {Array.<number | Error | null>}
|
|
137
|
+
*/
|
|
138
|
+
declare function parseMaybeDividedNumber(val: string, displayName: string): [number | null, MPDError | null];
|
|
139
|
+
/**
|
|
140
|
+
* @param {Object} root
|
|
141
|
+
* @returns {Object}
|
|
142
|
+
*/
|
|
143
|
+
declare function parseScheme(root: ITNode): IScheme;
|
|
144
|
+
/**
|
|
145
|
+
* Create a function to factorize the MPD parsing logic.
|
|
146
|
+
* @param {Object} dest - The destination object which will contain the parsed
|
|
147
|
+
* values.
|
|
148
|
+
* @param {Array.<Error>} warnings - An array which will contain every parsing
|
|
149
|
+
* error encountered.
|
|
150
|
+
* @return {Function}
|
|
151
|
+
*/
|
|
152
|
+
declare function ValueParser<T>(dest: T, warnings: Error[]): (val: string, { asKey, parser, dashName, }: {
|
|
153
|
+
asKey: keyof T;
|
|
154
|
+
parser: (value: string, displayName: string) => [T[keyof T] | null, MPDError | null];
|
|
155
|
+
dashName: string;
|
|
156
|
+
}) => void;
|
|
157
|
+
/**
|
|
158
|
+
* Error arising when parsing the MPD.
|
|
159
|
+
* @class MPDError
|
|
160
|
+
* @extends Error
|
|
161
|
+
*/
|
|
162
|
+
declare class MPDError extends Error {
|
|
163
|
+
readonly name: "MPDError";
|
|
164
|
+
readonly message: string;
|
|
165
|
+
/**
|
|
166
|
+
* @param {string} message
|
|
167
|
+
*/
|
|
168
|
+
constructor(message: string);
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* Obtain the equivalent of the `textContent` HTMLElement call for that node.
|
|
172
|
+
* @param {Array} children
|
|
173
|
+
* @returns {string}
|
|
174
|
+
*/
|
|
175
|
+
export declare function textContent(children: Array<ITNode | string>): string;
|
|
176
|
+
export { MPDError, ValueParser, parseBase64, parseBoolean, parseByteRange, parseDateTime, parseDuration, parseIntOrBoolean, parseMaybeDividedNumber, parseMPDFloat, parseMPDInteger, parseScheme, };
|
|
@@ -0,0 +1,310 @@
|
|
|
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
|
+
// XML-Schema
|
|
17
|
+
// <http://standards.iso.org/ittf/PubliclyAvailableStandards/MPEG-DASH_schema_files/DASH-MPD.xsd>
|
|
18
|
+
import log from "../../../../../log";
|
|
19
|
+
import { base64ToBytes } from "../../../../../utils/base64";
|
|
20
|
+
import isNonEmptyString from "../../../../../utils/is_non_empty_string";
|
|
21
|
+
import isNullOrUndefined from "../../../../../utils/is_null_or_undefined";
|
|
22
|
+
import { toContentString } from "../../../../../utils/xml-parser";
|
|
23
|
+
const iso8601Duration = /^P(([\d.]*)Y)?(([\d.]*)M)?(([\d.]*)D)?T?(([\d.]*)H)?(([\d.]*)M)?(([\d.]*)S)?/;
|
|
24
|
+
const rangeRe = /([0-9]+)-([0-9]+)/;
|
|
25
|
+
/**
|
|
26
|
+
* Parse MPD boolean attributes.
|
|
27
|
+
*
|
|
28
|
+
* The returned value is a tuple of two elements where:
|
|
29
|
+
* 1. the first value is the parsed boolean - or `null` if we could not parse
|
|
30
|
+
* it
|
|
31
|
+
* 2. the second value is a possible error encountered while parsing this
|
|
32
|
+
* value - set to `null` if no error was encountered.
|
|
33
|
+
* @param {string} val - The value to parse
|
|
34
|
+
* @param {string} displayName - The name of the property. Used for error
|
|
35
|
+
* formatting.
|
|
36
|
+
* @returns {Array.<Boolean | Error | null>}
|
|
37
|
+
*/
|
|
38
|
+
function parseBoolean(val, displayName) {
|
|
39
|
+
if (val === "true") {
|
|
40
|
+
return [true, null];
|
|
41
|
+
}
|
|
42
|
+
if (val === "false") {
|
|
43
|
+
return [false, null];
|
|
44
|
+
}
|
|
45
|
+
const error = new MPDError(`\`${displayName}\` property is not a boolean value but "${val}"`);
|
|
46
|
+
return [false, error];
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Parse MPD integer attributes.
|
|
50
|
+
*
|
|
51
|
+
* The returned value is a tuple of two elements where:
|
|
52
|
+
* 1. the first value is the parsed boolean - or `null` if we could not parse
|
|
53
|
+
* it
|
|
54
|
+
* 2. the second value is a possible error encountered while parsing this
|
|
55
|
+
* value - set to `null` if no error was encountered.
|
|
56
|
+
* @param {string} val - The value to parse
|
|
57
|
+
* @param {string} displayName - The name of the property. Used for error
|
|
58
|
+
* formatting.
|
|
59
|
+
* @returns {Array.<number | Error | null>}
|
|
60
|
+
*/
|
|
61
|
+
function parseMPDInteger(val, displayName) {
|
|
62
|
+
const toInt = parseInt(val, 10);
|
|
63
|
+
if (isNaN(toInt)) {
|
|
64
|
+
const error = new MPDError(`\`${displayName}\` property is not an integer value but "${val}"`);
|
|
65
|
+
return [null, error];
|
|
66
|
+
}
|
|
67
|
+
return [toInt, null];
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Parse MPD float attributes.
|
|
71
|
+
*
|
|
72
|
+
* The returned value is a tuple of two elements where:
|
|
73
|
+
* 1. the first value is the parsed boolean - or `null` if we could not parse
|
|
74
|
+
* it
|
|
75
|
+
* 2. the second value is a possible error encountered while parsing this
|
|
76
|
+
* value - set to `null` if no error was encountered.
|
|
77
|
+
* @param {string} val - The value to parse
|
|
78
|
+
* @param {string} displayName - The name of the property. Used for error
|
|
79
|
+
* formatting.
|
|
80
|
+
* @returns {Array.<number | Error | null>}
|
|
81
|
+
*/
|
|
82
|
+
function parseMPDFloat(val, displayName) {
|
|
83
|
+
if (val === "INF") {
|
|
84
|
+
return [Infinity, null];
|
|
85
|
+
}
|
|
86
|
+
const toInt = parseFloat(val);
|
|
87
|
+
if (isNaN(toInt)) {
|
|
88
|
+
const error = new MPDError(`\`${displayName}\` property is invalid: "${val}"`);
|
|
89
|
+
return [null, error];
|
|
90
|
+
}
|
|
91
|
+
return [toInt, null];
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Parse MPD attributes which are either integer or boolean values.
|
|
95
|
+
*
|
|
96
|
+
* The returned value is a tuple of two elements where:
|
|
97
|
+
* 1. the first value is the parsed value - or `null` if we could not parse
|
|
98
|
+
* it
|
|
99
|
+
* 2. the second value is a possible error encountered while parsing this
|
|
100
|
+
* value - set to `null` if no error was encountered.
|
|
101
|
+
* @param {string} val - The value to parse
|
|
102
|
+
* @param {string} displayName - The name of the property. Used for error
|
|
103
|
+
* formatting.
|
|
104
|
+
* @returns {Array.<Boolean | number | Error | null>}
|
|
105
|
+
*/
|
|
106
|
+
function parseIntOrBoolean(val, displayName) {
|
|
107
|
+
if (val === "true") {
|
|
108
|
+
return [true, null];
|
|
109
|
+
}
|
|
110
|
+
if (val === "false") {
|
|
111
|
+
return [false, null];
|
|
112
|
+
}
|
|
113
|
+
const toInt = parseInt(val, 10);
|
|
114
|
+
if (isNaN(toInt)) {
|
|
115
|
+
const error = new MPDError(`\`${displayName}\` property is not a boolean nor an integer but "${val}"`);
|
|
116
|
+
return [null, error];
|
|
117
|
+
}
|
|
118
|
+
return [toInt, null];
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Parse MPD date attributes.
|
|
122
|
+
*
|
|
123
|
+
* The returned value is a tuple of two elements where:
|
|
124
|
+
* 1. the first value is the parsed value - or `null` if we could not parse
|
|
125
|
+
* it
|
|
126
|
+
* 2. the second value is a possible error encountered while parsing this
|
|
127
|
+
* value - set to `null` if no error was encountered.
|
|
128
|
+
* @param {string} val - The value to parse
|
|
129
|
+
* @param {string} displayName - The name of the property. Used for error
|
|
130
|
+
* formatting.
|
|
131
|
+
* @returns {Array.<Date | null | Error>}
|
|
132
|
+
*/
|
|
133
|
+
function parseDateTime(val, displayName) {
|
|
134
|
+
const parsed = Date.parse(val);
|
|
135
|
+
if (isNaN(parsed)) {
|
|
136
|
+
const error = new MPDError(`\`${displayName}\` is in an invalid date format: "${val}"`);
|
|
137
|
+
return [null, error];
|
|
138
|
+
}
|
|
139
|
+
return [new Date(Date.parse(val)).getTime() / 1000, null];
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Parse MPD ISO8601 duration attributes into seconds.
|
|
143
|
+
*
|
|
144
|
+
* The returned value is a tuple of two elements where:
|
|
145
|
+
* 1. the first value is the parsed value - or `null` if we could not parse
|
|
146
|
+
* it
|
|
147
|
+
* 2. the second value is a possible error encountered while parsing this
|
|
148
|
+
* value - set to `null` if no error was encountered.
|
|
149
|
+
* @param {string} val - The value to parse
|
|
150
|
+
* @param {string} displayName - The name of the property. Used for error
|
|
151
|
+
* formatting.
|
|
152
|
+
* @returns {Array.<number | Error | null>}
|
|
153
|
+
*/
|
|
154
|
+
function parseDuration(val, displayName) {
|
|
155
|
+
if (!isNonEmptyString(val)) {
|
|
156
|
+
const error = new MPDError(`\`${displayName}\` property is empty`);
|
|
157
|
+
return [0, error];
|
|
158
|
+
}
|
|
159
|
+
const match = iso8601Duration.exec(val);
|
|
160
|
+
if (match === null) {
|
|
161
|
+
const error = new MPDError(`\`${displayName}\` property has an unrecognized format "${val}"`);
|
|
162
|
+
return [null, error];
|
|
163
|
+
}
|
|
164
|
+
const duration = parseFloat(isNonEmptyString(match[2]) ? match[2] : "0") * 365 * 24 * 60 * 60 +
|
|
165
|
+
parseFloat(isNonEmptyString(match[4]) ? match[4] : "0") * 30 * 24 * 60 * 60 +
|
|
166
|
+
parseFloat(isNonEmptyString(match[6]) ? match[6] : "0") * 24 * 60 * 60 +
|
|
167
|
+
parseFloat(isNonEmptyString(match[8]) ? match[8] : "0") * 60 * 60 +
|
|
168
|
+
parseFloat(isNonEmptyString(match[10]) ? match[10] : "0") * 60 +
|
|
169
|
+
parseFloat(isNonEmptyString(match[12]) ? match[12] : "0");
|
|
170
|
+
return [duration, null];
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* Parse MPD byterange attributes into arrays of two elements: the start and
|
|
174
|
+
* the end.
|
|
175
|
+
*
|
|
176
|
+
* The returned value is a tuple of two elements where:
|
|
177
|
+
* 1. the first value is the parsed value - or `null` if we could not parse
|
|
178
|
+
* it
|
|
179
|
+
* 2. the second value is a possible error encountered while parsing this
|
|
180
|
+
* value - set to `null` if no error was encountered.
|
|
181
|
+
* @param {string} val
|
|
182
|
+
* @param {string} displayName
|
|
183
|
+
* @returns {Array.<Array.<number> | Error | null>}
|
|
184
|
+
*/
|
|
185
|
+
function parseByteRange(val, displayName) {
|
|
186
|
+
const match = rangeRe.exec(val);
|
|
187
|
+
if (match === null) {
|
|
188
|
+
const error = new MPDError(`\`${displayName}\` property has an unrecognized format "${val}"`);
|
|
189
|
+
return [null, error];
|
|
190
|
+
}
|
|
191
|
+
else {
|
|
192
|
+
return [[+match[1], +match[2]], null];
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
/**
|
|
196
|
+
* Parse MPD base64 attribute into an Uint8Array.
|
|
197
|
+
* the end.
|
|
198
|
+
*
|
|
199
|
+
* The returned value is a tuple of two elements where:
|
|
200
|
+
* 1. the first value is the parsed value - or `null` if we could not parse
|
|
201
|
+
* it
|
|
202
|
+
* 2. the second value is a possible error encountered while parsing this
|
|
203
|
+
* value - set to `null` if no error was encountered.
|
|
204
|
+
* @param {string} val
|
|
205
|
+
* @param {string} displayName
|
|
206
|
+
* @returns {Uint8Array | Error | null>}
|
|
207
|
+
*/
|
|
208
|
+
function parseBase64(val, displayName) {
|
|
209
|
+
try {
|
|
210
|
+
return [base64ToBytes(val), null];
|
|
211
|
+
}
|
|
212
|
+
catch (_) {
|
|
213
|
+
const error = new MPDError(`\`${displayName}\` is not a valid base64 string: "${val}"`);
|
|
214
|
+
return [null, error];
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
/**
|
|
218
|
+
* Some values in the MPD can be expressed as divisions of integers (e.g. frame
|
|
219
|
+
* rates).
|
|
220
|
+
* This function tries to convert it to a floating point value.
|
|
221
|
+
* @param {string} val
|
|
222
|
+
* @param {string} displayName
|
|
223
|
+
* @returns {Array.<number | Error | null>}
|
|
224
|
+
*/
|
|
225
|
+
function parseMaybeDividedNumber(val, displayName) {
|
|
226
|
+
const matches = /^(\d+)\/(\d+)$/.exec(val);
|
|
227
|
+
if (matches !== null) {
|
|
228
|
+
// No need to check, we know both are numbers
|
|
229
|
+
return [+matches[1] / +matches[2], null];
|
|
230
|
+
}
|
|
231
|
+
return parseMPDFloat(val, displayName);
|
|
232
|
+
}
|
|
233
|
+
/**
|
|
234
|
+
* @param {Object} root
|
|
235
|
+
* @returns {Object}
|
|
236
|
+
*/
|
|
237
|
+
function parseScheme(root) {
|
|
238
|
+
let schemeIdUri;
|
|
239
|
+
let value;
|
|
240
|
+
for (const attributeName of Object.keys(root.attributes)) {
|
|
241
|
+
const attributeVal = root.attributes[attributeName];
|
|
242
|
+
if (isNullOrUndefined(attributeVal)) {
|
|
243
|
+
continue;
|
|
244
|
+
}
|
|
245
|
+
switch (attributeName) {
|
|
246
|
+
case "schemeIdUri":
|
|
247
|
+
schemeIdUri = attributeVal;
|
|
248
|
+
break;
|
|
249
|
+
case "value":
|
|
250
|
+
value = attributeVal;
|
|
251
|
+
break;
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
return { schemeIdUri, value };
|
|
255
|
+
}
|
|
256
|
+
/**
|
|
257
|
+
* Create a function to factorize the MPD parsing logic.
|
|
258
|
+
* @param {Object} dest - The destination object which will contain the parsed
|
|
259
|
+
* values.
|
|
260
|
+
* @param {Array.<Error>} warnings - An array which will contain every parsing
|
|
261
|
+
* error encountered.
|
|
262
|
+
* @return {Function}
|
|
263
|
+
*/
|
|
264
|
+
function ValueParser(dest, warnings) {
|
|
265
|
+
/**
|
|
266
|
+
* Parse a single value and add it to the `dest` objects.
|
|
267
|
+
* If an error arised while parsing, add it at the end of the `warnings` array.
|
|
268
|
+
* @param {string} objKey - The key which will be added to the `dest` object.
|
|
269
|
+
* @param {string} val - The value found in the MPD which we should parse.
|
|
270
|
+
* @param {Function} parsingFn - The parsing function adapted for this value.
|
|
271
|
+
* @param {string} displayName - The name of the key as it appears in the MPD.
|
|
272
|
+
* This is used only in error formatting,
|
|
273
|
+
*/
|
|
274
|
+
return function (val, { asKey, parser, dashName, }) {
|
|
275
|
+
const [parsingResult, parsingError] = parser(val, dashName);
|
|
276
|
+
if (parsingError !== null) {
|
|
277
|
+
log.warn(parsingError.message);
|
|
278
|
+
warnings.push(parsingError);
|
|
279
|
+
}
|
|
280
|
+
if (parsingResult !== null) {
|
|
281
|
+
dest[asKey] = parsingResult;
|
|
282
|
+
}
|
|
283
|
+
};
|
|
284
|
+
}
|
|
285
|
+
/**
|
|
286
|
+
* Error arising when parsing the MPD.
|
|
287
|
+
* @class MPDError
|
|
288
|
+
* @extends Error
|
|
289
|
+
*/
|
|
290
|
+
class MPDError extends Error {
|
|
291
|
+
/**
|
|
292
|
+
* @param {string} message
|
|
293
|
+
*/
|
|
294
|
+
constructor(message) {
|
|
295
|
+
super();
|
|
296
|
+
// @see https://stackoverflow.com/questions/41102060/typescript-extending-error-class
|
|
297
|
+
Object.setPrototypeOf(this, MPDError.prototype);
|
|
298
|
+
this.name = "MPDError";
|
|
299
|
+
this.message = message;
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
/**
|
|
303
|
+
* Obtain the equivalent of the `textContent` HTMLElement call for that node.
|
|
304
|
+
* @param {Array} children
|
|
305
|
+
* @returns {string}
|
|
306
|
+
*/
|
|
307
|
+
export function textContent(children) {
|
|
308
|
+
return toContentString(children);
|
|
309
|
+
}
|
|
310
|
+
export { MPDError, ValueParser, parseBase64, parseBoolean, parseByteRange, parseDateTime, parseDuration, parseIntOrBoolean, parseMaybeDividedNumber, parseMPDFloat, parseMPDInteger, parseScheme, };
|
|
@@ -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 { IMPDParserArguments } from "../common";
|
|
17
|
+
import type { IDashParserResponse } from "../parsers_types";
|
|
18
|
+
/**
|
|
19
|
+
* Parse MPD through the Fast JS parser.
|
|
20
|
+
* @param {string} xml - MPD under a string format
|
|
21
|
+
* @param {Object} args - Various parsing options and information.
|
|
22
|
+
* @returns {Object} - Response returned by the DASH-JS parser.
|
|
23
|
+
*/
|
|
24
|
+
export default function parseFromString(xml: string, args: IMPDParserArguments): IDashParserResponse<string>;
|
|
@@ -0,0 +1,114 @@
|
|
|
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 { assertUnreachable } from "../../../../utils/assert";
|
|
17
|
+
import { parseXml } from "../../../../utils/xml-parser";
|
|
18
|
+
import parseMpdIr from "../common";
|
|
19
|
+
import { createMPDIntermediateRepresentation } from "./node_parsers/MPD";
|
|
20
|
+
import { createPeriodIntermediateRepresentation } from "./node_parsers/Period";
|
|
21
|
+
/**
|
|
22
|
+
* Parse MPD through the Fast JS parser.
|
|
23
|
+
* @param {string} xml - MPD under a string format
|
|
24
|
+
* @param {Object} args - Various parsing options and information.
|
|
25
|
+
* @returns {Object} - Response returned by the DASH-JS parser.
|
|
26
|
+
*/
|
|
27
|
+
export default function parseFromString(xml, args) {
|
|
28
|
+
const root = parseXml(xml);
|
|
29
|
+
const lastChild = root[root.length - 1];
|
|
30
|
+
if (lastChild === undefined ||
|
|
31
|
+
typeof lastChild === "string" ||
|
|
32
|
+
lastChild.tagName !== "MPD") {
|
|
33
|
+
throw new Error("DASH Parser: document root should be MPD");
|
|
34
|
+
}
|
|
35
|
+
const [mpdIR, warnings] = createMPDIntermediateRepresentation(lastChild, xml);
|
|
36
|
+
const ret = parseMpdIr(mpdIR, args, warnings);
|
|
37
|
+
return processReturn(ret);
|
|
38
|
+
/**
|
|
39
|
+
* Handle `parseMpdIr` return values, asking for resources if they are needed
|
|
40
|
+
* and pre-processing them before continuing parsing.
|
|
41
|
+
*
|
|
42
|
+
* @param {Object} initialRes
|
|
43
|
+
* @returns {Object}
|
|
44
|
+
*/
|
|
45
|
+
function processReturn(initialRes) {
|
|
46
|
+
if (initialRes.type === "done") {
|
|
47
|
+
return initialRes;
|
|
48
|
+
}
|
|
49
|
+
else if (initialRes.type === "needs-clock") {
|
|
50
|
+
return {
|
|
51
|
+
type: "needs-resources",
|
|
52
|
+
value: {
|
|
53
|
+
urls: [initialRes.value.url],
|
|
54
|
+
format: "string",
|
|
55
|
+
continue(loadedClock) {
|
|
56
|
+
if (loadedClock.length !== 1) {
|
|
57
|
+
throw new Error("DASH parser: wrong number of loaded ressources.");
|
|
58
|
+
}
|
|
59
|
+
const newRet = initialRes.value.continue(loadedClock[0].responseData);
|
|
60
|
+
return processReturn(newRet);
|
|
61
|
+
},
|
|
62
|
+
},
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
else if (initialRes.type === "needs-xlinks") {
|
|
66
|
+
return {
|
|
67
|
+
type: "needs-resources",
|
|
68
|
+
value: {
|
|
69
|
+
urls: initialRes.value.xlinksUrls,
|
|
70
|
+
format: "string",
|
|
71
|
+
continue(loadedXlinks) {
|
|
72
|
+
const resourceInfos = [];
|
|
73
|
+
for (let i = 0; i < loadedXlinks.length; i++) {
|
|
74
|
+
const { responseData: xlinkResp, receivedTime, sendingTime, url, } = loadedXlinks[i];
|
|
75
|
+
if (!xlinkResp.success) {
|
|
76
|
+
throw xlinkResp.error;
|
|
77
|
+
}
|
|
78
|
+
const wrappedData = "<root>" + xlinkResp.data + "</root>";
|
|
79
|
+
const dataAsXML = parseXml(wrappedData);
|
|
80
|
+
const innerParsed = dataAsXML[dataAsXML.length - 1];
|
|
81
|
+
if (innerParsed === undefined || typeof innerParsed === "string") {
|
|
82
|
+
throw new Error("DASH parser: Invalid external ressources");
|
|
83
|
+
}
|
|
84
|
+
const periods = innerParsed.children;
|
|
85
|
+
const periodsIR = [];
|
|
86
|
+
const periodsIRWarnings = [];
|
|
87
|
+
for (let j = 0; j < periods.length; j++) {
|
|
88
|
+
const period = periods[j];
|
|
89
|
+
if (typeof period === "string" || period.tagName !== "Period") {
|
|
90
|
+
continue;
|
|
91
|
+
}
|
|
92
|
+
const [periodIR, periodWarnings] = createPeriodIntermediateRepresentation(period, wrappedData);
|
|
93
|
+
periodsIRWarnings.push(...periodWarnings);
|
|
94
|
+
periodsIR.push(periodIR);
|
|
95
|
+
}
|
|
96
|
+
resourceInfos.push({
|
|
97
|
+
url,
|
|
98
|
+
receivedTime,
|
|
99
|
+
sendingTime,
|
|
100
|
+
parsed: periodsIR,
|
|
101
|
+
warnings: periodsIRWarnings,
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
const newRet = initialRes.value.continue(resourceInfos);
|
|
105
|
+
return processReturn(newRet);
|
|
106
|
+
},
|
|
107
|
+
},
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
else {
|
|
111
|
+
assertUnreachable(initialRes);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
}
|
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
+
import type { ITNode } from "../../../utils/xml-parser";
|
|
16
17
|
/**
|
|
17
18
|
* Those are types used when generating the MPD "Intermediate Representation"
|
|
18
19
|
* which is an intermediate step between parsing the MPD (in XML) and generating
|
|
@@ -386,10 +387,11 @@ export interface IEventStreamEventIntermediateRepresentation {
|
|
|
386
387
|
duration?: number;
|
|
387
388
|
/**
|
|
388
389
|
* The `<Event>` element itself.
|
|
389
|
-
* Can be
|
|
390
|
+
* Can be under any of those forms:
|
|
390
391
|
* - Either as an Element instance directly
|
|
391
392
|
* - Either as the Element's UTF-8 textual representation.
|
|
393
|
+
* - Either as the Element's string representation.
|
|
392
394
|
*/
|
|
393
|
-
eventStreamData?: Element | ArrayBuffer;
|
|
395
|
+
eventStreamData?: Element | ArrayBuffer | string;
|
|
394
396
|
}
|
|
395
|
-
export type ITimelineParser = () => HTMLCollection;
|
|
397
|
+
export type ITimelineParser = () => ITNode[] | HTMLCollection;
|
|
@@ -15,7 +15,7 @@ export type IRxPlayerMode = "auto" | "main" | "multithread";
|
|
|
15
15
|
/** Argument of the `attachWorker` method. */
|
|
16
16
|
export interface IWorkerSettings {
|
|
17
17
|
workerUrl: string | Blob;
|
|
18
|
-
dashWasmUrl
|
|
18
|
+
dashWasmUrl?: string | ArrayBuffer | undefined;
|
|
19
19
|
}
|
|
20
20
|
/** Every options that can be given to the RxPlayer's constructor. */
|
|
21
21
|
export interface IConstructorOptions {
|