Skip to content

Commit a384e0c

Browse files
authored
fix(HLS): Fix bandwidth detection (shaka-project#9230)
Previously, AVERAGE-BANDWIDTH was prioritized over BANDWIDTH, but this produces undesirable results when peaks are reproduced and the ABR is unable to act.
1 parent ee00301 commit a384e0c

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

lib/hls/hls_parser.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1842,8 +1842,8 @@ shaka.hls.HlsParser = class {
18421842

18431843
const frameRate = firstTag.getAttributeValue('FRAME-RATE');
18441844
const bandwidth =
1845-
Number(firstTag.getAttributeValue('AVERAGE-BANDWIDTH')) ||
1846-
Number(firstTag.getRequiredAttrValue('BANDWIDTH'));
1845+
Number(firstTag.getRequiredAttrValue('BANDWIDTH')) ||
1846+
Number(firstTag.getAttributeValue('AVERAGE-BANDWIDTH'));
18471847

18481848
const resolution = firstTag.getAttributeValue('RESOLUTION');
18491849
const [width, height] = resolution ? resolution.split('x') : [null, null];

test/hls/hls_parser_unit.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -374,10 +374,10 @@ describe('HlsParser', () => {
374374
expect(actual).toEqual(manifest);
375375
});
376376

377-
it('prioritize AVERAGE-BANDWIDTH to BANDWIDTH', async () => {
377+
it('fallback to AVERAGE-BANDWIDTH', async () => {
378378
const master = [
379379
'#EXTM3U\n',
380-
'#EXT-X-STREAM-INF:BANDWIDTH=200,CODECS="avc1",',
380+
'#EXT-X-STREAM-INF:BANDWIDTH=0,CODECS="avc1",',
381381
'RESOLUTION=960x540,FRAME-RATE=60,',
382382
'AVERAGE-BANDWIDTH=100\n',
383383
'video\n',

0 commit comments

Comments
 (0)