FlixOlé v4.4.0版本的 MD5 值为:50e7f767ca3e8715936523e9ef089581

以下内容为反编译后的 d.java 源代码,内容仅作参考


package i.d.a.b.s4.r0.n;

import android.net.Uri;
import android.text.TextUtils;
import android.util.Base64;
import android.util.Pair;
import android.util.Xml;
import com.google.android.gms.cast.MediaTrack;
import com.google.common.base.Charsets;
import com.google.common.collect.Lists;
import com.magine.android.downloader.service.DownloaderService;
import com.swift.sandhook.utils.FileUtils;
import i.c.x;
import i.d.a.b.k2;
import i.d.a.b.k3;
import i.d.a.b.m4.v;
import i.d.a.b.s4.r0.n.k;
import i.d.a.b.w4.j0;
import i.d.a.b.x2;
import i.d.a.b.x4.o0;
import i.d.a.b.x4.p0;
import i.d.a.b.x4.q0;
import i.d.a.b.x4.u;
import i.d.a.b.x4.y;
import i.d.b.b.q;
import i.f.a.h.b.d.r;
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 okhttp3.internal.http2.Http2;
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;
public class d extends DefaultHandler implements j0.a<c> {
    public static final Pattern b = Pattern.compile("(\\d+)(?:/(\\d+))?");
    public static final Pattern c = Pattern.compile("CC([1-4])=.*");
    public static final Pattern d = Pattern.compile("([1-9]|[1-5][0-9]|6[0-3])=.*");
    public static final int[] e = {-1, 1, 2, 3, 4, 5, 6, 8, 2, 3, 4, 7, 8, 24, 8, 12, 10, 12, 14, 12, 14};
    public final XmlPullParserFactory a;

    public static final class a {
        public final x2 a;
        public final q<b> b;
        public final k c;
        public final String d;
        public final ArrayList<v.b> e;
        public final ArrayList<e> f4890f;
        public final long f4891g;
        public final List<e> f4892h;
        public final List<e> f4893i;

        public a(x2 x2Var, List<b> list, k kVar, String str, ArrayList<v.b> arrayList, ArrayList<e> arrayList2, List<e> list2, List<e> list3, long j2) {
            this.a = x2Var;
            this.b = q.A(list);
            this.c = kVar;
            this.d = str;
            this.e = arrayList;
            this.f4890f = arrayList2;
            this.f4892h = list2;
            this.f4893i = list3;
            this.f4891g = j2;
        }
    }

    public d() {
        try {
            this.a = XmlPullParserFactory.newInstance();
        } catch (XmlPullParserException e2) {
            throw new RuntimeException("Couldn't create XmlPullParserFactory instance", e2);
        }
    }

    public static int D(List<e> list) {
        String str;
        for (int i2 = 0; i2 < list.size(); i2++) {
            e eVar = list.get(i2);
            if ("urn:scte:dash:cc:cea-608:2015".equals(eVar.a) && (str = eVar.b) != null) {
                Matcher matcher = c.matcher(str);
                if (matcher.matches()) {
                    return Integer.parseInt(matcher.group(1));
                }
                u.i("MpdParser", "Unable to parse CEA-608 channel number from: " + eVar.b);
            }
        }
        return -1;
    }

    public static int E(List<e> list) {
        String str;
        for (int i2 = 0; i2 < list.size(); i2++) {
            e eVar = list.get(i2);
            if ("urn:scte:dash:cc:cea-708:2015".equals(eVar.a) && (str = eVar.b) != null) {
                Matcher matcher = d.matcher(str);
                if (matcher.matches()) {
                    return Integer.parseInt(matcher.group(1));
                }
                u.i("MpdParser", "Unable to parse CEA-708 service block number from: " + eVar.b);
            }
        }
        return -1;
    }

    public static long H(XmlPullParser xmlPullParser, String str, long j2) throws k3 {
        String attributeValue = xmlPullParser.getAttributeValue(null, str);
        return attributeValue == null ? j2 : p0.A0(attributeValue);
    }

    public static e I(XmlPullParser xmlPullParser, String str) throws XmlPullParserException, IOException {
        String r0 = r0(xmlPullParser, "schemeIdUri", "");
        String r02 = r0(xmlPullParser, "value", null);
        String r03 = r0(xmlPullParser, "id", null);
        do {
            xmlPullParser.next();
        } while (!q0.d(xmlPullParser, str));
        return new e(r0, r02, r03);
    }

    public static int J(XmlPullParser xmlPullParser) {
        char c2;
        String attributeValue = xmlPullParser.getAttributeValue(null, "value");
        if (attributeValue == null) {
            return -1;
        }
        String e2 = i.d.b.a.b.e(attributeValue);
        e2.hashCode();
        switch (e2.hashCode()) {
            case 1596796:
                if (e2.equals("4000")) {
                    c2 = 0;
                    break;
                }
                c2 = 65535;
                break;
            case 2937391:
                if (e2.equals("a000")) {
                    c2 = 1;
                    break;
                }
                c2 = 65535;
                break;
            case 3094035:
                if (e2.equals("f801")) {
                    c2 = 2;
                    break;
                }
                c2 = 65535;
                break;
            case 3133436:
                if (e2.equals("fa01")) {
                    c2 = 3;
                    break;
                }
                c2 = 65535;
                break;
            default:
                c2 = 65535;
                break;
        }
        switch (c2) {
            case 0:
                return 1;
            case 1:
                return 2;
            case 2:
                return 6;
            case 3:
                return 8;
            default:
                return -1;
        }
    }

    public static int K(XmlPullParser xmlPullParser) {
        int U = U(xmlPullParser, "value", -1);
        if (U <= 0 || U >= 33) {
            return -1;
        }
        return U;
    }

    public static int L(XmlPullParser xmlPullParser) {
        int bitCount;
        String attributeValue = xmlPullParser.getAttributeValue(null, "value");
        if (attributeValue == null || (bitCount = Integer.bitCount(Integer.parseInt(attributeValue, 16))) == 0) {
            return -1;
        }
        return bitCount;
    }

    public static long M(XmlPullParser xmlPullParser, String str, long j2) {
        String attributeValue = xmlPullParser.getAttributeValue(null, str);
        return attributeValue == null ? j2 : p0.B0(attributeValue);
    }

    public static String N(List<e> list) {
        for (int i2 = 0; i2 < list.size(); i2++) {
            e eVar = list.get(i2);
            String str = eVar.a;
            if ("tag:dolby.com,2018:dash:EC3_ExtensionType:2018".equals(str) && "JOC".equals(eVar.b)) {
                return "audio/eac3-joc";
            }
            if ("tag:dolby.com,2014:dash:DolbyDigitalPlusExtensionType:2014".equals(str) && "ec+3".equals(eVar.b)) {
                return "audio/eac3-joc";
            }
        }
        return "audio/eac3";
    }

    public static float R(XmlPullParser xmlPullParser, String str, float f2) {
        String attributeValue = xmlPullParser.getAttributeValue(null, str);
        return attributeValue == null ? f2 : Float.parseFloat(attributeValue);
    }

    public static float S(XmlPullParser xmlPullParser, float f2) {
        String group;
        String attributeValue = xmlPullParser.getAttributeValue(null, "frameRate");
        if (attributeValue != null) {
            Matcher matcher = b.matcher(attributeValue);
            if (matcher.matches()) {
                int parseInt = Integer.parseInt(matcher.group(1));
                float f3 = parseInt;
                return !TextUtils.isEmpty(matcher.group(2)) ? f3 / Integer.parseInt(group) : f3;
            }
            return f2;
        }
        return f2;
    }

    public static int U(XmlPullParser xmlPullParser, String str, int i2) {
        String attributeValue = xmlPullParser.getAttributeValue(null, str);
        return attributeValue == null ? i2 : Integer.parseInt(attributeValue);
    }

    public static long W(List<e> list) {
        for (int i2 = 0; i2 < list.size(); i2++) {
            e eVar = list.get(i2);
            if (i.d.b.a.b.a("http://dashif.org/guidelines/last-segment-number", eVar.a)) {
                return Long.parseLong(eVar.b);
            }
        }
        return -1L;
    }

    public static long X(XmlPullParser xmlPullParser, String str, long j2) {
        String attributeValue = xmlPullParser.getAttributeValue(null, str);
        return attributeValue == null ? j2 : Long.parseLong(attributeValue);
    }

    public static int Z(XmlPullParser xmlPullParser) {
        int U = U(xmlPullParser, "value", -1);
        if (U >= 0) {
            int[] iArr = e;
            if (U < iArr.length) {
                return iArr[U];
            }
            return -1;
        }
        return -1;
    }

    public static int p(int i2, int i3) {
        if (i2 == -1) {
            return i3;
        }
        if (i3 == -1) {
            return i2;
        }
        i.d.a.b.x4.e.g(i2 == i3);
        return i2;
    }

    public static String q(String str, String str2) {
        if (str == null) {
            return str2;
        }
        if (str2 == null) {
            return str;
        }
        i.d.a.b.x4.e.g(str.equals(str2));
        return str;
    }

    public static void r(ArrayList<v.b> arrayList) {
        String str;
        int i2 = 0;
        while (true) {
            if (i2 >= arrayList.size()) {
                str = null;
                break;
            }
            v.b bVar = arrayList.get(i2);
            if (k2.c.equals(bVar.f4510o) && (str = bVar.f4511p) != null) {
                arrayList.remove(i2);
                break;
            }
            i2++;
        }
        if (str == null) {
            return;
        }
        for (int i3 = 0; i3 < arrayList.size(); i3++) {
            v.b bVar2 = arrayList.get(i3);
            if (k2.b.equals(bVar2.f4510o) && bVar2.f4511p == null) {
                arrayList.set(i3, new v.b(k2.c, str, bVar2.f4512q, bVar2.r));
            }
        }
    }

    public static String r0(XmlPullParser xmlPullParser, String str, String str2) {
        String attributeValue = xmlPullParser.getAttributeValue(null, str);
        return attributeValue == null ? str2 : attributeValue;
    }

    public static void s(ArrayList<v.b> arrayList) {
        for (int size = arrayList.size() - 1; size >= 0; size--) {
            v.b bVar = arrayList.get(size);
            if (!bVar.c()) {
                int i2 = 0;
                while (true) {
                    if (i2 >= arrayList.size()) {
                        break;
                    } else if (arrayList.get(i2).a(bVar)) {
                        arrayList.remove(size);
                        break;
                    } else {
                        i2++;
                    }
                }
            }
        }
    }

    public static String s0(XmlPullParser xmlPullParser, String str) throws XmlPullParserException, IOException {
        String str2 = "";
        do {
            xmlPullParser.next();
            if (xmlPullParser.getEventType() == 4) {
                str2 = xmlPullParser.getText();
            } else {
                w(xmlPullParser);
            }
        } while (!q0.d(xmlPullParser, str));
        return str2;
    }

    public static long t(long j2, long j3) {
        if (j3 != -9223372036854775807L) {
            j2 = j3;
        }
        if (j2 == Long.MAX_VALUE) {
            return -9223372036854775807L;
        }
        return j2;
    }

    public static String u(String str, String str2) {
        if (y.m(str)) {
            return y.b(str2);
        }
        if (y.q(str)) {
            return y.l(str2);
        }
        if (y.p(str) || y.n(str)) {
            return str;
        }
        if ("application/mp4".equals(str)) {
            String e2 = y.e(str2);
            return "text/vtt".equals(e2) ? "application/x-mp4-vtt" : e2;
        }
        return null;
    }

    public static void w(XmlPullParser xmlPullParser) throws IOException, XmlPullParserException {
        if (q0.e(xmlPullParser)) {
            int i2 = 1;
            while (i2 != 0) {
                xmlPullParser.next();
                if (q0.e(xmlPullParser)) {
                    i2++;
                } else if (q0.c(xmlPullParser)) {
                    i2--;
                }
            }
        }
    }

    public int A(XmlPullParser xmlPullParser) throws XmlPullParserException, IOException {
        char c2;
        String r0 = r0(xmlPullParser, "schemeIdUri", null);
        r0.hashCode();
        int i2 = -1;
        switch (r0.hashCode()) {
            case -2128649360:
                if (r0.equals("urn:dts:dash:audio_channel_configuration:2012")) {
                    c2 = 0;
                    break;
                }
                c2 = 65535;
                break;
            case -1352850286:
                if (r0.equals("urn:mpeg:dash:23003:3:audio_channel_configuration:2011")) {
                    c2 = 1;
                    break;
                }
                c2 = 65535;
                break;
            case -1138141449:
                if (r0.equals("tag:dolby.com,2014:dash:audio_channel_configuration:2011")) {
                    c2 = 2;
                    break;
                }
                c2 = 65535;
                break;
            case -986633423:
                if (r0.equals("urn:mpeg:mpegB:cicp:ChannelConfiguration")) {
                    c2 = 3;
                    break;
                }
                c2 = 65535;
                break;
            case -79006963:
                if (r0.equals("tag:dts.com,2014:dash:audio_channel_configuration:2012")) {
                    c2 = 4;
                    break;
                }
                c2 = 65535;
                break;
            case 312179081:
                if (r0.equals("tag:dts.com,2018:uhd:audio_channel_configuration")) {
                    c2 = 5;
                    break;
                }
                c2 = 65535;
                break;
            case 2036691300:
                if (r0.equals("urn:dolby:dash:audio_channel_configuration:2011")) {
                    c2 = 6;
                    break;
                }
                c2 = 65535;
                break;
            default:
                c2 = 65535;
                break;
        }
        switch (c2) {
            case 0:
            case 4:
                i2 = K(xmlPullParser);
                break;
            case 1:
                i2 = U(xmlPullParser, "value", -1);
                break;
            case 2:
            case 6:
                i2 = J(xmlPullParser);
                break;
            case 3:
                i2 = Z(xmlPullParser);
                break;
            case 5:
                i2 = L(xmlPullParser);
                break;
        }
        do {
            xmlPullParser.next();
        } while (!q0.d(xmlPullParser, "AudioChannelConfiguration"));
        return i2;
    }

    public long B(XmlPullParser xmlPullParser, long j2) {
        String attributeValue = xmlPullParser.getAttributeValue(null, "availabilityTimeOffset");
        if (attributeValue == null) {
            return j2;
        }
        if ("INF".equals(attributeValue)) {
            return Long.MAX_VALUE;
        }
        return Float.parseFloat(attributeValue) * 1000000.0f;
    }

    public List<b> C(XmlPullParser xmlPullParser, List<b> list, boolean z) throws XmlPullParserException, IOException {
        String attributeValue = xmlPullParser.getAttributeValue(null, "dvb:priority");
        int parseInt = attributeValue != null ? Integer.parseInt(attributeValue) : z ? 1 : Integer.MIN_VALUE;
        String attributeValue2 = xmlPullParser.getAttributeValue(null, "dvb:weight");
        int parseInt2 = attributeValue2 != null ? Integer.parseInt(attributeValue2) : 1;
        String attributeValue3 = xmlPullParser.getAttributeValue(null, "serviceLocation");
        String s0 = s0(xmlPullParser, "BaseURL");
        if (o0.b(s0)) {
            if (attributeValue3 == null) {
                attributeValue3 = s0;
            }
            return Lists.i(new b(s0, attributeValue3, parseInt, parseInt2));
        }
        ArrayList arrayList = new ArrayList();
        for (int i2 = 0; i2 < list.size(); i2++) {
            b bVar = list.get(i2);
            String d2 = o0.d(bVar.a, s0);
            String str = attributeValue3 == null ? d2 : attributeValue3;
            if (z) {
                parseInt = bVar.c;
                parseInt2 = bVar.d;
                str = bVar.b;
            }
            arrayList.add(new b(d2, str, parseInt, parseInt2));
        }
        return arrayList;
    }

    public Pair<String, v.b> F(XmlPullParser xmlPullParser) throws XmlPullParserException, IOException {
        String str;
        UUID uuid;
        UUID uuid2;
        byte[] bArr;
        byte[] bArr2;
        String attributeValue = xmlPullParser.getAttributeValue(null, "schemeIdUri");
        if (attributeValue != null) {
            String e2 = i.d.b.a.b.e(attributeValue);
            e2.hashCode();
            char c2 = 65535;
            switch (e2.hashCode()) {
                case -1980789791:
                    if (e2.equals("urn:uuid:e2719d58-a985-b3c9-781a-b030af78d30e")) {
                        c2 = 0;
                        break;
                    }
                    break;
                case 489446379:
                    if (e2.equals("urn:uuid:9a04f079-9840-4286-ab92-e65be0885f95")) {
                        c2 = 1;
                        break;
                    }
                    break;
                case 755418770:
                    if (e2.equals("urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed")) {
                        c2 = 2;
                        break;
                    }
                    break;
                case 1812765994:
                    if (e2.equals("urn:mpeg:dash:mp4protection:2011")) {
                        c2 = 3;
                        break;
                    }
                    break;
            }
            switch (c2) {
                case 0:
                    uuid = k2.c;
                    str = null;
                    uuid2 = null;
                    bArr = uuid2;
                    bArr2 = uuid2;
                    break;
                case 1:
                    uuid = k2.e;
                    str = null;
                    uuid2 = null;
                    bArr = uuid2;
                    bArr2 = uuid2;
                    break;
                case 2:
                    uuid = k2.d;
                    str = null;
                    uuid2 = null;
                    bArr = uuid2;
                    bArr2 = uuid2;
                    break;
                case 3:
                    str = xmlPullParser.getAttributeValue(null, "value");
                    String b2 = q0.b(xmlPullParser, "default_KID");
                    if (!TextUtils.isEmpty(b2) && !"00000000-0000-0000-0000-000000000000".equals(b2)) {
                        String[] split = b2.split("\\s+");
                        UUID[] uuidArr = new UUID[split.length];
                        for (int i2 = 0; i2 < split.length; i2++) {
                            uuidArr[i2] = UUID.fromString(split[i2]);
                        }
                        uuid = k2.b;
                        bArr = null;
                        bArr2 = i.d.a.b.o4.v.h.b(uuid, uuidArr, null);
                        break;
                    } else {
                        uuid = null;
                        uuid2 = uuid;
                        bArr = uuid2;
                        bArr2 = uuid2;
                        break;
                    }
                    break;
            }
            do {
                xmlPullParser.next();
                if (!q0.f(xmlPullParser, "clearkey:Laurl") && xmlPullParser.next() == 4) {
                    bArr = xmlPullParser.getText();
                    bArr2 = bArr2;
                } else if (!q0.f(xmlPullParser, "ms:laurl")) {
                    bArr = xmlPullParser.getAttributeValue(null, "licenseUrl");
                    bArr2 = bArr2;
                } else if (bArr2 == null && q0.g(xmlPullParser, "pssh") && xmlPullParser.next() == 4) {
                    byte[] decode = Base64.decode(xmlPullParser.getText(), 0);
                    UUID f2 = i.d.a.b.o4.v.h.f(decode);
                    if (f2 == null) {
                        u.i("MpdParser", "Skipping malformed cenc:pssh data");
                        uuid = f2;
                        bArr2 = null;
                    } else {
                        bArr2 = decode;
                        uuid = f2;
                    }
                } else {
                    if (bArr2 == null) {
                        UUID uuid3 = k2.e;
                        if (uuid3.equals(uuid) && q0.f(xmlPullParser, "mspr:pro") && xmlPullParser.next() == 4) {
                            bArr2 = i.d.a.b.o4.v.h.a(uuid3, Base64.decode(xmlPullParser.getText(), 0));
                        }
                    }
                    w(xmlPullParser);
                    bArr2 = bArr2;
                }
            } while (!q0.d(xmlPullParser, "ContentProtection"));
            return Pair.create(str, uuid != null ? new v.b(uuid, bArr, i.f.a.h.b.e.a.a, bArr2) : null);
        }
        str = null;
        uuid = null;
        uuid2 = uuid;
        bArr = uuid2;
        bArr2 = uuid2;
        do {
            xmlPullParser.next();
            if (!q0.f(xmlPullParser, "clearkey:Laurl")) {
            }
            if (!q0.f(xmlPullParser, "ms:laurl")) {
            }
        } while (!q0.d(xmlPullParser, "ContentProtection"));
        return Pair.create(str, uuid != null ? new v.b(uuid, bArr, i.f.a.h.b.e.a.a, bArr2) : null);
    }

    public int G(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;
        }
        return "image".equals(attributeValue) ? 4 : -1;
    }

    public Pair<Long, i.d.a.b.q4.j.a> O(XmlPullParser xmlPullParser, String str, String str2, long j2, long j3, ByteArrayOutputStream byteArrayOutputStream) throws IOException, XmlPullParserException {
        long X = X(xmlPullParser, "id", 0L);
        long X2 = X(xmlPullParser, "duration", -9223372036854775807L);
        long X3 = X(xmlPullParser, "presentationTime", 0L);
        long E0 = p0.E0(X2, 1000L, j2);
        long E02 = p0.E0(X3 - j3, 1000000L, j2);
        String r0 = r0(xmlPullParser, "messageData", null);
        byte[] P = P(xmlPullParser, byteArrayOutputStream);
        Long valueOf = Long.valueOf(E02);
        if (r0 != null) {
            P = p0.e0(r0);
        }
        return Pair.create(valueOf, d(str, str2, X, E0, P));
    }

    public byte[] P(XmlPullParser xmlPullParser, ByteArrayOutputStream byteArrayOutputStream) throws XmlPullParserException, IOException {
        byteArrayOutputStream.reset();
        XmlSerializer newSerializer = Xml.newSerializer();
        newSerializer.setOutput(byteArrayOutputStream, Charsets.UTF_8.name());
        while (true) {
            xmlPullParser.nextToken();
            if (q0.d(xmlPullParser, "Event")) {
                newSerializer.flush();
                return byteArrayOutputStream.toByteArray();
            }
            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 i2 = 0; i2 < xmlPullParser.getAttributeCount(); i2++) {
                        newSerializer.attribute(xmlPullParser.getAttributeNamespace(i2), xmlPullParser.getAttributeName(i2), xmlPullParser.getAttributeValue(i2));
                    }
                    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;
            }
        }
    }

    public f Q(XmlPullParser xmlPullParser) throws XmlPullParserException, IOException {
        ByteArrayOutputStream byteArrayOutputStream;
        long j2;
        ArrayList arrayList;
        String r0 = r0(xmlPullParser, "schemeIdUri", "");
        String r02 = r0(xmlPullParser, "value", "");
        long X = X(xmlPullParser, "timescale", 1L);
        long X2 = X(xmlPullParser, "presentationTimeOffset", 0L);
        ArrayList arrayList2 = new ArrayList();
        ByteArrayOutputStream byteArrayOutputStream2 = new ByteArrayOutputStream(FileUtils.FileMode.MODE_ISVTX);
        while (true) {
            xmlPullParser.next();
            if (q0.f(xmlPullParser, "Event")) {
                byteArrayOutputStream = byteArrayOutputStream2;
                long j3 = X2;
                j2 = X2;
                arrayList = arrayList2;
                arrayList.add(O(xmlPullParser, r0, r02, X, j3, byteArrayOutputStream));
            } else {
                byteArrayOutputStream = byteArrayOutputStream2;
                j2 = X2;
                arrayList = arrayList2;
                w(xmlPullParser);
            }
            if (q0.d(xmlPullParser, "EventStream")) {
                break;
            }
            arrayList2 = arrayList;
            byteArrayOutputStream2 = byteArrayOutputStream;
            X2 = j2;
        }
        long[] jArr = new long[arrayList.size()];
        i.d.a.b.q4.j.a[] aVarArr = new i.d.a.b.q4.j.a[arrayList.size()];
        for (int i2 = 0; i2 < arrayList.size(); i2++) {
            Pair pair = (Pair) arrayList.get(i2);
            jArr[i2] = ((Long) pair.first).longValue();
            aVarArr[i2] = (i.d.a.b.q4.j.a) pair.second;
        }
        return e(r0, r02, X, jArr, aVarArr);
    }

    public i T(XmlPullParser xmlPullParser) {
        return d0(xmlPullParser, "sourceURL", "range");
    }

    public String V(XmlPullParser xmlPullParser) throws XmlPullParserException, IOException {
        return s0(xmlPullParser, "Label");
    }

    public c Y(XmlPullParser xmlPullParser, Uri uri) throws XmlPullParserException, IOException {
        long j2;
        ArrayList arrayList;
        ArrayList arrayList2;
        long j3;
        Throwable th;
        ArrayList arrayList3;
        long j4;
        boolean z;
        long j5;
        d dVar = this;
        boolean v = dVar.v(dVar.b0(xmlPullParser, "profiles", new String[0]));
        long j6 = -9223372036854775807L;
        long H = H(xmlPullParser, "availabilityStartTime", -9223372036854775807L);
        long M = M(xmlPullParser, "mediaPresentationDuration", -9223372036854775807L);
        long M2 = M(xmlPullParser, "minBufferTime", -9223372036854775807L);
        Throwable th2 = null;
        boolean equals = "dynamic".equals(xmlPullParser.getAttributeValue(null, "type"));
        long M3 = equals ? M(xmlPullParser, "minimumUpdatePeriod", -9223372036854775807L) : -9223372036854775807L;
        long M4 = equals ? M(xmlPullParser, "timeShiftBufferDepth", -9223372036854775807L) : -9223372036854775807L;
        long M5 = equals ? M(xmlPullParser, "suggestedPresentationDelay", -9223372036854775807L) : -9223372036854775807L;
        long H2 = H(xmlPullParser, "publishTime", -9223372036854775807L);
        long j7 = equals ? 0L : -9223372036854775807L;
        ArrayList i2 = Lists.i(new b(uri.toString(), uri.toString(), v ? 1 : Integer.MIN_VALUE, 1));
        ArrayList arrayList4 = new ArrayList();
        ArrayList arrayList5 = new ArrayList();
        long j8 = equals ? -9223372036854775807L : 0L;
        h hVar = null;
        o oVar = null;
        Uri uri2 = null;
        l lVar = null;
        boolean z2 = false;
        boolean z3 = false;
        while (true) {
            xmlPullParser.next();
            if (q0.f(xmlPullParser, "BaseURL")) {
                if (!z2) {
                    j7 = dVar.B(xmlPullParser, j7);
                    z2 = true;
                }
                arrayList5.addAll(dVar.C(xmlPullParser, i2, v));
            } else if (q0.f(xmlPullParser, "ProgramInformation")) {
                hVar = c0(xmlPullParser);
            } else if (q0.f(xmlPullParser, "UTCTiming")) {
                oVar = w0(xmlPullParser);
            } else if (q0.f(xmlPullParser, "Location")) {
                uri2 = o0.e(uri.toString(), xmlPullParser.nextText());
            } else if (q0.f(xmlPullParser, "ServiceDescription")) {
                lVar = q0(xmlPullParser);
            } else {
                if (!q0.f(xmlPullParser, "Period") || z3) {
                    j2 = j7;
                    arrayList = arrayList5;
                    arrayList2 = i2;
                    j3 = j6;
                    th = th2;
                    arrayList3 = arrayList4;
                    w(xmlPullParser);
                } else {
                    j2 = j7;
                    ArrayList arrayList6 = arrayList4;
                    arrayList = arrayList5;
                    arrayList2 = i2;
                    j3 = j6;
                    th = th2;
                    Pair<g, Long> a0 = a0(xmlPullParser, !arrayList5.isEmpty() ? arrayList5 : i2, j8, j2, H, M4, v);
                    g gVar = (g) a0.first;
                    if (gVar.b != j3) {
                        long longValue = ((Long) a0.second).longValue();
                        if (longValue == j3) {
                            arrayList3 = arrayList6;
                            j4 = j3;
                        } else {
                            j4 = gVar.b + longValue;
                            arrayList3 = arrayList6;
                        }
                        arrayList3.add(gVar);
                        j8 = j4;
                        z = z3;
                    } else if (!equals) {
                        throw k3.c("Unable to determine start of period " + arrayList6.size(), th);
                    } else {
                        arrayList3 = arrayList6;
                        z = true;
                    }
                    z3 = z;
                }
                j7 = j2;
                if (q0.d(xmlPullParser, "MPD")) {
                    arrayList4 = arrayList3;
                    th2 = th;
                    arrayList5 = arrayList;
                    i2 = arrayList2;
                    j6 = j3;
                    dVar = this;
                } else {
                    if (M == j3) {
                        if (j8 != j3) {
                            j5 = j8;
                            if (arrayList3.isEmpty()) {
                                return g(H, j5, M2, equals, M3, M4, M5, H2, hVar, oVar, lVar, uri2, arrayList3);
                            }
                            throw k3.c("No periods found.", th);
                        } else if (!equals) {
                            throw k3.c("Unable to determine duration of static manifest.", th);
                        }
                    }
                    j5 = M;
                    if (arrayList3.isEmpty()) {
                    }
                }
            }
            arrayList = arrayList5;
            arrayList2 = i2;
            j3 = j6;
            th = th2;
            arrayList3 = arrayList4;
            if (q0.d(xmlPullParser, "MPD")) {
            }
        }
    }

    public Pair<g, Long> a0(XmlPullParser xmlPullParser, List<b> list, long j2, long j3, long j4, long j5, boolean z) throws XmlPullParserException, IOException {
        long j6;
        ArrayList arrayList;
        ArrayList arrayList2;
        ArrayList arrayList3;
        Object obj;
        long j7;
        k l0;
        d dVar = this;
        XmlPullParser xmlPullParser2 = xmlPullParser;
        Object obj2 = null;
        String attributeValue = xmlPullParser2.getAttributeValue(null, "id");
        long M = M(xmlPullParser2, "start", j2);
        long j8 = -9223372036854775807L;
        long j9 = j4 != -9223372036854775807L ? j4 + M : -9223372036854775807L;
        long M2 = M(xmlPullParser2, "duration", -9223372036854775807L);
        ArrayList arrayList4 = new ArrayList();
        ArrayList arrayList5 = new ArrayList();
        ArrayList arrayList6 = new ArrayList();
        long j10 = j3;
        long j11 = -9223372036854775807L;
        k.e eVar = null;
        e eVar2 = null;
        boolean z2 = false;
        while (true) {
            xmlPullParser.next();
            if (q0.f(xmlPullParser2, "BaseURL")) {
                if (!z2) {
                    j10 = dVar.B(xmlPullParser2, j10);
                    z2 = true;
                }
                arrayList6.addAll(dVar.C(xmlPullParser2, list, z));
                arrayList3 = arrayList5;
                arrayList = arrayList6;
                j7 = j8;
                obj = obj2;
                arrayList2 = arrayList4;
            } else {
                if (q0.f(xmlPullParser2, "AdaptationSet")) {
                    j6 = j10;
                    arrayList = arrayList6;
                    arrayList2 = arrayList4;
                    arrayList2.add(y(xmlPullParser, !arrayList6.isEmpty() ? arrayList6 : list, eVar, M2, j10, j11, j9, j5, z));
                    xmlPullParser2 = xmlPullParser;
                    arrayList3 = arrayList5;
                } else {
                    j6 = j10;
                    ArrayList arrayList7 = arrayList5;
                    arrayList = arrayList6;
                    arrayList2 = arrayList4;
                    xmlPullParser2 = xmlPullParser;
                    if (q0.f(xmlPullParser2, "EventStream")) {
                        arrayList7.add(Q(xmlPullParser));
                        arrayList3 = arrayList7;
                    } else {
                        arrayList3 = arrayList7;
                        if (q0.f(xmlPullParser2, "SegmentBase")) {
                            eVar = j0(xmlPullParser2, null);
                            obj = null;
                            j10 = j6;
                            j7 = -9223372036854775807L;
                        } else {
                            if (q0.f(xmlPullParser2, "SegmentList")) {
                                long B = B(xmlPullParser2, -9223372036854775807L);
                                obj = null;
                                l0 = k0(xmlPullParser, null, j9, M2, j6, B, j5);
                                j11 = B;
                                j10 = j6;
                                j7 = -9223372036854775807L;
                            } else {
                                obj = null;
                                if (q0.f(xmlPullParser2, "SegmentTemplate")) {
                                    long B2 = B(xmlPullParser2, -9223372036854775807L);
                                    j7 = -9223372036854775807L;
                                    l0 = l0(xmlPullParser, null, q.F(), j9, M2, j6, B2, j5);
                                    j11 = B2;
                                    j10 = j6;
                                } else {
                                    j7 = -9223372036854775807L;
                                    if (q0.f(xmlPullParser2, "AssetIdentifier")) {
                                        eVar2 = I(xmlPullParser2, "AssetIdentifier");
                                    } else {
                                        w(xmlPullParser);
                                    }
                                    j10 = j6;
                                }
                            }
                            eVar = l0;
                        }
                    }
                }
                obj = null;
                j7 = -9223372036854775807L;
                j10 = j6;
            }
            if (q0.d(xmlPullParser2, "Period")) {
                return Pair.create(h(attributeValue, M, arrayList2, arrayList3, eVar2), Long.valueOf(M2));
            }
            arrayList4 = arrayList2;
            arrayList6 = arrayList;
            obj2 = obj;
            arrayList5 = arrayList3;
            j8 = j7;
            dVar = this;
        }
    }

    public final long b(List<k.d> list, long j2, long j3, int i2, long j4) {
        int j5 = i2 >= 0 ? i2 + 1 : (int) p0.j(j4 - j2, j3);
        for (int i3 = 0; i3 < j5; i3++) {
            list.add(m(j2, j3));
            j2 += j3;
        }
        return j2;
    }

    public String[] b0(XmlPullParser xmlPullParser, String str, String[] strArr) {
        String attributeValue = xmlPullParser.getAttributeValue(null, str);
        return attributeValue == null ? strArr : attributeValue.split(",");
    }

    public i.d.a.b.s4.r0.n.a c(int i2, int i3, List<j> list, List<e> list2, List<e> list3, List<e> list4) {
        return new i.d.a.b.s4.r0.n.a(i2, i3, list, list2, list3, list4);
    }

    public h c0(XmlPullParser xmlPullParser) throws IOException, XmlPullParserException {
        String str = null;
        String r0 = r0(xmlPullParser, "moreInformationURL", null);
        String r02 = r0(xmlPullParser, "lang", null);
        String str2 = null;
        String str3 = null;
        while (true) {
            xmlPullParser.next();
            if (q0.f(xmlPullParser, "Title")) {
                str = xmlPullParser.nextText();
            } else if (q0.f(xmlPullParser, "Source")) {
                str2 = xmlPullParser.nextText();
            } else if (q0.f(xmlPullParser, "Copyright")) {
                str3 = xmlPullParser.nextText();
            } else {
                w(xmlPullParser);
            }
            String str4 = str3;
            if (q0.d(xmlPullParser, "ProgramInformation")) {
                return new h(str, str2, str4, r0, r02);
            }
            str3 = str4;
        }
    }

    public i.d.a.b.q4.j.a d(String str, String str2, long j2, long j3, byte[] bArr) {
        return new i.d.a.b.q4.j.a(str, str2, j3, j2, bArr);
    }

    public i d0(XmlPullParser xmlPullParser, String str, String str2) {
        long j2;
        long j3;
        String attributeValue = xmlPullParser.getAttributeValue(null, str);
        String attributeValue2 = xmlPullParser.getAttributeValue(null, str2);
        if (attributeValue2 != null) {
            String[] split = attributeValue2.split("-");
            j2 = Long.parseLong(split[0]);
            if (split.length == 2) {
                j3 = (Long.parseLong(split[1]) - j2) + 1;
                return i(attributeValue, j2, j3);
            }
        } else {
            j2 = 0;
        }
        j3 = -1;
        return i(attributeValue, j2, j3);
    }

    public f e(String str, String str2, long j2, long[] jArr, i.d.a.b.q4.j.a[] aVarArr) {
        return new f(str, str2, j2, jArr, aVarArr);
    }

    public a e0(XmlPullParser xmlPullParser, List<b> list, String str, String str2, int i2, int i3, float f2, int i4, int i5, String str3, List<e> list2, List<e> list3, List<e> list4, List<e> list5, k kVar, long j2, long j3, long j4, long j5, long j6, boolean z) throws XmlPullParserException, IOException {
        long j7;
        ArrayList arrayList;
        ArrayList arrayList2;
        ArrayList arrayList3;
        ArrayList arrayList4;
        ArrayList arrayList5;
        ArrayList arrayList6;
        ArrayList arrayList7;
        int i6;
        long B;
        k kVar2;
        d dVar = this;
        String attributeValue = xmlPullParser.getAttributeValue(null, "id");
        int U = U(xmlPullParser, "bandwidth", -1);
        String r0 = r0(xmlPullParser, "mimeType", str);
        String r02 = r0(xmlPullParser, "codecs", str2);
        int U2 = U(xmlPullParser, "width", i2);
        int U3 = U(xmlPullParser, "height", i3);
        float S = S(xmlPullParser, f2);
        int U4 = U(xmlPullParser, "audioSamplingRate", i5);
        ArrayList arrayList8 = new ArrayList();
        ArrayList arrayList9 = new ArrayList();
        ArrayList arrayList10 = new ArrayList(list4);
        ArrayList arrayList11 = new ArrayList(list5);
        ArrayList arrayList12 = new ArrayList();
        int i7 = i4;
        long j8 = j4;
        long j9 = j5;
        String str4 = null;
        boolean z2 = false;
        k kVar3 = kVar;
        while (true) {
            xmlPullParser.next();
            if (q0.f(xmlPullParser, "BaseURL")) {
                if (!z2) {
                    j8 = dVar.B(xmlPullParser, j8);
                    z2 = true;
                }
                arrayList12.addAll(dVar.C(xmlPullParser, list, z));
            } else if (q0.f(xmlPullParser, "AudioChannelConfiguration")) {
                kVar2 = kVar3;
                arrayList = arrayList12;
                arrayList5 = arrayList8;
                i6 = A(xmlPullParser);
                arrayList6 = arrayList9;
                arrayList7 = arrayList11;
                if (q0.d(xmlPullParser, "Representation")) {
                    break;
                }
                arrayList11 = arrayList7;
                arrayList9 = arrayList6;
                arrayList8 = arrayList5;
                kVar3 = kVar2;
                dVar = this;
                i7 = i6;
                arrayList12 = arrayList;
            } else if (q0.f(xmlPullParser, "SegmentBase")) {
                kVar3 = dVar.j0(xmlPullParser, (k.e) kVar3);
            } else {
                if (q0.f(xmlPullParser, "SegmentList")) {
                    B = dVar.B(xmlPullParser, j9);
                    j7 = j8;
                    arrayList = arrayList12;
                    arrayList2 = arrayList11;
                    arrayList3 = arrayList9;
                    arrayList4 = arrayList10;
                    kVar3 = k0(xmlPullParser, (k.b) kVar3, j2, j3, j7, B, j6);
                    arrayList5 = arrayList8;
                } else {
                    j7 = j8;
                    arrayList = arrayList12;
                    arrayList2 = arrayList11;
                    arrayList3 = arrayList9;
                    arrayList4 = arrayList10;
                    if (q0.f(xmlPullParser, "SegmentTemplate")) {
                        B = dVar.B(xmlPullParser, j9);
                        arrayList5 = arrayList8;
                        kVar3 = l0(xmlPullParser, (k.c) kVar3, list5, j2, j3, j7, B, j6);
                    } else {
                        arrayList5 = arrayList8;
                        if (q0.f(xmlPullParser, "ContentProtection")) {
                            Pair<String, v.b> F = F(xmlPullParser);
                            Object obj = F.first;
                            if (obj != null) {
                                str4 = (String) obj;
                            }
                            Object obj2 = F.second;
                            if (obj2 != null) {
                                arrayList5.add((v.b) obj2);
                            }
                            i6 = i7;
                            j8 = j7;
                            arrayList7 = arrayList2;
                            arrayList6 = arrayList3;
                            arrayList10 = arrayList4;
                            kVar2 = kVar3;
                            if (q0.d(xmlPullParser, "Representation")) {
                            }
                        } else {
                            if (q0.f(xmlPullParser, "InbandEventStream")) {
                                arrayList6 = arrayList3;
                                arrayList6.add(I(xmlPullParser, "InbandEventStream"));
                                arrayList7 = arrayList2;
                                arrayList10 = arrayList4;
                            } else {
                                arrayList6 = arrayList3;
                                if (q0.f(xmlPullParser, "EssentialProperty")) {
                                    arrayList10 = arrayList4;
                                    arrayList10.add(I(xmlPullParser, "EssentialProperty"));
                                    arrayList7 = arrayList2;
                                } else {
                                    arrayList10 = arrayList4;
                                    if (q0.f(xmlPullParser, "SupplementalProperty")) {
                                        arrayList7 = arrayList2;
                                        arrayList7.add(I(xmlPullParser, "SupplementalProperty"));
                                    } else {
                                        arrayList7 = arrayList2;
                                        w(xmlPullParser);
                                    }
                                }
                            }
                            i6 = i7;
                            j8 = j7;
                            kVar2 = kVar3;
                            if (q0.d(xmlPullParser, "Representation")) {
                            }
                        }
                    }
                }
                i6 = i7;
                j9 = B;
                j8 = j7;
                arrayList7 = arrayList2;
                arrayList6 = arrayList3;
                arrayList10 = arrayList4;
                kVar2 = kVar3;
                if (q0.d(xmlPullParser, "Representation")) {
                }
            }
            arrayList = arrayList12;
            arrayList5 = arrayList8;
            i6 = i7;
            kVar2 = kVar3;
            arrayList6 = arrayList9;
            arrayList7 = arrayList11;
            if (q0.d(xmlPullParser, "Representation")) {
            }
        }
        ArrayList arrayList13 = arrayList7;
        ArrayList arrayList14 = arrayList10;
        ArrayList arrayList15 = arrayList6;
        x2 f3 = f(attributeValue, r0, U2, U3, S, i6, U4, U, str3, list2, list3, r02, arrayList14, arrayList13);
        k.e eVar = kVar2;
        if (kVar2 == null) {
            eVar = new k.e();
        }
        boolean isEmpty = arrayList.isEmpty();
        ArrayList arrayList16 = arrayList;
        if (isEmpty) {
            arrayList16 = list;
        }
        return new a(f3, arrayList16, eVar, str4, arrayList5, arrayList15, arrayList14, arrayList13, -1L);
    }

    public x2 f(String str, String str2, int i2, int i3, float f2, int i4, int i5, int i6, String str3, List<e> list, List<e> list2, String str4, List<e> list3, List<e> list4) {
        String str5 = str4;
        String u = u(str2, str5);
        if ("audio/eac3".equals(u)) {
            u = N(list4);
            if ("audio/eac3-joc".equals(u)) {
                str5 = "ec+3";
            }
        }
        int p0 = p0(list);
        int i0 = i0(list) | f0(list2) | h0(list3) | h0(list4);
        Pair<Integer, Integer> t0 = t0(list3);
        x2.b bVar = new x2.b();
        bVar.U(str);
        bVar.M(str2);
        bVar.g0(u);
        bVar.K(str5);
        bVar.b0(i6);
        bVar.i0(p0);
        bVar.e0(i0);
        bVar.X(str3);
        int i7 = -1;
        bVar.l0(t0 != null ? ((Integer) t0.first).intValue() : -1);
        bVar.m0(t0 != null ? ((Integer) t0.second).intValue() : -1);
        if (y.q(u)) {
            bVar.n0(i2);
            bVar.S(i3);
            bVar.R(f2);
        } else if (y.m(u)) {
            bVar.J(i4);
            bVar.h0(i5);
        } else if (y.p(u)) {
            if ("application/cea-608".equals(u)) {
                i7 = D(list2);
            } else if ("application/cea-708".equals(u)) {
                i7 = E(list2);
            }
            bVar.H(i7);
        } else if (y.n(u)) {
            bVar.n0(i2);
            bVar.S(i3);
        }
        return bVar.G();
    }

    public int f0(List<e> list) {
        int u0;
        int i2 = 0;
        for (int i3 = 0; i3 < list.size(); i3++) {
            e eVar = list.get(i3);
            if (i.d.b.a.b.a("urn:mpeg:dash:role:2011", eVar.a)) {
                u0 = g0(eVar.b);
            } else if (i.d.b.a.b.a("urn:tva:metadata:cs:AudioPurposeCS:2007", eVar.a)) {
                u0 = u0(eVar.b);
            }
            i2 |= u0;
        }
        return i2;
    }

    public c g(long j2, long j3, long j4, boolean z, long j5, long j6, long j7, long j8, h hVar, o oVar, l lVar, Uri uri, List<g> list) {
        return new c(j2, j3, j4, z, j5, j6, j7, j8, hVar, oVar, lVar, uri, list);
    }

    public int g0(String str) {
        if (str == null) {
            return 0;
        }
        str.hashCode();
        char c2 = 65535;
        switch (str.hashCode()) {
            case -2060497896:
                if (str.equals("subtitle")) {
                    c2 = 0;
                    break;
                }
                break;
            case -1724546052:
                if (str.equals("description")) {
                    c2 = 1;
                    break;
                }
                break;
            case -1580883024:
                if (str.equals("enhanced-audio-intelligibility")) {
                    c2 = 2;
                    break;
                }
                break;
            case -1574842690:
                if (str.equals("forced_subtitle")) {
                    c2 = 3;
                    break;
                }
                break;
            case -1408024454:
                if (str.equals(MediaTrack.x)) {
                    c2 = 4;
                    break;
                }
                break;
            case -1396432756:
                if (str.equals("forced-subtitle")) {
                    c2 = 5;
                    break;
                }
                break;
            case 99825:
                if (str.equals("dub")) {
                    c2 = 6;
                    break;
                }
                break;
            case 3343801:
                if (str.equals("main")) {
                    c2 = 7;
                    break;
                }
                break;
            case 3530173:
                if (str.equals("sign")) {
                    c2 = '\b';
                    break;
                }
                break;
            case 552573414:
                if (str.equals("caption")) {
                    c2 = '\t';
                    break;
                }
                break;
            case 899152809:
                if (str.equals("commentary")) {
                    c2 = '\n';
                    break;
                }
                break;
            case 1629013393:
                if (str.equals("emergency")) {
                    c2 = 11;
                    break;
                }
                break;
            case 1855372047:
                if (str.equals("supplementary")) {
                    c2 = '\f';
                    break;
                }
                break;
        }
        switch (c2) {
            case 0:
            case 3:
            case 5:
                return 128;
            case 1:
                return FileUtils.FileMode.MODE_ISVTX;
            case 2:
                return FileUtils.FileMode.MODE_ISUID;
            case 4:
                return 2;
            case 6:
                return 16;
            case 7:
                return 1;
            case '\b':
                return FileUtils.FileMode.MODE_IRUSR;
            case '\t':
                return 64;
            case '\n':
                return 8;
            case 11:
                return 32;
            case '\f':
                return 4;
            default:
                return 0;
        }
    }

    public g h(String str, long j2, List<i.d.a.b.s4.r0.n.a> list, List<f> list2, e eVar) {
        return new g(str, j2, list, list2, eVar);
    }

    public int h0(List<e> list) {
        int i2 = 0;
        for (int i3 = 0; i3 < list.size(); i3++) {
            if (i.d.b.a.b.a("http://dashif.org/guidelines/trickmode", list.get(i3).a)) {
                i2 |= Http2.INITIAL_MAX_FRAME_SIZE;
            }
        }
        return i2;
    }

    public i i(String str, long j2, long j3) {
        return new i(str, j2, j3);
    }

    public int i0(List<e> list) {
        int i2 = 0;
        for (int i3 = 0; i3 < list.size(); i3++) {
            e eVar = list.get(i3);
            if (i.d.b.a.b.a("urn:mpeg:dash:role:2011", eVar.a)) {
                i2 |= g0(eVar.b);
            }
        }
        return i2;
    }

    public j j(a aVar, String str, String str2, ArrayList<v.b> arrayList, ArrayList<e> arrayList2) {
        x2.b a2 = aVar.a.a();
        if (str != null) {
            a2.W(str);
        }
        String str3 = aVar.d;
        if (str3 != null) {
            str2 = str3;
        }
        ArrayList<v.b> arrayList3 = aVar.e;
        arrayList3.addAll(arrayList);
        if (!arrayList3.isEmpty()) {
            r(arrayList3);
            s(arrayList3);
            a2.O(new v(str2, arrayList3));
        }
        ArrayList<e> arrayList4 = aVar.f4890f;
        arrayList4.addAll(arrayList2);
        return j.o(aVar.f4891g, a2.G(), aVar.b, aVar.c, arrayList4, aVar.f4892h, aVar.f4893i, null);
    }

    public k.e j0(XmlPullParser xmlPullParser, k.e eVar) throws XmlPullParserException, IOException {
        long j2;
        long j3;
        long X = X(xmlPullParser, "timescale", eVar != null ? eVar.b : 1L);
        long X2 = X(xmlPullParser, "presentationTimeOffset", eVar != null ? eVar.c : 0L);
        long j4 = eVar != null ? eVar.d : 0L;
        long j5 = eVar != null ? eVar.e : 0L;
        String attributeValue = xmlPullParser.getAttributeValue(null, "indexRange");
        if (attributeValue != null) {
            String[] split = attributeValue.split("-");
            long parseLong = Long.parseLong(split[0]);
            j2 = (Long.parseLong(split[1]) - parseLong) + 1;
            j3 = parseLong;
        } else {
            j2 = j5;
            j3 = j4;
        }
        i iVar = eVar != null ? eVar.a : null;
        do {
            xmlPullParser.next();
            if (q0.f(xmlPullParser, "Initialization")) {
                iVar = T(xmlPullParser);
            } else {
                w(xmlPullParser);
            }
        } while (!q0.d(xmlPullParser, "SegmentBase"));
        return n(iVar, X, X2, j3, j2);
    }

    public k.b k(i iVar, long j2, long j3, long j4, long j5, List<k.d> list, long j6, List<i> list2, long j7, long j8) {
        return new k.b(iVar, j2, j3, j4, j5, list, j6, list2, p0.u0(j7), p0.u0(j8));
    }

    public k.b k0(XmlPullParser xmlPullParser, k.b bVar, long j2, long j3, long j4, long j5, long j6) throws XmlPullParserException, IOException {
        long X = X(xmlPullParser, "timescale", bVar != null ? bVar.b : 1L);
        long X2 = X(xmlPullParser, "presentationTimeOffset", bVar != null ? bVar.c : 0L);
        long X3 = X(xmlPullParser, "duration", bVar != null ? bVar.e : -9223372036854775807L);
        long X4 = X(xmlPullParser, "startNumber", bVar != null ? bVar.d : 1L);
        long t = t(j4, j5);
        List<k.d> list = null;
        List<i> list2 = null;
        i iVar = null;
        do {
            xmlPullParser.next();
            if (q0.f(xmlPullParser, "Initialization")) {
                iVar = T(xmlPullParser);
            } else if (q0.f(xmlPullParser, "SegmentTimeline")) {
                list = m0(xmlPullParser, X, j3);
            } else if (q0.f(xmlPullParser, "SegmentURL")) {
                if (list2 == null) {
                    list2 = new ArrayList<>();
                }
                list2.add(n0(xmlPullParser));
            } else {
                w(xmlPullParser);
            }
        } while (!q0.d(xmlPullParser, "SegmentList"));
        if (bVar != null) {
            if (iVar == null) {
                iVar = bVar.a;
            }
            if (list == null) {
                list = bVar.f4900f;
            }
            if (list2 == null) {
                list2 = bVar.f4904j;
            }
        }
        return k(iVar, X, X2, X4, X3, list, t, list2, j6, j2);
    }

    public k.c l(i iVar, long j2, long j3, long j4, long j5, long j6, List<k.d> list, long j7, n nVar, n nVar2, long j8, long j9) {
        return new k.c(iVar, j2, j3, j4, j5, j6, list, j7, nVar, nVar2, p0.u0(j8), p0.u0(j9));
    }

    public k.c l0(XmlPullParser xmlPullParser, k.c cVar, List<e> list, long j2, long j3, long j4, long j5, long j6) throws XmlPullParserException, IOException {
        long X = X(xmlPullParser, "timescale", cVar != null ? cVar.b : 1L);
        long X2 = X(xmlPullParser, "presentationTimeOffset", cVar != null ? cVar.c : 0L);
        long X3 = X(xmlPullParser, "duration", cVar != null ? cVar.e : -9223372036854775807L);
        long X4 = X(xmlPullParser, "startNumber", cVar != null ? cVar.d : 1L);
        long W = W(list);
        long t = t(j4, j5);
        List<k.d> list2 = null;
        n v0 = v0(xmlPullParser, DownloaderService.MEDIA_ROOT, cVar != null ? cVar.f4906k : null);
        n v02 = v0(xmlPullParser, "initialization", cVar != null ? cVar.f4905j : null);
        i iVar = null;
        while (true) {
            xmlPullParser.next();
            if (q0.f(xmlPullParser, "Initialization")) {
                iVar = T(xmlPullParser);
            } else if (q0.f(xmlPullParser, "SegmentTimeline")) {
                list2 = m0(xmlPullParser, X, j3);
            } else {
                w(xmlPullParser);
            }
            if (q0.d(xmlPullParser, "SegmentTemplate")) {
                break;
            }
        }
        if (cVar != null) {
            if (iVar == null) {
                iVar = cVar.a;
            }
            if (list2 == null) {
                list2 = cVar.f4900f;
            }
        }
        return l(iVar, X, X2, X4, W, X3, list2, t, v02, v0, j6, j2);
    }

    public k.d m(long j2, long j3) {
        return new k.d(j2, j3);
    }

    public List<k.d> m0(XmlPullParser xmlPullParser, long j2, long j3) throws XmlPullParserException, IOException {
        ArrayList arrayList = new ArrayList();
        long j4 = 0;
        long j5 = -9223372036854775807L;
        boolean z = false;
        int i2 = 0;
        do {
            xmlPullParser.next();
            if (q0.f(xmlPullParser, "S")) {
                long X = X(xmlPullParser, "t", -9223372036854775807L);
                if (z) {
                    j4 = b(arrayList, j4, j5, i2, X);
                }
                if (X == -9223372036854775807L) {
                    X = j4;
                }
                j5 = X(xmlPullParser, "d", -9223372036854775807L);
                i2 = U(xmlPullParser, r.e, 0);
                j4 = X;
                z = true;
            } else {
                w(xmlPullParser);
            }
        } while (!q0.d(xmlPullParser, "SegmentTimeline"));
        if (z) {
            b(arrayList, j4, j5, i2, p0.E0(j3, j2, 1000L));
        }
        return arrayList;
    }

    public k.e n(i iVar, long j2, long j3, long j4, long j5) {
        return new k.e(iVar, j2, j3, j4, j5);
    }

    public i n0(XmlPullParser xmlPullParser) {
        return d0(xmlPullParser, DownloaderService.MEDIA_ROOT, "mediaRange");
    }

    public o o(String str, String str2) {
        return new o(str, str2);
    }

    public int o0(String str) {
        if (str == null) {
            return 0;
        }
        str.hashCode();
        return (str.equals("forced_subtitle") || str.equals("forced-subtitle")) ? 2 : 0;
    }

    public int p0(List<e> list) {
        int i2 = 0;
        for (int i3 = 0; i3 < list.size(); i3++) {
            e eVar = list.get(i3);
            if (i.d.b.a.b.a("urn:mpeg:dash:role:2011", eVar.a)) {
                i2 |= o0(eVar.b);
            }
        }
        return i2;
    }

    public l q0(XmlPullParser xmlPullParser) throws XmlPullParserException, IOException {
        long j2 = -9223372036854775807L;
        long j3 = -9223372036854775807L;
        long j4 = -9223372036854775807L;
        float f2 = -3.4028235E38f;
        float f3 = -3.4028235E38f;
        while (true) {
            xmlPullParser.next();
            if (q0.f(xmlPullParser, "Latency")) {
                j2 = X(xmlPullParser, "target", -9223372036854775807L);
                j3 = X(xmlPullParser, "min", -9223372036854775807L);
                j4 = X(xmlPullParser, "max", -9223372036854775807L);
            } else if (q0.f(xmlPullParser, "PlaybackRate")) {
                f2 = R(xmlPullParser, "min", -3.4028235E38f);
                f3 = R(xmlPullParser, "max", -3.4028235E38f);
            }
            long j5 = j2;
            long j6 = j3;
            long j7 = j4;
            float f4 = f2;
            float f5 = f3;
            if (q0.d(xmlPullParser, "ServiceDescription")) {
                return new l(j5, j6, j7, f4, f5);
            }
            j2 = j5;
            j3 = j6;
            j4 = j7;
            f2 = f4;
            f3 = f5;
        }
    }

    public Pair<Integer, Integer> t0(List<e> list) {
        String str;
        for (int i2 = 0; i2 < list.size(); i2++) {
            e eVar = list.get(i2);
            if ((i.d.b.a.b.a("http://dashif.org/thumbnail_tile", eVar.a) || i.d.b.a.b.a("http://dashif.org/guidelines/thumbnail_tile", eVar.a)) && (str = eVar.b) != null) {
                String[] G0 = p0.G0(str, x.c);
                if (G0.length == 2) {
                    try {
                        return Pair.create(Integer.valueOf(Integer.parseInt(G0[0])), Integer.valueOf(Integer.parseInt(G0[1])));
                    } catch (NumberFormatException unused) {
                        continue;
                    }
                }
            }
        }
        return null;
    }

    public int u0(String str) {
        if (str == null) {
            return 0;
        }
        str.hashCode();
        char c2 = 65535;
        switch (str.hashCode()) {
            case 49:
                if (str.equals("1")) {
                    c2 = 0;
                    break;
                }
                break;
            case 50:
                if (str.equals("2")) {
                    c2 = 1;
                    break;
                }
                break;
            case 51:
                if (str.equals("3")) {
                    c2 = 2;
                    break;
                }
                break;
            case 52:
                if (str.equals("4")) {
                    c2 = 3;
                    break;
                }
                break;
            case 54:
                if (str.equals("6")) {
                    c2 = 4;
                    break;
                }
                break;
        }
        switch (c2) {
            case 0:
                return FileUtils.FileMode.MODE_ISVTX;
            case 1:
                return FileUtils.FileMode.MODE_ISUID;
            case 2:
                return 4;
            case 3:
                return 8;
            case 4:
                return 1;
            default:
                return 0;
        }
    }

    public final boolean v(String[] strArr) {
        for (String str : strArr) {
            if (str.startsWith("urn:dvb:dash:profile:dvb-dash:")) {
                return true;
            }
        }
        return false;
    }

    public n v0(XmlPullParser xmlPullParser, String str, n nVar) {
        String attributeValue = xmlPullParser.getAttributeValue(null, str);
        return attributeValue != null ? n.b(attributeValue) : nVar;
    }

    public o w0(XmlPullParser xmlPullParser) {
        return o(xmlPullParser.getAttributeValue(null, "schemeIdUri"), xmlPullParser.getAttributeValue(null, "value"));
    }

    @Override
    public c a(Uri uri, InputStream inputStream) throws IOException {
        try {
            XmlPullParser newPullParser = this.a.newPullParser();
            newPullParser.setInput(inputStream, null);
            if (newPullParser.next() == 2 && "MPD".equals(newPullParser.getName())) {
                return Y(newPullParser, uri);
            }
            throw k3.c("inputStream does not contain a valid media presentation description", null);
        } catch (XmlPullParserException e2) {
            throw k3.c(null, e2);
        }
    }

    public i.d.a.b.s4.r0.n.a y(XmlPullParser xmlPullParser, List<b> list, k kVar, long j2, long j3, long j4, long j5, long j6, boolean z) throws XmlPullParserException, IOException {
        long j7;
        ArrayList<e> arrayList;
        Object obj;
        long j8;
        ArrayList arrayList2;
        ArrayList arrayList3;
        ArrayList arrayList4;
        ArrayList arrayList5;
        ArrayList arrayList6;
        ArrayList<v.b> arrayList7;
        String str;
        String str2;
        ArrayList arrayList8;
        int i2;
        ArrayList<e> arrayList9;
        long B;
        d dVar = this;
        XmlPullParser xmlPullParser2 = xmlPullParser;
        int U = U(xmlPullParser2, "id", -1);
        int G = G(xmlPullParser);
        String attributeValue = xmlPullParser2.getAttributeValue(null, "mimeType");
        String attributeValue2 = xmlPullParser2.getAttributeValue(null, "codecs");
        int U2 = U(xmlPullParser2, "width", -1);
        int U3 = U(xmlPullParser2, "height", -1);
        float S = S(xmlPullParser2, -1.0f);
        int U4 = U(xmlPullParser2, "audioSamplingRate", -1);
        String str3 = "lang";
        String attributeValue3 = xmlPullParser2.getAttributeValue(null, "lang");
        String attributeValue4 = xmlPullParser2.getAttributeValue(null, "label");
        ArrayList<v.b> arrayList10 = new ArrayList<>();
        ArrayList<e> 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();
        k.e eVar = kVar;
        int i3 = G;
        String str4 = attributeValue3;
        String str5 = attributeValue4;
        String str6 = null;
        int i4 = -1;
        boolean z2 = false;
        long j9 = j3;
        long j10 = j4;
        while (true) {
            xmlPullParser.next();
            if (q0.f(xmlPullParser2, "BaseURL")) {
                if (!z2) {
                    j9 = dVar.B(xmlPullParser2, j9);
                    z2 = true;
                }
                j7 = j10;
                arrayList = arrayList11;
                arrayList17.addAll(dVar.C(xmlPullParser2, list, z));
            } else {
                j7 = j10;
                arrayList = arrayList11;
                if (q0.f(xmlPullParser2, "ContentProtection")) {
                    Pair<String, v.b> F = F(xmlPullParser);
                    Object obj2 = F.first;
                    if (obj2 != null) {
                        str6 = (String) obj2;
                    }
                    Object obj3 = F.second;
                    if (obj3 != null) {
                        arrayList10.add((v.b) obj3);
                    }
                } else {
                    if (q0.f(xmlPullParser2, "ContentComponent")) {
                        str2 = q(str4, xmlPullParser2.getAttributeValue(null, str3));
                        obj = null;
                        j8 = j9;
                        arrayList2 = arrayList17;
                        arrayList8 = arrayList16;
                        arrayList3 = arrayList15;
                        arrayList4 = arrayList14;
                        arrayList5 = arrayList13;
                        arrayList6 = arrayList12;
                        arrayList7 = arrayList10;
                        str = str3;
                        i2 = p(i3, G(xmlPullParser));
                        arrayList9 = arrayList;
                    } else {
                        int i5 = i3;
                        String str7 = str4;
                        if (q0.f(xmlPullParser2, "Role")) {
                            arrayList13.add(I(xmlPullParser2, "Role"));
                        } else if (q0.f(xmlPullParser2, "AudioChannelConfiguration")) {
                            i4 = A(xmlPullParser);
                        } else if (q0.f(xmlPullParser2, "Accessibility")) {
                            arrayList12.add(I(xmlPullParser2, "Accessibility"));
                        } else if (q0.f(xmlPullParser2, "EssentialProperty")) {
                            arrayList14.add(I(xmlPullParser2, "EssentialProperty"));
                        } else if (q0.f(xmlPullParser2, "SupplementalProperty")) {
                            arrayList15.add(I(xmlPullParser2, "SupplementalProperty"));
                        } else if (q0.f(xmlPullParser2, "Representation")) {
                            j8 = j9;
                            arrayList2 = arrayList17;
                            arrayList3 = arrayList15;
                            arrayList4 = arrayList14;
                            arrayList5 = arrayList13;
                            arrayList6 = arrayList12;
                            arrayList7 = arrayList10;
                            str = str3;
                            obj = null;
                            str2 = str7;
                            a e0 = e0(xmlPullParser, !arrayList17.isEmpty() ? arrayList17 : list, attributeValue, attributeValue2, U2, U3, S, i4, U4, str7, arrayList5, arrayList6, arrayList4, arrayList3, eVar, j5, j2, j8, j7, j6, z);
                            int p2 = p(i5, y.i(e0.a.y));
                            arrayList8 = arrayList16;
                            arrayList8.add(e0);
                            xmlPullParser2 = xmlPullParser;
                            i2 = p2;
                            arrayList9 = arrayList;
                        } else {
                            obj = null;
                            j8 = j9;
                            arrayList2 = arrayList17;
                            arrayList3 = arrayList15;
                            arrayList4 = arrayList14;
                            arrayList5 = arrayList13;
                            arrayList6 = arrayList12;
                            arrayList7 = arrayList10;
                            str = str3;
                            str2 = str7;
                            arrayList8 = arrayList16;
                            if (q0.f(xmlPullParser, "SegmentBase")) {
                                eVar = j0(xmlPullParser, (k.e) eVar);
                                i2 = i5;
                                arrayList9 = arrayList;
                                j10 = j7;
                                xmlPullParser2 = xmlPullParser;
                            } else {
                                if (q0.f(xmlPullParser, "SegmentList")) {
                                    B = B(xmlPullParser, j7);
                                    i2 = i5;
                                    eVar = k0(xmlPullParser, (k.b) eVar, j5, j2, j8, B, j6);
                                    xmlPullParser2 = xmlPullParser;
                                } else {
                                    j10 = j7;
                                    i2 = i5;
                                    if (q0.f(xmlPullParser, "SegmentTemplate")) {
                                        B = B(xmlPullParser, j10);
                                        xmlPullParser2 = xmlPullParser;
                                        eVar = l0(xmlPullParser, (k.c) eVar, arrayList3, j5, j2, j8, B, j6);
                                    } else {
                                        xmlPullParser2 = xmlPullParser;
                                        if (q0.f(xmlPullParser2, "InbandEventStream")) {
                                            arrayList9 = arrayList;
                                            arrayList9.add(I(xmlPullParser2, "InbandEventStream"));
                                        } else {
                                            arrayList9 = arrayList;
                                            if (q0.f(xmlPullParser2, "Label")) {
                                                str5 = V(xmlPullParser);
                                            } else if (q0.e(xmlPullParser)) {
                                                z(xmlPullParser);
                                            }
                                        }
                                    }
                                }
                                j10 = B;
                                arrayList9 = arrayList;
                            }
                            if (!q0.d(xmlPullParser2, "AdaptationSet")) {
                                break;
                            }
                            arrayList11 = arrayList9;
                            arrayList16 = arrayList8;
                            arrayList17 = arrayList2;
                            arrayList15 = arrayList3;
                            j9 = j8;
                            arrayList14 = arrayList4;
                            arrayList13 = arrayList5;
                            arrayList12 = arrayList6;
                            arrayList10 = arrayList7;
                            str3 = str;
                            i3 = i2;
                            str4 = str2;
                            dVar = this;
                        }
                        obj = null;
                        j8 = j9;
                        arrayList2 = arrayList17;
                        arrayList3 = arrayList15;
                        arrayList4 = arrayList14;
                        arrayList5 = arrayList13;
                        arrayList6 = arrayList12;
                        arrayList7 = arrayList10;
                        str = str3;
                        i2 = i5;
                        str2 = str7;
                        arrayList9 = arrayList;
                        j10 = j7;
                        arrayList8 = arrayList16;
                        if (!q0.d(xmlPullParser2, "AdaptationSet")) {
                        }
                    }
                    j10 = j7;
                    if (!q0.d(xmlPullParser2, "AdaptationSet")) {
                    }
                }
            }
            j10 = j7;
            j8 = j9;
            arrayList8 = arrayList16;
            arrayList4 = arrayList14;
            arrayList5 = arrayList13;
            arrayList6 = arrayList12;
            arrayList7 = arrayList10;
            str = str3;
            arrayList9 = arrayList;
            i2 = i3;
            str2 = str4;
            obj = null;
            arrayList2 = arrayList17;
            arrayList3 = arrayList15;
            if (!q0.d(xmlPullParser2, "AdaptationSet")) {
            }
        }
        ArrayList arrayList18 = new ArrayList(arrayList8.size());
        for (int i6 = 0; i6 < arrayList8.size(); i6++) {
            arrayList18.add(j((a) arrayList8.get(i6), str5, str6, arrayList7, arrayList9));
        }
        return c(U, i2, arrayList18, arrayList6, arrayList4, arrayList3);
    }

    public void z(XmlPullParser xmlPullParser) throws XmlPullParserException, IOException {
        w(xmlPullParser);
    }
}