Skip to content

Commit

Permalink
fixes 1086 and 1730 - if an X-EXT-MEDIA asset does not contain URI, i…
Browse files Browse the repository at this point in the history
…gnore when building stream list
  • Loading branch information
rgc committed Dec 26, 2018
1 parent 8c69ab1 commit 1863289
Show file tree
Hide file tree
Showing 2 changed files with 71 additions and 2 deletions.
11 changes: 11 additions & 0 deletions lib/hls/hls_parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -550,6 +550,17 @@ shaka.hls.HlsParser.prototype.createVariantsForTag_ = function(tag, playlist) {
const type = HlsParser.getRequiredAttributeValue_(tag, 'TYPE');
return type != 'CLOSED-CAPTIONS';
});

// AUDIO or VIDEO tags without a URI attribute are valid.
// If there is no uri, it means that audio/video is embedded in the
// stream described by the Variant tag.
// Do not create stream from AUDIO/VIDEO EXT-X-MEDIA tags without URI
mediaTags = mediaTags.filter((tag) => {
const uri = tag.getAttributeValue('URI') || '';
const type = tag.getAttributeValue('TYPE') || '';
return type == 'SUBTITLES' || uri != '';
});

let audioGroupId = tag.getAttributeValue('AUDIO');
let videoGroupId = tag.getAttributeValue('VIDEO');
goog.asserts.assert(audioGroupId == null || videoGroupId == null,
Expand Down
62 changes: 60 additions & 2 deletions test/hls/hls_parser_unit.js
Original file line number Diff line number Diff line change
Expand Up @@ -563,6 +563,64 @@ describe('HlsParser', function() {
await testHlsParser(master, media, manifest);
});

it('parses audio variant without URI', async () => {
const master = [
'#EXTM3U\n',
'#EXT-X-STREAM-INF:BANDWIDTH=200,',
'RESOLUTION=960x540,FRAME-RATE=60,AUDIO="aud1"\n',
'video\n',
'#EXT-X-MEDIA:TYPE=AUDIO,GROUP-ID="aud1",NAME="audio"\n',
].join('');

const media = [
'#EXTM3U\n',
'#EXT-X-PLAYLIST-TYPE:VOD\n',
'#EXT-X-MAP:URI="init.mp4",BYTERANGE="616@0"\n',
'#EXTINF:5,\n',
'#EXT-X-BYTERANGE:121090@616\n',
'main.mp4',
].join('');

let manifest = new shaka.test.ManifestGenerator()
.anyTimeline()
.addPeriod(0)
.addPartialVariant()
.addPartialStream(ContentType.VIDEO)
.mime('video/mp4', jasmine.any(String))
.build();

await testHlsParser(master, media, manifest);
});


it('parses video variant without URI', async () => {
const master = [
'#EXTM3U\n',
'#EXT-X-STREAM-INF:BANDWIDTH=200,CODECS="mp4a",VIDEO="vid1"\n',
'audio\n',
'#EXT-X-MEDIA:TYPE=VIDEO,GROUP-ID="vid1",NAME="video"\n',
].join('');

const media = [
'#EXTM3U\n',
'#EXT-X-PLAYLIST-TYPE:VOD\n',
'#EXT-X-MAP:URI="init.mp4",BYTERANGE="616@0"\n',
'#EXTINF:5,\n',
'#EXT-X-BYTERANGE:121090@616\n',
'main.mp4',
].join('');

let manifest = new shaka.test.ManifestGenerator()
.anyTimeline()
.addPeriod(0)
.addPartialVariant()
.addPartialStream(ContentType.AUDIO)
.mime('audio/mp4', jasmine.any(String))
.build();

await testHlsParser(master, media, manifest);
});

it('parses multiple variants', async () => {
const master = [
'#EXTM3U\n',
Expand Down Expand Up @@ -1339,9 +1397,9 @@ describe('HlsParser', function() {
const master = [
'#EXTM3U\n',
'#EXT-X-STREAM-INF:CODECS="avc1,mp4a",BANDWIDTH=200,',
'RESOLUTION=960x540,FRAME-RATE=60,VIDEO="vid"\n',
'RESOLUTION=960x540,FRAME-RATE=60,SUBTITLES="sub1"\n',
'audio\n',
'#EXT-X-MEDIA:TYPE=VIDEO,GROUP-ID="vid"',
'#EXT-X-MEDIA:TYPE=SUBTITLES,GROUP-ID="sub1"',
].join('');

const media = [
Expand Down

0 comments on commit 1863289

Please sign in to comment.