package defpackage;

import androidx.media3.common.ParserException;
import java.util.Locale;

/* JADX INFO: renamed from: ˎᵰᵙ, reason: contains not printable characters */
/* JADX INFO: loaded from: classes3.dex */
public final class C1777 implements InterfaceC0728 {

    /* JADX INFO: renamed from: ʽˈˋ, reason: contains not printable characters */
    public final C4545 f7123;

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

    /* JADX INFO: renamed from: ːˏᵟᵯ, reason: contains not printable characters */
    public final C4545 f7125;

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

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

    /* JADX INFO: renamed from: ᵮᵣᵗˈ, reason: contains not printable characters */
    public boolean f7128;

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

    /* JADX INFO: renamed from: ᵲᵶᵳˈ, reason: contains not printable characters */
    public final /* synthetic */ int f7130;

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

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

    /* JADX INFO: renamed from: ᵷᵺʾᵖ, reason: contains not printable characters */
    public final C3176 f7133;

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

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

    public C1777(C3176 c3176, int i) {
        this.f7130 = i;
        switch (i) {
            case 1:
                this.f7123 = new C4545();
                this.f7125 = new C4545(ᵥˇᵛˎ.ːˏᵟᵯ);
                this.f7133 = c3176;
                this.f7131 = -9223372036854775807L;
                this.f7124 = -1;
                this.f7134 = -9223372036854775807L;
                this.f7128 = false;
                this.f7126 = false;
                break;
            default:
                this.f7125 = new C4545(ᵥˇᵛˎ.ːˏᵟᵯ);
                this.f7133 = c3176;
                this.f7123 = new C4545();
                this.f7131 = -9223372036854775807L;
                this.f7124 = -1;
                this.f7134 = -9223372036854775807L;
                this.f7128 = false;
                this.f7126 = false;
                break;
        }
    }

    /* JADX INFO: renamed from: ᵨᵣ, reason: contains not printable characters */
    private final void m4915(long j) {
    }

    /* JADX INFO: renamed from: ᵻˈᵦʼ, reason: contains not printable characters */
    private final void m4916(long j) {
    }

    @Override // defpackage.InterfaceC0728
    /* JADX INFO: renamed from: ʽˈˋ */
    public final void mo2599(long j, long j2) {
        switch (this.f7130) {
            case 0:
                this.f7131 = j;
                this.f7134 = -9223372036854775807L;
                this.f7128 = false;
                this.f7126 = false;
                this.f7129 = 0;
                this.f7135 = 0;
                this.f7132 = j2;
                break;
            default:
                this.f7131 = j;
                this.f7134 = -9223372036854775807L;
                this.f7128 = false;
                this.f7126 = false;
                this.f7129 = 0;
                this.f7135 = 0;
                this.f7132 = j2;
                break;
        }
    }

    /* JADX INFO: renamed from: ˊᵫᵗ, reason: contains not printable characters */
    public int m4917() {
        C4545 c4545 = this.f7125;
        c4545.m9624(0);
        int iM9623 = c4545.m9623();
        InterfaceC5226 interfaceC5226 = this.f7127;
        interfaceC5226.getClass();
        interfaceC5226.mo1740(iM9623, c4545);
        return iM9623;
    }

    @Override // defpackage.InterfaceC0728
    /* JADX INFO: renamed from: ːˏᵟᵯ */
    public final void mo2600(InterfaceC4550 interfaceC4550, int i) {
        int i2 = this.f7130;
        C3176 c3176 = this.f7133;
        switch (i2) {
            case 0:
                InterfaceC5226 interfaceC5226Mo2743 = interfaceC4550.mo2743(i, 2);
                this.f7127 = interfaceC5226Mo2743;
                String str = AbstractC0956.f4222;
                interfaceC5226Mo2743.mo1742(c3176.f12057);
                break;
            default:
                InterfaceC5226 interfaceC5226Mo27432 = interfaceC4550.mo2743(i, 2);
                this.f7127 = interfaceC5226Mo27432;
                interfaceC5226Mo27432.mo1742(c3176.f12057);
                break;
        }
    }

    @Override // defpackage.InterfaceC0728
    /* JADX INFO: renamed from: ᵲᵶᵳˈ */
    public final void mo2601(long j) {
        int i = this.f7130;
    }

    /* JADX INFO: renamed from: ᵵᵽ, reason: contains not printable characters */
    public int m4918() {
        C4545 c4545 = this.f7125;
        c4545.m9624(0);
        int iM9623 = c4545.m9623();
        InterfaceC5226 interfaceC5226 = this.f7127;
        interfaceC5226.getClass();
        interfaceC5226.mo1740(iM9623, c4545);
        return iM9623;
    }

    @Override // defpackage.InterfaceC0728
    /* JADX INFO: renamed from: ᵷᵺʾᵖ */
    public final void mo2602(C4545 c4545, long j, int i, boolean z) throws ParserException {
        char c;
        int i2;
        boolean z2;
        int i3 = this.f7130;
        C4545 c45452 = this.f7123;
        switch (i3) {
            case 0:
                this.f7127.getClass();
                long j2 = this.f7134;
                if (j2 == -9223372036854775807L || j == j2) {
                    c = 0;
                } else {
                    c = 0;
                    this.f7128 = false;
                    this.f7126 = false;
                    this.f7129 = 0;
                    this.f7135 = 0;
                }
                if (!this.f7128) {
                    try {
                        byte[] bArr = c4545.f17284;
                        byte b = bArr[c];
                        int i4 = b & 31;
                        boolean z3 = this.f7126;
                        if (z3 && i4 != 28) {
                            this.f7128 = true;
                        }
                        boolean z4 = this.f7128;
                        if (!z4) {
                            if (i4 > 0 && i4 < 24) {
                                int iM9623 = c4545.m9623();
                                this.f7129 = m4918() + this.f7129;
                                this.f7127.mo1740(iM9623, c4545);
                                this.f7129 += iM9623;
                                this.f7135 = (c4545.f17284[0] & 31) == 5 ? 1 : 0;
                            } else if (i4 == 24) {
                                c4545.m9626();
                                while (c4545.m9623() > 4) {
                                    int iM9598 = c4545.m9598();
                                    this.f7129 = m4918() + this.f7129;
                                    this.f7127.mo1740(iM9598, c4545);
                                    this.f7129 += iM9598;
                                }
                                this.f7135 = 0;
                            } else {
                                if (i4 != 28) {
                                    String str = AbstractC0956.f4222;
                                    Locale locale = Locale.US;
                                    throw ParserException.m355("RTP H264 packetization mode [" + i4 + "] not supported.", null);
                                }
                                byte b2 = bArr[1];
                                int i5 = (b & 224) | (b2 & 31);
                                boolean z5 = (b2 & 128) > 0;
                                boolean z6 = (b2 & 64) > 0;
                                if (z5) {
                                    i2 = 1;
                                    if (z3) {
                                        this.f7128 = true;
                                        this.f7129 = 0;
                                    }
                                    this.f7126 = true;
                                    this.f7129 = m4918() + this.f7129;
                                    byte[] bArr2 = c4545.f17284;
                                    bArr2[1] = (byte) i5;
                                    c45452.getClass();
                                    c45452.m9600(bArr2.length, bArr2);
                                    c45452.m9624(1);
                                } else {
                                    i2 = 1;
                                    if (!z4) {
                                        int iM10653 = C5141.m10653(this.f7124);
                                        if (i != iM10653) {
                                            this.f7128 = true;
                                            String str2 = AbstractC0956.f4222;
                                            Locale locale2 = Locale.US;
                                            ˋˀᵧ.ʿٴˇ("Received RTP packet with unexpected sequence number. Expected: " + iM10653 + "; received: " + i + ". Dropping packet.");
                                        } else {
                                            byte[] bArr3 = c4545.f17284;
                                            c45452.getClass();
                                            c45452.m9600(bArr3.length, bArr3);
                                            c45452.m9624(2);
                                        }
                                    }
                                }
                                int iM96232 = c45452.m9623();
                                this.f7127.mo1740(iM96232, c45452);
                                this.f7129 += iM96232;
                                if (z6) {
                                    this.f7126 = false;
                                    this.f7135 = (i5 & 31) == 5 ? i2 : 0;
                                }
                            }
                        }
                    } catch (IndexOutOfBoundsException e) {
                        throw ParserException.m355(null, e);
                    }
                }
                if (this.f7131 == -9223372036854775807L) {
                    this.f7131 = j;
                }
                if (z) {
                    if (!this.f7128) {
                        this.f7127.mo1741(ᵸᵺᵜ.ˁˌᵩ(90000, this.f7132, j, this.f7131), this.f7135, this.f7129, 0, null);
                    }
                    this.f7128 = false;
                    this.f7126 = false;
                    this.f7129 = 0;
                    this.f7135 = 0;
                }
                this.f7134 = j;
                this.f7124 = i;
                return;
            default:
                if (c4545.f17284.length == 0) {
                    throw ParserException.m355("Empty RTP data packet.", null);
                }
                this.f7127.getClass();
                long j3 = this.f7134;
                if (j3 != -9223372036854775807L && j != j3) {
                    this.f7128 = false;
                    this.f7126 = false;
                    this.f7129 = 0;
                    this.f7135 = 0;
                }
                if (!this.f7128) {
                    byte[] bArr4 = c4545.f17284;
                    int i6 = (bArr4[0] >> 1) & 63;
                    boolean z7 = this.f7126;
                    if (z7 && i6 != 49) {
                        this.f7128 = true;
                    }
                    boolean z8 = this.f7128;
                    if (!z8) {
                        if (i6 >= 0 && i6 < 48) {
                            int iM96233 = c4545.m9623();
                            this.f7129 = m4917() + this.f7129;
                            this.f7127.mo1740(iM96233, c4545);
                            this.f7129 += iM96233;
                            int i7 = (c4545.f17284[0] >> 1) & 63;
                            this.f7135 = (i7 == 19 || i7 == 20) ? 1 : 0;
                        } else if (i6 == 48) {
                            c4545.m9624(2);
                            int i8 = 0;
                            for (int i9 = 2; c4545.m9623() > i9; i9 = 2) {
                                int iM95982 = c4545.m9598();
                                int i10 = (c4545.f17284[c4545.f17282] & 126) >> 1;
                                if (c4545.m9623() < iM95982) {
                                    throw ParserException.m355("Malformed Aggregation Packet. NAL unit size exceeds packet size.", null);
                                }
                                this.f7129 = m4917() + this.f7129;
                                this.f7127.mo1740(iM95982, c4545);
                                this.f7129 += iM95982;
                                this.f7135 |= (i10 == 19 || i10 == 20) ? 1 : 0;
                                i8++;
                            }
                            if (c4545.m9623() > 0) {
                                throw ParserException.m355("Malformed Aggregation Packet. Packet size exceeds NAL unit size.", null);
                            }
                            if (i8 < 2) {
                                throw ParserException.m355("Aggregation Packet must contain at least 2 NAL units.", null);
                            }
                        } else {
                            if (i6 != 49) {
                                String str3 = AbstractC0956.f4222;
                                Locale locale3 = Locale.US;
                                throw ParserException.m355("RTP H265 payload type [" + i6 + "] not supported.", null);
                            }
                            if (bArr4.length < 3) {
                                throw ParserException.m355("Malformed FU header.", null);
                            }
                            int i11 = bArr4[1] & 7;
                            byte b3 = bArr4[2];
                            int i12 = b3 & 63;
                            boolean z9 = (b3 & 128) > 0;
                            boolean z10 = (b3 & 64) > 0;
                            if (z9) {
                                if (z7) {
                                    z2 = true;
                                    this.f7128 = true;
                                    this.f7129 = 0;
                                } else {
                                    z2 = true;
                                }
                                this.f7126 = z2;
                                this.f7129 = m4917() + this.f7129;
                                byte[] bArr5 = (byte[]) c4545.f17284.clone();
                                c45452.getClass();
                                c45452.m9600(bArr5.length, bArr5);
                                byte[] bArr6 = c45452.f17284;
                                bArr6[1] = (byte) ((i12 << 1) & 127);
                                bArr6[2] = (byte) i11;
                                c45452.m9624(1);
                            } else if (!z8) {
                                int i13 = (this.f7124 + 1) % 65535;
                                if (i != i13) {
                                    this.f7128 = true;
                                    String str4 = AbstractC0956.f4222;
                                    Locale locale4 = Locale.US;
                                    ˋˀᵧ.ʿٴˇ("Received RTP packet with unexpected sequence number. Expected: " + i13 + "; received: " + i + ". Dropping packet.");
                                } else {
                                    c45452.getClass();
                                    c45452.m9600(bArr4.length, bArr4);
                                    c45452.m9624(3);
                                }
                            }
                            int iM96234 = c45452.m9623();
                            this.f7127.mo1740(iM96234, c45452);
                            this.f7129 += iM96234;
                            if (z10) {
                                this.f7126 = false;
                                this.f7135 = (i12 == 19 || i12 == 20) ? 1 : 0;
                            }
                        }
                    }
                }
                if (this.f7131 == -9223372036854775807L) {
                    this.f7131 = j;
                }
                if (z) {
                    if (!this.f7128) {
                        this.f7127.mo1741(ᵸᵺᵜ.ˁˌᵩ(90000, this.f7132, j, this.f7131), this.f7135, this.f7129, 0, null);
                    }
                    this.f7128 = false;
                    this.f7126 = false;
                    this.f7129 = 0;
                    this.f7135 = 0;
                }
                this.f7134 = j;
                this.f7124 = i;
                return;
        }
    }
}
