package defpackage;

import android.content.Context;
import android.net.Uri;
import android.text.TextUtils;
import j$.util.Objects;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Map;

/* renamed from: ᵘᵢᵹ, reason: contains not printable characters */
/* loaded from: classes3.dex */
public final class C2528 implements InterfaceC2569 {

    /* renamed from: ˀᵗᵝᵭ, reason: contains not printable characters */
    public InterfaceC2569 f9866;

    /* renamed from: ˎˑː, reason: contains not printable characters */
    public C2332 f9867;

    /* renamed from: ˑᵥˁ, reason: contains not printable characters */
    public C5015 f9868;

    /* renamed from: ᵡˎ, reason: contains not printable characters */
    public C1093 f9869;

    /* renamed from: ᵡⁱᵥ, reason: contains not printable characters */
    public C3727 f9870;

    /* renamed from: ᵢˇᵭ, reason: contains not printable characters */
    public final ArrayList f9871;

    /* renamed from: ᵤᵙᵷ, reason: contains not printable characters */
    public C3714 f9872;

    /* renamed from: ᵧᵾˀˈ, reason: contains not printable characters */
    public final Context f9873;

    /* renamed from: ᵮᵠـˌ, reason: contains not printable characters */
    public InterfaceC2569 f9874;

    /* renamed from: ᵾᵬ, reason: contains not printable characters */
    public C0087 f9875;

    /* renamed from: ᵿʗᵝʽ, reason: contains not printable characters */
    public final InterfaceC2569 f9876;

    public C2528(Context context, InterfaceC2569 interfaceC2569) {
        this.f9873 = context.getApplicationContext();
        interfaceC2569.getClass();
        this.f9876 = interfaceC2569;
        this.f9871 = new ArrayList();
    }

    /* renamed from: ˏᵙ, reason: contains not printable characters */
    public static void m6371(InterfaceC2569 interfaceC2569, C3873 c3873) {
        if (interfaceC2569 != null) {
            interfaceC2569.mo1415(c3873);
        }
    }

    @Override // defpackage.InterfaceC2569
    public final void close() {
        InterfaceC2569 interfaceC2569 = this.f9874;
        if (interfaceC2569 != null) {
            try {
                interfaceC2569.close();
            } finally {
                this.f9874 = null;
            }
        }
    }

    @Override // defpackage.InterfaceC1463
    public final int read(byte[] bArr, int i, int i2) {
        InterfaceC2569 interfaceC2569 = this.f9874;
        interfaceC2569.getClass();
        return interfaceC2569.read(bArr, i, i2);
    }

    @Override // defpackage.InterfaceC2569
    /* renamed from: ˏˋٴ */
    public final long mo1165(C4179 c4179) {
        ᵛᵾˏ.ᵿʗᵝʽ(this.f9874 == null);
        Uri uri = c4179.f15620;
        String scheme = uri.getScheme();
        String str = AbstractC3558.f13329;
        String scheme2 = uri.getScheme();
        boolean zIsEmpty = TextUtils.isEmpty(scheme2);
        Context context = this.f9873;
        if (zIsEmpty || Objects.equals(scheme2, "file")) {
            String path = uri.getPath();
            if (path == null || !path.startsWith("/android_asset/")) {
                if (this.f9875 == null) {
                    C0087 c0087 = new C0087(false);
                    this.f9875 = c0087;
                    m6372(c0087);
                }
                this.f9874 = this.f9875;
            } else {
                if (this.f9872 == null) {
                    C3714 c3714 = new C3714(context);
                    this.f9872 = c3714;
                    m6372(c3714);
                }
                this.f9874 = this.f9872;
            }
        } else if ("asset".equals(scheme)) {
            if (this.f9872 == null) {
                C3714 c37142 = new C3714(context);
                this.f9872 = c37142;
                m6372(c37142);
            }
            this.f9874 = this.f9872;
        } else if ("content".equals(scheme)) {
            if (this.f9870 == null) {
                C3727 c3727 = new C3727(context);
                this.f9870 = c3727;
                m6372(c3727);
            }
            this.f9874 = this.f9870;
        } else {
            boolean zEquals = "rtmp".equals(scheme);
            InterfaceC2569 interfaceC2569 = this.f9876;
            if (zEquals) {
                if (this.f9866 == null) {
                    try {
                        InterfaceC2569 interfaceC25692 = (InterfaceC2569) Class.forName("androidx.media3.datasource.rtmp.RtmpDataSource").getConstructor(null).newInstance(null);
                        this.f9866 = interfaceC25692;
                        m6372(interfaceC25692);
                    } catch (ClassNotFoundException unused) {
                        ᵳʿˉ.ᵶʔᵢˊ("Attempting to play RTMP stream without depending on the RTMP extension");
                    } catch (Exception e) {
                        ᵨᴵᵺ.ᵪʩ("Error instantiating RTMP extension", e);
                        return 0L;
                    }
                    if (this.f9866 == null) {
                        this.f9866 = interfaceC2569;
                    }
                }
                this.f9874 = this.f9866;
            } else if ("udp".equals(scheme)) {
                if (this.f9869 == null) {
                    C1093 c1093 = new C1093();
                    this.f9869 = c1093;
                    m6372(c1093);
                }
                this.f9874 = this.f9869;
            } else if ("data".equals(scheme)) {
                if (this.f9868 == null) {
                    C5015 c5015 = new C5015(false);
                    this.f9868 = c5015;
                    m6372(c5015);
                }
                this.f9874 = this.f9868;
            } else if ("rawresource".equals(scheme) || "android.resource".equals(scheme)) {
                if (this.f9867 == null) {
                    C2332 c2332 = new C2332(context);
                    this.f9867 = c2332;
                    m6372(c2332);
                }
                this.f9874 = this.f9867;
            } else {
                this.f9874 = interfaceC2569;
            }
        }
        return this.f9874.mo1165(c4179);
    }

    @Override // defpackage.InterfaceC2569
    /* renamed from: ᵡˎ */
    public final void mo1415(C3873 c3873) {
        c3873.getClass();
        this.f9876.mo1415(c3873);
        this.f9871.add(c3873);
        m6371(this.f9875, c3873);
        m6371(this.f9872, c3873);
        m6371(this.f9870, c3873);
        m6371(this.f9866, c3873);
        m6371(this.f9869, c3873);
        m6371(this.f9868, c3873);
        m6371(this.f9867, c3873);
    }

    /* renamed from: ᵥᵯˎ, reason: contains not printable characters */
    public final void m6372(InterfaceC2569 interfaceC2569) {
        int i = 0;
        while (true) {
            ArrayList arrayList = this.f9871;
            if (i >= arrayList.size()) {
                return;
            }
            interfaceC2569.mo1415((C3873) arrayList.get(i));
            i++;
        }
    }

    @Override // defpackage.InterfaceC2569
    /* renamed from: ᵨᵳʝ */
    public final Map mo1416() {
        InterfaceC2569 interfaceC2569 = this.f9874;
        return interfaceC2569 == null ? Collections.EMPTY_MAP : interfaceC2569.mo1416();
    }

    @Override // defpackage.InterfaceC2569
    /* renamed from: ᵿʗᵝʽ */
    public final Uri mo1166() {
        InterfaceC2569 interfaceC2569 = this.f9874;
        if (interfaceC2569 == null) {
            return null;
        }
        return interfaceC2569.mo1166();
    }
}
