Skip to content

Commit

Permalink
Merge branch 'master' into 'fix-npm-audit'
Browse files Browse the repository at this point in the history
  • Loading branch information
poirotp-bpk committed Nov 21, 2023
2 parents 10bc0f3 + 7383e95 commit 62f03c9
Show file tree
Hide file tree
Showing 3 changed files with 94 additions and 0 deletions.
17 changes: 17 additions & 0 deletions test/fixtures/m3u8/Multiple-rendition-groups.m3u8
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#EXTM3U
#EXT-X-VERSION:4
#EXT-X-INDEPENDENT-SEGMENTS
#EXT-X-MEDIA:TYPE=AUDIO,GROUP-ID="aac_high",NAME="English",DEFAULT=YES,URI="aac_high_eng.m3u8"
#EXT-X-MEDIA:TYPE=AUDIO,GROUP-ID="aac_high",NAME="Japanese",DEFAULT=NO,URI="aac_high_jp.m3u8"
#EXT-X-STREAM-INF:BANDWIDTH=6000000,AUDIO="aac_high"
1080p.m3u8
#EXT-X-MEDIA:TYPE=AUDIO,GROUP-ID="aac_mid",NAME="English",DEFAULT=YES,URI="aac_mid_eng.m3u8"
#EXT-X-MEDIA:TYPE=AUDIO,GROUP-ID="aac_mid",NAME="Japanese",DEFAULT=NO,URI="aac_mid_jp.m3u8"
#EXT-X-STREAM-INF:BANDWIDTH=3000000,AUDIO="aac_mid"
720p.m3u8
#EXT-X-STREAM-INF:BANDWIDTH=1500000,AUDIO="aac_mid"
540p.m3u8
#EXT-X-MEDIA:TYPE=AUDIO,GROUP-ID="aac_low",NAME="English",DEFAULT=YES,URI="aac_low_eng.m3u8"
#EXT-X-MEDIA:TYPE=AUDIO,GROUP-ID="aac_low",NAME="Japanese",DEFAULT=NO,URI="aac_low_jp.m3u8"
#EXT-X-STREAM-INF:BANDWIDTH=1000000,AUDIO="aac_low"
360p.m3u8
28 changes: 28 additions & 0 deletions test/fixtures/objects/Multiple-rendition-groups.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
const {MasterPlaylist, Variant, Rendition} = require('../../../types');

const renditions = [
new Rendition({type: 'AUDIO', groupId: 'aac_high', name: 'English', isDefault: true, uri: 'aac_high_eng.m3u8'}),
new Rendition({type: 'AUDIO', groupId: 'aac_high', name: 'Japanese', isDefault: false, uri: 'aac_high_jp.m3u8'}),
new Rendition({type: 'AUDIO', groupId: 'aac_mid', name: 'English', isDefault: true, uri: 'aac_mid_eng.m3u8'}),
new Rendition({type: 'AUDIO', groupId: 'aac_mid', name: 'Japanese', isDefault: false, uri: 'aac_mid_jp.m3u8'}),
new Rendition({type: 'AUDIO', groupId: 'aac_low', name: 'English', isDefault: true, uri: 'aac_low_eng.m3u8'}),
new Rendition({type: 'AUDIO', groupId: 'aac_low', name: 'Japanese', isDefault: false, uri: 'aac_low_jp.m3u8'}),
];
const variants = [
{uri: '1080p.m3u8', bandwidth: 6000000, audioId: 'aac_high'},
{uri: '720p.m3u8', bandwidth: 3000000, audioId: 'aac_mid'},
{uri: '540p.m3u8', bandwidth: 1500000, audioId: 'aac_mid'},
{uri: '360p.m3u8', bandwidth: 1000000, audioId: 'aac_low'},
].map(
({uri, bandwidth, audioId}) => new Variant({
uri, bandwidth, audio: renditions.filter(({groupId}) => groupId === audioId)
})
);

const playlist = new MasterPlaylist({
version: 4,
independentSegments: true,
variants,
});

module.exports = playlist;
49 changes: 49 additions & 0 deletions test/spec/misc/multiple-rendition-groups.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
const test = require("ava");
const utils = require("../../helpers/utils");
const HLS = require("../../..");

test("Multiple-Rendition-Groups_01", t => {
const shouldRead = `
#EXTM3U
#EXT-X-VERSION:4
#EXT-X-INDEPENDENT-SEGMENTS
#EXT-X-MEDIA:TYPE=AUDIO,GROUP-ID="aac_high",NAME="English",DEFAULT=YES,URI="aac_high_eng.m3u8"
#EXT-X-MEDIA:TYPE=AUDIO,GROUP-ID="aac_high",NAME="Japanese",DEFAULT=NO,URI="aac_high_jp.m3u8"
#EXT-X-MEDIA:TYPE=AUDIO,GROUP-ID="aac_mid",NAME="English",DEFAULT=YES,URI="aac_mid_eng.m3u8"
#EXT-X-MEDIA:TYPE=AUDIO,GROUP-ID="aac_mid",NAME="Japanese",DEFAULT=NO,URI="aac_mid_jp.m3u8"
#EXT-X-MEDIA:TYPE=AUDIO,GROUP-ID="aac_low",NAME="English",DEFAULT=YES,URI="aac_low_eng.m3u8"
#EXT-X-MEDIA:TYPE=AUDIO,GROUP-ID="aac_low",NAME="Japanese",DEFAULT=NO,URI="aac_low_jp.m3u8"
#EXT-X-STREAM-INF:BANDWIDTH=6000000,AUDIO="aac_high"
1080p.m3u8
#EXT-X-STREAM-INF:BANDWIDTH=3000000,AUDIO="aac_mid"
720p.m3u8
#EXT-X-STREAM-INF:BANDWIDTH=1500000,AUDIO="aac_mid"
540p.m3u8
#EXT-X-STREAM-INF:BANDWIDTH=1000000,AUDIO="aac_low"
360p.m3u8
`;

const playlist = HLS.parse(shouldRead);

const shouldWrite = `
#EXTM3U
#EXT-X-VERSION:4
#EXT-X-INDEPENDENT-SEGMENTS
#EXT-X-MEDIA:TYPE=AUDIO,GROUP-ID="aac_high",NAME="English",DEFAULT=YES,URI="aac_high_eng.m3u8"
#EXT-X-MEDIA:TYPE=AUDIO,GROUP-ID="aac_high",NAME="Japanese",DEFAULT=NO,URI="aac_high_jp.m3u8"
#EXT-X-STREAM-INF:BANDWIDTH=6000000,AUDIO="aac_high"
1080p.m3u8
#EXT-X-MEDIA:TYPE=AUDIO,GROUP-ID="aac_mid",NAME="English",DEFAULT=YES,URI="aac_mid_eng.m3u8"
#EXT-X-MEDIA:TYPE=AUDIO,GROUP-ID="aac_mid",NAME="Japanese",DEFAULT=NO,URI="aac_mid_jp.m3u8"
#EXT-X-STREAM-INF:BANDWIDTH=3000000,AUDIO="aac_mid"
720p.m3u8
#EXT-X-STREAM-INF:BANDWIDTH=1500000,AUDIO="aac_mid"
540p.m3u8
#EXT-X-MEDIA:TYPE=AUDIO,GROUP-ID="aac_low",NAME="English",DEFAULT=YES,URI="aac_low_eng.m3u8"
#EXT-X-MEDIA:TYPE=AUDIO,GROUP-ID="aac_low",NAME="Japanese",DEFAULT=NO,URI="aac_low_jp.m3u8"
#EXT-X-STREAM-INF:BANDWIDTH=1000000,AUDIO="aac_low"
360p.m3u8
`;

t.is(HLS.stringify(playlist), utils.stripCommentsAndEmptyLines(shouldWrite));
});

0 comments on commit 62f03c9

Please sign in to comment.