rx-player 4.5.0-dev.2026031700 → 4.5.0-dev.2026033100
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/CHANGELOG.md +3 -1
- package/VERSION +1 -1
- package/dist/commonjs/__GENERATED_CODE/embedded_worker.d.ts.map +1 -1
- package/dist/commonjs/__GENERATED_CODE/embedded_worker.js +1 -1
- package/dist/commonjs/compat/browser_compatibility_types.d.ts +16 -14
- package/dist/commonjs/compat/browser_compatibility_types.d.ts.map +1 -1
- package/dist/commonjs/compat/browser_compatibility_types.js +7 -4
- package/dist/commonjs/compat/browser_version.d.ts +2 -1
- package/dist/commonjs/compat/browser_version.d.ts.map +1 -1
- package/dist/commonjs/compat/browser_version.js +13 -0
- package/dist/commonjs/compat/disable_remote_playback_on_managed_media_source.d.ts.map +1 -1
- package/dist/commonjs/compat/disable_remote_playback_on_managed_media_source.js +1 -1
- package/dist/commonjs/compat/is_codec_supported.d.ts.map +1 -1
- package/dist/commonjs/compat/is_codec_supported.js +4 -3
- package/dist/commonjs/compat/should_patch_out_dolby_vision_config_data_from_mp4.d.ts +26 -0
- package/dist/commonjs/compat/should_patch_out_dolby_vision_config_data_from_mp4.d.ts.map +1 -0
- package/dist/commonjs/compat/should_patch_out_dolby_vision_config_data_from_mp4.js +45 -0
- package/dist/commonjs/core/entry/utils.js +3 -3
- package/dist/commonjs/core/fetchers/segment/segment_fetcher.d.ts.map +1 -1
- package/dist/commonjs/core/fetchers/segment/segment_fetcher.js +2 -1
- package/dist/commonjs/experimental/tools/VideoThumbnailLoader/prepare_source_buffer.d.ts.map +1 -1
- package/dist/commonjs/experimental/tools/VideoThumbnailLoader/prepare_source_buffer.js +2 -1
- package/dist/commonjs/experimental/tools/mediaCapabilitiesProber/probers/defaultCodecsFinder.d.ts.map +1 -1
- package/dist/commonjs/experimental/tools/mediaCapabilitiesProber/probers/defaultCodecsFinder.js +8 -6
- package/dist/commonjs/experimental/tools/mediaCapabilitiesProber/probers/mediaContentType.d.ts.map +1 -1
- package/dist/commonjs/experimental/tools/mediaCapabilitiesProber/probers/mediaContentType.js +4 -3
- package/dist/commonjs/initialize_worker.js +1 -1
- package/dist/commonjs/main_thread/api/debug/modules/segment_buffer_content.js +3 -3
- package/dist/commonjs/main_thread/api/public_api.js +2 -2
- package/dist/commonjs/main_thread/init/utils/update_manifest_codec_support.d.ts.map +1 -1
- package/dist/commonjs/main_thread/init/utils/update_manifest_codec_support.js +24 -12
- package/dist/commonjs/manifest/classes/adaptation.d.ts.map +1 -1
- package/dist/commonjs/manifest/classes/adaptation.js +3 -1
- package/dist/commonjs/manifest/classes/representation.d.ts +6 -2
- package/dist/commonjs/manifest/classes/representation.d.ts.map +1 -1
- package/dist/commonjs/manifest/classes/representation.js +45 -23
- package/dist/commonjs/manifest/types.d.ts +14 -6
- package/dist/commonjs/manifest/types.d.ts.map +1 -1
- package/dist/commonjs/manifest/utils.js +4 -4
- package/dist/commonjs/mse/main_media_source_interface.d.ts.map +1 -1
- package/dist/commonjs/mse/main_media_source_interface.js +3 -2
- package/dist/commonjs/mse/worker_media_source_interface.d.ts.map +1 -1
- package/dist/commonjs/parsers/containers/isobmff/get_box.d.ts +12 -1
- package/dist/commonjs/parsers/containers/isobmff/get_box.d.ts.map +1 -1
- package/dist/commonjs/parsers/containers/isobmff/get_box.js +16 -0
- package/dist/commonjs/parsers/containers/isobmff/index.d.ts +2 -1
- package/dist/commonjs/parsers/containers/isobmff/index.d.ts.map +1 -1
- package/dist/commonjs/parsers/containers/isobmff/index.js +3 -1
- package/dist/commonjs/parsers/containers/isobmff/remove_dolby_vision_config_data.d.ts +13 -0
- package/dist/commonjs/parsers/containers/isobmff/remove_dolby_vision_config_data.d.ts.map +1 -0
- package/dist/commonjs/parsers/containers/isobmff/remove_dolby_vision_config_data.js +180 -0
- package/dist/commonjs/parsers/manifest/metaplaylist/metaplaylist_parser.js +4 -4
- package/dist/commonjs/transports/dash/segment_parser.d.ts.map +1 -1
- package/dist/commonjs/transports/dash/segment_parser.js +6 -0
- package/dist/commonjs/transports/dash/text_parser.d.ts.map +1 -1
- package/dist/commonjs/transports/dash/text_parser.js +5 -1
- package/dist/commonjs/transports/local/text_parser.d.ts.map +1 -1
- package/dist/commonjs/transports/local/text_parser.js +5 -1
- package/dist/commonjs/transports/metaplaylist/pipelines.d.ts.map +1 -1
- package/dist/commonjs/transports/metaplaylist/pipelines.js +2 -1
- package/dist/commonjs/transports/smooth/pipelines.js +3 -3
- package/dist/commonjs/transports/types.d.ts +28 -2
- package/dist/commonjs/transports/types.d.ts.map +1 -1
- package/dist/commonjs/transports/utils/parse_text_track.d.ts +9 -2
- package/dist/commonjs/transports/utils/parse_text_track.d.ts.map +1 -1
- package/dist/commonjs/transports/utils/parse_text_track.js +1 -1
- package/dist/es2017/__GENERATED_CODE/embedded_worker.d.ts.map +1 -1
- package/dist/es2017/__GENERATED_CODE/embedded_worker.js +1 -1
- package/dist/es2017/compat/browser_compatibility_types.d.ts +16 -14
- package/dist/es2017/compat/browser_compatibility_types.d.ts.map +1 -1
- package/dist/es2017/compat/browser_compatibility_types.js +7 -1
- package/dist/es2017/compat/browser_version.d.ts +2 -1
- package/dist/es2017/compat/browser_version.d.ts.map +1 -1
- package/dist/es2017/compat/browser_version.js +13 -1
- package/dist/es2017/compat/disable_remote_playback_on_managed_media_source.d.ts.map +1 -1
- package/dist/es2017/compat/disable_remote_playback_on_managed_media_source.js +2 -2
- package/dist/es2017/compat/is_codec_supported.d.ts.map +1 -1
- package/dist/es2017/compat/is_codec_supported.js +2 -1
- package/dist/es2017/compat/should_patch_out_dolby_vision_config_data_from_mp4.d.ts +26 -0
- package/dist/es2017/compat/should_patch_out_dolby_vision_config_data_from_mp4.d.ts.map +1 -0
- package/dist/es2017/compat/should_patch_out_dolby_vision_config_data_from_mp4.js +42 -0
- package/dist/es2017/core/entry/utils.js +4 -4
- package/dist/es2017/core/fetchers/segment/segment_fetcher.d.ts.map +1 -1
- package/dist/es2017/core/fetchers/segment/segment_fetcher.js +2 -1
- package/dist/es2017/experimental/tools/VideoThumbnailLoader/prepare_source_buffer.d.ts.map +1 -1
- package/dist/es2017/experimental/tools/VideoThumbnailLoader/prepare_source_buffer.js +2 -1
- package/dist/es2017/experimental/tools/mediaCapabilitiesProber/probers/defaultCodecsFinder.d.ts.map +1 -1
- package/dist/es2017/experimental/tools/mediaCapabilitiesProber/probers/defaultCodecsFinder.js +3 -1
- package/dist/es2017/experimental/tools/mediaCapabilitiesProber/probers/mediaContentType.d.ts.map +1 -1
- package/dist/es2017/experimental/tools/mediaCapabilitiesProber/probers/mediaContentType.js +2 -1
- package/dist/es2017/initialize_worker.js +1 -1
- package/dist/es2017/main_thread/api/debug/modules/segment_buffer_content.js +3 -3
- package/dist/es2017/main_thread/api/public_api.js +2 -2
- package/dist/es2017/main_thread/init/utils/update_manifest_codec_support.d.ts.map +1 -1
- package/dist/es2017/main_thread/init/utils/update_manifest_codec_support.js +9 -7
- package/dist/es2017/manifest/classes/adaptation.d.ts.map +1 -1
- package/dist/es2017/manifest/classes/adaptation.js +3 -1
- package/dist/es2017/manifest/classes/representation.d.ts +6 -2
- package/dist/es2017/manifest/classes/representation.d.ts.map +1 -1
- package/dist/es2017/manifest/classes/representation.js +45 -23
- package/dist/es2017/manifest/types.d.ts +14 -6
- package/dist/es2017/manifest/types.d.ts.map +1 -1
- package/dist/es2017/manifest/utils.js +4 -4
- package/dist/es2017/mse/main_media_source_interface.d.ts.map +1 -1
- package/dist/es2017/mse/main_media_source_interface.js +2 -1
- package/dist/es2017/mse/worker_media_source_interface.d.ts.map +1 -1
- package/dist/es2017/parsers/containers/isobmff/get_box.d.ts +12 -1
- package/dist/es2017/parsers/containers/isobmff/get_box.d.ts.map +1 -1
- package/dist/es2017/parsers/containers/isobmff/get_box.js +16 -1
- package/dist/es2017/parsers/containers/isobmff/index.d.ts +2 -1
- package/dist/es2017/parsers/containers/isobmff/index.d.ts.map +1 -1
- package/dist/es2017/parsers/containers/isobmff/index.js +2 -1
- package/dist/es2017/parsers/containers/isobmff/remove_dolby_vision_config_data.d.ts +13 -0
- package/dist/es2017/parsers/containers/isobmff/remove_dolby_vision_config_data.d.ts.map +1 -0
- package/dist/es2017/parsers/containers/isobmff/remove_dolby_vision_config_data.js +155 -0
- package/dist/es2017/parsers/manifest/metaplaylist/metaplaylist_parser.js +4 -4
- package/dist/es2017/transports/dash/segment_parser.d.ts.map +1 -1
- package/dist/es2017/transports/dash/segment_parser.js +7 -1
- package/dist/es2017/transports/dash/text_parser.d.ts.map +1 -1
- package/dist/es2017/transports/dash/text_parser.js +5 -1
- package/dist/es2017/transports/local/text_parser.d.ts.map +1 -1
- package/dist/es2017/transports/local/text_parser.js +5 -1
- package/dist/es2017/transports/metaplaylist/pipelines.d.ts.map +1 -1
- package/dist/es2017/transports/metaplaylist/pipelines.js +2 -1
- package/dist/es2017/transports/smooth/pipelines.js +3 -3
- package/dist/es2017/transports/types.d.ts +28 -2
- package/dist/es2017/transports/types.d.ts.map +1 -1
- package/dist/es2017/transports/utils/parse_text_track.d.ts +9 -2
- package/dist/es2017/transports/utils/parse_text_track.d.ts.map +1 -1
- package/dist/es2017/transports/utils/parse_text_track.js +1 -1
- package/dist/worker.js +6 -6
- package/eslint.config.mjs +1 -14
- package/package.json +1 -1
- package/src/__GENERATED_CODE/embedded_worker.ts +1 -1
- package/src/compat/__tests__/browser_compatibility_types.test.ts +15 -26
- package/src/compat/__tests__/browser_version.test.ts +57 -18
- package/src/compat/__tests__/clear_element_src.test.ts +20 -40
- package/src/compat/__tests__/is_codec_supported.test.ts +39 -44
- package/src/compat/__tests__/is_vtt_cue.test.ts +5 -8
- package/src/compat/__tests__/make_vtt_cue.test.ts +20 -31
- package/src/compat/__tests__/remove_cue.test.ts +8 -20
- package/src/compat/__tests__/should_patch_out_dolby_vision_config_data_from_mp4.test.ts +78 -0
- package/src/compat/browser_compatibility_types.ts +8 -1
- package/src/compat/browser_version.ts +17 -1
- package/src/compat/disable_remote_playback_on_managed_media_source.ts +2 -2
- package/src/compat/is_codec_supported.ts +2 -1
- package/src/compat/should_patch_out_dolby_vision_config_data_from_mp4.ts +50 -0
- package/src/core/adaptive/__tests__/adaptive_representation_selector.test.ts +68 -28
- package/src/core/adaptive/__tests__/buffer_based_chooser.test.ts +26 -84
- package/src/core/entry/__tests__/utils.test.ts +7 -1
- package/src/core/entry/utils.ts +4 -4
- package/src/core/fetchers/segment/segment_fetcher.ts +2 -1
- package/src/errors/__tests__/format_error.test.ts +23 -24
- package/src/experimental/tools/VideoThumbnailLoader/prepare_source_buffer.ts +2 -1
- package/src/experimental/tools/mediaCapabilitiesProber/__tests__/probers/mediaDisplayInfos.test.ts +106 -0
- package/src/experimental/tools/mediaCapabilitiesProber/probers/__tests__/HDCPPolicy.test.ts +19 -42
- package/src/experimental/tools/mediaCapabilitiesProber/probers/__tests__/decodingInfo.test.ts +33 -40
- package/src/experimental/tools/mediaCapabilitiesProber/probers/__tests__/defaultCodecsFinder.test.ts +44 -68
- package/src/experimental/tools/mediaCapabilitiesProber/probers/__tests__/mediaContentType.test.ts +45 -80
- package/src/experimental/tools/mediaCapabilitiesProber/probers/defaultCodecsFinder.ts +3 -1
- package/src/experimental/tools/mediaCapabilitiesProber/probers/mediaContentType.ts +2 -1
- package/src/features/__tests__/add_features.test.ts +12 -27
- package/src/initialize_worker.ts +1 -1
- package/src/main_thread/api/__tests__/option_utils.test.ts +38 -67
- package/src/main_thread/api/__tests__/public_api.test.ts +56 -138
- package/src/main_thread/api/debug/modules/segment_buffer_content.ts +3 -3
- package/src/main_thread/api/public_api.ts +2 -2
- package/src/main_thread/decrypt/__tests__/__global__/find_key_system.test.ts +46 -28
- package/src/main_thread/decrypt/__tests__/__global__/get_license.test.ts +40 -10
- package/src/main_thread/decrypt/__tests__/__global__/init_data.test.ts +112 -129
- package/src/main_thread/decrypt/__tests__/__global__/media_key_system_access.test.ts +282 -377
- package/src/main_thread/decrypt/__tests__/__global__/media_keys.test.ts +70 -63
- package/src/main_thread/decrypt/__tests__/__global__/server_certificate.test.ts +73 -54
- package/src/main_thread/decrypt/__tests__/__global__/utils.ts +43 -83
- package/src/main_thread/decrypt/__tests__/find_key_system.test.ts +36 -17
- package/src/main_thread/decrypt/utils/__tests__/clean_old_stored_persistent_info.test.ts +44 -48
- package/src/main_thread/init/utils/__tests__/are_same_stream_events.test.ts +7 -22
- package/src/main_thread/init/utils/__tests__/refresh_scheduled_events_list.test.ts +3 -6
- package/src/main_thread/init/utils/__tests__/update_manifest_codec_support.test.ts +42 -19
- package/src/main_thread/init/utils/update_manifest_codec_support.ts +8 -6
- package/src/manifest/classes/__tests__/adaptation.test.ts +69 -125
- package/src/manifest/classes/__tests__/manifest.test.ts +88 -95
- package/src/manifest/classes/__tests__/period.test.ts +167 -117
- package/src/manifest/classes/__tests__/representation.test.ts +84 -25
- package/src/manifest/classes/__tests__/update_periods.test.ts +96 -225
- package/src/manifest/classes/adaptation.ts +4 -1
- package/src/manifest/classes/representation.ts +59 -27
- package/src/manifest/types.ts +14 -6
- package/src/manifest/utils.ts +4 -4
- package/src/mse/__tests__/main_media_source_interface.test.ts +3 -1
- package/src/mse/__tests__/worker_media_source_interface.test.ts +608 -0
- package/src/mse/main_media_source_interface.ts +2 -1
- package/src/mse/worker_media_source_interface.ts +2 -2
- package/src/parsers/containers/isobmff/__tests__/get_box.test.ts +449 -0
- package/src/parsers/containers/isobmff/__tests__/remove_dolby_vision_config_data.test.ts +282 -0
- package/src/parsers/containers/isobmff/get_box.ts +17 -0
- package/src/parsers/containers/isobmff/index.ts +8 -1
- package/src/parsers/containers/isobmff/remove_dolby_vision_config_data.ts +179 -0
- package/src/parsers/manifest/dash/common/__tests__/get_clock_offset.test.ts +19 -25
- package/src/parsers/manifest/dash/common/__tests__/get_http_utc-timing_url.test.ts +7 -19
- package/src/parsers/manifest/dash/js-parser/node_parsers/__tests__/ContentProtection.test.ts +26 -37
- package/src/parsers/manifest/dash/js-parser/node_parsers/__tests__/Initialization.test.ts +24 -53
- package/src/parsers/manifest/dash/js-parser/node_parsers/__tests__/SegmentURL.test.ts +31 -78
- package/src/parsers/manifest/metaplaylist/metaplaylist_parser.ts +6 -4
- package/src/parsers/manifest/utils/__tests__/update_segment_timeline.test.ts +79 -87
- package/src/parsers/texttracks/ttml/__tests__/resolve_styles_inheritance.test.ts +20 -26
- package/src/parsers/texttracks/ttml/html/__tests__/__global__/html_ttml_parser.test.ts +2 -7
- package/src/parsers/texttracks/webvtt/__tests__/parse_cue_block.test.ts +33 -30
- package/src/parsers/texttracks/webvtt/__tests__/parse_style_block.test.ts +33 -100
- package/src/parsers/texttracks/webvtt/html/__tests__/convert_payload_to_html.test.ts +16 -18
- package/src/parsers/texttracks/webvtt/html/__tests__/parse_webvtt_to_div.test.ts +73 -78
- package/src/parsers/texttracks/webvtt/html/__tests__/to_html.test.ts +36 -37
- package/src/transports/dash/segment_parser.ts +13 -0
- package/src/transports/dash/text_parser.ts +5 -1
- package/src/transports/local/text_parser.ts +5 -1
- package/src/transports/metaplaylist/pipelines.ts +2 -1
- package/src/transports/smooth/isobmff/__tests__/create_boxes.test.ts +150 -127
- package/src/transports/smooth/pipelines.ts +3 -3
- package/src/transports/types.ts +28 -2
- package/src/transports/utils/__tests__/check_isobmff_integrity.test.ts +49 -75
- package/src/transports/utils/parse_text_track.ts +10 -3
- package/src/utils/__tests__/object_assign.test.ts +2 -2
|
@@ -0,0 +1,282 @@
|
|
|
1
|
+
import { describe, it, expect } from "vitest";
|
|
2
|
+
import removeDolbyVisionConfigData from "../remove_dolby_vision_config_data";
|
|
3
|
+
|
|
4
|
+
/** Write a big-endian uint32 into a DataView */
|
|
5
|
+
function writeU32(view: DataView, offset: number, value: number): void {
|
|
6
|
+
view.setUint32(offset, value, false);
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Build a minimal ISOBMFF box:
|
|
11
|
+
* [size u32][type u32][...payload]
|
|
12
|
+
*/
|
|
13
|
+
function buildBox(
|
|
14
|
+
type: number,
|
|
15
|
+
payload: Uint8Array<ArrayBuffer>,
|
|
16
|
+
): Uint8Array<ArrayBuffer> {
|
|
17
|
+
const buf = new Uint8Array(8 + payload.length);
|
|
18
|
+
const view = new DataView(buf.buffer);
|
|
19
|
+
writeU32(view, 0, buf.length);
|
|
20
|
+
writeU32(view, 4, type);
|
|
21
|
+
buf.set(payload, 8);
|
|
22
|
+
return buf;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Concatenate multiple Uint8Arrays into one.
|
|
27
|
+
*/
|
|
28
|
+
function concat(...arrays: Array<Uint8Array<ArrayBuffer>>): Uint8Array<ArrayBuffer> {
|
|
29
|
+
const total = arrays.reduce((n, a) => n + a.length, 0);
|
|
30
|
+
const out = new Uint8Array(total);
|
|
31
|
+
let offset = 0;
|
|
32
|
+
for (const a of arrays) {
|
|
33
|
+
out.set(a, offset);
|
|
34
|
+
offset += a.length;
|
|
35
|
+
}
|
|
36
|
+
return out;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// Box type constants
|
|
40
|
+
const MOOV = 0x6d6f6f76;
|
|
41
|
+
const TRAK = 0x7472616b;
|
|
42
|
+
const MDIA = 0x6d646961;
|
|
43
|
+
const MINF = 0x6d696e66;
|
|
44
|
+
const STBL = 0x7374626c;
|
|
45
|
+
const STSD = 0x73747364;
|
|
46
|
+
const HVC1 = 0x68766331;
|
|
47
|
+
const AVC1 = 0x61766331;
|
|
48
|
+
const AV01 = 0x61763031;
|
|
49
|
+
const DVCC = 0x64766343;
|
|
50
|
+
const DVVC = 0x64767643;
|
|
51
|
+
const DVWC = 0x64767743;
|
|
52
|
+
const FREE = 0x66726565;
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Build a minimal dvcC/dvvC/dvwC payload (5 bytes of fields + 19 reserved).
|
|
56
|
+
* Values are representative of a real Profile 8 / level 6 / HDR10-compat record.
|
|
57
|
+
*/
|
|
58
|
+
function buildDvBox(type: number): Uint8Array<ArrayBuffer> {
|
|
59
|
+
const payload = new Uint8Array(24);
|
|
60
|
+
const view = new DataView(payload.buffer);
|
|
61
|
+
payload[0] = 1; // dv_version_major
|
|
62
|
+
payload[1] = 0; // dv_version_minor
|
|
63
|
+
// dv_profile=8 (7 bits), dv_level=6 (6 bits), rpu=1, el=0, bl=1
|
|
64
|
+
// => 0b_0001000_000110_1_0_1 packed into 16 bits = 0x10_35
|
|
65
|
+
view.setUint16(2, 0x1035, false);
|
|
66
|
+
// dv_bl_signal_compatibility_id=1 (HDR10) in top 4 bits => 0x10
|
|
67
|
+
payload[4] = 0x10;
|
|
68
|
+
// bytes 5–23: reserved zeros (already zero)
|
|
69
|
+
return buildBox(type, payload);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Build a minimal stsd FullBox wrapping a codec box that contains a DV config box.
|
|
74
|
+
* stsd FullBox header: version(1) + flags(3) + entry_count(4) = 8 bytes before children.
|
|
75
|
+
*/
|
|
76
|
+
function buildStsd(codecType: number, dvBoxType: number): Uint8Array<ArrayBuffer> {
|
|
77
|
+
const dvBox = buildDvBox(dvBoxType);
|
|
78
|
+
// A real codec box has extra fields before its children, but for our purposes
|
|
79
|
+
// the parser only cares about finding the dv child box inside it.
|
|
80
|
+
// We add 8 bytes of dummy codec-box fields (e.g. reserved + data-ref-index).
|
|
81
|
+
const codecPayload = concat(new Uint8Array(8), dvBox);
|
|
82
|
+
const codecBox = buildBox(codecType, codecPayload);
|
|
83
|
+
// stsd FullBox header: 4 bytes (version+flags) + 4 bytes (entry_count=1)
|
|
84
|
+
const stsdHeader = new Uint8Array(8);
|
|
85
|
+
new DataView(stsdHeader.buffer).setUint32(4, 1, false); // entry_count = 1
|
|
86
|
+
const stsdPayload = concat(stsdHeader, codecBox);
|
|
87
|
+
return buildBox(STSD, stsdPayload);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Wrap an stsd box in the full stbl > minf > mdia > trak chain.
|
|
92
|
+
*/
|
|
93
|
+
function buildTrakFromStsd(stsd: Uint8Array<ArrayBuffer>): Uint8Array<ArrayBuffer> {
|
|
94
|
+
const stbl = buildBox(STBL, stsd);
|
|
95
|
+
const minf = buildBox(MINF, stbl);
|
|
96
|
+
const mdia = buildBox(MDIA, minf);
|
|
97
|
+
return buildBox(TRAK, mdia);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* Wrap a trak (or multiple traks) in a moov box.
|
|
102
|
+
*/
|
|
103
|
+
function buildMoov(...traks: Array<Uint8Array<ArrayBuffer>>): Uint8Array<ArrayBuffer> {
|
|
104
|
+
return buildBox(MOOV, concat(...traks));
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* Find the byte offset of a box type within a buffer using a flat byte-by-byte
|
|
109
|
+
* scan. This finds boxes at any nesting depth.
|
|
110
|
+
* Returns -1 if not found.
|
|
111
|
+
*/
|
|
112
|
+
function findBoxOffset(buf: Uint8Array, type: number): number {
|
|
113
|
+
for (let i = 0; i + 8 <= buf.length; i++) {
|
|
114
|
+
const t = new DataView(buf.buffer, buf.byteOffset + i + 4, 4).getUint32(0, false);
|
|
115
|
+
if (t === type) {
|
|
116
|
+
return i;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
return -1;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
describe("removeDolbyVisionConfigData", () => {
|
|
123
|
+
describe("when there is no moov box", () => {
|
|
124
|
+
it("does nothing and does not throw", () => {
|
|
125
|
+
const data = buildBox(0x66726565 /* free */, new Uint8Array(16));
|
|
126
|
+
const before = data.slice();
|
|
127
|
+
removeDolbyVisionConfigData(data);
|
|
128
|
+
expect(data).toEqual(before);
|
|
129
|
+
});
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
describe("when moov has no trak", () => {
|
|
133
|
+
it("does nothing and does not throw", () => {
|
|
134
|
+
const data = buildMoov(buildBox(0x75647461 /* udta */, new Uint8Array(4)));
|
|
135
|
+
const before = data.slice();
|
|
136
|
+
removeDolbyVisionConfigData(data);
|
|
137
|
+
expect(data).toEqual(before);
|
|
138
|
+
});
|
|
139
|
+
});
|
|
140
|
+
|
|
141
|
+
describe("when trak has no dvcC/dvvC/dvwC", () => {
|
|
142
|
+
it("leaves all box types untouched", () => {
|
|
143
|
+
const stsd = buildStsd(HVC1, 0x68766343 /* hvcC — not a DV box */);
|
|
144
|
+
const data = buildMoov(buildTrakFromStsd(stsd));
|
|
145
|
+
const before = data.slice();
|
|
146
|
+
removeDolbyVisionConfigData(data);
|
|
147
|
+
expect(data).toEqual(before);
|
|
148
|
+
});
|
|
149
|
+
});
|
|
150
|
+
|
|
151
|
+
describe("dvcC replacement", () => {
|
|
152
|
+
it("replaces dvcC type bytes with 'free'", () => {
|
|
153
|
+
const stsd = buildStsd(HVC1, DVCC);
|
|
154
|
+
const data = buildMoov(buildTrakFromStsd(stsd));
|
|
155
|
+
|
|
156
|
+
removeDolbyVisionConfigData(data);
|
|
157
|
+
|
|
158
|
+
const dvOffset = findBoxOffset(data, DVCC);
|
|
159
|
+
expect(dvOffset).toBe(-1); // no longer found as dvcC
|
|
160
|
+
|
|
161
|
+
// The box that was dvcC should now read as `free`
|
|
162
|
+
const freeOffset = findBoxOffset(data, FREE);
|
|
163
|
+
expect(freeOffset).toBeGreaterThan(-1);
|
|
164
|
+
});
|
|
165
|
+
|
|
166
|
+
it("preserves the box size field", () => {
|
|
167
|
+
const stsd = buildStsd(HVC1, DVCC);
|
|
168
|
+
const data = buildMoov(buildTrakFromStsd(stsd));
|
|
169
|
+
const dvOffset = findBoxOffset(data, DVCC);
|
|
170
|
+
const sizeBefore = new DataView(
|
|
171
|
+
data.buffer,
|
|
172
|
+
data.byteOffset + dvOffset,
|
|
173
|
+
4,
|
|
174
|
+
).getUint32(0, false);
|
|
175
|
+
|
|
176
|
+
removeDolbyVisionConfigData(data);
|
|
177
|
+
|
|
178
|
+
// find the free box at the same position
|
|
179
|
+
const sizeAfter = new DataView(
|
|
180
|
+
data.buffer,
|
|
181
|
+
data.byteOffset + dvOffset,
|
|
182
|
+
4,
|
|
183
|
+
).getUint32(0, false);
|
|
184
|
+
expect(sizeAfter).toBe(sizeBefore);
|
|
185
|
+
});
|
|
186
|
+
|
|
187
|
+
it("preserves the payload bytes after replacing the type", () => {
|
|
188
|
+
const stsd = buildStsd(HVC1, DVCC);
|
|
189
|
+
const data = buildMoov(buildTrakFromStsd(stsd));
|
|
190
|
+
const dvOffset = findBoxOffset(data, DVCC);
|
|
191
|
+
const payloadBefore = data.slice(dvOffset + 8);
|
|
192
|
+
|
|
193
|
+
removeDolbyVisionConfigData(data);
|
|
194
|
+
|
|
195
|
+
const payloadAfter = data.slice(dvOffset + 8);
|
|
196
|
+
expect(payloadAfter).toEqual(payloadBefore);
|
|
197
|
+
});
|
|
198
|
+
});
|
|
199
|
+
|
|
200
|
+
describe("dvvC replacement", () => {
|
|
201
|
+
it("replaces dvvC type bytes with 'free'", () => {
|
|
202
|
+
const stsd = buildStsd(HVC1, DVVC);
|
|
203
|
+
const data = buildMoov(buildTrakFromStsd(stsd));
|
|
204
|
+
|
|
205
|
+
removeDolbyVisionConfigData(data);
|
|
206
|
+
|
|
207
|
+
expect(findBoxOffset(data, DVVC)).toBe(-1);
|
|
208
|
+
expect(findBoxOffset(data, FREE)).toBeGreaterThan(-1);
|
|
209
|
+
});
|
|
210
|
+
});
|
|
211
|
+
|
|
212
|
+
describe("dvwC replacement", () => {
|
|
213
|
+
it("replaces dvwC type bytes with 'free' (AV1 base layer)", () => {
|
|
214
|
+
const stsd = buildStsd(AV01, DVWC);
|
|
215
|
+
const data = buildMoov(buildTrakFromStsd(stsd));
|
|
216
|
+
|
|
217
|
+
removeDolbyVisionConfigData(data);
|
|
218
|
+
|
|
219
|
+
expect(findBoxOffset(data, DVWC)).toBe(-1);
|
|
220
|
+
expect(findBoxOffset(data, FREE)).toBeGreaterThan(-1);
|
|
221
|
+
});
|
|
222
|
+
});
|
|
223
|
+
|
|
224
|
+
describe("multiple trak boxes", () => {
|
|
225
|
+
it("replaces dvcC in all trak boxes", () => {
|
|
226
|
+
const stsd1 = buildStsd(HVC1, DVCC);
|
|
227
|
+
const stsd2 = buildStsd(AVC1, DVCC);
|
|
228
|
+
const data = buildMoov(buildTrakFromStsd(stsd1), buildTrakFromStsd(stsd2));
|
|
229
|
+
|
|
230
|
+
removeDolbyVisionConfigData(data);
|
|
231
|
+
|
|
232
|
+
// No dvcC should remain anywhere in the buffer
|
|
233
|
+
expect(findBoxOffset(data, DVCC)).toBe(-1);
|
|
234
|
+
});
|
|
235
|
+
|
|
236
|
+
it("only touches the DV track and leaves a non-DV trak intact", () => {
|
|
237
|
+
const stsdWithDv = buildStsd(HVC1, DVCC);
|
|
238
|
+
const stsdWithoutDv = buildStsd(AVC1, 0x61766343 /* avcC */);
|
|
239
|
+
const data = buildMoov(
|
|
240
|
+
buildTrakFromStsd(stsdWithDv),
|
|
241
|
+
buildTrakFromStsd(stsdWithoutDv),
|
|
242
|
+
);
|
|
243
|
+
const before = data.slice();
|
|
244
|
+
|
|
245
|
+
removeDolbyVisionConfigData(data);
|
|
246
|
+
|
|
247
|
+
// The avcC box should be completely untouched
|
|
248
|
+
const avcCOffset = findBoxOffset(data, 0x61766343);
|
|
249
|
+
const avcCOffsetBefore = findBoxOffset(before, 0x61766343);
|
|
250
|
+
expect(avcCOffset).toBe(avcCOffsetBefore);
|
|
251
|
+
});
|
|
252
|
+
});
|
|
253
|
+
|
|
254
|
+
describe("mixed dvcC and dvvC in the same segment", () => {
|
|
255
|
+
it("replaces both", () => {
|
|
256
|
+
const stsd1 = buildStsd(HVC1, DVCC);
|
|
257
|
+
const stsd2 = buildStsd(HVC1, DVVC);
|
|
258
|
+
const data = buildMoov(buildTrakFromStsd(stsd1), buildTrakFromStsd(stsd2));
|
|
259
|
+
|
|
260
|
+
removeDolbyVisionConfigData(data);
|
|
261
|
+
|
|
262
|
+
expect(findBoxOffset(data, DVCC)).toBe(-1);
|
|
263
|
+
expect(findBoxOffset(data, DVVC)).toBe(-1);
|
|
264
|
+
});
|
|
265
|
+
});
|
|
266
|
+
|
|
267
|
+
describe("empty segment", () => {
|
|
268
|
+
it("does not throw on an empty buffer", () => {
|
|
269
|
+
const data = new Uint8Array(0);
|
|
270
|
+
expect(() => removeDolbyVisionConfigData(data)).not.toThrow();
|
|
271
|
+
});
|
|
272
|
+
});
|
|
273
|
+
|
|
274
|
+
describe("truncated box", () => {
|
|
275
|
+
it("does not throw on a truncated moov", () => {
|
|
276
|
+
const full = buildMoov(buildTrakFromStsd(buildStsd(HVC1, DVCC)));
|
|
277
|
+
// Truncate to just the moov header — incomplete content
|
|
278
|
+
const truncated = full.slice(0, 10);
|
|
279
|
+
expect(() => removeDolbyVisionConfigData(truncated)).not.toThrow();
|
|
280
|
+
});
|
|
281
|
+
});
|
|
282
|
+
});
|
|
@@ -222,6 +222,22 @@ function getUuidContent<T extends ArrayBufferLike>(
|
|
|
222
222
|
}
|
|
223
223
|
}
|
|
224
224
|
|
|
225
|
+
/**
|
|
226
|
+
* When parsed, the "box type", which announce the name of the box, are in the
|
|
227
|
+
* RxPlayer encoded as unsigned 32 bit integers.
|
|
228
|
+
*
|
|
229
|
+
* When debugging or in logs, the textual fourCC format (e.g. `moov`, `mdat`,
|
|
230
|
+
* `pssh` etc.) is much more readable. Thus this function allows to convert
|
|
231
|
+
* between the two.
|
|
232
|
+
* @param {number} n - The box type as a "number" (32 bit unsigned integer).
|
|
233
|
+
* @returns {string} - its fourCC ASCII correspondance
|
|
234
|
+
*/
|
|
235
|
+
function boxTypeToFourCC(n: number): string {
|
|
236
|
+
return [(n >>> 24) & 0xff, (n >>> 16) & 0xff, (n >>> 8) & 0xff, n & 0xff]
|
|
237
|
+
.map((b) => String.fromCharCode(b))
|
|
238
|
+
.join("");
|
|
239
|
+
}
|
|
240
|
+
|
|
225
241
|
/**
|
|
226
242
|
* For the next encountered box, return byte offsets corresponding to:
|
|
227
243
|
* 1. the starting byte offset for the next box (should always be equal to
|
|
@@ -277,6 +293,7 @@ function getNextBoxOffsets(
|
|
|
277
293
|
}
|
|
278
294
|
|
|
279
295
|
export {
|
|
296
|
+
boxTypeToFourCC,
|
|
280
297
|
getBox,
|
|
281
298
|
getBoxContent,
|
|
282
299
|
getBoxesContent,
|
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
|
|
17
17
|
import extractCompleteChunks, { extractInitSegment } from "./extract_complete_chunks";
|
|
18
18
|
import findCompleteBox from "./find_complete_box";
|
|
19
|
+
import removeDolbyVisionConfigData from "./remove_dolby_vision_config_data";
|
|
19
20
|
import takePSSHOut, { getPsshSystemID } from "./take_pssh_out";
|
|
20
21
|
|
|
21
22
|
export { extractInitSegment };
|
|
@@ -38,4 +39,10 @@ export {
|
|
|
38
39
|
patchPssh,
|
|
39
40
|
updateBoxLength,
|
|
40
41
|
} from "./utils";
|
|
41
|
-
export {
|
|
42
|
+
export {
|
|
43
|
+
extractCompleteChunks,
|
|
44
|
+
findCompleteBox,
|
|
45
|
+
getPsshSystemID,
|
|
46
|
+
removeDolbyVisionConfigData,
|
|
47
|
+
takePSSHOut,
|
|
48
|
+
};
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
import log from "../../../log";
|
|
2
|
+
import { be4toi } from "../../../utils/byte_parsing";
|
|
3
|
+
import { boxTypeToFourCC, getBoxContent, getBoxOffsets } from "./get_box";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Replace every dvcC/dvvC/dvwC box in an ISOBMFF segment with FREE boxes.
|
|
7
|
+
* Useful to strip Dolby Vision configuration when the decoder cannot handle it.
|
|
8
|
+
*
|
|
9
|
+
* Unlike PSSH (which sits directly under `moov`), DV config boxes are nested
|
|
10
|
+
* deep inside each track: moov > trak > mdia > minf > stbl > stsd > <codec> > dvcC|dvvC|dvwC
|
|
11
|
+
* There may be multiple `trak` boxes, so we walk all of them.
|
|
12
|
+
*
|
|
13
|
+
* @param {Uint8Array} data - the ISOBMFF segment
|
|
14
|
+
* @returns {void}
|
|
15
|
+
*/
|
|
16
|
+
export default function removeDolbyVisionConfigData(data: Uint8Array<ArrayBuffer>): void {
|
|
17
|
+
const moov = getBoxContent(data, 0x6d6f6f76 /* moov */);
|
|
18
|
+
if (moov === null) {
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
// Walk every trak box inside moov
|
|
23
|
+
let trakStart = 0;
|
|
24
|
+
while (trakStart < moov.length) {
|
|
25
|
+
let trakOffsets;
|
|
26
|
+
try {
|
|
27
|
+
trakOffsets = getBoxOffsets(moov.subarray(trakStart), 0x7472616b /* trak */);
|
|
28
|
+
} catch (e) {
|
|
29
|
+
const err = e instanceof Error ? e : "";
|
|
30
|
+
log.warn("isobmff", "Error while iterating trak boxes in ISOBMFF", err);
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
if (trakOffsets === null) {
|
|
34
|
+
break;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const trak = getBoxContent(moov.subarray(trakStart), 0x7472616b /* trak */);
|
|
38
|
+
if (trak !== null) {
|
|
39
|
+
removeDvcCFromTrak(trak);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
// Advance past this trak box to find the next one
|
|
43
|
+
trakStart += trakOffsets[2];
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Walk the stsd box inside a trak and replace any dvcC/dvvC/dvwC boxes
|
|
49
|
+
* with free boxes.
|
|
50
|
+
* @param {Uint8Array} trak - content of a trak box
|
|
51
|
+
*/
|
|
52
|
+
function removeDvcCFromTrak(trak: Uint8Array<ArrayBuffer>): void {
|
|
53
|
+
const DV_BOX_TYPES = [
|
|
54
|
+
0x64766343 /* dvcC */, 0x64767643 /* dvvC */, 0x64767743 /* dvwC */,
|
|
55
|
+
];
|
|
56
|
+
|
|
57
|
+
// Descend: trak > mdia > minf > stbl > stsd
|
|
58
|
+
const mdia = getBoxContent(trak, 0x6d646961 /* mdia */);
|
|
59
|
+
if (mdia === null) {
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
const minf = getBoxContent(mdia, 0x6d696e66 /* minf */);
|
|
63
|
+
if (minf === null) {
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
const stbl = getBoxContent(minf, 0x7374626c /* stbl */);
|
|
67
|
+
if (stbl === null) {
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
const stsd = getBoxContent(stbl, 0x73747364 /* stsd */);
|
|
71
|
+
if (stsd === null) {
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
const stsdChildren = stsd.subarray(8);
|
|
76
|
+
|
|
77
|
+
// Each codec box (avc1, hvc1, av01 …) may contain a dvcC/dvvC/dvwC child.
|
|
78
|
+
let codecStart = 0;
|
|
79
|
+
while (codecStart < stsdChildren.length) {
|
|
80
|
+
if (codecStart + 8 > stsdChildren.length) {
|
|
81
|
+
break;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
const codecBoxSize = be4toi(stsdChildren, codecStart);
|
|
85
|
+
const codecBoxType = be4toi(stsdChildren, codecStart + 4);
|
|
86
|
+
|
|
87
|
+
if (codecBoxSize < 8 || codecStart + codecBoxSize > stsdChildren.length) {
|
|
88
|
+
break;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
// The codec box is a VisualSampleEntry (or a wrapper like encv/enca).
|
|
92
|
+
// Its layout is: size(4)+type(4)+reserved(6)+data_ref_idx(2) = 16 bytes,
|
|
93
|
+
// then codec-specific fixed fields before child boxes begin.
|
|
94
|
+
// We scan forward from offset 16 (past the mandatory SampleEntry header)
|
|
95
|
+
// looking for the first plausible box boundary, then walk child boxes from
|
|
96
|
+
// there.
|
|
97
|
+
const codecBox = stsdChildren.subarray(codecStart, codecStart + codecBoxSize);
|
|
98
|
+
|
|
99
|
+
// Find where children start: scan from offset 16 for a size+fourcc that
|
|
100
|
+
// fits entirely within the box.
|
|
101
|
+
const childrenStart = findNextChildrenStartOffset(codecBox);
|
|
102
|
+
if (childrenStart === null) {
|
|
103
|
+
codecStart += codecBoxSize;
|
|
104
|
+
continue;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
const codecChildren = codecBox.subarray(childrenStart);
|
|
108
|
+
|
|
109
|
+
// Now search for and erase DV boxes
|
|
110
|
+
for (const dvBoxType of DV_BOX_TYPES) {
|
|
111
|
+
let dvStart = 0;
|
|
112
|
+
while (dvStart < codecChildren.length) {
|
|
113
|
+
let dvOffsets;
|
|
114
|
+
try {
|
|
115
|
+
dvOffsets = getBoxOffsets(codecChildren.subarray(dvStart), dvBoxType);
|
|
116
|
+
} catch (e) {
|
|
117
|
+
const err = e instanceof Error ? e : "";
|
|
118
|
+
log.warn(
|
|
119
|
+
"isobmff",
|
|
120
|
+
"Error while patching out dvcC/dvvC/dvwC from ISOBMFF",
|
|
121
|
+
err,
|
|
122
|
+
);
|
|
123
|
+
break;
|
|
124
|
+
}
|
|
125
|
+
if (dvOffsets === null) {
|
|
126
|
+
break;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
if (log.hasLevel("DEBUG")) {
|
|
130
|
+
log.debug(
|
|
131
|
+
"isobmff",
|
|
132
|
+
`Found '${boxTypeToFourCC(dvBoxType)}' inside '${boxTypeToFourCC(codecBoxType)}', overwriting with 'free'`,
|
|
133
|
+
);
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
// Overwrite the 4-byte box type with `free` (0x66726565)
|
|
137
|
+
const typeByteOffset = dvStart + dvOffsets[0] + 4;
|
|
138
|
+
codecChildren[typeByteOffset] = 0x66; /* f */
|
|
139
|
+
codecChildren[typeByteOffset + 1] = 0x72; /* r */
|
|
140
|
+
codecChildren[typeByteOffset + 2] = 0x65; /* e */
|
|
141
|
+
codecChildren[typeByteOffset + 3] = 0x65; /* e */
|
|
142
|
+
|
|
143
|
+
// Advance past this box (size of box relative to the current slice)
|
|
144
|
+
dvStart += dvOffsets[2] - dvOffsets[0];
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
codecStart += codecBoxSize;
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
/**
|
|
153
|
+
* Scan a codec box (VisualSampleEntry or wrapper) to find the byte offset
|
|
154
|
+
* where child boxes begin. We skip the mandatory SampleEntry header (16 bytes)
|
|
155
|
+
* and then look for the first offset whose size+type looks like a valid box
|
|
156
|
+
* that fits within the parent.
|
|
157
|
+
*/
|
|
158
|
+
function findNextChildrenStartOffset(box: Uint8Array): number | null {
|
|
159
|
+
// SampleEntry header: size(4)+type(4)+reserved(6)+data_ref_idx(2) = 16 bytes minimum.
|
|
160
|
+
// Children can only start after that.
|
|
161
|
+
for (let off = 16; off + 8 <= box.length; off++) {
|
|
162
|
+
const size = be4toi(box, off);
|
|
163
|
+
if (size < 8 || off + size > box.length) {
|
|
164
|
+
continue;
|
|
165
|
+
}
|
|
166
|
+
// Check that the four-byte type is all printable ASCII as a sanity check.
|
|
167
|
+
let allPrint = true;
|
|
168
|
+
for (let i = off + 4; i < off + 8; i++) {
|
|
169
|
+
if (box[i] < 0x20 || box[i] > 0x7e) {
|
|
170
|
+
allPrint = false;
|
|
171
|
+
break;
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
if (allPrint) {
|
|
175
|
+
return off;
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
return null;
|
|
179
|
+
}
|
|
@@ -1,48 +1,42 @@
|
|
|
1
|
-
import { describe, beforeEach, it, expect, vi } from "vitest";
|
|
2
|
-
import
|
|
1
|
+
import { describe, beforeEach, it, expect, vi, afterEach } from "vitest";
|
|
2
|
+
import log from "../../../../../log";
|
|
3
|
+
import getClockOffset from "../get_clock_offset";
|
|
4
|
+
|
|
5
|
+
const logWarn = vi.spyOn(log, "warn").mockImplementation(() => {
|
|
6
|
+
/* noop */
|
|
7
|
+
});
|
|
3
8
|
|
|
4
9
|
describe("DASH Parser - getClockOffset", () => {
|
|
5
10
|
beforeEach(() => {
|
|
6
11
|
vi.resetModules();
|
|
7
12
|
});
|
|
13
|
+
afterEach(() => {
|
|
14
|
+
logWarn.mockClear();
|
|
15
|
+
});
|
|
8
16
|
|
|
9
|
-
it("should calculate a millisecond offset relatively to the monotonically-raising timestamp",
|
|
10
|
-
const mockWarn = vi.fn();
|
|
11
|
-
vi.doMock("../../../../../log", () => ({
|
|
12
|
-
default: { warn: mockWarn },
|
|
13
|
-
}));
|
|
14
|
-
|
|
15
|
-
const getClockOffset = (await vi.importActual("../get_clock_offset"))
|
|
16
|
-
.default as typeof IGetClockOffset;
|
|
17
|
+
it("should calculate a millisecond offset relatively to the monotonically-raising timestamp", () => {
|
|
17
18
|
const mockDate = vi
|
|
18
19
|
.spyOn(performance, "now")
|
|
19
20
|
.mockReturnValue(Date.parse("2019-03-24T13:00:00Z"));
|
|
20
21
|
|
|
21
22
|
expect(getClockOffset("2019-03-25T12:00:00Z")).toEqual(82800000);
|
|
22
|
-
expect(
|
|
23
|
+
expect(logWarn).not.toHaveBeenCalled();
|
|
23
24
|
mockDate.mockRestore();
|
|
24
25
|
});
|
|
25
26
|
|
|
26
|
-
it("should return undefined and warn if an invalid date is given",
|
|
27
|
-
const mockWarn = vi.fn();
|
|
28
|
-
vi.doMock("../../../../../log", () => ({
|
|
29
|
-
default: { warn: mockWarn },
|
|
30
|
-
}));
|
|
31
|
-
const getClockOffset = (await vi.importActual("../get_clock_offset"))
|
|
32
|
-
.default as typeof IGetClockOffset;
|
|
33
|
-
|
|
27
|
+
it("should return undefined and warn if an invalid date is given", () => {
|
|
34
28
|
expect(getClockOffset("2018/412/13")).toEqual(undefined);
|
|
35
|
-
expect(
|
|
36
|
-
expect(
|
|
29
|
+
expect(logWarn).toHaveBeenCalledTimes(1);
|
|
30
|
+
expect(logWarn).toHaveBeenCalledWith("dash", "Invalid clock received", {
|
|
37
31
|
clock: "2018/412/13",
|
|
38
32
|
});
|
|
39
|
-
|
|
33
|
+
logWarn.mockReset();
|
|
40
34
|
|
|
41
35
|
expect(getClockOffset("foo")).toEqual(undefined);
|
|
42
|
-
expect(
|
|
43
|
-
expect(
|
|
36
|
+
expect(logWarn).toHaveBeenCalledTimes(1);
|
|
37
|
+
expect(logWarn).toHaveBeenCalledWith("dash", "Invalid clock received", {
|
|
44
38
|
clock: "foo",
|
|
45
39
|
});
|
|
46
|
-
|
|
40
|
+
logWarn.mockReset();
|
|
47
41
|
});
|
|
48
42
|
});
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { describe, beforeEach, it, expect, vi } from "vitest";
|
|
2
2
|
import type { IMPDIntermediateRepresentation } from "../../node_parser_types";
|
|
3
|
-
import
|
|
3
|
+
import getHTTPUTCTimingURL from "../get_http_utc-timing_url";
|
|
4
4
|
|
|
5
5
|
describe("DASH Parser - getHTTPUTCTimingURL", () => {
|
|
6
6
|
beforeEach(() => {
|
|
7
7
|
vi.resetModules();
|
|
8
8
|
});
|
|
9
9
|
|
|
10
|
-
it("should return undefined if the given intermediate representation has no UTCTimings element",
|
|
10
|
+
it("should return undefined if the given intermediate representation has no UTCTimings element", () => {
|
|
11
11
|
const mpdIR: IMPDIntermediateRepresentation = {
|
|
12
12
|
children: {
|
|
13
13
|
baseURLs: [],
|
|
@@ -17,12 +17,10 @@ describe("DASH Parser - getHTTPUTCTimingURL", () => {
|
|
|
17
17
|
},
|
|
18
18
|
attributes: {},
|
|
19
19
|
};
|
|
20
|
-
const getHTTPUTCTimingURL = (await vi.importActual("../get_http_utc-timing_url"))
|
|
21
|
-
.default as typeof IGetHTTPUTCTimingURL;
|
|
22
20
|
expect(getHTTPUTCTimingURL(mpdIR)).toEqual(undefined);
|
|
23
21
|
});
|
|
24
22
|
|
|
25
|
-
it("should return undefined if the given intermediate representation has no http-iso UTCTimings element",
|
|
23
|
+
it("should return undefined if the given intermediate representation has no http-iso UTCTimings element", () => {
|
|
26
24
|
const mpdIR: IMPDIntermediateRepresentation = {
|
|
27
25
|
children: {
|
|
28
26
|
baseURLs: [],
|
|
@@ -41,12 +39,10 @@ describe("DASH Parser - getHTTPUTCTimingURL", () => {
|
|
|
41
39
|
},
|
|
42
40
|
attributes: {},
|
|
43
41
|
};
|
|
44
|
-
const getHTTPUTCTimingURL = (await vi.importActual("../get_http_utc-timing_url"))
|
|
45
|
-
.default as typeof IGetHTTPUTCTimingURL;
|
|
46
42
|
expect(getHTTPUTCTimingURL(mpdIR)).toEqual(undefined);
|
|
47
43
|
});
|
|
48
44
|
|
|
49
|
-
it("should return undefined if the given intermediate representation has no value for its http-iso UTCTimings element",
|
|
45
|
+
it("should return undefined if the given intermediate representation has no value for its http-iso UTCTimings element", () => {
|
|
50
46
|
const mpdIR: IMPDIntermediateRepresentation = {
|
|
51
47
|
children: {
|
|
52
48
|
baseURLs: [],
|
|
@@ -67,12 +63,10 @@ describe("DASH Parser - getHTTPUTCTimingURL", () => {
|
|
|
67
63
|
},
|
|
68
64
|
attributes: {},
|
|
69
65
|
};
|
|
70
|
-
const getHTTPUTCTimingURL = (await vi.importActual("../get_http_utc-timing_url"))
|
|
71
|
-
.default as typeof IGetHTTPUTCTimingURL;
|
|
72
66
|
expect(getHTTPUTCTimingURL(mpdIR)).toEqual(undefined);
|
|
73
67
|
});
|
|
74
68
|
|
|
75
|
-
it("should return the value of a single http-iso UTCTimings element",
|
|
69
|
+
it("should return the value of a single http-iso UTCTimings element", () => {
|
|
76
70
|
const mpdIR: IMPDIntermediateRepresentation = {
|
|
77
71
|
children: {
|
|
78
72
|
baseURLs: [],
|
|
@@ -87,12 +81,10 @@ describe("DASH Parser - getHTTPUTCTimingURL", () => {
|
|
|
87
81
|
},
|
|
88
82
|
attributes: {},
|
|
89
83
|
};
|
|
90
|
-
const getHTTPUTCTimingURL = (await vi.importActual("../get_http_utc-timing_url"))
|
|
91
|
-
.default as typeof IGetHTTPUTCTimingURL;
|
|
92
84
|
expect(getHTTPUTCTimingURL(mpdIR)).toEqual("foobar2000");
|
|
93
85
|
});
|
|
94
86
|
|
|
95
|
-
it("should return the first value of multiple http-iso UTCTimings elements",
|
|
87
|
+
it("should return the first value of multiple http-iso UTCTimings elements", () => {
|
|
96
88
|
const mpdIR: IMPDIntermediateRepresentation = {
|
|
97
89
|
children: {
|
|
98
90
|
baseURLs: [],
|
|
@@ -115,12 +107,10 @@ describe("DASH Parser - getHTTPUTCTimingURL", () => {
|
|
|
115
107
|
},
|
|
116
108
|
attributes: {},
|
|
117
109
|
};
|
|
118
|
-
const getHTTPUTCTimingURL = (await vi.importActual("../get_http_utc-timing_url"))
|
|
119
|
-
.default as typeof IGetHTTPUTCTimingURL;
|
|
120
110
|
expect(getHTTPUTCTimingURL(mpdIR)).toEqual("foobar1000");
|
|
121
111
|
});
|
|
122
112
|
|
|
123
|
-
it("should return the first value of a http-iso UTCTimings element when mixed with other elements",
|
|
113
|
+
it("should return the first value of a http-iso UTCTimings element when mixed with other elements", () => {
|
|
124
114
|
const mpdIR: IMPDIntermediateRepresentation = {
|
|
125
115
|
children: {
|
|
126
116
|
baseURLs: [],
|
|
@@ -151,8 +141,6 @@ describe("DASH Parser - getHTTPUTCTimingURL", () => {
|
|
|
151
141
|
},
|
|
152
142
|
attributes: {},
|
|
153
143
|
};
|
|
154
|
-
const getHTTPUTCTimingURL = (await vi.importActual("../get_http_utc-timing_url"))
|
|
155
|
-
.default as typeof IGetHTTPUTCTimingURL;
|
|
156
144
|
expect(getHTTPUTCTimingURL(mpdIR)).toEqual("foobar2000");
|
|
157
145
|
});
|
|
158
146
|
});
|