package e5;

import android.text.TextUtils;
import androidx.media3.common.MimeTypes;
import com.google.android.gms.internal.ads.gb;
import com.google.android.gms.internal.ads.ih1;
import com.google.android.gms.internal.ads.ja;
import com.google.android.gms.internal.ads.p01;
import com.google.android.gms.internal.ads.q2;
import com.google.android.gms.internal.ads.sm2;
import com.google.android.gms.internal.ads.u3;
import com.google.android.gms.internal.ads.vt0;
import com.google.android.gms.internal.ads.zn2;
import java.util.Collections;
import java.util.List;
import java.util.concurrent.PriorityBlockingQueue;
import java.util.concurrent.ThreadFactory;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import x2.o0;

/* JADX INFO: loaded from: classes.dex */
public final class a implements ja {

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public final /* synthetic */ int f25470a;

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public String f25471b;

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    public boolean f25472c;

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    public int f25473d;

    /* JADX INFO: renamed from: e, reason: collision with root package name */
    public int f25474e;

    /* JADX INFO: renamed from: f, reason: collision with root package name */
    public long f25475f;

    /* JADX INFO: renamed from: g, reason: collision with root package name */
    public final Object f25476g;

    /* JADX INFO: renamed from: h, reason: collision with root package name */
    public Object f25477h;

    public a() {
        this.f25470a = 2;
        this.f25471b = MimeTypes.VIDEO_MP2T;
        this.f25476g = new p01(10);
        this.f25475f = -9223372036854775807L;
    }

    @Override // com.google.android.gms.internal.ads.ja
    public final void a(q2 q2Var, o0 o0Var) {
        switch (this.f25470a) {
            case 1:
                int i10 = 0;
                while (true) {
                    u3[] u3VarArr = (u3[]) this.f25477h;
                    if (i10 < u3VarArr.length) {
                        gb gbVar = (gb) ((List) this.f25476g).get(i10);
                        o0Var.d();
                        o0Var.e();
                        u3 u3VarE = q2Var.e(o0Var.f34560d, 3);
                        sm2 sm2Var = new sm2();
                        o0Var.e();
                        sm2Var.zza(o0Var.f34561e);
                        sm2Var.zzl(this.f25471b);
                        sm2Var.zzm(MimeTypes.APPLICATION_DVBSUBS);
                        sm2Var.zzp(Collections.singletonList(gbVar.f11684b));
                        sm2Var.zze(gbVar.f11683a);
                        u3VarE.d(new zn2(sm2Var));
                        u3VarArr[i10] = u3VarE;
                        i10++;
                    }
                    break;
                }
                break;
            default:
                o0Var.d();
                o0Var.e();
                u3 u3VarE2 = q2Var.e(o0Var.f34560d, 5);
                this.f25477h = u3VarE2;
                sm2 sm2Var2 = new sm2();
                o0Var.e();
                sm2Var2.zza(o0Var.f34561e);
                sm2Var2.zzl(this.f25471b);
                sm2Var2.zzm(MimeTypes.APPLICATION_ID3);
                u3VarE2.d(new zn2(sm2Var2));
                break;
        }
    }

    @Override // com.google.android.gms.internal.ads.ja
    public final void b(boolean z10) {
        int i10;
        switch (this.f25470a) {
            case 1:
                if (this.f25472c) {
                    ih1.b1(this.f25475f != -9223372036854775807L);
                    for (u3 u3Var : (u3[]) this.f25477h) {
                        u3Var.zze(this.f25475f, 1, this.f25474e, 0, null);
                    }
                    this.f25472c = false;
                }
                break;
            default:
                ((u3) this.f25477h).getClass();
                if (this.f25472c && (i10 = this.f25473d) != 0 && this.f25474e == i10) {
                    ih1.b1(this.f25475f != -9223372036854775807L);
                    ((u3) this.f25477h).zze(this.f25475f, 1, this.f25473d, 0, null);
                    this.f25472c = false;
                    break;
                }
                break;
        }
    }

    @Override // com.google.android.gms.internal.ads.ja
    public final void c(int i10, long j10) {
        switch (this.f25470a) {
            case 1:
                if ((i10 & 4) != 0) {
                    this.f25472c = true;
                    this.f25475f = j10;
                    this.f25474e = 0;
                    this.f25473d = 2;
                    break;
                }
                break;
            default:
                if ((i10 & 4) != 0) {
                    this.f25472c = true;
                    this.f25475f = j10;
                    this.f25473d = 0;
                    this.f25474e = 0;
                    break;
                }
                break;
        }
    }

    @Override // com.google.android.gms.internal.ads.ja
    public final void d(p01 p01Var) {
        switch (this.f25470a) {
            case 1:
                if (this.f25472c) {
                    if (this.f25473d == 2) {
                        if (p01Var.y() != 0) {
                            if (p01Var.I() != 32) {
                                this.f25472c = false;
                            }
                            this.f25473d--;
                            if (!this.f25472c) {
                            }
                        }
                    }
                    if (this.f25473d == 1) {
                        if (p01Var.y() != 0) {
                            if (p01Var.I() != 0) {
                                this.f25472c = false;
                            }
                            this.f25473d--;
                            if (!this.f25472c) {
                            }
                        }
                    }
                    int i10 = p01Var.f15226b;
                    int iY = p01Var.y();
                    for (u3 u3Var : (u3[]) this.f25477h) {
                        p01Var.C(i10);
                        u3Var.a(p01Var, iY);
                    }
                    this.f25474e += iY;
                }
                break;
            default:
                ((u3) this.f25477h).getClass();
                if (this.f25472c) {
                    int iY2 = p01Var.y();
                    int i11 = this.f25474e;
                    if (i11 < 10) {
                        int iMin = Math.min(iY2, 10 - i11);
                        byte[] bArr = p01Var.f15225a;
                        int i12 = p01Var.f15226b;
                        p01 p01Var2 = (p01) this.f25476g;
                        System.arraycopy(bArr, i12, p01Var2.f15225a, this.f25474e, iMin);
                        if (this.f25474e + iMin == 10) {
                            p01Var2.C(0);
                            if (p01Var2.I() == 73 && p01Var2.I() == 68 && p01Var2.I() == 51) {
                                p01Var2.E(3);
                                this.f25473d = p01Var2.g() + 10;
                            } else {
                                vt0.c("Discarding invalid ID3 tag");
                                this.f25472c = false;
                            }
                        }
                    }
                    int iMin2 = Math.min(iY2, this.f25473d - this.f25474e);
                    ((u3) this.f25477h).a(p01Var, iMin2);
                    this.f25474e += iMin2;
                    break;
                }
                break;
        }
    }

    public final d e() {
        if (TextUtils.isEmpty(this.f25471b)) {
            throw new IllegalArgumentException("Name must be non-null and non-empty, but given: " + this.f25471b);
        }
        ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor(this.f25473d, this.f25474e, this.f25475f, TimeUnit.MILLISECONDS, new PriorityBlockingQueue(), new b((ThreadFactory) this.f25476g, this.f25471b, (c) this.f25477h, this.f25472c));
        if (this.f25475f != 0) {
            threadPoolExecutor.allowCoreThreadTimeOut(true);
        }
        return new d(threadPoolExecutor);
    }

    @Override // com.google.android.gms.internal.ads.ja
    public final void zza() {
        switch (this.f25470a) {
            case 1:
                this.f25472c = false;
                this.f25475f = -9223372036854775807L;
                break;
            default:
                this.f25472c = false;
                this.f25475f = -9223372036854775807L;
                break;
        }
    }

    public a(List list) {
        this.f25470a = 1;
        this.f25476g = list;
        this.f25471b = MimeTypes.VIDEO_MP2T;
        this.f25477h = new u3[list.size()];
        this.f25475f = -9223372036854775807L;
    }

    public a(boolean z10) {
        this.f25470a = 0;
        this.f25476g = new com.bumptech.glide.load.engine.a();
        this.f25477h = c.E;
        this.f25472c = z10;
    }
}
