package defpackage;

import android.net.Uri;
import android.text.TextUtils;
import j$.util.Objects;
import java.io.EOFException;
import java.io.IOException;
import java.io.InterruptedIOException;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.concurrent.TimeoutException;
import java.util.concurrent.atomic.AtomicInteger;

/* JADX INFO: renamed from: ᵚᵼᵛʽ, reason: contains not printable characters */
/* JADX INFO: loaded from: classes3.dex */
public final class C2755 extends AbstractC4352 {

    /* JADX INFO: renamed from: ᵗᵭ, reason: contains not printable characters */
    public static final AtomicInteger f10582 = new AtomicInteger();

    /* JADX INFO: renamed from: ʽᵡᵢᵾ, reason: contains not printable characters */
    public final C0085 f10583;

    /* JADX INFO: renamed from: ʿٴˇ, reason: contains not printable characters */
    public final int f10584;

    /* JADX INFO: renamed from: ʿᵿʽᵞ, reason: contains not printable characters */
    public C4818 f10585;

    /* JADX INFO: renamed from: ˀᵗ, reason: contains not printable characters */
    public final boolean f10586;

    /* JADX INFO: renamed from: ˀᵭ, reason: contains not printable characters */
    public final int f10587;

    /* JADX INFO: renamed from: ˁʢᵛ, reason: contains not printable characters */
    public final C4545 f10588;

    /* JADX INFO: renamed from: ˁˌᵩ, reason: contains not printable characters */
    public final boolean f10589;

    /* JADX INFO: renamed from: ˁᵺˈ, reason: contains not printable characters */
    public AbstractC4509 f10590;

    /* JADX INFO: renamed from: ˈⁱᵡ, reason: contains not printable characters */
    public final C0625 f10591;

    /* JADX INFO: renamed from: ˉˆᵗ, reason: contains not printable characters */
    public boolean f10592;

    /* JADX INFO: renamed from: ˉᵵᵜ, reason: contains not printable characters */
    public final Uri f10593;

    /* JADX INFO: renamed from: ˊˌˊ, reason: contains not printable characters */
    public final C3118 f10594;

    /* JADX INFO: renamed from: ˊᵡᵗʨ, reason: contains not printable characters */
    public final C0084 f10595;

    /* JADX INFO: renamed from: ˊᵾʽʼ, reason: contains not printable characters */
    public final InterfaceC1070 f10596;

    /* JADX INFO: renamed from: ˋʿᐧ, reason: contains not printable characters */
    public volatile boolean f10597;

    /* JADX INFO: renamed from: ˋᵯᵩ, reason: contains not printable characters */
    public boolean f10598;

    /* JADX INFO: renamed from: ˏᵩʨ, reason: contains not printable characters */
    public final boolean f10599;

    /* JADX INFO: renamed from: ːᵝٴᵶ, reason: contains not printable characters */
    public boolean f10600;

    /* JADX INFO: renamed from: ˑʢ, reason: contains not printable characters */
    public final boolean f10601;

    /* JADX INFO: renamed from: ᵛˀˊ, reason: contains not printable characters */
    public C5067 f10602;

    /* JADX INFO: renamed from: ᵛˑﹳ, reason: contains not printable characters */
    public final C5067 f10603;

    /* JADX INFO: renamed from: ᵜᵤ, reason: contains not printable characters */
    public long f10604;

    /* JADX INFO: renamed from: ᵞᵛᵘ, reason: contains not printable characters */
    public final C5576 f10605;

    /* JADX INFO: renamed from: ᵠˏˏ, reason: contains not printable characters */
    public final int f10606;

    /* JADX INFO: renamed from: ᵡᵶ, reason: contains not printable characters */
    public int f10607;

    /* JADX INFO: renamed from: ᵡᵶᵬʤ, reason: contains not printable characters */
    public boolean f10608;

    /* JADX INFO: renamed from: ᵨˈʼﹶ, reason: contains not printable characters */
    public final List f10609;

    /* JADX INFO: renamed from: ᵵᵬᵽ, reason: contains not printable characters */
    public final boolean f10610;

    public C2755(C0625 c0625, InterfaceC1070 interfaceC1070, C0084 c0084, C5286 c5286, boolean z, InterfaceC1070 interfaceC10702, C0084 c00842, boolean z2, Uri uri, List list, int i, Object obj, long j, long j2, long j3, int i2, boolean z3, int i3, boolean z4, boolean z5, C0085 c0085, C5576 c5576, C5067 c5067, C3118 c3118, C4545 c4545, boolean z6, boolean z7, C2136 c2136) {
        super(interfaceC1070, c0084, c5286, i, obj, j, j2, j3);
        this.f10586 = z;
        this.f10587 = i2;
        this.f10604 = z3 ? j2 - j : -9223372036854775807L;
        this.f10606 = i3;
        this.f10595 = c00842;
        this.f10596 = interfaceC10702;
        this.f10608 = c00842 != null;
        this.f10599 = z2;
        this.f10593 = uri;
        this.f10610 = z5;
        this.f10583 = c0085;
        this.f10601 = z4;
        this.f10591 = c0625;
        this.f10609 = list;
        this.f10605 = c5576;
        this.f10603 = c5067;
        this.f10594 = c3118;
        this.f10588 = c4545;
        this.f10600 = z6;
        this.f10589 = z7;
        C2822 c2822 = AbstractC4509.f17159;
        this.f10590 = C2598.f10048;
        this.f10584 = f10582.getAndIncrement();
    }

    /* JADX INFO: renamed from: ᵷᵺʾᵖ, reason: contains not printable characters */
    public static byte[] m6661(String str) {
        if (ᵻᵕᵭ.ʽᵡᵢᵾ(str).startsWith("0x")) {
            str = str.substring(2);
        }
        byte[] byteArray = new BigInteger(str, 16).toByteArray();
        byte[] bArr = new byte[16];
        int length = byteArray.length > 16 ? byteArray.length - 16 : 0;
        System.arraycopy(byteArray, length, bArr, (16 - byteArray.length) + length, byteArray.length - length);
        return bArr;
    }

    @Override // defpackage.AbstractC4352
    /* JADX INFO: renamed from: ʽˈˋ */
    public final boolean mo3272() {
        throw null;
    }

    /* JADX WARN: Multi-variable type inference failed */
    /* JADX WARN: Removed duplicated region for block: B:23:0x0084 A[PHI: r16 r36
      0x0084: PHI (r16v1 long) = (r16v0 long), (r16v3 long), (r16v3 long) binds: [B:40:0x00d6, B:22:0x0082, B:37:0x00bb] A[DONT_GENERATE, DONT_INLINE]
      0x0084: PHI (r36v2 ᵕᵾᵗᵸ) = (r36v1 ᵕᵾᵗᵸ), (r36v4 ᵕᵾᵗᵸ), (r36v4 ᵕᵾᵗᵸ) binds: [B:40:0x00d6, B:22:0x0082, B:37:0x00bb] A[DONT_GENERATE, DONT_INLINE]] */
    /* JADX WARN: Removed duplicated region for block: B:31:0x00af  */
    /* JADX WARN: Type inference failed for: r19v0 */
    /* JADX WARN: Type inference failed for: r19v1, types: [java.lang.Object, ᵯˊˑ] */
    /* JADX WARN: Type inference failed for: r19v2, types: [ᵯˊˑ] */
    /* JADX WARN: Type inference failed for: r19v3 */
    /* JADX WARN: Type inference failed for: r19v4 */
    /* JADX WARN: Type inference failed for: r19v6 */
    /* JADX WARN: Type inference failed for: r3v11 */
    /* JADX WARN: Type inference failed for: r3v12, types: [java.lang.String] */
    /* JADX WARN: Type inference failed for: r3v27 */
    /* JADX WARN: Type inference failed for: r4v10, types: [java.lang.Object, ᵯˊˑ] */
    /* JADX WARN: Type inference failed for: r4v26 */
    /* JADX WARN: Type inference failed for: r4v35 */
    /* JADX WARN: Type inference failed for: r4v40 */
    /* JADX WARN: Type inference failed for: r4v41 */
    /* JADX WARN: Type inference failed for: r4v42 */
    /* JADX WARN: Type inference failed for: r4v43 */
    /* JADX WARN: Type inference failed for: r4v44 */
    /* JADX INFO: renamed from: ˊᵫᵗ, reason: contains not printable characters */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final C2373 m6662(InterfaceC1070 interfaceC1070, C0084 c0084, boolean z) throws Throwable {
        int i;
        C2373 c2373;
        long j;
        long jM9601;
        long j2;
        C5067 c5067;
        C0085 c0085;
        ArrayList arrayList;
        ?? c0923;
        boolean zMo1255;
        InterfaceC1471 interfaceC1471;
        int i2;
        Object c4461;
        List listSingletonList;
        InterfaceC4291 c2724;
        InterfaceC2223 interfaceC2223;
        long jMo1308 = interfaceC1070.mo1308(c0084);
        long j3 = this.f7526;
        C0085 c00852 = this.f10583;
        if (z) {
            try {
                c00852.m1134(this.f10610, j3);
            } catch (InterruptedException unused) {
                throw new InterruptedIOException();
            } catch (TimeoutException e) {
                throw new IOException(e);
            }
        }
        C2373 c23732 = new C2373(interfaceC1070, c0084.f1290, jMo1308);
        if (this.f10602 == null) {
            C4545 c4545 = this.f10588;
            c23732.f9292 = 0;
            try {
                c4545.m9603(10);
                c23732.mo4708(c4545.f17284, 0, 10, false);
            } catch (EOFException unused2) {
                c2373 = null;
                j = -9223372036854775807L;
            }
            if (c4545.m9628() != 4801587) {
                c2373 = null;
                jM9601 = -9223372036854775807L;
                j = -9223372036854775807L;
            } else {
                c4545.m9609(3);
                int iM9620 = c4545.m9620();
                int i3 = iM9620 + 10;
                c2373 = null;
                byte[] bArr = c4545.f17284;
                j = -9223372036854775807L;
                if (i3 > bArr.length) {
                    c4545.m9603(i3);
                    System.arraycopy(bArr, 0, c4545.f17284, 0, 10);
                }
                c23732.mo4708(c4545.f17284, 10, iM9620, false);
                C1956 c1956M7227 = this.f10594.m7227(iM9620, c4545.f17284);
                if (c1956M7227 == null) {
                    jM9601 = j;
                } else {
                    InterfaceC2223[] interfaceC2223Arr = c1956M7227.f7784;
                    int length = interfaceC2223Arr.length;
                    int i4 = 0;
                    while (true) {
                        if (i4 >= length) {
                            interfaceC2223 = null;
                            break;
                        }
                        InterfaceC2223 interfaceC22232 = interfaceC2223Arr[i4];
                        if (C0077.class.isAssignableFrom(interfaceC22232.getClass())) {
                            interfaceC2223 = (InterfaceC2223) C0077.class.cast(interfaceC22232);
                            if (!((C0077) interfaceC2223).f1280.equals("com.apple.streaming.transportStreamTimestamp")) {
                                interfaceC2223 = null;
                            }
                            if (interfaceC2223 != null) {
                                break;
                            }
                            i4++;
                        }
                    }
                    C0077 c0077 = (C0077) interfaceC2223;
                    if (c0077 != null) {
                        System.arraycopy(c0077.f1281, 0, c4545.f17284, 0, 8);
                        c4545.m9624(0);
                        c4545.m9612(8);
                        jM9601 = c4545.m9601() & 8589934591L;
                    }
                }
            }
            c23732.f9292 = 0;
            C5067 c50672 = this.f10603;
            if (c50672 == null) {
                Uri uri = c0084.f1291;
                Map mapMo1306 = interfaceC1070.mo1306();
                C0625 c0625 = this.f10591;
                c0625.getClass();
                C5286 c5286 = this.f7531;
                int i5 = ᵘᵞʿⁱ.ᵔᵖᵹᵫ(c5286.f19987);
                List list = (List) mapMo1306.get("Content-Type");
                int i6 = ᵘᵞʿⁱ.ᵔᵖᵹᵫ((String) ((list == null || list.isEmpty()) ? c2373 : (String) list.get(0)));
                int i7 = ᵘᵞʿⁱ.ᵨᵼⁱ(uri);
                int[] iArr = C0625.f2965;
                ArrayList arrayList2 = new ArrayList(7);
                C0625.m2281(i5, arrayList2);
                C0625.m2281(i6, arrayList2);
                C0625.m2281(i7, arrayList2);
                int i8 = 0;
                for (int i9 = 7; i8 < i9; i9 = 7) {
                    C0625.m2281(iArr[i8], arrayList2);
                    i8++;
                }
                c23732.f9292 = 0;
                ?? r19 = c2373;
                int i10 = 0;
                while (true) {
                    int size = arrayList2.size();
                    C0085 c00853 = this.f10583;
                    if (i10 >= size) {
                        j2 = j3;
                        i = 0;
                        r19.getClass();
                        c5067 = new C5067(r19, c5286, c00853, (ᵱᵻᵧᵷ) c0625.f2970, c0625.f2969);
                        break;
                    }
                    int iIntValue = ((Integer) arrayList2.get(i10)).intValue();
                    int i11 = i10;
                    if (iIntValue == 0) {
                        c0085 = c00853;
                        j2 = j3;
                        arrayList = arrayList2;
                        c0923 = new C0923();
                    } else if (iIntValue == 1) {
                        c0085 = c00853;
                        j2 = j3;
                        arrayList = arrayList2;
                        c0923 = new C2388();
                    } else if (iIntValue == 2) {
                        c0085 = c00853;
                        j2 = j3;
                        arrayList = arrayList2;
                        c0923 = new C5204(0);
                    } else if (iIntValue != 7) {
                        List list2 = this.f10609;
                        InterfaceC1471 interfaceC14712 = InterfaceC1471.f5974;
                        if (iIntValue == 8) {
                            j2 = j3;
                            arrayList = arrayList2;
                            InterfaceC1471 interfaceC14713 = (ᵱᵻᵧᵷ) c0625.f2970;
                            boolean z2 = c0625.f2969;
                            int i12 = c0625.f2968;
                            if (z2) {
                                interfaceC1471 = interfaceC14713;
                                i2 = 4;
                            } else {
                                i2 = 36;
                                interfaceC1471 = interfaceC14712;
                            }
                            c0085 = c00853;
                            c4461 = new C4461(interfaceC1471, i2 | C4461.m9499(i12), c00853, null, list2 != null ? list2 : C2598.f10048, null);
                        } else if (iIntValue == 11) {
                            j2 = j3;
                            arrayList = arrayList2;
                            int i13 = c0625.f2967;
                            InterfaceC1471 interfaceC14714 = (ᵱᵻᵧᵷ) c0625.f2970;
                            boolean z3 = c0625.f2969;
                            int i14 = i13 | 16;
                            if (list2 != null) {
                                i14 = i13 | 48;
                                c0085 = c00853;
                                listSingletonList = list2;
                            } else {
                                C4753 c4753 = new C4753();
                                c0085 = c00853;
                                c4753.f18101 = AbstractC4208.m9132("application/cea-608");
                                listSingletonList = Collections.singletonList(new C5286(c4753));
                            }
                            String str = c5286.f19996;
                            if (!TextUtils.isEmpty(str)) {
                                if (AbstractC4208.m9130(str, "audio/mp4a-latm") == null) {
                                    i14 |= 2;
                                }
                                if (AbstractC4208.m9130(str, "video/avc") == null) {
                                    i14 |= 4;
                                }
                            }
                            c4461 = new C4018(2, !z3 ? 1 : 0, !z3 ? interfaceC14712 : interfaceC14714, c0085, new C1542(i14, listSingletonList), 112800);
                        } else if (iIntValue != 13) {
                            c0923 = c2373;
                            c0085 = c00853;
                            j2 = j3;
                            arrayList = arrayList2;
                        } else {
                            j2 = j3;
                            arrayList = arrayList2;
                            c0085 = c00853;
                            c0923 = new C3845(c5286.f19997, c00853, (ᵱᵻᵧᵷ) c0625.f2970, c0625.f2969);
                        }
                        c0923 = c4461;
                    } else {
                        c0085 = c00853;
                        j2 = j3;
                        arrayList = arrayList2;
                        c0923 = new C2724(0L);
                    }
                    c0923.getClass();
                    try {
                        zMo1255 = c0923.mo1255(c23732);
                        i = 0;
                        c23732.f9292 = 0;
                    } catch (EOFException unused3) {
                        i = 0;
                        c23732.f9292 = 0;
                        zMo1255 = false;
                    } catch (Throwable th) {
                        c23732.f9292 = 0;
                        throw th;
                    }
                    if (zMo1255) {
                        c5067 = new C5067(c0923, c5286, c0085, (ᵱᵻᵧᵷ) c0625.f2970, c0625.f2969);
                        break;
                    }
                    C5286 c52862 = c5286;
                    if (r19 == 0 && (iIntValue == i5 || iIntValue == i6 || iIntValue == i7 || iIntValue == 11)) {
                        r19 = c0923;
                    }
                    i10 = i11 + 1;
                    c5286 = c52862;
                    arrayList2 = arrayList;
                    j3 = j2;
                    r19 = r19;
                }
            } else {
                InterfaceC4291 interfaceC4291 = (InterfaceC4291) c50672.f19117;
                InterfaceC4291 interfaceC4291Mo1254 = interfaceC4291.mo1254();
                ᵻᵪ.ˌᴵ(!((interfaceC4291Mo1254 instanceof C4018) || (interfaceC4291Mo1254 instanceof C4461)));
                boolean z4 = interfaceC4291.mo1254() == interfaceC4291;
                Class<?> cls = interfaceC4291.getClass();
                if (!z4) {
                    ᵕᵩʽᵲ.ᵪᵹᵥᵻ(ᵱˉˈ.ᵸˆˁ("Can't recreate wrapped extractors. Outer type: %s", new Object[]{cls}));
                    return c2373;
                }
                if (interfaceC4291 instanceof C3845) {
                    c2724 = new C3845(((C5286) c50672.f19118).f19997, (C0085) c50672.f19121, (InterfaceC1471) c50672.f19119, c50672.f19120);
                } else if (interfaceC4291 instanceof C5204) {
                    c2724 = new C5204(0);
                } else if (interfaceC4291 instanceof C0923) {
                    c2724 = new C0923();
                } else if (interfaceC4291 instanceof C2388) {
                    c2724 = new C2388();
                } else {
                    if (!(interfaceC4291 instanceof C2724)) {
                        ᵕᵩʽᵲ.ᵪᵹᵥᵻ("Unexpected extractor type for recreation: ".concat(interfaceC4291.getClass().getSimpleName()));
                        return c2373;
                    }
                    c2724 = new C2724(0);
                }
                c5067 = new C5067(c2724, (C5286) c50672.f19118, (C0085) c50672.f19121, (InterfaceC1471) c50672.f19119, c50672.f19120);
                j2 = j3;
                i = 0;
            }
            C5067 c50673 = c5067;
            this.f10602 = c50673;
            InterfaceC4291 interfaceC4291Mo12542 = ((InterfaceC4291) c50673.f19117).mo1254();
            if ((interfaceC4291Mo12542 instanceof C5204) || (interfaceC4291Mo12542 instanceof C0923) || (interfaceC4291Mo12542 instanceof C2388) || (interfaceC4291Mo12542 instanceof C2724)) {
                C4818 c4818 = this.f10585;
                long jM1133 = jM9601 != j ? c00852.m1133(jM9601) : j2;
                if (c4818.f18368 != jM1133) {
                    c4818.f18368 = jM1133;
                    C3634[] c3634Arr = c4818.f18335;
                    int length2 = c3634Arr.length;
                    for (int i15 = i; i15 < length2; i15++) {
                        C3634 c3634 = c3634Arr[i15];
                        if (c3634.f3919 != jM1133) {
                            c3634.f3919 = jM1133;
                            c3634.f3917 = true;
                        }
                    }
                }
            } else {
                C4818 c48182 = this.f10585;
                if (c48182.f18368 != 0) {
                    c48182.f18368 = 0L;
                    C3634[] c3634Arr2 = c48182.f18335;
                    int length3 = c3634Arr2.length;
                    for (int i16 = i; i16 < length3; i16++) {
                        C3634 c36342 = c3634Arr2[i16];
                        if (c36342.f3919 != 0) {
                            c36342.f3919 = 0L;
                            c36342.f3917 = true;
                        }
                    }
                }
            }
            this.f10585.f18358.clear();
            ((InterfaceC4291) this.f10602.f19117).mo1257(this.f10585);
        } else {
            i = 0;
        }
        C4818 c48183 = this.f10585;
        C5576 c5576 = c48183.f18362;
        C5576 c55762 = this.f10605;
        if (!Objects.equals(c5576, c55762)) {
            c48183.f18362 = c55762;
            int i17 = i;
            while (true) {
                C3634[] c3634Arr3 = c48183.f18335;
                if (i17 >= c3634Arr3.length) {
                    break;
                }
                if (c48183.f18371[i17]) {
                    C3634 c36343 = c3634Arr3[i17];
                    c36343.f13802 = c55762;
                    c36343.f3917 = true;
                }
                i17++;
            }
        }
        return c23732;
    }

    /* JADX INFO: renamed from: ːˏᵟᵯ, reason: contains not printable characters */
    public final void m6663(InterfaceC1070 interfaceC1070, C0084 c0084, boolean z, boolean z2) {
        C0084 c0084M1131;
        boolean z3;
        long j;
        int i = this.f10607;
        if (z) {
            z3 = i != 0;
            c0084M1131 = c0084;
        } else {
            c0084M1131 = c0084.m1131(i);
            z3 = false;
        }
        try {
            C2373 c2373M6662 = m6662(interfaceC1070, c0084M1131, z2);
            if (z3) {
                c2373M6662.mo4711(this.f10607, false);
            }
            while (!this.f10597 && ((InterfaceC4291) this.f10602.f19117).mo1258(c2373M6662, C5067.f19116) == 0) {
                try {
                    try {
                    } catch (EOFException e) {
                        if ((this.f7531.f20000 & 16384) == 0) {
                            throw e;
                        }
                        ((InterfaceC4291) this.f10602.f19117).mo1252(0L, 0L);
                        j = c2373M6662.f9290;
                    }
                } catch (Throwable th) {
                    this.f10607 = (int) (c2373M6662.f9290 - c0084.f1290);
                    throw th;
                }
            }
            j = c2373M6662.f9290;
            this.f10607 = (int) (j - c0084.f1290);
        } finally {
            ˑᵕʾ.ᵷᵺʾᵖ(interfaceC1070);
        }
    }

    /* JADX INFO: renamed from: ᵨᵣ, reason: contains not printable characters */
    public final int m6664(int i) {
        ᵻᵪ.ˌᴵ(!this.f10600);
        if (i >= this.f10590.size()) {
            return 0;
        }
        return ((Integer) this.f10590.get(i)).intValue();
    }

    @Override // defpackage.InterfaceC1933
    /* JADX INFO: renamed from: ᵱᵽʡᵚ */
    public final void mo3273() {
        this.f10597 = true;
    }

    @Override // defpackage.InterfaceC1933
    /* JADX INFO: renamed from: ᵵᵽ */
    public final void mo3275() {
        C5067 c5067;
        this.f10585.getClass();
        if (this.f10602 == null && (c5067 = this.f10603) != null) {
            InterfaceC4291 interfaceC4291Mo1254 = ((InterfaceC4291) c5067.f19117).mo1254();
            if ((interfaceC4291Mo1254 instanceof C4018) || (interfaceC4291Mo1254 instanceof C4461)) {
                this.f10602 = this.f10603;
                this.f10608 = false;
            }
        }
        C0084 c0084 = this.f10595;
        InterfaceC1070 interfaceC1070 = this.f10596;
        if (this.f10608) {
            interfaceC1070.getClass();
            c0084.getClass();
            m6663(interfaceC1070, c0084, this.f10599, false);
            this.f10607 = 0;
            this.f10608 = false;
        }
        if (this.f10597) {
            return;
        }
        if (!this.f10601) {
            m6663(this.f7534, this.f7530, this.f10586, true);
        }
        this.f10592 = !this.f10597;
    }

    /* JADX INFO: renamed from: ᵻˈᵦʼ, reason: contains not printable characters */
    public final boolean m6665() {
        return this.f10604 != -9223372036854775807L;
    }
}
