package defpackage;

import android.text.TextUtils;
import java.util.ArrayList;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

/* renamed from: ᵝᵫˈ, reason: contains not printable characters */
/* loaded from: classes3.dex */
public abstract class AbstractC2924 {

    /* renamed from: ᵥᵯˎ, reason: contains not printable characters */
    public static final ArrayList f11356 = new ArrayList();

    /* renamed from: ᵴᵳ, reason: contains not printable characters */
    public static final Pattern f11357 = Pattern.compile("^mp4a\\.([a-zA-Z0-9]{2})(?:\\.([0-9]{1,2}))?$");

    /* renamed from: ˇʼʤˎ, reason: contains not printable characters */
    public static String m7100(String str) {
        C4697 c4697M7103;
        String strM7104 = null;
        if (str != null) {
            String str2 = ᵿᵧ.ᵺʙ(str.trim());
            if (str2.startsWith("avc1") || str2.startsWith("avc3")) {
                return "video/avc";
            }
            if (str2.startsWith("hev1") || str2.startsWith("hvc1")) {
                return "video/hevc";
            }
            if (str2.startsWith("vvc1") || str2.startsWith("vvi1")) {
                return "video/vvc";
            }
            if (str2.startsWith("dvav") || str2.startsWith("dva1") || str2.startsWith("dvhe") || str2.startsWith("dvh1") || str2.startsWith("dav1")) {
                return "video/dolby-vision";
            }
            if (str2.startsWith("av01")) {
                return "video/av01";
            }
            if (str2.startsWith("vp9") || str2.startsWith("vp09")) {
                return "video/x-vnd.on2.vp9";
            }
            if (str2.startsWith("vp8") || str2.startsWith("vp08")) {
                return "video/x-vnd.on2.vp8";
            }
            if (str2.startsWith("mp4a")) {
                if (str2.startsWith("mp4a.") && (c4697M7103 = m7103(str2)) != null) {
                    strM7104 = m7104(c4697M7103.f17367);
                }
                return strM7104 == null ? "audio/mp4a-latm" : strM7104;
            }
            if (str2.startsWith("mha1")) {
                return "audio/mha1";
            }
            if (str2.startsWith("mhm1")) {
                return "audio/mhm1";
            }
            if (str2.startsWith("ac-3") || str2.startsWith("dac3")) {
                return "audio/ac3";
            }
            if (str2.startsWith("ec-3") || str2.startsWith("dec3")) {
                return "audio/eac3";
            }
            if (str2.startsWith("ec+3")) {
                return "audio/eac3-joc";
            }
            if (str2.startsWith("ac-4") || str2.startsWith("dac4")) {
                return "audio/ac4";
            }
            if (str2.startsWith("dtsc")) {
                return "audio/vnd.dts";
            }
            if (str2.startsWith("dtse")) {
                return "audio/vnd.dts.hd;profile=lbr";
            }
            if (str2.startsWith("dtsh") || str2.startsWith("dtsl")) {
                return "audio/vnd.dts.hd";
            }
            if (str2.startsWith("dtsx")) {
                return "audio/vnd.dts.uhd;profile=p2";
            }
            if (str2.startsWith("opus")) {
                return "audio/opus";
            }
            if (str2.startsWith("vorbis")) {
                return "audio/vorbis";
            }
            if (str2.startsWith("flac")) {
                return "audio/flac";
            }
            if (str2.startsWith("stpp")) {
                return "application/ttml+xml";
            }
            if (str2.startsWith("wvtt")) {
                return "text/vtt";
            }
            if (str2.contains("cea708")) {
                return "application/cea-708";
            }
            if (str2.contains("eia608") || str2.contains("cea608")) {
                return "application/cea-608";
            }
            ArrayList arrayList = f11356;
            if (arrayList.size() > 0) {
                arrayList.get(0).getClass();
                C0910.m3050();
                return null;
            }
        }
        return null;
    }

    /* renamed from: ˌʾˀ, reason: contains not printable characters */
    public static String m7101(String str) {
        String str2;
        if (str == null) {
            return null;
        }
        str2 = ᵿᵧ.ᵺʙ(str);
        str2.getClass();
        switch (str2) {
            case "video/x-mvhevc":
                return "video/mv-hevc";
            case "audio/x-flac":
                return "audio/flac";
            case "application/x-mpegurl":
                return "application/x-mpegURL";
            case "audio/x-wav":
                return "audio/wav";
            case "audio/mpeg-l1":
                return "audio/mpeg-L1";
            case "audio/mpeg-l2":
                return "audio/mpeg-L2";
            case "audio/mp3":
                return "audio/mpeg";
            default:
                return str2;
        }
    }

    /* renamed from: ˌᵜᵹᵩ, reason: contains not printable characters */
    public static boolean m7102(String str, String str2) {
        if (str == null) {
            return false;
        }
        if (str.startsWith("dvhe") || str.startsWith("dvh1") || str.startsWith("dav1")) {
            return true;
        }
        if (str2 == null) {
            return false;
        }
        return (str2.startsWith("dvhe") && str.startsWith("hev1")) || (str2.startsWith("dvh1") && str.startsWith("hvc1")) || ((str2.startsWith("dvav") && str.startsWith("avc3")) || ((str2.startsWith("dva1") && str.startsWith("avc1")) || (str2.startsWith("dav1") && str.startsWith("av01"))));
    }

    /* renamed from: ˎˏʜʾ, reason: contains not printable characters */
    public static C4697 m7103(String str) {
        Matcher matcher = f11357.matcher(str);
        if (!matcher.matches()) {
            return null;
        }
        String strGroup = matcher.group(1);
        strGroup.getClass();
        String strGroup2 = matcher.group(2);
        try {
            return new C4697(Integer.parseInt(strGroup, 16), strGroup2 != null ? Integer.parseInt(strGroup2) : 0, 3);
        } catch (NumberFormatException unused) {
            return null;
        }
    }

    /* renamed from: ˏˋٴ, reason: contains not printable characters */
    public static String m7104(int i) {
        if (i == 32) {
            return "video/mp4v-es";
        }
        if (i == 33) {
            return "video/avc";
        }
        if (i == 35) {
            return "video/hevc";
        }
        if (i == 64) {
            return "audio/mp4a-latm";
        }
        if (i == 163) {
            return "video/wvc1";
        }
        if (i == 177) {
            return "video/x-vnd.on2.vp9";
        }
        if (i == 221) {
            return "audio/vorbis";
        }
        if (i == 165) {
            return "audio/ac3";
        }
        if (i == 166) {
            return "audio/eac3";
        }
        switch (i) {
            case 96:
            case 97:
            case 98:
            case 99:
            case 100:
            case 101:
                return "video/mpeg2";
            case 102:
            case 103:
            case 104:
                return "audio/mp4a-latm";
            case 105:
            case 107:
                return "audio/mpeg";
            case 106:
                return "video/mpeg";
            case 108:
                return "image/jpeg";
            default:
                switch (i) {
                    case 169:
                    case 172:
                        return "audio/vnd.dts";
                    case 170:
                    case 171:
                        return "audio/vnd.dts.hd";
                    case 173:
                        return "audio/opus";
                    case 174:
                        return "audio/ac4";
                    default:
                        return null;
                }
        }
    }

    /* renamed from: ˏᵙ, reason: contains not printable characters */
    public static String m7105(String str, String str2) {
        if (str != null && str2 != null) {
            String[] strArrM8156 = AbstractC3558.m8156(str);
            StringBuilder sb = new StringBuilder();
            for (String str3 : strArrM8156) {
                if (str2.equals(m7100(str3))) {
                    if (sb.length() > 0) {
                        sb.append(",");
                    }
                    sb.append(str3);
                }
            }
            if (sb.length() > 0) {
                return sb.toString();
            }
        }
        return null;
    }

    /* renamed from: ᵝᵵᵺ, reason: contains not printable characters */
    public static int m7106(String str) {
        if (TextUtils.isEmpty(str)) {
            return -1;
        }
        if (m7113(str)) {
            return 1;
        }
        if (m7110(str)) {
            return 2;
        }
        if (m7108(str)) {
            return 3;
        }
        if (m7109(str)) {
            return 4;
        }
        if ("application/id3".equals(str) || "application/x-emsg".equals(str) || "application/x-scte35".equals(str) || "application/x-icy".equals(str) || "application/vnd.dvb.ait".equals(str) || "application/meta".equals(str) || "application/x-itut-t35".equals(str)) {
            return 5;
        }
        if ("application/x-camera-motion".equals(str)) {
            return 6;
        }
        ArrayList arrayList = f11356;
        if (arrayList.size() <= 0) {
            return -1;
        }
        arrayList.get(0).getClass();
        C0910.m3050();
        return 0;
    }

    /* renamed from: ᵥᵯˎ, reason: contains not printable characters */
    public static boolean m7107(String str, String str2) {
        C4697 c4697M7103;
        int iM9875;
        if (str == null) {
            return false;
        }
        switch (str) {
            case "audio/mp4a-latm":
                if (str2 != null && (c4697M7103 = m7103(str2)) != null && (iM9875 = c4697M7103.m9875()) != 0 && iM9875 != 16) {
                }
                break;
        }
        return false;
    }

    /* renamed from: ᵪʩ, reason: contains not printable characters */
    public static boolean m7108(String str) {
        return "text".equals(m7114(str)) || "application/x-media3-cues".equals(str) || "application/cea-608".equals(str) || "application/cea-708".equals(str) || "application/x-mp4-cea-608".equals(str) || "application/x-subrip".equals(str) || "application/ttml+xml".equals(str) || "application/x-quicktime-tx3g".equals(str) || "application/x-mp4-vtt".equals(str) || "application/x-rawcc".equals(str) || "application/vobsub".equals(str) || "application/pgs".equals(str) || "application/dvbsubs".equals(str);
    }

    /* renamed from: ᵯٴᵦ, reason: contains not printable characters */
    public static boolean m7109(String str) {
        return "image".equals(m7114(str)) || "application/x-image-uri".equals(str);
    }

    /* renamed from: ᵳٴᵶ, reason: contains not printable characters */
    public static boolean m7110(String str) {
        return "video".equals(m7114(str));
    }

    /* renamed from: ᵴᵳ, reason: contains not printable characters */
    public static String m7111(String str) {
        if (str == null) {
            return null;
        }
        for (String str2 : AbstractC3558.m8156(str)) {
            String strM7100 = m7100(str2);
            if (strM7100 != null && m7113(strM7100)) {
                return strM7100;
            }
        }
        return null;
    }

    /* renamed from: ᵶᵷᵕ, reason: contains not printable characters */
    public static String m7112(String str) {
        if (str == null) {
            return null;
        }
        for (String str2 : AbstractC3558.m8156(str)) {
            String strM7100 = m7100(str2);
            if (strM7100 != null && m7110(strM7100)) {
                return strM7100;
            }
        }
        return null;
    }

    /* renamed from: ᵸˑ, reason: contains not printable characters */
    public static boolean m7113(String str) {
        return "audio".equals(m7114(str));
    }

    /* renamed from: ᵹᵝᵶ, reason: contains not printable characters */
    public static String m7114(String str) {
        int iIndexOf;
        if (str == null || (iIndexOf = str.indexOf(47)) == -1) {
            return null;
        }
        return str.substring(0, iIndexOf);
    }

    /* renamed from: ᵻᵢﹳᵰ, reason: contains not printable characters */
    public static int m7115(String str, String str2) {
        C4697 c4697M7103;
        str.getClass();
        switch (str) {
            case "audio/eac3-joc":
                return 18;
            case "audio/vnd.dts.hd;profile=lbr":
                return 8;
            case "audio/vnd.dts":
                return 7;
            case "audio/mp4a-latm":
                if (str2 == null || (c4697M7103 = m7103(str2)) == null) {
                    return 0;
                }
                return c4697M7103.m9875();
            case "audio/ac3":
                return 5;
            case "audio/ac4":
                return 17;
            case "audio/dsd":
                return 31;
            case "audio/vnd.dts.uhd;profile=p2":
                return 30;
            case "audio/eac3":
                return 6;
            case "audio/mpeg":
                return 9;
            case "audio/opus":
                return 20;
            case "audio/vnd.dts.hd":
                return 8;
            case "audio/true-hd":
                return 14;
            default:
                return 0;
        }
    }
}
