Skip to content

Commit

Permalink
Treat TARGETDURATION as a decimal-integer assigned a minimum value of…
Browse files Browse the repository at this point in the history
… 1 (#5159)

#4464
  • Loading branch information
robwalch committed Jan 26, 2023
1 parent 0bc24ef commit 502e8b0
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/loader/m3u8-parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ export default class M3U8Parser {
break;
}
case 'TARGETDURATION':
level.targetduration = parseFloat(value1);
level.targetduration = Math.max(parseInt(value1), 1);
break;
case 'VERSION':
level.version = parseInt(value1);
Expand Down
30 changes: 30 additions & 0 deletions tests/unit/loader/playlist-loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,36 @@ http://proxy-62.dailymotion.com/sec(3ae40f708f79ca9471f52b86da76a3a8)/video/107/
expect(result.totalduration).to.equal(0);
});

it('TARGETDURATION is a decimal-integer', function () {
const level = `#EXTM3U
#EXT-X-VERSION:3
#EXT-X-PLAYLIST-TYPE:VOD
#EXT-X-TARGETDURATION:2.5`;
const result = M3U8Parser.parseLevelPlaylist(
level,
'http://proxy-62.dailymotion.com/sec(3ae40f708f79ca9471f52b86da76a3a8)/video/107/282/158282701_mp4_h264_aac_hq.m3u8#cell=core',
0,
PlaylistLevelType.MAIN,
0
);
expect(result.targetduration).to.equal(2);
});

it('TARGETDURATION is a decimal-integer which HLS.js assigns a minimum value of 1', function () {
const level = `#EXTM3U
#EXT-X-VERSION:3
#EXT-X-PLAYLIST-TYPE:VOD
#EXT-X-TARGETDURATION:0.5`;
const result = M3U8Parser.parseLevelPlaylist(
level,
'http://proxy-62.dailymotion.com/sec(3ae40f708f79ca9471f52b86da76a3a8)/video/107/282/158282701_mp4_h264_aac_hq.m3u8#cell=core',
0,
PlaylistLevelType.MAIN,
0
);
expect(result.targetduration).to.equal(1);
});

it('parse level with several fragments', function () {
const level = `#EXTM3U
#EXT-X-VERSION:3
Expand Down

0 comments on commit 502e8b0

Please sign in to comment.