package defpackage;

import android.net.Uri;
import android.os.Looper;
import androidx.media3.common.ParserException;
import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;

/* JADX INFO: renamed from: ᵱᴵᵫᵎ, reason: contains not printable characters */
/* JADX INFO: loaded from: classes3.dex */
public final class C4438 extends AbstractC5108 {

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

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

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

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

    /* JADX INFO: renamed from: ˊᵡᵗʨ, reason: contains not printable characters */
    public C0707 f16908;

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

    /* JADX INFO: renamed from: ˌᵨʠᵫ, reason: contains not printable characters */
    public final C0625 f16910;

    /* JADX INFO: renamed from: ˑˊᵲ, reason: contains not printable characters */
    public final C3814 f16911;

    /* JADX INFO: renamed from: ᵛˑﹳ, reason: contains not printable characters */
    public C4216 f16912;

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

    /* JADX INFO: renamed from: ᵵᵬᵽ, reason: contains not printable characters */
    public C4838 f16914;

    /* JADX INFO: renamed from: ᵸˆˁ, reason: contains not printable characters */
    public final ᵟˑʽ f16915;

    static {
        AbstractC0456.m1895("media3.exoplayer.hls");
    }

    public C4438(C4838 c4838, ᵟˑʽ r2, C0625 c0625, C3814 c3814, InterfaceC4636 interfaceC4636, C1013 c1013, C1952 c1952, long j, boolean z, int i) {
        this.f16914 = c4838;
        this.f16908 = c4838.f18447;
        this.f16915 = r2;
        this.f16910 = c0625;
        this.f16911 = c3814;
        this.f16904 = interfaceC4636;
        this.f16913 = c1013;
        this.f16905 = c1952;
        this.f16909 = j;
        this.f16907 = z;
        this.f16906 = i;
    }

    /* JADX INFO: renamed from: ᵔᵖᵹᵫ, reason: contains not printable characters */
    public static C5274 m9445(long j, List list) {
        C5274 c5274 = null;
        for (int i = 0; i < list.size(); i++) {
            C5274 c52742 = (C5274) list.get(i);
            long j2 = c52742.f1916;
            if (j2 > j || !c52742.f19923) {
                if (j2 > j) {
                    break;
                }
            } else {
                c5274 = c52742;
            }
        }
        return c5274;
    }

    @Override // defpackage.AbstractC5108
    /* JADX INFO: renamed from: ˊᵨᵧ */
    public final void mo4070(C4216 c4216) {
        this.f16912 = c4216;
        Looper looperMyLooper = Looper.myLooper();
        looperMyLooper.getClass();
        C2136 c2136 = this.f19237;
        c2136.getClass();
        InterfaceC4636 interfaceC4636 = this.f16904;
        interfaceC4636.mo5536(looperMyLooper, c2136);
        interfaceC4636.mo5540();
        C1404 c1404M10599 = m10599(null);
        C4574 c4574 = mo4076().f18446;
        c4574.getClass();
        Uri uri = c4574.f17386;
        C1952 c1952 = this.f16905;
        c1952.getClass();
        c1952.f7769 = AbstractC0956.m3260(null);
        c1952.f7778 = c1404M10599;
        c1952.f7779 = this;
        Map map = Collections.EMPTY_MAP;
        ᵻᵪ.ᵱʡˏ(uri, "The uri must be set.");
        C3026 c3026 = new C3026(((InterfaceC1479) c1952.f7768.ˌᴵ).mo4241(), new C0084(uri, 1, null, map, 0L, -1L, null, 1), 4, c1952.f7773.mo2761());
        ᵻᵪ.ˌᴵ(c1952.f7764 == null);
        ᵣˊˈᵪ r14 = new ᵣˊˈᵪ(2, "DefaultHlsPlaylistTracker:MultivariantPlaylist");
        c1952.f7764 = r14;
        r14.ᵵᵬᵽ(c3026, c1952, c1952.f7771.m3345(c3026.f11645));
    }

    @Override // defpackage.InterfaceC5412
    /* JADX INFO: renamed from: ˋˈ */
    public final synchronized void mo3197(C4838 c4838) {
        this.f16914 = c4838;
    }

    @Override // defpackage.AbstractC5108
    /* JADX INFO: renamed from: ᵜᵪʾ */
    public final void mo3199() {
        C1952 c1952 = this.f16905;
        c1952.f7767 = null;
        c1952.f7766 = null;
        c1952.f7770 = null;
        c1952.f7774 = null;
        c1952.f7765 = null;
        c1952.f7763 = null;
        c1952.f7762 = null;
        c1952.f7761 = null;
        c1952.f7777 = -9223372036854775807L;
        c1952.f7764.ˊᵾʽʼ((InterfaceC1158) null);
        c1952.f7764 = null;
        HashMap map = c1952.f7775;
        Iterator it = map.values().iterator();
        while (it.hasNext()) {
            Iterator it2 = ((C1981) it.next()).f7852.values().iterator();
            while (it2.hasNext()) {
                ((C2163) it2.next()).f8609.ˊᵾʽʼ((InterfaceC1158) null);
            }
        }
        c1952.f7769.removeCallbacksAndMessages(null);
        c1952.f7769 = null;
        map.clear();
        this.f16904.mo5541();
    }

    /* JADX INFO: renamed from: ᵨᵼⁱ, reason: contains not printable characters */
    public final void m9446(C3096 c3096) {
        long j;
        C2266 c2266;
        boolean z;
        long jM3214;
        long j2;
        long jM32142;
        long j3;
        boolean z2 = c3096.f11824;
        boolean z3 = c3096.f11830;
        AbstractC4509 abstractC4509 = c3096.f11815;
        long j4 = c3096.f11816;
        long jM32143 = c3096.f11825;
        int i = c3096.f11832;
        long j5 = c3096.f11817;
        long jM3264 = z2 ? AbstractC0956.m3264(j5) : -9223372036854775807L;
        long j6 = (i == 2 || i == 1) ? jM3264 : -9223372036854775807L;
        C1952 c1952 = this.f16905;
        c1952.f7770.getClass();
        ᵱᵻᵧᵷ r32 = new ᵱᵻᵧᵷ();
        long j7 = 0;
        if (c1952.f7772) {
            C2462 c2462 = c3096.f11819;
            long j8 = j5 - c1952.f7777;
            boolean z4 = c3096.f11826;
            long j9 = z4 ? j8 + j4 : -9223372036854775807L;
            if (c3096.f11824) {
                z = z3;
                jM3214 = AbstractC0956.m3214(AbstractC0956.m3240(this.f16909)) - (j5 + j4);
            } else {
                z = z3;
                jM3214 = 0;
            }
            long j10 = this.f16908.f3235;
            if (j10 != -9223372036854775807L) {
                jM32142 = AbstractC0956.m3214(j10);
            } else {
                if (jM32143 != -9223372036854775807L) {
                    j2 = j4 - jM32143;
                } else {
                    j2 = c2462.f9576;
                    if (j2 == -9223372036854775807L || c3096.f11818 == -9223372036854775807L) {
                        j2 = c2462.f9573;
                        if (j2 == -9223372036854775807L) {
                            j2 = 3 * c3096.f11823;
                        }
                    }
                }
                jM32142 = j2 + jM3214;
            }
            long j11 = j4 + jM3214;
            long jM3267 = AbstractC0956.m3267(jM32142, jM3214, j11);
            C0707 c0707 = mo4076().f18447;
            boolean z5 = c0707.f3236 == -3.4028235E38f && c0707.f3234 == -3.4028235E38f && c2462.f9573 == -9223372036854775807L && c2462.f9576 == -9223372036854775807L;
            C0288 c0288M2557 = this.f16908.m2557();
            c0288M2557.f1931 = AbstractC0956.m3264(jM3267);
            c0288M2557.f1932 = z5 ? 1.0f : this.f16908.f3236;
            c0288M2557.f1930 = z5 ? 1.0f : this.f16908.f3234;
            C0707 c07072 = new C0707(c0288M2557);
            this.f16908 = c07072;
            if (jM32143 == -9223372036854775807L) {
                jM32143 = j11 - AbstractC0956.m3214(c07072.f3235);
            }
            if (z) {
                j7 = jM32143;
            } else {
                C5274 c5274M9445 = m9445(jM32143, c3096.f11814);
                if (c5274M9445 != null) {
                    j3 = c5274M9445.f1916;
                } else if (!abstractC4509.isEmpty()) {
                    C2799 c2799 = (C2799) abstractC4509.get(AbstractC0956.m3237(abstractC4509, Long.valueOf(jM32143), true));
                    C5274 c5274M94452 = m9445(jM32143, c2799.f10745);
                    j3 = c5274M94452 != null ? c5274M94452.f1916 : c2799.f1916;
                }
                j7 = j3;
            }
            c2266 = new C2266(j6, jM3264, j9, c3096.f11816, j8, j7, true, !z4, i == 2 && c3096.f11834, r32, mo4076(), this.f16908);
        } else {
            if (jM32143 == -9223372036854775807L || abstractC4509.isEmpty()) {
                j = 0;
            } else {
                if (!z3 && jM32143 != j4) {
                    jM32143 = ((C2799) abstractC4509.get(AbstractC0956.m3237(abstractC4509, Long.valueOf(jM32143), true))).f1916;
                }
                j = jM32143;
            }
            long j12 = c3096.f11816;
            c2266 = new C2266(j6, jM3264, j12, j12, 0L, j, true, false, true, r32, mo4076(), null);
        }
        m10600(c2266);
    }

    @Override // defpackage.InterfaceC5412
    /* JADX INFO: renamed from: ᵪᵹᵥᵻ */
    public final void mo3201(InterfaceC0472 interfaceC0472) {
        C5223 c5223 = (C5223) interfaceC0472;
        c5223.f19696.f7776.remove(c5223);
        for (C4818 c4818 : c5223.f19692) {
            if (c4818.f18326) {
                for (C3634 c3634 : c4818.f18335) {
                    c3634.m3115();
                    InterfaceC4417 interfaceC4417 = c3634.f3922;
                    if (interfaceC4417 != null) {
                        interfaceC4417.mo4235(c3634.f3934);
                        c3634.f3922 = null;
                        c3634.f3942 = null;
                    }
                }
            }
            C0808 c0808 = c4818.f18364;
            int iMo3733 = c0808.f3613.mo3733();
            C1952 c1952 = c0808.f3625;
            Uri uriM7893 = c0808.f3619[iMo3733].m7893();
            C1981 c1981 = (C1981) c1952.f7775.get(uriM7893);
            if (c1981 != null) {
                C2163 c2163 = (C2163) AbstractC0793.m2881(c1981.f7852, uriM7893, uriM7893);
                c2163.getClass();
                c2163.f8611 = false;
            }
            c0808.f3615 = null;
            c4818.f18350.ˊᵾʽʼ(c4818);
            c4818.f18355.removeCallbacksAndMessages(null);
            c4818.f18336 = true;
            c4818.f18370.clear();
        }
        c5223.f19688 = null;
    }

    @Override // defpackage.InterfaceC5412
    /* JADX INFO: renamed from: ᵵᵽ */
    public final synchronized C4838 mo4076() {
        return this.f16914;
    }

    @Override // defpackage.InterfaceC5412
    /* JADX INFO: renamed from: ᵶᵥᵝ */
    public final void mo5530() throws ParserException {
        C1952 c1952 = this.f16905;
        ᵣˊˈᵪ r0 = c1952.f7764;
        if (r0 != null) {
            r0.ʽˈˋ();
        }
        ParserException parserException = c1952.f7761;
        if (parserException != null) {
            throw parserException;
        }
        Uri uri = c1952.f7767;
        if (uri != null) {
            c1952.m5232(uri);
        }
    }

    @Override // defpackage.InterfaceC5412
    /* JADX INFO: renamed from: ᵻˈᵦʼ */
    public final InterfaceC0472 mo3203(C4100 c4100, ᵣˊˈᵪ r16, long j) {
        C1404 c1404M10599 = m10599(c4100);
        C3317 c3317 = new C3317(this.f19241.f12748, 0, c4100);
        C4216 c4216 = this.f16912;
        C2136 c2136 = this.f19237;
        c2136.getClass();
        return new C5223(this.f16910, this.f16905, this.f16915, c4216, this.f16904, c3317, this.f16913, c1404M10599, r16, this.f16911, this.f16907, this.f16906, c2136);
    }
}
