package com.google.android.exoplayer2.source.smoothstreaming.manifest;

import android.net.Uri;
import android.text.TextUtils;
import android.util.Base64;
import android.util.Pair;
import com.google.android.exoplayer2.ParserException;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
import java.util.UUID;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
import org.xmlpull.v1.XmlPullParserFactory;
import p000.p001.p002.p003.p004.C0567;
import p138.p139.p143.p144.C2803;
import p138.p176.p177.p190.C3431;
import p138.p176.p177.p190.p194.C3526;
import p138.p176.p177.p190.p198.p204.C3631;
import p138.p176.p177.p190.p210.C3710;
import p138.p176.p177.p190.p217.p224.p225.C3942;
import p138.p176.p177.p190.p238.C4112;
import p138.p176.p177.p190.p239.C4121;
import p138.p176.p177.p190.p239.C4150;

/* JADX INFO: loaded from: classes.dex */
public class SsManifestParser implements C4112.InterfaceC4113<C3942> {

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public final XmlPullParserFactory f1857;

    public static class MissingFieldException extends ParserException {
        public MissingFieldException(String str) {
            super(C2803.m4879("Missing required field: ", str));
        }
    }

    /* JADX INFO: renamed from: com.google.android.exoplayer2.source.smoothstreaming.manifest.SsManifestParser$֏, reason: contains not printable characters */
    public static abstract class AbstractC0305 {

        /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
        public final String f1858;

        /* JADX INFO: renamed from: ؠ, reason: contains not printable characters */
        public final String f1859;

        /* JADX INFO: renamed from: ހ, reason: contains not printable characters */
        public final AbstractC0305 f1860;

        /* JADX INFO: renamed from: ށ, reason: contains not printable characters */
        public final List<Pair<String, Object>> f1861 = new LinkedList();

        public AbstractC0305(AbstractC0305 abstractC0305, String str, String str2) {
            this.f1860 = abstractC0305;
            this.f1858 = str;
            this.f1859 = str2;
        }

        /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
        public final int m1242(XmlPullParser xmlPullParser, String str) throws ParserException {
            String attributeValue = xmlPullParser.getAttributeValue(null, str);
            if (attributeValue == null) {
                throw new MissingFieldException(str);
            }
            try {
                return Integer.parseInt(attributeValue);
            } catch (NumberFormatException e) {
                throw new ParserException(e);
            }
        }

        /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
        public final int m1243(XmlPullParser xmlPullParser, String str, int i) throws ParserException {
            String attributeValue = xmlPullParser.getAttributeValue(null, str);
            if (attributeValue == null) {
                return i;
            }
            try {
                return Integer.parseInt(attributeValue);
            } catch (NumberFormatException e) {
                throw new ParserException(e);
            }
        }

        /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
        public final long m1244(XmlPullParser xmlPullParser, String str, long j) throws ParserException {
            String attributeValue = xmlPullParser.getAttributeValue(null, str);
            if (attributeValue == null) {
                return j;
            }
            try {
                return Long.parseLong(attributeValue);
            } catch (NumberFormatException e) {
                throw new ParserException(e);
            }
        }

        /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
        public abstract Object mo1245();

        /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
        public final Object m1246(String str) {
            for (int i = 0; i < this.f1861.size(); i++) {
                Pair<String, Object> pair = this.f1861.get(i);
                if (((String) pair.first).equals(str)) {
                    return pair.second;
                }
            }
            AbstractC0305 abstractC0305 = this.f1860;
            if (abstractC0305 == null) {
                return null;
            }
            return abstractC0305.m1246(str);
        }

        /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
        public final Object m1247(XmlPullParser xmlPullParser) throws XmlPullParserException, IOException {
            boolean z = false;
            int i = 0;
            while (true) {
                int eventType = xmlPullParser.getEventType();
                AbstractC0305 c0309 = null;
                if (eventType == 1) {
                    return null;
                }
                if (eventType == 2) {
                    String name = xmlPullParser.getName();
                    if (this.f1859.equals(name)) {
                        mo1252(xmlPullParser);
                        z = true;
                    } else if (z) {
                        if (i > 0) {
                            i++;
                        } else if (mo1251(name)) {
                            mo1252(xmlPullParser);
                        } else {
                            String str = this.f1858;
                            if ("QualityLevel".equals(name)) {
                                c0309 = new C0307(this, str);
                            } else if ("Protection".equals(name)) {
                                c0309 = new C0306(this, str);
                            } else if ("StreamIndex".equals(name)) {
                                c0309 = new C0309(this, str);
                            }
                            if (c0309 == null) {
                                i = 1;
                            } else {
                                mo1248(c0309.m1247(xmlPullParser));
                            }
                        }
                    }
                } else if (eventType != 3) {
                    if (eventType == 4 && z && i == 0) {
                        mo1253(xmlPullParser);
                    }
                } else if (!z) {
                    continue;
                } else if (i > 0) {
                    i--;
                } else {
                    String name2 = xmlPullParser.getName();
                    mo1250(xmlPullParser);
                    if (!mo1251(name2)) {
                        return mo1245();
                    }
                }
                xmlPullParser.next();
            }
        }

        /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
        public void mo1248(Object obj) {
        }

        /* JADX INFO: renamed from: ؠ, reason: contains not printable characters */
        public final String m1249(XmlPullParser xmlPullParser, String str) throws MissingFieldException {
            String attributeValue = xmlPullParser.getAttributeValue(null, str);
            if (attributeValue != null) {
                return attributeValue;
            }
            throw new MissingFieldException(str);
        }

        /* JADX INFO: renamed from: ؠ, reason: contains not printable characters */
        public void mo1250(XmlPullParser xmlPullParser) {
        }

        /* JADX INFO: renamed from: ؠ, reason: contains not printable characters */
        public boolean mo1251(String str) {
            return false;
        }

        /* JADX INFO: renamed from: ހ, reason: contains not printable characters */
        public abstract void mo1252(XmlPullParser xmlPullParser);

        /* JADX INFO: renamed from: ށ, reason: contains not printable characters */
        public void mo1253(XmlPullParser xmlPullParser) {
        }
    }

    /* JADX INFO: renamed from: com.google.android.exoplayer2.source.smoothstreaming.manifest.SsManifestParser$ؠ, reason: contains not printable characters */
    public static class C0306 extends AbstractC0305 {

        /* JADX INFO: renamed from: ނ, reason: contains not printable characters */
        public boolean f1862;

        /* JADX INFO: renamed from: ރ, reason: contains not printable characters */
        public UUID f1863;

        /* JADX INFO: renamed from: ބ, reason: contains not printable characters */
        public byte[] f1864;

        public C0306(AbstractC0305 abstractC0305, String str) {
            super(abstractC0305, str, "Protection");
        }

        /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
        public static void m1254(byte[] bArr, int i, int i2) {
            byte b = bArr[i];
            bArr[i] = bArr[i2];
            bArr[i2] = b;
        }

        @Override // com.google.android.exoplayer2.source.smoothstreaming.manifest.SsManifestParser.AbstractC0305
        /* JADX INFO: renamed from: ֏ */
        public Object mo1245() {
            UUID uuid = this.f1863;
            byte[] bArrM1904 = C0567.m1904(uuid, this.f1864);
            byte[] bArr = this.f1864;
            C3631[] c3631Arr = new C3631[1];
            StringBuilder sb = new StringBuilder();
            for (int i = 0; i < bArr.length; i += 2) {
                sb.append((char) bArr[i]);
            }
            String string = sb.toString();
            byte[] bArrDecode = Base64.decode(string.substring(string.indexOf("<KID>") + 5, string.indexOf("</KID>")), 0);
            m1254(bArrDecode, 0, 3);
            byte b = bArrDecode[1];
            bArrDecode[1] = bArrDecode[2];
            bArrDecode[2] = b;
            byte b2 = bArrDecode[4];
            bArrDecode[4] = bArrDecode[5];
            bArrDecode[5] = b2;
            byte b3 = bArrDecode[6];
            bArrDecode[6] = bArrDecode[7];
            bArrDecode[7] = b3;
            c3631Arr[0] = new C3631(true, null, 8, bArrDecode, 0, 0, null);
            return new C3942.C3943(uuid, bArrM1904, c3631Arr);
        }

        @Override // com.google.android.exoplayer2.source.smoothstreaming.manifest.SsManifestParser.AbstractC0305
        /* JADX INFO: renamed from: ؠ */
        public void mo1250(XmlPullParser xmlPullParser) {
            if ("ProtectionHeader".equals(xmlPullParser.getName())) {
                this.f1862 = false;
            }
        }

        @Override // com.google.android.exoplayer2.source.smoothstreaming.manifest.SsManifestParser.AbstractC0305
        /* JADX INFO: renamed from: ؠ */
        public boolean mo1251(String str) {
            return "ProtectionHeader".equals(str);
        }

        @Override // com.google.android.exoplayer2.source.smoothstreaming.manifest.SsManifestParser.AbstractC0305
        /* JADX INFO: renamed from: ހ */
        public void mo1252(XmlPullParser xmlPullParser) {
            if ("ProtectionHeader".equals(xmlPullParser.getName())) {
                this.f1862 = true;
                String attributeValue = xmlPullParser.getAttributeValue(null, "SystemID");
                if (attributeValue.charAt(0) == '{' && attributeValue.charAt(attributeValue.length() - 1) == '}') {
                    attributeValue = attributeValue.substring(1, attributeValue.length() - 1);
                }
                this.f1863 = UUID.fromString(attributeValue);
            }
        }

        @Override // com.google.android.exoplayer2.source.smoothstreaming.manifest.SsManifestParser.AbstractC0305
        /* JADX INFO: renamed from: ށ */
        public void mo1253(XmlPullParser xmlPullParser) {
            if (this.f1862) {
                this.f1864 = Base64.decode(xmlPullParser.getText(), 0);
            }
        }
    }

    /* JADX INFO: renamed from: com.google.android.exoplayer2.source.smoothstreaming.manifest.SsManifestParser$ހ, reason: contains not printable characters */
    public static class C0307 extends AbstractC0305 {

        /* JADX INFO: renamed from: ނ, reason: contains not printable characters */
        public C3431 f1865;

        public C0307(AbstractC0305 abstractC0305, String str) {
            super(abstractC0305, str, "QualityLevel");
        }

        /* JADX INFO: renamed from: ހ, reason: contains not printable characters */
        public static List<byte[]> m1255(String str) {
            byte[][] bArr;
            ArrayList arrayList = new ArrayList();
            if (!TextUtils.isEmpty(str)) {
                byte[] bArrM6773 = C4150.m6773(str);
                if (C4121.m6623(bArrM6773, 0)) {
                    ArrayList arrayList2 = new ArrayList();
                    int length = 0;
                    do {
                        arrayList2.add(Integer.valueOf(length));
                        byte[] bArr2 = C4121.f13168;
                        length += bArr2.length;
                        int length2 = bArrM6773.length - bArr2.length;
                        while (true) {
                            if (length > length2) {
                                length = -1;
                                break;
                            }
                            if (C4121.m6623(bArrM6773, length)) {
                                break;
                            }
                            length++;
                        }
                    } while (length != -1);
                    byte[][] bArr3 = new byte[arrayList2.size()][];
                    int i = 0;
                    while (i < arrayList2.size()) {
                        int iIntValue = ((Integer) arrayList2.get(i)).intValue();
                        int iIntValue2 = (i < arrayList2.size() + (-1) ? ((Integer) arrayList2.get(i + 1)).intValue() : bArrM6773.length) - iIntValue;
                        byte[] bArr4 = new byte[iIntValue2];
                        System.arraycopy(bArrM6773, iIntValue, bArr4, 0, iIntValue2);
                        bArr3[i] = bArr4;
                        i++;
                    }
                    bArr = bArr3;
                } else {
                    bArr = null;
                }
                if (bArr == null) {
                    arrayList.add(bArrM6773);
                } else {
                    Collections.addAll(arrayList, bArr);
                }
            }
            return arrayList;
        }

        @Override // com.google.android.exoplayer2.source.smoothstreaming.manifest.SsManifestParser.AbstractC0305
        /* JADX INFO: renamed from: ֏ */
        public Object mo1245() {
            return this.f1865;
        }

        /* JADX WARN: Removed duplicated region for block: B:59:0x00f0  */
        /* JADX WARN: Removed duplicated region for block: B:60:0x0117  */
        @Override // com.google.android.exoplayer2.source.smoothstreaming.manifest.SsManifestParser.AbstractC0305
        /* JADX INFO: renamed from: ހ */
        /*
            Code decompiled incorrectly, please refer to instructions dump.
        */
        public void mo1252(XmlPullParser xmlPullParser) throws ParserException {
            String str;
            String str2;
            int iIntValue = ((Integer) m1246("Type")).intValue();
            String attributeValue = xmlPullParser.getAttributeValue(null, "Index");
            String str3 = (String) m1246("Name");
            int iM1242 = m1242(xmlPullParser, "Bitrate");
            String strM1249 = m1249(xmlPullParser, "FourCC");
            if (!strM1249.equalsIgnoreCase("H264") && !strM1249.equalsIgnoreCase("X264") && !strM1249.equalsIgnoreCase("AVC1") && !strM1249.equalsIgnoreCase("DAVC")) {
                if (strM1249.equalsIgnoreCase("AAC") || strM1249.equalsIgnoreCase("AACL") || strM1249.equalsIgnoreCase("AACH") || strM1249.equalsIgnoreCase("AACP")) {
                    str2 = "audio/mp4a-latm";
                } else if (strM1249.equalsIgnoreCase("TTML") || strM1249.equalsIgnoreCase("DFXP")) {
                    str = "application/ttml+xml";
                } else if (strM1249.equalsIgnoreCase("ac-3") || strM1249.equalsIgnoreCase("dac3")) {
                    str = "audio/ac3";
                } else if (strM1249.equalsIgnoreCase("ec-3") || strM1249.equalsIgnoreCase("dec3")) {
                    str = "audio/eac3";
                } else if (strM1249.equalsIgnoreCase("dtsc")) {
                    str = "audio/vnd.dts";
                } else if (strM1249.equalsIgnoreCase("dtsh") || strM1249.equalsIgnoreCase("dtsl")) {
                    str = "audio/vnd.dts.hd";
                } else if (strM1249.equalsIgnoreCase("dtse")) {
                    str = "audio/vnd.dts.hd;profile=lbr";
                } else if (strM1249.equalsIgnoreCase("opus")) {
                    str = "audio/opus";
                } else {
                    str2 = null;
                }
                if (iIntValue != 2) {
                    this.f1865 = C3431.m5592(attributeValue, str3, "video/mp4", str2, (String) null, (C3710) null, iM1242, m1242(xmlPullParser, "MaxWidth"), m1242(xmlPullParser, "MaxHeight"), -1.0f, m1255(xmlPullParser.getAttributeValue(null, "CodecPrivateData")), 0, 0);
                    return;
                }
                byte b = -1;
                int i = 0;
                if (iIntValue != 1) {
                    if (iIntValue != 3) {
                        this.f1865 = C3431.m5590(attributeValue, str3, "application/mp4", str2, null, iM1242, 0, 0, null);
                        return;
                    }
                    String str4 = (String) m1246("Subtype");
                    int iHashCode = str4.hashCode();
                    if (iHashCode != 2061026) {
                        if (iHashCode == 2094737 && str4.equals("DESC")) {
                            b = 1;
                        }
                    } else if (str4.equals("CAPT")) {
                        b = 0;
                    }
                    this.f1865 = C3431.m5594(attributeValue, str3, "application/mp4", str2, null, iM1242, 0, b != 0 ? b != 1 ? 0 : 1024 : 64, (String) m1246("Language"));
                    return;
                }
                if (str2 == null) {
                    str2 = "audio/mp4a-latm";
                }
                int iM12422 = m1242(xmlPullParser, "Channels");
                int iM12423 = m1242(xmlPullParser, "SamplingRate");
                List<byte[]> listM1255 = m1255(xmlPullParser.getAttributeValue(null, "CodecPrivateData"));
                if (((ArrayList) listM1255).isEmpty() && "audio/mp4a-latm".equals(str2)) {
                    int i2 = 0;
                    int i3 = -1;
                    while (true) {
                        int[] iArr = C4121.f13169;
                        if (i2 >= iArr.length) {
                            break;
                        }
                        if (iM12423 == iArr[i2]) {
                            i3 = i2;
                        }
                        i2++;
                    }
                    int i4 = -1;
                    while (true) {
                        int[] iArr2 = C4121.f13170;
                        if (i >= iArr2.length) {
                            break;
                        }
                        if (iM12422 == iArr2[i]) {
                            i4 = i;
                        }
                        i++;
                    }
                    if (iM12423 == -1 || i4 == -1) {
                        throw new IllegalArgumentException(C2803.m4873("Invalid sample rate or number of channels: ", iM12423, ", ", iM12422));
                    }
                    listM1255 = Collections.singletonList(C4121.m6624(2, i3, i4));
                }
                this.f1865 = C3431.m5593(attributeValue, str3, "audio/mp4", str2, (String) null, (C3710) null, iM1242, iM12422, iM12423, listM1255, 0, 0, (String) m1246("Language"));
                return;
            }
            str = "video/avc";
            str2 = str;
            if (iIntValue != 2) {
            }
        }
    }

    /* JADX INFO: renamed from: com.google.android.exoplayer2.source.smoothstreaming.manifest.SsManifestParser$ށ, reason: contains not printable characters */
    public static class C0308 extends AbstractC0305 {

        /* JADX INFO: renamed from: ނ, reason: contains not printable characters */
        public final List<C3942.C3944> f1866;

        /* JADX INFO: renamed from: ރ, reason: contains not printable characters */
        public int f1867;

        /* JADX INFO: renamed from: ބ, reason: contains not printable characters */
        public int f1868;

        /* JADX INFO: renamed from: ޅ, reason: contains not printable characters */
        public long f1869;

        /* JADX INFO: renamed from: ކ, reason: contains not printable characters */
        public long f1870;

        /* JADX INFO: renamed from: އ, reason: contains not printable characters */
        public long f1871;

        /* JADX INFO: renamed from: ވ, reason: contains not printable characters */
        public int f1872;

        /* JADX INFO: renamed from: މ, reason: contains not printable characters */
        public boolean f1873;

        /* JADX INFO: renamed from: ފ, reason: contains not printable characters */
        public C3942.C3943 f1874;

        public C0308(AbstractC0305 abstractC0305, String str) {
            super(abstractC0305, str, "SmoothStreamingMedia");
            this.f1872 = -1;
            this.f1874 = null;
            this.f1866 = new LinkedList();
        }

        @Override // com.google.android.exoplayer2.source.smoothstreaming.manifest.SsManifestParser.AbstractC0305
        /* JADX INFO: renamed from: ֏ */
        public Object mo1245() {
            int size = this.f1866.size();
            C3942.C3944[] c3944Arr = new C3942.C3944[size];
            this.f1866.toArray(c3944Arr);
            if (this.f1874 != null) {
                C3942.C3943 c3943 = this.f1874;
                C3526 c3526 = new C3526(null, true, new C3526.C3528(c3943.f12348, null, "video/mp4", c3943.f12349));
                for (int i = 0; i < size; i++) {
                    C3942.C3944 c3944 = c3944Arr[i];
                    int i2 = c3944.f12351;
                    if (i2 == 2 || i2 == 1) {
                        C3431[] c3431Arr = c3944.f12360;
                        for (int i3 = 0; i3 < c3431Arr.length; i3++) {
                            C3431 c3431 = c3431Arr[i3];
                            c3431Arr[i3] = c3431.m5601(c3526, c3431.f10088);
                        }
                    }
                }
            }
            return new C3942(this.f1867, this.f1868, this.f1869, this.f1870, this.f1871, this.f1872, this.f1873, this.f1874, c3944Arr);
        }

        @Override // com.google.android.exoplayer2.source.smoothstreaming.manifest.SsManifestParser.AbstractC0305
        /* JADX INFO: renamed from: ֏ */
        public void mo1248(Object obj) {
            if (obj instanceof C3942.C3944) {
                this.f1866.add((C3942.C3944) obj);
            } else if (obj instanceof C3942.C3943) {
                C0567.m1932(this.f1874 == null);
                this.f1874 = (C3942.C3943) obj;
            }
        }

        @Override // com.google.android.exoplayer2.source.smoothstreaming.manifest.SsManifestParser.AbstractC0305
        /* JADX INFO: renamed from: ހ */
        public void mo1252(XmlPullParser xmlPullParser) throws ParserException {
            this.f1867 = m1242(xmlPullParser, "MajorVersion");
            this.f1868 = m1242(xmlPullParser, "MinorVersion");
            this.f1869 = m1244(xmlPullParser, "TimeScale", 10000000L);
            String attributeValue = xmlPullParser.getAttributeValue(null, "Duration");
            if (attributeValue == null) {
                throw new MissingFieldException("Duration");
            }
            try {
                this.f1870 = Long.parseLong(attributeValue);
                this.f1871 = m1244(xmlPullParser, "DVRWindowLength", 0L);
                this.f1872 = m1243(xmlPullParser, "LookaheadCount", -1);
                String attributeValue2 = xmlPullParser.getAttributeValue(null, "IsLive");
                this.f1873 = attributeValue2 != null ? Boolean.parseBoolean(attributeValue2) : false;
                this.f1861.add(Pair.create("TimeScale", Long.valueOf(this.f1869)));
            } catch (NumberFormatException e) {
                throw new ParserException(e);
            }
        }
    }

    /* JADX INFO: renamed from: com.google.android.exoplayer2.source.smoothstreaming.manifest.SsManifestParser$ނ, reason: contains not printable characters */
    public static class C0309 extends AbstractC0305 {

        /* JADX INFO: renamed from: ނ, reason: contains not printable characters */
        public final String f1875;

        /* JADX INFO: renamed from: ރ, reason: contains not printable characters */
        public final List<C3431> f1876;

        /* JADX INFO: renamed from: ބ, reason: contains not printable characters */
        public int f1877;

        /* JADX INFO: renamed from: ޅ, reason: contains not printable characters */
        public String f1878;

        /* JADX INFO: renamed from: ކ, reason: contains not printable characters */
        public long f1879;

        /* JADX INFO: renamed from: އ, reason: contains not printable characters */
        public String f1880;

        /* JADX INFO: renamed from: ވ, reason: contains not printable characters */
        public String f1881;

        /* JADX INFO: renamed from: މ, reason: contains not printable characters */
        public int f1882;

        /* JADX INFO: renamed from: ފ, reason: contains not printable characters */
        public int f1883;

        /* JADX INFO: renamed from: ދ, reason: contains not printable characters */
        public int f1884;

        /* JADX INFO: renamed from: ތ, reason: contains not printable characters */
        public int f1885;

        /* JADX INFO: renamed from: ލ, reason: contains not printable characters */
        public String f1886;

        /* JADX INFO: renamed from: ގ, reason: contains not printable characters */
        public ArrayList<Long> f1887;

        /* JADX INFO: renamed from: ޏ, reason: contains not printable characters */
        public long f1888;

        public C0309(AbstractC0305 abstractC0305, String str) {
            super(abstractC0305, str, "StreamIndex");
            this.f1875 = str;
            this.f1876 = new LinkedList();
        }

        @Override // com.google.android.exoplayer2.source.smoothstreaming.manifest.SsManifestParser.AbstractC0305
        /* JADX INFO: renamed from: ֏ */
        public Object mo1245() {
            C3431[] c3431Arr = new C3431[this.f1876.size()];
            this.f1876.toArray(c3431Arr);
            String str = this.f1875;
            String str2 = this.f1881;
            int i = this.f1877;
            String str3 = this.f1878;
            long j = this.f1879;
            String str4 = this.f1880;
            int i2 = this.f1882;
            int i3 = this.f1883;
            int i4 = this.f1884;
            int i5 = this.f1885;
            String str5 = this.f1886;
            ArrayList<Long> arrayList = this.f1887;
            return new C3942.C3944(str, str2, i, str3, j, str4, i2, i3, i4, i5, str5, c3431Arr, arrayList, C4150.m6775(arrayList, 1000000L, j), C4150.m6797(this.f1888, 1000000L, j));
        }

        @Override // com.google.android.exoplayer2.source.smoothstreaming.manifest.SsManifestParser.AbstractC0305
        /* JADX INFO: renamed from: ֏ */
        public void mo1248(Object obj) {
            if (obj instanceof C3431) {
                this.f1876.add((C3431) obj);
            }
        }

        @Override // com.google.android.exoplayer2.source.smoothstreaming.manifest.SsManifestParser.AbstractC0305
        /* JADX INFO: renamed from: ؠ */
        public boolean mo1251(String str) {
            return "c".equals(str);
        }

        @Override // com.google.android.exoplayer2.source.smoothstreaming.manifest.SsManifestParser.AbstractC0305
        /* JADX INFO: renamed from: ހ */
        public void mo1252(XmlPullParser xmlPullParser) throws ParserException {
            int i = 1;
            if (!"c".equals(xmlPullParser.getName())) {
                String attributeValue = xmlPullParser.getAttributeValue(null, "Type");
                if (attributeValue == null) {
                    throw new MissingFieldException("Type");
                }
                if (!"audio".equalsIgnoreCase(attributeValue)) {
                    if ("video".equalsIgnoreCase(attributeValue)) {
                        i = 2;
                    } else {
                        if (!"text".equalsIgnoreCase(attributeValue)) {
                            throw new ParserException(C2803.m4880("Invalid key value[", attributeValue, "]"));
                        }
                        i = 3;
                    }
                }
                this.f1877 = i;
                this.f1861.add(Pair.create("Type", Integer.valueOf(i)));
                if (this.f1877 == 3) {
                    this.f1878 = m1249(xmlPullParser, "Subtype");
                } else {
                    this.f1878 = xmlPullParser.getAttributeValue(null, "Subtype");
                }
                this.f1861.add(Pair.create("Subtype", this.f1878));
                this.f1880 = xmlPullParser.getAttributeValue(null, "Name");
                this.f1881 = m1249(xmlPullParser, "Url");
                this.f1882 = m1243(xmlPullParser, "MaxWidth", -1);
                this.f1883 = m1243(xmlPullParser, "MaxHeight", -1);
                this.f1884 = m1243(xmlPullParser, "DisplayWidth", -1);
                this.f1885 = m1243(xmlPullParser, "DisplayHeight", -1);
                String attributeValue2 = xmlPullParser.getAttributeValue(null, "Language");
                this.f1886 = attributeValue2;
                this.f1861.add(Pair.create("Language", attributeValue2));
                long jM1243 = m1243(xmlPullParser, "TimeScale", -1);
                this.f1879 = jM1243;
                if (jM1243 == -1) {
                    this.f1879 = ((Long) m1246("TimeScale")).longValue();
                }
                this.f1887 = new ArrayList<>();
                return;
            }
            int size = this.f1887.size();
            long jM1244 = m1244(xmlPullParser, "t", -9223372036854775807L);
            if (jM1244 == -9223372036854775807L) {
                if (size == 0) {
                    jM1244 = 0;
                } else {
                    if (this.f1888 == -1) {
                        throw new ParserException("Unable to infer start time");
                    }
                    jM1244 = this.f1888 + this.f1887.get(size - 1).longValue();
                }
            }
            this.f1887.add(Long.valueOf(jM1244));
            this.f1888 = m1244(xmlPullParser, "d", -9223372036854775807L);
            long jM12442 = m1244(xmlPullParser, "r", 1L);
            if (jM12442 > 1 && this.f1888 == -9223372036854775807L) {
                throw new ParserException("Repeated chunk with unspecified duration");
            }
            while (true) {
                long j = i;
                if (j >= jM12442) {
                    return;
                }
                this.f1887.add(Long.valueOf((this.f1888 * j) + jM1244));
                i++;
            }
        }
    }

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

    @Override // p138.p176.p177.p190.p238.C4112.InterfaceC4113
    /* JADX INFO: renamed from: ֏ */
    public C3942 mo1229(Uri uri, InputStream inputStream) throws ParserException {
        try {
            XmlPullParser xmlPullParserNewPullParser = this.f1857.newPullParser();
            xmlPullParserNewPullParser.setInput(inputStream, null);
            return (C3942) new C0308(null, uri.toString()).m1247(xmlPullParserNewPullParser);
        } catch (XmlPullParserException e) {
            throw new ParserException(e);
        }
    }
}
