package defpackage;

import androidx.media3.common.ParserException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;

/* JADX INFO: renamed from: ˉᵡˎ, reason: contains not printable characters */
/* JADX INFO: loaded from: classes3.dex */
public final class C1229 implements InterfaceC4291 {

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

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

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

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

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

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

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

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

    /* JADX INFO: renamed from: ᵨᵣ, reason: contains not printable characters */
    public byte[] f5191 = AbstractC0956.f4216;

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

    public C1229(InterfaceC3971 interfaceC3971, C5286 c5286) {
        C5286 c52862;
        this.f5193 = interfaceC3971;
        if (c5286 != null) {
            C4753 c4753M10878 = c5286.m10878();
            c4753M10878.f18101 = AbstractC4208.m9132("application/x-media3-cues");
            c4753M10878.f18120 = c5286.f19987;
            c4753M10878.f18097 = interfaceC3971.mo1087();
            c52862 = new C5286(c4753M10878);
        } else {
            c52862 = null;
        }
        this.f5188 = c52862;
        this.f5190 = new ArrayList();
        this.f5189 = 0;
        this.f5196 = AbstractC0956.f4218;
        this.f5192 = -9223372036854775807L;
    }

    @Override // defpackage.InterfaceC4291
    /* JADX INFO: renamed from: ʽˈˋ */
    public final void mo1252(long j, long j2) {
        int i = this.f5189;
        ᵻᵪ.ˌᴵ((i == 0 || i == 5) ? false : true);
        this.f5192 = j2;
        if (this.f5189 == 2) {
            this.f5189 = 1;
        }
        if (this.f5189 == 4) {
            this.f5189 = 3;
        }
    }

    /* JADX INFO: renamed from: ˊᵫᵗ, reason: contains not printable characters */
    public final void m3714(C0206 c0206) {
        this.f5197.getClass();
        byte[] bArr = c0206.f1677;
        int length = bArr.length;
        C4545 c4545 = this.f5195;
        c4545.getClass();
        c4545.m9600(bArr.length, bArr);
        this.f5197.mo1740(length, c4545);
        this.f5197.mo1741(c0206.f1676, 1, length, 0, null);
    }

    @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) {
        return true;
    }

    @Override // defpackage.InterfaceC4291
    /* JADX INFO: renamed from: ᵲᵶᵳˈ */
    public final void mo1256() {
        if (this.f5189 == 5) {
            return;
        }
        this.f5193.reset();
        this.f5189 = 5;
    }

    @Override // defpackage.InterfaceC4291
    /* JADX INFO: renamed from: ᵵᵽ */
    public final void mo1257(InterfaceC4550 interfaceC4550) {
        ᵻᵪ.ˌᴵ(this.f5189 == 0);
        InterfaceC5226 interfaceC5226Mo2743 = interfaceC4550.mo2743(0, 3);
        this.f5197 = interfaceC5226Mo2743;
        C5286 c5286 = this.f5188;
        if (c5286 != null) {
            interfaceC5226Mo2743.mo1742(c5286);
            interfaceC4550.mo2740();
            interfaceC4550.mo2739(new C2665(-9223372036854775807L, new long[]{0}, new long[]{0}));
        }
        this.f5189 = 1;
    }

    /* JADX WARN: Removed duplicated region for block: B:67:0x007e A[EXC_TOP_SPLITTER, PHI: r22
      0x007e: PHI (r22v4 int) = (r22v5 int), (r22v6 int) binds: [B:32:0x007c, B:29:0x0077] A[DONT_GENERATE, DONT_INLINE], SYNTHETIC] */
    @Override // defpackage.InterfaceC4291
    /* JADX INFO: renamed from: ᵷᵺʾᵖ */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final int mo1258(InterfaceC5206 interfaceC5206, C2669 c2669) throws ParserException {
        int i;
        int i2 = this.f5189;
        ᵻᵪ.ˌᴵ((i2 == 0 || i2 == 5) ? false : true);
        if (this.f5189 == 1) {
            int i3 = interfaceC5206.getLength() != -1 ? ᵝˉː.ᵷᵺʾᵖ(interfaceC5206.getLength()) : 1024;
            if (i3 > this.f5191.length) {
                this.f5191 = new byte[i3];
            }
            this.f5194 = 0;
            this.f5189 = 2;
        }
        int i4 = this.f5189;
        ArrayList arrayList = this.f5190;
        if (i4 == 2) {
            byte[] bArr = this.f5191;
            if (bArr.length == this.f5194) {
                this.f5191 = Arrays.copyOf(bArr, bArr.length + 1024);
            }
            byte[] bArr2 = this.f5191;
            int i5 = this.f5194;
            int i6 = interfaceC5206.read(bArr2, i5, bArr2.length - i5);
            if (i6 != -1) {
                this.f5194 += i6;
            }
            long length = interfaceC5206.getLength();
            if (length != -1) {
                i = 0;
                if (this.f5194 == length) {
                    try {
                        long j = this.f5192;
                        this.f5193.mo1086(this.f5191, 0, this.f5194, j != -9223372036854775807L ? new C1589(true, j) : C1589.f6384, new ˈᵚᵰˎ(18, this));
                        Collections.sort(arrayList);
                        this.f5196 = new long[arrayList.size()];
                        for (int i7 = i; i7 < arrayList.size(); i7++) {
                            this.f5196[i7] = ((C0206) arrayList.get(i7)).f1676;
                        }
                        this.f5191 = AbstractC0956.f4216;
                        this.f5189 = 4;
                    } catch (RuntimeException e) {
                        throw ParserException.m357("SubtitleParser failed.", e);
                    }
                }
            } else {
                i = 0;
            }
            if (i6 == -1) {
            }
        } else {
            i = 0;
        }
        if (this.f5189 == 3) {
            if (interfaceC5206.mo4704(interfaceC5206.getLength() != -1 ? ᵝˉː.ᵷᵺʾᵖ(interfaceC5206.getLength()) : 1024) == -1) {
                long j2 = this.f5192;
                for (int iM3271 = j2 == -9223372036854775807L ? i : AbstractC0956.m3271(this.f5196, j2, true); iM3271 < arrayList.size(); iM3271++) {
                    m3714((C0206) arrayList.get(iM3271));
                }
                this.f5189 = 4;
            }
        }
        if (this.f5189 == 4) {
            return -1;
        }
        return i;
    }

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