added attribute parsin

This commit is contained in:
Lieblich, Jonathan 2018-10-11 17:09:00 -06:00
parent ce0b5e4c44
commit 6cbac152c9
4 changed files with 52 additions and 10 deletions

View file

@ -985,17 +985,19 @@ public class DashManifestParser extends DefaultHandler
String title = null;
String source = null;
String copyright = null;
String moreInformationURL = parseString(xpp, "moreInformationURL", null);
String lang = parseString(xpp, "lang", null);
do {
xpp.next();
if (XmlPullParserUtil.isStartTag(xpp, "Title")) {
title = xpp.getText();
title = xpp.nextText();
} else if (XmlPullParserUtil.isStartTag(xpp, "Source")) {
source = xpp.getText();
source = xpp.nextText();
} else if (XmlPullParserUtil.isStartTag(xpp, "Copyright")) {
copyright = xpp.getText();
copyright = xpp.nextText();
}
} while (!XmlPullParserUtil.isEndTag(xpp, "ProgramInformation"));
return new ProgramInformation(title, source, copyright);
return new ProgramInformation(title, source, copyright, moreInformationURL, lang);
}
// AudioChannelConfiguration parsing.

View file

@ -15,6 +15,8 @@
*/
package com.google.android.exoplayer2.source.dash.manifest;
import com.google.android.exoplayer2.util.Util;
public class ProgramInformation {
/**
* The title for the media presentation.
@ -31,9 +33,45 @@ public class ProgramInformation {
*/
public final String copyright;
public ProgramInformation(String title, String source, String copyright) {
/**
* A URL that provides more information about the media presentation.
*/
public final String moreInformationURL;
/**
* Declares the language code(s) for this ProgramInformation.
*/
public final String lang;
public ProgramInformation(String title, String source, String copyright, String moreInformationURL, String lang) {
this.title = title;
this.source = source;
this.copyright = copyright;
this.moreInformationURL = moreInformationURL;
this.lang = lang;
}
@Override
public boolean equals(Object obj) {
if (!(obj instanceof ProgramInformation)) {
return false;
}
ProgramInformation other = (ProgramInformation) obj;
return Util.areEqual(this.title, other.title)
&& Util.areEqual(this.source, other.source)
&& Util.areEqual(this.copyright, other.copyright)
&& Util.areEqual(this.moreInformationURL, other.moreInformationURL)
&& Util.areEqual(this.lang, other.lang);
}
@Override
public int hashCode() {
int result = 17;
result = 31 * result + (title != null ? title.hashCode() : 0);
result = 31 * result + (source != null ? source.hashCode() : 0);
result = 31 * result + (copyright != null ? copyright.hashCode() : 0);
result = 31 * result + (moreInformationURL != null ? moreInformationURL.hashCode() : 0);
result = 31 * result + (lang != null ? lang.hashCode() : 0);
return result;
}
}

View file

@ -9,8 +9,11 @@
xmlns="urn:mpeg:DASH:schema:MPD:2011"
xsi:schemaLocation="urn:mpeg:DASH:schema:MPD:2011 DASH-MPD.xsd"
yt:earliestMediaSequence="1266404" >
<ProgramInformation>
<scte214:ContentIdentifier type="URN" value="5939026565177792163" />
<ProgramInformation lang="enUs"
moreInformationURL="www.example.com">
<Title>MediaTitle</Title>
<Source>MediaSource</Source>
<Copyright>MediaCopyright</Copyright>
</ProgramInformation>
<Period start="PT6462826.784S" >
<SegmentList

View file

@ -158,9 +158,8 @@ public class DashManifestParserTest {
DashManifestParser parser = new DashManifestParser();
DashManifest mpd = parser.parse(Uri.parse("Https://example.com/test.mpd"),
TestUtil.getInputStream(RuntimeEnvironment.application, SAMPLE_MPD_1));
List<byte[]> list = new ArrayList<>();
list.add("<scte214:ContentIdentifier type=\"URN\" value=\"5939026565177792163\" />".getBytes());
ProgramInformation programInformation = new ProgramInformation("", "", "", list);
ProgramInformation programInformation = new ProgramInformation("MediaTitle", "MediaSource",
"MediaCopyright", "www.example.com", "enUs");
assertThat(programInformation).isEqualTo(mpd.programInformation);
}