package defpackage;

import android.net.Uri;
import android.os.Handler;
import android.os.Looper;
import android.os.SystemClock;
import android.util.SparseArray;
import androidx.media3.exoplayer.source.BehindLiveWindowException;
import java.io.IOException;
import java.math.RoundingMode;
import java.util.ArrayList;
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 C4002 extends AbstractC5108 {

    /* JADX INFO: renamed from: ʽᵡᵢᵾ, reason: contains not printable characters */
    public final SparseArray f15334;

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

    /* JADX INFO: renamed from: ʿᵿʽᵞ, reason: contains not printable characters */
    public Handler f15336;

    /* JADX INFO: renamed from: ˀᵗ, reason: contains not printable characters */
    public ᵣˊˈᵪ f15337;

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

    /* JADX INFO: renamed from: ˁʢᵛ, reason: contains not printable characters */
    public InterfaceC1070 f15339;

    /* JADX INFO: renamed from: ˁˌᵩ, reason: contains not printable characters */
    public final ᵥᵵᵶᵩ f15340;

    /* JADX INFO: renamed from: ˁᵺˈ, reason: contains not printable characters */
    public long f15341;

    /* JADX INFO: renamed from: ˈⁱᵡ, reason: contains not printable characters */
    public final RunnableC2689 f15342;

    /* JADX INFO: renamed from: ˉˆᵗ, reason: contains not printable characters */
    public boolean f15343;

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

    /* JADX INFO: renamed from: ˊˌˊ, reason: contains not printable characters */
    public final InterfaceC3244 f15345;

    /* JADX INFO: renamed from: ˊᵡᵗʨ, reason: contains not printable characters */
    public final C1404 f15346;

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

    /* JADX INFO: renamed from: ˋʿᐧ, reason: contains not printable characters */
    public C2906 f15348;

    /* JADX INFO: renamed from: ˋᵯᵩ, reason: contains not printable characters */
    public long f15349;

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

    /* JADX INFO: renamed from: ˏᵩʨ, reason: contains not printable characters */
    public C4216 f15351;

    /* JADX INFO: renamed from: ːᵝٴᵶ, reason: contains not printable characters */
    public int f15352;

    /* JADX INFO: renamed from: ˑʢ, reason: contains not printable characters */
    public final Object f15353;

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

    /* JADX INFO: renamed from: ᵗᵭ, reason: contains not printable characters */
    public long f15355;

    /* JADX INFO: renamed from: ᵛˀˊ, reason: contains not printable characters */
    public IOException f15356;

    /* JADX INFO: renamed from: ᵛˑﹳ, reason: contains not printable characters */
    public final InterfaceC2793 f15357;

    /* JADX INFO: renamed from: ᵜᵤ, reason: contains not printable characters */
    public long f15358;

    /* JADX INFO: renamed from: ᵞᵛᵘ, reason: contains not printable characters */
    public final C5306 f15359;

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

    /* JADX INFO: renamed from: ᵡᵶ, reason: contains not printable characters */
    public Uri f15361;

    /* JADX INFO: renamed from: ᵡᵶᵬʤ, reason: contains not printable characters */
    public final Uri f15362;

    /* JADX INFO: renamed from: ᵨˈʼﹶ, reason: contains not printable characters */
    public final RunnableC2689 f15363;

    /* JADX INFO: renamed from: ᵫˈᵹ, reason: contains not printable characters */
    public int f15364;

    /* JADX INFO: renamed from: ᵬᵦˋ, reason: contains not printable characters */
    public C0707 f15365;

    /* JADX INFO: renamed from: ᵵᵬᵽ, reason: contains not printable characters */
    public final ᵧᵙᵤ f15366;

    /* JADX INFO: renamed from: ᵵᵸᵕᵸ, reason: contains not printable characters */
    public C4838 f15367;

    /* JADX INFO: renamed from: ᵸˆˁ, reason: contains not printable characters */
    public final InterfaceC1479 f15368;

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

    /* JADX WARN: Type inference failed for: r2v10, types: [ᵙᵿʙˊ] */
    /* JADX WARN: Type inference failed for: r2v11, types: [ᵙᵿʙˊ] */
    public C4002(C4838 c4838, InterfaceC1479 interfaceC1479, InterfaceC2793 interfaceC2793, C1404 c1404, C3814 c3814, InterfaceC4636 interfaceC4636, C1013 c1013, long j, long j2) {
        this.f15367 = c4838;
        this.f15365 = c4838.f18447;
        C4574 c4574 = c4838.f18446;
        c4574.getClass();
        Uri uri = c4574.f17386;
        this.f15361 = uri;
        this.f15362 = uri;
        this.f15348 = null;
        this.f15368 = interfaceC1479;
        this.f15357 = interfaceC2793;
        this.f15354 = c1404;
        this.f15360 = interfaceC4636;
        this.f15344 = c1013;
        this.f15338 = j;
        this.f15347 = j2;
        this.f15335 = c3814;
        this.f15340 = new ᵥᵵᵶᵩ(6);
        final int i = 0;
        this.f15350 = false;
        this.f15346 = m10599(null);
        this.f15353 = new Object();
        this.f15334 = new SparseArray();
        this.f15359 = new C5306(this);
        this.f15355 = -9223372036854775807L;
        this.f15358 = -9223372036854775807L;
        this.f15366 = new ᵧᵙᵤ(13, this);
        this.f15345 = new C4111(this);
        this.f15342 = new Runnable(this) { // from class: ᵙᵿʙˊ

            /* JADX INFO: renamed from: ᵜᵪʾ, reason: contains not printable characters */
            public final /* synthetic */ C4002 f10359;

            {
                this.f10359 = this;
            }

            @Override // java.lang.Runnable
            public final void run() {
                int i2 = i;
                C4002 c4002 = this.f10359;
                switch (i2) {
                    case 0:
                        c4002.m8791();
                        break;
                    default:
                        try {
                            c4002.m8793(false);
                        } catch (Exception e) {
                            c4002.f15356 = new IOException(e);
                        }
                        break;
                }
            }
        };
        final int i2 = 1;
        this.f15363 = new Runnable(this) { // from class: ᵙᵿʙˊ

            /* JADX INFO: renamed from: ᵜᵪʾ, reason: contains not printable characters */
            public final /* synthetic */ C4002 f10359;

            {
                this.f10359 = this;
            }

            @Override // java.lang.Runnable
            public final void run() {
                int i22 = i2;
                C4002 c4002 = this.f10359;
                switch (i22) {
                    case 0:
                        c4002.m8791();
                        break;
                    default:
                        try {
                            c4002.m8793(false);
                        } catch (Exception e) {
                            c4002.f15356 = new IOException(e);
                        }
                        break;
                }
            }
        };
    }

    /* JADX INFO: renamed from: ᵨᵼⁱ, reason: contains not printable characters */
    public static boolean m8785(C1736 c1736) {
        List list = c1736.f6965;
        for (int i = 0; i < list.size(); i++) {
            int i2 = ((C2104) list.get(i)).f8363;
            if (i2 == 1 || i2 == 2) {
                return true;
            }
        }
        return false;
    }

    /* JADX INFO: renamed from: ʿٴˇ, reason: contains not printable characters */
    public final synchronized void m8786(C0707 c0707) {
        this.f15365 = c0707;
    }

    /* JADX INFO: renamed from: ˈᵲᵢ, reason: contains not printable characters */
    public final void m8787(C3026 c3026, long j, long j2) {
        long j3 = c3026.f11644;
        C0084 c0084 = c3026.f11646;
        C0165 c0165 = c3026.f11647;
        C3622 c3622 = new C3622(c0084, c0165.f1575, c0165.f1577, j, j2, c0165.f1576);
        this.f15344.getClass();
        this.f15346.m4045(c3622, c3026.f11645, -1, null, 0, null, -9223372036854775807L, -9223372036854775807L);
    }

    @Override // defpackage.AbstractC5108
    /* JADX INFO: renamed from: ˊᵨᵧ */
    public final void mo4070(C4216 c4216) {
        this.f15351 = c4216;
        Looper looperMyLooper = Looper.myLooper();
        C2136 c2136 = this.f19237;
        c2136.getClass();
        InterfaceC4636 interfaceC4636 = this.f15360;
        interfaceC4636.mo5536(looperMyLooper, c2136);
        interfaceC4636.mo5540();
        if (this.f15350) {
            m8793(false);
            return;
        }
        this.f15339 = this.f15368.mo4241();
        this.f15337 = new ᵣˊˈᵪ(2, "DashMediaSource");
        this.f15336 = AbstractC0956.m3260(null);
        m8791();
    }

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

    /* JADX INFO: renamed from: ˌᵨʠᵫ, reason: contains not printable characters */
    public final void m8788(IOException iOException) {
        ˋˀᵧ.ˋˈ("Failed to resolve time offset.", iOException);
        this.f15358 = System.currentTimeMillis() - SystemClock.elapsedRealtime();
        m8793(true);
    }

    /* JADX INFO: renamed from: ˑˊᵲ, reason: contains not printable characters */
    public final void m8789(C0946 c0946, InterfaceC2793 interfaceC2793) {
        InterfaceC1070 interfaceC1070 = this.f15339;
        Uri uri = Uri.parse(c0946.f4110);
        Map map = Collections.EMPTY_MAP;
        ᵻᵪ.ᵱʡˏ(uri, "The uri must be set.");
        this.f15337.ᵵᵬᵽ(new C3026(interfaceC1070, new C0084(uri, 1, null, map, 0L, -1L, null, 1), 5, interfaceC2793), new C5306(this), 1);
    }

    /* JADX INFO: renamed from: ᵔᵖᵹᵫ, reason: contains not printable characters */
    public final synchronized C0707 m8790() {
        return this.f15365;
    }

    @Override // defpackage.AbstractC5108
    /* JADX INFO: renamed from: ᵜᵪʾ */
    public final void mo3199() {
        this.f15343 = false;
        this.f15339 = null;
        ᵣˊˈᵪ r2 = this.f15337;
        if (r2 != null) {
            r2.ˊᵾʽʼ((InterfaceC1158) null);
            this.f15337 = null;
        }
        C0707 c0707 = mo4076().f18447;
        synchronized (this) {
            this.f15365 = c0707;
        }
        this.f15341 = 0L;
        this.f15349 = 0L;
        this.f15361 = this.f15362;
        this.f15356 = null;
        Handler handler = this.f15336;
        if (handler != null) {
            handler.removeCallbacksAndMessages(null);
            this.f15336 = null;
        }
        this.f15358 = -9223372036854775807L;
        this.f15352 = 0;
        this.f15355 = -9223372036854775807L;
        this.f15334.clear();
        ᵥᵵᵶᵩ r0 = this.f15340;
        ((HashMap) r0.ᵜᵪʾ).clear();
        ((HashMap) r0.ᵔᵖᵹᵫ).clear();
        ((HashMap) r0.ᵨᵼⁱ).clear();
        this.f15360.mo5541();
    }

    /* JADX INFO: renamed from: ᵠˏˏ, reason: contains not printable characters */
    public final void m8791() {
        Uri uri;
        this.f15336.removeCallbacks(this.f15342);
        if (this.f15337.ˑˊᵲ()) {
            return;
        }
        if (this.f15337.ᵠˏˏ()) {
            this.f15343 = true;
            return;
        }
        synchronized (this.f15353) {
            uri = this.f15361;
        }
        this.f15343 = false;
        Map map = Collections.EMPTY_MAP;
        ᵻᵪ.ᵱʡˏ(uri, "The uri must be set.");
        C3026 c3026 = new C3026(this.f15339, new C0084(uri, 1, null, map, 0L, -1L, null, 1), 4, this.f15357);
        ᵧᵙᵤ r1 = this.f15366;
        this.f15344.getClass();
        this.f15337.ᵵᵬᵽ(c3026, r1, 3);
    }

    @Override // defpackage.InterfaceC5412
    /* JADX INFO: renamed from: ᵪᵹᵥᵻ */
    public final void mo3201(InterfaceC0472 interfaceC0472) {
        C2523 c2523 = (C2523) interfaceC0472;
        C4627 c4627 = c2523.f9749;
        c4627.f17602 = true;
        c4627.f17599.removeCallbacksAndMessages(null);
        for (C4245 c4245 : c2523.f9758) {
            c4245.m9216(c2523);
        }
        c2523.f9751 = null;
        this.f15334.remove(c2523.f9753);
    }

    /* JADX INFO: renamed from: ᵯᵷʽ, reason: contains not printable characters */
    public final void m8792() {
        boolean z;
        ᵣˊˈᵪ r0 = this.f15337;
        C4111 c4111 = new C4111(this);
        synchronized (ᵥˈᵛ.ːˏᵟᵯ) {
            z = ᵥˈᵛ.ᵷᵺʾᵖ;
        }
        if (z) {
            c4111.m8966();
            return;
        }
        if (r0 == null) {
            r0 = new ᵣˊˈᵪ(2, "SntpClient");
        }
        r0.ᵵᵬᵽ(new ᵖˊʨ(8), new ᵢʒʡᵟ(27, c4111), 1);
    }

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

    @Override // defpackage.InterfaceC5412
    /* JADX INFO: renamed from: ᵶᵥᵝ */
    public final void mo5530() {
        this.f15345.mo7395();
    }

    /* JADX WARN: Code restructure failed: missing block: B:72:0x01a0, code lost:
    
        r14 = r14;
     */
    /* JADX WARN: Removed duplicated region for block: B:118:0x028e  */
    /* JADX WARN: Removed duplicated region for block: B:133:0x02d6  */
    /* JADX WARN: Removed duplicated region for block: B:166:0x0340  */
    /* JADX WARN: Removed duplicated region for block: B:203:0x03ec  */
    /* JADX WARN: Removed duplicated region for block: B:205:0x03f3  */
    /* JADX INFO: renamed from: ᵸˆˁ, reason: contains not printable characters */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final void m8793(boolean z) {
        C1736 c1736;
        long j;
        long j2;
        C4002 c4002;
        long j3;
        boolean z2;
        long jMax;
        boolean z3;
        long j4;
        long j5;
        C1736 c17362;
        long j6;
        int i;
        long jMin;
        C0707 c0707;
        float f;
        long j7;
        float f2;
        long j8;
        SparseArray sparseArray;
        int i2;
        boolean z4;
        SparseArray sparseArray2;
        C4245[] c4245Arr;
        RunnableC2689 runnableC2689 = this.f15363;
        long j9 = this.f15347;
        SparseArray sparseArray3 = this.f15334;
        boolean z5 = false;
        int i3 = 0;
        while (i3 < sparseArray3.size()) {
            int iKeyAt = sparseArray3.keyAt(i3);
            if (iKeyAt >= this.f15364) {
                C2523 c2523 = (C2523) sparseArray3.valueAt(i3);
                C2906 c2906 = this.f15348;
                int i4 = iKeyAt - this.f15364;
                c2523.f9741 = c2906;
                c2523.f9748 = i4;
                C4627 c4627 = c2523.f9749;
                c4627.f17596 = z5;
                c4627.f17601 = c2906;
                Iterator it = c4627.f17600.entrySet().iterator();
                while (it.hasNext()) {
                    int i5 = i3;
                    if (((Long) ((Map.Entry) it.next()).getKey()).longValue() < c4627.f17601.f11176) {
                        it.remove();
                    }
                    i3 = i5;
                }
                i2 = i3;
                C4245[] c4245Arr2 = c2523.f9758;
                if (c4245Arr2 != null) {
                    int length = c4245Arr2.length;
                    int i6 = 0;
                    while (i6 < length) {
                        C4187 c4187 = (C4187) c4245Arr2[i6].f16197;
                        C2693[] c2693Arr = c4187.f15981;
                        try {
                            c4187.f15979 = c2906;
                            c4187.f15975 = i4;
                            long jM6972 = c2906.m6972(i4);
                            try {
                                ArrayList arrayListM9119 = c4187.m9119();
                                sparseArray2 = sparseArray3;
                                c4245Arr = c4245Arr2;
                                int i7 = 0;
                                while (i7 < c2693Arr.length) {
                                    try {
                                        C2693[] c2693Arr2 = c2693Arr;
                                        c2693Arr2[i7] = c2693Arr2[i7].m6502(jM6972, (AbstractC0841) arrayListM9119.get(c4187.f15976.mo3741(i7)));
                                        i7++;
                                        c2693Arr = c2693Arr2;
                                    } catch (BehindLiveWindowException e) {
                                        e = e;
                                        c4187.f15973 = e;
                                    }
                                }
                            } catch (BehindLiveWindowException e2) {
                                e = e2;
                                sparseArray2 = sparseArray3;
                                c4245Arr = c4245Arr2;
                            }
                        } catch (BehindLiveWindowException e3) {
                            e = e3;
                            sparseArray2 = sparseArray3;
                            c4245Arr = c4245Arr2;
                        }
                        i6++;
                        sparseArray3 = sparseArray2;
                        c4245Arr2 = c4245Arr;
                    }
                    sparseArray = sparseArray3;
                    z4 = true;
                    c2523.f9751.mo3794(c2523);
                } else {
                    sparseArray = sparseArray3;
                    z4 = true;
                }
                c2523.f9762 = c2906.m6970(i4).f6967;
                for (C1966 c1966 : c2523.f9765) {
                    Iterator it2 = c2523.f9762.iterator();
                    while (true) {
                        if (it2.hasNext()) {
                            C2316 c2316 = (C2316) it2.next();
                            if (c2316.m5959().equals(c1966.f7810.m5959())) {
                                c1966.m5317(c2316, (c2906.f11185 && i4 == c2906.f11178.size() + (-1)) ? z4 : false);
                            }
                        }
                    }
                }
            } else {
                sparseArray = sparseArray3;
                i2 = i3;
            }
            i3 = i2 + 1;
            sparseArray3 = sparseArray;
            z5 = false;
        }
        int i8 = 1;
        C1736 c1736M6970 = this.f15348.m6970(0);
        int size = this.f15348.f11178.size() - 1;
        C1736 c1736M69702 = this.f15348.m6970(size);
        long jM69722 = this.f15348.m6972(size);
        long jM3214 = AbstractC0956.m3214(AbstractC0956.m3240(this.f15358));
        long jM69723 = this.f15348.m6972(0);
        long j10 = c1736M6970.f6964;
        List list = c1736M6970.f6965;
        long jM32142 = AbstractC0956.m3214(j10);
        boolean zM8785 = m8785(c1736M6970);
        int i9 = 0;
        while (true) {
            c1736 = c1736M6970;
            if (i9 >= list.size()) {
                j = 0;
                break;
            }
            C2104 c2104 = (C2104) list.get(i9);
            j = 0;
            List list2 = c2104.f8364;
            int i10 = c2104.f8363;
            boolean z6 = (i10 == i8 || i10 == 2) ? false : true;
            if ((!zM8785 || !z6) && !list2.isEmpty()) {
                InterfaceC1674 interfaceC1674Mo2987 = ((AbstractC0841) list2.get(0)).mo2987();
                if (interfaceC1674Mo2987 == null || interfaceC1674Mo2987.mo3003(jM69723, jM3214) == 0) {
                    break;
                } else {
                    jM32142 = Math.max(jM32142, interfaceC1674Mo2987.mo3007(interfaceC1674Mo2987.mo3010(jM69723, jM3214)) + jM32142);
                }
            }
            i9++;
            i8 = 1;
            c1736M6970 = c1736;
        }
        long j11 = c1736M69702.f6964;
        List list3 = c1736M69702.f6965;
        long jM32143 = AbstractC0956.m3214(j11);
        boolean zM87852 = m8785(c1736M69702);
        long jMin2 = Long.MAX_VALUE;
        int i11 = 0;
        while (true) {
            if (i11 >= list3.size()) {
                j2 = jM32142;
                c4002 = this;
                j3 = jMin2;
                break;
            }
            C2104 c21042 = (C2104) list3.get(i11);
            long j12 = jM32143;
            List list4 = c21042.f8364;
            int i12 = c21042.f8363;
            boolean z7 = (i12 == 1 || i12 == 2) ? false : true;
            if ((zM87852 && z7) || list4.isEmpty()) {
                j8 = jM32142;
            } else {
                InterfaceC1674 interfaceC1674Mo29872 = ((AbstractC0841) list4.get(0)).mo2987();
                if (interfaceC1674Mo29872 == null) {
                    j3 = j12 + jM69722;
                    c4002 = this;
                    j2 = jM32142;
                    break;
                }
                long jMo3003 = interfaceC1674Mo29872.mo3003(jM69722, jM3214);
                if (jMo3003 == j) {
                    c4002 = this;
                    j2 = jM32142;
                    j3 = j12;
                    break;
                } else {
                    j8 = jM32142;
                    long jMo3010 = (interfaceC1674Mo29872.mo3010(jM69722, jM3214) + jMo3003) - 1;
                    jMin2 = Math.min(jMin2, interfaceC1674Mo29872.mo3002(jMo3010, jM69722) + interfaceC1674Mo29872.mo3007(jMo3010) + j12);
                }
            }
            i11++;
            jM32143 = j12;
            jM32142 = j8;
        }
        if (!c4002.f15348.f11185) {
            z2 = false;
            break;
        }
        for (int i13 = 0; i13 < list3.size(); i13++) {
            InterfaceC1674 interfaceC1674Mo29873 = ((AbstractC0841) ((C2104) list3.get(i13)).f8364.get(0)).mo2987();
            if (interfaceC1674Mo29873 == null || interfaceC1674Mo29873.mo3004()) {
                z2 = false;
                break;
            }
        }
        z2 = true;
        if (z2) {
            long j13 = c4002.f15348.f11187;
            jMax = j13 != -9223372036854775807L ? Math.max(j2, j3 - AbstractC0956.m3214(j13)) : j2;
        }
        long j14 = j3 - jMax;
        C2906 c29062 = c4002.f15348;
        if (c29062.f11185) {
            ᵻᵪ.ˌᴵ(c29062.f11182 != -9223372036854775807L);
            long jM32144 = (jM3214 - AbstractC0956.m3214(c4002.f15348.f11182)) - jMax;
            C0707 c07072 = c4002.mo4076().f18447;
            long jM3264 = AbstractC0956.m3264(jM32144);
            j4 = -9223372036854775807L;
            long j15 = c07072.f3233;
            if (j15 != -9223372036854775807L) {
                jMin = Math.min(jM3264, j15);
            } else {
                C0288 c0288 = c4002.f15348.f11181;
                if (c0288 != null) {
                    long j16 = c0288.f1929;
                    jMin = j16 != -9223372036854775807L ? Math.min(jM3264, j16) : jM3264;
                }
            }
            long jM32642 = AbstractC0956.m3264(jM32144 - j14);
            if (jM32642 < j && jMin > j) {
                jM32642 = j;
            }
            boolean z8 = z2;
            long j17 = c4002.f15348.f11177;
            if (j17 != -9223372036854775807L) {
                jM32642 = Math.min(jM32642 + j17, jM3264);
            }
            long jM3267 = jM32642;
            long j18 = c07072.f3232;
            if (j18 != -9223372036854775807L) {
                jM3267 = AbstractC0956.m3267(j18, jM3267, jM3264);
            } else {
                C0288 c02882 = c4002.f15348.f11181;
                if (c02882 != null) {
                    long j19 = c02882.f1928;
                    if (j19 != -9223372036854775807L) {
                        jM3267 = AbstractC0956.m3267(j19, jM3267, jM3264);
                    }
                }
            }
            long j20 = jM3267;
            long j21 = j20 > jMin ? j20 : jMin;
            synchronized (this) {
                c0707 = c4002.f15365;
            }
            long jM32672 = c0707.f3235;
            if (jM32672 == -9223372036854775807L) {
                C2906 c29063 = c4002.f15348;
                C0288 c02883 = c29063.f11181;
                if (c02883 != null) {
                    long j22 = c02883.f1931;
                    if (j22 != -9223372036854775807L) {
                        jM32672 = j22;
                    } else {
                        jM32672 = c29063.f11183;
                        if (jM32672 == -9223372036854775807L) {
                            jM32672 = c4002.f15338;
                        }
                    }
                }
            }
            if (jM32672 < j20) {
                jM32672 = j20;
            }
            if (jM32672 > j21) {
                jM32672 = AbstractC0956.m3267(AbstractC0956.m3264(jM32144 - Math.min(j9, j14 / 2)), j20, j21);
            }
            long j23 = j21;
            float f3 = c07072.f3236;
            if (f3 == -3.4028235E38f) {
                C0288 c02884 = c4002.f15348.f11181;
                f3 = c02884 != null ? c02884.f1932 : -3.4028235E38f;
            }
            float f4 = c07072.f3234;
            if (f4 == -3.4028235E38f) {
                C0288 c02885 = c4002.f15348.f11181;
                f4 = c02885 != null ? c02885.f1930 : -3.4028235E38f;
            }
            if (f3 == -3.4028235E38f && f4 == -3.4028235E38f) {
                f = f4;
                C0288 c02886 = c4002.f15348.f11181;
                j7 = jM32144;
                z3 = z8;
                if (c02886 == null || c02886.f1931 == -9223372036854775807L) {
                    f3 = 1.0f;
                    f2 = 1.0f;
                }
                C0288 c02887 = new C0288();
                c02887.f1931 = jM32672;
                c02887.f1928 = j20;
                c02887.f1929 = j23;
                c02887.f1932 = f3;
                c02887.f1930 = f2;
                c4002.m8786(new C0707(c02887));
                long jM32643 = AbstractC0956.m3264(jMax) + c4002.f15348.f11182;
                long jM32145 = j7 - AbstractC0956.m3214(c4002.m8790().f3235);
                long jMin3 = Math.min(j9, j14 / 2);
                j6 = jM32145 >= jMin3 ? jMin3 : jM32145;
                j5 = jM32643;
                c17362 = c1736;
            } else {
                f = f4;
                j7 = jM32144;
                z3 = z8;
            }
            f2 = f;
            C0288 c028872 = new C0288();
            c028872.f1931 = jM32672;
            c028872.f1928 = j20;
            c028872.f1929 = j23;
            c028872.f1932 = f3;
            c028872.f1930 = f2;
            c4002.m8786(new C0707(c028872));
            long jM326432 = AbstractC0956.m3264(jMax) + c4002.f15348.f11182;
            long jM321452 = j7 - AbstractC0956.m3214(c4002.m8790().f3235);
            long jMin32 = Math.min(j9, j14 / 2);
            if (jM321452 >= jMin32) {
            }
            j5 = jM326432;
            c17362 = c1736;
        } else {
            z3 = z2;
            j4 = -9223372036854775807L;
            j5 = -9223372036854775807L;
            c17362 = c1736;
            j6 = j;
        }
        long jM32146 = jMax - AbstractC0956.m3214(c17362.f6964);
        C2906 c29064 = c4002.f15348;
        c4002.m10600(new C4157(c29064.f11182, j5, c4002.f15358, c4002.f15364, jM32146, j14, j6, c29064, c4002.mo4076(), c4002.f15348.f11185 ? c4002.m8790() : null));
        if (c4002.f15350) {
            return;
        }
        c4002.f15336.removeCallbacks(runnableC2689);
        if (z3) {
            Handler handler = c4002.f15336;
            C2906 c29065 = c4002.f15348;
            long jM3240 = AbstractC0956.m3240(c4002.f15358);
            int size2 = c29065.f11178.size() - 1;
            C1736 c1736M69703 = c29065.m6970(size2);
            long j24 = c1736M69703.f6964;
            List list5 = c1736M69703.f6965;
            long jM32147 = AbstractC0956.m3214(j24);
            long jM69724 = c29065.m6972(size2);
            long jM32148 = AbstractC0956.m3214(jM3240);
            long jM32149 = AbstractC0956.m3214(c29065.f11182);
            long jM321410 = AbstractC0956.m3214(c29065.f11179);
            if (jM321410 == j4 || jM321410 >= 5000000) {
                jM321410 = 5000000;
            }
            int i14 = 0;
            while (i14 < list5.size()) {
                List list6 = ((C2104) list5.get(i14)).f8364;
                if (list6.isEmpty()) {
                    i = i14;
                } else {
                    i = i14;
                    InterfaceC1674 interfaceC1674Mo29874 = ((AbstractC0841) list6.get(0)).mo2987();
                    if (interfaceC1674Mo29874 != null) {
                        long jMo3008 = (interfaceC1674Mo29874.mo3008(jM69724, jM32148) + (jM32149 + jM32147)) - jM32148;
                        if (jMo3008 > j && (jMo3008 < jM321410 - 100000 || (jMo3008 > jM321410 && jMo3008 < jM321410 + 100000))) {
                            jM321410 = jMo3008;
                        }
                    }
                }
                i14 = i + 1;
            }
            handler.postDelayed(runnableC2689, ᵥˈᵛ.ᵔᵖᵹᵫ(jM321410, 1000L, RoundingMode.CEILING));
        }
        if (c4002.f15343) {
            c4002.m8791();
            return;
        }
        if (z) {
            C2906 c29066 = c4002.f15348;
            if (c29066.f11185) {
                long j25 = c29066.f11179;
                if (j25 != j4) {
                    if (j25 == j) {
                        j25 = 5000;
                    }
                    c4002.f15336.postDelayed(c4002.f15342, Math.max(j, (c4002.f15341 + j25) - SystemClock.elapsedRealtime()));
                }
            }
        }
    }

    @Override // defpackage.InterfaceC5412
    /* JADX INFO: renamed from: ᵻˈᵦʼ */
    public final InterfaceC0472 mo3203(C4100 c4100, ᵣˊˈᵪ r24, long j) {
        int iIntValue = ((Integer) c4100.f15713).intValue() - this.f15364;
        C1404 c1404M10599 = m10599(c4100);
        C3317 c3317 = new C3317(this.f19241.f12748, 0, c4100);
        int i = this.f15364 + iIntValue;
        C2906 c2906 = this.f15348;
        C4216 c4216 = this.f15351;
        long j2 = this.f15358;
        C2136 c2136 = this.f19237;
        c2136.getClass();
        C2523 c2523 = new C2523(i, c2906, this.f15340, iIntValue, this.f15354, c4216, this.f15360, c3317, this.f15344, c1404M10599, j2, this.f15345, r24, this.f15335, this.f15359, c2136);
        this.f15334.put(i, c2523);
        return c2523;
    }
}
