package defpackage;

import android.net.Uri;
import android.os.Handler;
import android.os.Looper;
import android.os.SystemClock;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Map;
import java.util.regex.Matcher;

/* renamed from: ˊʼ, reason: contains not printable characters */
/* loaded from: classes3.dex */
public final class C1270 extends AbstractC3587 implements InterfaceC1426 {

    /* renamed from: ˀᵗᵩ, reason: contains not printable characters */
    public C3873 f5264;

    /* renamed from: ˁˑᵰ, reason: contains not printable characters */
    public final C4782 f5265;

    /* renamed from: ˆᵼᵷˊ, reason: contains not printable characters */
    public long f5266;

    /* renamed from: ˊᵸˊ, reason: contains not printable characters */
    public InterfaceC4619 f5267;

    /* renamed from: ˌᵪ, reason: contains not printable characters */
    public Handler f5268;

    /* renamed from: ˎˑː, reason: contains not printable characters */
    public final InterfaceC1731 f5269;

    /* renamed from: ˑᵝﹳᵜ, reason: contains not printable characters */
    public ᵧˉʙ f5270;

    /* renamed from: ˑᵥˁ, reason: contains not printable characters */
    public final Uri f5271;

    /* renamed from: ᐧﾞ, reason: contains not printable characters */
    public final C1899 f5272;

    /* renamed from: ᵙᵢᵨᵳ, reason: contains not printable characters */
    public final ArrayList f5273;

    /* renamed from: ᵛˈᵤ, reason: contains not printable characters */
    public C1374 f5274;

    /* renamed from: ᵡˎ, reason: contains not printable characters */
    public final boolean f5275;

    /* renamed from: ᵡᵘˎʽ, reason: contains not printable characters */
    public InterfaceC2569 f5276;

    /* renamed from: ᵧـˌᵎ, reason: contains not printable characters */
    public final ˉːᵡ f5277;

    /* renamed from: ᵮᵠـˌ, reason: contains not printable characters */
    public final C4118 f5278;

    /* renamed from: ᵳᵹᵺˋ, reason: contains not printable characters */
    public C0346 f5279;

    /* renamed from: ᵶʔᵢˊ, reason: contains not printable characters */
    public final long f5280;

    /* renamed from: ᵺʙ, reason: contains not printable characters */
    public final InterfaceC0687 f5281;

    /* renamed from: ﾞⁱ, reason: contains not printable characters */
    public final InterfaceC4068 f5282;

    static {
        AbstractC2483.m6325("media3.exoplayer.smoothstreaming");
    }

    public C1270(C0346 c0346, InterfaceC1731 interfaceC1731, InterfaceC4068 interfaceC4068, C4118 c4118, ˉːᵡ r8, InterfaceC0687 interfaceC0687, C1899 c1899, long j) {
        this.f5279 = c0346;
        C4962 c4962 = c0346.f2063;
        c4962.getClass();
        Uri uriWithAppendedPath = c4962.f18441;
        this.f5274 = null;
        if (uriWithAppendedPath.equals(Uri.EMPTY)) {
            uriWithAppendedPath = null;
        } else {
            String path = uriWithAppendedPath.getPath();
            if (path != null) {
                Matcher matcher = AbstractC3558.f13326.matcher(path);
                if (matcher.matches() && matcher.group(1) == null) {
                    uriWithAppendedPath = Uri.withAppendedPath(uriWithAppendedPath, "Manifest");
                }
            }
        }
        this.f5271 = uriWithAppendedPath;
        this.f5269 = interfaceC1731;
        this.f5282 = interfaceC4068;
        this.f5278 = c4118;
        this.f5277 = r8;
        this.f5281 = interfaceC0687;
        this.f5272 = c1899;
        this.f5280 = j;
        this.f5265 = m8200(null);
        this.f5275 = false;
        this.f5273 = new ArrayList();
    }

    @Override // defpackage.InterfaceC1426
    /* renamed from: ˁˑᵰ */
    public final C3160 mo3510(InterfaceC0452 interfaceC0452, long j, long j2, IOException iOException, int i) {
        C3934 c3934 = (C3934) interfaceC0452;
        long j3 = c3934.f14854;
        C4179 c4179 = c3934.f14852;
        C0186 c0186 = c3934.f14855;
        C0417 c0417 = new C0417(c4179, c0186.f1631, c0186.f1630, j, j2, c0186.f1628);
        int i2 = c3934.f14856;
        long jM5318 = this.f5272.m5318(new C2124(i, 5, iOException));
        C3160 c3160 = jM5318 == -9223372036854775807L ? ᵧˉʙ.ˑᵥˁ : new C3160(0, jM5318, false);
        this.f5265.m10083(c0417, i2, iOException, !c3160.m7518());
        return c3160;
    }

    @Override // defpackage.InterfaceC1426
    /* renamed from: ˌʾˀ */
    public final void mo3512(InterfaceC0452 interfaceC0452, long j, long j2) {
        C3934 c3934 = (C3934) interfaceC0452;
        long j3 = c3934.f14854;
        C4179 c4179 = c3934.f14852;
        C0186 c0186 = c3934.f14855;
        C0417 c0417 = new C0417(c4179, c0186.f1631, c0186.f1630, j, j2, c0186.f1628);
        this.f5272.getClass();
        this.f5265.m10099(c0417, c3934.f14856);
        this.f5274 = (C1374) c3934.f14851;
        this.f5266 = j - j2;
        m3826();
        if (this.f5274.f5656) {
            this.f5268.postDelayed(new RunnableC1600(14, this), Math.max(0L, (this.f5266 + 5000) - SystemClock.elapsedRealtime()));
        }
    }

    @Override // defpackage.InterfaceC4865
    /* renamed from: ˎˏʜʾ */
    public final InterfaceC3757 mo2928(C2477 c2477, ᵧˉʙ r13, long j) {
        C4782 c4782M8200 = m8200(c2477);
        C2221 c2221 = new C2221(this.f13402.f8731, 0, c2477);
        C2843 c2843 = new C2843(this.f5274, this.f5278, this.f5264, this.f5277, this.f5281, c2221, this.f5272, c4782M8200, this.f5267, r13);
        this.f5273.add(c2843);
        return c2843;
    }

    @Override // defpackage.InterfaceC1426
    /* renamed from: ˏˋٴ */
    public final void mo3514(InterfaceC0452 interfaceC0452, long j, long j2, boolean z) {
        C3934 c3934 = (C3934) interfaceC0452;
        long j3 = c3934.f14854;
        C4179 c4179 = c3934.f14852;
        C0186 c0186 = c3934.f14855;
        C0417 c0417 = new C0417(c4179, c0186.f1631, c0186.f1630, j, j2, c0186.f1628);
        this.f5272.getClass();
        this.f5265.m10086(c0417, c3934.f14856, -1, null, 0, null, -9223372036854775807L, -9223372036854775807L);
    }

    @Override // defpackage.AbstractC3587
    /* renamed from: ˑᵱ */
    public final void mo2929(C3873 c3873) {
        this.f5264 = c3873;
        Looper looperMyLooper = Looper.myLooper();
        C1545 c1545 = this.f13397;
        c1545.getClass();
        InterfaceC0687 interfaceC0687 = this.f5281;
        interfaceC0687.mo2673(looperMyLooper, c1545);
        interfaceC0687.mo2670();
        if (this.f5275) {
            this.f5267 = new ᵥᵵ(29);
            m3826();
            return;
        }
        this.f5276 = this.f5269.mo4930();
        ᵧˉʙ r3 = new ᵧˉʙ(2, "SsMediaSource");
        this.f5270 = r3;
        this.f5267 = r3;
        this.f5268 = AbstractC3558.m8130(null);
        m3825();
    }

    @Override // defpackage.AbstractC3587
    /* renamed from: ᵢˇᵭ */
    public final void mo2930() {
        this.f5274 = this.f5275 ? this.f5274 : null;
        this.f5276 = null;
        this.f5266 = 0L;
        ᵧˉʙ r0 = this.f5270;
        if (r0 != null) {
            r0.ˁˑᵰ((InterfaceC2428) null);
            this.f5270 = null;
        }
        Handler handler = this.f5268;
        if (handler != null) {
            handler.removeCallbacksAndMessages(null);
            this.f5268 = null;
        }
        this.f5281.mo2672();
    }

    /* renamed from: ᵤᵙᵷ, reason: contains not printable characters */
    public final void m3825() {
        if (this.f5270.ˎˑː()) {
            return;
        }
        Map map = Collections.EMPTY_MAP;
        Uri uri = this.f5271;
        ᵛᵾˏ.ᵨᵳʝ(uri, "The uri must be set.");
        C3934 c3934 = new C3934(this.f5276, new C4179(uri, 1, null, map, 0L, -1L, null, 1), 4, this.f5282);
        this.f5270.ᵡᵘˎʽ(c3934, this, this.f5272.m5319(c3934.f14856));
    }

    @Override // defpackage.InterfaceC4865
    /* renamed from: ᵪʩ */
    public final synchronized void mo2931(C0346 c0346) {
        this.f5279 = c0346;
    }

    @Override // defpackage.InterfaceC4865
    /* renamed from: ᵳٴᵶ */
    public final void mo2932(InterfaceC3757 interfaceC3757) {
        C2843 c2843 = (C2843) interfaceC3757;
        for (C3341 c3341 : c2843.f10946) {
            c3341.m7734(null);
        }
        c2843.f10944 = null;
        this.f5273.remove(interfaceC3757);
    }

    @Override // defpackage.InterfaceC4865
    /* renamed from: ᵸˑ */
    public final void mo2933() {
        this.f5267.mo5627();
    }

    @Override // defpackage.InterfaceC4865
    /* renamed from: ᵹᵝᵶ */
    public final synchronized C0346 mo2934() {
        return this.f5279;
    }

    /* renamed from: ᵾᵬ, reason: contains not printable characters */
    public final void m3826() {
        C4260 c4260;
        boolean z;
        C5300[] c5300Arr;
        boolean z2 = false;
        int i = 0;
        while (true) {
            ArrayList arrayList = this.f5273;
            if (i >= arrayList.size()) {
                break;
            }
            C2843 c2843 = (C2843) arrayList.get(i);
            C1374 c1374 = this.f5274;
            c2843.f10942 = c1374;
            for (C3341 c3341 : c2843.f10946) {
                C2614 c2614 = (C2614) c3341.f12473;
                C5300[] c5300Arr2 = c2614.f10111.f5651;
                int i2 = c2614.f10114;
                C5300 c5300 = c5300Arr2[i2];
                int i3 = c5300.f19836;
                long[] jArr = c5300.f19833;
                C5300 c53002 = c1374.f5651[i2];
                if (i3 == 0 || c53002.f19836 == 0) {
                    c2614.f10110 += i3;
                } else {
                    int i4 = i3 - 1;
                    long jM10956 = c5300.m10956(i4) + jArr[i4];
                    long j = c53002.f19833[0];
                    int i5 = c2614.f10110;
                    if (jM10956 <= j) {
                        c2614.f10110 = i5 + i3;
                    } else {
                        c2614.f10110 = AbstractC3558.m8119(jArr, j, true) + i5;
                    }
                }
                c2614.f10111 = c1374;
            }
            InterfaceC1727 interfaceC1727 = c2843.f10944;
            interfaceC1727.getClass();
            interfaceC1727.mo1661(c2843);
            i++;
        }
        C5300[] c5300Arr3 = this.f5274.f5651;
        int length = c5300Arr3.length;
        long jMax = Long.MIN_VALUE;
        int i6 = 0;
        long jMax2 = Long.MAX_VALUE;
        while (i6 < length) {
            C5300 c53003 = c5300Arr3[i6];
            int i7 = c53003.f19836;
            long[] jArr2 = c53003.f19833;
            if (i7 > 0) {
                z = z2;
                c5300Arr = c5300Arr3;
                jMax2 = Math.min(jMax2, jArr2[z ? 1 : 0]);
                int i8 = c53003.f19836 - 1;
                jMax = Math.max(jMax, c53003.m10956(i8) + jArr2[i8]);
            } else {
                z = z2;
                c5300Arr = c5300Arr3;
            }
            i6++;
            z2 = z;
            c5300Arr3 = c5300Arr;
        }
        C1374 c13742 = this.f5274;
        if (jMax2 == Long.MAX_VALUE) {
            long j2 = c13742.f5656 ? -9223372036854775807L : 0L;
            C1374 c13743 = this.f5274;
            boolean z3 = c13743.f5656;
            c4260 = new C4260(j2, 0L, 0L, 0L, true, z3, z3, c13743, mo2934());
        } else if (c13742.f5656) {
            long j3 = c13742.f5655;
            if (j3 != -9223372036854775807L && j3 > 0) {
                jMax2 = Math.max(jMax2, jMax - j3);
            }
            long j4 = jMax2;
            long j5 = jMax - j4;
            long jM8133 = j5 - AbstractC3558.m8133(this.f5280);
            if (jM8133 < 5000000) {
                jM8133 = Math.min(5000000L, j5 / 2);
            }
            c4260 = new C4260(-9223372036854775807L, j5, j4, jM8133, true, true, true, this.f5274, mo2934());
        } else {
            long j6 = c13742.f5650;
            if (j6 == -9223372036854775807L) {
                j6 = jMax - jMax2;
            }
            long j7 = j6;
            long j8 = jMax2;
            c4260 = new C4260(-9223372036854775807L, -9223372036854775807L, j8 + j7, j7, j8, 0L, true, false, false, this.f5274, mo2934(), null);
        }
        m8197(c4260);
    }

    @Override // defpackage.InterfaceC1426
    /* renamed from: ᵿʗᵝʽ */
    public final void mo3521(InterfaceC0452 interfaceC0452, long j, long j2, int i) {
        C0417 c0417;
        C3934 c3934 = (C3934) interfaceC0452;
        if (i == 0) {
            long j3 = c3934.f14854;
            c0417 = new C0417(c3934.f14852, j);
        } else {
            long j4 = c3934.f14854;
            C4179 c4179 = c3934.f14852;
            C0186 c0186 = c3934.f14855;
            c0417 = new C0417(c4179, c0186.f1631, c0186.f1630, j, j2, c0186.f1628);
        }
        this.f5265.m10089(c0417, c3934.f14856, -1, null, 0, null, -9223372036854775807L, -9223372036854775807L, i);
    }
}
