package defpackage;

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

/* renamed from: ˈᵚᵼˁ, reason: contains not printable characters */
/* loaded from: classes3.dex */
public final class C1070 implements InterfaceC1593 {

    /* renamed from: ˇʼʤˎ, reason: contains not printable characters */
    public InterfaceC2154 f4638;

    /* renamed from: ˌᵜᵹᵩ, reason: contains not printable characters */
    public boolean f4639;

    /* renamed from: ˎˏʜʾ, reason: contains not printable characters */
    public long f4640;

    /* renamed from: ˏˋٴ, reason: contains not printable characters */
    public int f4641;

    /* renamed from: ˏᵙ, reason: contains not printable characters */
    public final C3493 f4642;

    /* renamed from: ᵝᵵᵺ, reason: contains not printable characters */
    public long f4643;

    /* renamed from: ᵥᵯˎ, reason: contains not printable characters */
    public final /* synthetic */ int f4644;

    /* renamed from: ᵯٴᵦ, reason: contains not printable characters */
    public boolean f4645;

    /* renamed from: ᵴᵳ, reason: contains not printable characters */
    public final C3493 f4646;

    /* renamed from: ᵶᵷᵕ, reason: contains not printable characters */
    public int f4647;

    /* renamed from: ᵸˑ, reason: contains not printable characters */
    public long f4648;

    /* renamed from: ᵹᵝᵶ, reason: contains not printable characters */
    public int f4649;

    /* renamed from: ᵻᵢﹳᵰ, reason: contains not printable characters */
    public final C2419 f4650;

    public C1070(C2419 c2419, int i) {
        this.f4644 = i;
        switch (i) {
            case 1:
                this.f4646 = new C3493();
                this.f4642 = new C3493(ˊˉʤﹳ.ˏˋٴ);
                this.f4650 = c2419;
                this.f4640 = -9223372036854775807L;
                this.f4649 = -1;
                this.f4643 = -9223372036854775807L;
                this.f4639 = false;
                this.f4645 = false;
                break;
            default:
                this.f4642 = new C3493(ˊˉʤﹳ.ˏˋٴ);
                this.f4650 = c2419;
                this.f4646 = new C3493();
                this.f4640 = -9223372036854775807L;
                this.f4649 = -1;
                this.f4643 = -9223372036854775807L;
                this.f4639 = false;
                this.f4645 = false;
                break;
        }
    }

    /* renamed from: ˇʼʤˎ, reason: contains not printable characters */
    private final void m3464(long j) {
    }

    /* renamed from: ˏˋٴ, reason: contains not printable characters */
    private final void m3465(long j) {
    }

    /* renamed from: ˎˏʜʾ, reason: contains not printable characters */
    public int m3466() {
        C3493 c3493 = this.f4642;
        c3493.m7955(0);
        int iM7959 = c3493.m7959();
        InterfaceC2154 interfaceC2154 = this.f4638;
        interfaceC2154.getClass();
        interfaceC2154.mo4406(iM7959, c3493);
        return iM7959;
    }

    @Override // defpackage.InterfaceC1593
    /* renamed from: ˏᵙ */
    public final void mo2630(InterfaceC1982 interfaceC1982, int i) {
        int i2 = this.f4644;
        C2419 c2419 = this.f4650;
        switch (i2) {
            case 0:
                InterfaceC2154 interfaceC2154Mo4996 = interfaceC1982.mo4996(i, 2);
                this.f4638 = interfaceC2154Mo4996;
                String str = AbstractC3558.f13329;
                interfaceC2154Mo4996.mo4407(c2419.f9445);
                break;
            default:
                InterfaceC2154 interfaceC2154Mo49962 = interfaceC1982.mo4996(i, 2);
                this.f4638 = interfaceC2154Mo49962;
                interfaceC2154Mo49962.mo4407(c2419.f9445);
                break;
        }
    }

    @Override // defpackage.InterfaceC1593
    /* renamed from: ᵥᵯˎ */
    public final void mo2631(long j) {
        int i = this.f4644;
    }

    @Override // defpackage.InterfaceC1593
    /* renamed from: ᵴᵳ */
    public final void mo2632(long j, long j2) {
        switch (this.f4644) {
            case 0:
                this.f4640 = j;
                this.f4643 = -9223372036854775807L;
                this.f4639 = false;
                this.f4645 = false;
                this.f4647 = 0;
                this.f4641 = 0;
                this.f4648 = j2;
                break;
            default:
                this.f4640 = j;
                this.f4643 = -9223372036854775807L;
                this.f4639 = false;
                this.f4645 = false;
                this.f4647 = 0;
                this.f4641 = 0;
                this.f4648 = j2;
                break;
        }
    }

    /* renamed from: ᵹᵝᵶ, reason: contains not printable characters */
    public int m3467() {
        C3493 c3493 = this.f4642;
        c3493.m7955(0);
        int iM7959 = c3493.m7959();
        InterfaceC2154 interfaceC2154 = this.f4638;
        interfaceC2154.getClass();
        interfaceC2154.mo4406(iM7959, c3493);
        return iM7959;
    }

    @Override // defpackage.InterfaceC1593
    /* renamed from: ᵻᵢﹳᵰ */
    public final void mo2633(C3493 c3493, long j, int i, boolean z) throws ParserException {
        char c;
        int i2;
        boolean z2;
        int i3 = this.f4644;
        C3493 c34932 = this.f4646;
        switch (i3) {
            case 0:
                this.f4638.getClass();
                long j2 = this.f4643;
                if (j2 == -9223372036854775807L || j == j2) {
                    c = 0;
                } else {
                    c = 0;
                    this.f4639 = false;
                    this.f4645 = false;
                    this.f4647 = 0;
                    this.f4641 = 0;
                }
                if (!this.f4639) {
                    try {
                        byte[] bArr = c3493.f13082;
                        byte b = bArr[c];
                        int i4 = b & 31;
                        boolean z3 = this.f4645;
                        if (z3 && i4 != 28) {
                            this.f4639 = true;
                        }
                        boolean z4 = this.f4639;
                        if (!z4) {
                            if (i4 > 0 && i4 < 24) {
                                int iM7959 = c3493.m7959();
                                this.f4647 = m3466() + this.f4647;
                                this.f4638.mo4406(iM7959, c3493);
                                this.f4647 += iM7959;
                                this.f4641 = (c3493.f13082[0] & 31) == 5 ? 1 : 0;
                            } else if (i4 == 24) {
                                c3493.m7956();
                                while (c3493.m7959() > 4) {
                                    int iM7972 = c3493.m7972();
                                    this.f4647 = m3466() + this.f4647;
                                    this.f4638.mo4406(iM7972, c3493);
                                    this.f4647 += iM7972;
                                }
                                this.f4641 = 0;
                            } else {
                                if (i4 != 28) {
                                    String str = AbstractC3558.f13329;
                                    Locale locale = Locale.US;
                                    throw ParserException.m357("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.f4639 = true;
                                        this.f4647 = 0;
                                    }
                                    this.f4645 = true;
                                    this.f4647 = m3466() + this.f4647;
                                    byte[] bArr2 = c3493.f13082;
                                    bArr2[1] = (byte) i5;
                                    c34932.getClass();
                                    c34932.m7975(bArr2.length, bArr2);
                                    c34932.m7955(1);
                                } else {
                                    i2 = 1;
                                    if (!z4) {
                                        int iM10873 = C5228.m10873(this.f4649);
                                        if (i != iM10873) {
                                            this.f4639 = true;
                                            String str2 = AbstractC3558.f13329;
                                            Locale locale2 = Locale.US;
                                            ᵳʿˉ.ᵶʔᵢˊ("Received RTP packet with unexpected sequence number. Expected: " + iM10873 + "; received: " + i + ". Dropping packet.");
                                        } else {
                                            byte[] bArr3 = c3493.f13082;
                                            c34932.getClass();
                                            c34932.m7975(bArr3.length, bArr3);
                                            c34932.m7955(2);
                                        }
                                    }
                                }
                                int iM79592 = c34932.m7959();
                                this.f4638.mo4406(iM79592, c34932);
                                this.f4647 += iM79592;
                                if (z6) {
                                    this.f4645 = false;
                                    this.f4641 = (i5 & 31) == 5 ? i2 : 0;
                                }
                            }
                        }
                    } catch (IndexOutOfBoundsException e) {
                        throw ParserException.m357(null, e);
                    }
                }
                if (this.f4640 == -9223372036854775807L) {
                    this.f4640 = j;
                }
                if (z) {
                    if (!this.f4639) {
                        this.f4638.mo4410(ˁˈᵸ.ᵡᵘˎʽ(90000, this.f4648, j, this.f4640), this.f4641, this.f4647, 0, null);
                    }
                    this.f4639 = false;
                    this.f4645 = false;
                    this.f4647 = 0;
                    this.f4641 = 0;
                }
                this.f4643 = j;
                this.f4649 = i;
                return;
            default:
                if (c3493.f13082.length == 0) {
                    throw ParserException.m357("Empty RTP data packet.", null);
                }
                this.f4638.getClass();
                long j3 = this.f4643;
                if (j3 != -9223372036854775807L && j != j3) {
                    this.f4639 = false;
                    this.f4645 = false;
                    this.f4647 = 0;
                    this.f4641 = 0;
                }
                if (!this.f4639) {
                    byte[] bArr4 = c3493.f13082;
                    int i6 = (bArr4[0] >> 1) & 63;
                    boolean z7 = this.f4645;
                    if (z7 && i6 != 49) {
                        this.f4639 = true;
                    }
                    boolean z8 = this.f4639;
                    if (!z8) {
                        if (i6 >= 0 && i6 < 48) {
                            int iM79593 = c3493.m7959();
                            this.f4647 = m3467() + this.f4647;
                            this.f4638.mo4406(iM79593, c3493);
                            this.f4647 += iM79593;
                            int i7 = (c3493.f13082[0] >> 1) & 63;
                            this.f4641 = (i7 == 19 || i7 == 20) ? 1 : 0;
                        } else if (i6 == 48) {
                            c3493.m7955(2);
                            int i8 = 0;
                            for (int i9 = 2; c3493.m7959() > i9; i9 = 2) {
                                int iM79722 = c3493.m7972();
                                int i10 = (c3493.f13082[c3493.f13083] & 126) >> 1;
                                if (c3493.m7959() < iM79722) {
                                    throw ParserException.m357("Malformed Aggregation Packet. NAL unit size exceeds packet size.", null);
                                }
                                this.f4647 = m3467() + this.f4647;
                                this.f4638.mo4406(iM79722, c3493);
                                this.f4647 += iM79722;
                                this.f4641 |= (i10 == 19 || i10 == 20) ? 1 : 0;
                                i8++;
                            }
                            if (c3493.m7959() > 0) {
                                throw ParserException.m357("Malformed Aggregation Packet. Packet size exceeds NAL unit size.", null);
                            }
                            if (i8 < 2) {
                                throw ParserException.m357("Aggregation Packet must contain at least 2 NAL units.", null);
                            }
                        } else {
                            if (i6 != 49) {
                                String str3 = AbstractC3558.f13329;
                                Locale locale3 = Locale.US;
                                throw ParserException.m357("RTP H265 payload type [" + i6 + "] not supported.", null);
                            }
                            if (bArr4.length < 3) {
                                throw ParserException.m357("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.f4639 = true;
                                    this.f4647 = 0;
                                } else {
                                    z2 = true;
                                }
                                this.f4645 = z2;
                                this.f4647 = m3467() + this.f4647;
                                byte[] bArr5 = (byte[]) c3493.f13082.clone();
                                c34932.getClass();
                                c34932.m7975(bArr5.length, bArr5);
                                byte[] bArr6 = c34932.f13082;
                                bArr6[1] = (byte) ((i12 << 1) & 127);
                                bArr6[2] = (byte) i11;
                                c34932.m7955(1);
                            } else if (!z8) {
                                int i13 = (this.f4649 + 1) % 65535;
                                if (i != i13) {
                                    this.f4639 = true;
                                    String str4 = AbstractC3558.f13329;
                                    Locale locale4 = Locale.US;
                                    ᵳʿˉ.ᵶʔᵢˊ("Received RTP packet with unexpected sequence number. Expected: " + i13 + "; received: " + i + ". Dropping packet.");
                                } else {
                                    c34932.getClass();
                                    c34932.m7975(bArr4.length, bArr4);
                                    c34932.m7955(3);
                                }
                            }
                            int iM79594 = c34932.m7959();
                            this.f4638.mo4406(iM79594, c34932);
                            this.f4647 += iM79594;
                            if (z10) {
                                this.f4645 = false;
                                this.f4641 = (i12 == 19 || i12 == 20) ? 1 : 0;
                            }
                        }
                    }
                }
                if (this.f4640 == -9223372036854775807L) {
                    this.f4640 = j;
                }
                if (z) {
                    if (!this.f4639) {
                        this.f4638.mo4410(ˁˈᵸ.ᵡᵘˎʽ(90000, this.f4648, j, this.f4640), this.f4641, this.f4647, 0, null);
                    }
                    this.f4639 = false;
                    this.f4645 = false;
                    this.f4647 = 0;
                    this.f4641 = 0;
                }
                this.f4643 = j;
                this.f4649 = i;
                return;
        }
    }
}
