Skip to content

Commit

Permalink
Remove aggressiveMode from the transportOptions
Browse files Browse the repository at this point in the history
  • Loading branch information
peaBerberian committed Apr 14, 2022
1 parent c5958dd commit 7291c24
Show file tree
Hide file tree
Showing 13 changed files with 16 additions and 110 deletions.
26 changes: 0 additions & 26 deletions doc/api/Loading_a_Content.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 0 additions & 3 deletions doc/reference/API_Reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 0 additions & 2 deletions src/core/api/option_utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
21 changes: 5 additions & 16 deletions src/parsers/manifest/dash/common/indexes/template.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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. */
Expand Down Expand Up @@ -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. */
Expand All @@ -167,8 +161,7 @@ export default class TemplateRepresentationIndex implements IRepresentationIndex
index : ITemplateIndexIndexArgument,
context : ITemplateIndexContextArgument
) {
const { aggressiveMode,
availabilityTimeOffset,
const { availabilityTimeOffset,
manifestBoundsCalculator,
isDynamic,
periodEnd,
Expand All @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
Expand All @@ -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);
Expand Down
1 change: 0 additions & 1 deletion src/parsers/manifest/dash/common/parse_adaptation_sets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,6 @@ export default function parseAdaptationSets(
}

const reprCtxt : IRepresentationContext = {
aggressiveMode: context.aggressiveMode,
availabilityTimeComplete,
availabilityTimeOffset,
baseURLs: resolveBaseURLs(context.baseURLs, adaptationChildren.baseURLs),
Expand Down
5 changes: 1 addition & 4 deletions src/parsers/manifest/dash/common/parse_mpd.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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,
Expand Down
5 changes: 2 additions & 3 deletions src/parsers/manifest/dash/common/parse_periods.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand Down Expand Up @@ -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. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ describe("parseFromDocument", () => {
expect(function() {
parseFromDocument(doc, {
url: "",
aggressiveMode: false,
externalClockOffset: 10,
unsafelyBaseOnPreviousManifest: null,
});
Expand All @@ -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");
Expand Down
14 changes: 1 addition & 13 deletions src/parsers/manifest/smooth/create_parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -87,7 +80,6 @@ const MIME_TYPES : Partial<Record<string, string>> = {
};

export interface IHSSParserConfiguration {
aggressiveMode? : boolean | undefined;
suggestedPresentationDelay? : number | undefined;
referenceDateTime? : number | undefined;
minRepresentationBitrate? : number | undefined;
Expand Down Expand Up @@ -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 });
Expand Down
31 changes: 3 additions & 28 deletions src/parsers/manifest/smooth/representation_index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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.
*
Expand Down Expand Up @@ -221,8 +202,7 @@ export default class SmoothRepresentationIndex implements IRepresentationIndex {
constructor(
options : ISmoothRepresentationIndexContextInformation
) {
const { aggressiveMode,
isLive,
const { isLive,
segmentPrivateInfos,
media,
sharedSmoothTimeline } = options;
Expand All @@ -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;

Expand Down Expand Up @@ -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[] = [];
Expand All @@ -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 ||
Expand Down Expand Up @@ -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 {
Expand All @@ -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;
}
Expand Down
7 changes: 2 additions & 5 deletions src/transports/dash/manifest_parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,7 @@ export default function generateManifestParser(
scheduleRequest : IManifestParserRequestScheduler
) => IManifestParserResult | Promise<IManifestParserResult>
{
const { aggressiveMode,
referenceDateTime } = options;
const { referenceDateTime } = options;
const serverTimeOffset = options.serverSyncInfos !== undefined ?
options.serverSyncInfos.serverTimestamp - options.serverSyncInfos.clientTime :
undefined;
Expand All @@ -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 };
Expand Down
1 change: 0 additions & 1 deletion src/transports/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,6 @@ interface IServerSyncInfos { serverTimestamp : number;
clientTime : number; }

export interface ITransportOptions {
aggressiveMode? : boolean | undefined;
checkMediaSegmentIntegrity? : boolean | undefined;
lowLatencyMode : boolean;
manifestLoader?: ICustomManifestLoader | undefined;
Expand Down

0 comments on commit 7291c24

Please sign in to comment.