mirror of
https://github.com/samsonjs/media.git
synced 2026-04-27 15:07:40 +00:00
removed custom element parsing
This commit is contained in:
parent
e42786d6f2
commit
ce0b5e4c44
2 changed files with 21 additions and 69 deletions
|
|
@ -982,10 +982,9 @@ public class DashManifestParser extends DefaultHandler
|
||||||
}
|
}
|
||||||
|
|
||||||
protected ProgramInformation parseProgramInformation(XmlPullParser xpp) throws IOException, XmlPullParserException {
|
protected ProgramInformation parseProgramInformation(XmlPullParser xpp) throws IOException, XmlPullParserException {
|
||||||
String title = "";
|
String title = null;
|
||||||
String source = "";
|
String source = null;
|
||||||
String copyright = "";
|
String copyright = null;
|
||||||
List<byte[]> customEvents = new ArrayList<>();
|
|
||||||
do {
|
do {
|
||||||
xpp.next();
|
xpp.next();
|
||||||
if (XmlPullParserUtil.isStartTag(xpp, "Title")) {
|
if (XmlPullParserUtil.isStartTag(xpp, "Title")) {
|
||||||
|
|
@ -994,28 +993,9 @@ public class DashManifestParser extends DefaultHandler
|
||||||
source = xpp.getText();
|
source = xpp.getText();
|
||||||
} else if (XmlPullParserUtil.isStartTag(xpp, "Copyright")) {
|
} else if (XmlPullParserUtil.isStartTag(xpp, "Copyright")) {
|
||||||
copyright = xpp.getText();
|
copyright = xpp.getText();
|
||||||
} else {
|
|
||||||
byte[] customElement = parseCustomElement(xpp, new ByteArrayOutputStream(512));
|
|
||||||
if (customElement.length > 0) {
|
|
||||||
customEvents.add(customElement);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} while (!XmlPullParserUtil.isEndTag(xpp, "ProgramInformation"));
|
} while (!XmlPullParserUtil.isEndTag(xpp, "ProgramInformation"));
|
||||||
return new ProgramInformation(title, source, copyright, customEvents);
|
return new ProgramInformation(title, source, copyright);
|
||||||
}
|
|
||||||
|
|
||||||
private byte[] parseCustomElement(XmlPullParser xpp, ByteArrayOutputStream outputStream) throws IOException, XmlPullParserException {
|
|
||||||
XmlSerializer serializer = Xml.newSerializer();
|
|
||||||
serializer.setOutput(outputStream, C.UTF8_NAME);
|
|
||||||
if (xpp.getEventType() == XmlPullParser.START_TAG) {
|
|
||||||
serializer.startTag(xpp.getNamespace(), xpp.getName());
|
|
||||||
for (int i = 0; i < xpp.getAttributeCount(); i++) {
|
|
||||||
serializer.attribute(xpp.getAttributeNamespace(i), xpp.getAttributeName(i), xpp.getAttributeValue(i));
|
|
||||||
}
|
|
||||||
serializer.endTag(xpp.getNamespace(), xpp.getName());
|
|
||||||
}
|
|
||||||
serializer.flush();
|
|
||||||
return outputStream.toByteArray();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// AudioChannelConfiguration parsing.
|
// AudioChannelConfiguration parsing.
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,20 @@
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2018 The Android Open Source Project
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
package com.google.android.exoplayer2.source.dash.manifest;
|
package com.google.android.exoplayer2.source.dash.manifest;
|
||||||
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class ProgramInformation {
|
public class ProgramInformation {
|
||||||
/**
|
/**
|
||||||
* The title for the media presentation.
|
* The title for the media presentation.
|
||||||
|
|
@ -19,49 +31,9 @@ public class ProgramInformation {
|
||||||
*/
|
*/
|
||||||
public final String copyright;
|
public final String copyright;
|
||||||
|
|
||||||
/**
|
public ProgramInformation(String title, String source, String copyright) {
|
||||||
* A list of custom elements.
|
|
||||||
*/
|
|
||||||
public final List<byte[]> customEvents;
|
|
||||||
|
|
||||||
public ProgramInformation(String title, String source, String copyright, List<byte[]> customEvents) {
|
|
||||||
this.title = title;
|
this.title = title;
|
||||||
this.source = source;
|
this.source = source;
|
||||||
this.copyright = copyright;
|
this.copyright = copyright;
|
||||||
this.customEvents = customEvents;
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
@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);
|
|
||||||
for (int i = 0; i < customEvents.size(); i++) {
|
|
||||||
result = 31 * result + Arrays.hashCode(customEvents.get(i));
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean equals(Object obj) {
|
|
||||||
return obj instanceof ProgramInformation
|
|
||||||
&& ((ProgramInformation)obj).title.equals(this.title)
|
|
||||||
&& ((ProgramInformation)obj).source.equals(this.source)
|
|
||||||
&& ((ProgramInformation)obj).copyright.equals(this.copyright)
|
|
||||||
&& validateEvents(((ProgramInformation)obj).customEvents);
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean validateEvents(List<byte[]> customEvents) {
|
|
||||||
for (int i = 0; i < customEvents.size() && i < this.customEvents.size(); i++) {
|
|
||||||
byte[] comparator = customEvents.get(i);
|
|
||||||
byte[] current = this.customEvents.get(i);
|
|
||||||
for (int j = 0; j < comparator.length && j < current.length; j++) {
|
|
||||||
if (current[j] != comparator[j]) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue