Skip to content

Commit

Permalink
Add support for multiple roles to DASH parser.
Browse files Browse the repository at this point in the history
DASH parser used to assume representation can only have one role.
However that's not true in case of text representations that can
have both role=main and role=caption/subtitle.

Closes #500

Change-Id: I1b6a494347a0b86211b6982416e444c020b1eeb0
  • Loading branch information
ismena committed Aug 29, 2016
1 parent 3cad924 commit 925338f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
8 changes: 4 additions & 4 deletions lib/dash/dash_parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -716,19 +716,19 @@ shaka.dash.DashParser.prototype.parseAdaptationSet_ = function(context, elem) {
context.adaptationSet = this.createFrame_(elem, context.period, null);

var main = false;
var role = XmlUtils.findChild(elem, 'Role');
var roles = XmlUtils.findChildren(elem, 'Role');

// Default kind for text streams is 'subtitle' if unspecified in the manifest.
var kind = undefined;
if (context.adaptationSet.contentType == 'text') kind = 'subtitle';

if (role) {
var scheme = role.getAttribute('schemeIdUri');
for (var i = 0; i < roles.length; i++) {
var scheme = roles[i].getAttribute('schemeIdUri');
if (scheme == null || scheme == 'urn:mpeg:dash:role:2011') {
// These only apply for the given scheme, but allow them to be specified
// if there is no scheme specified.
// See: DASH section 5.8.5.5
var value = role.getAttribute('value');
var value = roles[i].getAttribute('value');
switch (value) {
case 'main':
main = true;
Expand Down
2 changes: 2 additions & 0 deletions test/dash/dash_parser_manifest_unit.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ describe('DashParser.Manifest', function() {
' <AdaptationSet mimeType="text/vtt" codecs="mp4a.40.29"',
' lang="es">',
' <Role value="caption" />',
' <Role value="main" />',
' <Representation bandwidth="100" />',
' </AdaptationSet>',
' <AdaptationSet mimeType="audio/mp4">',
Expand Down Expand Up @@ -145,6 +146,7 @@ describe('DashParser.Manifest', function() {
.size(576, 432)
.addStreamSet('text')
.language('es')
.primary()
.addStream(jasmine.any(Number))
.anySegmentFunctions()
.anyInitSegment()
Expand Down

0 comments on commit 925338f

Please sign in to comment.