Skip to content

Commit

Permalink
fix(HLS): Set the bandwidth correctly for audio/video-only variants (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
avelad committed Jan 25, 2024
1 parent 07ebdb1 commit 658386b
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions lib/hls/hls_parser.js
Expand Up @@ -450,8 +450,9 @@ shaka.hls.HlsParser = class {
const {segments, bandwidth} = this.createSegments_(
playlist, stream, mediaSequenceToStartTime, mediaVariables,
streamInfo.getUris);

stream.bandwidth = bandwidth;
if (bandwidth) {
stream.bandwidth = bandwidth;
}

stream.segmentIndex.mergeAndEvict(
segments, this.presentationTimeline_.getSegmentAvailabilityStart());
Expand Down Expand Up @@ -1386,7 +1387,7 @@ shaka.hls.HlsParser = class {
videoLayout = videoLayout || 'CH-MONO';

const streamInfos = this.createStreamInfosForVariantTags_(tags,
mediaTags, resolution, frameRate);
mediaTags, resolution, frameRate, bandwidth);

goog.asserts.assert(streamInfos.audio.length ||
streamInfos.video.length, 'We should have created a stream!');
Expand Down Expand Up @@ -1414,10 +1415,12 @@ shaka.hls.HlsParser = class {
* @param {!Array.<!shaka.hls.Tag>} mediaTags
* @param {?string} resolution
* @param {?string} frameRate
* @param {number} bandwidth
* @return {!shaka.hls.HlsParser.StreamInfos}
* @private
*/
createStreamInfosForVariantTags_(tags, mediaTags, resolution, frameRate) {
createStreamInfosForVariantTags_(
tags, mediaTags, resolution, frameRate, bandwidth) {
const ContentType = shaka.util.ManifestParserUtils.ContentType;

/** @type {shaka.hls.HlsParser.StreamInfos} */
Expand Down Expand Up @@ -1552,6 +1555,9 @@ shaka.hls.HlsParser = class {
if (globalGroupId) {
streamInfo.stream.groupId = globalGroupId;
}
if (!streamInfos.length) {
streamInfo.stream.bandwidth = bandwidth;
}
res[streamInfo.stream.type] = [streamInfo];
}
return res;
Expand Down Expand Up @@ -2239,7 +2245,7 @@ shaka.hls.HlsParser = class {
stream.drmInfos = realStream.drmInfos;
stream.keyIds = realStream.keyIds;
stream.mimeType = realStream.mimeType;
stream.bandwidth = realStream.bandwidth;
stream.bandwidth = stream.bandwidth || realStream.bandwidth;
stream.codecs = stream.codecs || realStream.codecs;

// Since we lazy-loaded this content, the player may need to create new
Expand Down Expand Up @@ -2518,7 +2524,9 @@ shaka.hls.HlsParser = class {

const {segments, bandwidth} = this.createSegments_(
playlist, stream, mediaSequenceToStartTime, mediaVariables, getUris);
stream.bandwidth = bandwidth;
if (bandwidth) {
stream.bandwidth = bandwidth;
}

// This new calculation is necessary for Low Latency streams.
if (this.isLive_()) {
Expand Down

0 comments on commit 658386b

Please sign in to comment.