From 65cafab4fb1d60d4d7db7896d9827bf20ad85f6f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81lvaro=20Velad=20Galv=C3=A1n?= Date: Thu, 25 Jan 2024 18:41:08 +0100 Subject: [PATCH] fix: player Dropping Variant (better codec available) when it should not (#6163) Fixes https://github.com/shaka-project/shaka-player/issues/6162 --- lib/util/stream_utils.js | 2 +- test/util/stream_utils_unit.js | 10 ++-------- 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/lib/util/stream_utils.js b/lib/util/stream_utils.js index 78b5857736..048b6a4675 100644 --- a/lib/util/stream_utils.js +++ b/lib/util/stream_utils.js @@ -162,7 +162,7 @@ shaka.util.StreamUtils = class { const currentCodec = MimeUtils.getNormalizedCodec(stream.codecs); if (previousCodec == currentCodec) { - if (stream.bandwidth < previousStream.bandwidth) { + if (stream.bandwidth > previousStream.bandwidth) { validVideoStreams.push(stream); validVideoIds.push(stream.id); } diff --git a/test/util/stream_utils_unit.js b/test/util/stream_utils_unit.js index d298d68850..b7f15f0824 100644 --- a/test/util/stream_utils_unit.js +++ b/test/util/stream_utils_unit.js @@ -825,12 +825,6 @@ describe('StreamUtils', () => { stream.size(20, 20); }); }); - manifest.addVariant(6, (variant) => { - variant.addVideo(7, (stream) => { - stream.bandwidth = 600000; - stream.size(20, 20); - }); - }); }); shaka.util.StreamUtils.chooseCodecsAndFilterManifest(manifest, @@ -838,8 +832,8 @@ describe('StreamUtils', () => { /* preferredAudioCodecs= */[], /* preferredDecodingAttributes= */[]); - expect(manifest.variants.length).toBe(2); - expect(manifest.variants.every((v) => [300000, 500000].includes( + expect(manifest.variants.length).toBe(3); + expect(manifest.variants.every((v) => [300000, 400000, 500000].includes( v.video.bandwidth))).toBeTruthy(); });