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 1 commit
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
7 changes: 3 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,9 @@ shaka.dash.SegmentList = class {
endTime = startTime + periodDuration;
}

const getUris = () => mediaUri;
const getUris = () => {
avelad marked this conversation as resolved.
Show resolved Hide resolved
return ManifestParserUtils.resolveUris(baseUris, [segment.mediaUri]);
};
references.push(
new shaka.media.SegmentReference(
periodStart + startTime,
Expand Down
21 changes: 15 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,23 @@ 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;
}

const getPartialUris = () => {
goog.asserts.assert(pUri, 'Partial uri should be defined!');
avelad marked this conversation as resolved.
Show resolved Hide resolved
const 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 +2832,16 @@ shaka.hls.HlsParser = class {
}
}

const getUris = () => {
const absoluteSegmentUri = this.variableSubstitution_(
theodab marked this conversation as resolved.
Show resolved Hide resolved
hlsSegment.absoluteUri, variables);
return absoluteSegmentUri.length ? [absoluteSegmentUri] : [];
};

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