package defpackage;

import android.content.Context;
import android.net.Uri;
import j$.util.Objects;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;

/* renamed from: ˀˌʗ, reason: contains not printable characters */
/* loaded from: classes3.dex */
public final class C0538 implements InterfaceC4667 {

    /* renamed from: ˇʼʤˎ, reason: contains not printable characters */
    public final long f2789;

    /* renamed from: ˎˏʜʾ, reason: contains not printable characters */
    public final float f2790;

    /* renamed from: ˏˋٴ, reason: contains not printable characters */
    public final long f2791;

    /* renamed from: ˏᵙ, reason: contains not printable characters */
    public ᵼᵫᵧˀ f2792;

    /* renamed from: ᵝᵵᵺ, reason: contains not printable characters */
    public boolean f2793;

    /* renamed from: ᵥᵯˎ, reason: contains not printable characters */
    public final C4430 f2794;

    /* renamed from: ᵴᵳ, reason: contains not printable characters */
    public final C2720 f2795;

    /* renamed from: ᵹᵝᵶ, reason: contains not printable characters */
    public final float f2796;

    /* renamed from: ᵻᵢﹳᵰ, reason: contains not printable characters */
    public final long f2797;

    public C0538(Context context, C2114 c2114) {
        C2720 c2720 = new C2720(context, new C3513(4));
        ᵼᵫᵧˀ r4 = new ᵼᵫᵧˀ(18);
        this.f2795 = c2720;
        this.f2792 = r4;
        C4430 c4430 = new C4430(c2114, r4);
        this.f2794 = c4430;
        if (c2720 != c4430.f16564) {
            c4430.f16564 = c2720;
            c4430.f16562.clear();
            c4430.f16559.clear();
        }
        this.f2797 = -9223372036854775807L;
        this.f2789 = -9223372036854775807L;
        this.f2791 = -9223372036854775807L;
        this.f2790 = -3.4028235E38f;
        this.f2796 = -3.4028235E38f;
        this.f2793 = true;
    }

    /* renamed from: ˎˏʜʾ, reason: contains not printable characters */
    public static InterfaceC4667 m2330(Class cls, InterfaceC1731 interfaceC1731) {
        try {
            return (InterfaceC4667) cls.getConstructor(InterfaceC1731.class).newInstance(interfaceC1731);
        } catch (Exception e) {
            C2707.m6713(e);
            return null;
        }
    }

    @Override // defpackage.InterfaceC4667
    /* renamed from: ˇʼʤˎ */
    public final InterfaceC4667 mo403(int i) {
        C4430 c4430 = this.f2794;
        c4430.f16557 = i;
        C2114 c2114 = c4430.f16561;
        synchronized (c2114) {
            c2114.f8357 = i;
        }
        return this;
    }

    @Override // defpackage.InterfaceC4667
    /* renamed from: ˏˋٴ */
    public final InterfaceC4667 mo404(ᵼᵫᵧˀ r3) {
        this.f2792 = r3;
        C4430 c4430 = this.f2794;
        c4430.f16558 = r3;
        C2114 c2114 = c4430.f16561;
        synchronized (c2114) {
            c2114.f8355 = r3;
        }
        Iterator it = c4430.f16559.values().iterator();
        while (it.hasNext()) {
            ((InterfaceC4667) it.next()).mo404(r3);
        }
        return this;
    }

    /* JADX WARN: Multi-variable type inference failed */
    /* JADX WARN: Type inference failed for: r10v0, types: [ᵚᵩʛʩ] */
    @Override // defpackage.InterfaceC4667
    /* renamed from: ˏᵙ */
    public final InterfaceC4865 mo405(C0346 c0346) {
        int iM8132;
        int i;
        C0346 c03462;
        C0112 c0112;
        Uri uri;
        String str;
        List list;
        C4471 c4471;
        long j;
        c0346.f2063.getClass();
        String scheme = c0346.f2063.f18441.getScheme();
        if (scheme != null && scheme.equals("ssai")) {
            throw null;
        }
        boolean zEquals = Objects.equals(c0346.f2063.f18442, "application/x-image-uri");
        C4962 c4962 = c0346.f2063;
        if (zEquals) {
            long j2 = c4962.f18439;
            String str2 = AbstractC3558.f13329;
            throw null;
        }
        Uri uri2 = c4962.f18441;
        String str3 = c4962.f18442;
        if (str3 != null) {
            switch (str3) {
                case "application/x-mpegURL":
                    iM8132 = 2;
                    break;
                case "application/vnd.ms-sstr+xml":
                    iM8132 = 1;
                    break;
                case "application/dash+xml":
                    iM8132 = 0;
                    break;
                case "application/x-rtsp":
                    iM8132 = 3;
                    break;
                default:
                    iM8132 = 4;
                    break;
            }
        } else {
            iM8132 = AbstractC3558.m8132(uri2);
        }
        if (c0346.f2063.f18439 != -9223372036854775807L) {
            C2114 c2114 = this.f2794.f16561;
            synchronized (c2114) {
                c2114.f8356 = 1;
            }
            C4430.m9464(this.f2794);
        }
        try {
            InterfaceC4667 interfaceC4667M9465 = this.f2794.m9465(iM8132);
            C2266 c2266M1213 = c0346.f2061.m1213();
            C0112 c01122 = c0346.f2061;
            if (c01122.f1416 == -9223372036854775807L) {
                c2266M1213.f8852 = this.f2797;
            }
            if (c01122.f1418 == -3.4028235E38f) {
                c2266M1213.f8854 = this.f2790;
            }
            if (c01122.f1414 == -3.4028235E38f) {
                c2266M1213.f8850 = this.f2796;
            }
            if (c01122.f1417 == -9223372036854775807L) {
                c2266M1213.f8853 = this.f2789;
            }
            if (c01122.f1415 == -9223372036854775807L) {
                c2266M1213.f8851 = this.f2791;
            }
            C0112 c01123 = new C0112(c2266M1213);
            if (c01123.equals(c0346.f2061)) {
                i = 1;
                c03462 = c0346;
            } else {
                new ᵬˆˀᵣ();
                List list2 = Collections.EMPTY_LIST;
                C4471 c44712 = C4471.f16684;
                C2927 c2927 = C2927.f11359;
                C5420 c5420 = c0346.f2059;
                C4184 c4184 = new C4184();
                c4184.f15658 = c5420.f14506;
                String str4 = c0346.f2062;
                C5582 c5582 = c0346.f2064;
                c0346.f2061.m1213();
                C2927 c29272 = c0346.f2060;
                C4962 c49622 = c0346.f2063;
                if (c49622 != null) {
                    String str5 = c49622.f18442;
                    Uri uri3 = c49622.f18441;
                    List list3 = c49622.f18440;
                    ?? r10 = c49622.f18443;
                    new ᵬˆˀᵣ();
                    i = 1;
                    c0112 = c01123;
                    str = str5;
                    j = c49622.f18439;
                    uri = uri3;
                    list = list3;
                    c4471 = r10;
                } else {
                    i = 1;
                    c0112 = c01123;
                    uri = null;
                    str = null;
                    list = list2;
                    c4471 = c44712;
                    j = -9223372036854775807L;
                }
                C2266 c2266M12132 = c0112.m1213();
                C4962 c49623 = uri != null ? new C4962(uri, str, null, list, c4471, j) : null;
                if (str4 == null) {
                    str4 = "";
                }
                String str6 = str4;
                C5420 c54202 = new C5420(c4184);
                C0112 c01124 = new C0112(c2266M12132);
                if (c5582 == null) {
                    c5582 = C5582.f20926;
                }
                c03462 = new C0346(str6, c54202, c49623, c01124, c5582, c29272);
            }
            InterfaceC4865 interfaceC4865Mo405 = interfaceC4667M9465.mo405(c03462);
            AbstractC2692 abstractC2692 = c03462.f2063.f18443;
            if (!abstractC2692.isEmpty()) {
                InterfaceC4865[] interfaceC4865Arr = new InterfaceC4865[abstractC2692.size() + 1];
                interfaceC4865Arr[0] = interfaceC4865Mo405;
                if (abstractC2692.size() > 0) {
                    if (!this.f2793) {
                        this.f2795.getClass();
                        C0633 c0633 = (C0633) abstractC2692.get(0);
                        int i2 = i;
                        new ArrayList(i2);
                        new HashSet(i2);
                        new CopyOnWriteArrayList();
                        new CopyOnWriteArrayList();
                        C4421 c4421 = AbstractC2692.f10429;
                        C4471 c44713 = C4471.f16684;
                        List list4 = Collections.EMPTY_LIST;
                        C4471 c44714 = C4471.f16684;
                        C2927 c29273 = C2927.f11359;
                        Uri uri4 = Uri.EMPTY;
                        c0633.getClass();
                        throw null;
                    }
                    C2153 c2153 = new C2153();
                    ((C0633) abstractC2692.get(0)).getClass();
                    ArrayList arrayList = AbstractC2924.f11356;
                    c2153.f8516 = null;
                    ((C0633) abstractC2692.get(0)).getClass();
                    c2153.f8527 = null;
                    ((C0633) abstractC2692.get(0)).getClass();
                    c2153.f8492 = 0;
                    ((C0633) abstractC2692.get(0)).getClass();
                    c2153.f8497 = 0;
                    ((C0633) abstractC2692.get(0)).getClass();
                    c2153.f8520 = null;
                    ((C0633) abstractC2692.get(0)).getClass();
                    c2153.f8512 = null;
                    C3446 c3446 = new C3446(c2153);
                    if (this.f2792.ᵻᵢﹳᵰ(c3446)) {
                        C2153 c2153M7829 = c3446.m7829();
                        c2153M7829.f8516 = AbstractC2924.m7101("application/x-media3-cues");
                        c2153M7829.f8522 = c3446.f12929;
                        c2153M7829.f8530 = this.f2792.ᵸʓᵠ(c3446);
                        new C3446(c2153M7829);
                    }
                    ((C0633) abstractC2692.get(0)).getClass();
                    throw null;
                }
                interfaceC4865Mo405 = new C0827(interfaceC4865Arr);
            }
            C5420 c54203 = c03462.f2059;
            if (c54203.f14506 != Long.MIN_VALUE) {
                C5466 c5466 = new C5466(interfaceC4865Mo405);
                ᵛᵾˏ.ᵿʗᵝʽ(!c5466.f20526);
                long j3 = c54203.f14506;
                ᵛᵾˏ.ᵿʗᵝʽ(!c5466.f20526);
                c5466.f20525 = j3;
                ᵛᵾˏ.ᵿʗᵝʽ(!c5466.f20526);
                c5466.f20523 = true;
                ᵛᵾˏ.ᵿʗᵝʽ(!c5466.f20526);
                ᵛᵾˏ.ᵿʗᵝʽ(!c5466.f20526);
                ᵛᵾˏ.ᵿʗᵝʽ(!c5466.f20526);
                ᵛᵾˏ.ᵿʗᵝʽ(!c5466.f20526);
                c5466.f20526 = true;
                interfaceC4865Mo405 = new C4632(c5466);
            }
            c03462.f2063.getClass();
            c03462.f2063.getClass();
            return interfaceC4865Mo405;
        } catch (ClassNotFoundException e) {
            C2707.m6713(e);
            return null;
        }
    }

    @Override // defpackage.InterfaceC4667
    /* renamed from: ᵥᵯˎ */
    public final InterfaceC4667 mo406(C1899 c1899) {
        ᵛᵾˏ.ᵨᵳʝ(c1899, "MediaSource.Factory#setLoadErrorHandlingPolicy no longer handles null by instantiating a new DefaultLoadErrorHandlingPolicy. Explicitly construct and pass an instance in order to retain the old behavior.");
        C4430 c4430 = this.f2794;
        c4430.f16560 = c1899;
        Iterator it = c4430.f16559.values().iterator();
        while (it.hasNext()) {
            ((InterfaceC4667) it.next()).mo406(c1899);
        }
        return this;
    }

    @Override // defpackage.InterfaceC4667
    /* renamed from: ᵴᵳ */
    public final InterfaceC4667 mo407(boolean z) {
        this.f2793 = z;
        C4430 c4430 = this.f2794;
        c4430.f16556 = z;
        C2114 c2114 = c4430.f16561;
        synchronized (c2114) {
            c2114.f8362 = z;
        }
        Iterator it = c4430.f16559.values().iterator();
        while (it.hasNext()) {
            ((InterfaceC4667) it.next()).mo407(z);
        }
        return this;
    }

    @Override // defpackage.InterfaceC4667
    /* renamed from: ᵻᵢﹳᵰ */
    public final InterfaceC4667 mo408(InterfaceC2050 interfaceC2050) {
        ᵛᵾˏ.ᵨᵳʝ(interfaceC2050, "MediaSource.Factory#setDrmSessionManagerProvider no longer handles null by instantiating a new DefaultDrmSessionManagerProvider. Explicitly construct and pass an instance in order to retain the old behavior.");
        C4430 c4430 = this.f2794;
        c4430.f16563 = interfaceC2050;
        Iterator it = c4430.f16559.values().iterator();
        while (it.hasNext()) {
            ((InterfaceC4667) it.next()).mo408(interfaceC2050);
        }
        return this;
    }
}
