diff --git a/doc/api/Loading_a_Content.md b/doc/api/Loading_a_Content.md index 74fe27f009f..fa17b15e940 100644 --- a/doc/api/Loading_a_Content.md +++ b/doc/api/Loading_a_Content.md @@ -531,32 +531,6 @@ considered stable: a complete explanation, you can look at the [corresponding chapter of the low-latency documentation](./Miscellaneous/Low_Latency.md#note-time-sync). -- **aggressiveMode** (`boolean|undefined`): - - If set to true, we will try to download segments very early, even if we are - not sure they had time to be completely generated. - - For the moment, this mode has only an effect for all Smooth contents and - some DASH contents relying on a number-based SegmentTemplate segment - indexing scheme. - - The upside is that you might have the last segments sooner. - The downside is that requests for segments which did not had time to - generate might trigger a `NetworkError`. Depending on your other settings - (especially the `networkConfig` loadVideo options), those errors might just - be sent as warnings and the corresponding requests be retried. - - Example: - - ```js - rxPlayer.loadVideo({ - // ... - transportOptions: { - aggressiveMode: true, - }, - }); - ``` - - **referenceDateTime** (`number|undefined`): Only useful for live contents. This is the default amount of time, in diff --git a/doc/reference/API_Reference.md b/doc/reference/API_Reference.md index da6d17a0d75..25a6a906ac5 100644 --- a/doc/reference/API_Reference.md +++ b/doc/reference/API_Reference.md @@ -161,9 +161,6 @@ properties, methods, events and so on. - [`transportOptions.serverSyncInfos`](../api/Loading_a_Content.md#transportoptions): Provide time synchronization mechanism between the client and server. - - [`transportOptions.aggressiveMode`](../api/Loading_a_Content.md#transportoptions): - Allows to ask to download the segments early. - - [`transportOptions.referenceDateTime`](../api/Loading_a_Content.md#transportoptions): Default offset to add to the segment's time to obtain a live time. This is in most cases not needed. diff --git a/src/core/api/option_utils.ts b/src/core/api/option_utils.ts index 9aa83b7a9ce..c5f45434a5b 100644 --- a/src/core/api/option_utils.ts +++ b/src/core/api/option_utils.ts @@ -55,8 +55,6 @@ interface IServerSyncInfos { /** Value of the `transportOptions` option of the `loadVideo` method. */ export interface ITransportOptions { - /** Whether we can perform request for segments in advance. */ - aggressiveMode? : boolean; /** * Whether we should check that an obtain segment is truncated and retry the * request if that's the case. diff --git a/src/parsers/manifest/dash/common/indexes/template.ts b/src/parsers/manifest/dash/common/indexes/template.ts index a989c3d21da..d8abd365519 100644 --- a/src/parsers/manifest/dash/common/indexes/template.ts +++ b/src/parsers/manifest/dash/common/indexes/template.ts @@ -112,7 +112,6 @@ export interface ITemplateIndexIndexArgument { /** Aditional context needed by a SegmentTemplate RepresentationIndex. */ export interface ITemplateIndexContextArgument { - aggressiveMode : boolean; /** Minimum availabilityTimeOffset concerning the segments of this Representation. */ availabilityTimeOffset : number; /** Allows to obtain the minimum and maximum positions of a content. */ @@ -141,11 +140,6 @@ export interface ITemplateIndexContextArgument { export default class TemplateRepresentationIndex implements IRepresentationIndex { /** Underlying structure to retrieve segment information. */ private _index : ITemplateIndex; - /** - * Whether the "aggressiveMode" is enabled. If enabled, segments can be - * requested in advance. - */ - private _aggressiveMode : boolean; /** Retrieve the maximum and minimum position of the whole content. */ private _manifestBoundsCalculator : ManifestBoundsCalculator; /** Absolute start of the Period, in seconds. */ @@ -167,8 +161,7 @@ export default class TemplateRepresentationIndex implements IRepresentationIndex index : ITemplateIndexIndexArgument, context : ITemplateIndexContextArgument ) { - const { aggressiveMode, - availabilityTimeOffset, + const { availabilityTimeOffset, manifestBoundsCalculator, isDynamic, periodEnd, @@ -187,7 +180,6 @@ export default class TemplateRepresentationIndex implements IRepresentationIndex this._availabilityTimeOffset = availabilityTimeOffset + minBaseUrlAto; this._manifestBoundsCalculator = manifestBoundsCalculator; - this._aggressiveMode = aggressiveMode; const presentationTimeOffset = index.presentationTimeOffset != null ? index.presentationTimeOffset : 0; @@ -435,7 +427,6 @@ export default class TemplateRepresentationIndex implements IRepresentationIndex */ _replace(newIndex : TemplateRepresentationIndex) : void { this._index = newIndex._index; - this._aggressiveMode = newIndex._aggressiveMode; this._isDynamic = newIndex._isDynamic; this._periodStart = newIndex._periodStart; this._scaledPeriodEnd = newIndex._scaledPeriodEnd; @@ -501,11 +492,9 @@ export default class TemplateRepresentationIndex implements IRepresentationIndex if (lastPos === undefined) { return undefined; } - const agressiveModeOffset = this._aggressiveMode ? (duration / timescale) : - 0; - if (this._scaledPeriodEnd != null && + if (this._scaledPeriodEnd !== undefined && this._scaledPeriodEnd < - (lastPos + agressiveModeOffset - this._periodStart) * this._index.timescale) { + (lastPos - this._periodStart) * this._index.timescale) { if (this._scaledPeriodEnd < duration) { return null; } @@ -523,8 +512,8 @@ export default class TemplateRepresentationIndex implements IRepresentationIndex } const availabilityTimeOffset = - ((this._availabilityTimeOffset !== undefined ? this._availabilityTimeOffset : 0) + - agressiveModeOffset) * timescale; + ((this._availabilityTimeOffset !== undefined ? this._availabilityTimeOffset : 0)) + * timescale; const numberOfSegmentsAvailable = Math.floor((scaledLastPosition + availabilityTimeOffset) / duration); diff --git a/src/parsers/manifest/dash/common/parse_adaptation_sets.ts b/src/parsers/manifest/dash/common/parse_adaptation_sets.ts index 9b1d9e002a7..8b429ef505d 100644 --- a/src/parsers/manifest/dash/common/parse_adaptation_sets.ts +++ b/src/parsers/manifest/dash/common/parse_adaptation_sets.ts @@ -308,7 +308,6 @@ export default function parseAdaptationSets( } const reprCtxt : IRepresentationContext = { - aggressiveMode: context.aggressiveMode, availabilityTimeComplete, availabilityTimeOffset, baseURLs: resolveBaseURLs(context.baseURLs, adaptationChildren.baseURLs), diff --git a/src/parsers/manifest/dash/common/parse_mpd.ts b/src/parsers/manifest/dash/common/parse_mpd.ts index 826530b1b78..3933e389041 100644 --- a/src/parsers/manifest/dash/common/parse_mpd.ts +++ b/src/parsers/manifest/dash/common/parse_mpd.ts @@ -40,8 +40,6 @@ import resolveBaseURLs, { /** Possible options for `parseMPD`. */ export interface IMPDParserArguments { - /** Whether we should request new segments even if they are not yet finished. */ - aggressiveMode : boolean; /** * If set, offset to add to `performance.now()` to obtain the current server's * time. @@ -252,8 +250,7 @@ function parseCompleteIntermediateRepresentation( const { externalClockOffset: clockOffset, unsafelyBaseOnPreviousManifest } = args; - const manifestInfos = { aggressiveMode: args.aggressiveMode, - availabilityStartTime, + const manifestInfos = { availabilityStartTime, baseURLs: mpdBaseUrls, clockOffset, duration: rootAttributes.duration, diff --git a/src/parsers/manifest/dash/common/parse_periods.ts b/src/parsers/manifest/dash/common/parse_periods.ts index af9cef40cec..525d547092c 100644 --- a/src/parsers/manifest/dash/common/parse_periods.ts +++ b/src/parsers/manifest/dash/common/parse_periods.ts @@ -110,10 +110,9 @@ export default function parsePeriods( const availabilityTimeComplete = periodIR.attributes.availabilityTimeComplete ?? true; const availabilityTimeOffset = periodIR.attributes.availabilityTimeOffset ?? 0; - const { aggressiveMode, manifestProfiles } = context; + const { manifestProfiles } = context; const { segmentTemplate } = periodIR.children; - const adapCtxt : IAdaptationSetContext = { aggressiveMode, - availabilityTimeComplete, + const adapCtxt : IAdaptationSetContext = { availabilityTimeComplete, availabilityTimeOffset, baseURLs: periodBaseURLs, manifestBoundsCalculator, diff --git a/src/parsers/manifest/dash/common/parse_representation_index.ts b/src/parsers/manifest/dash/common/parse_representation_index.ts index 0bd6a561dc3..d1095759a5b 100644 --- a/src/parsers/manifest/dash/common/parse_representation_index.ts +++ b/src/parsers/manifest/dash/common/parse_representation_index.ts @@ -50,8 +50,7 @@ export default function parseRepresentationIndex( ) : IRepresentationIndex { const representationBaseURLs = resolveBaseURLs(context.baseURLs, representation.children.baseURLs); - const { aggressiveMode, - availabilityTimeOffset, + const { availabilityTimeOffset, manifestBoundsCalculator, isDynamic, end: periodEnd, @@ -69,8 +68,7 @@ export default function parseRepresentationIndex( return inbandEventStreams .some(({ schemeIdUri }) => schemeIdUri === inbandEvent.schemeIdUri); }; - const reprIndexCtxt = { aggressiveMode, - availabilityTimeComplete: true, + const reprIndexCtxt = { availabilityTimeComplete: true, availabilityTimeOffset, unsafelyBaseOnPreviousRepresentation, isEMSGWhitelisted, @@ -138,8 +136,6 @@ export default function parseRepresentationIndex( export interface IRepresentationIndexContext { /** Parsed AdaptationSet which contains the Representation. */ adaptation : IAdaptationSetIntermediateRepresentation; - /** Whether we should request new segments even if they are not yet finished. */ - aggressiveMode : boolean; /** If false, declared segments in the MPD might still be not completely generated. */ availabilityTimeComplete : boolean; /** availability time offset of the concerned Adaptation. */ diff --git a/src/parsers/manifest/dash/js-parser/__tests__/parse_from_document.test.ts b/src/parsers/manifest/dash/js-parser/__tests__/parse_from_document.test.ts index b8da640216c..dfcc0dd3fc0 100644 --- a/src/parsers/manifest/dash/js-parser/__tests__/parse_from_document.test.ts +++ b/src/parsers/manifest/dash/js-parser/__tests__/parse_from_document.test.ts @@ -28,7 +28,6 @@ describe("parseFromDocument", () => { expect(function() { parseFromDocument(doc, { url: "", - aggressiveMode: false, externalClockOffset: 10, unsafelyBaseOnPreviousManifest: null, }); @@ -37,7 +36,6 @@ describe("parseFromDocument", () => { const prevManifest = {} as unknown as Manifest; parseFromDocument(doc, { url: "", - aggressiveMode: false, unsafelyBaseOnPreviousManifest: prevManifest, }); }).toThrow("document root should be MPD"); diff --git a/src/parsers/manifest/smooth/create_parser.ts b/src/parsers/manifest/smooth/create_parser.ts index a4dbd2e3484..b2bc8db5641 100644 --- a/src/parsers/manifest/smooth/create_parser.ts +++ b/src/parsers/manifest/smooth/create_parser.ts @@ -53,13 +53,6 @@ import parseBoolean from "./utils/parseBoolean"; import reduceChildren from "./utils/reduceChildren"; import { replaceRepresentationSmoothTokens } from "./utils/tokens"; -/** - * Default value for the aggressive `mode`. - * In this mode, segments will be returned even if we're not sure those had time - * to be generated. - */ -const DEFAULT_AGGRESSIVE_MODE = false; - interface IAdaptationParserArguments { root : Element; rootURL : string; timescale : number; @@ -87,7 +80,6 @@ const MIME_TYPES : Partial> = { }; export interface IHSSParserConfiguration { - aggressiveMode? : boolean | undefined; suggestedPresentationDelay? : number | undefined; referenceDateTime? : number | undefined; minRepresentationBitrate? : number | undefined; @@ -395,11 +387,7 @@ function createSmoothStreamingParser( keyId: firstProtection.keyId, } : undefined }; - const aggressiveMode = parserOptions.aggressiveMode == null ? - DEFAULT_AGGRESSIVE_MODE : - parserOptions.aggressiveMode; - const reprIndex = new RepresentationIndex({ aggressiveMode, - isLive, + const reprIndex = new RepresentationIndex({ isLive, sharedSmoothTimeline, media, segmentPrivateInfos }); diff --git a/src/parsers/manifest/smooth/representation_index.ts b/src/parsers/manifest/smooth/representation_index.ts index 66f9e7e6108..5ab5c6eda03 100644 --- a/src/parsers/manifest/smooth/representation_index.ts +++ b/src/parsers/manifest/smooth/representation_index.ts @@ -104,15 +104,6 @@ function calculateRepeat( * context the segments are in. */ export interface ISmoothRepresentationIndexContextInformation { - /** - * if `true`, the `SmoothRepresentationIndex` will return segments even if - * we're not sure they had time to be generated on the server side. - * - * TODO(Paul B.) This is a somewhat ugly option, only here for very specific - * Canal+ use-cases for now (most of all for Peer-to-Peer efficiency), - * scheduled to be removed in a next major version. - */ - aggressiveMode : boolean; /** * If `true` the corresponding Smooth Manifest was announced as a live * content. @@ -167,16 +158,6 @@ export default class SmoothRepresentationIndex implements IRepresentationIndex { width? : number | undefined; protection? : { keyId : Uint8Array } | undefined; }; - /** - * if `true`, this class will return segments even if we're not sure they had - * time to be generated on the server side. - * - * This is a somewhat ugly option, only here for very specific Canal+ - * use-cases for now (most of all for Peer-to-Peer efficiency), scheduled to - * be removed in a next major version. - */ - private _isAggressiveMode : boolean; - /** * Value only calculated for live contents. * @@ -221,8 +202,7 @@ export default class SmoothRepresentationIndex implements IRepresentationIndex { constructor( options : ISmoothRepresentationIndexContextInformation ) { - const { aggressiveMode, - isLive, + const { isLive, segmentPrivateInfos, media, sharedSmoothTimeline } = options; @@ -238,7 +218,6 @@ export default class SmoothRepresentationIndex implements IRepresentationIndex { width: segmentPrivateInfos.width, protection: segmentPrivateInfos.protection }; - this._isAggressiveMode = aggressiveMode; this._isLive = isLive; this._media = media; @@ -280,7 +259,6 @@ export default class SmoothRepresentationIndex implements IRepresentationIndex { const { timescale, timeline } = this._sharedSmoothTimeline; const { up, to } = normalizeRange(timescale, from, dur); const media = this._media; - const isAggressive = this._isAggressiveMode; let currentNumber : number|undefined; const segments : ISegment[] = []; @@ -297,8 +275,7 @@ export default class SmoothRepresentationIndex implements IRepresentationIndex { const repeat = calculateRepeat(segmentRange, timeline[i + 1]); let segmentNumberInCurrentRange = getSegmentNumber(start, up, duration); let segmentTime = start + segmentNumberInCurrentRange * duration; - const timeToAddToCheckMaxPosition = isAggressive ? 0 : - duration; + const timeToAddToCheckMaxPosition = duration; while (segmentTime < to && segmentNumberInCurrentRange <= repeat && (maxPosition === undefined || @@ -397,7 +374,6 @@ export default class SmoothRepresentationIndex implements IRepresentationIndex { /** * Returns last position available in the index. - * @param {Object} index * @returns {Number} */ getLastPosition() : number|undefined { @@ -415,8 +391,7 @@ export default class SmoothRepresentationIndex implements IRepresentationIndex { const { start, duration, repeatCount } = timelineElt; for (let j = repeatCount; j >= 0; j--) { const end = start + (duration * (j + 1)); - const positionToReach = this._isAggressiveMode ? end - duration : - end; + const positionToReach = end; if (positionToReach <= timescaledNow - this._scaledLiveGap) { return end / timescale; } diff --git a/src/transports/dash/manifest_parser.ts b/src/transports/dash/manifest_parser.ts index 3ed58d93f9a..63317a9b1b0 100644 --- a/src/transports/dash/manifest_parser.ts +++ b/src/transports/dash/manifest_parser.ts @@ -47,8 +47,7 @@ export default function generateManifestParser( scheduleRequest : IManifestParserRequestScheduler ) => IManifestParserResult | Promise { - const { aggressiveMode, - referenceDateTime } = options; + const { referenceDateTime } = options; const serverTimeOffset = options.serverSyncInfos !== undefined ? options.serverSyncInfos.serverTimestamp - options.serverSyncInfos.clientTime : undefined; @@ -63,13 +62,11 @@ export default function generateManifestParser( const argClockOffset = parserOptions.externalClockOffset; const url = manifestData.url ?? parserOptions.originalUrl; - const optAggressiveMode = aggressiveMode === true; const externalClockOffset = serverTimeOffset ?? argClockOffset; const unsafelyBaseOnPreviousManifest = parserOptions.unsafeMode ? parserOptions.previousManifest : null; - const dashParserOpts = { aggressiveMode: optAggressiveMode, - unsafelyBaseOnPreviousManifest, + const dashParserOpts = { unsafelyBaseOnPreviousManifest, url, referenceDateTime, externalClockOffset }; diff --git a/src/transports/types.ts b/src/transports/types.ts index b9ccb191d27..af769800538 100644 --- a/src/transports/types.ts +++ b/src/transports/types.ts @@ -424,7 +424,6 @@ interface IServerSyncInfos { serverTimestamp : number; clientTime : number; } export interface ITransportOptions { - aggressiveMode? : boolean | undefined; checkMediaSegmentIntegrity? : boolean | undefined; lowLatencyMode : boolean; manifestLoader?: ICustomManifestLoader | undefined;