discord-jadx/app/src/main/java/c/i/a/c/e2/l.java

473 lines
15 KiB
Java

package c.i.a.c.e2;
import android.os.Handler;
import android.os.Looper;
import android.os.Message;
import androidx.annotation.Nullable;
import c.d.b.a.a;
import c.i.a.c.e2.h;
import c.i.a.c.e2.m.c;
import c.i.a.c.e2.u.d;
import c.i.a.c.e2.u.i;
import c.i.a.c.g0;
import c.i.a.c.i2.f0;
import c.i.a.c.i2.p;
import c.i.a.c.i2.s;
import c.i.a.c.s0;
import com.google.android.exoplayer2.Format;
import com.google.android.exoplayer2.text.SubtitleDecoderException;
import java.util.Collections;
import java.util.List;
import java.util.Objects;
/* compiled from: TextRenderer */
public final class l extends g0 implements Handler.Callback {
public int A;
@Nullable
public Format B;
@Nullable
public g C;
@Nullable
public i D;
@Nullable
public j E;
@Nullable
public j F;
public int G;
public long H;
@Nullable
public final Handler t;
public final k u;
public final h v;
public final s0 w;
/* renamed from: x reason: collision with root package name */
public boolean f811x;
/* renamed from: y reason: collision with root package name */
public boolean f812y;
/* renamed from: z reason: collision with root package name */
public boolean f813z;
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
public l(k kVar, @Nullable Looper looper) {
super(3);
Handler handler;
h hVar = h.a;
Objects.requireNonNull(kVar);
this.u = kVar;
if (looper == null) {
handler = null;
} else {
int i = f0.a;
handler = new Handler(looper, this);
}
this.t = handler;
this.v = hVar;
this.w = new s0();
this.H = -9223372036854775807L;
}
@Override // c.i.a.c.g0
public void B() {
this.B = null;
this.H = -9223372036854775807L;
J();
N();
g gVar = this.C;
Objects.requireNonNull(gVar);
gVar.release();
this.C = null;
this.A = 0;
}
@Override // c.i.a.c.g0
public void D(long j, boolean z2) {
J();
this.f811x = false;
this.f812y = false;
this.H = -9223372036854775807L;
if (this.A != 0) {
O();
return;
}
N();
g gVar = this.C;
Objects.requireNonNull(gVar);
gVar.flush();
}
@Override // c.i.a.c.g0
public void H(Format[] formatArr, long j, long j2) {
this.B = formatArr[0];
if (this.C != null) {
this.A = 1;
} else {
M();
}
}
public final void J() {
List<c> emptyList = Collections.emptyList();
Handler handler = this.t;
if (handler != null) {
handler.obtainMessage(0, emptyList).sendToTarget();
} else {
this.u.m(emptyList);
}
}
public final long K() {
if (this.G == -1) {
return Long.MAX_VALUE;
}
Objects.requireNonNull(this.E);
int i = this.G;
f fVar = this.E.k;
Objects.requireNonNull(fVar);
if (i >= fVar.i()) {
return Long.MAX_VALUE;
}
j jVar = this.E;
int i2 = this.G;
f fVar2 = jVar.k;
Objects.requireNonNull(fVar2);
return fVar2.g(i2) + jVar.l;
}
public final void L(SubtitleDecoderException subtitleDecoderException) {
StringBuilder L = a.L("Subtitle decoding failed. streamFormat=");
L.append(this.B);
p.b("TextRenderer", L.toString(), subtitleDecoderException);
J();
O();
}
/* JADX INFO: Can't fix incorrect switch cases order, some code will duplicate */
/* JADX WARNING: Code restructure failed: missing block: B:32:0x008e, code lost:
if (r1.equals("application/pgs") == false) goto L_0x009c;
*/
public final void M() {
g gVar;
char c2 = 1;
this.f813z = true;
h hVar = this.v;
Format format = this.B;
Objects.requireNonNull(format);
Objects.requireNonNull((h.a) hVar);
String str = format.t;
if (str != null) {
switch (str.hashCode()) {
case -1351681404:
if (str.equals("application/dvbsubs")) {
c2 = 0;
break;
}
c2 = 65535;
break;
case -1248334819:
break;
case -1026075066:
if (str.equals("application/x-mp4-vtt")) {
c2 = 2;
break;
}
c2 = 65535;
break;
case -1004728940:
if (str.equals("text/vtt")) {
c2 = 3;
break;
}
c2 = 65535;
break;
case 691401887:
if (str.equals("application/x-quicktime-tx3g")) {
c2 = 4;
break;
}
c2 = 65535;
break;
case 822864842:
if (str.equals("text/x-ssa")) {
c2 = 5;
break;
}
c2 = 65535;
break;
case 930165504:
if (str.equals("application/x-mp4-cea-608")) {
c2 = 6;
break;
}
c2 = 65535;
break;
case 1566015601:
if (str.equals("application/cea-608")) {
c2 = 7;
break;
}
c2 = 65535;
break;
case 1566016562:
if (str.equals("application/cea-708")) {
c2 = '\b';
break;
}
c2 = 65535;
break;
case 1668750253:
if (str.equals("application/x-subrip")) {
c2 = '\t';
break;
}
c2 = 65535;
break;
case 1693976202:
if (str.equals("application/ttml+xml")) {
c2 = '\n';
break;
}
c2 = 65535;
break;
default:
c2 = 65535;
break;
}
switch (c2) {
case 0:
gVar = new c.i.a.c.e2.n.a(format.v);
this.C = gVar;
return;
case 1:
gVar = new c.i.a.c.e2.o.a();
this.C = gVar;
return;
case 2:
gVar = new d();
this.C = gVar;
return;
case 3:
gVar = new i();
this.C = gVar;
return;
case 4:
gVar = new c.i.a.c.e2.t.a(format.v);
this.C = gVar;
return;
case 5:
gVar = new c.i.a.c.e2.q.a(format.v);
this.C = gVar;
return;
case 6:
case 7:
gVar = new c(str, format.L, 16000);
this.C = gVar;
return;
case '\b':
gVar = new c.i.a.c.e2.m.d(format.L, format.v);
this.C = gVar;
return;
case '\t':
gVar = new c.i.a.c.e2.r.a();
this.C = gVar;
return;
case '\n':
gVar = new c.i.a.c.e2.s.c();
this.C = gVar;
return;
}
}
throw new IllegalArgumentException(a.u("Attempted to create decoder for unsupported MIME type: ", str));
}
public final void N() {
this.D = null;
this.G = -1;
j jVar = this.E;
if (jVar != null) {
jVar.p();
this.E = null;
}
j jVar2 = this.F;
if (jVar2 != null) {
jVar2.p();
this.F = null;
}
}
public final void O() {
N();
g gVar = this.C;
Objects.requireNonNull(gVar);
gVar.release();
this.C = null;
this.A = 0;
M();
}
@Override // c.i.a.c.l1
public int a(Format format) {
Objects.requireNonNull((h.a) this.v);
String str = format.t;
if (!("text/vtt".equals(str) || "text/x-ssa".equals(str) || "application/ttml+xml".equals(str) || "application/x-mp4-vtt".equals(str) || "application/x-subrip".equals(str) || "application/x-quicktime-tx3g".equals(str) || "application/cea-608".equals(str) || "application/x-mp4-cea-608".equals(str) || "application/cea-708".equals(str) || "application/dvbsubs".equals(str) || "application/pgs".equals(str))) {
return s.i(format.t) ? 1 : 0;
}
return (format.M == null ? 4 : 2) | 0 | 0;
}
@Override // c.i.a.c.k1
public boolean b() {
return this.f812y;
}
@Override // c.i.a.c.k1
public boolean d() {
return true;
}
@Override // c.i.a.c.k1, c.i.a.c.l1
public String getName() {
return "TextRenderer";
}
@Override // android.os.Handler.Callback
public boolean handleMessage(Message message) {
if (message.what == 0) {
this.u.m((List) message.obj);
return true;
}
throw new IllegalStateException();
}
@Override // c.i.a.c.k1
public void q(long j, long j2) {
boolean z2;
if (this.r) {
long j3 = this.H;
if (j3 != -9223372036854775807L && j >= j3) {
N();
this.f812y = true;
}
}
if (!this.f812y) {
if (this.F == null) {
g gVar = this.C;
Objects.requireNonNull(gVar);
gVar.a(j);
try {
g gVar2 = this.C;
Objects.requireNonNull(gVar2);
this.F = gVar2.b();
} catch (SubtitleDecoderException e) {
L(e);
return;
}
}
if (this.m == 2) {
if (this.E != null) {
long K = K();
z2 = false;
while (K <= j) {
this.G++;
K = K();
z2 = true;
}
} else {
z2 = false;
}
j jVar = this.F;
if (jVar != null) {
if (jVar.n()) {
if (!z2 && K() == Long.MAX_VALUE) {
if (this.A == 2) {
O();
} else {
N();
this.f812y = true;
}
}
} else if (jVar.j <= j) {
j jVar2 = this.E;
if (jVar2 != null) {
jVar2.p();
}
f fVar = jVar.k;
Objects.requireNonNull(fVar);
this.G = fVar.f(j - jVar.l);
this.E = jVar;
this.F = null;
z2 = true;
}
}
if (z2) {
Objects.requireNonNull(this.E);
j jVar3 = this.E;
f fVar2 = jVar3.k;
Objects.requireNonNull(fVar2);
List<c> h = fVar2.h(j - jVar3.l);
Handler handler = this.t;
if (handler != null) {
handler.obtainMessage(0, h).sendToTarget();
} else {
this.u.m(h);
}
}
if (this.A != 2) {
while (!this.f811x) {
try {
i iVar = this.D;
if (iVar == null) {
g gVar3 = this.C;
Objects.requireNonNull(gVar3);
iVar = gVar3.c();
if (iVar != null) {
this.D = iVar;
} else {
return;
}
}
if (this.A == 1) {
iVar.i = 4;
g gVar4 = this.C;
Objects.requireNonNull(gVar4);
gVar4.d(iVar);
this.D = null;
this.A = 2;
return;
}
int I = I(this.w, iVar, false);
if (I == -4) {
if (iVar.n()) {
this.f811x = true;
this.f813z = false;
} else {
Format format = this.w.b;
if (format != null) {
iVar.q = format.f2194x;
iVar.s();
this.f813z &= !iVar.o();
} else {
return;
}
}
if (!this.f813z) {
g gVar5 = this.C;
Objects.requireNonNull(gVar5);
gVar5.d(iVar);
this.D = null;
}
} else if (I == -3) {
return;
}
} catch (SubtitleDecoderException e2) {
L(e2);
return;
}
}
}
}
}
}
}