package com.google.android.gms.internal.ads;

import android.net.Uri;
import androidx.annotation.Nullable;
import androidx.media3.exoplayer.rtsp.RtspHeaders;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/* JADX INFO: loaded from: classes2.dex */
public final class l2 implements t2 {

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public static final int[] f13471b = {5, 4, 12, 8, 3, 10, 9, 11, 6, 2, 0, 1, 7, 16, 15, 14, 17, 18, 19, 20, 21};

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    public static final k2 f13472c = new k2(i2.f12326a);

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    public static final k2 f13473d = new k2(w80.f17916h);

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public final va2 f13474a = new va2(5);

    @Nullable
    private zzguf zze;

    public final void a(int i10, ArrayList arrayList) {
        va2 va2Var = this.f13474a;
        switch (i10) {
            case 0:
                arrayList.add(new ba());
                break;
            case 1:
                arrayList.add(new da());
                break;
            case 2:
                arrayList.add(new fa());
                break;
            case 3:
                arrayList.add(new z3());
                break;
            case 4:
                o2 o2VarZza = f13472c.zza(0);
                if (o2VarZza == null) {
                    arrayList.add(new m4());
                } else {
                    arrayList.add(o2VarZza);
                }
                break;
            case 5:
                arrayList.add(new o4());
                break;
            case 6:
                arrayList.add(new g6(new b6(), 0, va2Var));
                break;
            case 7:
                arrayList.add(new m6());
                break;
            case 8:
                arrayList.add(new d7(va2Var, 0, null, null, zzgwa.f19786e, null));
                arrayList.add(new j7(0, va2Var));
                break;
            case 9:
                arrayList.add(new z7());
                break;
            case 10:
                arrayList.add(new bb());
                break;
            case 11:
                if (this.zze == null) {
                    bs1 bs1Var = zzguf.f19771b;
                    this.zze = zzgwa.f19786e;
                }
                arrayList.add(new fb(va2Var, new g91(), new ha(this.zze)));
                break;
            case 12:
                ob obVar = new ob();
                obVar.f14994c = 0;
                obVar.f14995d = -1L;
                obVar.f14997f = -1;
                obVar.f14998g = -1L;
                arrayList.add(obVar);
                break;
            case 14:
                arrayList.add(new s4(1));
                break;
            case 15:
                o2 o2VarZza2 = f13473d.zza(new Object[0]);
                if (o2VarZza2 != null) {
                    arrayList.add(o2VarZza2);
                }
                break;
            case 16:
                arrayList.add(new b4(va2Var));
                break;
            case 17:
                arrayList.add(new j4(1));
                break;
            case 18:
                arrayList.add(new i4(1));
                break;
            case 19:
                arrayList.add(new j4(0));
                break;
            case 20:
                arrayList.add(new s4(0));
                break;
            case 21:
                arrayList.add(new i4(0));
                break;
        }
    }

    /* JADX WARN: Removed duplicated region for block: B:114:0x01c6  */
    /* JADX WARN: Removed duplicated region for block: B:142:0x020a  */
    @Override // com.google.android.gms.internal.ads.t2
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final synchronized o2[] h(Uri uri, Map map) {
        ArrayList arrayList;
        int i10;
        try {
            arrayList = new ArrayList(21);
            List list = (List) map.get(RtspHeaders.CONTENT_TYPE);
            String str = null;
            if (list != null && !list.isEmpty()) {
                str = (String) list.get(0);
            }
            int i11 = 20;
            if (str != null) {
                switch (hc.a(str)) {
                    case "audio/ac3":
                    case "audio/eac3":
                    case "audio/eac3-joc":
                        i10 = 0;
                        break;
                    case "audio/ac4":
                        i10 = 1;
                        break;
                    case "audio/amr":
                    case "audio/3gpp":
                    case "audio/amr-wb":
                        i10 = 3;
                        break;
                    case "audio/flac":
                        i10 = 4;
                        break;
                    case "video/x-flv":
                        i10 = 5;
                        break;
                    case "audio/midi":
                        i10 = 15;
                        break;
                    case "video/x-matroska":
                    case "audio/x-matroska":
                    case "video/webm":
                    case "audio/webm":
                    case "application/webm":
                        i10 = 6;
                        break;
                    case "audio/mpeg":
                        i10 = 7;
                        break;
                    case "video/mp4":
                    case "audio/mp4":
                    case "application/mp4":
                        i10 = 8;
                        break;
                    case "audio/ogg":
                        i10 = 9;
                        break;
                    case "video/mp2p":
                        i10 = 10;
                        break;
                    case "video/mp2t":
                        i10 = 11;
                        break;
                    case "audio/wav":
                        i10 = 12;
                        break;
                    case "text/vtt":
                        i10 = 13;
                        break;
                    case "image/jpeg":
                        i10 = 14;
                        break;
                    case "video/x-msvideo":
                        i10 = 16;
                        break;
                    case "image/png":
                        i10 = 17;
                        break;
                    case "image/webp":
                        i10 = 18;
                        break;
                    case "image/bmp":
                        i10 = 19;
                        break;
                    case "image/heif":
                    case "image/heic":
                        i10 = 20;
                        break;
                    case "image/avif":
                        i10 = 21;
                        break;
                    default:
                        i10 = -1;
                        break;
                }
            } else {
                i10 = -1;
            }
            if (i10 != -1) {
                a(i10, arrayList);
            }
            String lastPathSegment = uri.getLastPathSegment();
            if (lastPathSegment != null) {
                if (lastPathSegment.endsWith(".ac3") || lastPathSegment.endsWith(".ec3")) {
                    i11 = 0;
                } else if (lastPathSegment.endsWith(".ac4")) {
                    i11 = 1;
                } else if (lastPathSegment.endsWith(".adts") || lastPathSegment.endsWith(".aac")) {
                    i11 = 2;
                } else if (lastPathSegment.endsWith(".amr")) {
                    i11 = 3;
                } else if (lastPathSegment.endsWith(".flac")) {
                    i11 = 4;
                } else if (lastPathSegment.endsWith(".flv")) {
                    i11 = 5;
                } else if (lastPathSegment.endsWith(".mid") || lastPathSegment.endsWith(".midi") || lastPathSegment.endsWith(".smf")) {
                    i11 = 15;
                } else if (lastPathSegment.startsWith(".mk", lastPathSegment.length() - 4) || lastPathSegment.endsWith(".webm")) {
                    i11 = 6;
                } else if (lastPathSegment.endsWith(".mp3")) {
                    i11 = 7;
                } else if (lastPathSegment.endsWith(".mp4") || lastPathSegment.startsWith(".m4", lastPathSegment.length() - 4) || lastPathSegment.startsWith(".mp4", lastPathSegment.length() - 5) || lastPathSegment.startsWith(".cmf", lastPathSegment.length() - 5)) {
                    i11 = 8;
                } else if (lastPathSegment.startsWith(".og", lastPathSegment.length() - 4) || lastPathSegment.endsWith(".opus")) {
                    i11 = 9;
                } else if (lastPathSegment.endsWith(".ps") || lastPathSegment.endsWith(".mpeg") || lastPathSegment.endsWith(".mpg") || lastPathSegment.endsWith(".m2p")) {
                    i11 = 10;
                } else if (lastPathSegment.endsWith(".ts") || lastPathSegment.startsWith(".ts", lastPathSegment.length() - 4)) {
                    i11 = 11;
                } else if (lastPathSegment.endsWith(".wav") || lastPathSegment.endsWith(".wave")) {
                    i11 = 12;
                } else if (lastPathSegment.endsWith(".vtt") || lastPathSegment.endsWith(".webvtt")) {
                    i11 = 13;
                } else if (lastPathSegment.endsWith(".jpg") || lastPathSegment.endsWith(".jpeg")) {
                    i11 = 14;
                } else if (lastPathSegment.endsWith(".avi")) {
                    i11 = 16;
                } else if (lastPathSegment.endsWith(".png")) {
                    i11 = 17;
                } else if (lastPathSegment.endsWith(".webp")) {
                    i11 = 18;
                } else if (lastPathSegment.endsWith(".bmp") || lastPathSegment.endsWith(".dib")) {
                    i11 = 19;
                } else if (!lastPathSegment.endsWith(".heic") && !lastPathSegment.endsWith(".heif")) {
                    i11 = lastPathSegment.endsWith(".avif") ? 21 : -1;
                }
            }
            if (i11 != -1 && i11 != i10) {
                a(i11, arrayList);
            }
            int[] iArr = f13471b;
            for (int i12 = 0; i12 < 21; i12++) {
                int i13 = iArr[i12];
                if (i13 != i10 && i13 != i11) {
                    a(i13, arrayList);
                }
            }
        } catch (Throwable th) {
            throw th;
        }
        return (o2[]) arrayList.toArray(new o2[0]);
    }

    @Override // com.google.android.gms.internal.ads.t2, com.google.android.gms.internal.ads.ow0
    /* JADX INFO: renamed from: zza */
    public final synchronized o2[] mo6zza() {
        return h(Uri.EMPTY, new HashMap());
    }
}
