rx-player 4.2.0-dev.2024091000 → 4.2.0-dev.2024092400

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.
Files changed (149) hide show
  1. package/CHANGELOG.md +11 -2
  2. package/VERSION +1 -1
  3. package/dist/commonjs/__GENERATED_CODE/embedded_dash_wasm.d.ts.map +1 -1
  4. package/dist/commonjs/__GENERATED_CODE/embedded_dash_wasm.js +1 -1
  5. package/dist/commonjs/__GENERATED_CODE/embedded_worker.d.ts.map +1 -1
  6. package/dist/commonjs/__GENERATED_CODE/embedded_worker.js +1 -1
  7. package/dist/commonjs/compat/eme/close_session.js +2 -2
  8. package/dist/commonjs/compat/eme/load_session.js +2 -2
  9. package/dist/commonjs/compat/patch_webkit_source_buffer.d.ts.map +1 -1
  10. package/dist/commonjs/compat/patch_webkit_source_buffer.js +0 -3
  11. package/dist/commonjs/config.d.ts +7 -156
  12. package/dist/commonjs/config.d.ts.map +1 -1
  13. package/dist/commonjs/config.js +50 -3
  14. package/dist/commonjs/core/fetchers/manifest/manifest_fetcher.js +2 -2
  15. package/dist/commonjs/core/fetchers/segment/segment_fetcher.js +2 -2
  16. package/dist/commonjs/core/fetchers/utils/schedule_request.js +2 -2
  17. package/dist/commonjs/core/main/worker/worker_main.d.ts.map +1 -1
  18. package/dist/commonjs/core/main/worker/worker_main.js +4 -0
  19. package/dist/commonjs/core/segment_sinks/garbage_collector.js +2 -2
  20. package/dist/commonjs/core/segment_sinks/implementations/audio_video/audio_video_segment_buffer.js +2 -2
  21. package/dist/commonjs/core/segment_sinks/implementations/text/text_segment_buffer.js +2 -2
  22. package/dist/commonjs/core/stream/adaptation/adaptation_stream.d.ts.map +1 -1
  23. package/dist/commonjs/core/stream/adaptation/adaptation_stream.js +20 -9
  24. package/dist/commonjs/core/stream/adaptation/index.d.ts +1 -1
  25. package/dist/commonjs/core/stream/adaptation/index.d.ts.map +1 -1
  26. package/dist/commonjs/core/stream/adaptation/index.js +0 -15
  27. package/dist/commonjs/core/stream/orchestrator/stream_orchestrator.js +2 -2
  28. package/dist/commonjs/core/stream/period/index.d.ts +1 -1
  29. package/dist/commonjs/core/stream/period/index.d.ts.map +1 -1
  30. package/dist/commonjs/core/stream/period/index.js +0 -15
  31. package/dist/commonjs/core/stream/period/period_stream.js +2 -2
  32. package/dist/commonjs/core/stream/representation/index.d.ts +1 -1
  33. package/dist/commonjs/core/stream/representation/index.d.ts.map +1 -1
  34. package/dist/commonjs/core/stream/representation/index.js +0 -15
  35. package/dist/commonjs/core/stream/representation/utils/append_segment_to_buffer.d.ts.map +1 -1
  36. package/dist/commonjs/core/stream/representation/utils/append_segment_to_buffer.js +16 -11
  37. package/dist/commonjs/core/stream/representation/utils/push_init_segment.js +2 -2
  38. package/dist/commonjs/core/stream/representation/utils/push_media_segment.js +2 -2
  39. package/dist/commonjs/default_config.js +4 -0
  40. package/dist/commonjs/experimental/tools/VideoThumbnailLoader/video_thumbnail_loader.js +2 -2
  41. package/dist/commonjs/experimental/tools/createMetaplaylist/get_duration_from_manifest.js +2 -2
  42. package/dist/commonjs/main_thread/api/public_api.d.ts.map +1 -1
  43. package/dist/commonjs/main_thread/api/public_api.js +19 -4
  44. package/dist/commonjs/main_thread/decrypt/attach_media_keys.js +2 -2
  45. package/dist/commonjs/main_thread/decrypt/content_decryptor.d.ts.map +1 -1
  46. package/dist/commonjs/main_thread/decrypt/content_decryptor.js +4 -2
  47. package/dist/commonjs/main_thread/decrypt/create_or_load_session.js +2 -2
  48. package/dist/commonjs/main_thread/decrypt/create_session.js +2 -2
  49. package/dist/commonjs/main_thread/decrypt/dispose_decryption_resources.js +2 -2
  50. package/dist/commonjs/main_thread/decrypt/find_key_system.js +2 -2
  51. package/dist/commonjs/main_thread/decrypt/get_media_keys.d.ts.map +1 -1
  52. package/dist/commonjs/main_thread/decrypt/get_media_keys.js +3 -2
  53. package/dist/commonjs/main_thread/decrypt/init_media_keys.js +2 -2
  54. package/dist/commonjs/main_thread/decrypt/session_events_listener.js +2 -2
  55. package/dist/commonjs/main_thread/decrypt/set_server_certificate.js +2 -4
  56. package/dist/commonjs/main_thread/decrypt/utils/clean_old_loaded_sessions.js +2 -2
  57. package/dist/commonjs/main_thread/decrypt/utils/loaded_sessions_store.js +2 -2
  58. package/dist/commonjs/main_thread/init/media_source_content_initializer.js +2 -2
  59. package/dist/commonjs/main_thread/init/multi_thread_content_initializer.js +2 -2
  60. package/dist/commonjs/multithread_types.d.ts +8 -1
  61. package/dist/commonjs/multithread_types.d.ts.map +1 -1
  62. package/dist/commonjs/parsers/manifest/dash/wasm-parser/ts/dash-wasm-parser.js +2 -2
  63. package/dist/commonjs/parsers/manifest/dash/wasm-parser/ts/generators/AdaptationSet.d.ts.map +1 -1
  64. package/dist/commonjs/parsers/manifest/dash/wasm-parser/ts/generators/AdaptationSet.js +6 -5
  65. package/dist/commonjs/parsers/manifest/dash/wasm-parser/ts/generators/Label.d.ts +4 -0
  66. package/dist/commonjs/parsers/manifest/dash/wasm-parser/ts/generators/Label.d.ts.map +1 -0
  67. package/dist/commonjs/parsers/manifest/dash/wasm-parser/ts/generators/Label.js +12 -0
  68. package/dist/commonjs/parsers/manifest/dash/wasm-parser/ts/types.d.ts +2 -1
  69. package/dist/commonjs/parsers/manifest/dash/wasm-parser/ts/types.d.ts.map +1 -1
  70. package/dist/commonjs/parsers/manifest/index.d.ts +1 -1
  71. package/dist/commonjs/parsers/manifest/index.d.ts.map +1 -1
  72. package/dist/commonjs/parsers/manifest/index.js +0 -15
  73. package/dist/commonjs/transports/dash/integrity_checks.js +2 -2
  74. package/dist/commonjs/transports/dash/load_chunked_segment_data.js +2 -2
  75. package/dist/commonjs/transports/dash/segment_loader.js +2 -2
  76. package/dist/commonjs/transports/dash/text_loader.js +2 -2
  77. package/dist/commonjs/transports/smooth/segment_loader.js +2 -2
  78. package/dist/commonjs/utils/request/fetch.js +2 -2
  79. package/dist/commonjs/utils/retry_promise_with_backoff.js +2 -2
  80. package/dist/es2017/__GENERATED_CODE/embedded_dash_wasm.d.ts.map +1 -1
  81. package/dist/es2017/__GENERATED_CODE/embedded_dash_wasm.js +1 -1
  82. package/dist/es2017/__GENERATED_CODE/embedded_worker.d.ts.map +1 -1
  83. package/dist/es2017/__GENERATED_CODE/embedded_worker.js +1 -1
  84. package/dist/es2017/compat/patch_webkit_source_buffer.d.ts.map +1 -1
  85. package/dist/es2017/compat/patch_webkit_source_buffer.js +0 -3
  86. package/dist/es2017/config.d.ts +7 -156
  87. package/dist/es2017/config.d.ts.map +1 -1
  88. package/dist/es2017/config.js +6 -1
  89. package/dist/es2017/core/main/worker/worker_main.d.ts.map +1 -1
  90. package/dist/es2017/core/main/worker/worker_main.js +4 -0
  91. package/dist/es2017/core/stream/adaptation/adaptation_stream.d.ts.map +1 -1
  92. package/dist/es2017/core/stream/adaptation/adaptation_stream.js +18 -7
  93. package/dist/es2017/core/stream/adaptation/index.d.ts +1 -1
  94. package/dist/es2017/core/stream/adaptation/index.d.ts.map +1 -1
  95. package/dist/es2017/core/stream/adaptation/index.js +0 -1
  96. package/dist/es2017/core/stream/period/index.d.ts +1 -1
  97. package/dist/es2017/core/stream/period/index.d.ts.map +1 -1
  98. package/dist/es2017/core/stream/period/index.js +0 -1
  99. package/dist/es2017/core/stream/representation/index.d.ts +1 -1
  100. package/dist/es2017/core/stream/representation/index.d.ts.map +1 -1
  101. package/dist/es2017/core/stream/representation/index.js +0 -1
  102. package/dist/es2017/core/stream/representation/utils/append_segment_to_buffer.d.ts.map +1 -1
  103. package/dist/es2017/core/stream/representation/utils/append_segment_to_buffer.js +6 -2
  104. package/dist/es2017/default_config.js +4 -0
  105. package/dist/es2017/main_thread/api/public_api.d.ts.map +1 -1
  106. package/dist/es2017/main_thread/api/public_api.js +17 -2
  107. package/dist/es2017/main_thread/decrypt/content_decryptor.d.ts.map +1 -1
  108. package/dist/es2017/main_thread/decrypt/content_decryptor.js +2 -0
  109. package/dist/es2017/main_thread/decrypt/get_media_keys.d.ts.map +1 -1
  110. package/dist/es2017/main_thread/decrypt/get_media_keys.js +1 -0
  111. package/dist/es2017/multithread_types.d.ts +8 -1
  112. package/dist/es2017/multithread_types.d.ts.map +1 -1
  113. package/dist/es2017/parsers/manifest/dash/wasm-parser/ts/generators/AdaptationSet.d.ts.map +1 -1
  114. package/dist/es2017/parsers/manifest/dash/wasm-parser/ts/generators/AdaptationSet.js +6 -5
  115. package/dist/es2017/parsers/manifest/dash/wasm-parser/ts/generators/Label.d.ts +4 -0
  116. package/dist/es2017/parsers/manifest/dash/wasm-parser/ts/generators/Label.d.ts.map +1 -0
  117. package/dist/es2017/parsers/manifest/dash/wasm-parser/ts/generators/Label.js +9 -0
  118. package/dist/es2017/parsers/manifest/dash/wasm-parser/ts/types.d.ts +2 -1
  119. package/dist/es2017/parsers/manifest/dash/wasm-parser/ts/types.d.ts.map +1 -1
  120. package/dist/es2017/parsers/manifest/index.d.ts +1 -1
  121. package/dist/es2017/parsers/manifest/index.d.ts.map +1 -1
  122. package/dist/es2017/parsers/manifest/index.js +1 -1
  123. package/dist/mpd-parser.wasm +0 -0
  124. package/dist/rx-player.js +52 -13
  125. package/dist/rx-player.min.js +16 -16
  126. package/dist/worker.js +6 -6
  127. package/package.json +24 -19
  128. package/src/__GENERATED_CODE/embedded_dash_wasm.ts +1 -1
  129. package/src/__GENERATED_CODE/embedded_worker.ts +1 -1
  130. package/src/compat/patch_webkit_source_buffer.ts +0 -3
  131. package/src/config.ts +10 -2
  132. package/src/core/main/worker/worker_main.ts +5 -0
  133. package/src/core/stream/adaptation/adaptation_stream.ts +18 -7
  134. package/src/core/stream/adaptation/index.ts +1 -1
  135. package/src/core/stream/period/index.ts +1 -1
  136. package/src/core/stream/representation/index.ts +1 -1
  137. package/src/core/stream/representation/utils/append_segment_to_buffer.ts +6 -2
  138. package/src/default_config.ts +21 -0
  139. package/src/main_thread/api/public_api.ts +19 -2
  140. package/src/main_thread/decrypt/content_decryptor.ts +2 -0
  141. package/src/main_thread/decrypt/get_media_keys.ts +1 -0
  142. package/src/main_thread/init/multi_thread_content_initializer.ts +0 -18
  143. package/src/multithread_types.ts +9 -0
  144. package/src/parsers/manifest/dash/wasm-parser/rs/events.rs +3 -2
  145. package/src/parsers/manifest/dash/wasm-parser/rs/processor/mod.rs +6 -2
  146. package/src/parsers/manifest/dash/wasm-parser/ts/generators/AdaptationSet.ts +10 -5
  147. package/src/parsers/manifest/dash/wasm-parser/ts/generators/Label.ts +16 -0
  148. package/src/parsers/manifest/dash/wasm-parser/ts/types.ts +3 -0
  149. package/src/parsers/manifest/index.ts +1 -1
@@ -85,10 +85,8 @@ export default function patchWebkitSourceBuffer(): void {
85
85
  val: unknown,
86
86
  ) {
87
87
  queueMicrotask(() => {
88
- // @ts-expect-error: trigger is normally protected
89
88
  this.trigger(eventName, val as Event);
90
89
  this.updating = false;
91
- // @ts-expect-error: trigger is normally protected
92
90
  this.trigger("updateend", new Event("updateend"));
93
91
  });
94
92
  };
@@ -97,7 +95,6 @@ export default function patchWebkitSourceBuffer(): void {
97
95
  if (this.updating) {
98
96
  throw new Error("updating");
99
97
  }
100
- // @ts-expect-error: trigger is normally protected
101
98
  this.trigger("updatestart", new Event("updatestart"));
102
99
  this.updating = true;
103
100
  try {
package/src/config.ts CHANGED
@@ -9,13 +9,21 @@
9
9
  import type { IDefaultConfig } from "./default_config";
10
10
  import DEFAULT_CONFIG from "./default_config";
11
11
  import deepMerge from "./utils/deep_merge";
12
+ import EventEmitter from "./utils/event_emitter";
12
13
 
13
- class ConfigHandler {
14
- _config = DEFAULT_CONFIG;
14
+ interface IConfigHandlerEvents {
15
+ update: Partial<IDefaultConfig>;
16
+ }
17
+
18
+ class ConfigHandler extends EventEmitter<IConfigHandlerEvents> {
19
+ public updated = false;
20
+ private _config = DEFAULT_CONFIG;
15
21
 
16
22
  update(config: Partial<IDefaultConfig>) {
17
23
  const newConfig = deepMerge(this._config, config);
18
24
  this._config = newConfig;
25
+ this.updated = true;
26
+ this.trigger("update", config);
19
27
  }
20
28
 
21
29
  getCurrent(): IDefaultConfig {
@@ -401,6 +401,11 @@ export default function initializeWorkerMain() {
401
401
  break;
402
402
  }
403
403
 
404
+ case MainThreadMessageType.ConfigUpdate: {
405
+ config.update(msg.value);
406
+ break;
407
+ }
408
+
404
409
  default:
405
410
  assertUnreachable(msg);
406
411
  }
@@ -381,7 +381,7 @@ export default function AdaptationStream(
381
381
  const bufferGoal = createMappedReference(
382
382
  wantedBufferAhead,
383
383
  (prev) => {
384
- return prev * getBufferGoalRatio(representation);
384
+ return getBufferGoal(representation, prev);
385
385
  },
386
386
  bufferGoalCanceller.signal,
387
387
  );
@@ -406,10 +406,11 @@ export default function AdaptationStream(
406
406
  const lastBufferGoalRatio = bufferGoalRatioMap.get(representation.id) ?? 1;
407
407
  // 70%, 49%, 34.3%, 24%, 16.81%, 11.76%, 8.24% and 5.76%
408
408
  const newBufferGoalRatio = lastBufferGoalRatio * 0.7;
409
- if (newBufferGoalRatio <= 0.05 || wba * newBufferGoalRatio <= 2) {
410
- throw formattedError;
411
- }
412
409
  bufferGoalRatioMap.set(representation.id, newBufferGoalRatio);
410
+ if (newBufferGoalRatio <= 0.05 || getBufferGoal(representation, wba) <= 2) {
411
+ representationStreamCallbacks.error(formattedError);
412
+ return;
413
+ }
413
414
 
414
415
  // We wait 4 seconds to let the situation evolve by itself before
415
416
  // retrying loading segments with a lower buffer goal
@@ -481,15 +482,25 @@ export default function AdaptationStream(
481
482
  }
482
483
 
483
484
  /**
484
- * @param {Object} representation
485
+ * Returns how much media data should be pre-buffered for this
486
+ * `Representation`, according to the `wantedBufferAhead` setting and previous
487
+ * issues encountered with that `Representation`.
488
+ * @param {Object} representation - The `Representation` you want to buffer.
489
+ * @param {number} wba - The value of `wantedBufferAhead` set by the user.
485
490
  * @returns {number}
486
491
  */
487
- function getBufferGoalRatio(representation: IRepresentation): number {
492
+ function getBufferGoal(representation: IRepresentation, wba: number): number {
488
493
  const oldBufferGoalRatio = bufferGoalRatioMap.get(representation.id);
489
494
  const bufferGoalRatio = oldBufferGoalRatio !== undefined ? oldBufferGoalRatio : 1;
490
495
  if (oldBufferGoalRatio === undefined) {
491
496
  bufferGoalRatioMap.set(representation.id, bufferGoalRatio);
492
497
  }
493
- return bufferGoalRatio;
498
+ if (bufferGoalRatio < 1 && wba === Infinity) {
499
+ // When `wba` is equal to `Infinity`, dividing it will still make it equal
500
+ // to `Infinity`. To make the `bufferGoalRatio` still have an effect, we
501
+ // just starts from a `wba` set to the high value of 5 minutes.
502
+ return 5 * 60 * 1000 * bufferGoalRatio;
503
+ }
504
+ return wba * bufferGoalRatio;
494
505
  }
495
506
  }
@@ -15,6 +15,6 @@
15
15
  */
16
16
 
17
17
  import AdaptationStream from "./adaptation_stream";
18
- export * from "./types";
18
+ export type * from "./types";
19
19
 
20
20
  export default AdaptationStream;
@@ -15,6 +15,6 @@
15
15
  */
16
16
 
17
17
  import PeriodStream from "./period_stream";
18
- export * from "./types";
18
+ export type * from "./types";
19
19
 
20
20
  export default PeriodStream;
@@ -15,6 +15,6 @@
15
15
  */
16
16
 
17
17
  import RepresentationStream from "./representation_stream";
18
- export * from "./types";
18
+ export type * from "./types";
19
19
 
20
20
  export default RepresentationStream;
@@ -72,8 +72,12 @@ export default async function appendSegmentToBuffer<T>(
72
72
  log.warn("Stream: Running garbage collector");
73
73
  const start = Math.max(currentPos - 5, 0);
74
74
  const end = currentPos + bufferGoal.getValue() + 12;
75
- await segmentSink.removeBuffer(0, start);
76
- await segmentSink.removeBuffer(end, Number.MAX_VALUE);
75
+ if (start > 0) {
76
+ await segmentSink.removeBuffer(0, start);
77
+ }
78
+ if (end < Number.MAX_VALUE) {
79
+ await segmentSink.removeBuffer(end, Number.MAX_VALUE);
80
+ }
77
81
  await sleep(200);
78
82
  if (cancellationSignal.cancellationError !== null) {
79
83
  throw cancellationSignal.cancellationError;
@@ -1187,3 +1187,24 @@ const DEFAULT_CONFIG = {
1187
1187
 
1188
1188
  export type IDefaultConfig = typeof DEFAULT_CONFIG;
1189
1189
  export default DEFAULT_CONFIG;
1190
+
1191
+ // NOTE Because the config may have to be serialized and shared between several
1192
+ // environments, we check here that some strict type is respected:
1193
+ // - only a subset of types are authorized for now, just make it easier to
1194
+ // reason about.
1195
+ // - Needs to make sense in JSON: no `function`, no `Date`, no `undefined`...
1196
+ interface IGenericConfigData {
1197
+ [key: string]:
1198
+ | string
1199
+ | number
1200
+ | boolean
1201
+ | number[]
1202
+ | string[]
1203
+ | Partial<Record<string, string[]>>
1204
+ | IGenericConfigData;
1205
+ }
1206
+
1207
+ function checkIsSerializable(_conf: IGenericConfigData): void {
1208
+ // noop
1209
+ }
1210
+ checkIsSerializable(DEFAULT_CONFIG);
@@ -32,6 +32,7 @@ import getStartDate from "../../compat/get_start_date";
32
32
  import hasMseInWorker from "../../compat/has_mse_in_worker";
33
33
  import hasWorkerApi from "../../compat/has_worker_api";
34
34
  import isDebugModeEnabled from "../../compat/is_debug_mode_enabled";
35
+ import config from "../../config";
35
36
  import type { ISegmentSinkMetrics } from "../../core/segment_sinks/segment_buffers_store";
36
37
  import type {
37
38
  IAdaptationChoice,
@@ -39,6 +40,7 @@ import type {
39
40
  IABRThrottlers,
40
41
  IBufferType,
41
42
  } from "../../core/types";
43
+ import type { IDefaultConfig } from "../../default_config";
42
44
  import type { IErrorCode, IErrorType } from "../../errors";
43
45
  import { ErrorCodes, ErrorTypes, formatError, MediaError } from "../../errors";
44
46
  import WorkerInitializationError from "../../errors/worker_initialization_error";
@@ -409,7 +411,7 @@ class Player extends EventEmitter<IPublicAPIEvent> {
409
411
  // See: https://bugzilla.mozilla.org/show_bug.cgi?id=1194624
410
412
  videoElement.preload = "auto";
411
413
 
412
- this.version = /* PLAYER_VERSION */ "4.2.0-dev.2024091000";
414
+ this.version = /* PLAYER_VERSION */ "4.2.0-dev.2024092400";
413
415
  this.log = log;
414
416
  this.state = "STOPPED";
415
417
  this.videoElement = videoElement;
@@ -573,6 +575,21 @@ class Player extends EventEmitter<IPublicAPIEvent> {
573
575
  },
574
576
  this._destroyCanceller.signal,
575
577
  );
578
+
579
+ const sendConfigUpdates = (updates: Partial<IDefaultConfig>) => {
580
+ if (this._priv_worker === null) {
581
+ return;
582
+ }
583
+ log.debug("---> Sending To Worker:", MainThreadMessageType.ConfigUpdate);
584
+ this._priv_worker.postMessage({
585
+ type: MainThreadMessageType.ConfigUpdate,
586
+ value: updates,
587
+ });
588
+ };
589
+ if (config.updated) {
590
+ sendConfigUpdates(config.getCurrent());
591
+ }
592
+ config.addEventListener("update", sendConfigUpdates, this._destroyCanceller.signal);
576
593
  });
577
594
  }
578
595
 
@@ -3313,7 +3330,7 @@ class Player extends EventEmitter<IPublicAPIEvent> {
3313
3330
  }
3314
3331
  }
3315
3332
  }
3316
- Player.version = /* PLAYER_VERSION */ "4.2.0-dev.2024091000";
3333
+ Player.version = /* PLAYER_VERSION */ "4.2.0-dev.2024092400";
3317
3334
 
3318
3335
  /** Every events sent by the RxPlayer's public API. */
3319
3336
  interface IPublicAPIEvent {
@@ -208,6 +208,7 @@ export default class ContentDecryptor extends EventEmitter<IContentDecryptorEven
208
208
 
209
209
  this.systemId = systemId;
210
210
  if (this._stateData.state === ContentDecryptorState.Initializing) {
211
+ log.debug("DRM: Waiting for attachment.");
211
212
  this._stateData = {
212
213
  state: ContentDecryptorState.WaitingForAttachment,
213
214
  isInitDataQueueLocked: true,
@@ -260,6 +261,7 @@ export default class ContentDecryptor extends EventEmitter<IContentDecryptorEven
260
261
  const shouldDisableLock = options.disableMediaKeysAttachmentLock === true;
261
262
 
262
263
  if (shouldDisableLock) {
264
+ log.debug("DRM: disabling MediaKeys attachment lock. Ready for content");
263
265
  this._stateData = {
264
266
  state: ContentDecryptorState.ReadyForContent,
265
267
  isInitDataQueueLocked: true,
@@ -102,6 +102,7 @@ export default async function getMediaKeysInfos(
102
102
  currentState !== null &&
103
103
  evt.type === "reuse-media-key-system-access"
104
104
  ) {
105
+ log.debug("DRM: Reusing already created MediaKeys");
105
106
  const { mediaKeys, loadedSessionsStore } = currentState;
106
107
 
107
108
  // We might just rely on the currently attached MediaKeys instance.
@@ -2006,24 +2006,6 @@ type IDecryptionInitializationState =
2006
2006
  * `HTMLMediaElement` (such as linking a content / `MediaSource` to it).
2007
2007
  */
2008
2008
  | { type: "uninitialized"; value: null }
2009
- /**
2010
- * The `MediaSource` or media url has to be linked to the `HTMLMediaElement`
2011
- * before continuing.
2012
- * Once it has been linked with success (e.g. the `MediaSource` has "opened"),
2013
- * the `isMediaLinked` `SharedReference` should be set to `true`.
2014
- *
2015
- * In the `MediaSource` case, you should wait until the `"initialized"`
2016
- * state before pushing segment.
2017
- *
2018
- * Note that the `"awaiting-media-link"` is an optional state. It can be
2019
- * skipped to directly `"initialized"` instead.
2020
- */
2021
- | {
2022
- type: "awaiting-media-link";
2023
- value: {
2024
- isMediaLinked: SharedReference<boolean>;
2025
- };
2026
- }
2027
2009
  /**
2028
2010
  * The `MediaSource` or media url can be linked AND segments can be pushed to
2029
2011
  * the `HTMLMediaElement` on which decryption capabilities were wanted.
@@ -14,6 +14,7 @@ import type {
14
14
  IRepresentationsChoice,
15
15
  ITrackSwitchingMode,
16
16
  } from "./core/types";
17
+ import type { IDefaultConfig } from "./default_config";
17
18
  import type {
18
19
  ISerializedMediaError,
19
20
  ISerializedNetworkError,
@@ -158,6 +159,12 @@ export interface ILogLevelUpdateMessage {
158
159
  };
159
160
  }
160
161
 
162
+ /** Message sent by the main thread to update the Worker's global config. */
163
+ export interface IConfigUpdateMessage {
164
+ type: MainThreadMessageType.ConfigUpdate;
165
+ value: Partial<IDefaultConfig>;
166
+ }
167
+
161
168
  /**
162
169
  * Message sent by the main thread when a new content should be "prepared".
163
170
  *
@@ -542,6 +549,7 @@ export const enum MainThreadMessageType {
542
549
  RemoveTextDataError = "remove-text-error",
543
550
  CodecSupportUpdate = "codec-support-update",
544
551
  ContentUrlsUpdate = "urls-update",
552
+ ConfigUpdate = "config-update",
545
553
  DecipherabilityStatusUpdate = "decipherability-update",
546
554
  LogLevelUpdate = "log-level-update",
547
555
  MediaSourceReadyStateChange = "media-source-ready-state-change",
@@ -560,6 +568,7 @@ export const enum MainThreadMessageType {
560
568
  export type IMainThreadMessage =
561
569
  | IInitMessage
562
570
  | ILogLevelUpdateMessage
571
+ | IConfigUpdateMessage
563
572
  | IPrepareContentMessage
564
573
  | IStopContentMessage
565
574
  | IStartPreparedContentMessage
@@ -86,6 +86,9 @@ pub enum TagName {
86
86
  // -- Inside a <SegmentList> --
87
87
  /// Indicate a <SegmentURL> node
88
88
  SegmentUrl = 20,
89
+
90
+ /// Indicate a <Label> node
91
+ Label = 21,
89
92
  }
90
93
 
91
94
  #[derive(PartialEq, Clone, Copy)]
@@ -276,8 +279,6 @@ pub enum AttributeName {
276
279
  /// namespaces that will appear in it.
277
280
  Namespace = 70,
278
281
 
279
- Label = 71, // String
280
-
281
282
  ServiceLocation = 72, // String
282
283
 
283
284
  // SegmentTemplate
@@ -114,7 +114,10 @@ impl MPDProcessor {
114
114
  }
115
115
  b"cenc:pssh" => self.process_cenc_element(),
116
116
  b"Location" => self.process_location_element(),
117
- b"Label" => self.process_label_element(),
117
+ b"Label" => {
118
+ TagName::Label.report_tag_open();
119
+ self.process_label_element();
120
+ }
118
121
  b"SegmentTimeline" => self.process_segment_timeline_element(),
119
122
 
120
123
  b"EventStream" => {
@@ -274,7 +277,7 @@ impl MPDProcessor {
274
277
  Ok(Event::Text(t)) => {
275
278
  if t.len() > 0 {
276
279
  match t.unescape() {
277
- Ok(unescaped) => AttributeName::Label.report(unescaped),
280
+ Ok(unescaped) => AttributeName::Text.report(unescaped),
278
281
  Err(err) => ParsingError::from(err).report_err(),
279
282
  }
280
283
  }
@@ -284,6 +287,7 @@ impl MPDProcessor {
284
287
  if inner_tag > 0 {
285
288
  inner_tag -= 1;
286
289
  } else {
290
+ TagName::Label.report_tag_close();
287
291
  break;
288
292
  }
289
293
  }
@@ -27,6 +27,7 @@ import { parseFloatOrBool, parseString } from "../utils";
27
27
  import { generateBaseUrlAttrParser } from "./BaseURL";
28
28
  import { generateContentComponentAttrParser } from "./ContentComponent";
29
29
  import { generateContentProtectionAttrParser } from "./ContentProtection";
30
+ import { generateLabelElementParser } from "./Label";
30
31
  import {
31
32
  generateRepresentationAttrParser,
32
33
  generateRepresentationChildrenParser,
@@ -209,6 +210,15 @@ export function generateAdaptationSetChildrenParser(
209
210
  break;
210
211
  }
211
212
 
213
+ case TagName.Label: {
214
+ parsersStack.pushParsers(
215
+ nodeId,
216
+ noop, // Label as treated like an attribute
217
+ generateLabelElementParser(adaptationSetChildren, linearMemory),
218
+ );
219
+ break;
220
+ }
221
+
212
222
  default:
213
223
  // Allows to make sure we're not mistakenly closing a re-opened
214
224
  // tag.
@@ -363,11 +373,6 @@ export function generateAdaptationSetAttrParser(
363
373
  case AttributeName.AvailabilityTimeComplete:
364
374
  adaptationAttrs.availabilityTimeComplete = dataView.getUint8(0) === 0;
365
375
  break;
366
- case AttributeName.Label: {
367
- const label = parseString(textDecoder, linearMemory.buffer, ptr, len);
368
- adaptationAttrs.label = label;
369
- break;
370
- }
371
376
 
372
377
  // TODO
373
378
  // case AttributeName.StartsWithSap:
@@ -0,0 +1,16 @@
1
+ import type { IAdaptationSetChildren } from "../../../node_parser_types";
2
+ import type { IAttributeParser } from "../parsers_stack";
3
+ import { AttributeName } from "../types";
4
+ import { parseString } from "../utils";
5
+
6
+ export function generateLabelElementParser(
7
+ adaptationSet: IAdaptationSetChildren,
8
+ linearMemory: WebAssembly.Memory,
9
+ ): IAttributeParser {
10
+ const textDecoder = new TextDecoder();
11
+ return function onMPDAttribute(attr: AttributeName, ptr: number, len: number) {
12
+ if (attr === AttributeName.Text) {
13
+ adaptationSet.label = parseString(textDecoder, linearMemory.buffer, ptr, len);
14
+ }
15
+ };
16
+ }
@@ -108,6 +108,9 @@ export const enum TagName {
108
108
 
109
109
  /// Indicate a <SegmentURL> node
110
110
  SegmentUrl = 20,
111
+
112
+ /// Indicate a <Label> node
113
+ Label = 21,
111
114
  }
112
115
 
113
116
  /**
@@ -14,4 +14,4 @@
14
14
  * limitations under the License.
15
15
  */
16
16
 
17
- export * from "./types";
17
+ export type * from "./types";