rx-player 3.29.0-dev.2022091600 → 3.29.0-dev.2022103100
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 +22 -10
- package/MAINTAINERS.md +2 -1
- package/VERSION +1 -1
- package/dist/_esm5.processed/compat/browser_detection.d.ts +4 -1
- package/dist/_esm5.processed/compat/browser_detection.js +7 -1
- package/dist/_esm5.processed/compat/can_reuse_media_keys.d.ts +12 -0
- package/dist/_esm5.processed/compat/can_reuse_media_keys.js +15 -0
- package/dist/_esm5.processed/compat/enable_audio_track.d.ts +11 -0
- package/dist/_esm5.processed/compat/enable_audio_track.js +26 -0
- package/dist/_esm5.processed/compat/index.d.ts +4 -2
- package/dist/_esm5.processed/compat/index.js +4 -2
- package/dist/_esm5.processed/compat/{should_renew_media_keys.d.ts → should_renew_media_key_system_access.d.ts} +3 -3
- package/dist/_esm5.processed/compat/{should_renew_media_keys.js → should_renew_media_key_system_access.js} +3 -3
- package/dist/_esm5.processed/config.d.ts +1 -0
- package/dist/_esm5.processed/core/api/playback_observer.d.ts +14 -5
- package/dist/_esm5.processed/core/api/playback_observer.js +54 -22
- package/dist/_esm5.processed/core/api/public_api.d.ts +7 -4
- package/dist/_esm5.processed/core/api/public_api.js +79 -61
- package/dist/_esm5.processed/core/api/tracks_management/media_element_track_choice_manager.js +9 -10
- package/dist/_esm5.processed/core/decrypt/__tests__/__global__/utils.js +1 -1
- package/dist/_esm5.processed/core/decrypt/find_key_system.js +3 -3
- package/dist/_esm5.processed/core/decrypt/get_media_keys.js +4 -1
- package/dist/_esm5.processed/core/fetchers/cdn_prioritizer.d.ts +98 -0
- package/dist/_esm5.processed/core/fetchers/cdn_prioritizer.js +173 -0
- package/dist/_esm5.processed/core/fetchers/manifest/manifest_fetcher.js +4 -4
- package/dist/_esm5.processed/core/fetchers/segment/segment_fetcher.d.ts +2 -1
- package/dist/_esm5.processed/core/fetchers/segment/segment_fetcher.js +15 -16
- package/dist/_esm5.processed/core/fetchers/segment/segment_fetcher_creator.d.ts +3 -1
- package/dist/_esm5.processed/core/fetchers/segment/segment_fetcher_creator.js +5 -2
- package/dist/_esm5.processed/core/fetchers/utils/schedule_request.d.ts +103 -0
- package/dist/_esm5.processed/core/fetchers/utils/schedule_request.js +414 -0
- package/dist/_esm5.processed/core/init/content_time_boundaries_observer.d.ts +4 -3
- package/dist/_esm5.processed/core/init/content_time_boundaries_observer.js +21 -22
- package/dist/_esm5.processed/core/init/initialize_media_source.d.ts +18 -4
- package/dist/_esm5.processed/core/init/initialize_media_source.js +10 -2
- package/dist/_esm5.processed/core/init/load_on_media_source.js +7 -1
- package/dist/_esm5.processed/core/init/stall_avoider.js +3 -1
- package/dist/_esm5.processed/default_config.d.ts +11 -0
- package/dist/_esm5.processed/default_config.js +11 -0
- package/dist/_esm5.processed/experimental/tools/VideoThumbnailLoader/video_thumbnail_loader.js +1 -1
- package/dist/_esm5.processed/manifest/manifest.js +11 -2
- package/dist/_esm5.processed/manifest/representation.d.ts +12 -1
- package/dist/_esm5.processed/manifest/representation.js +1 -0
- package/dist/_esm5.processed/manifest/representation_index/static.d.ts +1 -1
- package/dist/_esm5.processed/manifest/representation_index/static.js +2 -2
- package/dist/_esm5.processed/manifest/representation_index/types.d.ts +32 -15
- package/dist/_esm5.processed/manifest/update_period_in_place.js +1 -0
- package/dist/_esm5.processed/parsers/manifest/dash/common/indexes/base.d.ts +10 -9
- package/dist/_esm5.processed/parsers/manifest/dash/common/indexes/base.js +11 -11
- package/dist/_esm5.processed/parsers/manifest/dash/common/indexes/get_init_segment.d.ts +1 -1
- package/dist/_esm5.processed/parsers/manifest/dash/common/indexes/get_init_segment.js +3 -3
- package/dist/_esm5.processed/parsers/manifest/dash/common/indexes/get_segments_from_timeline.d.ts +1 -1
- package/dist/_esm5.processed/parsers/manifest/dash/common/indexes/get_segments_from_timeline.js +4 -4
- package/dist/_esm5.processed/parsers/manifest/dash/common/indexes/list.d.ts +7 -7
- package/dist/_esm5.processed/parsers/manifest/dash/common/indexes/list.js +12 -8
- package/dist/_esm5.processed/parsers/manifest/dash/common/indexes/template.d.ts +5 -6
- package/dist/_esm5.processed/parsers/manifest/dash/common/indexes/template.js +16 -16
- package/dist/_esm5.processed/parsers/manifest/dash/common/indexes/timeline/timeline_representation_index.d.ts +11 -10
- package/dist/_esm5.processed/parsers/manifest/dash/common/indexes/timeline/timeline_representation_index.js +14 -13
- package/dist/_esm5.processed/parsers/manifest/dash/common/indexes/tokens.d.ts +3 -4
- package/dist/_esm5.processed/parsers/manifest/dash/common/indexes/tokens.js +4 -12
- package/dist/_esm5.processed/parsers/manifest/dash/common/parse_mpd.js +2 -4
- package/dist/_esm5.processed/parsers/manifest/dash/common/parse_representation_index.js +1 -3
- package/dist/_esm5.processed/parsers/manifest/dash/common/parse_representations.js +6 -2
- package/dist/_esm5.processed/parsers/manifest/dash/common/resolve_base_urls.d.ts +1 -2
- package/dist/_esm5.processed/parsers/manifest/dash/common/resolve_base_urls.js +3 -8
- package/dist/_esm5.processed/parsers/manifest/dash/js-parser/node_parsers/BaseURL.d.ts +1 -1
- package/dist/_esm5.processed/parsers/manifest/dash/js-parser/node_parsers/BaseURL.js +2 -20
- package/dist/_esm5.processed/parsers/manifest/dash/node_parser_types.d.ts +0 -6
- package/dist/_esm5.processed/parsers/manifest/dash/wasm-parser/ts/generators/BaseURL.js +0 -11
- package/dist/_esm5.processed/parsers/manifest/dash/wasm-parser/ts/types.d.ts +5 -1
- package/dist/_esm5.processed/parsers/manifest/local/parse_local_manifest.js +2 -1
- package/dist/_esm5.processed/parsers/manifest/local/representation_index.js +2 -2
- package/dist/_esm5.processed/parsers/manifest/metaplaylist/metaplaylist_parser.js +7 -1
- package/dist/_esm5.processed/parsers/manifest/smooth/create_parser.js +17 -11
- package/dist/_esm5.processed/parsers/manifest/smooth/representation_index.js +2 -2
- package/dist/_esm5.processed/parsers/manifest/types.d.ts +24 -0
- package/dist/_esm5.processed/parsers/texttracks/ttml/html/apply_extent.js +8 -1
- package/dist/_esm5.processed/parsers/texttracks/ttml/html/apply_origin.js +9 -1
- package/dist/_esm5.processed/parsers/texttracks/ttml/html/create_element.js +2 -1
- package/dist/_esm5.processed/transports/dash/construct_segment_url.d.ts +18 -0
- package/dist/_esm5.processed/transports/dash/construct_segment_url.js +21 -0
- package/dist/_esm5.processed/transports/dash/image_pipelines.d.ts +3 -2
- package/dist/_esm5.processed/transports/dash/image_pipelines.js +5 -3
- package/dist/_esm5.processed/transports/dash/segment_loader.js +4 -2
- package/dist/_esm5.processed/transports/dash/text_loader.js +4 -2
- package/dist/_esm5.processed/transports/dash/text_parser.js +3 -1
- package/dist/_esm5.processed/transports/local/segment_loader.d.ts +3 -2
- package/dist/_esm5.processed/transports/local/segment_loader.js +2 -2
- package/dist/_esm5.processed/transports/metaplaylist/pipelines.js +8 -8
- package/dist/_esm5.processed/transports/smooth/pipelines.js +11 -7
- package/dist/_esm5.processed/transports/smooth/utils.d.ts +4 -2
- package/dist/_esm5.processed/transports/smooth/utils.js +7 -1
- package/dist/_esm5.processed/transports/types.d.ts +5 -3
- package/dist/_esm5.processed/utils/event_emitter.d.ts +1 -2
- package/dist/_esm5.processed/utils/resolve_url.d.ts +7 -4
- package/dist/_esm5.processed/utils/resolve_url.js +11 -8
- package/dist/mpd-parser.wasm +0 -0
- package/dist/rx-player.js +5656 -13236
- package/dist/rx-player.min.js +1 -1
- package/jest.config.js +28 -23
- package/package.json +29 -29
- package/sonar-project.properties +1 -1
- package/src/compat/__tests__/can_reuse_media_keys.test.ts +54 -0
- package/src/compat/__tests__/enable_audio_track.test.ts +341 -0
- package/src/compat/__tests__/{should_renew_media_keys.test.ts → should_renew_media_key_system_access.test.ts} +7 -5
- package/src/compat/browser_detection.ts +10 -0
- package/src/compat/can_reuse_media_keys.ts +19 -0
- package/src/compat/enable_audio_track.ts +33 -0
- package/src/compat/index.ts +6 -2
- package/src/compat/{should_renew_media_keys.ts → should_renew_media_key_system_access.ts} +3 -3
- package/src/core/api/playback_observer.ts +97 -33
- package/src/core/api/public_api.ts +126 -74
- package/src/core/api/tracks_management/media_element_track_choice_manager.ts +3 -11
- package/src/core/decrypt/__tests__/__global__/media_keys.test.ts +182 -0
- package/src/core/decrypt/__tests__/__global__/utils.ts +2 -0
- package/src/core/decrypt/find_key_system.ts +3 -3
- package/src/core/decrypt/get_media_keys.ts +5 -1
- package/src/core/fetchers/cdn_prioritizer.ts +198 -0
- package/src/core/fetchers/manifest/manifest_fetcher.ts +7 -11
- package/src/core/fetchers/segment/segment_fetcher.ts +12 -10
- package/src/core/fetchers/segment/segment_fetcher_creator.ts +10 -1
- package/src/core/fetchers/utils/schedule_request.ts +482 -0
- package/src/core/init/content_time_boundaries_observer.ts +12 -12
- package/src/core/init/initialize_media_source.ts +31 -4
- package/src/core/init/load_on_media_source.ts +11 -2
- package/src/core/init/stall_avoider.ts +4 -1
- package/src/core/stream/orchestrator/stream_orchestrator.ts +0 -1
- package/src/default_config.ts +12 -0
- package/src/experimental/tools/VideoThumbnailLoader/video_thumbnail_loader.ts +1 -0
- package/src/manifest/manifest.ts +11 -2
- package/src/manifest/representation.ts +15 -0
- package/src/manifest/representation_index/__tests__/static.test.ts +1 -1
- package/src/manifest/representation_index/static.ts +3 -3
- package/src/manifest/representation_index/types.ts +33 -15
- package/src/manifest/update_period_in_place.ts +1 -0
- package/src/parsers/manifest/dash/common/indexes/base.ts +22 -23
- package/src/parsers/manifest/dash/common/indexes/get_init_segment.ts +6 -4
- package/src/parsers/manifest/dash/common/indexes/get_segments_from_timeline.ts +5 -5
- package/src/parsers/manifest/dash/common/indexes/list.ts +19 -20
- package/src/parsers/manifest/dash/common/indexes/template.ts +23 -27
- package/src/parsers/manifest/dash/common/indexes/timeline/timeline_representation_index.ts +25 -23
- package/src/parsers/manifest/dash/common/indexes/tokens.ts +7 -18
- package/src/parsers/manifest/dash/common/parse_mpd.ts +2 -4
- package/src/parsers/manifest/dash/common/parse_representation_index.ts +1 -6
- package/src/parsers/manifest/dash/common/parse_representations.ts +9 -0
- package/src/parsers/manifest/dash/common/resolve_base_urls.ts +5 -9
- package/src/parsers/manifest/dash/js-parser/node_parsers/BaseURL.ts +2 -29
- package/src/parsers/manifest/dash/js-parser/node_parsers/__tests__/AdaptationSet.test.ts +7 -11
- package/src/parsers/manifest/dash/node_parser_types.ts +0 -7
- package/src/parsers/manifest/dash/wasm-parser/rs/events.rs +3 -1
- package/src/parsers/manifest/dash/wasm-parser/rs/processor/attributes.rs +1 -8
- package/src/parsers/manifest/dash/wasm-parser/ts/generators/BaseURL.ts +0 -13
- package/src/parsers/manifest/dash/wasm-parser/ts/types.ts +8 -0
- package/src/parsers/manifest/local/parse_local_manifest.ts +1 -0
- package/src/parsers/manifest/local/representation_index.ts +2 -2
- package/src/parsers/manifest/metaplaylist/metaplaylist_parser.ts +7 -1
- package/src/parsers/manifest/smooth/create_parser.ts +17 -13
- package/src/parsers/manifest/smooth/representation_index.ts +2 -2
- package/src/parsers/manifest/types.ts +26 -1
- package/src/parsers/manifest/utils/__tests__/get_first_time_from_adaptations.test.ts +15 -0
- package/src/parsers/manifest/utils/__tests__/get_last_time_from_adaptation.test.ts +15 -0
- package/src/parsers/texttracks/ttml/html/apply_extent.ts +8 -1
- package/src/parsers/texttracks/ttml/html/apply_origin.ts +9 -1
- package/src/parsers/texttracks/ttml/html/create_element.ts +2 -2
- package/src/transports/dash/construct_segment_url.ts +28 -0
- package/src/transports/dash/image_pipelines.ts +5 -2
- package/src/transports/dash/segment_loader.ts +5 -2
- package/src/transports/dash/text_loader.ts +5 -2
- package/src/transports/dash/text_parser.ts +3 -1
- package/src/transports/local/segment_loader.ts +3 -2
- package/src/transports/metaplaylist/pipelines.ts +28 -9
- package/src/transports/smooth/pipelines.ts +12 -6
- package/src/transports/smooth/utils.ts +13 -1
- package/src/transports/types.ts +6 -3
- package/src/utils/__tests__/event_emitter.test.ts +72 -67
- package/src/utils/__tests__/initialization_segment_cache.test.ts +7 -7
- package/src/utils/__tests__/resolve_url.test.ts +27 -23
- package/src/utils/event_emitter.ts +1 -3
- package/src/utils/resolve_url.ts +11 -8
- package/dist/_esm5.processed/core/fetchers/utils/try_urls_with_backoff.d.ts +0 -85
- package/dist/_esm5.processed/core/fetchers/utils/try_urls_with_backoff.js +0 -264
- package/dummy +0 -1
- package/src/core/fetchers/utils/try_urls_with_backoff.ts +0 -287
|
@@ -43,7 +43,7 @@ var __assign = (this && this.__assign) || function () {
|
|
|
43
43
|
* This file defines the public API for the RxPlayer.
|
|
44
44
|
* It also starts the different sub-parts of the player on various API calls.
|
|
45
45
|
*/
|
|
46
|
-
import { combineLatest as observableCombineLatest, concat as observableConcat, connectable, distinctUntilChanged, EMPTY, filter, map, merge as observableMerge, mergeMap, Observable, of as observableOf, share, shareReplay, skipWhile, startWith, Subject, switchMap, take, takeUntil, } from "rxjs";
|
|
46
|
+
import { combineLatest as observableCombineLatest, concat as observableConcat, connectable, distinctUntilChanged, EMPTY, filter, map, merge as observableMerge, mergeMap, Observable, of as observableOf, share, shareReplay, skipWhile, startWith, Subject, switchMap, take, takeUntil, tap, } from "rxjs";
|
|
47
47
|
import { events, exitFullscreen, getStartDate, isFullscreen, requestFullscreen, } from "../../compat";
|
|
48
48
|
/* eslint-disable-next-line max-len */
|
|
49
49
|
import canRelyOnVideoVisibilityAndSize from "../../compat/can_rely_on_video_visibility_and_size";
|
|
@@ -61,7 +61,7 @@ import createSharedReference, { createMappedReference, } from "../../utils/refer
|
|
|
61
61
|
import TaskCanceller from "../../utils/task_canceller";
|
|
62
62
|
import warnOnce from "../../utils/warn_once";
|
|
63
63
|
import { clearOnStop, disposeDecryptionResources, getCurrentKeySystem, } from "../decrypt";
|
|
64
|
-
import { ManifestFetcher,
|
|
64
|
+
import { ManifestFetcher, } from "../fetchers";
|
|
65
65
|
import initializeMediaSourcePlayback from "../init";
|
|
66
66
|
import { checkReloadOptions, parseConstructorOptions, parseLoadVideoOptions, } from "./option_utils";
|
|
67
67
|
import PlaybackObserver from "./playback_observer";
|
|
@@ -87,7 +87,7 @@ var Player = /** @class */ (function (_super) {
|
|
|
87
87
|
// Workaround to support Firefox autoplay on FF 42.
|
|
88
88
|
// See: https://bugzilla.mozilla.org/show_bug.cgi?id=1194624
|
|
89
89
|
videoElement.preload = "auto";
|
|
90
|
-
_this.version = /* PLAYER_VERSION */ "3.29.0-dev.
|
|
90
|
+
_this.version = /* PLAYER_VERSION */ "3.29.0-dev.2022103100";
|
|
91
91
|
_this.log = log;
|
|
92
92
|
_this.state = "STOPPED";
|
|
93
93
|
_this.videoElement = videoElement;
|
|
@@ -163,7 +163,7 @@ var Player = /** @class */ (function (_super) {
|
|
|
163
163
|
_this._priv_preferredAudioTracks = preferredAudioTracks;
|
|
164
164
|
_this._priv_preferredTextTracks = preferredTextTracks;
|
|
165
165
|
_this._priv_preferredVideoTracks = preferredVideoTracks;
|
|
166
|
-
_this.
|
|
166
|
+
_this._priv_reloadingMetadata = {};
|
|
167
167
|
return _this;
|
|
168
168
|
}
|
|
169
169
|
Object.defineProperty(Player, "ErrorTypes", {
|
|
@@ -262,7 +262,7 @@ var Player = /** @class */ (function (_super) {
|
|
|
262
262
|
this._priv_bitrateInfos.minAutoBitrates.audio.finish();
|
|
263
263
|
this._priv_bitrateInfos.maxAutoBitrates.video.finish();
|
|
264
264
|
this._priv_bitrateInfos.maxAutoBitrates.audio.finish();
|
|
265
|
-
this.
|
|
265
|
+
this._priv_reloadingMetadata = {};
|
|
266
266
|
// un-attach video element
|
|
267
267
|
this.videoElement = null;
|
|
268
268
|
};
|
|
@@ -273,50 +273,49 @@ var Player = /** @class */ (function (_super) {
|
|
|
273
273
|
Player.prototype.loadVideo = function (opts) {
|
|
274
274
|
var options = parseLoadVideoOptions(opts);
|
|
275
275
|
log.info("API: Calling loadvideo", options.url, options.transport);
|
|
276
|
-
this.
|
|
276
|
+
this._priv_reloadingMetadata = { options: options };
|
|
277
277
|
this._priv_initializeContentPlayback(options);
|
|
278
278
|
};
|
|
279
279
|
/**
|
|
280
|
-
* Reload last content.
|
|
281
|
-
* the manifest.
|
|
280
|
+
* Reload the last loaded content.
|
|
282
281
|
* @param {Object} reloadOpts
|
|
283
282
|
*/
|
|
284
283
|
Player.prototype.reload = function (reloadOpts) {
|
|
285
|
-
var _a
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
lastPlaybackPosition === undefined) {
|
|
284
|
+
var _a, _b;
|
|
285
|
+
var _c = this._priv_reloadingMetadata, options = _c.options, manifest = _c.manifest, reloadPosition = _c.reloadPosition, reloadInPause = _c.reloadInPause;
|
|
286
|
+
if (options === undefined) {
|
|
289
287
|
throw new Error("API: Can't reload without having previously loaded a content.");
|
|
290
288
|
}
|
|
291
289
|
checkReloadOptions(reloadOpts);
|
|
292
|
-
var
|
|
293
|
-
if (reloadOpts !== undefined
|
|
294
|
-
reloadOpts.reloadAt
|
|
295
|
-
reloadOpts.reloadAt.position !== undefined) {
|
|
296
|
-
startAtPositon = reloadOpts.reloadAt.position;
|
|
290
|
+
var startAt;
|
|
291
|
+
if (((_a = reloadOpts === null || reloadOpts === void 0 ? void 0 : reloadOpts.reloadAt) === null || _a === void 0 ? void 0 : _a.position) !== undefined) {
|
|
292
|
+
startAt = { position: reloadOpts.reloadAt.position };
|
|
297
293
|
}
|
|
298
|
-
else {
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
playbackPosition = lastPlaybackPosition;
|
|
302
|
-
}
|
|
303
|
-
else {
|
|
304
|
-
if (this.videoElement === null) {
|
|
305
|
-
throw new Error("Can't reload when video element does not exist.");
|
|
306
|
-
}
|
|
307
|
-
playbackPosition = this.videoElement.currentTime;
|
|
308
|
-
}
|
|
309
|
-
if (reloadOpts !== undefined &&
|
|
310
|
-
reloadOpts.reloadAt !== undefined &&
|
|
311
|
-
reloadOpts.reloadAt.relative !== undefined) {
|
|
312
|
-
startAtPositon = reloadOpts.reloadAt.relative + playbackPosition;
|
|
294
|
+
else if (((_b = reloadOpts === null || reloadOpts === void 0 ? void 0 : reloadOpts.reloadAt) === null || _b === void 0 ? void 0 : _b.relative) !== undefined) {
|
|
295
|
+
if (reloadPosition === undefined) {
|
|
296
|
+
throw new Error("Can't reload to a relative position when previous content was not loaded.");
|
|
313
297
|
}
|
|
314
298
|
else {
|
|
315
|
-
|
|
299
|
+
startAt = { position: reloadOpts.reloadAt.relative + reloadPosition };
|
|
316
300
|
}
|
|
317
301
|
}
|
|
302
|
+
else if (reloadPosition !== undefined) {
|
|
303
|
+
startAt = { position: reloadPosition };
|
|
304
|
+
}
|
|
305
|
+
var autoPlay;
|
|
306
|
+
if ((reloadOpts === null || reloadOpts === void 0 ? void 0 : reloadOpts.autoPlay) !== undefined) {
|
|
307
|
+
autoPlay = reloadOpts.autoPlay;
|
|
308
|
+
}
|
|
309
|
+
else if (reloadInPause !== undefined) {
|
|
310
|
+
autoPlay = !reloadInPause;
|
|
311
|
+
}
|
|
318
312
|
var newOptions = __assign(__assign({}, options), { initialManifest: manifest });
|
|
319
|
-
|
|
313
|
+
if (startAt !== undefined) {
|
|
314
|
+
newOptions.startAt = startAt;
|
|
315
|
+
}
|
|
316
|
+
if (autoPlay !== undefined) {
|
|
317
|
+
newOptions.autoPlay = autoPlay;
|
|
318
|
+
}
|
|
320
319
|
this._priv_initializeContentPlayback(newOptions);
|
|
321
320
|
};
|
|
322
321
|
/**
|
|
@@ -377,10 +376,6 @@ var Player = /** @class */ (function (_super) {
|
|
|
377
376
|
var manifestFetcher = new ManifestFetcher(url, transportPipelines, { lowLatencyMode: lowLatencyMode, maxRetryRegular: manifestRetry,
|
|
378
377
|
maxRetryOffline: offlineRetry,
|
|
379
378
|
requestTimeout: manifestRequestTimeout });
|
|
380
|
-
/** Interface used to download segments. */
|
|
381
|
-
var segmentFetcherCreator = new SegmentFetcherCreator(transportPipelines, { lowLatencyMode: lowLatencyMode, maxRetryOffline: offlineRetry,
|
|
382
|
-
maxRetryRegular: segmentRetry,
|
|
383
|
-
requestTimeout: segmentRequestTimeout });
|
|
384
379
|
/** Observable emitting the initial Manifest */
|
|
385
380
|
var manifest$ = void 0;
|
|
386
381
|
if (initialManifest instanceof Manifest) {
|
|
@@ -459,8 +454,11 @@ var Player = /** @class */ (function (_super) {
|
|
|
459
454
|
{ textTrackMode: "html",
|
|
460
455
|
textTrackElement: options.textTrackElement };
|
|
461
456
|
var bufferOptions = objectAssign({ audioTrackSwitchingMode: audioTrackSwitchingMode, enableFastSwitching: enableFastSwitching, manualBitrateSwitchingMode: manualBitrateSwitchingMode, onCodecSwitch: onCodecSwitch }, this._priv_bufferOptions);
|
|
457
|
+
var segmentRequestOptions = { regularError: segmentRetry,
|
|
458
|
+
requestTimeout: segmentRequestTimeout,
|
|
459
|
+
offlineError: offlineRetry };
|
|
462
460
|
// We've every options set up. Start everything now
|
|
463
|
-
var init$ = initializeMediaSourcePlayback({ adaptiveOptions: adaptiveOptions, autoPlay: autoPlay, bufferOptions: bufferOptions, playbackObserver: playbackObserver, keySystems: keySystems, lowLatencyMode: lowLatencyMode, manifest$: manifest$, manifestFetcher: manifestFetcher, mediaElement: videoElement, minimumManifestUpdateInterval: minimumManifestUpdateInterval,
|
|
461
|
+
var init$ = initializeMediaSourcePlayback({ adaptiveOptions: adaptiveOptions, autoPlay: autoPlay, bufferOptions: bufferOptions, playbackObserver: playbackObserver, keySystems: keySystems, lowLatencyMode: lowLatencyMode, manifest$: manifest$, manifestFetcher: manifestFetcher, mediaElement: videoElement, minimumManifestUpdateInterval: minimumManifestUpdateInterval, segmentRequestOptions: segmentRequestOptions, speed: this._priv_speed, startAt: startAt, transport: transportPipelines, textTrackOptions: textTrackOptions })
|
|
464
462
|
.pipe(takeUntil(stoppedContent$));
|
|
465
463
|
playback$ = connectable(init$, { connector: function () { return new Subject(); },
|
|
466
464
|
resetOnDisconnect: false });
|
|
@@ -576,25 +574,47 @@ var Player = /** @class */ (function (_super) {
|
|
|
576
574
|
playbackSubscription.unsubscribe();
|
|
577
575
|
}
|
|
578
576
|
});
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
577
|
+
/**
|
|
578
|
+
* Function updating `this._priv_reloadingMetadata` in function of the
|
|
579
|
+
* current state and playback conditions.
|
|
580
|
+
* To call when either might change.
|
|
581
|
+
* @param {string} state - The player state we're about to switch to.
|
|
582
|
+
*/
|
|
583
|
+
var updateReloadingMetadata = function (state) {
|
|
584
|
+
switch (state) {
|
|
585
|
+
case "STOPPED":
|
|
586
|
+
case "RELOADING":
|
|
587
|
+
case "LOADING":
|
|
588
|
+
break; // keep previous metadata
|
|
589
|
+
case "ENDED":
|
|
590
|
+
_this._priv_reloadingMetadata.reloadInPause = true;
|
|
591
|
+
_this._priv_reloadingMetadata.reloadPosition =
|
|
592
|
+
playbackObserver.getReference().getValue().position;
|
|
593
|
+
break;
|
|
594
|
+
default:
|
|
595
|
+
var o = playbackObserver.getReference().getValue();
|
|
596
|
+
_this._priv_reloadingMetadata.reloadInPause = o.paused;
|
|
597
|
+
_this._priv_reloadingMetadata.reloadPosition = o.position;
|
|
598
|
+
break;
|
|
599
|
+
}
|
|
600
|
+
};
|
|
601
|
+
playerState$.pipe(tap(function (newState) {
|
|
602
|
+
updateReloadingMetadata(newState);
|
|
592
603
|
_this._priv_setPlayerState(newState);
|
|
593
604
|
// Previous call could have performed all kind of side-effects, thus,
|
|
594
605
|
// we re-check the current state associated to the RxPlayer
|
|
595
606
|
if (_this.state === "ENDED" && _this._priv_stopAtEnd) {
|
|
596
607
|
currentContentCanceller.cancel();
|
|
597
608
|
}
|
|
609
|
+
}), map(function (state) { return state !== "RELOADING" && state !== "STOPPED"; }), distinctUntilChanged(), switchMap(function (canSendObservation) { return canSendObservation ? observation$ :
|
|
610
|
+
EMPTY; }), takeUntil(stoppedContent$)).subscribe(function (o) {
|
|
611
|
+
updateReloadingMetadata(_this.state);
|
|
612
|
+
_this._priv_triggerPositionUpdate(o);
|
|
613
|
+
});
|
|
614
|
+
// Link "seeking" and "seeked" events (once the content is loaded)
|
|
615
|
+
loaded$.pipe(switchMap(function () { return emitSeekEvents(_this.videoElement, observation$); }), takeUntil(stoppedContent$)).subscribe(function (evt) {
|
|
616
|
+
log.info("API: Triggering \"".concat(evt, "\" event"));
|
|
617
|
+
_this.trigger(evt, null);
|
|
598
618
|
});
|
|
599
619
|
// Link playback events to the corresponding callbacks
|
|
600
620
|
playback$.subscribe({
|
|
@@ -1916,7 +1936,7 @@ var Player = /** @class */ (function (_super) {
|
|
|
1916
1936
|
return;
|
|
1917
1937
|
}
|
|
1918
1938
|
contentInfos.manifest = manifest;
|
|
1919
|
-
this.
|
|
1939
|
+
this._priv_reloadingMetadata.manifest = manifest;
|
|
1920
1940
|
var initialAudioTrack = contentInfos.initialAudioTrack, initialTextTrack = contentInfos.initialTextTrack;
|
|
1921
1941
|
this._priv_trackChoiceManager = new TrackChoiceManager({
|
|
1922
1942
|
preferTrickModeTracks: this._priv_preferTrickModeTracks,
|
|
@@ -2218,14 +2238,10 @@ var Player = /** @class */ (function (_super) {
|
|
|
2218
2238
|
log.warn("API: Cannot perform time update: no content loaded.");
|
|
2219
2239
|
return;
|
|
2220
2240
|
}
|
|
2221
|
-
if (this.state === "RELOADING" /* PLAYER_STATES.RELOADING */) {
|
|
2222
|
-
return;
|
|
2223
|
-
}
|
|
2224
2241
|
var _b = this._priv_contentInfos, isDirectFile = _b.isDirectFile, manifest = _b.manifest;
|
|
2225
2242
|
if ((!isDirectFile && manifest === null) || isNullOrUndefined(observation)) {
|
|
2226
2243
|
return;
|
|
2227
2244
|
}
|
|
2228
|
-
this._priv_lastContentPlaybackInfos.lastPlaybackPosition = observation.position;
|
|
2229
2245
|
var maximumPosition = manifest !== null ? manifest.getMaximumSafePosition() :
|
|
2230
2246
|
undefined;
|
|
2231
2247
|
var positionData = {
|
|
@@ -2233,9 +2249,11 @@ var Player = /** @class */ (function (_super) {
|
|
|
2233
2249
|
duration: observation.duration,
|
|
2234
2250
|
playbackRate: observation.playbackRate,
|
|
2235
2251
|
maximumBufferTime: maximumPosition,
|
|
2236
|
-
// TODO
|
|
2237
|
-
bufferGap:
|
|
2238
|
-
|
|
2252
|
+
// TODO bufferGap may be undefined
|
|
2253
|
+
bufferGap: observation.bufferGap === undefined ||
|
|
2254
|
+
!isFinite(observation.bufferGap) ?
|
|
2255
|
+
0 :
|
|
2256
|
+
observation.bufferGap,
|
|
2239
2257
|
};
|
|
2240
2258
|
if (manifest !== null &&
|
|
2241
2259
|
manifest.isLive &&
|
|
@@ -2294,5 +2312,5 @@ var Player = /** @class */ (function (_super) {
|
|
|
2294
2312
|
};
|
|
2295
2313
|
return Player;
|
|
2296
2314
|
}(EventEmitter));
|
|
2297
|
-
Player.version = /* PLAYER_VERSION */ "3.29.0-dev.
|
|
2315
|
+
Player.version = /* PLAYER_VERSION */ "3.29.0-dev.2022103100";
|
|
2298
2316
|
export default Player;
|
package/dist/_esm5.processed/core/api/tracks_management/media_element_track_choice_manager.js
CHANGED
|
@@ -28,7 +28,11 @@ var __extends = (this && this.__extends) || (function () {
|
|
|
28
28
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
29
29
|
};
|
|
30
30
|
})();
|
|
31
|
-
|
|
31
|
+
/**
|
|
32
|
+
* /!\ This file is feature-switchable.
|
|
33
|
+
* It always should be imported through the `features` object.
|
|
34
|
+
*/
|
|
35
|
+
import { enableAudioTrack } from "../../../compat";
|
|
32
36
|
import EventEmitter from "../../../utils/event_emitter";
|
|
33
37
|
import normalizeLanguage from "../../../utils/languages";
|
|
34
38
|
/**
|
|
@@ -747,15 +751,10 @@ var MediaElementTrackChoiceManager = /** @class */ (function (_super) {
|
|
|
747
751
|
* @param {number} index}
|
|
748
752
|
*/
|
|
749
753
|
MediaElementTrackChoiceManager.prototype._enableAudioTrackFromIndex = function (index) {
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
var audioTrack = _a[_i];
|
|
755
|
-
audioTrack.nativeTrack.enabled = false;
|
|
756
|
-
}
|
|
757
|
-
this._audioTracks[index].nativeTrack.enabled = true;
|
|
758
|
-
return;
|
|
754
|
+
enableAudioTrack(this._audioTracks.map(function (_a) {
|
|
755
|
+
var nativeTrack = _a.nativeTrack;
|
|
756
|
+
return nativeTrack;
|
|
757
|
+
}), index);
|
|
759
758
|
};
|
|
760
759
|
return MediaElementTrackChoiceManager;
|
|
761
760
|
}(EventEmitter));
|
|
@@ -257,7 +257,7 @@ export function mockCompat(exportedFunctions) {
|
|
|
257
257
|
var mockGetInitData = jest.fn(function (encryptedEvent) {
|
|
258
258
|
return encryptedEvent;
|
|
259
259
|
});
|
|
260
|
-
jest.mock("../../../../compat", function () { return (__assign({ events: mockEvents, requestMediaKeySystemAccess: mockRmksa, setMediaKeys: mockSetMediaKeys, getInitData: mockGetInitData, generateKeyRequest: mockGenerateKeyRequest }, exportedFunctions)); });
|
|
260
|
+
jest.mock("../../../../compat", function () { return (__assign({ events: mockEvents, requestMediaKeySystemAccess: mockRmksa, setMediaKeys: mockSetMediaKeys, getInitData: mockGetInitData, generateKeyRequest: mockGenerateKeyRequest, shouldRenewMediaKeySystemAccess: jest.fn(function () { return false; }), canReuseMediaKeys: jest.fn(function () { return true; }) }, exportedFunctions)); });
|
|
261
261
|
return { mockEvents: mockEvents, eventTriggers: { triggerEncrypted: triggerEncrypted, triggerKeyMessage: triggerKeyMessage, triggerKeyError: triggerKeyError, triggerKeyStatusesChange: triggerKeyStatusesChange },
|
|
262
262
|
mockRequestMediaKeySystemAccess: mockRmksa, mockGetInitData: mockGetInitData, mockSetMediaKeys: mockSetMediaKeys, mockGenerateKeyRequest: mockGenerateKeyRequest };
|
|
263
263
|
}
|
|
@@ -49,7 +49,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
49
49
|
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
50
50
|
}
|
|
51
51
|
};
|
|
52
|
-
import { requestMediaKeySystemAccess,
|
|
52
|
+
import { requestMediaKeySystemAccess, shouldRenewMediaKeySystemAccess, } from "../../compat";
|
|
53
53
|
import config from "../../config";
|
|
54
54
|
import { EncryptedMediaError } from "../../errors";
|
|
55
55
|
import log from "../../log";
|
|
@@ -64,7 +64,7 @@ import MediaKeysInfosStore from "./utils/media_keys_infos_store";
|
|
|
64
64
|
*/
|
|
65
65
|
function checkCachedMediaKeySystemAccess(keySystems, currentKeySystemAccess, currentKeySystemOptions) {
|
|
66
66
|
var mksConfiguration = currentKeySystemAccess.getConfiguration();
|
|
67
|
-
if (
|
|
67
|
+
if (shouldRenewMediaKeySystemAccess() || mksConfiguration == null) {
|
|
68
68
|
return null;
|
|
69
69
|
}
|
|
70
70
|
var firstCompatibleOption = keySystems.filter(function (ks) {
|
|
@@ -157,7 +157,7 @@ function buildKeySystemConfigurations(ksName, keySystem) {
|
|
|
157
157
|
// More details here:
|
|
158
158
|
// https://storage.googleapis.com/wvdocs/Chrome_EME_Changes_and_Best_Practices.pdf
|
|
159
159
|
// https://www.w3.org/TR/encrypted-media/#get-supported-configuration-and-consent
|
|
160
|
-
var videoCapabilities = flatMap(
|
|
160
|
+
var videoCapabilities = flatMap(videoRobustnesses, function (robustness) {
|
|
161
161
|
return ["video/mp4;codecs=\"avc1.4d401e\"",
|
|
162
162
|
"video/mp4;codecs=\"avc1.42e01e\"",
|
|
163
163
|
"video/webm;codecs=\"vp8\""].map(function (contentType) {
|
|
@@ -49,6 +49,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
49
49
|
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
50
50
|
}
|
|
51
51
|
};
|
|
52
|
+
import { canReuseMediaKeys, } from "../../compat";
|
|
52
53
|
import { EncryptedMediaError } from "../../errors";
|
|
53
54
|
import log from "../../log";
|
|
54
55
|
import isNullOrUndefined from "../../utils/is_null_or_undefined";
|
|
@@ -100,7 +101,9 @@ export default function getMediaKeysInfos(mediaElement, keySystemsConfigs, cance
|
|
|
100
101
|
_a = evt.value, options = _a.options, mediaKeySystemAccess = _a.mediaKeySystemAccess;
|
|
101
102
|
currentState = MediaKeysInfosStore.getState(mediaElement);
|
|
102
103
|
persistentSessionsStore = createPersistentSessionsStorage(options);
|
|
103
|
-
if (
|
|
104
|
+
if (canReuseMediaKeys() &&
|
|
105
|
+
currentState !== null &&
|
|
106
|
+
evt.type === "reuse-media-key-system-access") {
|
|
104
107
|
mediaKeys_1 = currentState.mediaKeys, loadedSessionsStore_1 = currentState.loadedSessionsStore;
|
|
105
108
|
// We might just rely on the currently attached MediaKeys instance.
|
|
106
109
|
// First check if server certificate parameters are the same than in the
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2015 CANAL+ Group
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
import { ICdnMetadata } from "../../parsers/manifest";
|
|
17
|
+
import { IPlayerError } from "../../public_types";
|
|
18
|
+
import EventEmitter from "../../utils/event_emitter";
|
|
19
|
+
import { CancellationSignal } from "../../utils/task_canceller";
|
|
20
|
+
/**
|
|
21
|
+
* Class signaling the priority between multiple CDN available for any given
|
|
22
|
+
* resource.
|
|
23
|
+
*
|
|
24
|
+
* This class might perform requests and schedule timeouts by itself to keep its
|
|
25
|
+
* internal list of CDN priority up-to-date.
|
|
26
|
+
* When it is not needed anymore, you should call the `dispose` method to clear
|
|
27
|
+
* all resources.
|
|
28
|
+
*
|
|
29
|
+
* @class CdnPrioritizer
|
|
30
|
+
*/
|
|
31
|
+
export default class CdnPrioritizer extends EventEmitter<ICdnPrioritizerEvents> {
|
|
32
|
+
/**
|
|
33
|
+
* Structure keeping a list of CDN currently downgraded.
|
|
34
|
+
* Downgraded CDN immediately have a lower priority than any non-downgraded
|
|
35
|
+
* CDN for a specific amount of time.
|
|
36
|
+
*/
|
|
37
|
+
private _downgradedCdnList;
|
|
38
|
+
/**
|
|
39
|
+
* @param {Object} destroySignal
|
|
40
|
+
*/
|
|
41
|
+
constructor(destroySignal: CancellationSignal);
|
|
42
|
+
/**
|
|
43
|
+
* From the list of __ALL__ CDNs available to a resource, return them in the
|
|
44
|
+
* order in which requests should be performed.
|
|
45
|
+
*
|
|
46
|
+
* Note: It is VERY important to include all CDN that are able to reach the
|
|
47
|
+
* wanted resource, even those which will in the end not be used anyway.
|
|
48
|
+
* If some CDN are not communicated, the `CdnPrioritizer` might wrongly
|
|
49
|
+
* consider that the current resource don't have any of the CDN prioritized
|
|
50
|
+
* internally and return other CDN which should have been forbidden if it knew
|
|
51
|
+
* about the other, non-used, ones.
|
|
52
|
+
*
|
|
53
|
+
* @param {Array.<string>} everyCdnForResource - Array of ALL available CDN
|
|
54
|
+
* able to reach the wanted resource - even those which might not be used in
|
|
55
|
+
* the end.
|
|
56
|
+
* @returns {Array.<Object>} - Array of CDN that can be tried to reach the
|
|
57
|
+
* resource, sorted by order of CDN preference, according to the
|
|
58
|
+
* `CdnPrioritizer`'s own list of priorities.
|
|
59
|
+
*/
|
|
60
|
+
getCdnPreferenceForResource(everyCdnForResource: ICdnMetadata[]): ICdnMetadata[];
|
|
61
|
+
/**
|
|
62
|
+
* Limit usage of the CDN for a configured amount of time.
|
|
63
|
+
* Call this method if you encountered an issue with that CDN which leads you
|
|
64
|
+
* to want to prevent its usage currently.
|
|
65
|
+
*
|
|
66
|
+
* Note that the CDN can still be the preferred one if no other CDN exist for
|
|
67
|
+
* a wanted resource.
|
|
68
|
+
* @param {string} metadata
|
|
69
|
+
*/
|
|
70
|
+
downgradeCdn(metadata: ICdnMetadata): void;
|
|
71
|
+
/**
|
|
72
|
+
* From the list of __ALL__ CDNs available to a resource, return them in the
|
|
73
|
+
* order in which requests should be performed.
|
|
74
|
+
*
|
|
75
|
+
* Note: It is VERY important to include all CDN that are able to reach the
|
|
76
|
+
* wanted resource, even those which will in the end not be used anyway.
|
|
77
|
+
* If some CDN are not communicated, the `CdnPrioritizer` might wrongly
|
|
78
|
+
* consider that the current resource don't have any of the CDN prioritized
|
|
79
|
+
* internally and return other CDN which should have been forbidden if it knew
|
|
80
|
+
* about the other, non-used, ones.
|
|
81
|
+
*
|
|
82
|
+
* @param {Array.<string>} everyCdnForResource - Array of ALL available CDN
|
|
83
|
+
* able to reach the wanted resource - even those which might not be used in
|
|
84
|
+
* the end.
|
|
85
|
+
* @returns {Array.<string>} - Array of CDN that can be tried to reach the
|
|
86
|
+
* resource, sorted by order of CDN preference, according to the
|
|
87
|
+
* `CdnPrioritizer`'s own list of priorities.
|
|
88
|
+
*/
|
|
89
|
+
private _innerGetCdnPreferenceForResource;
|
|
90
|
+
/**
|
|
91
|
+
* @param {number} index
|
|
92
|
+
*/
|
|
93
|
+
private _removeIndexFromDowngradeList;
|
|
94
|
+
}
|
|
95
|
+
export interface ICdnPrioritizerEvents {
|
|
96
|
+
warnings: IPlayerError[];
|
|
97
|
+
priorityChange: null;
|
|
98
|
+
}
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2015 CANAL+ Group
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
var __extends = (this && this.__extends) || (function () {
|
|
17
|
+
var extendStatics = function (d, b) {
|
|
18
|
+
extendStatics = Object.setPrototypeOf ||
|
|
19
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
20
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
21
|
+
return extendStatics(d, b);
|
|
22
|
+
};
|
|
23
|
+
return function (d, b) {
|
|
24
|
+
if (typeof b !== "function" && b !== null)
|
|
25
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
26
|
+
extendStatics(d, b);
|
|
27
|
+
function __() { this.constructor = d; }
|
|
28
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
29
|
+
};
|
|
30
|
+
})();
|
|
31
|
+
import config from "../../config";
|
|
32
|
+
import arrayFindIndex from "../../utils/array_find_index";
|
|
33
|
+
import EventEmitter from "../../utils/event_emitter";
|
|
34
|
+
/**
|
|
35
|
+
* Class signaling the priority between multiple CDN available for any given
|
|
36
|
+
* resource.
|
|
37
|
+
*
|
|
38
|
+
* This class might perform requests and schedule timeouts by itself to keep its
|
|
39
|
+
* internal list of CDN priority up-to-date.
|
|
40
|
+
* When it is not needed anymore, you should call the `dispose` method to clear
|
|
41
|
+
* all resources.
|
|
42
|
+
*
|
|
43
|
+
* @class CdnPrioritizer
|
|
44
|
+
*/
|
|
45
|
+
var CdnPrioritizer = /** @class */ (function (_super) {
|
|
46
|
+
__extends(CdnPrioritizer, _super);
|
|
47
|
+
/**
|
|
48
|
+
* @param {Object} destroySignal
|
|
49
|
+
*/
|
|
50
|
+
function CdnPrioritizer(destroySignal) {
|
|
51
|
+
var _this = _super.call(this) || this;
|
|
52
|
+
_this._downgradedCdnList = { metadata: [], timeouts: [] };
|
|
53
|
+
destroySignal.register(function () {
|
|
54
|
+
for (var _i = 0, _a = _this._downgradedCdnList.timeouts; _i < _a.length; _i++) {
|
|
55
|
+
var timeout = _a[_i];
|
|
56
|
+
clearTimeout(timeout);
|
|
57
|
+
}
|
|
58
|
+
_this._downgradedCdnList = { metadata: [], timeouts: [] };
|
|
59
|
+
});
|
|
60
|
+
return _this;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* From the list of __ALL__ CDNs available to a resource, return them in the
|
|
64
|
+
* order in which requests should be performed.
|
|
65
|
+
*
|
|
66
|
+
* Note: It is VERY important to include all CDN that are able to reach the
|
|
67
|
+
* wanted resource, even those which will in the end not be used anyway.
|
|
68
|
+
* If some CDN are not communicated, the `CdnPrioritizer` might wrongly
|
|
69
|
+
* consider that the current resource don't have any of the CDN prioritized
|
|
70
|
+
* internally and return other CDN which should have been forbidden if it knew
|
|
71
|
+
* about the other, non-used, ones.
|
|
72
|
+
*
|
|
73
|
+
* @param {Array.<string>} everyCdnForResource - Array of ALL available CDN
|
|
74
|
+
* able to reach the wanted resource - even those which might not be used in
|
|
75
|
+
* the end.
|
|
76
|
+
* @returns {Array.<Object>} - Array of CDN that can be tried to reach the
|
|
77
|
+
* resource, sorted by order of CDN preference, according to the
|
|
78
|
+
* `CdnPrioritizer`'s own list of priorities.
|
|
79
|
+
*/
|
|
80
|
+
CdnPrioritizer.prototype.getCdnPreferenceForResource = function (everyCdnForResource) {
|
|
81
|
+
if (everyCdnForResource.length <= 1) {
|
|
82
|
+
// The huge majority of contents have only one CDN available.
|
|
83
|
+
// Here, prioritizing make no sense.
|
|
84
|
+
return everyCdnForResource;
|
|
85
|
+
}
|
|
86
|
+
return this._innerGetCdnPreferenceForResource(everyCdnForResource);
|
|
87
|
+
};
|
|
88
|
+
/**
|
|
89
|
+
* Limit usage of the CDN for a configured amount of time.
|
|
90
|
+
* Call this method if you encountered an issue with that CDN which leads you
|
|
91
|
+
* to want to prevent its usage currently.
|
|
92
|
+
*
|
|
93
|
+
* Note that the CDN can still be the preferred one if no other CDN exist for
|
|
94
|
+
* a wanted resource.
|
|
95
|
+
* @param {string} metadata
|
|
96
|
+
*/
|
|
97
|
+
CdnPrioritizer.prototype.downgradeCdn = function (metadata) {
|
|
98
|
+
var _this = this;
|
|
99
|
+
var indexOf = indexOfMetadata(this._downgradedCdnList.metadata, metadata);
|
|
100
|
+
if (indexOf >= 0) {
|
|
101
|
+
this._removeIndexFromDowngradeList(indexOf);
|
|
102
|
+
}
|
|
103
|
+
var DEFAULT_CDN_DOWNGRADE_TIME = config.getCurrent().DEFAULT_CDN_DOWNGRADE_TIME;
|
|
104
|
+
var downgradeTime = DEFAULT_CDN_DOWNGRADE_TIME;
|
|
105
|
+
this._downgradedCdnList.metadata.push(metadata);
|
|
106
|
+
var timeout = window.setTimeout(function () {
|
|
107
|
+
var newIndex = indexOfMetadata(_this._downgradedCdnList.metadata, metadata);
|
|
108
|
+
if (newIndex >= 0) {
|
|
109
|
+
_this._removeIndexFromDowngradeList(newIndex);
|
|
110
|
+
}
|
|
111
|
+
_this.trigger("priorityChange", null);
|
|
112
|
+
}, downgradeTime);
|
|
113
|
+
this._downgradedCdnList.timeouts.push(timeout);
|
|
114
|
+
this.trigger("priorityChange", null);
|
|
115
|
+
};
|
|
116
|
+
/**
|
|
117
|
+
* From the list of __ALL__ CDNs available to a resource, return them in the
|
|
118
|
+
* order in which requests should be performed.
|
|
119
|
+
*
|
|
120
|
+
* Note: It is VERY important to include all CDN that are able to reach the
|
|
121
|
+
* wanted resource, even those which will in the end not be used anyway.
|
|
122
|
+
* If some CDN are not communicated, the `CdnPrioritizer` might wrongly
|
|
123
|
+
* consider that the current resource don't have any of the CDN prioritized
|
|
124
|
+
* internally and return other CDN which should have been forbidden if it knew
|
|
125
|
+
* about the other, non-used, ones.
|
|
126
|
+
*
|
|
127
|
+
* @param {Array.<string>} everyCdnForResource - Array of ALL available CDN
|
|
128
|
+
* able to reach the wanted resource - even those which might not be used in
|
|
129
|
+
* the end.
|
|
130
|
+
* @returns {Array.<string>} - Array of CDN that can be tried to reach the
|
|
131
|
+
* resource, sorted by order of CDN preference, according to the
|
|
132
|
+
* `CdnPrioritizer`'s own list of priorities.
|
|
133
|
+
*/
|
|
134
|
+
CdnPrioritizer.prototype._innerGetCdnPreferenceForResource = function (everyCdnForResource) {
|
|
135
|
+
var _this = this;
|
|
136
|
+
var _a = everyCdnForResource
|
|
137
|
+
.reduce(function (acc, elt) {
|
|
138
|
+
if (_this._downgradedCdnList.metadata.some(function (c) { return c.id === elt.id &&
|
|
139
|
+
c.baseUrl === elt.baseUrl; })) {
|
|
140
|
+
acc[1].push(elt);
|
|
141
|
+
}
|
|
142
|
+
else {
|
|
143
|
+
acc[0].push(elt);
|
|
144
|
+
}
|
|
145
|
+
return acc;
|
|
146
|
+
}, [[], []]), allowedInOrder = _a[0], downgradedInOrder = _a[1];
|
|
147
|
+
return allowedInOrder.concat(downgradedInOrder);
|
|
148
|
+
};
|
|
149
|
+
/**
|
|
150
|
+
* @param {number} index
|
|
151
|
+
*/
|
|
152
|
+
CdnPrioritizer.prototype._removeIndexFromDowngradeList = function (index) {
|
|
153
|
+
this._downgradedCdnList.metadata.splice(index, 1);
|
|
154
|
+
var oldTimeout = this._downgradedCdnList.timeouts.splice(index, 1);
|
|
155
|
+
clearTimeout(oldTimeout[0]);
|
|
156
|
+
};
|
|
157
|
+
return CdnPrioritizer;
|
|
158
|
+
}(EventEmitter));
|
|
159
|
+
export default CdnPrioritizer;
|
|
160
|
+
/**
|
|
161
|
+
* Find the index of the given CDN metadata in a CDN metadata array.
|
|
162
|
+
* Returns `-1` if not found.
|
|
163
|
+
* @param {Array.<Object>} arr
|
|
164
|
+
* @param {Object} elt
|
|
165
|
+
* @returns {number}
|
|
166
|
+
*/
|
|
167
|
+
function indexOfMetadata(arr, elt) {
|
|
168
|
+
if (arr.length === 0) {
|
|
169
|
+
return -1;
|
|
170
|
+
}
|
|
171
|
+
return elt.id !== undefined ? arrayFindIndex(arr, function (m) { return m.id === elt.id; }) :
|
|
172
|
+
arrayFindIndex(arr, function (m) { return m.baseUrl === elt.baseUrl; });
|
|
173
|
+
}
|
|
@@ -57,7 +57,7 @@ import assert from "../../../utils/assert";
|
|
|
57
57
|
import isNullOrUndefined from "../../../utils/is_null_or_undefined";
|
|
58
58
|
import TaskCanceller from "../../../utils/task_canceller";
|
|
59
59
|
import errorSelector from "../utils/error_selector";
|
|
60
|
-
import {
|
|
60
|
+
import { scheduleRequestPromise, } from "../utils/schedule_request";
|
|
61
61
|
/**
|
|
62
62
|
* Class allowing to facilitate the task of loading and parsing a Manifest.
|
|
63
63
|
* @class ManifestFetcher
|
|
@@ -156,7 +156,7 @@ var ManifestFetcher = /** @class */ (function () {
|
|
|
156
156
|
var resolveManifestUrl = pipelines.resolveManifestUrl;
|
|
157
157
|
assert(resolveManifestUrl !== undefined);
|
|
158
158
|
var callResolver = function () { return resolveManifestUrl(resolverUrl, canceller.signal); };
|
|
159
|
-
return
|
|
159
|
+
return scheduleRequestPromise(callResolver, backoffSettings, canceller.signal);
|
|
160
160
|
}
|
|
161
161
|
/**
|
|
162
162
|
* Call the loader part of the pipeline, retrying if it fails according
|
|
@@ -174,7 +174,7 @@ var ManifestFetcher = /** @class */ (function () {
|
|
|
174
174
|
requestTimeout = undefined;
|
|
175
175
|
}
|
|
176
176
|
var callLoader = function () { return loadManifest(manifestUrl, { timeout: requestTimeout }, canceller.signal); };
|
|
177
|
-
return
|
|
177
|
+
return scheduleRequestPromise(callLoader, backoffSettings, canceller.signal);
|
|
178
178
|
}
|
|
179
179
|
});
|
|
180
180
|
};
|
|
@@ -258,7 +258,7 @@ var ManifestFetcher = /** @class */ (function () {
|
|
|
258
258
|
switch (_a.label) {
|
|
259
259
|
case 0:
|
|
260
260
|
_a.trys.push([0, 2, , 3]);
|
|
261
|
-
return [4 /*yield*/,
|
|
261
|
+
return [4 /*yield*/, scheduleRequestPromise(performRequest, backoffSettings, canceller.signal)];
|
|
262
262
|
case 1:
|
|
263
263
|
data = _a.sent();
|
|
264
264
|
return [2 /*return*/, data];
|