package com.google.android.exoplayer2.source.dash;

import android.net.Uri;
import android.os.Handler;
import android.os.SystemClock;
import android.text.TextUtils;
import android.util.Log;
import android.util.SparseArray;
import com.google.android.exoplayer2.ParserException;
import com.google.android.exoplayer2.upstream.Loader;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.nio.charset.Charset;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Iterator;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.TimeZone;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import p000.p001.p002.p003.p004.C0567;
import p138.p139.p143.p144.C2803;
import p138.p176.p177.p190.AbstractC3457;
import p138.p176.p177.p190.C3414;
import p138.p176.p177.p190.C3430;
import p138.p176.p177.p190.p194.C3531;
import p138.p176.p177.p190.p194.InterfaceC3532;
import p138.p176.p177.p190.p216.C3776;
import p138.p176.p177.p190.p216.C3777;
import p138.p176.p177.p190.p217.AbstractC3790;
import p138.p176.p177.p190.p217.C3794;
import p138.p176.p177.p190.p217.InterfaceC3798;
import p138.p176.p177.p190.p217.InterfaceC3800;
import p138.p176.p177.p190.p217.InterfaceC3803;
import p138.p176.p177.p190.p217.InterfaceC3808;
import p138.p176.p177.p190.p217.p218.C3831;
import p138.p176.p177.p190.p217.p219.C3841;
import p138.p176.p177.p190.p217.p220.C3856;
import p138.p176.p177.p190.p217.p220.C3860;
import p138.p176.p177.p190.p217.p220.C3864;
import p138.p176.p177.p190.p217.p220.C3865;
import p138.p176.p177.p190.p217.p220.InterfaceC3854;
import p138.p176.p177.p190.p217.p220.InterfaceC3858;
import p138.p176.p177.p190.p217.p220.p221.C3869;
import p138.p176.p177.p190.p217.p220.p221.C3870;
import p138.p176.p177.p190.p217.p220.p221.C3871;
import p138.p176.p177.p190.p217.p220.p221.C3874;
import p138.p176.p177.p190.p217.p220.p221.C3875;
import p138.p176.p177.p190.p217.p220.p221.C3890;
import p138.p176.p177.p190.p238.C4098;
import p138.p176.p177.p190.p238.C4108;
import p138.p176.p177.p190.p238.C4112;
import p138.p176.p177.p190.p238.C4114;
import p138.p176.p177.p190.p238.InterfaceC4089;
import p138.p176.p177.p190.p238.InterfaceC4095;
import p138.p176.p177.p190.p238.InterfaceC4109;
import p138.p176.p177.p190.p238.InterfaceC4110;
import p138.p176.p177.p190.p238.InterfaceC4115;
import p138.p176.p177.p190.p239.C4131;
import p138.p176.p177.p190.p239.C4150;

/* JADX INFO: loaded from: classes.dex */
public final class DashMediaSource extends AbstractC3790 {

    /* JADX INFO: renamed from: ވ, reason: contains not printable characters */
    public final boolean f1749;

    /* JADX INFO: renamed from: މ, reason: contains not printable characters */
    public final InterfaceC4095.InterfaceC4096 f1750;

    /* JADX INFO: renamed from: ފ, reason: contains not printable characters */
    public final InterfaceC3854.InterfaceC3855 f1751;

    /* JADX INFO: renamed from: ދ, reason: contains not printable characters */
    public final C3794 f1752;

    /* JADX INFO: renamed from: ތ, reason: contains not printable characters */
    public final InterfaceC3532<?> f1753;

    /* JADX INFO: renamed from: ލ, reason: contains not printable characters */
    public final InterfaceC4109 f1754;

    /* JADX INFO: renamed from: ގ, reason: contains not printable characters */
    public final long f1755;

    /* JADX INFO: renamed from: ޏ, reason: contains not printable characters */
    public final boolean f1756;

    /* JADX INFO: renamed from: ސ, reason: contains not printable characters */
    public final InterfaceC3803.C3804 f1757;

    /* JADX INFO: renamed from: ޑ, reason: contains not printable characters */
    public final C4112.InterfaceC4113<? extends C3870> f1758;

    /* JADX INFO: renamed from: ޒ, reason: contains not printable characters */
    public final C0295 f1759;

    /* JADX INFO: renamed from: ޓ, reason: contains not printable characters */
    public final Object f1760;

    /* JADX INFO: renamed from: ޔ, reason: contains not printable characters */
    public final SparseArray<C3856> f1761;

    /* JADX INFO: renamed from: ޕ, reason: contains not printable characters */
    public final Runnable f1762;

    /* JADX INFO: renamed from: ޖ, reason: contains not printable characters */
    public final Runnable f1763;

    /* JADX INFO: renamed from: ޗ, reason: contains not printable characters */
    public final C3865.InterfaceC3867 f1764;

    /* JADX INFO: renamed from: ޘ, reason: contains not printable characters */
    public final InterfaceC4110 f1765;

    /* JADX INFO: renamed from: ޙ, reason: contains not printable characters */
    public final Object f1766;

    /* JADX INFO: renamed from: ޚ, reason: contains not printable characters */
    public InterfaceC4095 f1767;

    /* JADX INFO: renamed from: ޛ, reason: contains not printable characters */
    public Loader f1768;

    /* JADX INFO: renamed from: ޜ, reason: contains not printable characters */
    public InterfaceC4115 f1769;

    /* JADX INFO: renamed from: ޝ, reason: contains not printable characters */
    public IOException f1770;

    /* JADX INFO: renamed from: ޞ, reason: contains not printable characters */
    public Handler f1771;

    /* JADX INFO: renamed from: ޟ, reason: contains not printable characters */
    public Uri f1772;

    /* JADX INFO: renamed from: ޠ, reason: contains not printable characters */
    public Uri f1773;

    /* JADX INFO: renamed from: ޡ, reason: contains not printable characters */
    public C3870 f1774;

    /* JADX INFO: renamed from: ޢ, reason: contains not printable characters */
    public boolean f1775;

    /* JADX INFO: renamed from: ޣ, reason: contains not printable characters */
    public long f1776;

    /* JADX INFO: renamed from: ޤ, reason: contains not printable characters */
    public long f1777;

    /* JADX INFO: renamed from: ޥ, reason: contains not printable characters */
    public long f1778;

    /* JADX INFO: renamed from: ޱ, reason: contains not printable characters */
    public int f1779;

    /* JADX INFO: renamed from: ࢠ, reason: contains not printable characters */
    public long f1780;

    /* JADX INFO: renamed from: ࢢ, reason: contains not printable characters */
    public int f1781;

    public static final class Factory implements InterfaceC3808 {

        /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
        public final InterfaceC3854.InterfaceC3855 f1782;

        /* JADX INFO: renamed from: ؠ, reason: contains not printable characters */
        public final InterfaceC4095.InterfaceC4096 f1783;

        /* JADX INFO: renamed from: ހ, reason: contains not printable characters */
        public InterfaceC3532<?> f1784;

        /* JADX INFO: renamed from: ށ, reason: contains not printable characters */
        public C4112.InterfaceC4113<? extends C3870> f1785;

        /* JADX INFO: renamed from: ނ, reason: contains not printable characters */
        public List<C3777> f1786;

        /* JADX INFO: renamed from: ރ, reason: contains not printable characters */
        public C3794 f1787;

        /* JADX INFO: renamed from: ބ, reason: contains not printable characters */
        public InterfaceC4109 f1788;

        /* JADX INFO: renamed from: ޅ, reason: contains not printable characters */
        public long f1789;

        /* JADX INFO: renamed from: ކ, reason: contains not printable characters */
        public boolean f1790;

        public Factory(InterfaceC3854.InterfaceC3855 interfaceC3855, InterfaceC4095.InterfaceC4096 interfaceC4096) {
            if (interfaceC3855 == null) {
                throw null;
            }
            this.f1782 = interfaceC3855;
            this.f1783 = interfaceC4096;
            this.f1784 = C3531.m5830();
            this.f1788 = new C4108();
            this.f1789 = 30000L;
            this.f1787 = new C3794();
        }

        public Factory(InterfaceC4095.InterfaceC4096 interfaceC4096) {
            this(new C3860.C3861(interfaceC4096), interfaceC4096);
        }

        public DashMediaSource createMediaSource(Uri uri) {
            this.f1790 = true;
            if (this.f1785 == null) {
                this.f1785 = new C3871();
            }
            List<C3777> list = this.f1786;
            if (list != null) {
                this.f1785 = new C3776(this.f1785, list);
            }
            C3870 c3870 = null;
            if (uri != null) {
                return new DashMediaSource(c3870, uri, this.f1783, this.f1785, this.f1782, this.f1787, this.f1784, this.f1788, this.f1789, false, null, null);
            }
            throw null;
        }

        public Factory setStreamKeys(List<C3777> list) {
            C0567.m1932(!this.f1790);
            this.f1786 = list;
            return this;
        }

        /* JADX INFO: renamed from: setStreamKeys, reason: collision with other method in class */
        public /* bridge */ /* synthetic */ InterfaceC3808 m1221setStreamKeys(List list) {
            return setStreamKeys((List<C3777>) list);
        }
    }

    /* JADX INFO: renamed from: com.google.android.exoplayer2.source.dash.DashMediaSource$ؠ, reason: contains not printable characters */
    public static final class C0292 extends AbstractC3457 {

        /* JADX INFO: renamed from: ؠ, reason: contains not printable characters */
        public final long f1791;

        /* JADX INFO: renamed from: ހ, reason: contains not printable characters */
        public final long f1792;

        /* JADX INFO: renamed from: ށ, reason: contains not printable characters */
        public final int f1793;

        /* JADX INFO: renamed from: ނ, reason: contains not printable characters */
        public final long f1794;

        /* JADX INFO: renamed from: ރ, reason: contains not printable characters */
        public final long f1795;

        /* JADX INFO: renamed from: ބ, reason: contains not printable characters */
        public final long f1796;

        /* JADX INFO: renamed from: ޅ, reason: contains not printable characters */
        public final C3870 f1797;

        /* JADX INFO: renamed from: ކ, reason: contains not printable characters */
        public final Object f1798;

        public C0292(long j, long j2, int i, long j3, long j4, long j5, C3870 c3870, Object obj) {
            this.f1791 = j;
            this.f1792 = j2;
            this.f1793 = i;
            this.f1794 = j3;
            this.f1795 = j4;
            this.f1796 = j5;
            this.f1797 = c3870;
            this.f1798 = obj;
        }

        /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
        public static boolean m1222(C3870 c3870) {
            return c3870.f11966 && c3870.f11967 != -9223372036854775807L && c3870.f11964 == -9223372036854775807L;
        }

        @Override // p138.p176.p177.p190.AbstractC3457
        /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
        public int mo1223(Object obj) {
            int iIntValue;
            if ((obj instanceof Integer) && (iIntValue = ((Integer) obj).intValue() - this.f1793) >= 0 && iIntValue < mo1227()) {
                return iIntValue;
            }
            return -1;
        }

        @Override // p138.p176.p177.p190.AbstractC3457
        /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
        public Object mo1224(int i) {
            C0567.m1842(i, 0, mo1227());
            return Integer.valueOf(this.f1793 + i);
        }

        @Override // p138.p176.p177.p190.AbstractC3457
        /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
        public AbstractC3457.C3459 mo1225(int i, AbstractC3457.C3459 c3459, boolean z) {
            C0567.m1842(i, 0, mo1227());
            if (z) {
                String str = this.f1797.f11974.get(i).f11993;
            }
            Integer numValueOf = z ? Integer.valueOf(this.f1793 + i) : null;
            long jM5458 = C3414.m5458(this.f1797.m6264(i));
            long jM54582 = C3414.m5458(this.f1797.f11974.get(i).f11994 - this.f1797.m6263(0).f11994) - this.f1794;
            if (c3459 == null) {
                throw null;
            }
            C3831 c3831 = C3831.f11788;
            c3459.f10224 = numValueOf;
            c3459.f10225 = 0;
            c3459.f10226 = jM5458;
            c3459.f10227 = jM54582;
            c3459.f10228 = c3831;
            return c3459;
        }

        /* JADX WARN: Removed duplicated region for block: B:10:0x002b A[PHI: r3
          0x002b: PHI (r3v2 long) = (r3v1 long), (r3v4 long) binds: [B:6:0x001b, B:8:0x0023] A[DONT_GENERATE, DONT_INLINE]] */
        @Override // p138.p176.p177.p190.AbstractC3457
        /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
        /*
            Code decompiled incorrectly, please refer to instructions dump.
        */
        public AbstractC3457.C3460 mo1226(int i, AbstractC3457.C3460 c3460, long j) {
            InterfaceC3858 interfaceC3858Mo6292;
            C0567.m1842(i, 0, 1);
            long jMo6242 = this.f1796;
            if (m1222(this.f1797)) {
                if (j > 0) {
                    jMo6242 += j;
                    if (jMo6242 > this.f1795) {
                        jMo6242 = -9223372036854775807L;
                    } else {
                        long j2 = this.f1794 + jMo6242;
                        long jM6265 = this.f1797.m6265(0);
                        int i2 = 0;
                        while (i2 < this.f1797.m6262() - 1 && j2 >= jM6265) {
                            j2 -= jM6265;
                            i2++;
                            jM6265 = this.f1797.m6265(i2);
                        }
                        C3875 c3875M6263 = this.f1797.m6263(i2);
                        int size = c3875M6263.f11995.size();
                        int i3 = 0;
                        while (true) {
                            if (i3 >= size) {
                                i3 = -1;
                                break;
                            }
                            if (c3875M6263.f11995.get(i3).f11959 == 2) {
                                break;
                            }
                            i3++;
                        }
                        if (i3 != -1 && (interfaceC3858Mo6292 = c3875M6263.f11995.get(i3).f11960.get(0).mo6292()) != null && interfaceC3858Mo6292.mo6248(jM6265) != 0) {
                            jMo6242 = (interfaceC3858Mo6292.mo6242(interfaceC3858Mo6292.mo6243(j2, jM6265)) + jMo6242) - j2;
                        }
                    }
                }
            }
            long j3 = jMo6242;
            Object obj = AbstractC3457.C3460.f10229;
            Object obj2 = this.f1798;
            C3870 c3870 = this.f1797;
            c3460.m5694(obj, obj2, c3870, this.f1791, this.f1792, true, m1222(c3870), this.f1797.f11966, j3, this.f1795, 0, mo1227() - 1, this.f1794);
            return c3460;
        }

        @Override // p138.p176.p177.p190.AbstractC3457
        /* JADX INFO: renamed from: ހ, reason: contains not printable characters */
        public int mo1227() {
            return this.f1797.m6262();
        }

        @Override // p138.p176.p177.p190.AbstractC3457
        /* JADX INFO: renamed from: ށ, reason: contains not printable characters */
        public int mo1228() {
            return 1;
        }
    }

    /* JADX INFO: renamed from: com.google.android.exoplayer2.source.dash.DashMediaSource$ހ, reason: contains not printable characters */
    public final class C0293 implements C3865.InterfaceC3867 {
        public /* synthetic */ C0293(C0291 c0291) {
        }
    }

    /* JADX INFO: renamed from: com.google.android.exoplayer2.source.dash.DashMediaSource$ށ, reason: contains not printable characters */
    public static final class C0294 implements C4112.InterfaceC4113<Long> {

        /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
        public static final Pattern f1800 = Pattern.compile("(.+?)(Z|((\\+|-|−)(\\d\\d)(:?(\\d\\d))?))");

        @Override // p138.p176.p177.p190.p238.C4112.InterfaceC4113
        /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
        public Long mo1229(Uri uri, InputStream inputStream) throws IOException {
            String line = new BufferedReader(new InputStreamReader(inputStream, Charset.forName("UTF-8"))).readLine();
            try {
                Matcher matcher = f1800.matcher(line);
                if (!matcher.matches()) {
                    throw new ParserException("Couldn't parse timestamp: " + line);
                }
                String strGroup = matcher.group(1);
                SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss", Locale.US);
                simpleDateFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
                long time = simpleDateFormat.parse(strGroup).getTime();
                if (!"Z".equals(matcher.group(2))) {
                    long j = "+".equals(matcher.group(4)) ? 1L : -1L;
                    long j2 = Long.parseLong(matcher.group(5));
                    String strGroup2 = matcher.group(7);
                    time -= ((((j2 * 60) + (TextUtils.isEmpty(strGroup2) ? 0L : Long.parseLong(strGroup2))) * 60) * 1000) * j;
                }
                return Long.valueOf(time);
            } catch (ParseException e) {
                throw new ParserException(e);
            }
        }
    }

    /* JADX INFO: renamed from: com.google.android.exoplayer2.source.dash.DashMediaSource$ނ, reason: contains not printable characters */
    public final class C0295 implements Loader.InterfaceC0319<C4112<C3870>> {
        public /* synthetic */ C0295(C0291 c0291) {
        }

        @Override // com.google.android.exoplayer2.upstream.Loader.InterfaceC0319
        /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
        public Loader.C0320 mo1230(Loader.InterfaceC0322 interfaceC0322, long j, long j2, IOException iOException, int i) {
            C4112 c4112 = (C4112) interfaceC0322;
            DashMediaSource dashMediaSource = DashMediaSource.this;
            long jMo6616 = dashMediaSource.f1754.mo6616(4, j2, iOException, i);
            Loader.C0320 c0320M1289 = jMo6616 == -9223372036854775807L ? Loader.f1981 : Loader.m1289(false, jMo6616);
            InterfaceC3803.C3804 c3804 = dashMediaSource.f1757;
            C4098 c4098 = c4112.f13153;
            C4114 c4114 = c4112.f13155;
            c3804.m6137(c4098, c4114.f13160, c4114.f13161, c4112.f13154, j, j2, c4114.f13159, iOException, !c0320M1289.m1296());
            return c0320M1289;
        }

        @Override // com.google.android.exoplayer2.upstream.Loader.InterfaceC0319
        /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
        public void mo1231(Loader.InterfaceC0322 interfaceC0322, long j, long j2) {
            DashMediaSource.this.m1218((C4112) interfaceC0322, j, j2);
        }

        @Override // com.google.android.exoplayer2.upstream.Loader.InterfaceC0319
        /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
        public void mo1232(Loader.InterfaceC0322 interfaceC0322, long j, long j2, boolean z) {
            DashMediaSource.this.m1214((C4112<?>) interfaceC0322, j, j2);
        }
    }

    /* JADX INFO: renamed from: com.google.android.exoplayer2.source.dash.DashMediaSource$ރ, reason: contains not printable characters */
    public final class C0296 implements InterfaceC4110 {
        public C0296() {
        }

        @Override // p138.p176.p177.p190.p238.InterfaceC4110
        /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
        public void mo1233() throws IOException {
            DashMediaSource.this.f1768.m1291(Integer.MIN_VALUE);
            IOException iOException = DashMediaSource.this.f1770;
            if (iOException != null) {
                throw iOException;
            }
        }
    }

    /* JADX INFO: renamed from: com.google.android.exoplayer2.source.dash.DashMediaSource$ބ, reason: contains not printable characters */
    public static final class C0297 {

        /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
        public final boolean f1803;

        /* JADX INFO: renamed from: ؠ, reason: contains not printable characters */
        public final long f1804;

        /* JADX INFO: renamed from: ހ, reason: contains not printable characters */
        public final long f1805;

        public C0297(boolean z, long j, long j2) {
            this.f1803 = z;
            this.f1804 = j;
            this.f1805 = j2;
        }

        /* JADX WARN: Removed duplicated region for block: B:19:0x0040 A[PHI: r12
          0x0040: PHI (r12v4 boolean) = (r12v2 boolean), (r12v1 boolean) binds: [B:27:0x0074, B:18:0x003e] A[DONT_GENERATE, DONT_INLINE]] */
        /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
        /*
            Code decompiled incorrectly, please refer to instructions dump.
        */
        public static C0297 m1234(C3875 c3875, long j) {
            boolean z;
            boolean z2;
            int i;
            int size = c3875.f11995.size();
            int i2 = 0;
            for (int i3 = 0; i3 < size; i3++) {
                int i4 = c3875.f11995.get(i3).f11959;
                if (i4 == 1 || i4 == 2) {
                    z = true;
                    break;
                }
            }
            z = false;
            long jMin = Long.MAX_VALUE;
            int i5 = 0;
            boolean zMo6244 = false;
            long jMax = 0;
            boolean z3 = false;
            while (i5 < size) {
                C3869 c3869 = c3875.f11995.get(i5);
                if (!z || c3869.f11959 != 3) {
                    InterfaceC3858 interfaceC3858Mo6292 = c3869.f11960.get(i2).mo6292();
                    if (interfaceC3858Mo6292 == null) {
                        return new C0297(true, 0L, j);
                    }
                    zMo6244 |= interfaceC3858Mo6292.mo6244();
                    int iMo6248 = interfaceC3858Mo6292.mo6248(j);
                    if (iMo6248 == 0) {
                        z2 = z;
                        i = i5;
                        jMin = 0;
                        jMax = 0;
                        z3 = true;
                    } else if (z3) {
                        z2 = z;
                        i = i5;
                    } else {
                        z2 = z;
                        long jMo6245 = interfaceC3858Mo6292.mo6245();
                        i = i5;
                        jMax = Math.max(jMax, interfaceC3858Mo6292.mo6242(jMo6245));
                        if (iMo6248 != -1) {
                            long j2 = (jMo6245 + ((long) iMo6248)) - 1;
                            jMin = Math.min(jMin, interfaceC3858Mo6292.mo6246(j2, j) + interfaceC3858Mo6292.mo6242(j2));
                        }
                    }
                }
                i5 = i + 1;
                z = z2;
                i2 = 0;
            }
            return new C0297(zMo6244, jMax, jMin);
        }
    }

    /* JADX INFO: renamed from: com.google.android.exoplayer2.source.dash.DashMediaSource$ޅ, reason: contains not printable characters */
    public final class C0298 implements Loader.InterfaceC0319<C4112<Long>> {
        public /* synthetic */ C0298(C0291 c0291) {
        }

        @Override // com.google.android.exoplayer2.upstream.Loader.InterfaceC0319
        /* JADX INFO: renamed from: ֏ */
        public Loader.C0320 mo1230(Loader.InterfaceC0322 interfaceC0322, long j, long j2, IOException iOException, int i) {
            C4112 c4112 = (C4112) interfaceC0322;
            DashMediaSource dashMediaSource = DashMediaSource.this;
            InterfaceC3803.C3804 c3804 = dashMediaSource.f1757;
            C4098 c4098 = c4112.f13153;
            C4114 c4114 = c4112.f13155;
            c3804.m6137(c4098, c4114.f13160, c4114.f13161, c4112.f13154, j, j2, c4114.f13159, iOException, true);
            dashMediaSource.m1211(iOException);
            return Loader.f1980;
        }

        /* JADX WARN: Multi-variable type inference failed */
        @Override // com.google.android.exoplayer2.upstream.Loader.InterfaceC0319
        /* JADX INFO: renamed from: ֏ */
        public void mo1231(Loader.InterfaceC0322 interfaceC0322, long j, long j2) {
            C4112 c4112 = (C4112) interfaceC0322;
            DashMediaSource dashMediaSource = DashMediaSource.this;
            InterfaceC3803.C3804 c3804 = dashMediaSource.f1757;
            C4098 c4098 = c4112.f13153;
            C4114 c4114 = c4112.f13155;
            c3804.m6142(c4098, c4114.f13160, c4114.f13161, c4112.f13154, j, j2, c4114.f13159);
            dashMediaSource.f1778 = ((Long) c4112.f13157).longValue() - j;
            dashMediaSource.m1216(true);
        }

        @Override // com.google.android.exoplayer2.upstream.Loader.InterfaceC0319
        /* JADX INFO: renamed from: ֏ */
        public void mo1232(Loader.InterfaceC0322 interfaceC0322, long j, long j2, boolean z) {
            DashMediaSource.this.m1214((C4112<?>) interfaceC0322, j, j2);
        }
    }

    /* JADX INFO: renamed from: com.google.android.exoplayer2.source.dash.DashMediaSource$ކ, reason: contains not printable characters */
    public static final class C0299 implements C4112.InterfaceC4113<Long> {
        public /* synthetic */ C0299(C0291 c0291) {
        }

        @Override // p138.p176.p177.p190.p238.C4112.InterfaceC4113
        /* JADX INFO: renamed from: ֏ */
        public Long mo1229(Uri uri, InputStream inputStream) {
            return Long.valueOf(C4150.m6805(new BufferedReader(new InputStreamReader(inputStream)).readLine()));
        }
    }

    static {
        C3430.m5578("goog.exo.dash");
    }

    public /* synthetic */ DashMediaSource(C3870 c3870, Uri uri, InterfaceC4095.InterfaceC4096 interfaceC4096, C4112.InterfaceC4113 interfaceC4113, InterfaceC3854.InterfaceC3855 interfaceC3855, C3794 c3794, InterfaceC3532 interfaceC3532, InterfaceC4109 interfaceC4109, long j, boolean z, Object obj, C0291 c0291) {
        this.f1772 = uri;
        this.f1774 = c3870;
        this.f1773 = uri;
        this.f1750 = interfaceC4096;
        this.f1758 = interfaceC4113;
        this.f1751 = interfaceC3855;
        this.f1753 = interfaceC3532;
        this.f1754 = interfaceC4109;
        this.f1755 = j;
        this.f1756 = z;
        this.f1752 = c3794;
        this.f1766 = obj;
        this.f1749 = c3870 != null;
        C0291 c02912 = null;
        this.f1757 = m6096((InterfaceC3800.C3801) null);
        this.f1760 = new Object();
        this.f1761 = new SparseArray<>();
        this.f1764 = new C0293(c02912);
        this.f1780 = -9223372036854775807L;
        if (!this.f1749) {
            this.f1759 = new C0295(c02912);
            this.f1765 = new C0296();
            this.f1762 = new Runnable() { // from class: ދ.ހ.֏.ؠ.ໞ.ޞ.ؠ
                @Override // java.lang.Runnable
                public final void run() {
                    this.f11879.m1220();
                }
            };
            this.f1763 = new Runnable() { // from class: ދ.ހ.֏.ؠ.ໞ.ޞ.֏
                @Override // java.lang.Runnable
                public final void run() {
                    this.f11878.m1219();
                }
            };
            return;
        }
        C0567.m1932(!c3870.f11966);
        this.f1759 = null;
        this.f1762 = null;
        this.f1763 = null;
        this.f1765 = new InterfaceC4110.C4111();
    }

    @Override // p138.p176.p177.p190.p217.InterfaceC3800
    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public InterfaceC3798 mo1209(InterfaceC3800.C3801 c3801, InterfaceC4089 interfaceC4089, long j) {
        int iIntValue = ((Integer) c3801.f11629).intValue() - this.f1781;
        long j2 = this.f1774.m6263(iIntValue).f11994;
        C0567.m1896(true);
        C3856 c3856 = new C3856(this.f1781 + iIntValue, this.f1774, iIntValue, this.f1751, this.f1769, this.f1753, this.f1754, new InterfaceC3803.C3804(this.f11611.f11636, 0, c3801, j2), this.f1778, this.f1765, interfaceC4089, this.f1752, this.f1764);
        this.f1761.put(c3856.f11881, c3856);
        return c3856;
    }

    @Override // p138.p176.p177.p190.p217.InterfaceC3800
    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public void mo1210() {
        this.f1765.mo1233();
    }

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public final void m1211(IOException iOException) {
        C4131.m6645("DashMediaSource", "Failed to resolve UtcTiming element.", iOException);
        m1216(true);
    }

    @Override // p138.p176.p177.p190.p217.InterfaceC3800
    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public void mo1212(InterfaceC3798 interfaceC3798) {
        C3856 c3856 = (C3856) interfaceC3798;
        C3865 c3865 = c3856.f11892;
        c3865.f11951 = true;
        c3865.f11944.removeCallbacksAndMessages(null);
        for (C3841<InterfaceC3854> c3841 : c3856.f11896) {
            c3841.m6219(c3856);
        }
        c3856.f11895 = null;
        c3856.f11894.m6138();
        this.f1761.remove(c3856.f11881);
    }

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public final void m1213(C3890 c3890, C4112.InterfaceC4113<Long> interfaceC4113) {
        C4112 c4112 = new C4112(this.f1767, Uri.parse(c3890.f12035), 5, interfaceC4113);
        this.f1757.m6133(c4112.f13153, c4112.f13154, this.f1768.m1290(c4112, new C0298(null), 1));
    }

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public void m1214(C4112<?> c4112, long j, long j2) {
        InterfaceC3803.C3804 c3804 = this.f1757;
        C4098 c4098 = c4112.f13153;
        C4114 c4114 = c4112.f13155;
        c3804.m6136(c4098, c4114.f13160, c4114.f13161, c4112.f13154, j, j2, c4114.f13159);
    }

    @Override // p138.p176.p177.p190.p217.AbstractC3790
    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public void mo1215(InterfaceC4115 interfaceC4115) {
        this.f1769 = interfaceC4115;
        this.f1753.mo1129();
        if (this.f1749) {
            m1216(false);
            return;
        }
        this.f1767 = this.f1750.mo1286();
        this.f1768 = new Loader("Loader:DashMediaSource");
        this.f1771 = new Handler();
        m1220();
    }

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public final void m1216(boolean z) {
        long j;
        boolean z2;
        long j2;
        for (int i = 0; i < this.f1761.size(); i++) {
            int iKeyAt = this.f1761.keyAt(i);
            if (iKeyAt >= this.f1781) {
                C3856 c3856ValueAt = this.f1761.valueAt(i);
                C3870 c3870 = this.f1774;
                int i2 = iKeyAt - this.f1781;
                c3856ValueAt.f11899 = c3870;
                c3856ValueAt.f11900 = i2;
                C3865 c3865 = c3856ValueAt.f11892;
                c3865.f11950 = false;
                c3865.f11947 = -9223372036854775807L;
                c3865.f11946 = c3870;
                Iterator<Map.Entry<Long, Long>> it = c3865.f11945.entrySet().iterator();
                while (it.hasNext()) {
                    if (it.next().getKey().longValue() < c3865.f11946.f11970) {
                        it.remove();
                    }
                }
                C3841<InterfaceC3854>[] c3841Arr = c3856ValueAt.f11896;
                if (c3841Arr != null) {
                    for (C3841<InterfaceC3854> c3841 : c3841Arr) {
                        ((InterfaceC3854) c3841.f11835).mo6235(c3870, i2);
                    }
                    c3856ValueAt.f11895.mo5541(c3856ValueAt);
                }
                c3856ValueAt.f11901 = c3870.f11974.get(i2).f11996;
                for (C3864 c3864 : c3856ValueAt.f11897) {
                    Iterator<C3874> it2 = c3856ValueAt.f11901.iterator();
                    while (true) {
                        if (it2.hasNext()) {
                            C3874 next = it2.next();
                            if (next.m6288().equals(c3864.f11937.m6288())) {
                                c3864.m6260(next, c3870.f11966 && i2 == c3870.m6262() - 1);
                            }
                        }
                    }
                }
            }
        }
        int iM6262 = this.f1774.m6262() - 1;
        C0297 c0297M1234 = C0297.m1234(this.f1774.m6263(0), this.f1774.m6265(0));
        C0297 c0297M12342 = C0297.m1234(this.f1774.m6263(iM6262), this.f1774.m6265(iM6262));
        long jMax = c0297M1234.f1804;
        long jMin = c0297M12342.f1805;
        if (!this.f1774.f11966 || c0297M12342.f1803) {
            j = jMax;
            z2 = false;
        } else {
            jMin = Math.min(((this.f1778 != 0 ? C3414.m5458(SystemClock.elapsedRealtime() + this.f1778) : C3414.m5458(System.currentTimeMillis())) - C3414.m5458(this.f1774.f11963)) - C3414.m5458(this.f1774.m6263(iM6262).f11994), jMin);
            long j3 = this.f1774.f11968;
            if (j3 != -9223372036854775807L) {
                long jM5458 = jMin - C3414.m5458(j3);
                while (jM5458 < 0 && iM6262 > 0) {
                    iM6262--;
                    jM5458 += this.f1774.m6265(iM6262);
                }
                jMax = iM6262 == 0 ? Math.max(jMax, jM5458) : this.f1774.m6265(0);
            }
            j = jMax;
            z2 = true;
        }
        long jM6265 = jMin - j;
        for (int i3 = 0; i3 < this.f1774.m6262() - 1; i3++) {
            jM6265 = this.f1774.m6265(i3) + jM6265;
        }
        C3870 c38702 = this.f1774;
        if (c38702.f11966) {
            long j4 = this.f1755;
            if (!this.f1756) {
                long j5 = c38702.f11969;
                if (j5 != -9223372036854775807L) {
                    j4 = j5;
                }
            }
            long jM54582 = jM6265 - C3414.m5458(j4);
            if (jM54582 < 5000000) {
                jM54582 = Math.min(5000000L, jM6265 / 2);
            }
            j2 = jM54582;
        } else {
            j2 = 0;
        }
        C3870 c38703 = this.f1774;
        long j6 = c38703.f11963;
        long jM5459 = j6 != -9223372036854775807L ? C3414.m5459(j) + j6 + c38703.m6263(0).f11994 : -9223372036854775807L;
        C3870 c38704 = this.f1774;
        m6098(new C0292(c38704.f11963, jM5459, this.f1781, j, jM6265, j2, c38704, this.f1766));
        if (this.f1749) {
            return;
        }
        this.f1771.removeCallbacks(this.f1763);
        if (z2) {
            this.f1771.postDelayed(this.f1763, 5000L);
        }
        if (this.f1775) {
            m1220();
            return;
        }
        if (z) {
            C3870 c38705 = this.f1774;
            if (c38705.f11966) {
                long j7 = c38705.f11967;
                if (j7 != -9223372036854775807L) {
                    this.f1771.postDelayed(this.f1762, Math.max(0L, (this.f1776 + (j7 != 0 ? j7 : 5000L)) - SystemClock.elapsedRealtime()));
                }
            }
        }
    }

    @Override // p138.p176.p177.p190.p217.AbstractC3790
    /* JADX INFO: renamed from: ؠ, reason: contains not printable characters */
    public void mo1217() {
        this.f1775 = false;
        this.f1767 = null;
        Loader loader = this.f1768;
        if (loader != null) {
            loader.m1292((Loader.InterfaceC0323) null);
            this.f1768 = null;
        }
        this.f1776 = 0L;
        this.f1777 = 0L;
        this.f1774 = this.f1749 ? this.f1774 : null;
        this.f1773 = this.f1772;
        this.f1770 = null;
        Handler handler = this.f1771;
        if (handler != null) {
            handler.removeCallbacksAndMessages(null);
            this.f1771 = null;
        }
        this.f1778 = 0L;
        this.f1779 = 0;
        this.f1780 = -9223372036854775807L;
        this.f1781 = 0;
        this.f1761.clear();
        this.f1753.mo1126();
    }

    /* JADX WARN: Removed duplicated region for block: B:24:0x0092  */
    /* JADX WARN: Removed duplicated region for block: B:29:0x00bf  */
    /* JADX INFO: renamed from: ؠ, reason: contains not printable characters */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public void m1218(C4112<C3870> c4112, long j, long j2) {
        C3890 c3890;
        boolean z;
        InterfaceC3803.C3804 c3804 = this.f1757;
        C4098 c4098 = c4112.f13153;
        C4114 c4114 = c4112.f13155;
        c3804.m6142(c4098, c4114.f13160, c4114.f13161, c4112.f13154, j, j2, c4114.f13159);
        C3870 c3870 = c4112.f13157;
        C3870 c38702 = this.f1774;
        int iM6262 = c38702 == null ? 0 : c38702.m6262();
        long j3 = c3870.m6263(0).f11994;
        int i = 0;
        while (i < iM6262 && this.f1774.m6263(i).f11994 < j3) {
            i++;
        }
        if (c3870.f11966) {
            if (iM6262 - i > c3870.m6262()) {
                Log.w("DashMediaSource", "Loaded out of sync manifest");
            } else {
                long j4 = this.f1780;
                if (j4 == -9223372036854775807L || c3870.f11970 * 1000 > j4) {
                    z = false;
                    if (!z) {
                        int i2 = this.f1779;
                        this.f1779 = i2 + 1;
                        if (i2 < this.f1754.mo6614(c4112.f13154)) {
                            this.f1771.postDelayed(this.f1762, Math.min((this.f1779 - 1) * 1000, 5000));
                            return;
                        } else {
                            this.f1770 = new DashManifestStaleException();
                            return;
                        }
                    }
                    this.f1779 = 0;
                } else {
                    StringBuilder sbM4889 = C2803.m4889("Loaded stale dynamic manifest: ");
                    sbM4889.append(c3870.f11970);
                    sbM4889.append(", ");
                    sbM4889.append(this.f1780);
                    Log.w("DashMediaSource", sbM4889.toString());
                }
            }
            z = true;
            if (!z) {
            }
        }
        this.f1774 = c3870;
        this.f1775 = c3870.f11966 & this.f1775;
        this.f1776 = j - j2;
        this.f1777 = j;
        synchronized (this.f1760) {
            if (c4112.f13153.f13076 == this.f1773) {
                this.f1773 = this.f1774.f11972 != null ? this.f1774.f11972 : c4112.f13155.f13160;
            }
        }
        if (iM6262 != 0) {
            this.f1781 += i;
            m1216(true);
            return;
        }
        C3870 c38703 = this.f1774;
        if (!c38703.f11966 || (c3890 = c38703.f11971) == null) {
            m1216(true);
            return;
        }
        String str = c3890.f12034;
        if (C4150.m6769((Object) str, (Object) "urn:mpeg:dash:utc:direct:2014") || C4150.m6769((Object) str, (Object) "urn:mpeg:dash:utc:direct:2012")) {
            try {
                this.f1778 = C4150.m6805(c3890.f12035) - this.f1777;
                m1216(true);
                return;
            } catch (ParserException e) {
                m1211(e);
                return;
            }
        }
        if (C4150.m6769((Object) str, (Object) "urn:mpeg:dash:utc:http-iso:2014") || C4150.m6769((Object) str, (Object) "urn:mpeg:dash:utc:http-iso:2012")) {
            m1213(c3890, new C0294());
        } else if (C4150.m6769((Object) str, (Object) "urn:mpeg:dash:utc:http-xsdate:2014") || C4150.m6769((Object) str, (Object) "urn:mpeg:dash:utc:http-xsdate:2012")) {
            m1213(c3890, new C0299(null));
        } else {
            m1211(new IOException("Unsupported UTC timing scheme"));
        }
    }

    /* JADX INFO: renamed from: ހ, reason: contains not printable characters */
    public /* synthetic */ void m1219() {
        m1216(false);
    }

    /* JADX INFO: renamed from: ށ, reason: contains not printable characters */
    public final void m1220() {
        Uri uri;
        this.f1771.removeCallbacks(this.f1762);
        if (this.f1768.m1294()) {
            return;
        }
        if (this.f1768.m1295()) {
            this.f1775 = true;
            return;
        }
        synchronized (this.f1760) {
            uri = this.f1773;
        }
        this.f1775 = false;
        C4112 c4112 = new C4112(this.f1767, uri, 4, this.f1758);
        this.f1757.m6133(c4112.f13153, c4112.f13154, this.f1768.m1290(c4112, this.f1759, this.f1754.mo6614(4)));
    }
}
