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,449 @@
|
|
|
1
|
+
import { describe, it, expect, vi, afterEach } from "vitest";
|
|
2
|
+
import assert from "../../../../utils/assert";
|
|
3
|
+
import { concat } from "../../../../utils/byte_parsing";
|
|
4
|
+
import {
|
|
5
|
+
boxTypeToFourCC,
|
|
6
|
+
getBox,
|
|
7
|
+
getBoxContent,
|
|
8
|
+
getBoxesContent,
|
|
9
|
+
getBoxOffsets,
|
|
10
|
+
getChildBox,
|
|
11
|
+
getNextBoxOffsets,
|
|
12
|
+
getUuidContent,
|
|
13
|
+
} from "../get_box";
|
|
14
|
+
|
|
15
|
+
const logWarn = vi.hoisted(() => vi.fn());
|
|
16
|
+
vi.mock("../../../../log", () => ({
|
|
17
|
+
default: { warn: logWarn, debug: vi.fn(), error: vi.fn(), info: vi.fn() },
|
|
18
|
+
}));
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Writes a 32-bit big-endian integer into `buf` at `offset`.
|
|
22
|
+
*/
|
|
23
|
+
function writeBe4(buf: Uint8Array, offset: number, value: number): void {
|
|
24
|
+
buf[offset] = (value >>> 24) & 0xff;
|
|
25
|
+
buf[offset + 1] = (value >>> 16) & 0xff;
|
|
26
|
+
buf[offset + 2] = (value >>> 8) & 0xff;
|
|
27
|
+
buf[offset + 3] = value & 0xff;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Writes a 64-bit big-endian integer (as two 32-bit halves) into `buf` at
|
|
32
|
+
* `offset`. Sufficient for box sizes well within the 32-bit range.
|
|
33
|
+
*/
|
|
34
|
+
function writeBe8(buf: Uint8Array, offset: number, hi: number, lo: number): void {
|
|
35
|
+
writeBe4(buf, offset, hi);
|
|
36
|
+
writeBe4(buf, offset + 4, lo);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/** Box name constants (big-endian ASCII) */
|
|
40
|
+
const MOOV = 0x6d6f6f76;
|
|
41
|
+
const MDAT = 0x6d646174;
|
|
42
|
+
const FTYP = 0x66747970;
|
|
43
|
+
const FREE = 0x66726565;
|
|
44
|
+
const UUID = 0x75756964;
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Builds a minimal ISOBMFF box:
|
|
48
|
+
* [4 bytes size][4 bytes name][...content]
|
|
49
|
+
*
|
|
50
|
+
* Total size = 8 + content.length
|
|
51
|
+
*/
|
|
52
|
+
function makeBox(name: number, content: Uint8Array = new Uint8Array(0)): Uint8Array {
|
|
53
|
+
const size = 8 + content.length;
|
|
54
|
+
const buf = new Uint8Array(size);
|
|
55
|
+
writeBe4(buf, 0, size);
|
|
56
|
+
writeBe4(buf, 4, name);
|
|
57
|
+
buf.set(content, 8);
|
|
58
|
+
return buf;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Builds an extended-size (size === 1) box:
|
|
63
|
+
* [4 bytes: 1][4 bytes name][8 bytes largeSize][...content]
|
|
64
|
+
*
|
|
65
|
+
* Total size = 16 + content.length
|
|
66
|
+
*/
|
|
67
|
+
function makeLargeBox(name: number, content: Uint8Array = new Uint8Array(0)): Uint8Array {
|
|
68
|
+
const totalSize = 16 + content.length;
|
|
69
|
+
const buf = new Uint8Array(totalSize);
|
|
70
|
+
writeBe4(buf, 0, 1); // size === 1 → extended
|
|
71
|
+
writeBe4(buf, 4, name);
|
|
72
|
+
writeBe8(buf, 8, 0, totalSize); // 64-bit size (fits in lower 32 bits)
|
|
73
|
+
buf.set(content, 16);
|
|
74
|
+
return buf;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Builds a uuid box:
|
|
79
|
+
* [4 bytes size][4 bytes "uuid"][16 bytes uuid][...content]
|
|
80
|
+
*/
|
|
81
|
+
function makeUuidBox(
|
|
82
|
+
id1: number,
|
|
83
|
+
id2: number,
|
|
84
|
+
id3: number,
|
|
85
|
+
id4: number,
|
|
86
|
+
content: Uint8Array = new Uint8Array(0),
|
|
87
|
+
): Uint8Array {
|
|
88
|
+
const size = 8 + 16 + content.length;
|
|
89
|
+
const buf = new Uint8Array(size);
|
|
90
|
+
writeBe4(buf, 0, size);
|
|
91
|
+
writeBe4(buf, 4, UUID);
|
|
92
|
+
writeBe4(buf, 8, id1);
|
|
93
|
+
writeBe4(buf, 12, id2);
|
|
94
|
+
writeBe4(buf, 16, id3);
|
|
95
|
+
writeBe4(buf, 20, id4);
|
|
96
|
+
buf.set(content, 24);
|
|
97
|
+
return buf;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
describe("isobmff - boxTypeToFourCC", () => {
|
|
101
|
+
afterEach(() => {
|
|
102
|
+
vi.resetAllMocks();
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
it("should convert 'moov' integer to its fourCC string", () => {
|
|
106
|
+
expect(boxTypeToFourCC(0x6d6f6f76)).toBe("moov");
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
it("should convert 'mdat' integer to its fourCC string", () => {
|
|
110
|
+
expect(boxTypeToFourCC(0x6d646174)).toBe("mdat");
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
it("should convert 'pssh' integer to its fourCC string", () => {
|
|
114
|
+
expect(boxTypeToFourCC(0x70737368)).toBe("pssh");
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
it("should correctly extract all four distinct bytes", () => {
|
|
118
|
+
// 'A'=0x41 'B'=0x42 'C'=0x43 'D'=0x44
|
|
119
|
+
expect(boxTypeToFourCC(0x41424344)).toBe("ABCD");
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
it("should return four identical characters when all bytes are the same", () => {
|
|
123
|
+
expect(boxTypeToFourCC(0x61616161)).toBe("aaaa");
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
it("should return four null characters for 0", () => {
|
|
127
|
+
expect(boxTypeToFourCC(0x00000000)).toBe("\0\0\0\0");
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
it("should handle the maximum 32-bit unsigned integer", () => {
|
|
131
|
+
expect(boxTypeToFourCC(0xffffffff)).toBe("\xff\xff\xff\xff");
|
|
132
|
+
});
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
describe("isobmff - getBoxOffsets", () => {
|
|
136
|
+
afterEach(() => {
|
|
137
|
+
vi.resetAllMocks();
|
|
138
|
+
});
|
|
139
|
+
|
|
140
|
+
it("should return null when the buffer is too small to hold any box header", () => {
|
|
141
|
+
expect(getBoxOffsets(new Uint8Array(7), MOOV)).toBeNull();
|
|
142
|
+
});
|
|
143
|
+
|
|
144
|
+
it("should return null when the box name does not match", () => {
|
|
145
|
+
const buf = makeBox(FTYP, new Uint8Array(4));
|
|
146
|
+
expect(getBoxOffsets(buf, MOOV)).toBeNull();
|
|
147
|
+
});
|
|
148
|
+
|
|
149
|
+
it("should find a simple box and return correct offsets", () => {
|
|
150
|
+
const content = new Uint8Array([1, 2, 3, 4]);
|
|
151
|
+
const buf = makeBox(MOOV, content);
|
|
152
|
+
// [0, 8, 12] → start=0, contentStart=8, end=12
|
|
153
|
+
expect(getBoxOffsets(buf, MOOV)).toEqual([0, 8, 12]);
|
|
154
|
+
});
|
|
155
|
+
|
|
156
|
+
it("should skip earlier boxes and find the requested one", () => {
|
|
157
|
+
const first = makeBox(FTYP, new Uint8Array(4));
|
|
158
|
+
const second = makeBox(MOOV, new Uint8Array(8));
|
|
159
|
+
const buf = concat(first, second);
|
|
160
|
+
const result = getBoxOffsets(buf, MOOV);
|
|
161
|
+
expect(result).not.toBeNull();
|
|
162
|
+
assert(result !== null); // For TypeScript
|
|
163
|
+
expect(result[0]).toBe(first.length);
|
|
164
|
+
expect(result[2]).toBe(buf.length);
|
|
165
|
+
});
|
|
166
|
+
|
|
167
|
+
it("should handle an extended-size (size === 1) box", () => {
|
|
168
|
+
const content = new Uint8Array([0xaa, 0xbb]);
|
|
169
|
+
const buf = makeLargeBox(MOOV, content);
|
|
170
|
+
// start=0, contentStart=16, end=18
|
|
171
|
+
expect(getBoxOffsets(buf, MOOV)).toEqual([0, 16, 18]);
|
|
172
|
+
});
|
|
173
|
+
|
|
174
|
+
it("should treat size === 0 as extending to the end of the buffer", () => {
|
|
175
|
+
const buf = makeBox(MOOV, new Uint8Array(4));
|
|
176
|
+
writeBe4(buf, 0, 0); // overwrite size with 0
|
|
177
|
+
const result = getBoxOffsets(buf, MOOV);
|
|
178
|
+
expect(result).not.toBeNull();
|
|
179
|
+
assert(result !== null); // For TypeScript
|
|
180
|
+
expect(result[2]).toBe(buf.length);
|
|
181
|
+
});
|
|
182
|
+
|
|
183
|
+
it("should return null when an extended-size header cannot fit in the buffer", () => {
|
|
184
|
+
// Write size=1 (extended) but only 12 bytes total — not enough for the 8-byte largeSize field
|
|
185
|
+
const buf = new Uint8Array(12);
|
|
186
|
+
writeBe4(buf, 0, 1);
|
|
187
|
+
writeBe4(buf, 4, MOOV);
|
|
188
|
+
expect(getBoxOffsets(buf, MOOV)).toBeNull();
|
|
189
|
+
});
|
|
190
|
+
|
|
191
|
+
it("should add 16 bytes to the content offset for a uuid box", () => {
|
|
192
|
+
const content = new Uint8Array(4);
|
|
193
|
+
const buf = makeUuidBox(0x01020304, 0x05060708, 0x090a0b0c, 0x0d0e0f10, content);
|
|
194
|
+
const result = getBoxOffsets(buf, UUID);
|
|
195
|
+
expect(result).not.toBeNull();
|
|
196
|
+
assert(result !== null); // For TypeScript
|
|
197
|
+
// uuid header: 8 (size+name) + 16 (uuid bytes) = content starts at 24
|
|
198
|
+
expect(result[1]).toBe(24);
|
|
199
|
+
});
|
|
200
|
+
});
|
|
201
|
+
|
|
202
|
+
describe("isobmff - getBoxContent", () => {
|
|
203
|
+
afterEach(() => {
|
|
204
|
+
vi.resetAllMocks();
|
|
205
|
+
});
|
|
206
|
+
|
|
207
|
+
it("should return null when the box is not present", () => {
|
|
208
|
+
const buf = makeBox(FTYP, new Uint8Array(4));
|
|
209
|
+
expect(getBoxContent(buf, MOOV)).toBeNull();
|
|
210
|
+
});
|
|
211
|
+
|
|
212
|
+
it("should return only the content bytes (excluding size and name)", () => {
|
|
213
|
+
const content = new Uint8Array([10, 20, 30]);
|
|
214
|
+
const buf = makeBox(MDAT, content);
|
|
215
|
+
const result = getBoxContent(buf, MDAT);
|
|
216
|
+
expect(result).not.toBeNull();
|
|
217
|
+
assert(result !== null); // For TypeScript
|
|
218
|
+
expect(Array.from(result)).toEqual([10, 20, 30]);
|
|
219
|
+
});
|
|
220
|
+
|
|
221
|
+
it("should return an empty Uint8Array for a box with no content", () => {
|
|
222
|
+
const buf = makeBox(FTYP);
|
|
223
|
+
const result = getBoxContent(buf, FTYP);
|
|
224
|
+
expect(result).not.toBeNull();
|
|
225
|
+
assert(result !== null); // For TypeScript
|
|
226
|
+
expect(result.length).toBe(0);
|
|
227
|
+
});
|
|
228
|
+
});
|
|
229
|
+
|
|
230
|
+
describe("isobmff - getBoxesContent", () => {
|
|
231
|
+
afterEach(() => {
|
|
232
|
+
vi.resetAllMocks();
|
|
233
|
+
});
|
|
234
|
+
|
|
235
|
+
it("should return an empty array when no matching box exists", () => {
|
|
236
|
+
const buf = makeBox(FTYP, new Uint8Array(4));
|
|
237
|
+
expect(getBoxesContent(buf, MOOV)).toEqual([]);
|
|
238
|
+
});
|
|
239
|
+
|
|
240
|
+
it("should return all occurrences of a repeated box, in order", () => {
|
|
241
|
+
const first = makeBox(FREE, new Uint8Array([1]));
|
|
242
|
+
const second = makeBox(FREE, new Uint8Array([2]));
|
|
243
|
+
const third = makeBox(FREE, new Uint8Array([3]));
|
|
244
|
+
const buf = concat(first, second, third);
|
|
245
|
+
const result = getBoxesContent(buf, FREE);
|
|
246
|
+
expect(result).toHaveLength(3);
|
|
247
|
+
expect(Array.from(result[0])).toEqual([1]);
|
|
248
|
+
expect(Array.from(result[1])).toEqual([2]);
|
|
249
|
+
expect(Array.from(result[2])).toEqual([3]);
|
|
250
|
+
});
|
|
251
|
+
|
|
252
|
+
it("should return only the matching boxes and skip others", () => {
|
|
253
|
+
const a = makeBox(FTYP, new Uint8Array([0xaa]));
|
|
254
|
+
const b = makeBox(FREE, new Uint8Array([0xbb]));
|
|
255
|
+
const c = makeBox(FTYP, new Uint8Array([0xcc]));
|
|
256
|
+
const buf = concat(a, b, c);
|
|
257
|
+
const result = getBoxesContent(buf, FTYP);
|
|
258
|
+
expect(result).toHaveLength(2);
|
|
259
|
+
expect(Array.from(result[0])).toEqual([0xaa]);
|
|
260
|
+
expect(Array.from(result[1])).toEqual([0xcc]);
|
|
261
|
+
});
|
|
262
|
+
});
|
|
263
|
+
|
|
264
|
+
describe("isobmff - getBox", () => {
|
|
265
|
+
afterEach(() => {
|
|
266
|
+
vi.resetAllMocks();
|
|
267
|
+
});
|
|
268
|
+
|
|
269
|
+
it("should return null when the box is not found", () => {
|
|
270
|
+
const buf = makeBox(FTYP, new Uint8Array(4));
|
|
271
|
+
expect(getBox(buf, MOOV)).toBeNull();
|
|
272
|
+
});
|
|
273
|
+
|
|
274
|
+
it("should return the full box bytes — size + name + content", () => {
|
|
275
|
+
const content = new Uint8Array([0xde, 0xad]);
|
|
276
|
+
const fullBox = makeBox(MDAT, content);
|
|
277
|
+
const result = getBox(fullBox, MDAT);
|
|
278
|
+
expect(result).not.toBeNull();
|
|
279
|
+
assert(result !== null); // For TypeScript
|
|
280
|
+
expect(Array.from(result)).toEqual(Array.from(fullBox));
|
|
281
|
+
});
|
|
282
|
+
|
|
283
|
+
it("should return only the matching box when preceded by another box", () => {
|
|
284
|
+
const before = makeBox(FTYP, new Uint8Array(4));
|
|
285
|
+
const target = makeBox(MOOV, new Uint8Array([0xff]));
|
|
286
|
+
const buf = concat(before, target);
|
|
287
|
+
const result = getBox(buf, MOOV);
|
|
288
|
+
expect(result).not.toBeNull();
|
|
289
|
+
assert(result !== null); // For TypeScript
|
|
290
|
+
expect(Array.from(result)).toEqual(Array.from(target));
|
|
291
|
+
});
|
|
292
|
+
});
|
|
293
|
+
|
|
294
|
+
describe("isobmff - getChildBox", () => {
|
|
295
|
+
afterEach(() => {
|
|
296
|
+
vi.resetAllMocks();
|
|
297
|
+
});
|
|
298
|
+
|
|
299
|
+
it("should return null when an empty childNames array is provided and the buffer is non-empty", () => {
|
|
300
|
+
// With no children to traverse, the loop never executes and currBox is
|
|
301
|
+
// returned as-is. Verify the returned reference equals the input.
|
|
302
|
+
const buf = makeBox(MOOV, new Uint8Array(4));
|
|
303
|
+
const result = getChildBox(buf, []);
|
|
304
|
+
assert(result !== null);
|
|
305
|
+
expect(Array.from(result)).toEqual(Array.from(buf));
|
|
306
|
+
});
|
|
307
|
+
|
|
308
|
+
it("should return null when the first child is not found", () => {
|
|
309
|
+
const buf = makeBox(FTYP, new Uint8Array(4));
|
|
310
|
+
expect(getChildBox(buf, [MOOV])).toBeNull();
|
|
311
|
+
});
|
|
312
|
+
|
|
313
|
+
it("should return null when an intermediate child is not found", () => {
|
|
314
|
+
// moov → ftyp exists, but moov → ftyp → mdat does not
|
|
315
|
+
const innerContent = makeBox(FTYP, new Uint8Array(2));
|
|
316
|
+
const outer = makeBox(MOOV, innerContent);
|
|
317
|
+
expect(getChildBox(outer, [MOOV, FTYP, MDAT])).toBeNull();
|
|
318
|
+
});
|
|
319
|
+
|
|
320
|
+
it("should traverse a chain of nested boxes and return the innermost content", () => {
|
|
321
|
+
const payload = new Uint8Array([0x42]);
|
|
322
|
+
const innermost = makeBox(MDAT, payload);
|
|
323
|
+
const middle = makeBox(FTYP, innermost);
|
|
324
|
+
const outer = makeBox(MOOV, middle);
|
|
325
|
+
const result = getChildBox(outer, [MOOV, FTYP, MDAT]);
|
|
326
|
+
expect(result).not.toBeNull();
|
|
327
|
+
assert(result !== null); // For TypeScript
|
|
328
|
+
expect(Array.from(result)).toEqual([0x42]);
|
|
329
|
+
});
|
|
330
|
+
});
|
|
331
|
+
|
|
332
|
+
describe("isobmff - getNextBoxOffsets", () => {
|
|
333
|
+
afterEach(() => {
|
|
334
|
+
vi.resetAllMocks();
|
|
335
|
+
});
|
|
336
|
+
|
|
337
|
+
it("should return null and warn when the buffer is shorter than 8 bytes", () => {
|
|
338
|
+
const result = getNextBoxOffsets(new Uint8Array(4));
|
|
339
|
+
expect(result).toBeNull();
|
|
340
|
+
expect(logWarn).toHaveBeenCalledOnce();
|
|
341
|
+
});
|
|
342
|
+
|
|
343
|
+
it("should return correct offsets for a simple box", () => {
|
|
344
|
+
const content = new Uint8Array([1, 2]);
|
|
345
|
+
const buf = makeBox(MOOV, content);
|
|
346
|
+
// start=0, contentStart=8, end=10
|
|
347
|
+
expect(getNextBoxOffsets(buf)).toEqual([0, 8, 10]);
|
|
348
|
+
});
|
|
349
|
+
|
|
350
|
+
it("should handle an extended-size box correctly", () => {
|
|
351
|
+
const content = new Uint8Array([0xab]);
|
|
352
|
+
const buf = makeLargeBox(FTYP, content);
|
|
353
|
+
expect(getNextBoxOffsets(buf)).toEqual([0, 16, 17]);
|
|
354
|
+
});
|
|
355
|
+
|
|
356
|
+
it("should treat size === 0 as extending to the end of the buffer", () => {
|
|
357
|
+
const buf = makeBox(MOOV, new Uint8Array(6));
|
|
358
|
+
writeBe4(buf, 0, 0);
|
|
359
|
+
const result = getNextBoxOffsets(buf);
|
|
360
|
+
expect(result).not.toBeNull();
|
|
361
|
+
assert(result !== null); // For TypeScript
|
|
362
|
+
expect(result[2]).toBe(buf.length);
|
|
363
|
+
});
|
|
364
|
+
|
|
365
|
+
it("should return null and warn when an extended-size header cannot fit in the buffer", () => {
|
|
366
|
+
const buf = new Uint8Array(12);
|
|
367
|
+
writeBe4(buf, 0, 1);
|
|
368
|
+
writeBe4(buf, 4, MOOV);
|
|
369
|
+
const result = getNextBoxOffsets(buf);
|
|
370
|
+
expect(result).toBeNull();
|
|
371
|
+
expect(logWarn).toHaveBeenCalledOnce();
|
|
372
|
+
});
|
|
373
|
+
|
|
374
|
+
it("should add 16 bytes to the content offset for a uuid box", () => {
|
|
375
|
+
const content = new Uint8Array(2);
|
|
376
|
+
const buf = makeUuidBox(0x01020304, 0x05060708, 0x090a0b0c, 0x0d0e0f10, content);
|
|
377
|
+
const result = getNextBoxOffsets(buf);
|
|
378
|
+
expect(result).not.toBeNull();
|
|
379
|
+
assert(result !== null); // For TypeScript
|
|
380
|
+
expect(result[1]).toBe(24);
|
|
381
|
+
});
|
|
382
|
+
|
|
383
|
+
it("should always return 0 as the first element (start byte)", () => {
|
|
384
|
+
const buf = makeBox(FREE, new Uint8Array(4));
|
|
385
|
+
const result = getNextBoxOffsets(buf);
|
|
386
|
+
assert(result !== null);
|
|
387
|
+
expect(result[0]).toBe(0);
|
|
388
|
+
});
|
|
389
|
+
});
|
|
390
|
+
|
|
391
|
+
describe("isobmff - getUuidContent", () => {
|
|
392
|
+
afterEach(() => {
|
|
393
|
+
vi.resetAllMocks();
|
|
394
|
+
});
|
|
395
|
+
|
|
396
|
+
const ID1 = 0x01020304;
|
|
397
|
+
const ID2 = 0x05060708;
|
|
398
|
+
const ID3 = 0x090a0b0c;
|
|
399
|
+
const ID4 = 0x0d0e0f10;
|
|
400
|
+
|
|
401
|
+
it("should return undefined when no uuid box is present", () => {
|
|
402
|
+
const buf = makeBox(MOOV, new Uint8Array(4));
|
|
403
|
+
expect(getUuidContent(buf, ID1, ID2, ID3, ID4)).toBeUndefined();
|
|
404
|
+
});
|
|
405
|
+
|
|
406
|
+
it("should return undefined when the uuid identifiers do not match", () => {
|
|
407
|
+
const buf = makeUuidBox(0xdeadbeef, ID2, ID3, ID4, new Uint8Array(2));
|
|
408
|
+
expect(getUuidContent(buf, ID1, ID2, ID3, ID4)).toBeUndefined();
|
|
409
|
+
});
|
|
410
|
+
|
|
411
|
+
it("should return the content bytes when the uuid matches exactly", () => {
|
|
412
|
+
const payload = new Uint8Array([0xca, 0xfe]);
|
|
413
|
+
const buf = makeUuidBox(ID1, ID2, ID3, ID4, payload);
|
|
414
|
+
const result = getUuidContent(buf, ID1, ID2, ID3, ID4);
|
|
415
|
+
expect(result).not.toBeUndefined();
|
|
416
|
+
assert(result !== undefined); // For TypeScript
|
|
417
|
+
expect(Array.from(result)).toEqual([0xca, 0xfe]);
|
|
418
|
+
});
|
|
419
|
+
|
|
420
|
+
it("should skip non-uuid boxes and find the matching uuid box", () => {
|
|
421
|
+
const payload = new Uint8Array([0xff]);
|
|
422
|
+
const nonUuid = makeBox(MOOV, new Uint8Array(4));
|
|
423
|
+
const uuidBox = makeUuidBox(ID1, ID2, ID3, ID4, payload);
|
|
424
|
+
const buf = concat(nonUuid, uuidBox);
|
|
425
|
+
const result = getUuidContent(buf, ID1, ID2, ID3, ID4);
|
|
426
|
+
expect(result).not.toBeUndefined();
|
|
427
|
+
assert(result !== undefined); // For TypeScript
|
|
428
|
+
expect(Array.from(result)).toEqual([0xff]);
|
|
429
|
+
});
|
|
430
|
+
|
|
431
|
+
it("should return undefined when uuid header is present but the 16-byte id cannot fit in the buffer", () => {
|
|
432
|
+
// Build a box that claims to be uuid but is too short to hold its 16-byte identifier
|
|
433
|
+
const buf = new Uint8Array(16);
|
|
434
|
+
writeBe4(buf, 0, 16);
|
|
435
|
+
writeBe4(buf, 4, UUID);
|
|
436
|
+
// Only 8 bytes remain — not enough for the full 16-byte uuid identifier
|
|
437
|
+
expect(getUuidContent(buf, ID1, ID2, ID3, ID4)).toBeUndefined();
|
|
438
|
+
});
|
|
439
|
+
|
|
440
|
+
it("should handle a size === 0 uuid box that extends to end of buffer", () => {
|
|
441
|
+
const payload = new Uint8Array([0x11, 0x22]);
|
|
442
|
+
const uuidBox = makeUuidBox(ID1, ID2, ID3, ID4, payload);
|
|
443
|
+
writeBe4(uuidBox, 0, 0); // size = 0 → extends to end
|
|
444
|
+
const result = getUuidContent(uuidBox, ID1, ID2, ID3, ID4);
|
|
445
|
+
expect(result).not.toBeUndefined();
|
|
446
|
+
assert(result !== undefined); // For TypeScript
|
|
447
|
+
expect(Array.from(result)).toEqual([0x11, 0x22]);
|
|
448
|
+
});
|
|
449
|
+
});
|