package defpackage;

import android.util.SparseArray;
import java.io.EOFException;
import java.io.InterruptedIOException;
import java.util.List;

/* JADX INFO: renamed from: ˑˋᵛᵩ, reason: contains not printable characters */
/* JADX INFO: loaded from: classes3.dex */
public final class C2065 implements InterfaceC4291 {

    /* JADX INFO: renamed from: ˊᵫᵗ, reason: contains not printable characters */
    public long f8177;

    /* JADX INFO: renamed from: ᵨᵣ, reason: contains not printable characters */
    public boolean f8179;

    /* JADX INFO: renamed from: ᵱᵽʡᵚ, reason: contains not printable characters */
    public InterfaceC4550 f8180;

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

    /* JADX INFO: renamed from: ᵶᵥᵝ, reason: contains not printable characters */
    public boolean f8183;

    /* JADX INFO: renamed from: ᵻʽᵯ, reason: contains not printable characters */
    public C5052 f8185;

    /* JADX INFO: renamed from: ᵻˈᵦʼ, reason: contains not printable characters */
    public boolean f8186;

    /* JADX INFO: renamed from: ᵲᵶᵳˈ, reason: contains not printable characters */
    public final C0085 f8181 = new C0085(0);

    /* JADX INFO: renamed from: ːˏᵟᵯ, reason: contains not printable characters */
    public final C4545 f8178 = new C4545(4096);

    /* JADX INFO: renamed from: ʽˈˋ, reason: contains not printable characters */
    public final SparseArray f8176 = new SparseArray();

    /* JADX INFO: renamed from: ᵷᵺʾᵖ, reason: contains not printable characters */
    public final C3827 f8184 = new C3827();

    @Override // defpackage.InterfaceC4291
    /* JADX INFO: renamed from: ʽˈˋ */
    public final void mo1252(long j, long j2) {
        C0085 c0085 = this.f8181;
        boolean z = c0085.m1136() == -9223372036854775807L;
        if (!z) {
            long jM1139 = c0085.m1139();
            z = (jM1139 == -9223372036854775807L || jM1139 == 0 || jM1139 == j2) ? false : true;
        }
        if (z) {
            c0085.m1138(j2);
        }
        C5052 c5052 = this.f8185;
        if (c5052 != null) {
            c5052.m10391(j2);
        }
        int i = 0;
        while (true) {
            SparseArray sparseArray = this.f8176;
            if (i >= sparseArray.size()) {
                return;
            }
            C1293 c1293 = (C1293) sparseArray.valueAt(i);
            c1293.f5392 = false;
            c1293.f5389.mo2659();
            i++;
        }
    }

    @Override // defpackage.InterfaceC4291
    /* JADX INFO: renamed from: ːˏᵟᵯ */
    public final InterfaceC4291 mo1254() {
        return this;
    }

    @Override // defpackage.InterfaceC4291
    /* JADX INFO: renamed from: ᵨᵣ */
    public final boolean mo1255(InterfaceC5206 interfaceC5206) throws EOFException, InterruptedIOException {
        byte[] bArr = new byte[14];
        C2373 c2373 = (C2373) interfaceC5206;
        c2373.mo4708(bArr, 0, 14, false);
        if (442 == (((bArr[0] & 255) << 24) | ((bArr[1] & 255) << 16) | ((bArr[2] & 255) << 8) | (bArr[3] & 255)) && (bArr[4] & 196) == 68 && (bArr[6] & 4) == 4 && (bArr[8] & 4) == 4 && (bArr[9] & 1) == 1 && (bArr[12] & 3) == 3) {
            c2373.m6055(bArr[13] & 7, false);
            c2373.mo4708(bArr, 0, 3, false);
            if (1 == (((bArr[0] & 255) << 16) | ((bArr[1] & 255) << 8) | (bArr[2] & 255))) {
                return true;
            }
        }
        return false;
    }

    @Override // defpackage.InterfaceC4291
    /* JADX INFO: renamed from: ᵲᵶᵳˈ */
    public final void mo1256() {
    }

    @Override // defpackage.InterfaceC4291
    /* JADX INFO: renamed from: ᵵᵽ */
    public final void mo1257(InterfaceC4550 interfaceC4550) {
        this.f8180 = interfaceC4550;
    }

    @Override // defpackage.InterfaceC4291
    /* JADX INFO: renamed from: ᵷᵺʾᵖ */
    public final int mo1258(InterfaceC5206 interfaceC5206, C2669 c2669) {
        char c;
        int i;
        int i2;
        InterfaceC2750 c4439;
        long j;
        this.f8180.getClass();
        long length = interfaceC5206.getLength();
        int i3 = (length > (-1L) ? 1 : (length == (-1L) ? 0 : -1));
        long j2 = -9223372036854775807L;
        C3827 c3827 = this.f8184;
        if (i3 != 0) {
            c = 3;
            if (!c3827.f14613) {
                C0085 c0085 = c3827.f14615;
                C4545 c4545 = c3827.f14611;
                if (!c3827.f14614) {
                    long length2 = interfaceC5206.getLength();
                    int iMin = (int) Math.min(20000L, length2);
                    long j3 = length2 - ((long) iMin);
                    if (interfaceC5206.getPosition() != j3) {
                        c2669.f10317 = j3;
                        return 1;
                    }
                    c4545.m9603(iMin);
                    interfaceC5206.mo4698();
                    interfaceC5206.mo4701(c4545.f17284, 0, iMin);
                    int i4 = c4545.f17282;
                    int i5 = c4545.f17283 - 4;
                    while (true) {
                        if (i5 < i4) {
                            break;
                        }
                        if (C3827.m8525(i5, c4545.f17284) == 442) {
                            c4545.m9624(i5 + 4);
                            long jM8526 = C3827.m8526(c4545);
                            if (jM8526 != -9223372036854775807L) {
                                j2 = jM8526;
                                break;
                            }
                        }
                        i5--;
                    }
                    c3827.f14616 = j2;
                    c3827.f14614 = true;
                    return 0;
                }
                if (c3827.f14616 == -9223372036854775807L) {
                    c3827.m8527(interfaceC5206);
                    return 0;
                }
                if (c3827.f14617) {
                    long j4 = c3827.f14618;
                    if (j4 == -9223372036854775807L) {
                        c3827.m8527(interfaceC5206);
                        return 0;
                    }
                    c3827.f14612 = c0085.m1135(c3827.f14616) - c0085.m1133(j4);
                    c3827.m8527(interfaceC5206);
                    return 0;
                }
                int iMin2 = (int) Math.min(20000L, interfaceC5206.getLength());
                if (interfaceC5206.getPosition() != 0) {
                    c2669.f10317 = 0L;
                    return 1;
                }
                c4545.m9603(iMin2);
                interfaceC5206.mo4698();
                interfaceC5206.mo4701(c4545.f17284, 0, iMin2);
                int i6 = c4545.f17282;
                int i7 = c4545.f17283;
                while (true) {
                    if (i6 >= i7 - 3) {
                        j = -9223372036854775807L;
                        break;
                    }
                    if (C3827.m8525(i6, c4545.f17284) == 442) {
                        c4545.m9624(i6 + 4);
                        long jM85262 = C3827.m8526(c4545);
                        if (jM85262 != -9223372036854775807L) {
                            j = jM85262;
                            break;
                        }
                    }
                    i6++;
                }
                c3827.f14618 = j;
                c3827.f14617 = true;
                return 0;
            }
        } else {
            c = 3;
        }
        if (this.f8183) {
            i = i3;
            i2 = 4;
        } else {
            this.f8183 = true;
            long j5 = c3827.f14612;
            if (j5 != -9223372036854775807L) {
                i = i3;
                i2 = 4;
                C5052 c5052 = new C5052(new ʻﾞ(), new C3714(c3827.f14615), j5, j5 + 1, 0L, length, 188L, 1000);
                this.f8185 = c5052;
                this.f8180.mo2739(c5052.f19096);
            } else {
                i = i3;
                i2 = 4;
                this.f8180.mo2739(new C3782(j5));
            }
        }
        C5052 c50522 = this.f8185;
        if (c50522 != null && c50522.f19095 != null) {
            return c50522.m10390(interfaceC5206, c2669);
        }
        interfaceC5206.mo4698();
        long jMo4706 = i != 0 ? length - interfaceC5206.mo4706() : -1L;
        if (jMo4706 != -1 && jMo4706 < 4) {
            return -1;
        }
        C4545 c45452 = this.f8178;
        if (!interfaceC5206.mo4708(c45452.f17284, 0, i2, true)) {
            return -1;
        }
        c45452.m9624(0);
        int iM9614 = c45452.m9614();
        if (iM9614 == 441) {
            return -1;
        }
        if (iM9614 == 442) {
            interfaceC5206.mo4701(c45452.f17284, 0, 10);
            c45452.m9624(9);
            interfaceC5206.mo4700((c45452.m9626() & 7) + 14);
            return 0;
        }
        if (iM9614 == 443) {
            interfaceC5206.mo4701(c45452.f17284, 0, 2);
            c45452.m9624(0);
            interfaceC5206.mo4700(c45452.m9598() + 6);
            return 0;
        }
        if (((iM9614 & (-256)) >> 8) != 1) {
            interfaceC5206.mo4700(1);
            return 0;
        }
        int i8 = iM9614 & 255;
        SparseArray sparseArray = this.f8176;
        C1293 c1293 = (C1293) sparseArray.get(i8);
        if (!this.f8179) {
            if (c1293 == null) {
                if (i8 == 189) {
                    c4439 = new C3292("video/mp2p");
                    this.f8186 = true;
                    this.f8177 = interfaceC5206.getPosition();
                } else if ((iM9614 & 224) == 192) {
                    c4439 = new C3637(0, null, "video/mp2p");
                    this.f8186 = true;
                    this.f8177 = interfaceC5206.getPosition();
                } else if ((iM9614 & 240) == 224) {
                    c4439 = new C4439(null, "video/mp2p");
                    this.f8182 = true;
                    this.f8177 = interfaceC5206.getPosition();
                } else {
                    c4439 = null;
                }
                if (c4439 != null) {
                    c4439.mo2663(this.f8180, new C4173(i8, 256));
                    c1293 = new C1293(c4439, this.f8181);
                    sparseArray.put(i8, c1293);
                }
            }
            if (interfaceC5206.getPosition() > ((this.f8186 && this.f8182) ? this.f8177 + 8192 : 1048576L)) {
                this.f8179 = true;
                this.f8180.mo2740();
            }
        }
        interfaceC5206.mo4701(c45452.f17284, 0, 2);
        c45452.m9624(0);
        int iM9598 = c45452.m9598() + 6;
        if (c1293 == null) {
            interfaceC5206.mo4700(iM9598);
            return 0;
        }
        c45452.m9603(iM9598);
        interfaceC5206.readFully(c45452.f17284, 0, iM9598);
        c45452.m9624(6);
        InterfaceC2750 interfaceC2750 = c1293.f5389;
        C3180 c3180 = c1293.f5387;
        c45452.m9627(c3180.f12075, 0, 3);
        c3180.m7298(0);
        c3180.m7287(8);
        c1293.f5391 = c3180.m7299();
        c1293.f5388 = c3180.m7299();
        c3180.m7287(6);
        c45452.m9627(c3180.f12075, 0, c3180.m7302(8));
        c3180.m7298(0);
        C0085 c00852 = c1293.f5386;
        c1293.f5390 = 0L;
        if (c1293.f5391) {
            c3180.m7287(4);
            long jM7302 = ((long) c3180.m7302(3)) << 30;
            c3180.m7287(1);
            long jM73022 = jM7302 | ((long) (c3180.m7302(15) << 15));
            c3180.m7287(1);
            long jM73023 = jM73022 | ((long) c3180.m7302(15));
            c3180.m7287(1);
            if (!c1293.f5392 && c1293.f5388) {
                c3180.m7287(4);
                long jM73024 = ((long) c3180.m7302(3)) << 30;
                c3180.m7287(1);
                long jM73025 = jM73024 | ((long) (c3180.m7302(15) << 15));
                c3180.m7287(1);
                long jM73026 = jM73025 | ((long) c3180.m7302(15));
                c3180.m7287(1);
                c00852.m1133(jM73026);
                c1293.f5392 = true;
            }
            c1293.f5390 = c00852.m1133(jM73023);
        }
        interfaceC2750.mo2660(c1293.f5390, 4);
        interfaceC2750.mo2661(c45452);
        interfaceC2750.mo2662(false);
        c45452.m9612(c45452.f17284.length);
        return 0;
    }

    @Override // defpackage.InterfaceC4291
    /* JADX INFO: renamed from: ᵻˈᵦʼ */
    public final List mo1259() {
        C2822 c2822 = AbstractC4509.f17159;
        return C2598.f10048;
    }
}
