discord-jadx/app/src/main/java/c/a/q/o0/a.java

154 lines
8.5 KiB
Java

package c.a.q.o0;
import c.a.q.o0.e;
import co.discord.media_engine.InboundRtpVideo;
import co.discord.media_engine.OutboundRtpAudio;
import co.discord.media_engine.OutboundRtpVideo;
import co.discord.media_engine.ReceiverReport;
import co.discord.media_engine.Stats;
import co.discord.media_engine.Transport;
import com.discord.rtcconnection.KrispOveruseDetector;
import com.discord.rtcconnection.mediaengine.MediaEngineConnection;
import com.discord.utilities.logging.Logger;
import d0.z.d.k;
import d0.z.d.m;
import f0.e0.c;
import java.util.Iterator;
import java.util.Map;
import java.util.Objects;
import kotlin.Pair;
import kotlin.Unit;
import kotlin.jvm.functions.Function1;
/* compiled from: RtcStatsCollector.kt */
public final /* synthetic */ class a extends k implements Function1<Stats, Unit> {
public a(d dVar) {
super(1, dVar, d.class, "onStatsReceived", "onStatsReceived(Lco/discord/media_engine/Stats;)V", 0);
}
/* Return type fixed from 'java.lang.Object' to match base method */
/* JADX DEBUG: Method arguments types fixed to match base method, original types: [java.lang.Object] */
@Override // kotlin.jvm.functions.Function1
public Unit invoke(Stats stats) {
e eVar;
Throwable th;
long j;
OutboundRtpVideo outboundRtpVideo;
ReceiverReport[] receiverReports;
Stats stats2 = stats;
m.checkNotNullParameter(stats2, "p1");
d dVar = (d) this.receiver;
dVar.a.add(stats2);
if (dVar.a.size() > dVar.i) {
dVar.a.removeFirst();
}
dVar.f.update(stats2);
e eVar2 = dVar.g;
synchronized (eVar2) {
try {
m.checkNotNullParameter(stats2, "stats");
long currentTimeMillis = eVar2.q.currentTimeMillis();
Transport transport = stats2.getTransport();
eVar2.f(null, Integer.valueOf((transport == null || (receiverReports = transport.getReceiverReports()) == null) ? 0 : receiverReports.length), currentTimeMillis);
if (!eVar2.k.a() && (outboundRtpVideo = stats2.getOutboundRtpVideo()) != null) {
eVar2.a(eVar2.l, new e.h((long) outboundRtpVideo.getResolution().getHeight(), currentTimeMillis, new e.a(outboundRtpVideo.getFramesEncoded(), outboundRtpVideo.getFramesSent(), outboundRtpVideo.getPacketsSent(), (long) outboundRtpVideo.getPacketsLost(), 0, outboundRtpVideo.getBytesSent(), outboundRtpVideo.getNackCount(), outboundRtpVideo.getPliCount())));
if (eVar2.l.d == null && outboundRtpVideo.getFramesEncoded() > 0) {
eVar2.e.notifyAsync(g.i);
eVar2.l.d = Long.valueOf(currentTimeMillis - eVar2.g);
Logger.i$default(eVar2.p, "VideoQuality: outboundStats.timeToFirstFrame: " + eVar2.l.d, null, 2, null);
}
eVar2.b(outboundRtpVideo.getBitrateTarget());
}
if (!eVar2.i.a()) {
Iterator<Map.Entry<String, InboundRtpVideo>> it = stats2.getInboundRtpVideo().entrySet().iterator();
while (it.hasNext()) {
Map.Entry<String, InboundRtpVideo> next = it.next();
String key = next.getKey();
InboundRtpVideo value = next.getValue();
Map<String, e.C0043e> map = eVar2.m;
e.C0043e eVar3 = map.get(key);
if (eVar3 == null) {
eVar3 = new e.C0043e();
map.put(key, eVar3);
}
e.C0043e eVar4 = eVar3;
try {
eVar = eVar2;
try {
eVar.a(eVar4, new e.h((long) value.getResolution().getHeight(), currentTimeMillis, new e.a((long) value.getFramesDecoded(), (long) value.getFramesReceived(), (long) value.getPacketsReceived(), (long) value.getPacketsLost(), (long) value.getFramesDropped(), value.getBytesReceived(), value.getNackCount(), value.getPliCount())));
if (eVar4.d == null && value.getFramesDecoded() > 0) {
byte[] bArr = c.a;
m.checkParameterIsNotNull(key, "$this$toLongOrDefault");
try {
j = Long.parseLong(key);
} catch (NumberFormatException unused) {
j = 0;
}
Long l = eVar.n.get(Long.valueOf(value.getSsrc()));
if (l != null) {
eVar.e.notifyAsync(new h(value));
eVar4.d = Long.valueOf(currentTimeMillis - l.longValue());
Logger.i$default(eVar.p, "VideoQuality: inbound.timeToFirstFrame: " + eVar4.d + " (userId: " + j + ", ssrc: " + value.getSsrc() + ')', null, 2, null);
} else {
Logger.e$default(eVar.p, "VideoQuality: inbound.timeToFirstFrame: Unable to locate start time. (userId: " + j + ", ssrc: " + value.getSsrc() + ')', null, null, 6, null);
}
}
eVar2 = eVar;
it = it;
stats2 = stats2;
dVar = dVar;
currentTimeMillis = currentTimeMillis;
} catch (Throwable th2) {
th = th2;
throw th;
}
} catch (Throwable th3) {
th = th3;
eVar = eVar2;
throw th;
}
}
}
KrispOveruseDetector krispOveruseDetector = dVar.h;
Objects.requireNonNull(krispOveruseDetector);
m.checkNotNullParameter(stats2, "stats");
if (krispOveruseDetector.d.getType() == MediaEngineConnection.Type.DEFAULT && krispOveruseDetector.d.b()) {
OutboundRtpAudio outboundRtpAudio = stats2.getOutboundRtpAudio();
if (outboundRtpAudio != null && outboundRtpAudio.getNoiseCancellerIsEnabled()) {
OutboundRtpAudio outboundRtpAudio2 = krispOveruseDetector.b;
if (outboundRtpAudio2 != null) {
Pair<Boolean, Long> a = krispOveruseDetector.a(outboundRtpAudio2, stats2.getOutboundRtpAudio(), 8.0d);
boolean booleanValue = a.component1().booleanValue();
long longValue = a.component2().longValue();
if (booleanValue) {
krispOveruseDetector.d.f(KrispOveruseDetector.Status.CPU_OVERUSE);
} else if (longValue == 0) {
int i = krispOveruseDetector.f2154c + 1;
krispOveruseDetector.f2154c = i;
if (i > 2) {
krispOveruseDetector.d.f(KrispOveruseDetector.Status.FAILED);
}
} else {
krispOveruseDetector.f2154c = 0;
}
}
krispOveruseDetector.b = stats2.getOutboundRtpAudio();
}
OutboundRtpAudio outboundRtpAudio3 = stats2.getOutboundRtpAudio();
if (outboundRtpAudio3 != null && outboundRtpAudio3.getVoiceActivityDetectorIsEnabled()) {
OutboundRtpAudio outboundRtpAudio4 = krispOveruseDetector.a;
if (outboundRtpAudio4 != null && krispOveruseDetector.a(outboundRtpAudio4, stats2.getOutboundRtpAudio(), 4.0d).component1().booleanValue()) {
krispOveruseDetector.d.f(KrispOveruseDetector.Status.VAD_CPU_OVERUSE);
}
krispOveruseDetector.a = stats2.getOutboundRtpAudio();
}
}
return Unit.a;
} catch (Throwable th4) {
th = th4;
eVar = eVar2;
throw th;
}
}
}
}