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

import android.text.TextUtils;
import com.google.android.exoplayer2.ParserException;
import java.io.EOFException;
import java.util.Arrays;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.checkerframework.checker.nullness.qual.RequiresNonNull;
import p000.p001.p002.p003.p004.C0567;
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.C3570;
import p138.p176.p177.p190.p198.InterfaceC3561;
import p138.p176.p177.p190.p198.InterfaceC3562;
import p138.p176.p177.p190.p198.InterfaceC3571;
import p138.p176.p177.p190.p198.InterfaceC3575;
import p138.p176.p177.p190.p226.p234.C4008;
import p138.p176.p177.p190.p226.p234.C4012;
import p138.p176.p177.p190.p239.C4140;
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 C3920 implements InterfaceC3561 {

    /* JADX INFO: renamed from: ބ, reason: contains not printable characters */
    public static final Pattern f12192 = Pattern.compile("LOCAL:([^,]+)");

    /* JADX INFO: renamed from: ޅ, reason: contains not printable characters */
    public static final Pattern f12193 = Pattern.compile("MPEGTS:(-?\\d+)");

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public final String f12194;

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

    /* JADX INFO: renamed from: ށ, reason: contains not printable characters */
    public InterfaceC3562 f12197;

    /* JADX INFO: renamed from: ރ, reason: contains not printable characters */
    public int f12199;

    /* JADX INFO: renamed from: ހ, reason: contains not printable characters */
    public final C4140 f12196 = new C4140();

    /* JADX INFO: renamed from: ނ, reason: contains not printable characters */
    public byte[] f12198 = new byte[1024];

    public C3920(String str, C4149 c4149) {
        this.f12194 = str;
        this.f12195 = c4149;
    }

    @Override // p138.p176.p177.p190.p198.InterfaceC3561
    /* JADX INFO: renamed from: ֏ */
    public int mo5886(C3558 c3558, C3570 c3570) throws InterruptedException, ParserException, EOFException {
        Matcher matcher;
        String strM6690;
        C0567.m1856(this.f12197);
        int i = (int) c3558.f10562;
        int i2 = this.f12199;
        byte[] bArr = this.f12198;
        if (i2 == bArr.length) {
            this.f12198 = Arrays.copyOf(bArr, ((i != -1 ? i : bArr.length) * 3) / 2);
        }
        byte[] bArr2 = this.f12198;
        int i3 = this.f12199;
        int iM5870 = c3558.m5870(bArr2, i3, bArr2.length - i3);
        if (iM5870 != -1) {
            int i4 = this.f12199 + iM5870;
            this.f12199 = i4;
            if (i == -1 || i4 != i) {
                return 0;
            }
        }
        C4140 c4140 = new C4140(this.f12198);
        C4012.m6467(c4140);
        long j = 0;
        long jM6466 = 0;
        for (String strM66902 = c4140.m6690(); !TextUtils.isEmpty(strM66902); strM66902 = c4140.m6690()) {
            if (strM66902.startsWith("X-TIMESTAMP-MAP")) {
                Matcher matcher2 = f12192.matcher(strM66902);
                if (!matcher2.find()) {
                    throw new ParserException(C2803.m4879("X-TIMESTAMP-MAP doesn't contain local timestamp: ", strM66902));
                }
                Matcher matcher3 = f12193.matcher(strM66902);
                if (!matcher3.find()) {
                    throw new ParserException(C2803.m4879("X-TIMESTAMP-MAP doesn't contain media timestamp: ", strM66902));
                }
                jM6466 = C4012.m6466(matcher2.group(1));
                j = (Long.parseLong(matcher3.group(1)) * 1000000) / 90000;
            }
        }
        while (true) {
            String strM66903 = c4140.m6690();
            if (strM66903 == null) {
                matcher = null;
                break;
            }
            if (!C4012.f12707.matcher(strM66903).matches()) {
                matcher = C4008.f12692.matcher(strM66903);
                if (matcher.matches()) {
                    break;
                }
            } else {
                do {
                    strM6690 = c4140.m6690();
                    if (strM6690 != null) {
                    }
                } while (!strM6690.isEmpty());
            }
        }
        if (matcher == null) {
            m6335(0L);
        } else {
            long jM64662 = C4012.m6466(matcher.group(1));
            long jM6737 = this.f12195.m6737((((j + jM64662) - jM6466) * 90000) / 1000000);
            InterfaceC3575 interfaceC3575M6335 = m6335(jM6737 - jM64662);
            this.f12196.m6684(this.f12198, this.f12199);
            interfaceC3575M6335.mo5885(this.f12196, this.f12199);
            interfaceC3575M6335.mo5883(jM6737, 1, this.f12199, 0, null);
        }
        return -1;
    }

    @RequiresNonNull({"output"})
    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public final InterfaceC3575 m6335(long j) {
        InterfaceC3575 interfaceC3575Mo5891 = this.f12197.mo5891(0, 3);
        interfaceC3575Mo5891.mo5884(C3431.m5587((String) null, "text/vtt", (String) null, -1, 0, this.f12194, (C3526) null, j));
        this.f12197.mo5892();
        return interfaceC3575Mo5891;
    }

    @Override // p138.p176.p177.p190.p198.InterfaceC3561
    /* JADX INFO: renamed from: ֏ */
    public void mo5887() {
    }

    @Override // p138.p176.p177.p190.p198.InterfaceC3561
    /* JADX INFO: renamed from: ֏ */
    public void mo5888(long j, long j2) {
        throw new IllegalStateException();
    }

    @Override // p138.p176.p177.p190.p198.InterfaceC3561
    /* JADX INFO: renamed from: ֏ */
    public void mo5889(InterfaceC3562 interfaceC3562) {
        this.f12197 = interfaceC3562;
        interfaceC3562.mo5893(new InterfaceC3571.C3573(-9223372036854775807L, 0L));
    }

    @Override // p138.p176.p177.p190.p198.InterfaceC3561
    /* JADX INFO: renamed from: ֏ */
    public boolean mo5890(C3558 c3558) {
        c3558.m5875(this.f12198, 0, 6, false);
        this.f12196.m6684(this.f12198, 6);
        if (C4012.m6465(this.f12196)) {
            return true;
        }
        c3558.m5875(this.f12198, 6, 3, false);
        this.f12196.m6684(this.f12198, 9);
        return C4012.m6465(this.f12196);
    }
}
