Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/core/fetchers/segment/segment_fetcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ export default function createSegmentFetcher<TLoadedFormat, TSegmentDataType>({
requestOptions.requestTimeout < 0 ? undefined : requestOptions.requestTimeout,
connectionTimeout,
cmcdPayload: undefined,
requestData: undefined,
};

/**
Expand Down Expand Up @@ -286,6 +287,7 @@ export default function createSegmentFetcher<TLoadedFormat, TSegmentDataType>({
): ReturnType<ISegmentLoader<TLoadedFormat>> {
pipelineRequestOptions.cmcdPayload =
cmcdDataBuilder?.getCmcdDataForSegmentRequest(content);
pipelineRequestOptions.requestData = content.representation.requestData;
return loadSegment(
cdnMetadata,
context,
Expand Down
1 change: 1 addition & 0 deletions src/core/fetchers/thumbnails/thumbnail_fetcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ export default function createThumbnailFetcher(
requestOptions.requestTimeout < 0 ? undefined : requestOptions.requestTimeout,
connectionTimeout,
cmcdPayload: undefined,
requestData: thumbnailTrack.requestData,
};

/**
Expand Down
4 changes: 4 additions & 0 deletions src/manifest/classes/period.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import type {
IManifestStreamEvent,
IParsedAdaptations,
IParsedPeriod,
IParsedThumbnailTrack,
} from "../../parsers/manifest/index.ts";
import type { ITrackType, IRepresentationFilter } from "../../public_types.ts";
import arrayFind from "../../utils/array_find.ts";
Expand Down Expand Up @@ -97,6 +98,7 @@ export default class Period implements IPeriodMetadata {
mimeType: thumbnailTrack.mimeType,
index: thumbnailTrack.index,
cdnMetadata: thumbnailTrack.cdnMetadata,
requestData: thumbnailTrack.requestData,
height: thumbnailTrack.height,
width: thumbnailTrack.width,
horizontalTiles: thumbnailTrack.horizontalTiles,
Expand Down Expand Up @@ -264,6 +266,8 @@ export interface IThumbnailTrack {
mimeType: string;
/** CDN(s) on which the thumbnails may be loaded. */
cdnMetadata: ICdnMetadata[] | null;
/** Transport-specific data used when requesting this track's resources. */
requestData?: IParsedThumbnailTrack["requestData"];
/**
* A loaded thumbnail's height in pixels. Note that there can be multiple actual
* thumbnails per loaded thumbnail resource (see `horizontalTiles` and
Expand Down
3 changes: 3 additions & 0 deletions src/manifest/classes/representation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ class Representation implements IRepresentationMetadata {
* @see IRepresentationMetadata.bitrate
*/
public bitrate: number;
/** Transport-specific data used when requesting this Representation's resources. */
public requestData?: IParsedRepresentation["requestData"];
/**
* @see IRepresentationMetadata.frameRate
*/
Expand Down Expand Up @@ -143,6 +145,7 @@ class Representation implements IRepresentationMetadata {
this.uniqueId = generateRepresentationUniqueId();
this.shouldBeAvoided = false;
this.bitrate = args.bitrate;
this.requestData = args.requestData;
this.baseCodecs = [];
this.trackType = trackType;

Expand Down
2 changes: 2 additions & 0 deletions src/manifest/classes/update_period_in_place.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ export default function updatePeriodInPlace(
oldThumbnailTrack.end = newThumbnailTrack.end;
oldThumbnailTrack.tileDuration = newThumbnailTrack.tileDuration;
oldThumbnailTrack.cdnMetadata = newThumbnailTrack.cdnMetadata;
oldThumbnailTrack.requestData = newThumbnailTrack.requestData;
if (updateType === MANIFEST_UPDATE_TYPE.Full) {
oldThumbnailTrack.index._replace(newThumbnailTrack.index);
} else {
Expand Down Expand Up @@ -177,6 +178,7 @@ export default function updatePeriodInPlace(
const [newRepresentation] = newRepresentations.splice(newRepresentationIdx, 1);
updatedRepresentations.push(oldRepresentation.getMetadataSnapshot());
oldRepresentation.cdnMetadata = newRepresentation.cdnMetadata;
oldRepresentation.requestData = newRepresentation.requestData;
if (updateType === MANIFEST_UPDATE_TYPE.Full) {
oldRepresentation.index._replace(newRepresentation.index);
} else {
Expand Down
12 changes: 12 additions & 0 deletions src/parsers/manifest/dash/common/parse_adaptation_sets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ import inferAdaptationType, {
} from "./infer_adaptation_type.ts";
import type { IRepresentationContext } from "./parse_representations.ts";
import parseRepresentations from "./parse_representations.ts";
import { parseUrlQueryInfo } from "./parse_url_query_info.ts";
import resolveBaseURLs from "./resolve_base_urls.ts";

/**
Expand Down Expand Up @@ -326,6 +327,11 @@ export default function parseAdaptationSets(
);
}

const adaptationUrlQueryInfo = parseUrlQueryInfo(
adaptationChildren.EssentialProperty,
adaptationChildren.SupplementalProperty,
context.mpdUrl,
);
const reprCtxt: IRepresentationContext = {
availabilityTimeComplete,
availabilityTimeOffset,
Expand All @@ -336,10 +342,15 @@ export default function parseAdaptationSets(
isDynamic: context.isDynamic,
isLastPeriod: context.isLastPeriod,
manifestProfiles: context.manifestProfiles,
mpdUrl: context.mpdUrl,
parentSegmentTemplates,
receivedTime: context.receivedTime,
start: context.start,
unsafelyBaseOnPreviousAdaptation: null,
urlQueryInfo:
adaptationUrlQueryInfo === undefined
? context.urlQueryInfo
: context.urlQueryInfo.concat(adaptationUrlQueryInfo),
};

const trickModeProperty = Array.isArray(essentialProperties)
Expand Down Expand Up @@ -595,6 +606,7 @@ function createThumbnailTracks(
tracks.push({
id: representation.id,
cdnMetadata: representation.cdnMetadata,
requestData: representation.requestData,
index: representation.index,
mimeType: representation.mimeType,
height: representation.height,
Expand Down
8 changes: 8 additions & 0 deletions src/parsers/manifest/dash/common/parse_mpd.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ import ManifestBoundsCalculator from "./manifest_bounds_calculator.ts";
import parseAvailabilityStartTime from "./parse_availability_start_time.ts";
import type { IXLinkInfos } from "./parse_periods.ts";
import parsePeriods from "./parse_periods.ts";
import { parseUrlQueryInfo } from "./parse_url_query_info.ts";
import type { IResolvedBaseUrl } from "./resolve_base_urls.ts";
import resolveBaseURLs from "./resolve_base_urls.ts";

Expand Down Expand Up @@ -275,6 +276,11 @@ function parseCompleteIntermediateRepresentation(
});
const contentProtectionParser = new ContentProtectionParser();
contentProtectionParser.addReferences(rootChildren.ContentProtection);
const mpdUrlQueryInfo = parseUrlQueryInfo(
rootChildren.EssentialProperty,
rootChildren.SupplementalProperty,
args.url,
);
const manifestInfos = {
availabilityStartTime,
baseURLs: mpdBaseUrls,
Expand All @@ -284,7 +290,9 @@ function parseCompleteIntermediateRepresentation(
isDynamic,
manifestBoundsCalculator,
manifestProfiles: mpdIR.attributes.profiles,
mpdUrl: args.url,
receivedTime: args.manifestReceivedTime,
urlQueryInfo: mpdUrlQueryInfo === undefined ? [] : [mpdUrlQueryInfo],
unsafelyBaseOnPreviousManifest,
xlinkInfos,
xmlNamespaces: mpdIR.attributes.namespaces,
Expand Down
16 changes: 16 additions & 0 deletions src/parsers/manifest/dash/common/parse_periods.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ import flattenOverlappingPeriods from "./flatten_overlapping_periods.ts";
import getPeriodsTimeInformation from "./get_periods_time_infos.ts";
import type { IAdaptationSetContext } from "./parse_adaptation_sets.ts";
import parseAdaptationSets from "./parse_adaptation_sets.ts";
import type { IDashUrlQueryInfo } from "./parse_url_query_info.ts";
import { parseUrlQueryInfo } from "./parse_url_query_info.ts";
import resolveBaseURLs from "./resolve_base_urls.ts";

const generatePeriodID = idGenerator();
Expand Down Expand Up @@ -113,6 +115,11 @@ export default function parsePeriods(
const segmentTemplate =
periodIR.children.SegmentTemplate[periodIR.children.SegmentTemplate.length - 1];
contentProtectionParser.addReferences(periodIR.children.ContentProtection);
const periodUrlQueryInfo = parseUrlQueryInfo(
[],
periodIR.children.SupplementalProperty,
context.mpdUrl,
);
const adapCtxt: IAdaptationSetContext = {
availabilityTimeComplete,
availabilityTimeOffset,
Expand All @@ -123,10 +130,15 @@ export default function parsePeriods(
isDynamic,
isLastPeriod,
manifestProfiles,
mpdUrl: context.mpdUrl,
receivedTime,
segmentTemplate,
start: periodStart,
unsafelyBaseOnPreviousPeriod,
urlQueryInfo:
periodUrlQueryInfo === undefined
? context.urlQueryInfo
: context.urlQueryInfo.concat(periodUrlQueryInfo),
};
const { adaptations, thumbnailTracks } = parseAdaptationSets(
periodIR.children.AdaptationSet,
Expand Down Expand Up @@ -359,6 +371,10 @@ export interface IPeriodContext extends IInheritedAdaptationContext {
clockOffset?: number | undefined;
/** Duration (mediaPresentationDuration) of the whole MPD, in seconds. */
duration?: number | undefined;
/** URL of the MPD from which Annex I parameters may be inherited. */
mpdUrl?: string | undefined;
/** Annex I URL query instructions inherited from the MPD level. */
urlQueryInfo: IDashUrlQueryInfo[];
/**
* The parser should take this Manifest - which is a previously parsed
* Manifest for the same dynamic content - as a base to speed-up the parsing
Expand Down
42 changes: 42 additions & 0 deletions src/parsers/manifest/dash/common/parse_representations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ import { convertSupplementalCodecsToRFC6381 } from "./convert_supplemental_codec
import { getWEBMHDRInformation } from "./get_hdr_information.ts";
import type { IRepresentationIndexContext } from "./parse_representation_index.ts";
import parseRepresentationIndex from "./parse_representation_index.ts";
import type { IDashUrlQueryInfo } from "./parse_url_query_info.ts";
import { combineUrlQueryInfo, parseUrlQueryInfo } from "./parse_url_query_info.ts";
import resolveBaseURLs from "./resolve_base_urls.ts";

/**
Expand Down Expand Up @@ -209,12 +211,48 @@ export default function parseRepresentations(
}));

// Construct Representation Base
const representationUrlQueryInfo = parseUrlQueryInfo(
representation.children.EssentialProperty,
representation.children.SupplementalProperty,
context.mpdUrl,
);
const urlQueryInfo =
representationUrlQueryInfo === undefined
? context.urlQueryInfo
: context.urlQueryInfo.concat(representationUrlQueryInfo);
const segmentUrlQuery = combineUrlQueryInfo(
urlQueryInfo.filter((info) => info.appliesTo.segment),
);
const initUrlQuery = combineUrlQueryInfo(
urlQueryInfo.filter((info) => info.appliesTo.init),
);
const parsedRepresentation: IParsedRepresentation = {
bitrate: representationBitrate,
cdnMetadata,
index: representationIndex,
id: representationID,
};
if (segmentUrlQuery.length > 0 || initUrlQuery.length > 0) {
parsedRepresentation.requestData = {};
if (segmentUrlQuery.length > 0) {
parsedRepresentation.requestData.segment = {
urlQuery: segmentUrlQuery.map((info) => ({
value: info.queryString,
sameOriginOnly: info.sameOriginOnly,
sourceUrl: info.sourceUrl,
})),
};
}
if (initUrlQuery.length > 0) {
parsedRepresentation.requestData.init = {
urlQuery: initUrlQuery.map((info) => ({
value: info.queryString,
sameOriginOnly: info.sameOriginOnly,
sourceUrl: info.sourceUrl,
})),
};
}
}

if (
representation.children.SupplementalProperty.length > 0 &&
Expand Down Expand Up @@ -300,6 +338,10 @@ export default function parseRepresentations(
export interface IRepresentationContext extends IInheritedRepresentationIndexContext {
/** Manifest DASH profiles used for signalling some features */
manifestProfiles?: string | undefined;
/** URL of the MPD from which Annex I parameters may be inherited. */
mpdUrl?: string | undefined;
/** Annex I URL query instructions inherited from upper MPD levels. */
urlQueryInfo: IDashUrlQueryInfo[];
/**
* The parser should take this Adaptation - which is from a previously parsed
* Manifest for the same dynamic content - as a base to speed-up the parsing
Expand Down
Loading
Loading