Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Improve parsing time in DASH and HLS #5261

Merged
merged 2 commits into from
Jun 7, 2023
Merged
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
11 changes: 7 additions & 4 deletions lib/dash/segment_list.js
Original file line number Diff line number Diff line change
Expand Up @@ -223,9 +223,6 @@ shaka.dash.SegmentList = class {
let prevEndTime = info.startTime;
for (let i = 0; i < max; i++) {
const segment = info.mediaSegments[i];
const mediaUri = ManifestParserUtils.resolveUris(
baseUris, [segment.mediaUri]);

const startTime = prevEndTime;
let endTime;

Expand All @@ -243,7 +240,13 @@ shaka.dash.SegmentList = class {
endTime = startTime + periodDuration;
}

const getUris = () => mediaUri;
let uris = null;
const getUris = () => {
avelad marked this conversation as resolved.
Show resolved Hide resolved
if (uris == null) {
uris = ManifestParserUtils.resolveUris(baseUris, [segment.mediaUri]);
}
return uris;
};
references.push(
new shaka.media.SegmentReference(
periodStart + startTime,
Expand Down
27 changes: 21 additions & 6 deletions lib/hls/hls_parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -2669,8 +2669,6 @@ shaka.hls.HlsParser = class {
variables, absoluteMediaPlaylistUri, type, timestampOffset,
hlsAes128Key) {
const tags = hlsSegment.tags;
const absoluteSegmentUri = this.variableSubstitution_(
hlsSegment.absoluteUri, variables);
const extinfTag =
shaka.hls.Utils.getFirstTagWithName(tags, 'EXTINF');

Expand Down Expand Up @@ -2754,18 +2752,26 @@ shaka.hls.HlsParser = class {
if (!pUri) {
continue;
}
const pAbsoluteUri = shaka.hls.Utils.constructAbsoluteUri(
absoluteMediaPlaylistUri, pUri);

let partialStatus = shaka.media.SegmentReference.Status.AVAILABLE;
if (item.getAttributeValue('GAP') == 'YES') {
partialStatus = shaka.media.SegmentReference.Status.MISSING;
}

let pAbsoluteUri = null;
const getPartialUris = () => {
if (pAbsoluteUri == null) {
goog.asserts.assert(pUri, 'Partial uri should be defined!');
pAbsoluteUri = shaka.hls.Utils.constructAbsoluteUri(
absoluteMediaPlaylistUri, pUri);
}
return [pAbsoluteUri];
};

const partial = new shaka.media.SegmentReference(
pStartTime,
pEndTime,
() => [pAbsoluteUri],
getPartialUris,
pStartByte,
pEndByte,
initSegmentReference,
Expand Down Expand Up @@ -2829,10 +2835,19 @@ shaka.hls.HlsParser = class {
}
}

let absoluteSegmentUri = null;
const getUris = () => {
if (absoluteSegmentUri == null) {
absoluteSegmentUri = this.variableSubstitution_(
hlsSegment.absoluteUri, variables);
}
return absoluteSegmentUri.length ? [absoluteSegmentUri] : [];
};

return new shaka.media.SegmentReference(
startTime,
endTime,
() => absoluteSegmentUri.length ? [absoluteSegmentUri] : [],
getUris,
startByte,
endByte,
initSegmentReference,
Expand Down