462 lines
13 KiB
Java
462 lines
13 KiB
Java
package c.i.a.c.d2;
|
|
|
|
import android.os.Looper;
|
|
import android.util.Log;
|
|
import androidx.annotation.CallSuper;
|
|
import androidx.annotation.Nullable;
|
|
import c.i.a.c.a2.v;
|
|
import c.i.a.c.a2.w;
|
|
import c.i.a.c.d2.d0;
|
|
import c.i.a.c.h2.c;
|
|
import c.i.a.c.h2.f;
|
|
import c.i.a.c.h2.m;
|
|
import c.i.a.c.i2.f0;
|
|
import c.i.a.c.s0;
|
|
import c.i.a.c.z1.q;
|
|
import c.i.a.c.z1.s;
|
|
import com.airbnb.lottie.parser.AnimatableValueParser;
|
|
import com.google.android.exoplayer2.Format;
|
|
import com.google.android.exoplayer2.drm.DrmInitData;
|
|
import com.google.android.exoplayer2.drm.DrmSession;
|
|
import java.io.EOFException;
|
|
import java.io.IOException;
|
|
import java.util.Objects;
|
|
/* compiled from: SampleQueue */
|
|
public class e0 implements w {
|
|
@Nullable
|
|
public Format A;
|
|
@Nullable
|
|
public Format B;
|
|
@Nullable
|
|
public Format C;
|
|
public boolean D;
|
|
public boolean E;
|
|
public final d0 a;
|
|
public final a b = new a();
|
|
@Nullable
|
|
|
|
/* renamed from: c reason: collision with root package name */
|
|
public final s f787c;
|
|
@Nullable
|
|
public final q.a d;
|
|
@Nullable
|
|
public final Looper e;
|
|
@Nullable
|
|
public b f;
|
|
@Nullable
|
|
public Format g;
|
|
@Nullable
|
|
public DrmSession h;
|
|
public int i = 1000;
|
|
public int[] j = new int[1000];
|
|
public long[] k = new long[1000];
|
|
public int[] l = new int[1000];
|
|
public int[] m = new int[1000];
|
|
public long[] n = new long[1000];
|
|
public w.a[] o = new w.a[1000];
|
|
public Format[] p = new Format[1000];
|
|
public int q;
|
|
public int r;
|
|
|
|
/* renamed from: s reason: collision with root package name */
|
|
public int f788s;
|
|
public int t;
|
|
public long u = Long.MIN_VALUE;
|
|
public long v = Long.MIN_VALUE;
|
|
public long w = Long.MIN_VALUE;
|
|
|
|
/* renamed from: x reason: collision with root package name */
|
|
public boolean f789x;
|
|
|
|
/* renamed from: y reason: collision with root package name */
|
|
public boolean f790y = true;
|
|
|
|
/* renamed from: z reason: collision with root package name */
|
|
public boolean f791z = true;
|
|
|
|
/* compiled from: SampleQueue */
|
|
public static final class a {
|
|
public int a;
|
|
public long b;
|
|
@Nullable
|
|
|
|
/* renamed from: c reason: collision with root package name */
|
|
public w.a f792c;
|
|
}
|
|
|
|
/* compiled from: SampleQueue */
|
|
public interface b {
|
|
}
|
|
|
|
public e0(m mVar, @Nullable Looper looper, @Nullable s sVar, @Nullable q.a aVar) {
|
|
this.e = looper;
|
|
this.f787c = sVar;
|
|
this.d = aVar;
|
|
this.a = new d0(mVar);
|
|
}
|
|
|
|
@Override // c.i.a.c.a2.w
|
|
public final int a(f fVar, int i, boolean z2, int i2) throws IOException {
|
|
d0 d0Var = this.a;
|
|
int c2 = d0Var.c(i);
|
|
d0.a aVar = d0Var.f;
|
|
int read = fVar.read(aVar.d.a, aVar.a(d0Var.g), c2);
|
|
if (read != -1) {
|
|
d0Var.b(read);
|
|
return read;
|
|
} else if (z2) {
|
|
return -1;
|
|
} else {
|
|
throw new EOFException();
|
|
}
|
|
}
|
|
|
|
@Override // c.i.a.c.a2.w
|
|
public /* synthetic */ int b(f fVar, int i, boolean z2) {
|
|
return v.a(this, fVar, i, z2);
|
|
}
|
|
|
|
@Override // c.i.a.c.a2.w
|
|
public /* synthetic */ void c(c.i.a.c.i2.w wVar, int i) {
|
|
v.b(this, wVar, i);
|
|
}
|
|
|
|
@Override // c.i.a.c.a2.w
|
|
public void d(long j, int i, int i2, int i3, @Nullable w.a aVar) {
|
|
int i4 = i & 1;
|
|
boolean z2 = i4 != 0;
|
|
if (this.f790y) {
|
|
if (z2) {
|
|
this.f790y = false;
|
|
} else {
|
|
return;
|
|
}
|
|
}
|
|
long j2 = j + 0;
|
|
if (this.D) {
|
|
if (j2 >= this.u) {
|
|
if (i4 == 0) {
|
|
if (!this.E) {
|
|
StringBuilder L = c.d.b.a.a.L("Overriding unexpected non-sync sample for format: ");
|
|
L.append(this.B);
|
|
Log.w("SampleQueue", L.toString());
|
|
this.E = true;
|
|
}
|
|
i |= 1;
|
|
}
|
|
} else {
|
|
return;
|
|
}
|
|
}
|
|
long j3 = (this.a.g - ((long) i2)) - ((long) i3);
|
|
synchronized (this) {
|
|
int i5 = this.q;
|
|
if (i5 > 0) {
|
|
int k = k(i5 - 1);
|
|
AnimatableValueParser.k(this.k[k] + ((long) this.l[k]) <= j3);
|
|
}
|
|
this.f789x = (536870912 & i) != 0;
|
|
this.w = Math.max(this.w, j2);
|
|
int k2 = k(this.q);
|
|
this.n[k2] = j2;
|
|
long[] jArr = this.k;
|
|
jArr[k2] = j3;
|
|
this.l[k2] = i2;
|
|
this.m[k2] = i;
|
|
this.o[k2] = aVar;
|
|
Format[] formatArr = this.p;
|
|
Format format = this.B;
|
|
formatArr[k2] = format;
|
|
this.j[k2] = 0;
|
|
this.C = format;
|
|
int i6 = this.q + 1;
|
|
this.q = i6;
|
|
int i7 = this.i;
|
|
if (i6 == i7) {
|
|
int i8 = i7 + 1000;
|
|
int[] iArr = new int[i8];
|
|
long[] jArr2 = new long[i8];
|
|
long[] jArr3 = new long[i8];
|
|
int[] iArr2 = new int[i8];
|
|
int[] iArr3 = new int[i8];
|
|
w.a[] aVarArr = new w.a[i8];
|
|
Format[] formatArr2 = new Format[i8];
|
|
int i9 = this.f788s;
|
|
int i10 = i7 - i9;
|
|
System.arraycopy(jArr, i9, jArr2, 0, i10);
|
|
System.arraycopy(this.n, this.f788s, jArr3, 0, i10);
|
|
System.arraycopy(this.m, this.f788s, iArr2, 0, i10);
|
|
System.arraycopy(this.l, this.f788s, iArr3, 0, i10);
|
|
System.arraycopy(this.o, this.f788s, aVarArr, 0, i10);
|
|
System.arraycopy(this.p, this.f788s, formatArr2, 0, i10);
|
|
System.arraycopy(this.j, this.f788s, iArr, 0, i10);
|
|
int i11 = this.f788s;
|
|
System.arraycopy(this.k, 0, jArr2, i10, i11);
|
|
System.arraycopy(this.n, 0, jArr3, i10, i11);
|
|
System.arraycopy(this.m, 0, iArr2, i10, i11);
|
|
System.arraycopy(this.l, 0, iArr3, i10, i11);
|
|
System.arraycopy(this.o, 0, aVarArr, i10, i11);
|
|
System.arraycopy(this.p, 0, formatArr2, i10, i11);
|
|
System.arraycopy(this.j, 0, iArr, i10, i11);
|
|
this.k = jArr2;
|
|
this.n = jArr3;
|
|
this.m = iArr2;
|
|
this.l = iArr3;
|
|
this.o = aVarArr;
|
|
this.p = formatArr2;
|
|
this.j = iArr;
|
|
this.f788s = 0;
|
|
this.i = i8;
|
|
}
|
|
}
|
|
}
|
|
|
|
@Override // c.i.a.c.a2.w
|
|
public final void e(Format format) {
|
|
boolean z2;
|
|
this.A = format;
|
|
synchronized (this) {
|
|
z2 = false;
|
|
this.f791z = false;
|
|
if (!f0.a(format, this.B)) {
|
|
if (f0.a(format, this.C)) {
|
|
this.B = this.C;
|
|
} else {
|
|
this.B = format;
|
|
}
|
|
Format format2 = this.B;
|
|
this.D = c.i.a.c.i2.s.a(format2.t, format2.q);
|
|
this.E = false;
|
|
z2 = true;
|
|
}
|
|
}
|
|
b bVar = this.f;
|
|
if (bVar != null && z2) {
|
|
b0 b0Var = (b0) bVar;
|
|
b0Var.f781z.post(b0Var.f779x);
|
|
}
|
|
}
|
|
|
|
@Override // c.i.a.c.a2.w
|
|
public final void f(c.i.a.c.i2.w wVar, int i, int i2) {
|
|
d0 d0Var = this.a;
|
|
Objects.requireNonNull(d0Var);
|
|
while (i > 0) {
|
|
int c2 = d0Var.c(i);
|
|
d0.a aVar = d0Var.f;
|
|
wVar.e(aVar.d.a, aVar.a(d0Var.g), c2);
|
|
i -= c2;
|
|
d0Var.b(c2);
|
|
}
|
|
}
|
|
|
|
public final long g(int i) {
|
|
this.v = Math.max(this.v, j(i));
|
|
int i2 = this.q - i;
|
|
this.q = i2;
|
|
this.r += i;
|
|
int i3 = this.f788s + i;
|
|
this.f788s = i3;
|
|
int i4 = this.i;
|
|
if (i3 >= i4) {
|
|
this.f788s = i3 - i4;
|
|
}
|
|
int i5 = this.t - i;
|
|
this.t = i5;
|
|
if (i5 < 0) {
|
|
this.t = 0;
|
|
}
|
|
if (i2 != 0) {
|
|
return this.k[this.f788s];
|
|
}
|
|
int i6 = this.f788s;
|
|
if (i6 != 0) {
|
|
i4 = i6;
|
|
}
|
|
int i7 = i4 - 1;
|
|
return this.k[i7] + ((long) this.l[i7]);
|
|
}
|
|
|
|
public final void h() {
|
|
long g;
|
|
d0 d0Var = this.a;
|
|
synchronized (this) {
|
|
int i = this.q;
|
|
g = i == 0 ? -1 : g(i);
|
|
}
|
|
d0Var.a(g);
|
|
}
|
|
|
|
public final int i(int i, int i2, long j, boolean z2) {
|
|
int i3 = -1;
|
|
for (int i4 = 0; i4 < i2; i4++) {
|
|
long[] jArr = this.n;
|
|
if (jArr[i] > j) {
|
|
return i3;
|
|
}
|
|
if (!z2 || (this.m[i] & 1) != 0) {
|
|
if (jArr[i] == j) {
|
|
return i4;
|
|
}
|
|
i3 = i4;
|
|
}
|
|
i++;
|
|
if (i == this.i) {
|
|
i = 0;
|
|
}
|
|
}
|
|
return i3;
|
|
}
|
|
|
|
public final long j(int i) {
|
|
long j = Long.MIN_VALUE;
|
|
if (i == 0) {
|
|
return Long.MIN_VALUE;
|
|
}
|
|
int k = k(i - 1);
|
|
for (int i2 = 0; i2 < i; i2++) {
|
|
j = Math.max(j, this.n[k]);
|
|
if ((this.m[k] & 1) != 0) {
|
|
break;
|
|
}
|
|
k--;
|
|
if (k == -1) {
|
|
k = this.i - 1;
|
|
}
|
|
}
|
|
return j;
|
|
}
|
|
|
|
public final int k(int i) {
|
|
int i2 = this.f788s + i;
|
|
int i3 = this.i;
|
|
return i2 < i3 ? i2 : i2 - i3;
|
|
}
|
|
|
|
@Nullable
|
|
public final synchronized Format l() {
|
|
return this.f791z ? null : this.B;
|
|
}
|
|
|
|
public final boolean m() {
|
|
return this.t != this.q;
|
|
}
|
|
|
|
@CallSuper
|
|
public synchronized boolean n(boolean z2) {
|
|
Format format;
|
|
boolean z3 = true;
|
|
if (!m()) {
|
|
if (!z2 && !this.f789x && ((format = this.B) == null || format == this.g)) {
|
|
z3 = false;
|
|
}
|
|
return z3;
|
|
}
|
|
int k = k(this.t);
|
|
if (this.p[k] != this.g) {
|
|
return true;
|
|
}
|
|
return o(k);
|
|
}
|
|
|
|
public final boolean o(int i) {
|
|
DrmSession drmSession = this.h;
|
|
return drmSession == null || drmSession.getState() == 4 || ((this.m[i] & 1073741824) == 0 && this.h.d());
|
|
}
|
|
|
|
public final void p(Format format, s0 s0Var) {
|
|
Format format2;
|
|
Format format3 = this.g;
|
|
boolean z2 = format3 == null;
|
|
DrmInitData drmInitData = z2 ? null : format3.w;
|
|
this.g = format;
|
|
DrmInitData drmInitData2 = format.w;
|
|
s sVar = this.f787c;
|
|
if (sVar != null) {
|
|
Class<? extends c.i.a.c.z1.w> c2 = sVar.c(format);
|
|
Format.b a2 = format.a();
|
|
a2.D = c2;
|
|
format2 = a2.a();
|
|
} else {
|
|
format2 = format;
|
|
}
|
|
s0Var.b = format2;
|
|
s0Var.a = this.h;
|
|
if (this.f787c != null) {
|
|
if (z2 || !f0.a(drmInitData, drmInitData2)) {
|
|
DrmSession drmSession = this.h;
|
|
s sVar2 = this.f787c;
|
|
Looper looper = this.e;
|
|
Objects.requireNonNull(looper);
|
|
DrmSession b2 = sVar2.b(looper, this.d, format);
|
|
this.h = b2;
|
|
s0Var.a = b2;
|
|
if (drmSession != null) {
|
|
drmSession.b(this.d);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
@CallSuper
|
|
public void q(boolean z2) {
|
|
d0 d0Var = this.a;
|
|
d0.a aVar = d0Var.d;
|
|
if (aVar.f786c) {
|
|
d0.a aVar2 = d0Var.f;
|
|
int i = (((int) (aVar2.a - aVar.a)) / d0Var.b) + (aVar2.f786c ? 1 : 0);
|
|
c[] cVarArr = new c[i];
|
|
int i2 = 0;
|
|
while (i2 < i) {
|
|
cVarArr[i2] = aVar.d;
|
|
aVar.d = null;
|
|
d0.a aVar3 = aVar.e;
|
|
aVar.e = null;
|
|
i2++;
|
|
aVar = aVar3;
|
|
}
|
|
d0Var.a.a(cVarArr);
|
|
}
|
|
d0.a aVar4 = new d0.a(0, d0Var.b);
|
|
d0Var.d = aVar4;
|
|
d0Var.e = aVar4;
|
|
d0Var.f = aVar4;
|
|
d0Var.g = 0;
|
|
d0Var.a.c();
|
|
this.q = 0;
|
|
this.r = 0;
|
|
this.f788s = 0;
|
|
this.t = 0;
|
|
this.f790y = true;
|
|
this.u = Long.MIN_VALUE;
|
|
this.v = Long.MIN_VALUE;
|
|
this.w = Long.MIN_VALUE;
|
|
this.f789x = false;
|
|
this.C = null;
|
|
if (z2) {
|
|
this.A = null;
|
|
this.B = null;
|
|
this.f791z = true;
|
|
}
|
|
}
|
|
|
|
public final synchronized boolean r(long j, boolean z2) {
|
|
synchronized (this) {
|
|
this.t = 0;
|
|
d0 d0Var = this.a;
|
|
d0Var.e = d0Var.d;
|
|
}
|
|
int k = k(0);
|
|
if (!m() || j < this.n[k] || (j > this.w && !z2)) {
|
|
return false;
|
|
}
|
|
int i = i(k, this.q - this.t, j, true);
|
|
if (i == -1) {
|
|
return false;
|
|
}
|
|
this.u = j;
|
|
this.t += i;
|
|
return true;
|
|
}
|
|
}
|