Skip to content

Commit

Permalink
fix(HLS): Propagate bandwidth to stream in audio-only and video-only (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
avelad committed Jul 10, 2024
1 parent 6e439f0 commit 368860e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
15 changes: 8 additions & 7 deletions lib/hls/hls_parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -1487,7 +1487,7 @@ shaka.hls.HlsParser = class {
videoLayout = videoLayout || 'CH-MONO';

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

goog.asserts.assert(streamInfos.audio.length ||
streamInfos.video.length, 'We should have created a stream!');
Expand Down Expand Up @@ -1515,12 +1515,10 @@ 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, bandwidth) {
createStreamInfosForVariantTags_(tags, mediaTags, resolution, frameRate) {
const ContentType = shaka.util.ManifestParserUtils.ContentType;

/** @type {shaka.hls.HlsParser.StreamInfos} */
Expand Down Expand Up @@ -1655,9 +1653,6 @@ 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 @@ -1879,6 +1874,12 @@ shaka.hls.HlsParser = class {
videoStream.drmInfos = drmInfos;
videoStream.keyIds = keyIds;
}
if (videoStream && !audioStream) {
videoStream.bandwidth = bandwidth;
}
if (!videoStream && audioStream) {
audioStream.bandwidth = bandwidth;
}
const audioDrmInfos = audioInfo ? audioInfo.stream.drmInfos : null;
const videoDrmInfos = videoInfo ? videoInfo.stream.drmInfos : null;
const videoStreamUri =
Expand Down
3 changes: 3 additions & 0 deletions test/hls/hls_parser_unit.js
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,7 @@ describe('HlsParser', () => {
manifest.addPartialVariant((variant) => {
variant.bandwidth = 100;
variant.addPartialStream(ContentType.VIDEO, (stream) => {
stream.bandwidth = 100;
stream.frameRate = 60;
stream.mime('video/mp4', 'avc1');
stream.size(960, 540);
Expand Down Expand Up @@ -496,8 +497,10 @@ describe('HlsParser', () => {
const manifest = shaka.test.ManifestGenerator.generate((manifest) => {
manifest.anyTimeline();
manifest.addPartialVariant((variant) => {
variant.bandwidth = 200;
variant.addPartialStream(ContentType.AUDIO, (stream) => {
stream.mime('audio/mp4', 'mp4a');
stream.bandwidth = 200;
});
});
manifest.sequenceMode = sequenceMode;
Expand Down

0 comments on commit 368860e

Please sign in to comment.