package p138.p176.p177.p190.p217.p222;

import android.net.Uri;
import android.text.TextUtils;
import java.io.EOFException;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import p138.p139.p143.p144.C2803;
import p138.p176.p177.p190.C3431;
import p138.p176.p177.p190.p194.C3526;
import p138.p176.p177.p190.p198.C3558;
import p138.p176.p177.p190.p198.InterfaceC3561;
import p138.p176.p177.p190.p198.p203.C3606;
import p138.p176.p177.p190.p198.p204.C3620;
import p138.p176.p177.p190.p198.p207.C3651;
import p138.p176.p177.p190.p198.p207.C3653;
import p138.p176.p177.p190.p198.p207.C3655;
import p138.p176.p177.p190.p198.p207.C3657;
import p138.p176.p177.p190.p198.p207.C3687;
import p138.p176.p177.p190.p210.C3710;
import p138.p176.p177.p190.p217.p222.InterfaceC3905;
import p138.p176.p177.p190.p239.C4134;
import p138.p176.p177.p190.p239.C4149;

/* JADX INFO: renamed from: ދ.ހ.֏.ؠ.ໞ.ޟ.ރ, reason: contains not printable characters */
/* JADX INFO: loaded from: classes.dex */
public final class C3896 implements InterfaceC3905 {

    /* JADX INFO: renamed from: ؠ, reason: contains not printable characters */
    public final int f12044;

    /* JADX INFO: renamed from: ހ, reason: contains not printable characters */
    public final boolean f12045;

    public C3896() {
        this.f12044 = 0;
        this.f12045 = true;
    }

    public C3896(int i, boolean z) {
        this.f12044 = i;
        this.f12045 = z;
    }

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public static C3620 m6301(C4149 c4149, C3431 c3431, List<C3431> list) {
        boolean z;
        C3710 c3710 = c3431.f10088;
        if (c3710 != null) {
            int i = 0;
            while (true) {
                C3710.InterfaceC3712[] interfaceC3712Arr = c3710.f11440;
                if (i >= interfaceC3712Arr.length) {
                    break;
                }
                C3710.InterfaceC3712 interfaceC3712 = interfaceC3712Arr[i];
                if (interfaceC3712 instanceof C3915) {
                    z = !((C3915) interfaceC3712).f12185.isEmpty();
                    break;
                }
                i++;
            }
        } else {
            z = false;
        }
        int i2 = z ? 4 : 0;
        if (list == null) {
            list = Collections.emptyList();
        }
        return new C3620(i2, c4149, null, list);
    }

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public static C3687 m6302(int i, boolean z, C3431 c3431, List<C3431> list, C4149 c4149) {
        int i2 = i | 16;
        if (list != null) {
            i2 |= 32;
        } else {
            list = z ? Collections.singletonList(C3431.m5579((String) null, "application/cea-608", 0, (String) null, (C3526) null)) : Collections.emptyList();
        }
        String str = c3431.f10087;
        if (!TextUtils.isEmpty(str)) {
            if (!"audio/mp4a-latm".equals(C4134.m6651(str))) {
                i2 |= 2;
            }
            if (!"video/avc".equals(C4134.m6656(str))) {
                i2 |= 4;
            }
        }
        return new C3687(2, c4149, new C3657(i2, list));
    }

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public static InterfaceC3905.C3906 m6303(InterfaceC3561 interfaceC3561) {
        boolean z = true;
        boolean z2 = (interfaceC3561 instanceof C3655) || (interfaceC3561 instanceof C3651) || (interfaceC3561 instanceof C3653) || (interfaceC3561 instanceof C3606);
        if (!(interfaceC3561 instanceof C3687) && !(interfaceC3561 instanceof C3620)) {
            z = false;
        }
        return new InterfaceC3905.C3906(interfaceC3561, z2, z);
    }

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public static boolean m6304(InterfaceC3561 interfaceC3561, C3558 c3558) {
        try {
            return interfaceC3561.mo5890(c3558);
        } catch (EOFException unused) {
            return false;
        } finally {
            c3558.f10565 = 0;
        }
    }

    @Override // p138.p176.p177.p190.p217.p222.InterfaceC3905
    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public InterfaceC3905.C3906 mo6305(InterfaceC3561 interfaceC3561, Uri uri, C3431 c3431, List<C3431> list, C4149 c4149, Map<String, List<String>> map, C3558 c3558) {
        if (interfaceC3561 != null) {
            if ((interfaceC3561 instanceof C3687) || (interfaceC3561 instanceof C3620)) {
                return m6303(interfaceC3561);
            }
            if ((interfaceC3561 instanceof C3920 ? m6303(new C3920(c3431.f10108, c4149)) : interfaceC3561 instanceof C3655 ? m6303(new C3655(0)) : interfaceC3561 instanceof C3651 ? m6303(new C3651()) : interfaceC3561 instanceof C3653 ? m6303(new C3653()) : interfaceC3561 instanceof C3606 ? m6303(new C3606(0, -9223372036854775807L)) : null) == null) {
                StringBuilder sbM4889 = C2803.m4889("Unexpected previousExtractor type: ");
                sbM4889.append(interfaceC3561.getClass().getSimpleName());
                throw new IllegalArgumentException(sbM4889.toString());
            }
        }
        String lastPathSegment = uri.getLastPathSegment();
        if (lastPathSegment == null) {
            lastPathSegment = "";
        }
        InterfaceC3561 c3920 = ("text/vtt".equals(c3431.f10090) || lastPathSegment.endsWith(".webvtt") || lastPathSegment.endsWith(".vtt")) ? new C3920(c3431.f10108, c4149) : lastPathSegment.endsWith(".aac") ? new C3655(0) : (lastPathSegment.endsWith(".ac3") || lastPathSegment.endsWith(".ec3")) ? new C3651() : lastPathSegment.endsWith(".ac4") ? new C3653() : lastPathSegment.endsWith(".mp3") ? new C3606(0, 0L) : (lastPathSegment.endsWith(".mp4") || lastPathSegment.startsWith(".m4", lastPathSegment.length() + (-4)) || lastPathSegment.startsWith(".mp4", lastPathSegment.length() + (-5)) || lastPathSegment.startsWith(".cmf", lastPathSegment.length() + (-5))) ? m6301(c4149, c3431, list) : m6302(this.f12044, this.f12045, c3431, list, c4149);
        c3558.f10565 = 0;
        if (m6304(c3920, c3558)) {
            return m6303(c3920);
        }
        if (!(c3920 instanceof C3920)) {
            C3920 c39202 = new C3920(c3431.f10108, c4149);
            if (m6304(c39202, c3558)) {
                return m6303(c39202);
            }
        }
        if (!(c3920 instanceof C3655)) {
            C3655 c3655 = new C3655(0);
            if (m6304(c3655, c3558)) {
                return m6303(c3655);
            }
        }
        if (!(c3920 instanceof C3651)) {
            C3651 c3651 = new C3651();
            if (m6304(c3651, c3558)) {
                return m6303(c3651);
            }
        }
        if (!(c3920 instanceof C3653)) {
            C3653 c3653 = new C3653();
            if (m6304(c3653, c3558)) {
                return m6303(c3653);
            }
        }
        if (!(c3920 instanceof C3606)) {
            C3606 c3606 = new C3606(0, 0L);
            if (m6304(c3606, c3558)) {
                return m6303(c3606);
            }
        }
        if (!(c3920 instanceof C3620)) {
            C3620 c3620M6301 = m6301(c4149, c3431, list);
            if (m6304(c3620M6301, c3558)) {
                return m6303(c3620M6301);
            }
        }
        if (!(c3920 instanceof C3687)) {
            C3687 c3687M6302 = m6302(this.f12044, this.f12045, c3431, list, c4149);
            if (m6304(c3687M6302, c3558)) {
                return m6303(c3687M6302);
            }
        }
        return m6303(c3920);
    }
}
