Pixel Fusion v1.0.2版本的 MD5 值为:7c04c460c2996569d4ad075cd671a946
以下内容为反编译后的 DashManifestParser.java 源代码,内容仅作参考
package io.bidmachine.media3.exoplayer.dash.manifest;
import android.net.Uri;
import android.text.TextUtils;
import android.util.Base64;
import android.util.Pair;
import android.util.Xml;
import androidx.annotation.Nullable;
import androidx.exifinterface.media.ExifInterface;
import com.google.common.base.babbDABcB;
import com.google.common.base.dcadbB;
import com.google.common.collect.abBDacbDA;
import com.google.common.collect.ddbaba;
import com.json.t4;
import io.bidmachine.media3.common.C;
import io.bidmachine.media3.common.DrmInitData;
import io.bidmachine.media3.common.Format;
import io.bidmachine.media3.common.MimeTypes;
import io.bidmachine.media3.common.ParserException;
import io.bidmachine.media3.common.util.Assertions;
import io.bidmachine.media3.common.util.Log;
import io.bidmachine.media3.common.util.UnstableApi;
import io.bidmachine.media3.common.util.UriUtil;
import io.bidmachine.media3.common.util.Util;
import io.bidmachine.media3.common.util.XmlPullParserUtil;
import io.bidmachine.media3.exoplayer.dash.manifest.SegmentBase;
import io.bidmachine.media3.exoplayer.upstream.ParsingLoadable;
import io.bidmachine.media3.extractor.metadata.emsg.EventMessage;
import io.bidmachine.media3.extractor.mp4.PsshAtomUtil;
import io.bidmachine.unified.UnifiedMediationParams;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.xml.sax.helpers.DefaultHandler;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
import org.xmlpull.v1.XmlPullParserFactory;
import org.xmlpull.v1.XmlSerializer;
@UnstableApi
public class DashManifestParser extends DefaultHandler implements ParsingLoadable.Parser<DashManifest> {
private static final String TAG = "MpdParser";
private final XmlPullParserFactory xmlParserFactory;
private static final Pattern FRAME_RATE_PATTERN = Pattern.compile("(\\d+)(?:/(\\d+))?");
private static final Pattern CEA_608_ACCESSIBILITY_PATTERN = Pattern.compile("CC([1-4])=.*");
private static final Pattern CEA_708_ACCESSIBILITY_PATTERN = Pattern.compile("([1-9]|[1-5][0-9]|6[0-3])=.*");
private static final int[] MPEG_CHANNEL_CONFIGURATION_MAPPING = {-1, 1, 2, 3, 4, 5, 6, 8, 2, 3, 4, 7, 8, 24, 8, 12, 10, 12, 14, 12, 14};
public static final class RepresentationInfo {
public final ddbaba<BaseUrl> baseUrls;
public final ArrayList<DrmInitData.SchemeData> drmSchemeDatas;
@Nullable
public final String drmSchemeType;
public final List<Descriptor> essentialProperties;
public final Format format;
public final ArrayList<Descriptor> inbandEventStreams;
public final long revisionId;
public final SegmentBase segmentBase;
public final List<Descriptor> supplementalProperties;
public RepresentationInfo(Format format, List<BaseUrl> list, SegmentBase segmentBase, @Nullable String str, ArrayList<DrmInitData.SchemeData> arrayList, ArrayList<Descriptor> arrayList2, List<Descriptor> list2, List<Descriptor> list3, long j) {
this.format = format;
this.baseUrls = ddbaba.bbBABBaACBD(list);
this.segmentBase = segmentBase;
this.drmSchemeType = str;
this.drmSchemeDatas = arrayList;
this.inbandEventStreams = arrayList2;
this.essentialProperties = list2;
this.supplementalProperties = list3;
this.revisionId = j;
}
}
public DashManifestParser() {
try {
this.xmlParserFactory = XmlPullParserFactory.newInstance();
} catch (XmlPullParserException e) {
throw new RuntimeException("Couldn't create XmlPullParserFactory instance", e);
}
}
private long addSegmentTimelineElementsToList(List<SegmentBase.SegmentTimelineElement> list, long j, long j2, int i, long j3) {
int ceilDivide;
if (i >= 0) {
ceilDivide = i + 1;
} else {
ceilDivide = (int) Util.ceilDivide(j3 - j, j2);
}
for (int i2 = 0; i2 < ceilDivide; i2++) {
list.add(buildSegmentTimelineElement(j, j2));
j += j2;
}
return j;
}
private static int checkContentTypeConsistency(int i, int i2) {
boolean z;
if (i == -1) {
return i2;
}
if (i2 == -1) {
return i;
}
if (i == i2) {
z = true;
} else {
z = false;
}
Assertions.checkState(z);
return i;
}
@Nullable
private static String checkLanguageConsistency(@Nullable String str, @Nullable String str2) {
if (str == null) {
return str2;
}
if (str2 == null) {
return str;
}
Assertions.checkState(str.equals(str2));
return str;
}
private static void fillInClearKeyInformation(ArrayList<DrmInitData.SchemeData> arrayList) {
String str;
int i = 0;
while (true) {
if (i < arrayList.size()) {
DrmInitData.SchemeData schemeData = arrayList.get(i);
if (C.CLEARKEY_UUID.equals(schemeData.uuid) && (str = schemeData.licenseServerUrl) != null) {
arrayList.remove(i);
break;
}
i++;
} else {
str = null;
break;
}
}
if (str == null) {
return;
}
for (int i2 = 0; i2 < arrayList.size(); i2++) {
DrmInitData.SchemeData schemeData2 = arrayList.get(i2);
if (C.COMMON_PSSH_UUID.equals(schemeData2.uuid) && schemeData2.licenseServerUrl == null) {
arrayList.set(i2, new DrmInitData.SchemeData(C.CLEARKEY_UUID, str, schemeData2.mimeType, schemeData2.data));
}
}
}
private static void filterRedundantIncompleteSchemeDatas(ArrayList<DrmInitData.SchemeData> arrayList) {
for (int size = arrayList.size() - 1; size >= 0; size--) {
DrmInitData.SchemeData schemeData = arrayList.get(size);
if (!schemeData.hasData()) {
int i = 0;
while (true) {
if (i >= arrayList.size()) {
break;
}
if (arrayList.get(i).canReplace(schemeData)) {
arrayList.remove(size);
break;
}
i++;
}
}
}
}
private static long getFinalAvailabilityTimeOffset(long j, long j2) {
if (j2 != -9223372036854775807L) {
j = j2;
}
if (j == Long.MAX_VALUE) {
return -9223372036854775807L;
}
return j;
}
@Nullable
private static String getSampleMimeType(@Nullable String str, @Nullable String str2) {
if (MimeTypes.isAudio(str)) {
return MimeTypes.getAudioMediaMimeType(str2);
}
if (MimeTypes.isVideo(str)) {
return MimeTypes.getVideoMediaMimeType(str2);
}
if (MimeTypes.isText(str)) {
return str;
}
if (MimeTypes.isImage(str)) {
return str;
}
if ("application/mp4".equals(str)) {
String mediaMimeType = MimeTypes.getMediaMimeType(str2);
if ("text/vtt".equals(mediaMimeType)) {
return "application/x-mp4-vtt";
}
return mediaMimeType;
}
return null;
}
private boolean isDvbProfileDeclared(String[] strArr) {
for (String str : strArr) {
if (str.startsWith("urn:dvb:dash:profile:dvb-dash:")) {
return true;
}
}
return false;
}
public static void maybeSkipTag(XmlPullParser xmlPullParser) throws IOException, XmlPullParserException {
if (!XmlPullParserUtil.isStartTag(xmlPullParser)) {
return;
}
int i = 1;
while (i != 0) {
xmlPullParser.next();
if (XmlPullParserUtil.isStartTag(xmlPullParser)) {
i++;
} else if (XmlPullParserUtil.isEndTag(xmlPullParser)) {
i--;
}
}
}
public static int parseCea608AccessibilityChannel(List<Descriptor> list) {
String str;
for (int i = 0; i < list.size(); i++) {
Descriptor descriptor = list.get(i);
if ("urn:scte:dash:cc:cea-608:2015".equals(descriptor.schemeIdUri) && (str = descriptor.value) != null) {
Matcher matcher = CEA_608_ACCESSIBILITY_PATTERN.matcher(str);
if (matcher.matches()) {
return Integer.parseInt(matcher.group(1));
}
Log.w(TAG, "Unable to parse CEA-608 channel number from: " + descriptor.value);
}
}
return -1;
}
public static int parseCea708AccessibilityChannel(List<Descriptor> list) {
String str;
for (int i = 0; i < list.size(); i++) {
Descriptor descriptor = list.get(i);
if ("urn:scte:dash:cc:cea-708:2015".equals(descriptor.schemeIdUri) && (str = descriptor.value) != null) {
Matcher matcher = CEA_708_ACCESSIBILITY_PATTERN.matcher(str);
if (matcher.matches()) {
return Integer.parseInt(matcher.group(1));
}
Log.w(TAG, "Unable to parse CEA-708 service block number from: " + descriptor.value);
}
}
return -1;
}
public static long parseDateTime(XmlPullParser xmlPullParser, String str, long j) throws ParserException {
String attributeValue = xmlPullParser.getAttributeValue(null, str);
if (attributeValue == null) {
return j;
}
return Util.parseXsDateTime(attributeValue);
}
public static Descriptor parseDescriptor(XmlPullParser xmlPullParser, String str) throws XmlPullParserException, IOException {
String parseString = parseString(xmlPullParser, "schemeIdUri", "");
String parseString2 = parseString(xmlPullParser, t4.h.X, null);
String parseString3 = parseString(xmlPullParser, "id", null);
do {
xmlPullParser.next();
} while (!XmlPullParserUtil.isEndTag(xmlPullParser, str));
return new Descriptor(parseString, parseString2, parseString3);
}
public static int parseDolbyChannelConfiguration(XmlPullParser xmlPullParser) {
char c;
String attributeValue = xmlPullParser.getAttributeValue(null, t4.h.X);
if (attributeValue == null) {
return -1;
}
String dDbCdDC2 = babbDABcB.dDbCdDC(attributeValue);
dDbCdDC2.getClass();
switch (dDbCdDC2.hashCode()) {
case 1596796:
if (dDbCdDC2.equals("4000")) {
c = 0;
break;
}
c = 65535;
break;
case 2937391:
if (dDbCdDC2.equals("a000")) {
c = 1;
break;
}
c = 65535;
break;
case 3094035:
if (dDbCdDC2.equals("f801")) {
c = 2;
break;
}
c = 65535;
break;
case 3133436:
if (dDbCdDC2.equals("fa01")) {
c = 3;
break;
}
c = 65535;
break;
default:
c = 65535;
break;
}
switch (c) {
case 0:
return 1;
case 1:
return 2;
case 2:
return 6;
case 3:
return 8;
default:
return -1;
}
}
public static int parseDtsChannelConfiguration(XmlPullParser xmlPullParser) {
int parseInt = parseInt(xmlPullParser, t4.h.X, -1);
if (parseInt <= 0 || parseInt >= 33) {
return -1;
}
return parseInt;
}
public static int parseDtsxChannelConfiguration(XmlPullParser xmlPullParser) {
int bitCount;
String attributeValue = xmlPullParser.getAttributeValue(null, t4.h.X);
if (attributeValue == null || (bitCount = Integer.bitCount(Integer.parseInt(attributeValue, 16))) == 0) {
return -1;
}
return bitCount;
}
public static long parseDuration(XmlPullParser xmlPullParser, String str, long j) {
String attributeValue = xmlPullParser.getAttributeValue(null, str);
if (attributeValue == null) {
return j;
}
return Util.parseXsDuration(attributeValue);
}
public static String parseEac3SupplementalProperties(List<Descriptor> list) {
for (int i = 0; i < list.size(); i++) {
Descriptor descriptor = list.get(i);
String str = descriptor.schemeIdUri;
if (!"tag:dolby.com,2018:dash:EC3_ExtensionType:2018".equals(str) || !"JOC".equals(descriptor.value)) {
if ("tag:dolby.com,2014:dash:DolbyDigitalPlusExtensionType:2014".equals(str) && "ec+3".equals(descriptor.value)) {
return "audio/eac3-joc";
}
} else {
return "audio/eac3-joc";
}
}
return "audio/eac3";
}
public static float parseFloat(XmlPullParser xmlPullParser, String str, float f) {
String attributeValue = xmlPullParser.getAttributeValue(null, str);
if (attributeValue != null) {
return Float.parseFloat(attributeValue);
}
return f;
}
public static float parseFrameRate(XmlPullParser xmlPullParser, float f) {
String attributeValue = xmlPullParser.getAttributeValue(null, "frameRate");
if (attributeValue != null) {
Matcher matcher = FRAME_RATE_PATTERN.matcher(attributeValue);
if (matcher.matches()) {
int parseInt = Integer.parseInt(matcher.group(1));
if (!TextUtils.isEmpty(matcher.group(2))) {
return parseInt / Integer.parseInt(r2);
}
return parseInt;
}
return f;
}
return f;
}
public static int parseInt(XmlPullParser xmlPullParser, String str, int i) {
String attributeValue = xmlPullParser.getAttributeValue(null, str);
if (attributeValue != null) {
return Integer.parseInt(attributeValue);
}
return i;
}
public static long parseLastSegmentNumberSupplementalProperty(List<Descriptor> list) {
for (int i = 0; i < list.size(); i++) {
Descriptor descriptor = list.get(i);
if (babbDABcB.BbdcDCacCa("http://dashif.org/guidelines/last-segment-number", descriptor.schemeIdUri)) {
return Long.parseLong(descriptor.value);
}
}
return -1L;
}
public static long parseLong(XmlPullParser xmlPullParser, String str, long j) {
String attributeValue = xmlPullParser.getAttributeValue(null, str);
if (attributeValue != null) {
return Long.parseLong(attributeValue);
}
return j;
}
public static int parseMpegChannelConfiguration(XmlPullParser xmlPullParser) {
int parseInt = parseInt(xmlPullParser, t4.h.X, -1);
if (parseInt < 0) {
return -1;
}
int[] iArr = MPEG_CHANNEL_CONFIGURATION_MAPPING;
if (parseInt >= iArr.length) {
return -1;
}
return iArr[parseInt];
}
public static String parseString(XmlPullParser xmlPullParser, String str, String str2) {
String attributeValue = xmlPullParser.getAttributeValue(null, str);
if (attributeValue != null) {
return attributeValue;
}
return str2;
}
public static String parseText(XmlPullParser xmlPullParser, String str) throws XmlPullParserException, IOException {
String str2 = "";
do {
xmlPullParser.next();
if (xmlPullParser.getEventType() == 4) {
str2 = xmlPullParser.getText();
} else {
maybeSkipTag(xmlPullParser);
}
} while (!XmlPullParserUtil.isEndTag(xmlPullParser, str));
return str2;
}
public AdaptationSet buildAdaptationSet(int i, int i2, List<Representation> list, List<Descriptor> list2, List<Descriptor> list3, List<Descriptor> list4) {
return new AdaptationSet(i, i2, list, list2, list3, list4);
}
public EventMessage buildEvent(String str, String str2, long j, long j2, byte[] bArr) {
return new EventMessage(str, str2, j2, j, bArr);
}
public EventStream buildEventStream(String str, String str2, long j, long[] jArr, EventMessage[] eventMessageArr) {
return new EventStream(str, str2, j, jArr, eventMessageArr);
}
public Format buildFormat(@Nullable String str, @Nullable String str2, int i, int i2, float f, int i3, int i4, int i5, @Nullable String str3, List<Descriptor> list, List<Descriptor> list2, @Nullable String str4, List<Descriptor> list3, List<Descriptor> list4) {
int i6;
int i7;
String str5 = str4;
String sampleMimeType = getSampleMimeType(str2, str5);
if ("audio/eac3".equals(sampleMimeType)) {
sampleMimeType = parseEac3SupplementalProperties(list4);
if ("audio/eac3-joc".equals(sampleMimeType)) {
str5 = "ec+3";
}
}
int parseSelectionFlagsFromRoleDescriptors = parseSelectionFlagsFromRoleDescriptors(list);
int parseRoleFlagsFromRoleDescriptors = parseRoleFlagsFromRoleDescriptors(list) | parseRoleFlagsFromAccessibilityDescriptors(list2) | parseRoleFlagsFromProperties(list3) | parseRoleFlagsFromProperties(list4);
Pair<Integer, Integer> parseTileCountFromProperties = parseTileCountFromProperties(list3);
Format.Builder language = new Format.Builder().setId(str).setContainerMimeType(str2).setSampleMimeType(sampleMimeType).setCodecs(str5).setPeakBitrate(i5).setSelectionFlags(parseSelectionFlagsFromRoleDescriptors).setRoleFlags(parseRoleFlagsFromRoleDescriptors).setLanguage(str3);
int i8 = -1;
if (parseTileCountFromProperties != null) {
i6 = ((Integer) parseTileCountFromProperties.first).intValue();
} else {
i6 = -1;
}
Format.Builder tileCountHorizontal = language.setTileCountHorizontal(i6);
if (parseTileCountFromProperties != null) {
i7 = ((Integer) parseTileCountFromProperties.second).intValue();
} else {
i7 = -1;
}
Format.Builder tileCountVertical = tileCountHorizontal.setTileCountVertical(i7);
if (MimeTypes.isVideo(sampleMimeType)) {
tileCountVertical.setWidth(i).setHeight(i2).setFrameRate(f);
} else if (MimeTypes.isAudio(sampleMimeType)) {
tileCountVertical.setChannelCount(i3).setSampleRate(i4);
} else if (MimeTypes.isText(sampleMimeType)) {
if ("application/cea-608".equals(sampleMimeType)) {
i8 = parseCea608AccessibilityChannel(list2);
} else if ("application/cea-708".equals(sampleMimeType)) {
i8 = parseCea708AccessibilityChannel(list2);
}
tileCountVertical.setAccessibilityChannel(i8);
} else if (MimeTypes.isImage(sampleMimeType)) {
tileCountVertical.setWidth(i).setHeight(i2);
}
return tileCountVertical.build();
}
public DashManifest buildMediaPresentationDescription(long j, long j2, long j3, boolean z, long j4, long j5, long j6, long j7, @Nullable ProgramInformation programInformation, @Nullable UtcTimingElement utcTimingElement, @Nullable ServiceDescriptionElement serviceDescriptionElement, @Nullable Uri uri, List<Period> list) {
return new DashManifest(j, j2, j3, z, j4, j5, j6, j7, programInformation, utcTimingElement, serviceDescriptionElement, uri, list);
}
public Period buildPeriod(@Nullable String str, long j, List<AdaptationSet> list, List<EventStream> list2, @Nullable Descriptor descriptor) {
return new Period(str, j, list, list2, descriptor);
}
public RangedUri buildRangedUri(String str, long j, long j2) {
return new RangedUri(str, j, j2);
}
public Representation buildRepresentation(RepresentationInfo representationInfo, @Nullable String str, @Nullable String str2, ArrayList<DrmInitData.SchemeData> arrayList, ArrayList<Descriptor> arrayList2) {
Format.Builder buildUpon = representationInfo.format.buildUpon();
if (str != null) {
buildUpon.setLabel(str);
}
String str3 = representationInfo.drmSchemeType;
if (str3 != null) {
str2 = str3;
}
ArrayList<DrmInitData.SchemeData> arrayList3 = representationInfo.drmSchemeDatas;
arrayList3.addAll(arrayList);
if (!arrayList3.isEmpty()) {
fillInClearKeyInformation(arrayList3);
filterRedundantIncompleteSchemeDatas(arrayList3);
buildUpon.setDrmInitData(new DrmInitData(str2, arrayList3));
}
ArrayList<Descriptor> arrayList4 = representationInfo.inbandEventStreams;
arrayList4.addAll(arrayList2);
return Representation.newInstance(representationInfo.revisionId, buildUpon.build(), representationInfo.baseUrls, representationInfo.segmentBase, arrayList4, representationInfo.essentialProperties, representationInfo.supplementalProperties, null);
}
public SegmentBase.SegmentList buildSegmentList(RangedUri rangedUri, long j, long j2, long j3, long j4, @Nullable List<SegmentBase.SegmentTimelineElement> list, long j5, @Nullable List<RangedUri> list2, long j6, long j7) {
return new SegmentBase.SegmentList(rangedUri, j, j2, j3, j4, list, j5, list2, Util.msToUs(j6), Util.msToUs(j7));
}
public SegmentBase.SegmentTemplate buildSegmentTemplate(RangedUri rangedUri, long j, long j2, long j3, long j4, long j5, List<SegmentBase.SegmentTimelineElement> list, long j6, @Nullable UrlTemplate urlTemplate, @Nullable UrlTemplate urlTemplate2, long j7, long j8) {
return new SegmentBase.SegmentTemplate(rangedUri, j, j2, j3, j4, j5, list, j6, urlTemplate, urlTemplate2, Util.msToUs(j7), Util.msToUs(j8));
}
public SegmentBase.SegmentTimelineElement buildSegmentTimelineElement(long j, long j2) {
return new SegmentBase.SegmentTimelineElement(j, j2);
}
public SegmentBase.SingleSegmentBase buildSingleSegmentBase(RangedUri rangedUri, long j, long j2, long j3, long j4) {
return new SegmentBase.SingleSegmentBase(rangedUri, j, j2, j3, j4);
}
public UtcTimingElement buildUtcTimingElement(String str, String str2) {
return new UtcTimingElement(str, str2);
}
public AdaptationSet parseAdaptationSet(XmlPullParser xmlPullParser, List<BaseUrl> list, @Nullable SegmentBase segmentBase, long j, long j2, long j3, long j4, long j5, boolean z) throws XmlPullParserException, IOException {
long j6;
ArrayList<Descriptor> arrayList;
Object obj;
long j7;
ArrayList arrayList2;
ArrayList arrayList3;
ArrayList arrayList4;
ArrayList arrayList5;
ArrayList arrayList6;
ArrayList<DrmInitData.SchemeData> arrayList7;
String str;
String str2;
ArrayList arrayList8;
int i;
ArrayList<Descriptor> arrayList9;
long parseAvailabilityTimeOffsetUs;
List<BaseUrl> list2;
DashManifestParser dashManifestParser = this;
XmlPullParser xmlPullParser2 = xmlPullParser;
int parseInt = parseInt(xmlPullParser2, "id", -1);
int parseContentType = parseContentType(xmlPullParser);
String attributeValue = xmlPullParser2.getAttributeValue(null, "mimeType");
String attributeValue2 = xmlPullParser2.getAttributeValue(null, "codecs");
int parseInt2 = parseInt(xmlPullParser2, "width", -1);
int parseInt3 = parseInt(xmlPullParser2, "height", -1);
float parseFrameRate = parseFrameRate(xmlPullParser2, -1.0f);
int parseInt4 = parseInt(xmlPullParser2, "audioSamplingRate", -1);
String str3 = "lang";
String attributeValue3 = xmlPullParser2.getAttributeValue(null, "lang");
String attributeValue4 = xmlPullParser2.getAttributeValue(null, "label");
ArrayList<DrmInitData.SchemeData> arrayList10 = new ArrayList<>();
ArrayList<Descriptor> arrayList11 = new ArrayList<>();
ArrayList arrayList12 = new ArrayList();
ArrayList arrayList13 = new ArrayList();
ArrayList arrayList14 = new ArrayList();
ArrayList arrayList15 = new ArrayList();
ArrayList arrayList16 = new ArrayList();
ArrayList arrayList17 = new ArrayList();
SegmentBase segmentBase2 = segmentBase;
int i2 = parseContentType;
String str4 = attributeValue3;
String str5 = attributeValue4;
String str6 = null;
int i3 = -1;
boolean z2 = false;
long j8 = j2;
long j9 = j3;
while (true) {
xmlPullParser.next();
if (XmlPullParserUtil.isStartTag(xmlPullParser2, "BaseURL")) {
if (!z2) {
j8 = dashManifestParser.parseAvailabilityTimeOffsetUs(xmlPullParser2, j8);
z2 = true;
}
j6 = j9;
arrayList = arrayList11;
arrayList17.addAll(dashManifestParser.parseBaseUrl(xmlPullParser2, list, z));
} else {
j6 = j9;
arrayList = arrayList11;
if (XmlPullParserUtil.isStartTag(xmlPullParser2, "ContentProtection")) {
Pair<String, DrmInitData.SchemeData> parseContentProtection = parseContentProtection(xmlPullParser);
Object obj2 = parseContentProtection.first;
if (obj2 != null) {
str6 = (String) obj2;
}
Object obj3 = parseContentProtection.second;
if (obj3 != null) {
arrayList10.add((DrmInitData.SchemeData) obj3);
}
} else {
if (XmlPullParserUtil.isStartTag(xmlPullParser2, "ContentComponent")) {
String checkLanguageConsistency = checkLanguageConsistency(str4, xmlPullParser2.getAttributeValue(null, str3));
int checkContentTypeConsistency = checkContentTypeConsistency(i2, parseContentType(xmlPullParser));
str2 = checkLanguageConsistency;
obj = null;
j7 = j8;
arrayList2 = arrayList17;
arrayList8 = arrayList16;
arrayList3 = arrayList15;
arrayList4 = arrayList14;
arrayList5 = arrayList13;
arrayList6 = arrayList12;
arrayList7 = arrayList10;
str = str3;
i = checkContentTypeConsistency;
arrayList9 = arrayList;
} else {
int i4 = i2;
String str7 = str4;
if (XmlPullParserUtil.isStartTag(xmlPullParser2, "Role")) {
arrayList13.add(parseDescriptor(xmlPullParser2, "Role"));
} else if (XmlPullParserUtil.isStartTag(xmlPullParser2, "AudioChannelConfiguration")) {
i3 = parseAudioChannelConfiguration(xmlPullParser);
} else if (XmlPullParserUtil.isStartTag(xmlPullParser2, "Accessibility")) {
arrayList12.add(parseDescriptor(xmlPullParser2, "Accessibility"));
} else if (XmlPullParserUtil.isStartTag(xmlPullParser2, "EssentialProperty")) {
arrayList14.add(parseDescriptor(xmlPullParser2, "EssentialProperty"));
} else if (XmlPullParserUtil.isStartTag(xmlPullParser2, "SupplementalProperty")) {
arrayList15.add(parseDescriptor(xmlPullParser2, "SupplementalProperty"));
} else if (XmlPullParserUtil.isStartTag(xmlPullParser2, "Representation")) {
if (!arrayList17.isEmpty()) {
list2 = arrayList17;
} else {
list2 = list;
}
j7 = j8;
arrayList2 = arrayList17;
arrayList3 = arrayList15;
arrayList4 = arrayList14;
arrayList5 = arrayList13;
arrayList6 = arrayList12;
arrayList7 = arrayList10;
str = str3;
obj = null;
str2 = str7;
RepresentationInfo parseRepresentation = parseRepresentation(xmlPullParser, list2, attributeValue, attributeValue2, parseInt2, parseInt3, parseFrameRate, i3, parseInt4, str7, arrayList5, arrayList6, arrayList4, arrayList3, segmentBase2, j4, j, j7, j6, j5, z);
int checkContentTypeConsistency2 = checkContentTypeConsistency(i4, MimeTypes.getTrackType(parseRepresentation.format.sampleMimeType));
arrayList8 = arrayList16;
arrayList8.add(parseRepresentation);
xmlPullParser2 = xmlPullParser;
i = checkContentTypeConsistency2;
arrayList9 = arrayList;
} else {
obj = null;
j7 = j8;
arrayList2 = arrayList17;
arrayList3 = arrayList15;
arrayList4 = arrayList14;
arrayList5 = arrayList13;
arrayList6 = arrayList12;
arrayList7 = arrayList10;
str = str3;
str2 = str7;
arrayList8 = arrayList16;
if (XmlPullParserUtil.isStartTag(xmlPullParser, "SegmentBase")) {
segmentBase2 = parseSegmentBase(xmlPullParser, (SegmentBase.SingleSegmentBase) segmentBase2);
i = i4;
arrayList9 = arrayList;
j9 = j6;
xmlPullParser2 = xmlPullParser;
} else {
if (XmlPullParserUtil.isStartTag(xmlPullParser, "SegmentList")) {
parseAvailabilityTimeOffsetUs = parseAvailabilityTimeOffsetUs(xmlPullParser, j6);
i = i4;
segmentBase2 = parseSegmentList(xmlPullParser, (SegmentBase.SegmentList) segmentBase2, j4, j, j7, parseAvailabilityTimeOffsetUs, j5);
xmlPullParser2 = xmlPullParser;
} else {
j9 = j6;
i = i4;
if (XmlPullParserUtil.isStartTag(xmlPullParser, "SegmentTemplate")) {
parseAvailabilityTimeOffsetUs = parseAvailabilityTimeOffsetUs(xmlPullParser, j9);
xmlPullParser2 = xmlPullParser;
segmentBase2 = parseSegmentTemplate(xmlPullParser, (SegmentBase.SegmentTemplate) segmentBase2, arrayList3, j4, j, j7, parseAvailabilityTimeOffsetUs, j5);
} else {
xmlPullParser2 = xmlPullParser;
if (XmlPullParserUtil.isStartTag(xmlPullParser2, "InbandEventStream")) {
arrayList9 = arrayList;
arrayList9.add(parseDescriptor(xmlPullParser2, "InbandEventStream"));
} else {
arrayList9 = arrayList;
if (XmlPullParserUtil.isStartTag(xmlPullParser2, "Label")) {
str5 = parseLabel(xmlPullParser);
} else if (XmlPullParserUtil.isStartTag(xmlPullParser)) {
parseAdaptationSetChild(xmlPullParser);
}
}
}
}
j9 = parseAvailabilityTimeOffsetUs;
arrayList9 = arrayList;
}
if (!XmlPullParserUtil.isEndTag(xmlPullParser2, "AdaptationSet")) {
break;
}
arrayList11 = arrayList9;
arrayList16 = arrayList8;
arrayList17 = arrayList2;
arrayList15 = arrayList3;
j8 = j7;
arrayList14 = arrayList4;
arrayList13 = arrayList5;
arrayList12 = arrayList6;
arrayList10 = arrayList7;
str3 = str;
i2 = i;
str4 = str2;
dashManifestParser = this;
}
obj = null;
j7 = j8;
arrayList2 = arrayList17;
arrayList3 = arrayList15;
arrayList4 = arrayList14;
arrayList5 = arrayList13;
arrayList6 = arrayList12;
arrayList7 = arrayList10;
str = str3;
i = i4;
str2 = str7;
arrayList9 = arrayList;
j9 = j6;
arrayList8 = arrayList16;
if (!XmlPullParserUtil.isEndTag(xmlPullParser2, "AdaptationSet")) {
}
}
j9 = j6;
if (!XmlPullParserUtil.isEndTag(xmlPullParser2, "AdaptationSet")) {
}
}
}
j9 = j6;
j7 = j8;
arrayList8 = arrayList16;
arrayList4 = arrayList14;
arrayList5 = arrayList13;
arrayList6 = arrayList12;
arrayList7 = arrayList10;
str = str3;
arrayList9 = arrayList;
i = i2;
str2 = str4;
obj = null;
arrayList2 = arrayList17;
arrayList3 = arrayList15;
if (!XmlPullParserUtil.isEndTag(xmlPullParser2, "AdaptationSet")) {
}
}
ArrayList arrayList18 = new ArrayList(arrayList8.size());
for (int i5 = 0; i5 < arrayList8.size(); i5++) {
arrayList18.add(buildRepresentation((RepresentationInfo) arrayList8.get(i5), str5, str6, arrayList7, arrayList9));
}
return buildAdaptationSet(parseInt, i, arrayList18, arrayList6, arrayList4, arrayList3);
}
public void parseAdaptationSetChild(XmlPullParser xmlPullParser) throws XmlPullParserException, IOException {
maybeSkipTag(xmlPullParser);
}
public int parseAudioChannelConfiguration(XmlPullParser xmlPullParser) throws XmlPullParserException, IOException {
char c;
String parseString = parseString(xmlPullParser, "schemeIdUri", null);
parseString.getClass();
int i = -1;
switch (parseString.hashCode()) {
case -2128649360:
if (parseString.equals("urn:dts:dash:audio_channel_configuration:2012")) {
c = 0;
break;
}
c = 65535;
break;
case -1352850286:
if (parseString.equals("urn:mpeg:dash:23003:3:audio_channel_configuration:2011")) {
c = 1;
break;
}
c = 65535;
break;
case -1138141449:
if (parseString.equals("tag:dolby.com,2014:dash:audio_channel_configuration:2011")) {
c = 2;
break;
}
c = 65535;
break;
case -986633423:
if (parseString.equals("urn:mpeg:mpegB:cicp:ChannelConfiguration")) {
c = 3;
break;
}
c = 65535;
break;
case -79006963:
if (parseString.equals("tag:dts.com,2014:dash:audio_channel_configuration:2012")) {
c = 4;
break;
}
c = 65535;
break;
case 312179081:
if (parseString.equals("tag:dts.com,2018:uhd:audio_channel_configuration")) {
c = 5;
break;
}
c = 65535;
break;
case 2036691300:
if (parseString.equals("urn:dolby:dash:audio_channel_configuration:2011")) {
c = 6;
break;
}
c = 65535;
break;
default:
c = 65535;
break;
}
switch (c) {
case 0:
case 4:
i = parseDtsChannelConfiguration(xmlPullParser);
break;
case 1:
i = parseInt(xmlPullParser, t4.h.X, -1);
break;
case 2:
case 6:
i = parseDolbyChannelConfiguration(xmlPullParser);
break;
case 3:
i = parseMpegChannelConfiguration(xmlPullParser);
break;
case 5:
i = parseDtsxChannelConfiguration(xmlPullParser);
break;
}
do {
xmlPullParser.next();
} while (!XmlPullParserUtil.isEndTag(xmlPullParser, "AudioChannelConfiguration"));
return i;
}
public long parseAvailabilityTimeOffsetUs(XmlPullParser xmlPullParser, long j) {
String attributeValue = xmlPullParser.getAttributeValue(null, "availabilityTimeOffset");
if (attributeValue == null) {
return j;
}
if ("INF".equals(attributeValue)) {
return Long.MAX_VALUE;
}
return Float.parseFloat(attributeValue) * 1000000.0f;
}
public List<BaseUrl> parseBaseUrl(XmlPullParser xmlPullParser, List<BaseUrl> list, boolean z) throws XmlPullParserException, IOException {
int i;
int i2;
String str;
String attributeValue = xmlPullParser.getAttributeValue(null, "dvb:priority");
if (attributeValue != null) {
i = Integer.parseInt(attributeValue);
} else if (z) {
i = 1;
} else {
i = Integer.MIN_VALUE;
}
String attributeValue2 = xmlPullParser.getAttributeValue(null, "dvb:weight");
if (attributeValue2 != null) {
i2 = Integer.parseInt(attributeValue2);
} else {
i2 = 1;
}
String attributeValue3 = xmlPullParser.getAttributeValue(null, "serviceLocation");
String parseText = parseText(xmlPullParser, "BaseURL");
if (UriUtil.isAbsolute(parseText)) {
if (attributeValue3 == null) {
attributeValue3 = parseText;
}
return abBDacbDA.cBBdBADc(new BaseUrl(parseText, attributeValue3, i, i2));
}
ArrayList arrayList = new ArrayList();
for (int i3 = 0; i3 < list.size(); i3++) {
BaseUrl baseUrl = list.get(i3);
String resolve = UriUtil.resolve(baseUrl.url, parseText);
if (attributeValue3 == null) {
str = resolve;
} else {
str = attributeValue3;
}
if (z) {
i = baseUrl.priority;
i2 = baseUrl.weight;
str = baseUrl.serviceLocation;
}
arrayList.add(new BaseUrl(resolve, str, i, i2));
}
return arrayList;
}
public Pair<String, DrmInitData.SchemeData> parseContentProtection(XmlPullParser xmlPullParser) throws XmlPullParserException, IOException {
String str;
?? r3;
String str2;
String str3;
?? r4;
DrmInitData.SchemeData schemeData = null;
String attributeValue = xmlPullParser.getAttributeValue(null, "schemeIdUri");
if (attributeValue != null) {
String dDbCdDC2 = babbDABcB.dDbCdDC(attributeValue);
dDbCdDC2.getClass();
char c = 65535;
switch (dDbCdDC2.hashCode()) {
case -1980789791:
if (dDbCdDC2.equals("urn:uuid:e2719d58-a985-b3c9-781a-b030af78d30e")) {
c = 0;
break;
}
break;
case 489446379:
if (dDbCdDC2.equals("urn:uuid:9a04f079-9840-4286-ab92-e65be0885f95")) {
c = 1;
break;
}
break;
case 755418770:
if (dDbCdDC2.equals("urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed")) {
c = 2;
break;
}
break;
case 1812765994:
if (dDbCdDC2.equals("urn:mpeg:dash:mp4protection:2011")) {
c = 3;
break;
}
break;
}
switch (c) {
case 0:
r3 = C.CLEARKEY_UUID;
str = null;
str2 = null;
str3 = str2;
r4 = str2;
break;
case 1:
r3 = C.PLAYREADY_UUID;
str = null;
str2 = null;
str3 = str2;
r4 = str2;
break;
case 2:
r3 = C.WIDEVINE_UUID;
str = null;
str2 = null;
str3 = str2;
r4 = str2;
break;
case 3:
str = xmlPullParser.getAttributeValue(null, t4.h.X);
String attributeValueIgnorePrefix = XmlPullParserUtil.getAttributeValueIgnorePrefix(xmlPullParser, "default_KID");
if (!TextUtils.isEmpty(attributeValueIgnorePrefix) && !"00000000-0000-0000-0000-000000000000".equals(attributeValueIgnorePrefix)) {
String[] split = attributeValueIgnorePrefix.split("\\s+");
UUID[] uuidArr = new UUID[split.length];
for (int i = 0; i < split.length; i++) {
uuidArr[i] = UUID.fromString(split[i]);
}
r3 = C.COMMON_PSSH_UUID;
str3 = null;
r4 = PsshAtomUtil.buildPsshAtom(r3, uuidArr, null);
break;
} else {
r3 = null;
str2 = r3;
str3 = str2;
r4 = str2;
break;
}
break;
}
do {
xmlPullParser.next();
if (!XmlPullParserUtil.isStartTag(xmlPullParser, "clearkey:Laurl") && xmlPullParser.next() == 4) {
str3 = xmlPullParser.getText();
r4 = r4;
} else if (!XmlPullParserUtil.isStartTag(xmlPullParser, "ms:laurl")) {
str3 = xmlPullParser.getAttributeValue(null, "licenseUrl");
r4 = r4;
} else if (r4 == 0 && XmlPullParserUtil.isStartTagIgnorePrefix(xmlPullParser, "pssh") && xmlPullParser.next() == 4) {
byte[] decode = Base64.decode(xmlPullParser.getText(), 0);
UUID parseUuid = PsshAtomUtil.parseUuid(decode);
if (parseUuid == null) {
Log.w(TAG, "Skipping malformed cenc:pssh data");
r3 = parseUuid;
r4 = 0;
} else {
r4 = decode;
r3 = parseUuid;
}
} else {
if (r4 == 0) {
?? r6 = C.PLAYREADY_UUID;
if (r6.equals(r3) && XmlPullParserUtil.isStartTag(xmlPullParser, "mspr:pro") && xmlPullParser.next() == 4) {
r4 = PsshAtomUtil.buildPsshAtom(r6, Base64.decode(xmlPullParser.getText(), 0));
}
}
maybeSkipTag(xmlPullParser);
r4 = r4;
}
} while (!XmlPullParserUtil.isEndTag(xmlPullParser, "ContentProtection"));
if (r3 != null) {
schemeData = new DrmInitData.SchemeData(r3, str3, "video/mp4", r4);
}
return Pair.create(str, schemeData);
}
str = null;
r3 = null;
str2 = r3;
str3 = str2;
r4 = str2;
do {
xmlPullParser.next();
if (!XmlPullParserUtil.isStartTag(xmlPullParser, "clearkey:Laurl")) {
}
if (!XmlPullParserUtil.isStartTag(xmlPullParser, "ms:laurl")) {
}
} while (!XmlPullParserUtil.isEndTag(xmlPullParser, "ContentProtection"));
if (r3 != null) {
}
return Pair.create(str, schemeData);
}
public int parseContentType(XmlPullParser xmlPullParser) {
String attributeValue = xmlPullParser.getAttributeValue(null, "contentType");
if (TextUtils.isEmpty(attributeValue)) {
return -1;
}
if ("audio".equals(attributeValue)) {
return 1;
}
if ("video".equals(attributeValue)) {
return 2;
}
if ("text".equals(attributeValue)) {
return 3;
}
if (!"image".equals(attributeValue)) {
return -1;
}
return 4;
}
public Pair<Long, EventMessage> parseEvent(XmlPullParser xmlPullParser, String str, String str2, long j, long j2, ByteArrayOutputStream byteArrayOutputStream) throws IOException, XmlPullParserException {
long parseLong = parseLong(xmlPullParser, "id", 0L);
long parseLong2 = parseLong(xmlPullParser, "duration", -9223372036854775807L);
long parseLong3 = parseLong(xmlPullParser, "presentationTime", 0L);
long scaleLargeTimestamp = Util.scaleLargeTimestamp(parseLong2, 1000L, j);
long scaleLargeTimestamp2 = Util.scaleLargeTimestamp(parseLong3 - j2, 1000000L, j);
String parseString = parseString(xmlPullParser, "messageData", null);
byte[] parseEventObject = parseEventObject(xmlPullParser, byteArrayOutputStream);
Long valueOf = Long.valueOf(scaleLargeTimestamp2);
if (parseString != null) {
parseEventObject = Util.getUtf8Bytes(parseString);
}
return Pair.create(valueOf, buildEvent(str, str2, parseLong, scaleLargeTimestamp, parseEventObject));
}
public byte[] parseEventObject(XmlPullParser xmlPullParser, ByteArrayOutputStream byteArrayOutputStream) throws XmlPullParserException, IOException {
byteArrayOutputStream.reset();
XmlSerializer newSerializer = Xml.newSerializer();
newSerializer.setOutput(byteArrayOutputStream, dcadbB.f57054babbDABcB.name());
xmlPullParser.nextToken();
while (!XmlPullParserUtil.isEndTag(xmlPullParser, "Event")) {
switch (xmlPullParser.getEventType()) {
case 0:
newSerializer.startDocument(null, Boolean.FALSE);
break;
case 1:
newSerializer.endDocument();
break;
case 2:
newSerializer.startTag(xmlPullParser.getNamespace(), xmlPullParser.getName());
for (int i = 0; i < xmlPullParser.getAttributeCount(); i++) {
newSerializer.attribute(xmlPullParser.getAttributeNamespace(i), xmlPullParser.getAttributeName(i), xmlPullParser.getAttributeValue(i));
}
break;
case 3:
newSerializer.endTag(xmlPullParser.getNamespace(), xmlPullParser.getName());
break;
case 4:
newSerializer.text(xmlPullParser.getText());
break;
case 5:
newSerializer.cdsect(xmlPullParser.getText());
break;
case 6:
newSerializer.entityRef(xmlPullParser.getText());
break;
case 7:
newSerializer.ignorableWhitespace(xmlPullParser.getText());
break;
case 8:
newSerializer.processingInstruction(xmlPullParser.getText());
break;
case 9:
newSerializer.comment(xmlPullParser.getText());
break;
case 10:
newSerializer.docdecl(xmlPullParser.getText());
break;
}
xmlPullParser.nextToken();
}
newSerializer.flush();
return byteArrayOutputStream.toByteArray();
}
public EventStream parseEventStream(XmlPullParser xmlPullParser) throws XmlPullParserException, IOException {
ByteArrayOutputStream byteArrayOutputStream;
long j;
ArrayList arrayList;
String parseString = parseString(xmlPullParser, "schemeIdUri", "");
String parseString2 = parseString(xmlPullParser, t4.h.X, "");
long parseLong = parseLong(xmlPullParser, "timescale", 1L);
long parseLong2 = parseLong(xmlPullParser, "presentationTimeOffset", 0L);
ArrayList arrayList2 = new ArrayList();
ByteArrayOutputStream byteArrayOutputStream2 = new ByteArrayOutputStream(512);
while (true) {
xmlPullParser.next();
if (XmlPullParserUtil.isStartTag(xmlPullParser, "Event")) {
byteArrayOutputStream = byteArrayOutputStream2;
long j2 = parseLong2;
j = parseLong2;
arrayList = arrayList2;
arrayList.add(parseEvent(xmlPullParser, parseString, parseString2, parseLong, j2, byteArrayOutputStream));
} else {
byteArrayOutputStream = byteArrayOutputStream2;
j = parseLong2;
arrayList = arrayList2;
maybeSkipTag(xmlPullParser);
}
if (XmlPullParserUtil.isEndTag(xmlPullParser, "EventStream")) {
break;
}
arrayList2 = arrayList;
byteArrayOutputStream2 = byteArrayOutputStream;
parseLong2 = j;
}
long[] jArr = new long[arrayList.size()];
EventMessage[] eventMessageArr = new EventMessage[arrayList.size()];
for (int i = 0; i < arrayList.size(); i++) {
Pair pair = (Pair) arrayList.get(i);
jArr[i] = ((Long) pair.first).longValue();
eventMessageArr[i] = (EventMessage) pair.second;
}
return buildEventStream(parseString, parseString2, parseLong, jArr, eventMessageArr);
}
public RangedUri parseInitialization(XmlPullParser xmlPullParser) {
return parseRangedUrl(xmlPullParser, "sourceURL", "range");
}
public String parseLabel(XmlPullParser xmlPullParser) throws XmlPullParserException, IOException {
return parseText(xmlPullParser, "Label");
}
public DashManifest parseMediaPresentationDescription(XmlPullParser xmlPullParser, Uri uri) throws XmlPullParserException, IOException {
long j;
long j2;
long j3;
long j4;
int i;
long j5;
long j6;
ArrayList arrayList;
ArrayList arrayList2;
long j7;
Throwable th;
ArrayList arrayList3;
ArrayList arrayList4;
long j8;
boolean z;
long j9;
DashManifestParser dashManifestParser = this;
boolean isDvbProfileDeclared = dashManifestParser.isDvbProfileDeclared(dashManifestParser.parseProfiles(xmlPullParser, "profiles", new String[0]));
long j10 = -9223372036854775807L;
long parseDateTime = parseDateTime(xmlPullParser, "availabilityStartTime", -9223372036854775807L);
long parseDuration = parseDuration(xmlPullParser, "mediaPresentationDuration", -9223372036854775807L);
long parseDuration2 = parseDuration(xmlPullParser, "minBufferTime", -9223372036854775807L);
Throwable th2 = null;
boolean equals = "dynamic".equals(xmlPullParser.getAttributeValue(null, "type"));
if (equals) {
j = parseDuration(xmlPullParser, "minimumUpdatePeriod", -9223372036854775807L);
} else {
j = -9223372036854775807L;
}
if (equals) {
j2 = parseDuration(xmlPullParser, "timeShiftBufferDepth", -9223372036854775807L);
} else {
j2 = -9223372036854775807L;
}
if (equals) {
j3 = parseDuration(xmlPullParser, "suggestedPresentationDelay", -9223372036854775807L);
} else {
j3 = -9223372036854775807L;
}
long parseDateTime2 = parseDateTime(xmlPullParser, "publishTime", -9223372036854775807L);
if (equals) {
j4 = 0;
} else {
j4 = -9223372036854775807L;
}
String uri2 = uri.toString();
String uri3 = uri.toString();
if (isDvbProfileDeclared) {
i = 1;
} else {
i = Integer.MIN_VALUE;
}
ArrayList cBBdBADc2 = abBDacbDA.cBBdBADc(new BaseUrl(uri2, uri3, i, 1));
ArrayList arrayList5 = new ArrayList();
ArrayList arrayList6 = new ArrayList();
if (equals) {
j5 = -9223372036854775807L;
} else {
j5 = 0;
}
long j11 = j5;
ProgramInformation programInformation = null;
UtcTimingElement utcTimingElement = null;
Uri uri4 = null;
ServiceDescriptionElement serviceDescriptionElement = null;
boolean z2 = false;
boolean z3 = false;
while (true) {
xmlPullParser.next();
if (XmlPullParserUtil.isStartTag(xmlPullParser, "BaseURL")) {
if (!z2) {
j4 = dashManifestParser.parseAvailabilityTimeOffsetUs(xmlPullParser, j4);
z2 = true;
}
arrayList6.addAll(dashManifestParser.parseBaseUrl(xmlPullParser, cBBdBADc2, isDvbProfileDeclared));
} else if (XmlPullParserUtil.isStartTag(xmlPullParser, "ProgramInformation")) {
programInformation = parseProgramInformation(xmlPullParser);
} else if (XmlPullParserUtil.isStartTag(xmlPullParser, "UTCTiming")) {
utcTimingElement = parseUtcTiming(xmlPullParser);
} else if (XmlPullParserUtil.isStartTag(xmlPullParser, "Location")) {
uri4 = UriUtil.resolveToUri(uri.toString(), xmlPullParser.nextText());
} else if (XmlPullParserUtil.isStartTag(xmlPullParser, "ServiceDescription")) {
serviceDescriptionElement = parseServiceDescription(xmlPullParser);
} else {
if (XmlPullParserUtil.isStartTag(xmlPullParser, "Period") && !z3) {
if (!arrayList6.isEmpty()) {
arrayList4 = arrayList6;
} else {
arrayList4 = cBBdBADc2;
}
j6 = j4;
ArrayList arrayList7 = arrayList5;
arrayList = arrayList6;
arrayList2 = cBBdBADc2;
j7 = j10;
th = th2;
Pair<Period, Long> parsePeriod = parsePeriod(xmlPullParser, arrayList4, j11, j6, parseDateTime, j2, isDvbProfileDeclared);
Period period = (Period) parsePeriod.first;
if (period.startMs == j7) {
if (equals) {
arrayList3 = arrayList7;
z = true;
} else {
throw ParserException.createForMalformedManifest("Unable to determine start of period " + arrayList7.size(), th);
}
} else {
long longValue = ((Long) parsePeriod.second).longValue();
if (longValue == j7) {
arrayList3 = arrayList7;
j8 = j7;
} else {
j8 = period.startMs + longValue;
arrayList3 = arrayList7;
}
arrayList3.add(period);
j11 = j8;
z = z3;
}
z3 = z;
} else {
j6 = j4;
arrayList = arrayList6;
arrayList2 = cBBdBADc2;
j7 = j10;
th = th2;
arrayList3 = arrayList5;
maybeSkipTag(xmlPullParser);
}
j4 = j6;
if (!XmlPullParserUtil.isEndTag(xmlPullParser, "MPD")) {
if (parseDuration == j7) {
if (j11 != j7) {
j9 = j11;
if (arrayList3.isEmpty()) {
return buildMediaPresentationDescription(parseDateTime, j9, parseDuration2, equals, j, j2, j3, parseDateTime2, programInformation, utcTimingElement, serviceDescriptionElement, uri4, arrayList3);
}
throw ParserException.createForMalformedManifest("No periods found.", th);
}
if (!equals) {
throw ParserException.createForMalformedManifest("Unable to determine duration of static manifest.", th);
}
}
j9 = parseDuration;
if (arrayList3.isEmpty()) {
}
} else {
arrayList5 = arrayList3;
th2 = th;
arrayList6 = arrayList;
cBBdBADc2 = arrayList2;
j10 = j7;
dashManifestParser = this;
}
}
arrayList = arrayList6;
arrayList2 = cBBdBADc2;
j7 = j10;
th = th2;
arrayList3 = arrayList5;
if (!XmlPullParserUtil.isEndTag(xmlPullParser, "MPD")) {
}
}
}
public Pair<Period, Long> parsePeriod(XmlPullParser xmlPullParser, List<BaseUrl> list, long j, long j2, long j3, long j4, boolean z) throws XmlPullParserException, IOException {
long j5;
long j6;
ArrayList arrayList;
ArrayList arrayList2;
ArrayList arrayList3;
Object obj;
long j7;
SegmentBase parseSegmentTemplate;
List<BaseUrl> list2;
DashManifestParser dashManifestParser = this;
XmlPullParser xmlPullParser2 = xmlPullParser;
Object obj2 = null;
String attributeValue = xmlPullParser2.getAttributeValue(null, "id");
long parseDuration = parseDuration(xmlPullParser2, "start", j);
long j8 = -9223372036854775807L;
if (j3 != -9223372036854775807L) {
j5 = j3 + parseDuration;
} else {
j5 = -9223372036854775807L;
}
long parseDuration2 = parseDuration(xmlPullParser2, "duration", -9223372036854775807L);
ArrayList arrayList4 = new ArrayList();
ArrayList arrayList5 = new ArrayList();
ArrayList arrayList6 = new ArrayList();
long j9 = j2;
long j10 = -9223372036854775807L;
SegmentBase segmentBase = null;
Descriptor descriptor = null;
boolean z2 = false;
while (true) {
xmlPullParser.next();
if (XmlPullParserUtil.isStartTag(xmlPullParser2, "BaseURL")) {
if (!z2) {
j9 = dashManifestParser.parseAvailabilityTimeOffsetUs(xmlPullParser2, j9);
z2 = true;
}
arrayList6.addAll(dashManifestParser.parseBaseUrl(xmlPullParser2, list, z));
arrayList3 = arrayList5;
arrayList = arrayList6;
j7 = j8;
obj = obj2;
arrayList2 = arrayList4;
} else {
if (XmlPullParserUtil.isStartTag(xmlPullParser2, "AdaptationSet")) {
if (!arrayList6.isEmpty()) {
list2 = arrayList6;
} else {
list2 = list;
}
j6 = j9;
arrayList = arrayList6;
arrayList2 = arrayList4;
arrayList2.add(parseAdaptationSet(xmlPullParser, list2, segmentBase, parseDuration2, j9, j10, j5, j4, z));
xmlPullParser2 = xmlPullParser;
arrayList3 = arrayList5;
} else {
j6 = j9;
ArrayList arrayList7 = arrayList5;
arrayList = arrayList6;
arrayList2 = arrayList4;
xmlPullParser2 = xmlPullParser;
if (XmlPullParserUtil.isStartTag(xmlPullParser2, "EventStream")) {
arrayList7.add(parseEventStream(xmlPullParser));
arrayList3 = arrayList7;
} else if (XmlPullParserUtil.isStartTag(xmlPullParser2, "SegmentBase")) {
arrayList3 = arrayList7;
segmentBase = parseSegmentBase(xmlPullParser2, null);
obj = null;
j9 = j6;
j7 = -9223372036854775807L;
} else {
arrayList3 = arrayList7;
if (XmlPullParserUtil.isStartTag(xmlPullParser2, "SegmentList")) {
long parseAvailabilityTimeOffsetUs = parseAvailabilityTimeOffsetUs(xmlPullParser2, -9223372036854775807L);
obj = null;
parseSegmentTemplate = parseSegmentList(xmlPullParser, null, j5, parseDuration2, j6, parseAvailabilityTimeOffsetUs, j4);
j10 = parseAvailabilityTimeOffsetUs;
j9 = j6;
j7 = -9223372036854775807L;
} else {
obj = null;
if (XmlPullParserUtil.isStartTag(xmlPullParser2, "SegmentTemplate")) {
long parseAvailabilityTimeOffsetUs2 = parseAvailabilityTimeOffsetUs(xmlPullParser2, -9223372036854775807L);
j7 = -9223372036854775807L;
parseSegmentTemplate = parseSegmentTemplate(xmlPullParser, null, ddbaba.BcBaaccAbbd(), j5, parseDuration2, j6, parseAvailabilityTimeOffsetUs2, j4);
j10 = parseAvailabilityTimeOffsetUs2;
j9 = j6;
} else {
j7 = -9223372036854775807L;
if (XmlPullParserUtil.isStartTag(xmlPullParser2, "AssetIdentifier")) {
descriptor = parseDescriptor(xmlPullParser2, "AssetIdentifier");
} else {
maybeSkipTag(xmlPullParser);
}
j9 = j6;
}
}
segmentBase = parseSegmentTemplate;
}
}
obj = null;
j7 = -9223372036854775807L;
j9 = j6;
}
if (XmlPullParserUtil.isEndTag(xmlPullParser2, "Period")) {
return Pair.create(buildPeriod(attributeValue, parseDuration, arrayList2, arrayList3, descriptor), Long.valueOf(parseDuration2));
}
arrayList4 = arrayList2;
arrayList6 = arrayList;
obj2 = obj;
arrayList5 = arrayList3;
j8 = j7;
dashManifestParser = this;
}
}
public String[] parseProfiles(XmlPullParser xmlPullParser, String str, String[] strArr) {
String attributeValue = xmlPullParser.getAttributeValue(null, str);
if (attributeValue == null) {
return strArr;
}
return attributeValue.split(",");
}
public ProgramInformation parseProgramInformation(XmlPullParser xmlPullParser) throws IOException, XmlPullParserException {
String str = null;
String parseString = parseString(xmlPullParser, "moreInformationURL", null);
String parseString2 = parseString(xmlPullParser, "lang", null);
String str2 = null;
String str3 = null;
while (true) {
xmlPullParser.next();
if (XmlPullParserUtil.isStartTag(xmlPullParser, "Title")) {
str = xmlPullParser.nextText();
} else if (XmlPullParserUtil.isStartTag(xmlPullParser, "Source")) {
str2 = xmlPullParser.nextText();
} else if (XmlPullParserUtil.isStartTag(xmlPullParser, ExifInterface.f27016ACbAdA)) {
str3 = xmlPullParser.nextText();
} else {
maybeSkipTag(xmlPullParser);
}
String str4 = str3;
if (XmlPullParserUtil.isEndTag(xmlPullParser, "ProgramInformation")) {
return new ProgramInformation(str, str2, str4, parseString, parseString2);
}
str3 = str4;
}
}
public RangedUri parseRangedUrl(XmlPullParser xmlPullParser, String str, String str2) {
long j;
long j2;
String attributeValue = xmlPullParser.getAttributeValue(null, str);
String attributeValue2 = xmlPullParser.getAttributeValue(null, str2);
if (attributeValue2 != null) {
String[] split = attributeValue2.split("-");
j = Long.parseLong(split[0]);
if (split.length == 2) {
j2 = (Long.parseLong(split[1]) - j) + 1;
return buildRangedUri(attributeValue, j, j2);
}
} else {
j = 0;
}
j2 = -1;
return buildRangedUri(attributeValue, j, j2);
}
public RepresentationInfo parseRepresentation(XmlPullParser xmlPullParser, List<BaseUrl> list, @Nullable String str, @Nullable String str2, int i, int i2, float f, int i3, int i4, @Nullable String str3, List<Descriptor> list2, List<Descriptor> list3, List<Descriptor> list4, List<Descriptor> list5, @Nullable SegmentBase segmentBase, long j, long j2, long j3, long j4, long j5, boolean z) throws XmlPullParserException, IOException {
long j6;
ArrayList arrayList;
ArrayList arrayList2;
ArrayList arrayList3;
ArrayList arrayList4;
ArrayList arrayList5;
ArrayList arrayList6;
int i5;
long parseAvailabilityTimeOffsetUs;
ArrayList arrayList7;
SegmentBase segmentBase2;
ArrayList arrayList8;
ArrayList arrayList9;
ArrayList arrayList10;
ArrayList arrayList11;
DashManifestParser dashManifestParser = this;
String attributeValue = xmlPullParser.getAttributeValue(null, "id");
int parseInt = parseInt(xmlPullParser, "bandwidth", -1);
String parseString = parseString(xmlPullParser, "mimeType", str);
String parseString2 = parseString(xmlPullParser, "codecs", str2);
int parseInt2 = parseInt(xmlPullParser, "width", i);
int parseInt3 = parseInt(xmlPullParser, "height", i2);
float parseFrameRate = parseFrameRate(xmlPullParser, f);
int parseInt4 = parseInt(xmlPullParser, "audioSamplingRate", i4);
ArrayList arrayList12 = new ArrayList();
ArrayList arrayList13 = new ArrayList();
ArrayList arrayList14 = new ArrayList(list4);
ArrayList arrayList15 = new ArrayList(list5);
ArrayList arrayList16 = new ArrayList();
int i6 = i3;
SegmentBase segmentBase3 = segmentBase;
long j7 = j3;
String str4 = null;
boolean z2 = false;
long j8 = j4;
while (true) {
xmlPullParser.next();
if (XmlPullParserUtil.isStartTag(xmlPullParser, "BaseURL")) {
if (!z2) {
j7 = dashManifestParser.parseAvailabilityTimeOffsetUs(xmlPullParser, j7);
z2 = true;
}
arrayList16.addAll(dashManifestParser.parseBaseUrl(xmlPullParser, list, z));
} else if (XmlPullParserUtil.isStartTag(xmlPullParser, "AudioChannelConfiguration")) {
segmentBase2 = segmentBase3;
arrayList10 = arrayList16;
arrayList4 = arrayList12;
i5 = parseAudioChannelConfiguration(xmlPullParser);
arrayList5 = arrayList13;
arrayList6 = arrayList15;
arrayList11 = arrayList10;
if (XmlPullParserUtil.isEndTag(xmlPullParser, "Representation")) {
break;
}
arrayList15 = arrayList6;
arrayList13 = arrayList5;
arrayList12 = arrayList4;
segmentBase3 = segmentBase2;
dashManifestParser = this;
i6 = i5;
arrayList16 = arrayList11;
} else if (XmlPullParserUtil.isStartTag(xmlPullParser, "SegmentBase")) {
segmentBase3 = dashManifestParser.parseSegmentBase(xmlPullParser, (SegmentBase.SingleSegmentBase) segmentBase3);
} else {
if (XmlPullParserUtil.isStartTag(xmlPullParser, "SegmentList")) {
parseAvailabilityTimeOffsetUs = dashManifestParser.parseAvailabilityTimeOffsetUs(xmlPullParser, j8);
j6 = j7;
arrayList9 = arrayList16;
arrayList = arrayList15;
arrayList2 = arrayList13;
arrayList3 = arrayList14;
segmentBase3 = parseSegmentList(xmlPullParser, (SegmentBase.SegmentList) segmentBase3, j, j2, j6, parseAvailabilityTimeOffsetUs, j5);
arrayList4 = arrayList12;
} else {
j6 = j7;
ArrayList arrayList17 = arrayList16;
arrayList = arrayList15;
arrayList2 = arrayList13;
arrayList3 = arrayList14;
if (XmlPullParserUtil.isStartTag(xmlPullParser, "SegmentTemplate")) {
parseAvailabilityTimeOffsetUs = dashManifestParser.parseAvailabilityTimeOffsetUs(xmlPullParser, j8);
arrayList4 = arrayList12;
segmentBase3 = parseSegmentTemplate(xmlPullParser, (SegmentBase.SegmentTemplate) segmentBase3, list5, j, j2, j6, parseAvailabilityTimeOffsetUs, j5);
arrayList9 = arrayList17;
} else {
arrayList4 = arrayList12;
if (XmlPullParserUtil.isStartTag(xmlPullParser, "ContentProtection")) {
Pair<String, DrmInitData.SchemeData> parseContentProtection = parseContentProtection(xmlPullParser);
Object obj = parseContentProtection.first;
if (obj != null) {
str4 = (String) obj;
}
Object obj2 = parseContentProtection.second;
if (obj2 != null) {
arrayList4.add((DrmInitData.SchemeData) obj2);
}
i5 = i6;
arrayList8 = arrayList17;
j7 = j6;
arrayList6 = arrayList;
arrayList5 = arrayList2;
arrayList14 = arrayList3;
arrayList7 = arrayList8;
segmentBase2 = segmentBase3;
arrayList11 = arrayList7;
if (XmlPullParserUtil.isEndTag(xmlPullParser, "Representation")) {
}
} else {
if (XmlPullParserUtil.isStartTag(xmlPullParser, "InbandEventStream")) {
arrayList5 = arrayList2;
arrayList5.add(parseDescriptor(xmlPullParser, "InbandEventStream"));
arrayList6 = arrayList;
arrayList14 = arrayList3;
} else {
arrayList5 = arrayList2;
if (XmlPullParserUtil.isStartTag(xmlPullParser, "EssentialProperty")) {
arrayList14 = arrayList3;
arrayList14.add(parseDescriptor(xmlPullParser, "EssentialProperty"));
arrayList6 = arrayList;
} else {
arrayList14 = arrayList3;
if (XmlPullParserUtil.isStartTag(xmlPullParser, "SupplementalProperty")) {
arrayList6 = arrayList;
arrayList6.add(parseDescriptor(xmlPullParser, "SupplementalProperty"));
} else {
arrayList6 = arrayList;
maybeSkipTag(xmlPullParser);
}
}
}
i5 = i6;
j7 = j6;
arrayList7 = arrayList17;
segmentBase2 = segmentBase3;
arrayList11 = arrayList7;
if (XmlPullParserUtil.isEndTag(xmlPullParser, "Representation")) {
}
}
}
}
i5 = i6;
j8 = parseAvailabilityTimeOffsetUs;
arrayList8 = arrayList9;
j7 = j6;
arrayList6 = arrayList;
arrayList5 = arrayList2;
arrayList14 = arrayList3;
arrayList7 = arrayList8;
segmentBase2 = segmentBase3;
arrayList11 = arrayList7;
if (XmlPullParserUtil.isEndTag(xmlPullParser, "Representation")) {
}
}
arrayList10 = arrayList16;
arrayList4 = arrayList12;
i5 = i6;
segmentBase2 = segmentBase3;
arrayList5 = arrayList13;
arrayList6 = arrayList15;
arrayList11 = arrayList10;
if (XmlPullParserUtil.isEndTag(xmlPullParser, "Representation")) {
}
}
ArrayList arrayList18 = arrayList6;
ArrayList arrayList19 = arrayList14;
ArrayList arrayList20 = arrayList5;
Format buildFormat = buildFormat(attributeValue, parseString, parseInt2, parseInt3, parseFrameRate, i5, parseInt4, parseInt, str3, list2, list3, parseString2, arrayList19, arrayList18);
if (segmentBase2 == null) {
segmentBase2 = new SegmentBase.SingleSegmentBase();
}
boolean isEmpty = arrayList11.isEmpty();
List<BaseUrl> list6 = arrayList11;
if (isEmpty) {
list6 = list;
}
return new RepresentationInfo(buildFormat, list6, segmentBase2, str4, arrayList4, arrayList20, arrayList19, arrayList18, -1L);
}
public int parseRoleFlagsFromAccessibilityDescriptors(List<Descriptor> list) {
int parseTvaAudioPurposeCsValue;
int i = 0;
for (int i2 = 0; i2 < list.size(); i2++) {
Descriptor descriptor = list.get(i2);
if (babbDABcB.BbdcDCacCa("urn:mpeg:dash:role:2011", descriptor.schemeIdUri)) {
parseTvaAudioPurposeCsValue = parseRoleFlagsFromDashRoleScheme(descriptor.value);
} else if (babbDABcB.BbdcDCacCa("urn:tva:metadata:cs:AudioPurposeCS:2007", descriptor.schemeIdUri)) {
parseTvaAudioPurposeCsValue = parseTvaAudioPurposeCsValue(descriptor.value);
}
i |= parseTvaAudioPurposeCsValue;
}
return i;
}
public int parseRoleFlagsFromDashRoleScheme(@Nullable String str) {
if (str == null) {
return 0;
}
char c = 65535;
switch (str.hashCode()) {
case -2060497896:
if (str.equals("subtitle")) {
c = 0;
break;
}
break;
case -1724546052:
if (str.equals(UnifiedMediationParams.KEY_DESCRIPTION)) {
c = 1;
break;
}
break;
case -1580883024:
if (str.equals("enhanced-audio-intelligibility")) {
c = 2;
break;
}
break;
case -1574842690:
if (str.equals("forced_subtitle")) {
c = 3;
break;
}
break;
case -1408024454:
if (str.equals("alternate")) {
c = 4;
break;
}
break;
case -1396432756:
if (str.equals("forced-subtitle")) {
c = 5;
break;
}
break;
case 99825:
if (str.equals("dub")) {
c = 6;
break;
}
break;
case 3343801:
if (str.equals(t4.h.Z)) {
c = 7;
break;
}
break;
case 3530173:
if (str.equals("sign")) {
c = '\b';
break;
}
break;
case 552573414:
if (str.equals("caption")) {
c = '\t';
break;
}
break;
case 899152809:
if (str.equals("commentary")) {
c = '\n';
break;
}
break;
case 1629013393:
if (str.equals("emergency")) {
c = 11;
break;
}
break;
case 1855372047:
if (str.equals("supplementary")) {
c = '\f';
break;
}
break;
}
switch (c) {
case 0:
case 3:
case 5:
return 128;
case 1:
return 512;
case 2:
return 2048;
case 4:
return 2;
case 6:
return 16;
case 7:
return 1;
case '\b':
return 256;
case '\t':
return 64;
case '\n':
return 8;
case 11:
return 32;
case '\f':
return 4;
default:
return 0;
}
}
public int parseRoleFlagsFromProperties(List<Descriptor> list) {
int i = 0;
for (int i2 = 0; i2 < list.size(); i2++) {
if (babbDABcB.BbdcDCacCa("http://dashif.org/guidelines/trickmode", list.get(i2).schemeIdUri)) {
i |= 16384;
}
}
return i;
}
public int parseRoleFlagsFromRoleDescriptors(List<Descriptor> list) {
int i = 0;
for (int i2 = 0; i2 < list.size(); i2++) {
Descriptor descriptor = list.get(i2);
if (babbDABcB.BbdcDCacCa("urn:mpeg:dash:role:2011", descriptor.schemeIdUri)) {
i |= parseRoleFlagsFromDashRoleScheme(descriptor.value);
}
}
return i;
}
public SegmentBase.SingleSegmentBase parseSegmentBase(XmlPullParser xmlPullParser, @Nullable SegmentBase.SingleSegmentBase singleSegmentBase) throws XmlPullParserException, IOException {
long j;
long j2;
long j3;
long j4;
long j5;
if (singleSegmentBase != null) {
j = singleSegmentBase.timescale;
} else {
j = 1;
}
long parseLong = parseLong(xmlPullParser, "timescale", j);
long j6 = 0;
if (singleSegmentBase != null) {
j2 = singleSegmentBase.presentationTimeOffset;
} else {
j2 = 0;
}
long parseLong2 = parseLong(xmlPullParser, "presentationTimeOffset", j2);
if (singleSegmentBase != null) {
j3 = singleSegmentBase.indexStart;
} else {
j3 = 0;
}
if (singleSegmentBase != null) {
j6 = singleSegmentBase.indexLength;
}
RangedUri rangedUri = null;
String attributeValue = xmlPullParser.getAttributeValue(null, "indexRange");
if (attributeValue != null) {
String[] split = attributeValue.split("-");
j5 = Long.parseLong(split[0]);
j4 = (Long.parseLong(split[1]) - j5) + 1;
} else {
j4 = j6;
j5 = j3;
}
if (singleSegmentBase != null) {
rangedUri = singleSegmentBase.initialization;
}
do {
xmlPullParser.next();
if (XmlPullParserUtil.isStartTag(xmlPullParser, "Initialization")) {
rangedUri = parseInitialization(xmlPullParser);
} else {
maybeSkipTag(xmlPullParser);
}
} while (!XmlPullParserUtil.isEndTag(xmlPullParser, "SegmentBase"));
return buildSingleSegmentBase(rangedUri, parseLong, parseLong2, j5, j4);
}
public SegmentBase.SegmentList parseSegmentList(XmlPullParser xmlPullParser, @Nullable SegmentBase.SegmentList segmentList, long j, long j2, long j3, long j4, long j5) throws XmlPullParserException, IOException {
long j6;
long j7;
long j8;
long j9 = 1;
if (segmentList != null) {
j6 = segmentList.timescale;
} else {
j6 = 1;
}
long parseLong = parseLong(xmlPullParser, "timescale", j6);
if (segmentList != null) {
j7 = segmentList.presentationTimeOffset;
} else {
j7 = 0;
}
long parseLong2 = parseLong(xmlPullParser, "presentationTimeOffset", j7);
if (segmentList != null) {
j8 = segmentList.duration;
} else {
j8 = -9223372036854775807L;
}
long parseLong3 = parseLong(xmlPullParser, "duration", j8);
if (segmentList != null) {
j9 = segmentList.startNumber;
}
long parseLong4 = parseLong(xmlPullParser, "startNumber", j9);
long finalAvailabilityTimeOffset = getFinalAvailabilityTimeOffset(j3, j4);
List<SegmentBase.SegmentTimelineElement> list = null;
List<RangedUri> list2 = null;
RangedUri rangedUri = null;
do {
xmlPullParser.next();
if (XmlPullParserUtil.isStartTag(xmlPullParser, "Initialization")) {
rangedUri = parseInitialization(xmlPullParser);
} else if (XmlPullParserUtil.isStartTag(xmlPullParser, "SegmentTimeline")) {
list = parseSegmentTimeline(xmlPullParser, parseLong, j2);
} else if (XmlPullParserUtil.isStartTag(xmlPullParser, "SegmentURL")) {
if (list2 == null) {
list2 = new ArrayList<>();
}
list2.add(parseSegmentUrl(xmlPullParser));
} else {
maybeSkipTag(xmlPullParser);
}
} while (!XmlPullParserUtil.isEndTag(xmlPullParser, "SegmentList"));
if (segmentList != null) {
if (rangedUri == null) {
rangedUri = segmentList.initialization;
}
if (list == null) {
list = segmentList.segmentTimeline;
}
if (list2 == null) {
list2 = segmentList.mediaSegments;
}
}
return buildSegmentList(rangedUri, parseLong, parseLong2, parseLong4, parseLong3, list, finalAvailabilityTimeOffset, list2, j5, j);
}
public SegmentBase.SegmentTemplate parseSegmentTemplate(XmlPullParser xmlPullParser, @Nullable SegmentBase.SegmentTemplate segmentTemplate, List<Descriptor> list, long j, long j2, long j3, long j4, long j5) throws XmlPullParserException, IOException {
long j6;
long j7;
long j8;
UrlTemplate urlTemplate;
UrlTemplate urlTemplate2;
long j9 = 1;
if (segmentTemplate != null) {
j6 = segmentTemplate.timescale;
} else {
j6 = 1;
}
long parseLong = parseLong(xmlPullParser, "timescale", j6);
if (segmentTemplate != null) {
j7 = segmentTemplate.presentationTimeOffset;
} else {
j7 = 0;
}
long parseLong2 = parseLong(xmlPullParser, "presentationTimeOffset", j7);
if (segmentTemplate != null) {
j8 = segmentTemplate.duration;
} else {
j8 = -9223372036854775807L;
}
long parseLong3 = parseLong(xmlPullParser, "duration", j8);
if (segmentTemplate != null) {
j9 = segmentTemplate.startNumber;
}
long parseLong4 = parseLong(xmlPullParser, "startNumber", j9);
long parseLastSegmentNumberSupplementalProperty = parseLastSegmentNumberSupplementalProperty(list);
long finalAvailabilityTimeOffset = getFinalAvailabilityTimeOffset(j3, j4);
List<SegmentBase.SegmentTimelineElement> list2 = null;
if (segmentTemplate != null) {
urlTemplate = segmentTemplate.mediaTemplate;
} else {
urlTemplate = null;
}
UrlTemplate parseUrlTemplate = parseUrlTemplate(xmlPullParser, t4.h.H0, urlTemplate);
if (segmentTemplate != null) {
urlTemplate2 = segmentTemplate.initializationTemplate;
} else {
urlTemplate2 = null;
}
UrlTemplate parseUrlTemplate2 = parseUrlTemplate(xmlPullParser, "initialization", urlTemplate2);
RangedUri rangedUri = null;
do {
xmlPullParser.next();
if (XmlPullParserUtil.isStartTag(xmlPullParser, "Initialization")) {
rangedUri = parseInitialization(xmlPullParser);
} else if (XmlPullParserUtil.isStartTag(xmlPullParser, "SegmentTimeline")) {
list2 = parseSegmentTimeline(xmlPullParser, parseLong, j2);
} else {
maybeSkipTag(xmlPullParser);
}
} while (!XmlPullParserUtil.isEndTag(xmlPullParser, "SegmentTemplate"));
if (segmentTemplate != null) {
if (rangedUri == null) {
rangedUri = segmentTemplate.initialization;
}
if (list2 == null) {
list2 = segmentTemplate.segmentTimeline;
}
}
return buildSegmentTemplate(rangedUri, parseLong, parseLong2, parseLong4, parseLastSegmentNumberSupplementalProperty, parseLong3, list2, finalAvailabilityTimeOffset, parseUrlTemplate2, parseUrlTemplate, j5, j);
}
public List<SegmentBase.SegmentTimelineElement> parseSegmentTimeline(XmlPullParser xmlPullParser, long j, long j2) throws XmlPullParserException, IOException {
ArrayList arrayList = new ArrayList();
long j3 = 0;
long j4 = -9223372036854775807L;
boolean z = false;
int i = 0;
do {
xmlPullParser.next();
if (XmlPullParserUtil.isStartTag(xmlPullParser, ExifInterface.f27289bBbdAB)) {
long parseLong = parseLong(xmlPullParser, "t", -9223372036854775807L);
if (z) {
j3 = addSegmentTimelineElementsToList(arrayList, j3, j4, i, parseLong);
}
if (parseLong == -9223372036854775807L) {
parseLong = j3;
}
j4 = parseLong(xmlPullParser, "d", -9223372036854775807L);
i = parseInt(xmlPullParser, "r", 0);
j3 = parseLong;
z = true;
} else {
maybeSkipTag(xmlPullParser);
}
} while (!XmlPullParserUtil.isEndTag(xmlPullParser, "SegmentTimeline"));
if (z) {
addSegmentTimelineElementsToList(arrayList, j3, j4, i, Util.scaleLargeTimestamp(j2, j, 1000L));
}
return arrayList;
}
public RangedUri parseSegmentUrl(XmlPullParser xmlPullParser) {
return parseRangedUrl(xmlPullParser, t4.h.H0, "mediaRange");
}
public int parseSelectionFlagsFromDashRoleScheme(@Nullable String str) {
if (str == null) {
return 0;
}
if (!str.equals("forced_subtitle") && !str.equals("forced-subtitle")) {
return 0;
}
return 2;
}
public int parseSelectionFlagsFromRoleDescriptors(List<Descriptor> list) {
int i = 0;
for (int i2 = 0; i2 < list.size(); i2++) {
Descriptor descriptor = list.get(i2);
if (babbDABcB.BbdcDCacCa("urn:mpeg:dash:role:2011", descriptor.schemeIdUri)) {
i |= parseSelectionFlagsFromDashRoleScheme(descriptor.value);
}
}
return i;
}
public ServiceDescriptionElement parseServiceDescription(XmlPullParser xmlPullParser) throws XmlPullParserException, IOException {
long j = -9223372036854775807L;
long j2 = -9223372036854775807L;
long j3 = -9223372036854775807L;
float f = -3.4028235E38f;
float f2 = -3.4028235E38f;
while (true) {
xmlPullParser.next();
if (XmlPullParserUtil.isStartTag(xmlPullParser, "Latency")) {
j = parseLong(xmlPullParser, "target", -9223372036854775807L);
j2 = parseLong(xmlPullParser, "min", -9223372036854775807L);
j3 = parseLong(xmlPullParser, "max", -9223372036854775807L);
} else if (XmlPullParserUtil.isStartTag(xmlPullParser, "PlaybackRate")) {
f = parseFloat(xmlPullParser, "min", -3.4028235E38f);
f2 = parseFloat(xmlPullParser, "max", -3.4028235E38f);
}
long j4 = j;
long j5 = j2;
long j6 = j3;
float f3 = f;
float f4 = f2;
if (XmlPullParserUtil.isEndTag(xmlPullParser, "ServiceDescription")) {
return new ServiceDescriptionElement(j4, j5, j6, f3, f4);
}
j = j4;
j2 = j5;
j3 = j6;
f = f3;
f2 = f4;
}
}
@Nullable
public Pair<Integer, Integer> parseTileCountFromProperties(List<Descriptor> list) {
String str;
for (int i = 0; i < list.size(); i++) {
Descriptor descriptor = list.get(i);
if ((babbDABcB.BbdcDCacCa("http://dashif.org/thumbnail_tile", descriptor.schemeIdUri) || babbDABcB.BbdcDCacCa("http://dashif.org/guidelines/thumbnail_tile", descriptor.schemeIdUri)) && (str = descriptor.value) != null) {
String[] split = Util.split(str, "x");
if (split.length == 2) {
try {
return Pair.create(Integer.valueOf(Integer.parseInt(split[0])), Integer.valueOf(Integer.parseInt(split[1])));
} catch (NumberFormatException unused) {
continue;
}
}
}
}
return null;
}
public int parseTvaAudioPurposeCsValue(@Nullable String str) {
if (str == null) {
return 0;
}
char c = 65535;
switch (str.hashCode()) {
case 49:
if (str.equals("1")) {
c = 0;
break;
}
break;
case 50:
if (str.equals("2")) {
c = 1;
break;
}
break;
case 51:
if (str.equals(ExifInterface.f27091BcDcBa)) {
c = 2;
break;
}
break;
case 52:
if (str.equals("4")) {
c = 3;
break;
}
break;
case 54:
if (str.equals("6")) {
c = 4;
break;
}
break;
}
switch (c) {
case 0:
return 512;
case 1:
return 2048;
case 2:
return 4;
case 3:
return 8;
case 4:
return 1;
default:
return 0;
}
}
@Nullable
public UrlTemplate parseUrlTemplate(XmlPullParser xmlPullParser, String str, @Nullable UrlTemplate urlTemplate) {
String attributeValue = xmlPullParser.getAttributeValue(null, str);
if (attributeValue != null) {
return UrlTemplate.compile(attributeValue);
}
return urlTemplate;
}
public UtcTimingElement parseUtcTiming(XmlPullParser xmlPullParser) {
return buildUtcTimingElement(xmlPullParser.getAttributeValue(null, "schemeIdUri"), xmlPullParser.getAttributeValue(null, t4.h.X));
}
@Override
public DashManifest parse(Uri uri, InputStream inputStream) throws IOException {
try {
XmlPullParser newPullParser = this.xmlParserFactory.newPullParser();
newPullParser.setInput(inputStream, null);
if (newPullParser.next() == 2 && "MPD".equals(newPullParser.getName())) {
return parseMediaPresentationDescription(newPullParser, uri);
}
throw ParserException.createForMalformedManifest("inputStream does not contain a valid media presentation description", null);
} catch (XmlPullParserException e) {
throw ParserException.createForMalformedManifest(null, e);
}
}
}