package c.i.a.c; import android.annotation.SuppressLint; import android.os.Handler; import android.os.Looper; import android.util.Log; import android.util.Pair; import androidx.annotation.Nullable; import c.i.a.c.d2.a0; import c.i.a.c.d2.h0; import c.i.a.c.d2.y; import c.i.a.c.f2.k; import c.i.a.c.f2.l; import c.i.a.c.f2.m; import c.i.a.c.g1; import c.i.a.c.h1; import c.i.a.c.h2.d; import c.i.a.c.i2.c0; import c.i.a.c.i2.f0; import c.i.a.c.i2.g; import c.i.a.c.i2.o; import c.i.a.c.q0; import c.i.a.c.r1; import c.i.a.c.u1.b1; import c.i.a.c.u1.c1; import c.i.a.c.u1.d1; import c.i.b.b.u; import com.airbnb.lottie.parser.AnimatableValueParser; import com.google.android.exoplayer2.ExoPlaybackException; import com.google.android.exoplayer2.IllegalSeekPositionException; import com.google.android.exoplayer2.metadata.Metadata; import com.google.android.exoplayer2.source.TrackGroupArray; import java.util.ArrayList; import java.util.Iterator; import java.util.List; import java.util.Objects; import java.util.Random; import java.util.concurrent.CopyOnWriteArraySet; /* compiled from: ExoPlayerImpl */ public final class o0 extends f0 implements g1 { public final m b; /* renamed from: c reason: collision with root package name */ public final k1[] f931c; public final l d; public final c0 e; public final q0.e f; public final q0 g; public final o h; public final r1.b i; public final List j; public final boolean k; public final a0 l; @Nullable public final c1 m; public final Looper n; public final d o; public final g p; public int q; public boolean r; /* renamed from: s reason: collision with root package name */ public int f932s; public boolean t; public int u; public int v; public h0 w; /* renamed from: x reason: collision with root package name */ public c1 f933x; /* renamed from: y reason: collision with root package name */ public int f934y; /* renamed from: z reason: collision with root package name */ public long f935z; /* compiled from: ExoPlayerImpl */ public static final class a implements a1 { public final Object a; public r1 b; public a(Object obj, r1 r1Var) { this.a = obj; this.b = r1Var; } @Override // c.i.a.c.a1 public r1 a() { return this.b; } @Override // c.i.a.c.a1 public Object getUid() { return this.a; } } @SuppressLint({"HandlerLeak"}) public o0(k1[] k1VarArr, l lVar, a0 a0Var, u0 u0Var, d dVar, @Nullable c1 c1Var, boolean z2, o1 o1Var, t0 t0Var, long j, boolean z3, g gVar, Looper looper, @Nullable g1 g1Var) { StringBuilder K = c.d.b.a.a.K("Init "); K.append(Integer.toHexString(System.identityHashCode(this))); K.append(" ["); K.append("ExoPlayerLib/2.13.3"); K.append("] ["); K.append(f0.e); K.append("]"); Log.i("ExoPlayerImpl", K.toString()); AnimatableValueParser.D(k1VarArr.length > 0); this.f931c = k1VarArr; Objects.requireNonNull(lVar); this.d = lVar; this.l = a0Var; this.o = dVar; this.m = c1Var; this.k = z2; this.n = looper; this.p = gVar; this.q = 0; this.h = new o<>(new CopyOnWriteArraySet(), looper, gVar, a0.i, new l(g1Var)); this.j = new ArrayList(); this.w = new h0.a(0, new Random()); m mVar = new m(new m1[k1VarArr.length], new c.i.a.c.f2.g[k1VarArr.length], null); this.b = mVar; this.i = new r1.b(); this.f934y = -1; this.e = gVar.b(looper, null); o oVar = new o(this); this.f = oVar; this.f933x = c1.i(mVar); if (c1Var != null) { AnimatableValueParser.D(c1Var.o == null || c1Var.l.b.isEmpty()); c1Var.o = g1Var; o oVar2 = c1Var.n; c1Var.n = new o<>(oVar2.e, looper, oVar2.a, oVar2.f907c, new b1(c1Var, g1Var)); l(c1Var); dVar.f(new Handler(looper), c1Var); } this.g = new q0(k1VarArr, lVar, mVar, u0Var, dVar, this.q, this.r, c1Var, o1Var, t0Var, j, z3, looper, gVar, oVar); } public static boolean N(c1 c1Var) { return c1Var.e == 3 && c1Var.l && c1Var.m == 0; } @Override // c.i.a.c.g1 public TrackGroupArray A() { return this.f933x.h; } @Override // c.i.a.c.g1 public int B() { return this.q; } @Override // c.i.a.c.g1 public long C() { if (d()) { c1 c1Var = this.f933x; y.a aVar = c1Var.f773c; c1Var.b.h(aVar.a, this.i); return h0.b(this.i.a(aVar.b, aVar.f810c)); } r1 D = D(); if (D.q()) { return -9223372036854775807L; } return D.n(o(), this.a).b(); } @Override // c.i.a.c.g1 public r1 D() { return this.f933x.b; } @Override // c.i.a.c.g1 public Looper E() { return this.n; } @Override // c.i.a.c.g1 public boolean F() { return this.r; } @Override // c.i.a.c.g1 public long G() { if (this.f933x.b.q()) { return this.f935z; } c1 c1Var = this.f933x; if (c1Var.k.d != c1Var.f773c.d) { return c1Var.b.n(o(), this.a).b(); } long j = c1Var.q; if (this.f933x.k.a()) { c1 c1Var2 = this.f933x; r1.b h = c1Var2.b.h(c1Var2.k.a, this.i); long d = h.d(this.f933x.k.b); j = d == Long.MIN_VALUE ? h.d : d; } return P(this.f933x.k, j); } @Override // c.i.a.c.g1 public k H() { return new k(this.f933x.i.f864c); } @Override // c.i.a.c.g1 public int I(int i) { return this.f931c[i].x(); } @Override // c.i.a.c.g1 public long J() { if (this.f933x.b.q()) { return this.f935z; } if (this.f933x.f773c.a()) { return h0.b(this.f933x.f774s); } c1 c1Var = this.f933x; return P(c1Var.f773c, c1Var.f774s); } @Override // c.i.a.c.g1 @Nullable public g1.c K() { return null; } public final int L() { if (this.f933x.b.q()) { return this.f934y; } c1 c1Var = this.f933x; return c1Var.b.h(c1Var.f773c.a, this.i).f952c; } @Nullable public final Pair M(r1 r1Var, int i, long j) { if (r1Var.q()) { this.f934y = i; if (j == -9223372036854775807L) { j = 0; } this.f935z = j; return null; } if (i == -1 || i >= r1Var.p()) { i = r1Var.a(this.r); j = r1Var.n(i, this.a).a(); } return r1Var.j(this.a, this.i, i, h0.a(j)); } public final c1 O(c1 c1Var, r1 r1Var, @Nullable Pair pair) { List list; int i; AnimatableValueParser.k(r1Var.q() || pair != null); r1 r1Var2 = c1Var.b; c1 h = c1Var.h(r1Var); if (r1Var.q()) { y.a aVar = c1.a; y.a aVar2 = c1.a; long a2 = h0.a(this.f935z); long a3 = h0.a(this.f935z); TrackGroupArray trackGroupArray = TrackGroupArray.i; m mVar = this.b; c.i.b.b.a aVar3 = u.j; c1 a4 = h.b(aVar2, a2, a3, 0, trackGroupArray, mVar, c.i.b.b.q0.k).a(aVar2); a4.q = a4.f774s; return a4; } Object obj = h.f773c.a; int i2 = f0.a; boolean z2 = !obj.equals(pair.first); y.a aVar4 = z2 ? new y.a(pair.first) : h.f773c; long longValue = ((Long) pair.second).longValue(); long a5 = h0.a(s()); if (!r1Var2.q()) { a5 -= r1Var2.h(obj, this.i).e; } if (z2 || longValue < a5) { AnimatableValueParser.D(!aVar4.a()); TrackGroupArray trackGroupArray2 = z2 ? TrackGroupArray.i : h.h; m mVar2 = z2 ? this.b : h.i; if (z2) { c.i.b.b.a aVar5 = u.j; list = c.i.b.b.q0.k; } else { list = h.j; } c1 a6 = h.b(aVar4, longValue, longValue, 0, trackGroupArray2, mVar2, list).a(aVar4); a6.q = longValue; return a6; } else if (i == 0) { int b = r1Var.b(h.k.a); if (b != -1 && r1Var.f(b, this.i).f952c == r1Var.h(aVar4.a, this.i).f952c) { return h; } r1Var.h(aVar4.a, this.i); long a7 = aVar4.a() ? this.i.a(aVar4.b, aVar4.f810c) : this.i.d; c1 a8 = h.b(aVar4, h.f774s, h.f774s, a7 - h.f774s, h.h, h.i, h.j).a(aVar4); a8.q = a7; return a8; } else { AnimatableValueParser.D(!aVar4.a()); long max = Math.max(0L, h.r - (longValue - a5)); long j = h.q; if (h.k.equals(h.f773c)) { j = longValue + max; } c1 b2 = h.b(aVar4, longValue, longValue, max, h.h, h.i, h.j); b2.q = j; return b2; } } public final long P(y.a aVar, long j) { long b = h0.b(j); this.f933x.b.h(aVar.a, this.i); return b + h0.b(this.i.e); } public final void Q(int i, int i2) { for (int i3 = i2 - 1; i3 >= i; i3--) { this.j.remove(i3); } this.w = this.w.a(i, i2); } public void R(boolean z2, int i, int i2) { c1 c1Var = this.f933x; if (c1Var.l != z2 || c1Var.m != i) { this.f932s++; c1 d = c1Var.d(z2, i); this.g.o.b(1, z2 ? 1 : 0, i).sendToTarget(); S(d, false, 4, 0, i2, false); } } public final void S(c1 c1Var, boolean z2, int i, int i2, int i3, boolean z3) { Pair pair; int i4; c1 c1Var2 = this.f933x; this.f933x = c1Var; boolean z4 = !c1Var2.b.equals(c1Var.b); r1 r1Var = c1Var2.b; r1 r1Var2 = c1Var.b; if (r1Var2.q() && r1Var.q()) { pair = new Pair(Boolean.FALSE, -1); } else if (r1Var2.q() != r1Var.q()) { pair = new Pair(Boolean.TRUE, 3); } else { Object obj = r1Var.n(r1Var.h(c1Var2.f773c.a, this.i).f952c, this.a).f953c; Object obj2 = r1Var2.n(r1Var2.h(c1Var.f773c.a, this.i).f952c, this.a).f953c; int i5 = this.a.o; if (!obj.equals(obj2)) { if (z2 && i == 0) { i4 = 1; } else if (z2 && i == 1) { i4 = 2; } else if (z4) { i4 = 3; } else { throw new IllegalStateException(); } pair = new Pair(Boolean.TRUE, Integer.valueOf(i4)); } else { pair = (z2 && i == 0 && r1Var2.b(c1Var.f773c.a) == i5) ? new Pair(Boolean.TRUE, 0) : new Pair(Boolean.FALSE, -1); } } boolean booleanValue = ((Boolean) pair.first).booleanValue(); int intValue = ((Integer) pair.second).intValue(); if (!c1Var2.b.equals(c1Var.b)) { this.h.b(0, new c(c1Var, i2)); } if (z2) { this.h.b(12, new d(i)); } if (booleanValue) { this.h.b(1, new r(!c1Var.b.q() ? c1Var.b.n(c1Var.b.h(c1Var.f773c.a, this.i).f952c, this.a).e : null, intValue)); } ExoPlaybackException exoPlaybackException = c1Var2.f; ExoPlaybackException exoPlaybackException2 = c1Var.f; if (!(exoPlaybackException == exoPlaybackException2 || exoPlaybackException2 == null)) { this.h.b(11, new n(c1Var)); } m mVar = c1Var2.i; m mVar2 = c1Var.i; if (mVar != mVar2) { this.d.a(mVar2.d); this.h.b(2, new m(c1Var, new k(c1Var.i.f864c))); } if (!c1Var2.j.equals(c1Var.j)) { this.h.b(3, new j(c1Var)); } if (c1Var2.g != c1Var.g) { this.h.b(4, new f(c1Var)); } if (!(c1Var2.e == c1Var.e && c1Var2.l == c1Var.l)) { this.h.b(-1, new p(c1Var)); } if (c1Var2.e != c1Var.e) { this.h.b(5, new k(c1Var)); } if (c1Var2.l != c1Var.l) { this.h.b(6, new v(c1Var, i3)); } if (c1Var2.m != c1Var.m) { this.h.b(7, new s(c1Var)); } if (N(c1Var2) != N(c1Var)) { this.h.b(8, new i(c1Var)); } if (!c1Var2.n.equals(c1Var.n)) { this.h.b(13, new w(c1Var)); } if (z3) { this.h.b(-1, a.a); } if (c1Var2.o != c1Var.o) { this.h.b(-1, new g(c1Var)); } if (c1Var2.p != c1Var.p) { this.h.b(-1, new u(c1Var)); } this.h.a(); } @Override // c.i.a.c.g1 public void a() { c1 c1Var = this.f933x; if (c1Var.e == 1) { c1 e = c1Var.e(null); c1 g = e.g(e.b.q() ? 4 : 2); this.f932s++; this.g.o.a(0).sendToTarget(); S(g, false, 4, 1, 1, false); } } public h1 b(h1.b bVar) { return new h1(this.g, bVar, this.f933x.b, o(), this.p, this.g.q); } @Override // c.i.a.c.g1 public d1 c() { return this.f933x.n; } @Override // c.i.a.c.g1 public boolean d() { return this.f933x.f773c.a(); } @Override // c.i.a.c.g1 public long e() { return h0.b(this.f933x.r); } @Override // c.i.a.c.g1 public void f(int i, long j) { r1 r1Var = this.f933x.b; if (i < 0 || (!r1Var.q() && i >= r1Var.p())) { throw new IllegalSeekPositionException(r1Var, i, j); } int i2 = 1; this.f932s++; if (d()) { Log.w("ExoPlayerImpl", "seekTo ignored because an ad is playing"); q0.d dVar = new q0.d(this.f933x); dVar.a(1); o0 o0Var = ((o) this.f).a; o0Var.e.a.post(new t(o0Var, dVar)); return; } c1 c1Var = this.f933x; if (c1Var.e != 1) { i2 = 2; } c1 O = O(c1Var.g(i2), r1Var, M(r1Var, i, j)); this.g.o.c(3, new q0.g(r1Var, i, h0.a(j))).sendToTarget(); S(O, true, 1, 0, 1, true); } @Override // c.i.a.c.g1 public boolean g() { return this.f933x.l; } @Override // c.i.a.c.g1 public void h(boolean z2) { if (this.r != z2) { this.r = z2; this.g.o.b(12, z2 ? 1 : 0, 0).sendToTarget(); o oVar = this.h; oVar.b(10, new h(z2)); oVar.a(); } } @Override // c.i.a.c.g1 public List i() { return this.f933x.j; } @Override // c.i.a.c.g1 public int j() { if (this.f933x.b.q()) { return 0; } c1 c1Var = this.f933x; return c1Var.b.b(c1Var.f773c.a); } @Override // c.i.a.c.g1 public void l(g1.a aVar) { o oVar = this.h; if (!oVar.h) { Objects.requireNonNull(aVar); oVar.e.add(new o.c<>(aVar, oVar.f907c)); } } @Override // c.i.a.c.g1 public int m() { if (d()) { return this.f933x.f773c.f810c; } return -1; } @Override // c.i.a.c.g1 public void n(g1.a aVar) { o oVar = this.h; Iterator> it = oVar.e.iterator(); while (it.hasNext()) { o.c next = it.next(); if (next.a.equals(aVar)) { o.b bVar = oVar.d; next.d = true; if (next.f908c) { bVar.a(next.a, next.b); } oVar.e.remove(next); } } } @Override // c.i.a.c.g1 public int o() { int L = L(); if (L == -1) { return 0; } return L; } @Override // c.i.a.c.g1 @Nullable public ExoPlaybackException p() { return this.f933x.f; } @Override // c.i.a.c.g1 public void q(boolean z2) { R(z2, 0, 1); } @Override // c.i.a.c.g1 @Nullable public g1.d r() { return null; } @Override // c.i.a.c.g1 public long s() { if (!d()) { return J(); } c1 c1Var = this.f933x; c1Var.b.h(c1Var.f773c.a, this.i); c1 c1Var2 = this.f933x; return c1Var2.d == -9223372036854775807L ? c1Var2.b.n(o(), this.a).a() : h0.b(this.i.e) + h0.b(this.f933x.d); } @Override // c.i.a.c.g1 public int u() { return this.f933x.e; } @Override // c.i.a.c.g1 public int w() { if (d()) { return this.f933x.f773c.b; } return -1; } @Override // c.i.a.c.g1 public void x(int i) { if (this.q != i) { this.q = i; this.g.o.b(11, i, 0).sendToTarget(); o oVar = this.h; oVar.b(9, new e(i)); oVar.a(); } } @Override // c.i.a.c.g1 public int z() { return this.f933x.m; } }