APK反编译源代码展示 - 南明离火平台提供

应用版本信息
应用名称:Meganet Turbo
版本号:2.0.10
包名称:br.com.meganetturbo.appcliente

MD5 校验值:12538e99b43ae4a3db9c6dfff4aad74d

反编译源代码说明

d.java 文件包含反编译后的源代码,请注意,该内容仅供学习和参考使用,不得用于非法用途。


package k3;

import a4.j0;
import android.net.Uri;
import android.text.TextUtils;
import android.util.Base64;
import android.util.Pair;
import android.util.Xml;
import b4.n0;
import b4.q0;
import b4.r;
import b4.r0;
import b4.v;
import e2.q1;
import e2.x2;
import i2.m;
import java.io.ByteArrayOutputStream;
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 k3.k;
import o5.e0;
import o5.u;
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> {

    private static final Pattern f16898b = Pattern.compile("(\\d+)(?:/(\\d+))?");

    private static final Pattern f16899c = Pattern.compile("CC([1-4])=.*");

    private static final Pattern f16900d = Pattern.compile("([1-9]|[1-5][0-9]|6[0-3])=.*");

    private static final int[] f16901e = {-1, 1, 2, 3, 4, 5, 6, 8, 2, 3, 4, 7, 8, 24, 8, 12, 10, 12, 14, 12, 14};

    private final XmlPullParserFactory f16902a;

    public static final class a {

        public final q1 f16903a;

        public final u<b> f16904b;

        public final k f16905c;

        public final String f16906d;

        public final ArrayList<m.b> f16907e;

        public final ArrayList<e> f16908f;

        public final long f16909g;

        public final List<e> f16910h;

        public final List<e> f16911i;

        public a(q1 q1Var, List<b> list, k kVar, String str, ArrayList<m.b> arrayList, ArrayList<e> arrayList2, List<e> list2, List<e> list3, long j10) {
            this.f16903a = q1Var;
            this.f16904b = u.r(list);
            this.f16905c = kVar;
            this.f16906d = str;
            this.f16907e = arrayList;
            this.f16908f = arrayList2;
            this.f16910h = list2;
            this.f16911i = list3;
            this.f16909g = j10;
        }
    }

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

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

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

    protected static long H(XmlPullParser xmlPullParser, String str, long j10) {
        String attributeValue = xmlPullParser.getAttributeValue(null, str);
        return attributeValue == null ? j10 : q0.I0(attributeValue);
    }

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

    protected static int J(XmlPullParser xmlPullParser) {
        char c10;
        String attributeValue = xmlPullParser.getAttributeValue(null, "value");
        if (attributeValue == null) {
            return -1;
        }
        String e10 = n5.c.e(attributeValue);
        e10.hashCode();
        switch (e10.hashCode()) {
            case 1596796:
                if (e10.equals("4000")) {
                    c10 = 0;
                    break;
                }
                c10 = 65535;
                break;
            case 2937391:
                if (e10.equals("a000")) {
                    c10 = 1;
                    break;
                }
                c10 = 65535;
                break;
            case 3094035:
                if (e10.equals("f801")) {
                    c10 = 2;
                    break;
                }
                c10 = 65535;
                break;
            case 3133436:
                if (e10.equals("fa01")) {
                    c10 = 3;
                    break;
                }
                c10 = 65535;
                break;
            default:
                c10 = 65535;
                break;
        }
        switch (c10) {
            case 0:
                return 1;
            case 1:
                return 2;
            case 2:
                return 6;
            case 3:
                return 8;
            default:
                return -1;
        }
    }

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

    protected 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;
    }

    protected static long M(XmlPullParser xmlPullParser, String str, long j10) {
        String attributeValue = xmlPullParser.getAttributeValue(null, str);
        return attributeValue == null ? j10 : q0.J0(attributeValue);
    }

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

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

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

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

    protected static long W(List<e> list) {
        for (int i10 = 0; i10 < list.size(); i10++) {
            e eVar = list.get(i10);
            if (n5.c.a("http://dashif.org/guidelines/last-segment-number", eVar.f16912a)) {
                return Long.parseLong(eVar.f16913b);
            }
        }
        return -1L;
    }

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

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

    private long b(List<k.d> list, long j10, long j11, int i10, long j12) {
        int m10 = i10 >= 0 ? i10 + 1 : (int) q0.m(j12 - j10, j11);
        for (int i11 = 0; i11 < m10; i11++) {
            list.add(m(j10, j11));
            j10 += j11;
        }
        return j10;
    }

    private static int p(int i10, int i11) {
        if (i10 == -1) {
            return i11;
        }
        if (i11 == -1) {
            return i10;
        }
        b4.a.f(i10 == i11);
        return i10;
    }

    private static String q(String str, String str2) {
        if (str == null) {
            return str2;
        }
        if (str2 == null) {
            return str;
        }
        b4.a.f(str.equals(str2));
        return str;
    }

    private static void r(ArrayList<m.b> arrayList) {
        String str;
        int i10 = 0;
        while (true) {
            if (i10 >= arrayList.size()) {
                str = null;
                break;
            }
            m.b bVar = arrayList.get(i10);
            if (e2.l.f10988c.equals(bVar.f14095b) && (str = bVar.f14096c) != null) {
                arrayList.remove(i10);
                break;
            }
            i10++;
        }
        if (str == null) {
            return;
        }
        for (int i11 = 0; i11 < arrayList.size(); i11++) {
            m.b bVar2 = arrayList.get(i11);
            if (e2.l.f10987b.equals(bVar2.f14095b) && bVar2.f14096c == null) {
                arrayList.set(i11, new m.b(e2.l.f10988c, str, bVar2.f14097d, bVar2.f14098e));
            }
        }
    }

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

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

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

    private static long t(long j10, long j11) {
        if (j11 != -9223372036854775807L) {
            j10 = j11;
        }
        if (j10 == Long.MAX_VALUE) {
            return -9223372036854775807L;
        }
        return j10;
    }

    private static String u(String str, String str2) {
        if (v.o(str)) {
            return v.c(str2);
        }
        if (v.s(str)) {
            return v.n(str2);
        }
        if (v.r(str) || v.p(str)) {
            return str;
        }
        if (!"application/mp4".equals(str)) {
            return null;
        }
        String g10 = v.g(str2);
        return "text/vtt".equals(g10) ? "application/x-mp4-vtt" : g10;
    }

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

    public static void w(XmlPullParser xmlPullParser) {
        if (r0.e(xmlPullParser)) {
            int i10 = 1;
            while (i10 != 0) {
                xmlPullParser.next();
                if (r0.e(xmlPullParser)) {
                    i10++;
                } else if (r0.c(xmlPullParser)) {
                    i10--;
                }
            }
        }
    }

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

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

    protected List<b> C(XmlPullParser xmlPullParser, List<b> list, boolean z10) {
        String attributeValue = xmlPullParser.getAttributeValue(null, "dvb:priority");
        int parseInt = attributeValue != null ? Integer.parseInt(attributeValue) : z10 ? 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 s02 = s0(xmlPullParser, "BaseURL");
        if (n0.b(s02)) {
            if (attributeValue3 == null) {
                attributeValue3 = s02;
            }
            return e0.j(new b(s02, attributeValue3, parseInt, parseInt2));
        }
        ArrayList arrayList = new ArrayList();
        for (int i10 = 0; i10 < list.size(); i10++) {
            b bVar = list.get(i10);
            String d10 = n0.d(bVar.f16881a, s02);
            String str = attributeValue3 == null ? d10 : attributeValue3;
            if (z10) {
                parseInt = bVar.f16883c;
                parseInt2 = bVar.f16884d;
                str = bVar.f16882b;
            }
            arrayList.add(new b(d10, str, parseInt, parseInt2));
        }
        return arrayList;
    }

    protected Pair<String, m.b> F(XmlPullParser xmlPullParser) {
        String str;
        ?? r32;
        String str2;
        String str3;
        ?? r42;
        String attributeValue = xmlPullParser.getAttributeValue(null, "schemeIdUri");
        if (attributeValue != null) {
            String e10 = n5.c.e(attributeValue);
            e10.hashCode();
            char c10 = 65535;
            switch (e10.hashCode()) {
                case -1980789791:
                    if (e10.equals("urn:uuid:e2719d58-a985-b3c9-781a-b030af78d30e")) {
                        c10 = 0;
                        break;
                    }
                    break;
                case 489446379:
                    if (e10.equals("urn:uuid:9a04f079-9840-4286-ab92-e65be0885f95")) {
                        c10 = 1;
                        break;
                    }
                    break;
                case 755418770:
                    if (e10.equals("urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed")) {
                        c10 = 2;
                        break;
                    }
                    break;
                case 1812765994:
                    if (e10.equals("urn:mpeg:dash:mp4protection:2011")) {
                        c10 = 3;
                        break;
                    }
                    break;
            }
            switch (c10) {
                case 0:
                    r32 = e2.l.f10988c;
                    str = null;
                    str2 = null;
                    str3 = str2;
                    r42 = str2;
                    break;
                case 1:
                    r32 = e2.l.f10990e;
                    str = null;
                    str2 = null;
                    str3 = str2;
                    r42 = str2;
                    break;
                case 2:
                    r32 = e2.l.f10989d;
                    str = null;
                    str2 = null;
                    str3 = str2;
                    r42 = str2;
                    break;
                case 3:
                    str = xmlPullParser.getAttributeValue(null, "value");
                    String b10 = r0.b(xmlPullParser, "default_KID");
                    if (!TextUtils.isEmpty(b10) && !"00000000-0000-0000-0000-000000000000".equals(b10)) {
                        String[] split = b10.split("\\s+");
                        UUID[] uuidArr = new UUID[split.length];
                        for (int i10 = 0; i10 < split.length; i10++) {
                            uuidArr[i10] = UUID.fromString(split[i10]);
                        }
                        r32 = e2.l.f10987b;
                        str3 = null;
                        r42 = r2.l.b(r32, uuidArr, null);
                        break;
                    } else {
                        r32 = null;
                        str2 = r32;
                        str3 = str2;
                        r42 = str2;
                        break;
                    }
                    break;
            }
            do {
                xmlPullParser.next();
                if (!r0.f(xmlPullParser, "clearkey:Laurl") && xmlPullParser.next() == 4) {
                    str3 = xmlPullParser.getText();
                    r42 = r42;
                } else if (!r0.f(xmlPullParser, "ms:laurl")) {
                    str3 = xmlPullParser.getAttributeValue(null, "licenseUrl");
                    r42 = r42;
                } else if (r42 == 0 && r0.g(xmlPullParser, "pssh") && xmlPullParser.next() == 4) {
                    byte[] decode = Base64.decode(xmlPullParser.getText(), 0);
                    UUID f10 = r2.l.f(decode);
                    if (f10 == null) {
                        r.i("MpdParser", "Skipping malformed cenc:pssh data");
                        r32 = f10;
                        r42 = 0;
                    } else {
                        r42 = decode;
                        r32 = f10;
                    }
                } else {
                    if (r42 == 0) {
                        ?? r62 = e2.l.f10990e;
                        if (r62.equals(r32) && r0.f(xmlPullParser, "mspr:pro") && xmlPullParser.next() == 4) {
                            r42 = r2.l.a(r62, Base64.decode(xmlPullParser.getText(), 0));
                        }
                    }
                    w(xmlPullParser);
                    r42 = r42;
                }
            } while (!r0.d(xmlPullParser, "ContentProtection"));
            return Pair.create(str, r32 != null ? new m.b(r32, str3, "video/mp4", r42) : null);
        }
        str = null;
        r32 = null;
        str2 = r32;
        str3 = str2;
        r42 = str2;
        do {
            xmlPullParser.next();
            if (!r0.f(xmlPullParser, "clearkey:Laurl")) {
            }
            if (!r0.f(xmlPullParser, "ms:laurl")) {
            }
        } while (!r0.d(xmlPullParser, "ContentProtection"));
        return Pair.create(str, r32 != null ? new m.b(r32, str3, "video/mp4", r42) : null);
    }

    protected 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;
    }

    protected Pair<Long, y2.a> O(XmlPullParser xmlPullParser, String str, String str2, long j10, long j11, ByteArrayOutputStream byteArrayOutputStream) {
        long X = X(xmlPullParser, "id", 0L);
        long X2 = X(xmlPullParser, "duration", -9223372036854775807L);
        long X3 = X(xmlPullParser, "presentationTime", 0L);
        long N0 = q0.N0(X2, 1000L, j10);
        long N02 = q0.N0(X3 - j11, 1000000L, j10);
        String r02 = r0(xmlPullParser, "messageData", null);
        byte[] P = P(xmlPullParser, byteArrayOutputStream);
        Long valueOf = Long.valueOf(N02);
        if (r02 != null) {
            P = q0.l0(r02);
        }
        return Pair.create(valueOf, d(str, str2, X, N0, P));
    }

    protected byte[] P(XmlPullParser xmlPullParser, ByteArrayOutputStream byteArrayOutputStream) {
        byteArrayOutputStream.reset();
        XmlSerializer newSerializer = Xml.newSerializer();
        newSerializer.setOutput(byteArrayOutputStream, n5.e.f18540c.name());
        while (true) {
            xmlPullParser.nextToken();
            if (r0.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 i10 = 0; i10 < xmlPullParser.getAttributeCount(); i10++) {
                        newSerializer.attribute(xmlPullParser.getAttributeNamespace(i10), xmlPullParser.getAttributeName(i10), xmlPullParser.getAttributeValue(i10));
                    }
                    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;
            }
        }
    }

    protected f Q(XmlPullParser xmlPullParser) {
        ByteArrayOutputStream byteArrayOutputStream;
        long j10;
        ArrayList arrayList;
        String r02 = r0(xmlPullParser, "schemeIdUri", "");
        String r03 = r0(xmlPullParser, "value", "");
        long X = X(xmlPullParser, "timescale", 1L);
        long X2 = X(xmlPullParser, "presentationTimeOffset", 0L);
        ArrayList arrayList2 = new ArrayList();
        ByteArrayOutputStream byteArrayOutputStream2 = new ByteArrayOutputStream(512);
        while (true) {
            xmlPullParser.next();
            if (r0.f(xmlPullParser, "Event")) {
                byteArrayOutputStream = byteArrayOutputStream2;
                long j11 = X2;
                j10 = X2;
                arrayList = arrayList2;
                arrayList.add(O(xmlPullParser, r02, r03, X, j11, byteArrayOutputStream));
            } else {
                byteArrayOutputStream = byteArrayOutputStream2;
                j10 = X2;
                arrayList = arrayList2;
                w(xmlPullParser);
            }
            if (r0.d(xmlPullParser, "EventStream")) {
                break;
            }
            arrayList2 = arrayList;
            byteArrayOutputStream2 = byteArrayOutputStream;
            X2 = j10;
        }
        long[] jArr = new long[arrayList.size()];
        y2.a[] aVarArr = new y2.a[arrayList.size()];
        for (int i10 = 0; i10 < arrayList.size(); i10++) {
            Pair pair = (Pair) arrayList.get(i10);
            jArr[i10] = ((Long) pair.first).longValue();
            aVarArr[i10] = (y2.a) pair.second;
        }
        return e(r02, r03, X, jArr, aVarArr);
    }

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

    protected String V(XmlPullParser xmlPullParser) {
        return s0(xmlPullParser, "Label");
    }

    protected c Y(XmlPullParser xmlPullParser, Uri uri) {
        long j10;
        ArrayList arrayList;
        ArrayList arrayList2;
        long j11;
        Throwable th;
        ArrayList arrayList3;
        long j12;
        boolean z10;
        long j13;
        d dVar = this;
        boolean v10 = dVar.v(dVar.b0(xmlPullParser, "profiles", new String[0]));
        long j14 = -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 j15 = equals ? 0L : -9223372036854775807L;
        ArrayList j16 = e0.j(new b(uri.toString(), uri.toString(), v10 ? 1 : Integer.MIN_VALUE, 1));
        ArrayList arrayList4 = new ArrayList();
        ArrayList arrayList5 = new ArrayList();
        long j17 = equals ? -9223372036854775807L : 0L;
        h hVar = null;
        o oVar = null;
        Uri uri2 = null;
        l lVar = null;
        boolean z11 = false;
        boolean z12 = false;
        while (true) {
            xmlPullParser.next();
            if (r0.f(xmlPullParser, "BaseURL")) {
                if (!z11) {
                    j15 = dVar.B(xmlPullParser, j15);
                    z11 = true;
                }
                arrayList5.addAll(dVar.C(xmlPullParser, j16, v10));
            } else if (r0.f(xmlPullParser, "ProgramInformation")) {
                hVar = c0(xmlPullParser);
            } else if (r0.f(xmlPullParser, "UTCTiming")) {
                oVar = w0(xmlPullParser);
            } else if (r0.f(xmlPullParser, "Location")) {
                uri2 = n0.e(uri.toString(), xmlPullParser.nextText());
            } else if (r0.f(xmlPullParser, "ServiceDescription")) {
                lVar = q0(xmlPullParser);
            } else {
                if (!r0.f(xmlPullParser, "Period") || z12) {
                    j10 = j15;
                    arrayList = arrayList5;
                    arrayList2 = j16;
                    j11 = j14;
                    th = th2;
                    arrayList3 = arrayList4;
                    w(xmlPullParser);
                } else {
                    j10 = j15;
                    ArrayList arrayList6 = arrayList4;
                    arrayList = arrayList5;
                    arrayList2 = j16;
                    j11 = j14;
                    th = th2;
                    Pair<g, Long> a02 = a0(xmlPullParser, !arrayList5.isEmpty() ? arrayList5 : j16, j17, j10, H, M4, v10);
                    g gVar = (g) a02.first;
                    if (gVar.f16921b != j11) {
                        long longValue = ((Long) a02.second).longValue();
                        if (longValue == j11) {
                            arrayList3 = arrayList6;
                            j12 = j11;
                        } else {
                            j12 = gVar.f16921b + longValue;
                            arrayList3 = arrayList6;
                        }
                        arrayList3.add(gVar);
                        j17 = j12;
                        z10 = z12;
                    } else {
                        if (!equals) {
                            throw x2.c("Unable to determine start of period " + arrayList6.size(), th);
                        }
                        arrayList3 = arrayList6;
                        z10 = true;
                    }
                    z12 = z10;
                }
                j15 = j10;
                if (r0.d(xmlPullParser, "MPD")) {
                    arrayList4 = arrayList3;
                    th2 = th;
                    arrayList5 = arrayList;
                    j16 = arrayList2;
                    j14 = j11;
                    dVar = this;
                } else {
                    if (M == j11) {
                        if (j17 != j11) {
                            j13 = j17;
                            if (arrayList3.isEmpty()) {
                                return g(H, j13, M2, equals, M3, M4, M5, H2, hVar, oVar, lVar, uri2, arrayList3);
                            }
                            throw x2.c("No periods found.", th);
                        }
                        if (!equals) {
                            throw x2.c("Unable to determine duration of static manifest.", th);
                        }
                    }
                    j13 = M;
                    if (arrayList3.isEmpty()) {
                    }
                }
            }
            arrayList = arrayList5;
            arrayList2 = j16;
            j11 = j14;
            th = th2;
            arrayList3 = arrayList4;
            if (r0.d(xmlPullParser, "MPD")) {
            }
        }
    }

    protected Pair<g, Long> a0(XmlPullParser xmlPullParser, List<b> list, long j10, long j11, long j12, long j13, boolean z10) {
        long j14;
        ArrayList arrayList;
        ArrayList arrayList2;
        ArrayList arrayList3;
        Object obj;
        long j15;
        k l02;
        d dVar = this;
        XmlPullParser xmlPullParser2 = xmlPullParser;
        Object obj2 = null;
        String attributeValue = xmlPullParser2.getAttributeValue(null, "id");
        long M = M(xmlPullParser2, "start", j10);
        long j16 = -9223372036854775807L;
        long j17 = j12 != -9223372036854775807L ? j12 + M : -9223372036854775807L;
        long M2 = M(xmlPullParser2, "duration", -9223372036854775807L);
        ArrayList arrayList4 = new ArrayList();
        ArrayList arrayList5 = new ArrayList();
        ArrayList arrayList6 = new ArrayList();
        long j18 = j11;
        long j19 = -9223372036854775807L;
        k kVar = null;
        e eVar = null;
        boolean z11 = false;
        while (true) {
            xmlPullParser.next();
            if (r0.f(xmlPullParser2, "BaseURL")) {
                if (!z11) {
                    j18 = dVar.B(xmlPullParser2, j18);
                    z11 = true;
                }
                arrayList6.addAll(dVar.C(xmlPullParser2, list, z10));
                arrayList3 = arrayList5;
                arrayList = arrayList6;
                j15 = j16;
                obj = obj2;
                arrayList2 = arrayList4;
            } else {
                if (r0.f(xmlPullParser2, "AdaptationSet")) {
                    j14 = j18;
                    arrayList = arrayList6;
                    arrayList2 = arrayList4;
                    arrayList2.add(y(xmlPullParser, !arrayList6.isEmpty() ? arrayList6 : list, kVar, M2, j18, j19, j17, j13, z10));
                    xmlPullParser2 = xmlPullParser;
                    arrayList3 = arrayList5;
                } else {
                    j14 = j18;
                    ArrayList arrayList7 = arrayList5;
                    arrayList = arrayList6;
                    arrayList2 = arrayList4;
                    xmlPullParser2 = xmlPullParser;
                    if (r0.f(xmlPullParser2, "EventStream")) {
                        arrayList7.add(Q(xmlPullParser));
                        arrayList3 = arrayList7;
                    } else {
                        arrayList3 = arrayList7;
                        if (r0.f(xmlPullParser2, "SegmentBase")) {
                            kVar = j0(xmlPullParser2, null);
                            obj = null;
                            j18 = j14;
                            j15 = -9223372036854775807L;
                        } else {
                            if (r0.f(xmlPullParser2, "SegmentList")) {
                                long B = B(xmlPullParser2, -9223372036854775807L);
                                obj = null;
                                l02 = k0(xmlPullParser, null, j17, M2, j14, B, j13);
                                j19 = B;
                                j18 = j14;
                                j15 = -9223372036854775807L;
                            } else {
                                obj = null;
                                if (r0.f(xmlPullParser2, "SegmentTemplate")) {
                                    long B2 = B(xmlPullParser2, -9223372036854775807L);
                                    j15 = -9223372036854775807L;
                                    l02 = l0(xmlPullParser, null, u.v(), j17, M2, j14, B2, j13);
                                    j19 = B2;
                                    j18 = j14;
                                } else {
                                    j15 = -9223372036854775807L;
                                    if (r0.f(xmlPullParser2, "AssetIdentifier")) {
                                        eVar = I(xmlPullParser2, "AssetIdentifier");
                                    } else {
                                        w(xmlPullParser);
                                    }
                                    j18 = j14;
                                }
                            }
                            kVar = l02;
                        }
                    }
                }
                obj = null;
                j15 = -9223372036854775807L;
                j18 = j14;
            }
            if (r0.d(xmlPullParser2, "Period")) {
                return Pair.create(h(attributeValue, M, arrayList2, arrayList3, eVar), Long.valueOf(M2));
            }
            arrayList4 = arrayList2;
            arrayList6 = arrayList;
            obj2 = obj;
            arrayList5 = arrayList3;
            j16 = j15;
            dVar = this;
        }
    }

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

    protected k3.a c(int i10, int i11, List<j> list, List<e> list2, List<e> list3, List<e> list4) {
        return new k3.a(i10, i11, list, list2, list3, list4);
    }

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

    protected y2.a d(String str, String str2, long j10, long j11, byte[] bArr) {
        return new y2.a(str, str2, j11, j10, bArr);
    }

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

    protected f e(String str, String str2, long j10, long[] jArr, y2.a[] aVarArr) {
        return new f(str, str2, j10, jArr, aVarArr);
    }

    protected a e0(XmlPullParser xmlPullParser, List<b> list, String str, String str2, int i10, int i11, float f10, int i12, int i13, String str3, List<e> list2, List<e> list3, List<e> list4, List<e> list5, k kVar, long j10, long j11, long j12, long j13, long j14, boolean z10) {
        long j15;
        ArrayList arrayList;
        ArrayList arrayList2;
        ArrayList arrayList3;
        ArrayList arrayList4;
        ArrayList arrayList5;
        ArrayList arrayList6;
        int i14;
        long B;
        ArrayList arrayList7;
        k kVar2;
        ArrayList arrayList8;
        ArrayList arrayList9;
        ArrayList arrayList10;
        ArrayList arrayList11;
        d dVar = this;
        String attributeValue = xmlPullParser.getAttributeValue(null, "id");
        int U = U(xmlPullParser, "bandwidth", -1);
        String r02 = r0(xmlPullParser, "mimeType", str);
        String r03 = r0(xmlPullParser, "codecs", str2);
        int U2 = U(xmlPullParser, "width", i10);
        int U3 = U(xmlPullParser, "height", i11);
        float S = S(xmlPullParser, f10);
        int U4 = U(xmlPullParser, "audioSamplingRate", i13);
        ArrayList arrayList12 = new ArrayList();
        ArrayList arrayList13 = new ArrayList();
        ArrayList arrayList14 = new ArrayList(list4);
        ArrayList arrayList15 = new ArrayList(list5);
        ArrayList arrayList16 = new ArrayList();
        int i15 = i12;
        long j16 = j12;
        long j17 = j13;
        String str4 = null;
        boolean z11 = false;
        k kVar3 = kVar;
        while (true) {
            xmlPullParser.next();
            if (r0.f(xmlPullParser, "BaseURL")) {
                if (!z11) {
                    j16 = dVar.B(xmlPullParser, j16);
                    z11 = true;
                }
                arrayList16.addAll(dVar.C(xmlPullParser, list, z10));
            } else if (r0.f(xmlPullParser, "AudioChannelConfiguration")) {
                kVar2 = kVar3;
                arrayList10 = arrayList16;
                arrayList4 = arrayList12;
                i14 = A(xmlPullParser);
                arrayList5 = arrayList13;
                arrayList6 = arrayList15;
                arrayList11 = arrayList10;
                if (r0.d(xmlPullParser, "Representation")) {
                    break;
                }
                arrayList15 = arrayList6;
                arrayList13 = arrayList5;
                arrayList12 = arrayList4;
                kVar3 = kVar2;
                dVar = this;
                i15 = i14;
                arrayList16 = arrayList11;
            } else if (r0.f(xmlPullParser, "SegmentBase")) {
                kVar3 = dVar.j0(xmlPullParser, (k.e) kVar3);
            } else {
                if (r0.f(xmlPullParser, "SegmentList")) {
                    B = dVar.B(xmlPullParser, j17);
                    j15 = j16;
                    arrayList9 = arrayList16;
                    arrayList = arrayList15;
                    arrayList2 = arrayList13;
                    arrayList3 = arrayList14;
                    kVar3 = k0(xmlPullParser, (k.b) kVar3, j10, j11, j15, B, j14);
                    arrayList4 = arrayList12;
                } else {
                    j15 = j16;
                    ArrayList arrayList17 = arrayList16;
                    arrayList = arrayList15;
                    arrayList2 = arrayList13;
                    arrayList3 = arrayList14;
                    if (r0.f(xmlPullParser, "SegmentTemplate")) {
                        B = dVar.B(xmlPullParser, j17);
                        arrayList4 = arrayList12;
                        kVar3 = l0(xmlPullParser, (k.c) kVar3, list5, j10, j11, j15, B, j14);
                        arrayList9 = arrayList17;
                    } else {
                        arrayList4 = arrayList12;
                        if (r0.f(xmlPullParser, "ContentProtection")) {
                            Pair<String, m.b> F = F(xmlPullParser);
                            Object obj = F.first;
                            if (obj != null) {
                                str4 = (String) obj;
                            }
                            Object obj2 = F.second;
                            if (obj2 != null) {
                                arrayList4.add((m.b) obj2);
                            }
                            i14 = i15;
                            arrayList8 = arrayList17;
                            j16 = j15;
                            arrayList6 = arrayList;
                            arrayList5 = arrayList2;
                            arrayList14 = arrayList3;
                            arrayList7 = arrayList8;
                            kVar2 = kVar3;
                            arrayList11 = arrayList7;
                            if (r0.d(xmlPullParser, "Representation")) {
                            }
                        } else {
                            if (r0.f(xmlPullParser, "InbandEventStream")) {
                                arrayList5 = arrayList2;
                                arrayList5.add(I(xmlPullParser, "InbandEventStream"));
                                arrayList6 = arrayList;
                                arrayList14 = arrayList3;
                            } else {
                                arrayList5 = arrayList2;
                                if (r0.f(xmlPullParser, "EssentialProperty")) {
                                    arrayList14 = arrayList3;
                                    arrayList14.add(I(xmlPullParser, "EssentialProperty"));
                                    arrayList6 = arrayList;
                                } else {
                                    arrayList14 = arrayList3;
                                    if (r0.f(xmlPullParser, "SupplementalProperty")) {
                                        arrayList6 = arrayList;
                                        arrayList6.add(I(xmlPullParser, "SupplementalProperty"));
                                    } else {
                                        arrayList6 = arrayList;
                                        w(xmlPullParser);
                                    }
                                }
                            }
                            i14 = i15;
                            j16 = j15;
                            arrayList7 = arrayList17;
                            kVar2 = kVar3;
                            arrayList11 = arrayList7;
                            if (r0.d(xmlPullParser, "Representation")) {
                            }
                        }
                    }
                }
                i14 = i15;
                j17 = B;
                arrayList8 = arrayList9;
                j16 = j15;
                arrayList6 = arrayList;
                arrayList5 = arrayList2;
                arrayList14 = arrayList3;
                arrayList7 = arrayList8;
                kVar2 = kVar3;
                arrayList11 = arrayList7;
                if (r0.d(xmlPullParser, "Representation")) {
                }
            }
            arrayList10 = arrayList16;
            arrayList4 = arrayList12;
            i14 = i15;
            kVar2 = kVar3;
            arrayList5 = arrayList13;
            arrayList6 = arrayList15;
            arrayList11 = arrayList10;
            if (r0.d(xmlPullParser, "Representation")) {
            }
        }
        ArrayList arrayList18 = arrayList6;
        ArrayList arrayList19 = arrayList14;
        ArrayList arrayList20 = arrayList5;
        q1 f11 = f(attributeValue, r02, U2, U3, S, i14, U4, U, str3, list2, list3, r03, arrayList19, arrayList18);
        if (kVar2 == null) {
            kVar2 = new k.e();
        }
        boolean isEmpty = arrayList11.isEmpty();
        List<b> list6 = arrayList11;
        if (isEmpty) {
            list6 = list;
        }
        return new a(f11, list6, kVar2, str4, arrayList4, arrayList20, arrayList19, arrayList18, -1L);
    }

    protected q1 f(String str, String str2, int i10, int i11, float f10, int i12, int i13, int i14, String str3, List<e> list, List<e> list2, String str4, List<e> list3, List<e> list4) {
        String str5 = str4;
        String u10 = u(str2, str5);
        if ("audio/eac3".equals(u10)) {
            u10 = N(list4);
            if ("audio/eac3-joc".equals(u10)) {
                str5 = "ec+3";
            }
        }
        int p02 = p0(list);
        int i02 = i0(list) | f0(list2) | h0(list3) | h0(list4);
        Pair<Integer, Integer> t02 = t0(list3);
        q1.b X = new q1.b().U(str).M(str2).g0(u10).K(str5).b0(i14).i0(p02).e0(i02).X(str3);
        int i15 = -1;
        q1.b m02 = X.l0(t02 != null ? ((Integer) t02.first).intValue() : -1).m0(t02 != null ? ((Integer) t02.second).intValue() : -1);
        if (v.s(u10)) {
            m02.n0(i10).S(i11).R(f10);
        } else if (v.o(u10)) {
            m02.J(i12).h0(i13);
        } else if (v.r(u10)) {
            if ("application/cea-608".equals(u10)) {
                i15 = D(list2);
            } else if ("application/cea-708".equals(u10)) {
                i15 = E(list2);
            }
            m02.H(i15);
        } else if (v.p(u10)) {
            m02.n0(i10).S(i11);
        }
        return m02.G();
    }

    protected int f0(List<e> list) {
        int u02;
        int i10 = 0;
        for (int i11 = 0; i11 < list.size(); i11++) {
            e eVar = list.get(i11);
            if (n5.c.a("urn:mpeg:dash:role:2011", eVar.f16912a)) {
                u02 = g0(eVar.f16913b);
            } else if (n5.c.a("urn:tva:metadata:cs:AudioPurposeCS:2007", eVar.f16912a)) {
                u02 = u0(eVar.f16913b);
            }
            i10 |= u02;
        }
        return i10;
    }

    protected c g(long j10, long j11, long j12, boolean z10, long j13, long j14, long j15, long j16, h hVar, o oVar, l lVar, Uri uri, List<g> list) {
        return new c(j10, j11, j12, z10, j13, j14, j15, j16, hVar, oVar, lVar, uri, list);
    }

    protected int g0(String str) {
        if (str == null) {
            return 0;
        }
        char c10 = 65535;
        switch (str.hashCode()) {
            case -2060497896:
                if (str.equals("subtitle")) {
                    c10 = 0;
                    break;
                }
                break;
            case -1724546052:
                if (str.equals("description")) {
                    c10 = 1;
                    break;
                }
                break;
            case -1580883024:
                if (str.equals("enhanced-audio-intelligibility")) {
                    c10 = 2;
                    break;
                }
                break;
            case -1574842690:
                if (str.equals("forced_subtitle")) {
                    c10 = 3;
                    break;
                }
                break;
            case -1408024454:
                if (str.equals("alternate")) {
                    c10 = 4;
                    break;
                }
                break;
            case -1396432756:
                if (str.equals("forced-subtitle")) {
                    c10 = 5;
                    break;
                }
                break;
            case 99825:
                if (str.equals("dub")) {
                    c10 = 6;
                    break;
                }
                break;
            case 3343801:
                if (str.equals("main")) {
                    c10 = 7;
                    break;
                }
                break;
            case 3530173:
                if (str.equals("sign")) {
                    c10 = '\b';
                    break;
                }
                break;
            case 552573414:
                if (str.equals("caption")) {
                    c10 = '\t';
                    break;
                }
                break;
            case 899152809:
                if (str.equals("commentary")) {
                    c10 = '\n';
                    break;
                }
                break;
            case 1629013393:
                if (str.equals("emergency")) {
                    c10 = 11;
                    break;
                }
                break;
            case 1855372047:
                if (str.equals("supplementary")) {
                    c10 = '\f';
                    break;
                }
                break;
        }
        switch (c10) {
            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;
        }
    }

    protected g h(String str, long j10, List<k3.a> list, List<f> list2, e eVar) {
        return new g(str, j10, list, list2, eVar);
    }

    protected int h0(List<e> list) {
        int i10 = 0;
        for (int i11 = 0; i11 < list.size(); i11++) {
            if (n5.c.a("http://dashif.org/guidelines/trickmode", list.get(i11).f16912a)) {
                i10 |= 16384;
            }
        }
        return i10;
    }

    protected i i(String str, long j10, long j11) {
        return new i(str, j10, j11);
    }

    protected int i0(List<e> list) {
        int i10 = 0;
        for (int i11 = 0; i11 < list.size(); i11++) {
            e eVar = list.get(i11);
            if (n5.c.a("urn:mpeg:dash:role:2011", eVar.f16912a)) {
                i10 |= g0(eVar.f16913b);
            }
        }
        return i10;
    }

    protected j j(a aVar, String str, String str2, ArrayList<m.b> arrayList, ArrayList<e> arrayList2) {
        q1.b b10 = aVar.f16903a.b();
        if (str != null) {
            b10.W(str);
        }
        String str3 = aVar.f16906d;
        if (str3 != null) {
            str2 = str3;
        }
        ArrayList<m.b> arrayList3 = aVar.f16907e;
        arrayList3.addAll(arrayList);
        if (!arrayList3.isEmpty()) {
            r(arrayList3);
            s(arrayList3);
            b10.O(new i2.m(str2, arrayList3));
        }
        ArrayList<e> arrayList4 = aVar.f16908f;
        arrayList4.addAll(arrayList2);
        return j.o(aVar.f16909g, b10.G(), aVar.f16904b, aVar.f16905c, arrayList4, aVar.f16910h, aVar.f16911i, null);
    }

    protected k.e j0(XmlPullParser xmlPullParser, k.e eVar) {
        long j10;
        long j11;
        long X = X(xmlPullParser, "timescale", eVar != null ? eVar.f16949b : 1L);
        long X2 = X(xmlPullParser, "presentationTimeOffset", eVar != null ? eVar.f16950c : 0L);
        long j12 = eVar != null ? eVar.f16963d : 0L;
        long j13 = eVar != null ? eVar.f16964e : 0L;
        String attributeValue = xmlPullParser.getAttributeValue(null, "indexRange");
        if (attributeValue != null) {
            String[] split = attributeValue.split("-");
            long parseLong = Long.parseLong(split[0]);
            j10 = (Long.parseLong(split[1]) - parseLong) + 1;
            j11 = parseLong;
        } else {
            j10 = j13;
            j11 = j12;
        }
        i iVar = eVar != null ? eVar.f16948a : null;
        do {
            xmlPullParser.next();
            if (r0.f(xmlPullParser, "Initialization")) {
                iVar = T(xmlPullParser);
            } else {
                w(xmlPullParser);
            }
        } while (!r0.d(xmlPullParser, "SegmentBase"));
        return n(iVar, X, X2, j11, j10);
    }

    protected k.b k(i iVar, long j10, long j11, long j12, long j13, List<k.d> list, long j14, List<i> list2, long j15, long j16) {
        return new k.b(iVar, j10, j11, j12, j13, list, j14, list2, q0.B0(j15), q0.B0(j16));
    }

    protected k.b k0(XmlPullParser xmlPullParser, k.b bVar, long j10, long j11, long j12, long j13, long j14) {
        long X = X(xmlPullParser, "timescale", bVar != null ? bVar.f16949b : 1L);
        long X2 = X(xmlPullParser, "presentationTimeOffset", bVar != null ? bVar.f16950c : 0L);
        long X3 = X(xmlPullParser, "duration", bVar != null ? bVar.f16952e : -9223372036854775807L);
        long X4 = X(xmlPullParser, "startNumber", bVar != null ? bVar.f16951d : 1L);
        long t10 = t(j12, j13);
        List<k.d> list = null;
        List<i> list2 = null;
        i iVar = null;
        do {
            xmlPullParser.next();
            if (r0.f(xmlPullParser, "Initialization")) {
                iVar = T(xmlPullParser);
            } else if (r0.f(xmlPullParser, "SegmentTimeline")) {
                list = m0(xmlPullParser, X, j11);
            } else if (r0.f(xmlPullParser, "SegmentURL")) {
                if (list2 == null) {
                    list2 = new ArrayList<>();
                }
                list2.add(n0(xmlPullParser));
            } else {
                w(xmlPullParser);
            }
        } while (!r0.d(xmlPullParser, "SegmentList"));
        if (bVar != null) {
            if (iVar == null) {
                iVar = bVar.f16948a;
            }
            if (list == null) {
                list = bVar.f16953f;
            }
            if (list2 == null) {
                list2 = bVar.f16957j;
            }
        }
        return k(iVar, X, X2, X4, X3, list, t10, list2, j14, j10);
    }

    protected k.c l(i iVar, long j10, long j11, long j12, long j13, long j14, List<k.d> list, long j15, n nVar, n nVar2, long j16, long j17) {
        return new k.c(iVar, j10, j11, j12, j13, j14, list, j15, nVar, nVar2, q0.B0(j16), q0.B0(j17));
    }

    protected k.c l0(XmlPullParser xmlPullParser, k.c cVar, List<e> list, long j10, long j11, long j12, long j13, long j14) {
        long X = X(xmlPullParser, "timescale", cVar != null ? cVar.f16949b : 1L);
        long X2 = X(xmlPullParser, "presentationTimeOffset", cVar != null ? cVar.f16950c : 0L);
        long X3 = X(xmlPullParser, "duration", cVar != null ? cVar.f16952e : -9223372036854775807L);
        long X4 = X(xmlPullParser, "startNumber", cVar != null ? cVar.f16951d : 1L);
        long W = W(list);
        long t10 = t(j12, j13);
        List<k.d> list2 = null;
        n v02 = v0(xmlPullParser, "media", cVar != null ? cVar.f16959k : null);
        n v03 = v0(xmlPullParser, "initialization", cVar != null ? cVar.f16958j : null);
        i iVar = null;
        do {
            xmlPullParser.next();
            if (r0.f(xmlPullParser, "Initialization")) {
                iVar = T(xmlPullParser);
            } else if (r0.f(xmlPullParser, "SegmentTimeline")) {
                list2 = m0(xmlPullParser, X, j11);
            } else {
                w(xmlPullParser);
            }
        } while (!r0.d(xmlPullParser, "SegmentTemplate"));
        if (cVar != null) {
            if (iVar == null) {
                iVar = cVar.f16948a;
            }
            if (list2 == null) {
                list2 = cVar.f16953f;
            }
        }
        return l(iVar, X, X2, X4, W, X3, list2, t10, v03, v02, j14, j10);
    }

    protected k.d m(long j10, long j11) {
        return new k.d(j10, j11);
    }

    protected List<k.d> m0(XmlPullParser xmlPullParser, long j10, long j11) {
        ArrayList arrayList = new ArrayList();
        long j12 = 0;
        long j13 = -9223372036854775807L;
        boolean z10 = false;
        int i10 = 0;
        do {
            xmlPullParser.next();
            if (r0.f(xmlPullParser, "S")) {
                long X = X(xmlPullParser, "t", -9223372036854775807L);
                if (z10) {
                    j12 = b(arrayList, j12, j13, i10, X);
                }
                if (X == -9223372036854775807L) {
                    X = j12;
                }
                j13 = X(xmlPullParser, "d", -9223372036854775807L);
                i10 = U(xmlPullParser, "r", 0);
                j12 = X;
                z10 = true;
            } else {
                w(xmlPullParser);
            }
        } while (!r0.d(xmlPullParser, "SegmentTimeline"));
        if (z10) {
            b(arrayList, j12, j13, i10, q0.N0(j11, j10, 1000L));
        }
        return arrayList;
    }

    protected k.e n(i iVar, long j10, long j11, long j12, long j13) {
        return new k.e(iVar, j10, j11, j12, j13);
    }

    protected i n0(XmlPullParser xmlPullParser) {
        return d0(xmlPullParser, "media", "mediaRange");
    }

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

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

    protected int p0(List<e> list) {
        int i10 = 0;
        for (int i11 = 0; i11 < list.size(); i11++) {
            e eVar = list.get(i11);
            if (n5.c.a("urn:mpeg:dash:role:2011", eVar.f16912a)) {
                i10 |= o0(eVar.f16913b);
            }
        }
        return i10;
    }

    protected l q0(XmlPullParser xmlPullParser) {
        long j10 = -9223372036854775807L;
        long j11 = -9223372036854775807L;
        long j12 = -9223372036854775807L;
        float f10 = -3.4028235E38f;
        float f11 = -3.4028235E38f;
        while (true) {
            xmlPullParser.next();
            if (r0.f(xmlPullParser, "Latency")) {
                j10 = X(xmlPullParser, "target", -9223372036854775807L);
                j11 = X(xmlPullParser, "min", -9223372036854775807L);
                j12 = X(xmlPullParser, "max", -9223372036854775807L);
            } else if (r0.f(xmlPullParser, "PlaybackRate")) {
                f10 = R(xmlPullParser, "min", -3.4028235E38f);
                f11 = R(xmlPullParser, "max", -3.4028235E38f);
            }
            long j13 = j10;
            long j14 = j11;
            long j15 = j12;
            float f12 = f10;
            float f13 = f11;
            if (r0.d(xmlPullParser, "ServiceDescription")) {
                return new l(j13, j14, j15, f12, f13);
            }
            j10 = j13;
            j11 = j14;
            j12 = j15;
            f10 = f12;
            f11 = f13;
        }
    }

    protected Pair<Integer, Integer> t0(List<e> list) {
        String str;
        for (int i10 = 0; i10 < list.size(); i10++) {
            e eVar = list.get(i10);
            if ((n5.c.a("http://dashif.org/thumbnail_tile", eVar.f16912a) || n5.c.a("http://dashif.org/guidelines/thumbnail_tile", eVar.f16912a)) && (str = eVar.f16913b) != null) {
                String[] Q0 = q0.Q0(str, "x");
                if (Q0.length == 2) {
                    try {
                        return Pair.create(Integer.valueOf(Integer.parseInt(Q0[0])), Integer.valueOf(Integer.parseInt(Q0[1])));
                    } catch (NumberFormatException unused) {
                        continue;
                    }
                }
            }
        }
        return null;
    }

    protected int u0(String str) {
        if (str == null) {
            return 0;
        }
        char c10 = 65535;
        switch (str.hashCode()) {
            case 49:
                if (str.equals("1")) {
                    c10 = 0;
                    break;
                }
                break;
            case 50:
                if (str.equals("2")) {
                    c10 = 1;
                    break;
                }
                break;
            case 51:
                if (str.equals("3")) {
                    c10 = 2;
                    break;
                }
                break;
            case 52:
                if (str.equals("4")) {
                    c10 = 3;
                    break;
                }
                break;
            case 54:
                if (str.equals("6")) {
                    c10 = 4;
                    break;
                }
                break;
        }
        switch (c10) {
            case 0:
                return 512;
            case 1:
                return 2048;
            case 2:
                return 4;
            case 3:
                return 8;
            case 4:
                return 1;
            default:
                return 0;
        }
    }

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

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

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

    protected k3.a y(XmlPullParser xmlPullParser, List<b> list, k kVar, long j10, long j11, long j12, long j13, long j14, boolean z10) {
        long j15;
        ArrayList<e> arrayList;
        Object obj;
        long j16;
        ArrayList arrayList2;
        ArrayList arrayList3;
        ArrayList arrayList4;
        ArrayList arrayList5;
        ArrayList arrayList6;
        ArrayList<m.b> arrayList7;
        String str;
        String str2;
        ArrayList arrayList8;
        int i10;
        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<m.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 kVar2 = kVar;
        int i11 = G;
        String str4 = attributeValue3;
        String str5 = attributeValue4;
        String str6 = null;
        int i12 = -1;
        boolean z11 = false;
        long j17 = j11;
        long j18 = j12;
        while (true) {
            xmlPullParser.next();
            if (r0.f(xmlPullParser2, "BaseURL")) {
                if (!z11) {
                    j17 = dVar.B(xmlPullParser2, j17);
                    z11 = true;
                }
                j15 = j18;
                arrayList = arrayList11;
                arrayList17.addAll(dVar.C(xmlPullParser2, list, z10));
            } else {
                j15 = j18;
                arrayList = arrayList11;
                if (r0.f(xmlPullParser2, "ContentProtection")) {
                    Pair<String, m.b> F = F(xmlPullParser);
                    Object obj2 = F.first;
                    if (obj2 != null) {
                        str6 = (String) obj2;
                    }
                    Object obj3 = F.second;
                    if (obj3 != null) {
                        arrayList10.add((m.b) obj3);
                    }
                } else {
                    if (r0.f(xmlPullParser2, "ContentComponent")) {
                        String q10 = q(str4, xmlPullParser2.getAttributeValue(null, str3));
                        int p10 = p(i11, G(xmlPullParser));
                        str2 = q10;
                        obj = null;
                        j16 = j17;
                        arrayList2 = arrayList17;
                        arrayList8 = arrayList16;
                        arrayList3 = arrayList15;
                        arrayList4 = arrayList14;
                        arrayList5 = arrayList13;
                        arrayList6 = arrayList12;
                        arrayList7 = arrayList10;
                        str = str3;
                        i10 = p10;
                        arrayList9 = arrayList;
                    } else {
                        int i13 = i11;
                        String str7 = str4;
                        if (r0.f(xmlPullParser2, "Role")) {
                            arrayList13.add(I(xmlPullParser2, "Role"));
                        } else if (r0.f(xmlPullParser2, "AudioChannelConfiguration")) {
                            i12 = A(xmlPullParser);
                        } else if (r0.f(xmlPullParser2, "Accessibility")) {
                            arrayList12.add(I(xmlPullParser2, "Accessibility"));
                        } else if (r0.f(xmlPullParser2, "EssentialProperty")) {
                            arrayList14.add(I(xmlPullParser2, "EssentialProperty"));
                        } else if (r0.f(xmlPullParser2, "SupplementalProperty")) {
                            arrayList15.add(I(xmlPullParser2, "SupplementalProperty"));
                        } else if (r0.f(xmlPullParser2, "Representation")) {
                            j16 = j17;
                            arrayList2 = arrayList17;
                            arrayList3 = arrayList15;
                            arrayList4 = arrayList14;
                            arrayList5 = arrayList13;
                            arrayList6 = arrayList12;
                            arrayList7 = arrayList10;
                            str = str3;
                            obj = null;
                            str2 = str7;
                            a e02 = e0(xmlPullParser, !arrayList17.isEmpty() ? arrayList17 : list, attributeValue, attributeValue2, U2, U3, S, i12, U4, str7, arrayList5, arrayList6, arrayList4, arrayList3, kVar2, j13, j10, j16, j15, j14, z10);
                            int p11 = p(i13, v.k(e02.f16903a.f11156r));
                            arrayList8 = arrayList16;
                            arrayList8.add(e02);
                            xmlPullParser2 = xmlPullParser;
                            i10 = p11;
                            arrayList9 = arrayList;
                        } else {
                            obj = null;
                            j16 = j17;
                            arrayList2 = arrayList17;
                            arrayList3 = arrayList15;
                            arrayList4 = arrayList14;
                            arrayList5 = arrayList13;
                            arrayList6 = arrayList12;
                            arrayList7 = arrayList10;
                            str = str3;
                            str2 = str7;
                            arrayList8 = arrayList16;
                            if (r0.f(xmlPullParser, "SegmentBase")) {
                                kVar2 = j0(xmlPullParser, (k.e) kVar2);
                                i10 = i13;
                                arrayList9 = arrayList;
                                j18 = j15;
                                xmlPullParser2 = xmlPullParser;
                            } else {
                                if (r0.f(xmlPullParser, "SegmentList")) {
                                    B = B(xmlPullParser, j15);
                                    i10 = i13;
                                    kVar2 = k0(xmlPullParser, (k.b) kVar2, j13, j10, j16, B, j14);
                                    xmlPullParser2 = xmlPullParser;
                                } else {
                                    j18 = j15;
                                    i10 = i13;
                                    if (r0.f(xmlPullParser, "SegmentTemplate")) {
                                        B = B(xmlPullParser, j18);
                                        xmlPullParser2 = xmlPullParser;
                                        kVar2 = l0(xmlPullParser, (k.c) kVar2, arrayList3, j13, j10, j16, B, j14);
                                    } else {
                                        xmlPullParser2 = xmlPullParser;
                                        if (r0.f(xmlPullParser2, "InbandEventStream")) {
                                            arrayList9 = arrayList;
                                            arrayList9.add(I(xmlPullParser2, "InbandEventStream"));
                                        } else {
                                            arrayList9 = arrayList;
                                            if (r0.f(xmlPullParser2, "Label")) {
                                                str5 = V(xmlPullParser);
                                            } else if (r0.e(xmlPullParser)) {
                                                z(xmlPullParser);
                                            }
                                        }
                                    }
                                }
                                j18 = B;
                                arrayList9 = arrayList;
                            }
                            if (!r0.d(xmlPullParser2, "AdaptationSet")) {
                                break;
                            }
                            arrayList11 = arrayList9;
                            arrayList16 = arrayList8;
                            arrayList17 = arrayList2;
                            arrayList15 = arrayList3;
                            j17 = j16;
                            arrayList14 = arrayList4;
                            arrayList13 = arrayList5;
                            arrayList12 = arrayList6;
                            arrayList10 = arrayList7;
                            str3 = str;
                            i11 = i10;
                            str4 = str2;
                            dVar = this;
                        }
                        obj = null;
                        j16 = j17;
                        arrayList2 = arrayList17;
                        arrayList3 = arrayList15;
                        arrayList4 = arrayList14;
                        arrayList5 = arrayList13;
                        arrayList6 = arrayList12;
                        arrayList7 = arrayList10;
                        str = str3;
                        i10 = i13;
                        str2 = str7;
                        arrayList9 = arrayList;
                        j18 = j15;
                        arrayList8 = arrayList16;
                        if (!r0.d(xmlPullParser2, "AdaptationSet")) {
                        }
                    }
                    j18 = j15;
                    if (!r0.d(xmlPullParser2, "AdaptationSet")) {
                    }
                }
            }
            j18 = j15;
            j16 = j17;
            arrayList8 = arrayList16;
            arrayList4 = arrayList14;
            arrayList5 = arrayList13;
            arrayList6 = arrayList12;
            arrayList7 = arrayList10;
            str = str3;
            arrayList9 = arrayList;
            i10 = i11;
            str2 = str4;
            obj = null;
            arrayList2 = arrayList17;
            arrayList3 = arrayList15;
            if (!r0.d(xmlPullParser2, "AdaptationSet")) {
            }
        }
        ArrayList arrayList18 = new ArrayList(arrayList8.size());
        for (int i14 = 0; i14 < arrayList8.size(); i14++) {
            arrayList18.add(j((a) arrayList8.get(i14), str5, str6, arrayList7, arrayList9));
        }
        return c(U, i10, arrayList18, arrayList6, arrayList4, arrayList3);
    }

    protected void z(XmlPullParser xmlPullParser) {
        w(xmlPullParser);
    }
}