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;

/* JADX INFO: renamed from: ᵤᵧʧ, reason: contains not printable characters */
/* JADX INFO: loaded from: classes3.dex */
public final class C3451 implements InterfaceC1070 {

    /* JADX INFO: renamed from: ʿٴˇ, reason: contains not printable characters */
    public InterfaceC1070 f13303;

    /* JADX INFO: renamed from: ˈᵲᵢ, reason: contains not printable characters */
    public InterfaceC1070 f13304;

    /* JADX INFO: renamed from: ˌᴵ, reason: contains not printable characters */
    public final Context f13305;

    /* JADX INFO: renamed from: ˌᵨʠᵫ, reason: contains not printable characters */
    public C3103 f13306;

    /* JADX INFO: renamed from: ˑˊᵲ, reason: contains not printable characters */
    public C3309 f13307;

    /* JADX INFO: renamed from: ᵔᵖᵹᵫ, reason: contains not printable characters */
    public final InterfaceC1070 f13308;

    /* JADX INFO: renamed from: ᵜᵪʾ, reason: contains not printable characters */
    public final ArrayList f13309;

    /* JADX INFO: renamed from: ᵨᵼⁱ, reason: contains not printable characters */
    public C4363 f13310;

    /* JADX INFO: renamed from: ᵯᵷʽ, reason: contains not printable characters */
    public C1248 f13311;

    /* JADX INFO: renamed from: ᵶˇᵱ, reason: contains not printable characters */
    public C0232 f13312;

    /* JADX INFO: renamed from: ᵸˆˁ, reason: contains not printable characters */
    public C3986 f13313;

    public C3451(Context context, InterfaceC1070 interfaceC1070) {
        this.f13305 = context.getApplicationContext();
        interfaceC1070.getClass();
        this.f13308 = interfaceC1070;
        this.f13309 = new ArrayList();
    }

    /* JADX INFO: renamed from: ːˏᵟᵯ, reason: contains not printable characters */
    public static void m7864(InterfaceC1070 interfaceC1070, C4216 c4216) {
        if (interfaceC1070 != null) {
            interfaceC1070.mo1309(c4216);
        }
    }

    @Override // defpackage.InterfaceC1070
    public final void close() {
        InterfaceC1070 interfaceC1070 = this.f13303;
        if (interfaceC1070 != null) {
            try {
                interfaceC1070.close();
            } finally {
                this.f13303 = null;
            }
        }
    }

    @Override // defpackage.InterfaceC0372
    public final int read(byte[] bArr, int i, int i2) {
        InterfaceC1070 interfaceC1070 = this.f13303;
        interfaceC1070.getClass();
        return interfaceC1070.read(bArr, i, i2);
    }

    @Override // defpackage.InterfaceC1070
    /* JADX INFO: renamed from: ˉᵲ */
    public final Map mo1306() {
        InterfaceC1070 interfaceC1070 = this.f13303;
        return interfaceC1070 == null ? Collections.EMPTY_MAP : interfaceC1070.mo1306();
    }

    @Override // defpackage.InterfaceC1070
    /* JADX INFO: renamed from: ᵯᵷʽ */
    public final Uri mo1307() {
        InterfaceC1070 interfaceC1070 = this.f13303;
        if (interfaceC1070 == null) {
            return null;
        }
        return interfaceC1070.mo1307();
    }

    /* JADX INFO: renamed from: ᵲᵶᵳˈ, reason: contains not printable characters */
    public final void m7865(InterfaceC1070 interfaceC1070) {
        int i = 0;
        while (true) {
            ArrayList arrayList = this.f13309;
            if (i >= arrayList.size()) {
                return;
            }
            interfaceC1070.mo1309((C4216) arrayList.get(i));
            i++;
        }
    }

    @Override // defpackage.InterfaceC1070
    /* JADX INFO: renamed from: ᵵᵽ */
    public final long mo1308(C0084 c0084) {
        ᵻᵪ.ˌᴵ(this.f13303 == null);
        Uri uri = c0084.f1291;
        String scheme = uri.getScheme();
        String str = AbstractC0956.f4222;
        String scheme2 = uri.getScheme();
        boolean zIsEmpty = TextUtils.isEmpty(scheme2);
        Context context = this.f13305;
        if (zIsEmpty || Objects.equals(scheme2, "file")) {
            String path = uri.getPath();
            if (path == null || !path.startsWith("/android_asset/")) {
                if (this.f13310 == null) {
                    C4363 c4363 = new C4363(false);
                    this.f13310 = c4363;
                    m7865(c4363);
                }
                this.f13303 = this.f13310;
            } else {
                if (this.f13311 == null) {
                    C1248 c1248 = new C1248(context);
                    this.f13311 = c1248;
                    m7865(c1248);
                }
                this.f13303 = this.f13311;
            }
        } else if ("asset".equals(scheme)) {
            if (this.f13311 == null) {
                C1248 c12482 = new C1248(context);
                this.f13311 = c12482;
                m7865(c12482);
            }
            this.f13303 = this.f13311;
        } else if ("content".equals(scheme)) {
            if (this.f13312 == null) {
                C0232 c0232 = new C0232(context);
                this.f13312 = c0232;
                m7865(c0232);
            }
            this.f13303 = this.f13312;
        } else {
            boolean zEquals = "rtmp".equals(scheme);
            InterfaceC1070 interfaceC1070 = this.f13308;
            if (zEquals) {
                if (this.f13304 == null) {
                    try {
                        InterfaceC1070 interfaceC10702 = (InterfaceC1070) Class.forName("androidx.media3.datasource.rtmp.RtmpDataSource").getConstructor(null).newInstance(null);
                        this.f13304 = interfaceC10702;
                        m7865(interfaceC10702);
                    } 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.f13304 == null) {
                        this.f13304 = interfaceC1070;
                    }
                }
                this.f13303 = this.f13304;
            } else if ("udp".equals(scheme)) {
                if (this.f13306 == null) {
                    C3103 c3103 = new C3103();
                    this.f13306 = c3103;
                    m7865(c3103);
                }
                this.f13303 = this.f13306;
            } else if ("data".equals(scheme)) {
                if (this.f13313 == null) {
                    C3986 c3986 = new C3986(false);
                    this.f13313 = c3986;
                    m7865(c3986);
                }
                this.f13303 = this.f13313;
            } else if ("rawresource".equals(scheme) || "android.resource".equals(scheme)) {
                if (this.f13307 == null) {
                    C3309 c3309 = new C3309(context);
                    this.f13307 = c3309;
                    m7865(c3309);
                }
                this.f13303 = this.f13307;
            } else {
                this.f13303 = interfaceC1070;
            }
        }
        return this.f13303.mo1308(c0084);
    }

    @Override // defpackage.InterfaceC1070
    /* JADX INFO: renamed from: ᵶˇᵱ */
    public final void mo1309(C4216 c4216) {
        c4216.getClass();
        this.f13308.mo1309(c4216);
        this.f13309.add(c4216);
        m7864(this.f13310, c4216);
        m7864(this.f13311, c4216);
        m7864(this.f13312, c4216);
        m7864(this.f13304, c4216);
        m7864(this.f13306, c4216);
        m7864(this.f13313, c4216);
        m7864(this.f13307, c4216);
    }
}
