From f00a8aa88b35ba39d267ee43d308bf9d70d9d8ea Mon Sep 17 00:00:00 2001 From: Paul Berberian Date: Wed, 6 Nov 2024 21:45:38 +0100 Subject: [PATCH] Replace Representation deprecation mechanism by Representation avoidance --- src/core/main/common/FreezeResolver.ts | 22 +++++++++---------- src/core/main/worker/content_preparer.ts | 15 +++++-------- src/core/main/worker/worker_main.ts | 10 ++++----- .../stream/adaptation/adaptation_stream.ts | 6 ++--- src/main_thread/api/option_utils.ts | 6 ++--- src/main_thread/api/public_api.ts | 8 +++---- .../init/media_source_content_initializer.ts | 10 ++++----- .../init/multi_thread_content_initializer.ts | 6 ++--- src/manifest/classes/manifest.ts | 16 +++++++------- src/manifest/classes/representation.ts | 4 ++-- src/multithread_types.ts | 4 ++-- src/public_types.ts | 4 ++-- 12 files changed, 53 insertions(+), 58 deletions(-) diff --git a/src/core/main/common/FreezeResolver.ts b/src/core/main/common/FreezeResolver.ts index 428acc9b7f..ce104ebe67 100644 --- a/src/core/main/common/FreezeResolver.ts +++ b/src/core/main/common/FreezeResolver.ts @@ -17,8 +17,8 @@ import type { IBufferedChunk } from "../../segment_sinks"; * In that case, the recommendation is to avoid playing those * `Representation` at all. */ -export interface IRepresentationDeprecationFreezeResolution { - type: "deprecate-representations"; +export interface IRepresentationAvoidanceFreezeResolution { + type: "avoid-representations"; /** The `Representation` to avoid. */ value: Array<{ adaptation: IAdaptation; @@ -59,7 +59,7 @@ export interface IReloadFreezeResolution { /** Describe a strategy that can be taken to un-freeze playback. */ export type IFreezeResolution = - | IRepresentationDeprecationFreezeResolution + | IRepresentationAvoidanceFreezeResolution | IFlushFreezeResolution | IReloadFreezeResolution; @@ -319,8 +319,8 @@ export default class FreezeResolver { "FR: A recent flush seemed to have no effect on freeze, checking for transitions", ); - /** Contains Representation we might want to deprecate after the following algorithm */ - const toDeprecate = []; + /** Contains Representation we might want to avoid after the following algorithm */ + const toAvoid = []; for (const ttype of ["audio", "video"] as const) { const segmentList = this._lastSegmentInfo[ttype]; @@ -383,9 +383,9 @@ export default class FreezeResolver { previousRepresentationEntry.segment === null ) { log.debug( - "FR: Freeze when beginning to play a content, try deprecating this quality", + "FR: Freeze when beginning to play a content, try avoiding this quality", ); - toDeprecate.push({ + toAvoid.push({ adaptation: currentSegment.infos.adaptation, period: currentSegment.infos.period, representation: currentSegment.infos.representation, @@ -401,10 +401,10 @@ export default class FreezeResolver { previousRepresentationEntry.segment.infos.representation.uniqueId ) { log.warn( - "FR: Freeze when switching Representation, deprecating", + "FR: Freeze when switching Representation, avoiding", currentSegment.infos.representation.bitrate, ); - toDeprecate.push({ + toAvoid.push({ adaptation: currentSegment.infos.adaptation, period: currentSegment.infos.period, representation: currentSegment.infos.representation, @@ -412,8 +412,8 @@ export default class FreezeResolver { } } - if (toDeprecate.length > 0) { - return { type: "deprecate-representations", value: toDeprecate }; + if (toAvoid.length > 0) { + return { type: "avoid-representations", value: toAvoid }; } else { log.debug("FR: Reloading because flush doesn't work"); return { type: "reload", value: null }; diff --git a/src/core/main/worker/content_preparer.ts b/src/core/main/worker/content_preparer.ts index 10584b83e3..b50bb25bbb 100644 --- a/src/core/main/worker/content_preparer.ts +++ b/src/core/main/worker/content_preparer.ts @@ -84,13 +84,8 @@ export default class ContentPreparer { currentMediaSourceCanceller.linkToSignal(contentCanceller.signal); - const { - contentId, - url, - hasText, - transportOptions, - enableRepresentationDeprecation, - } = context; + const { contentId, url, hasText, transportOptions, enableRepresentationAvoidance } = + context; let manifest: IManifest | null = null; // TODO better way @@ -158,7 +153,7 @@ export default class ContentPreparer { this._currentContent = { cmcdDataBuilder, contentId, - enableRepresentationDeprecation, + enableRepresentationAvoidance, freezeResolver, mediaSource, manifest: null, @@ -335,11 +330,11 @@ export interface IPreparedContentData { */ cmcdDataBuilder: CmcdDataBuilder | null; /** - * If `true`, the RxPlayer can enable its "Representation deprecation" + * If `true`, the RxPlayer can enable its "Representation avoidance" * mechanism, where it avoid loading Representation that it suspect * have issues being decoded on the current device. */ - enableRepresentationDeprecation: boolean; + enableRepresentationAvoidance: boolean; /** * Interface to the MediaSource implementation, allowing to buffer audio * and video media segments. diff --git a/src/core/main/worker/worker_main.ts b/src/core/main/worker/worker_main.ts index 91c30112b8..df77cbc41b 100644 --- a/src/core/main/worker/worker_main.ts +++ b/src/core/main/worker/worker_main.ts @@ -518,7 +518,7 @@ function loadOrReloadPreparedContent( const { contentId, cmcdDataBuilder, - enableRepresentationDeprecation, + enableRepresentationAvoidance, manifest, mediaSource, representationEstimator, @@ -561,11 +561,11 @@ function loadOrReloadPreparedContent( }); break; } - case "deprecate-representations": { - log.info("WP: Planning Representation deprecation due to freeze"); + case "avoid-representations": { + log.info("WP: Planning Representation avoidance due to freeze"); const content = freezeResolution.value; - if (enableRepresentationDeprecation) { - manifest.deprecateRepresentations(content); + if (enableRepresentationAvoidance) { + manifest.addRepresentationsToAvoid(content); } handleMediaSourceReload({ timeOffset: 0, diff --git a/src/core/stream/adaptation/adaptation_stream.ts b/src/core/stream/adaptation/adaptation_stream.ts index fcc479f749..369dffa798 100644 --- a/src/core/stream/adaptation/adaptation_stream.ts +++ b/src/core/stream/adaptation/adaptation_stream.ts @@ -161,7 +161,7 @@ export default function AdaptationStream( // NOTE: We expect that the rest of the RxPlayer code is already handling // cases where the list of playable `Representation` changes: - // decipherability updates, `Representation` deprecation etc. + // decipherability updates, "`Representation` avoidance" etc. const newRepresentations = getRepresentationList( content.adaptation.representations, newRepIds, @@ -547,13 +547,13 @@ function getRepresentationList( (r) => arrayIncludes(authorizedRepIds, r.id) && r.decipherable !== false && - !r.deprecated && + !r.shouldBeAvoided && r.isSupported !== false, ); if (filteredRepresentations.length > 0) { return filteredRepresentations; } - // Retry without deprecated `Representation` + // Retry without "`Representation` avoidance" return availableRepresentations.filter( (r) => arrayIncludes(authorizedRepIds, r.id) && diff --git a/src/main_thread/api/option_utils.ts b/src/main_thread/api/option_utils.ts index faf605a666..c1832d3b8b 100644 --- a/src/main_thread/api/option_utils.ts +++ b/src/main_thread/api/option_utils.ts @@ -112,7 +112,7 @@ interface IParsedLoadVideoOptionsBase { cmcd: ICmcdOptions | undefined; /** @see ILoadVideoOptions.experimentalOptions */ experimentalOptions: { - enableRepresentationDeprecation: boolean; + enableRepresentationAvoidance: boolean; }; __priv_manifestUpdateUrl?: string | undefined; __priv_patchLastSegmentInSidx?: boolean | undefined; @@ -488,8 +488,8 @@ function parseLoadVideoOptions(options: ILoadVideoOptions): IParsedLoadVideoOpti url, cmcd: options.cmcd, experimentalOptions: { - enableRepresentationDeprecation: - options.experimentalOptions?.enableRepresentationDeprecation === true, + enableRepresentationAvoidance: + options.experimentalOptions?.enableRepresentationAvoidance === true, }, }; } diff --git a/src/main_thread/api/public_api.ts b/src/main_thread/api/public_api.ts index bedbfe4bf0..4bffea993e 100644 --- a/src/main_thread/api/public_api.ts +++ b/src/main_thread/api/public_api.ts @@ -936,8 +936,8 @@ class Player extends EventEmitter { autoPlay, bufferOptions, cmcd, - enableRepresentationDeprecation: - experimentalOptions.enableRepresentationDeprecation, + enableRepresentationAvoidance: + experimentalOptions.enableRepresentationAvoidance, keySystems, lowLatencyMode, transport: transportPipelines, @@ -980,8 +980,8 @@ class Player extends EventEmitter { autoPlay, bufferOptions, cmcd, - enableRepresentationDeprecation: - experimentalOptions.enableRepresentationDeprecation, + enableRepresentationAvoidance: + experimentalOptions.enableRepresentationAvoidance, keySystems, lowLatencyMode, transportOptions, diff --git a/src/main_thread/init/media_source_content_initializer.ts b/src/main_thread/init/media_source_content_initializer.ts index cb8ca676fe..644cce12e7 100644 --- a/src/main_thread/init/media_source_content_initializer.ts +++ b/src/main_thread/init/media_source_content_initializer.ts @@ -730,10 +730,10 @@ export default class MediaSourceContentInitializer extends ContentInitializer { playbackObserver.setCurrentTime(wantedSeekingTime); break; } - case "deprecate-representations": { + case "avoid-representations": { const contents = freezeResolution.value; - if (this._initSettings.enableRepresentationDeprecation) { - manifest.deprecateRepresentations(contents); + if (this._initSettings.enableRepresentationAvoidance) { + manifest.addRepresentationsToAvoid(contents); } triggerReload(); break; @@ -1212,11 +1212,11 @@ export interface IInitializeArguments { */ cmcd?: ICmcdOptions | undefined; /** - * If `true`, the RxPlayer can enable its "Representation deprecation" + * If `true`, the RxPlayer can enable its "Representation avoidance" * mechanism, where it avoid loading Representation that it suspect * have issues being decoded on the current device. */ - enableRepresentationDeprecation: boolean; + enableRepresentationAvoidance: boolean; /** Every encryption configuration set. */ keySystems: IKeySystemOption[]; /** `true` to play low-latency contents optimally. */ diff --git a/src/main_thread/init/multi_thread_content_initializer.ts b/src/main_thread/init/multi_thread_content_initializer.ts index 1de34800e8..d4a93a907d 100644 --- a/src/main_thread/init/multi_thread_content_initializer.ts +++ b/src/main_thread/init/multi_thread_content_initializer.ts @@ -170,7 +170,7 @@ export default class MultiThreadContentInitializer extends ContentInitializer { value: { contentId, cmcd: this._settings.cmcd, - enableRepresentationDeprecation: this._settings.enableRepresentationDeprecation, + enableRepresentationAvoidance: this._settings.enableRepresentationAvoidance, url: this._settings.url, hasText: this._hasTextBufferFeature(), transportOptions, @@ -1897,11 +1897,11 @@ export interface IInitializeArguments { */ cmcd?: ICmcdOptions | undefined; /** - * If `true`, the RxPlayer can enable its "Representation deprecation" + * If `true`, the RxPlayer can enable its "Representation avoidance" * mechanism, where it avoid loading Representation that it suspect * have issues being decoded on the current device. */ - enableRepresentationDeprecation: boolean; + enableRepresentationAvoidance: boolean; /** Every encryption configuration set. */ keySystems: IKeySystemOption[]; /** `true` to play low-latency contents optimally. */ diff --git a/src/manifest/classes/manifest.ts b/src/manifest/classes/manifest.ts index 37a25cd3c6..cdc8ad6431 100644 --- a/src/manifest/classes/manifest.ts +++ b/src/manifest/classes/manifest.ts @@ -79,10 +79,10 @@ export interface IManifestEvents { /** Some Representation's support status has been updated */ supportUpdate: null; /** - * Some `Representation` have been "deprecated", meaning we should avoid - * playing them. + * Some `Representation`'s avoidance status has been updated, meaning that we + * might have to avoid playing them due to playback issues. */ - deprecationUpdate: IUpdatedRepresentationInfo[]; + representationAvoidanceUpdate: IUpdatedRepresentationInfo[]; } /** @@ -547,11 +547,11 @@ export default class Manifest } /** - * Mark some `Representation` as being "deprecated", meaning we should not - * attempt to load it anymore, unless forced. + * Indicate that some `Representation` needs to be avoided due to playback + * issues. * @param {Array.} items */ - public deprecateRepresentations( + public addRepresentationsToAvoid( items: Array<{ period: Period; adaptation: Adaptation; @@ -572,7 +572,7 @@ export default class Manifest if (representation === undefined) { continue; } - representation.deprecated = true; + representation.shouldBeAvoided = true; updates.push({ manifest: this, period, @@ -581,7 +581,7 @@ export default class Manifest }); } if (updates.length > 0) { - this.trigger("deprecationUpdate", updates); + this.trigger("representationAvoidanceUpdate", updates); } } diff --git a/src/manifest/classes/representation.ts b/src/manifest/classes/representation.ts index 5f2e77bc04..a2ab691d08 100644 --- a/src/manifest/classes/representation.ts +++ b/src/manifest/classes/representation.ts @@ -120,7 +120,7 @@ class Representation implements IRepresentationMetadata { * instanciated `Representation`, you are supposed to rely on * `Manifest` methods for this. */ - public deprecated: boolean; + public shouldBeAvoided: boolean; /** * @param {Object} args @@ -133,7 +133,7 @@ class Representation implements IRepresentationMetadata { ) { this.id = args.id; this.uniqueId = generateRepresentationUniqueId(); - this.deprecated = false; + this.shouldBeAvoided = false; this.bitrate = args.bitrate; this.codecs = []; this.trackType = trackType; diff --git a/src/multithread_types.ts b/src/multithread_types.ts index 05bae4cf7e..2bb303ca6a 100644 --- a/src/multithread_types.ts +++ b/src/multithread_types.ts @@ -109,11 +109,11 @@ export interface IContentInitializationData { */ cmcd?: ICmcdOptions | undefined; /** - * If `true`, the RxPlayer can enable its "Representation deprecation" + * If `true`, the RxPlayer can enable its "Representation avoidance" * mechanism, where it avoid loading Representation that it suspect * have issues being decoded on the current device. */ - enableRepresentationDeprecation: boolean; + enableRepresentationAvoidance: boolean; /** * URL at which the content's Manifest is accessible. * `undefined` if unknown. diff --git a/src/public_types.ts b/src/public_types.ts index f55b1c4731..317a3248c7 100644 --- a/src/public_types.ts +++ b/src/public_types.ts @@ -192,11 +192,11 @@ export interface ILoadVideoOptions { experimentalOptions?: | { /** - * If `true`, the RxPlayer can enable its "Representation deprecation" + * If `true`, the RxPlayer can enable its "Representation avoidance" * mechanism, where it avoid loading Representation that it suspect * have issues being decoded on the current device. */ - enableRepresentationDeprecation: boolean | undefined; + enableRepresentationAvoidance: boolean | undefined; } | undefined; }