Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Address optional URI component mentioned in issue 1086 and issue 1730 #1732

Merged
merged 1 commit into from
Jan 18, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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