Skip to content

Commit

Permalink
Read Role parameter from DASH manifest
Browse files Browse the repository at this point in the history
  • Loading branch information
sergiomartinez4 committed Feb 8, 2017
1 parent 06e1dc3 commit c8cb0fd
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 4 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true
#Thu Feb 04 15:49:07 GMT 2016
version=1.5.13
version=1.5.13.1
group=com.google.exoplayer
android.useDeprecatedNdk=true
org.gradle.jvmargs=-XX:MaxPermSize=512m
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,16 @@ public class AdaptationSet {

public final int type;

public final Role role;

public final List<Representation> representations;
public final List<ContentProtection> contentProtections;

public AdaptationSet(int id, int type, List<Representation> representations,
List<ContentProtection> contentProtections) {
List<ContentProtection> contentProtections, Role role) {
this.id = id;
this.type = type;
this.role = role;
this.representations = Collections.unmodifiableList(representations);
if (contentProtections == null) {
this.contentProtections = Collections.emptyList();
Expand All @@ -47,6 +50,11 @@ public AdaptationSet(int id, int type, List<Representation> representations,
}
}

public AdaptationSet(int id, int type, List<Representation> representations,
List<ContentProtection> contentProtections) {
this(id, type, representations, null, null);
}

public AdaptationSet(int id, int type, List<Representation> representations) {
this(id, type, representations, null);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -232,12 +232,17 @@ protected AdaptationSet parseAdaptationSet(XmlPullParser xpp, String baseUrl,
int audioChannels = -1;
int audioSamplingRate = parseInt(xpp, "audioSamplingRate", -1);
String language = xpp.getAttributeValue(null, "lang");
Role role = null;

ContentProtectionsBuilder contentProtectionsBuilder = new ContentProtectionsBuilder();
List<Representation> representations = new ArrayList<>();
boolean seenFirstBaseUrl = false;
do {
xpp.next();
if (ParserUtil.isStartTag(xpp, "Role")) {
role = parseRoleTag(xpp);
}

if (ParserUtil.isStartTag(xpp, "BaseURL")) {
if (!seenFirstBaseUrl) {
baseUrl = parseBaseUrl(xpp, baseUrl);
Expand Down Expand Up @@ -271,12 +276,17 @@ protected AdaptationSet parseAdaptationSet(XmlPullParser xpp, String baseUrl,
}
} while (!ParserUtil.isEndTag(xpp, "AdaptationSet"));

return buildAdaptationSet(id, contentType, representations, contentProtectionsBuilder.build());
return buildAdaptationSet(id, contentType, representations, contentProtectionsBuilder.build(), role);
}

protected AdaptationSet buildAdaptationSet(int id, int contentType,
List<Representation> representations, List<ContentProtection> contentProtections) {
return new AdaptationSet(id, contentType, representations, contentProtections);
return buildAdaptationSet(id, contentType, representations, contentProtections, null);
}

protected AdaptationSet buildAdaptationSet(int id, int contentType,
List<Representation> representations, List<ContentProtection> contentProtections, Role role) {
return new AdaptationSet(id, contentType, representations, contentProtections, role);
}

protected int parseContentType(XmlPullParser xpp) {
Expand Down Expand Up @@ -356,6 +366,22 @@ protected void parseAdaptationSetChild(XmlPullParser xpp)
// pass
}

//Parsing Role Tag
protected Role parseRoleTag(XmlPullParser xpp) throws XmlPullParserException, IOException {
String schemeIdUri = parseString(xpp, "schemeIdUri", null);
String value = parseString(xpp, "value", null);
Role role = null;

do {
xpp.next();
} while (!ParserUtil.isEndTag(xpp, "Role"));

if (schemeIdUri != null || value != null) {
role = new Role(schemeIdUri, value);
}
return role;
}

// Representation parsing.

protected Representation parseRepresentation(XmlPullParser xpp, String baseUrl,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package com.google.android.exoplayer.dash.mpd;


public class Role {
public final String schemeIdUri;
public final String value;

public Role(String schemeIdUri, String value) {
this.schemeIdUri = schemeIdUri;
this.value = value;
}
}

0 comments on commit c8cb0fd

Please sign in to comment.