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

455 lines
21 KiB
Java
Raw Normal View History

2021-08-18 07:29:27 +00:00
package c.a.q.o0;
import androidx.annotation.AnyThread;
import com.discord.utilities.collections.Histogram;
import com.discord.utilities.collections.ListenerCollection;
import com.discord.utilities.collections.ListenerCollectionSubject;
import com.discord.utilities.logging.Logger;
import com.discord.utilities.system.DeviceResourceUsageMonitor;
import com.discord.utilities.time.Clock;
import com.discord.utilities.time.TimeSpan;
import d0.t.h0;
import d0.t.n;
import d0.t.r;
import d0.z.d.m;
import d0.z.d.o;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.TimeUnit;
import kotlin.Pair;
import kotlin.Unit;
import kotlin.jvm.functions.Function1;
import kotlin.jvm.internal.DefaultConstructorMarker;
/* compiled from: VideoQuality.kt */
public final class e {
public static final List<Integer> a = n.listOf((Object[]) new Integer[]{0, 500000, 1000000, 1500000, 2000000, 3000000, 4000000, 5000000, 6000000, 7000000, 8000000});
public static final List<Integer> b = n.listOf((Object[]) new Integer[]{0, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60});
/* renamed from: c reason: collision with root package name */
2021-08-31 07:21:49 +00:00
public static final List<Integer> f231c = n.listOf((Object[]) new Integer[]{720, 480, 360});
2021-08-18 07:29:27 +00:00
public static final b d = new b(null);
public final ListenerCollectionSubject<f> e;
public final ListenerCollection<f> f;
public final long g;
public Long h;
public final d i;
public final d j;
public final d k;
public final C0042e l = new C0042e();
public final Map<String, C0042e> m = new LinkedHashMap();
public final Map<Long, Long> n = new LinkedHashMap();
public int o;
public final DeviceResourceUsageMonitor p;
public final Logger q;
public final Clock r;
/* compiled from: VideoQuality.kt */
public static final class a {
public long a;
public long b;
/* renamed from: c reason: collision with root package name */
2021-08-31 07:21:49 +00:00
public long f232c;
2021-08-18 07:29:27 +00:00
public long d;
public long e;
public long f;
public long g;
public long h;
public a() {
this(0, 0, 0, 0, 0, 0, 0, 0, 255);
}
public a(long j, long j2, long j3, long j4, long j5, long j6, long j7, long j8) {
this.a = j;
this.b = j2;
2021-08-31 07:21:49 +00:00
this.f232c = j3;
2021-08-18 07:29:27 +00:00
this.d = j4;
this.e = j5;
this.f = j6;
this.g = j7;
this.h = j8;
}
/* JADX INFO: this call moved to the top of the method (can break code semantics) */
public /* synthetic */ a(long j, long j2, long j3, long j4, long j5, long j6, long j7, long j8, int i) {
this((i & 1) != 0 ? 0 : j, (i & 2) != 0 ? 0 : j2, (i & 4) != 0 ? 0 : j3, (i & 8) != 0 ? 0 : j4, (i & 16) != 0 ? 0 : j5, (i & 32) != 0 ? 0 : j6, (i & 64) != 0 ? 0 : j7, (i & 128) == 0 ? j8 : 0);
}
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (!(obj instanceof a)) {
return false;
}
a aVar = (a) obj;
2021-08-31 07:21:49 +00:00
return this.a == aVar.a && this.b == aVar.b && this.f232c == aVar.f232c && this.d == aVar.d && this.e == aVar.e && this.f == aVar.f && this.g == aVar.g && this.h == aVar.h;
2021-08-18 07:29:27 +00:00
}
public int hashCode() {
int a = a0.a.a.b.a(this.b);
2021-08-31 07:21:49 +00:00
int a2 = a0.a.a.b.a(this.f232c);
2021-08-18 07:29:27 +00:00
int a3 = a0.a.a.b.a(this.d);
int a4 = a0.a.a.b.a(this.e);
int a5 = a0.a.a.b.a(this.f);
int a6 = a0.a.a.b.a(this.g);
return a0.a.a.b.a(this.h) + ((a6 + ((a5 + ((a4 + ((a3 + ((a2 + ((a + (a0.a.a.b.a(this.a) * 31)) * 31)) * 31)) * 31)) * 31)) * 31)) * 31);
}
public String toString() {
2021-08-31 07:21:49 +00:00
StringBuilder P = c.d.b.a.a.P("AggregatedProperties(framesCodec=");
P.append(this.a);
P.append(", framesNetwork=");
P.append(this.b);
P.append(", packets=");
P.append(this.f232c);
P.append(", packetsLost=");
P.append(this.d);
P.append(", framesDropped=");
P.append(this.e);
P.append(", bytes=");
P.append(this.f);
P.append(", nackCount=");
P.append(this.g);
P.append(", pliCount=");
return c.d.b.a.a.A(P, this.h, ")");
2021-08-18 07:29:27 +00:00
}
}
/* compiled from: VideoQuality.kt */
public static final class b {
public b(DefaultConstructorMarker defaultConstructorMarker) {
}
public static final long a(b bVar, Float f) {
if (f != null) {
return d0.a0.a.roundToLong(f.floatValue());
}
return 0;
}
}
/* compiled from: VideoQuality.kt */
public static abstract class c implements f {
}
/* compiled from: VideoQuality.kt */
public static final class d {
public Long a;
public long b;
public d(boolean z2, long j) {
this.a = z2 ? Long.valueOf(j) : null;
}
public final boolean a() {
return this.a != null;
}
public final void b(boolean z2, long j) {
Long l = this.a;
if (l == null) {
if (z2) {
this.a = Long.valueOf(j);
}
} else if (l != null) {
long longValue = l.longValue();
if (!z2) {
this.b = (j - longValue) + this.b;
this.a = null;
}
}
}
public final long c(long j) {
Long l = this.a;
if (l == null) {
return this.b;
}
return (this.b + j) - l.longValue();
}
}
/* compiled from: VideoQuality.kt */
/* renamed from: c.a.q.o0.e$e reason: collision with other inner class name */
public static final class C0042e {
public List<g> a = new ArrayList();
public final Histogram b = new Histogram(5, 0, 2, null);
/* renamed from: c reason: collision with root package name */
2021-08-31 07:21:49 +00:00
public final Histogram f233c = new Histogram(25600, 0, 2, null);
2021-08-18 07:29:27 +00:00
public Long d;
public a e = new a(0, 0, 0, 0, 0, 0, 0, 0, 255);
public long f;
public Map<Integer, Float> g = new LinkedHashMap();
public Map<Integer, Float> h = new LinkedHashMap();
public float i;
public Map<Integer, Float> j = new LinkedHashMap();
public C0042e() {
for (Number number : e.a) {
this.g.put(Integer.valueOf(number.intValue()), Float.valueOf(0.0f));
}
for (Number number2 : e.b) {
this.h.put(Integer.valueOf(number2.intValue()), Float.valueOf(0.0f));
}
2021-08-31 07:21:49 +00:00
for (Number number3 : e.f231c) {
2021-08-18 07:29:27 +00:00
this.j.put(Integer.valueOf(number3.intValue()), Float.valueOf(0.0f));
}
}
}
/* compiled from: VideoQuality.kt */
public interface f {
void onFirstFrameReceived(long j);
void onFirstFrameSent();
}
/* compiled from: VideoQuality.kt */
public static final class g {
public final long a;
public final long b;
/* renamed from: c reason: collision with root package name */
2021-08-31 07:21:49 +00:00
public final a f234c;
2021-08-18 07:29:27 +00:00
public g() {
this(0, 0, new a(0, 0, 0, 0, 0, 0, 0, 0, 255));
}
public g(long j, long j2, a aVar) {
m.checkNotNullParameter(aVar, "aggregatedProperties");
this.a = j;
this.b = j2;
2021-08-31 07:21:49 +00:00
this.f234c = aVar;
2021-08-18 07:29:27 +00:00
}
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (!(obj instanceof g)) {
return false;
}
g gVar = (g) obj;
2021-08-31 07:21:49 +00:00
return this.a == gVar.a && this.b == gVar.b && m.areEqual(this.f234c, gVar.f234c);
2021-08-18 07:29:27 +00:00
}
public int hashCode() {
int a = (a0.a.a.b.a(this.b) + (a0.a.a.b.a(this.a) * 31)) * 31;
2021-08-31 07:21:49 +00:00
a aVar = this.f234c;
2021-08-18 07:29:27 +00:00
return a + (aVar != null ? aVar.hashCode() : 0);
}
public String toString() {
2021-08-31 07:21:49 +00:00
StringBuilder P = c.d.b.a.a.P("RawVideoStats(resolution=");
P.append(this.a);
P.append(", timestamp=");
P.append(this.b);
P.append(", aggregatedProperties=");
P.append(this.f234c);
P.append(")");
return P.toString();
2021-08-18 07:29:27 +00:00
}
}
/* compiled from: VideoQuality.kt */
public static final class h extends o implements Function1<DeviceResourceUsageMonitor.ResourceUsage, Unit> {
public final /* synthetic */ e this$0;
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
public h(e eVar) {
super(1);
this.this$0 = eVar;
}
/* 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(DeviceResourceUsageMonitor.ResourceUsage resourceUsage) {
DeviceResourceUsageMonitor.ResourceUsage resourceUsage2 = resourceUsage;
m.checkNotNullParameter(resourceUsage2, "it");
e eVar = this.this$0;
List<Integer> list = e.a;
synchronized (eVar) {
for (Map.Entry<String, C0042e> entry : eVar.m.entrySet()) {
C0042e value = entry.getValue();
value.b.addSample((long) resourceUsage2.getCpuUsagePercent());
2021-08-31 07:21:49 +00:00
value.f233c.addSample(resourceUsage2.getMemoryRssBytes());
2021-08-18 07:29:27 +00:00
}
eVar.l.b.addSample((long) resourceUsage2.getCpuUsagePercent());
2021-08-31 07:21:49 +00:00
eVar.l.f233c.addSample(resourceUsage2.getMemoryRssBytes());
2021-08-18 07:29:27 +00:00
}
return Unit.a;
}
}
public e(Logger logger, Clock clock) {
m.checkNotNullParameter(logger, "logger");
m.checkNotNullParameter(clock, "clock");
this.q = logger;
this.r = clock;
ListenerCollectionSubject<f> listenerCollectionSubject = new ListenerCollectionSubject<>();
this.e = listenerCollectionSubject;
this.f = listenerCollectionSubject;
long currentTimeMillis = clock.currentTimeMillis();
this.g = currentTimeMillis;
this.i = new d(false, currentTimeMillis);
this.j = new d(false, currentTimeMillis);
this.k = new d(false, currentTimeMillis);
DeviceResourceUsageMonitor deviceResourceUsageMonitor = new DeviceResourceUsageMonitor(new TimeSpan(1, TimeUnit.SECONDS), clock, new h(this));
this.p = deviceResourceUsageMonitor;
deviceResourceUsageMonitor.start();
}
public final void a(C0042e eVar, g gVar) {
eVar.a.add(gVar);
if (eVar.a.size() >= 2) {
List<g> list = eVar.a;
g gVar2 = list.get(list.size() - 1);
List<g> list2 = eVar.a;
g gVar3 = list2.get(list2.size() - 2);
f fVar = f.i;
eVar.f = (gVar2.b - gVar3.b) + eVar.f;
a aVar = eVar.e;
2021-08-31 07:21:49 +00:00
a aVar2 = gVar2.f234c;
a aVar3 = gVar3.f234c;
2021-08-18 07:29:27 +00:00
aVar.a = fVar.a(aVar2.a, aVar3.a) + aVar.a;
aVar.b = fVar.a(aVar2.b, aVar3.b) + aVar.b;
2021-08-31 07:21:49 +00:00
aVar.f232c = fVar.a(aVar2.f232c, aVar3.f232c) + aVar.f232c;
2021-08-18 07:29:27 +00:00
aVar.d = fVar.a(aVar2.d, aVar3.d) + aVar.d;
aVar.e = fVar.a(aVar2.e, aVar3.e) + aVar.e;
aVar.f = fVar.a(aVar2.f, aVar3.f) + aVar.f;
aVar.g = fVar.a(aVar2.g, aVar3.g) + aVar.g;
aVar.h = fVar.a(aVar2.h, aVar3.h) + aVar.h;
2021-08-31 07:21:49 +00:00
a aVar4 = gVar2.f234c;
2021-08-18 07:29:27 +00:00
long j = aVar4.f;
long j2 = aVar4.a;
long j3 = gVar2.b;
long j4 = gVar2.a;
float f2 = ((float) (j3 - gVar3.b)) / 1000.0f;
eVar.i = (((float) j4) * f2) + eVar.i;
if (eVar.a.size() >= 6) {
List<g> list3 = eVar.a;
g gVar4 = list3.get(list3.size() - 3);
2021-08-31 07:21:49 +00:00
a aVar5 = gVar4.f234c;
2021-08-18 07:29:27 +00:00
long j5 = aVar5.f;
long j6 = aVar5.a;
long j7 = gVar4.b;
2021-08-31 07:21:49 +00:00
Iterator<T> it = f231c.iterator();
2021-08-18 07:29:27 +00:00
while (true) {
float f3 = 0.0f;
if (!it.hasNext()) {
break;
}
int intValue = ((Number) it.next()).intValue();
if (j4 <= ((long) intValue)) {
Map<Integer, Float> map = eVar.j;
Integer valueOf = Integer.valueOf(intValue);
Float f4 = eVar.j.get(Integer.valueOf(intValue));
if (f4 != null) {
f3 = f4.floatValue();
}
map.put(valueOf, Float.valueOf(f3 + f2));
}
j2 = j2;
j6 = j6;
}
float f5 = ((float) (j3 - j7)) / 1000.0f;
float f6 = ((float) ((j - j5) * ((long) 8))) / f5;
float f7 = ((float) (j2 - j6)) / f5;
for (Number number : a) {
int intValue2 = number.intValue();
if (f6 <= ((float) intValue2)) {
Map<Integer, Float> map2 = eVar.g;
Integer valueOf2 = Integer.valueOf(intValue2);
Float f8 = eVar.g.get(Integer.valueOf(intValue2));
map2.put(valueOf2, Float.valueOf((f8 != null ? f8.floatValue() : 0.0f) + f2));
}
}
for (Number number2 : b) {
int intValue3 = number2.intValue();
if (f7 <= ((float) intValue3)) {
Map<Integer, Float> map3 = eVar.h;
Integer valueOf3 = Integer.valueOf(intValue3);
Float f9 = eVar.h.get(Integer.valueOf(intValue3));
map3.put(valueOf3, Float.valueOf((f9 != null ? f9.floatValue() : 0.0f) + f2));
}
}
r.removeFirst(eVar.a);
}
}
}
@AnyThread
public final synchronized Map<String, Object> b(String str) {
C0042e eVar;
m.checkNotNullParameter(str, "userId");
eVar = this.m.get(str);
return eVar != null ? d(eVar) : null;
}
@AnyThread
public final synchronized Map<String, Object> c() {
return h0.plus(d(this.l), h0.mapOf(d0.o.to("target_bitrate", Integer.valueOf(this.o)), d0.o.to("duration_encoder_nvidia_cuda", 0), d0.o.to("duration_encoder_nvidia_direct3d", 0), d0.o.to("duration_encoder_openh264", 0), d0.o.to("duration_encoder_videotoolbox", 0), d0.o.to("duration_encoder_amd_direct3d", 0), d0.o.to("duration_encoder_intel", 0), d0.o.to("duration_encoder_intel_direct3d", 0), d0.o.to("duration_encoder_unknown", 0)));
}
2021-08-31 07:21:49 +00:00
/* JADX DEBUG: Can't convert new array creation: APUT found in different block: 0x04e0: APUT
2021-08-18 07:29:27 +00:00
(r6v4 kotlin.Pair[])
(6 ??[int, float, short, byte, char])
2021-08-31 07:21:49 +00:00
(wrap: kotlin.Pair : 0x04db: INVOKE (r1v3 kotlin.Pair) =
2021-08-18 07:29:27 +00:00
("time_to_first_frame_ms")
2021-08-31 07:21:49 +00:00
(wrap: java.lang.Long : 0x04d4: INVOKE (r1v2 java.lang.Long) = (r4v22 long) type: STATIC call: java.lang.Long.valueOf(long):java.lang.Long)
2021-08-18 07:29:27 +00:00
type: STATIC call: d0.o.to(java.lang.Object, java.lang.Object):kotlin.Pair)
*/
public final Map<String, Object> d(C0042e eVar) {
Float valueOf;
long currentTimeMillis = this.r.currentTimeMillis();
Long l = this.h;
float longValue = ((float) (l != null ? l.longValue() - this.g : currentTimeMillis - this.g)) / 1000.0f;
float f2 = ((float) eVar.f) / 1000.0f;
int i = (f2 > ((float) 0) ? 1 : (f2 == ((float) 0) ? 0 : -1));
long roundToLong = (i <= 0 || (valueOf = Float.valueOf(eVar.i / f2)) == null) ? 0 : d0.a0.a.roundToLong(valueOf.floatValue());
Histogram.Report report = eVar.b.getReport();
2021-08-31 07:21:49 +00:00
Histogram.Report report2 = eVar.f233c.getReport();
2021-08-18 07:29:27 +00:00
b bVar = d;
2021-08-31 07:21:49 +00:00
long j = (long) 1024;
Map mapOf = h0.mapOf(d0.o.to("duration", Double.valueOf(Math.floor((double) longValue))), c.d.b.a.a.Y(bVar, eVar.g.get(8000000), "duration_stream_under_8mbps"), c.d.b.a.a.Y(bVar, eVar.g.get(7000000), "duration_stream_under_7mbps"), c.d.b.a.a.Y(bVar, eVar.g.get(6000000), "duration_stream_under_6mbps"), c.d.b.a.a.Y(bVar, eVar.g.get(5000000), "duration_stream_under_5mbps"), c.d.b.a.a.Y(bVar, eVar.g.get(4000000), "duration_stream_under_4mbps"), c.d.b.a.a.Y(bVar, eVar.g.get(3000000), "duration_stream_under_3mbps"), c.d.b.a.a.Y(bVar, eVar.g.get(2000000), "duration_stream_under_2mbps"), c.d.b.a.a.Y(bVar, eVar.g.get(1500000), "duration_stream_under_1_5mbps"), c.d.b.a.a.Y(bVar, eVar.g.get(1000000), "duration_stream_under_1mbps"), c.d.b.a.a.Y(bVar, eVar.g.get(500000), "duration_stream_under_0_5mbps"), c.d.b.a.a.Y(bVar, eVar.g.get(0), "duration_stream_at_0mbps"), c.d.b.a.a.Y(bVar, eVar.h.get(60), "duration_fps_under_60"), c.d.b.a.a.Y(bVar, eVar.h.get(55), "duration_fps_under_55"), c.d.b.a.a.Y(bVar, eVar.h.get(50), "duration_fps_under_50"), c.d.b.a.a.Y(bVar, eVar.h.get(45), "duration_fps_under_45"), c.d.b.a.a.Y(bVar, eVar.h.get(40), "duration_fps_under_40"), c.d.b.a.a.Y(bVar, eVar.h.get(35), "duration_fps_under_35"), c.d.b.a.a.Y(bVar, eVar.h.get(30), "duration_fps_under_30"), c.d.b.a.a.Y(bVar, eVar.h.get(25), "duration_fps_under_25"), c.d.b.a.a.Y(bVar, eVar.h.get(20), "duration_fps_under_20"), c.d.b.a.a.Y(bVar, eVar.h.get(15), "duration_fps_under_15"), c.d.b.a.a.Y(bVar, eVar.h.get(10), "duration_fps_under_10"), c.d.b.a.a.Y(bVar, eVar.h.get(5), "duration_fps_under_5"), c.d.b.a.a.Y(bVar, eVar.h.get(0), "duration_fps_at_0"), d0.o.to("avg_resolution", Long.valueOf(roundToLong)), c.d.b.a.a.Y(bVar, eVar.j.get(720), "duration_resolution_under_720"), c.d.b.a.a.Y(bVar, eVar.j.get(480), "duration_resolution_under_480"), c.d.b.a.a.Y(bVar, eVar.j.get(360), "duration_resolution_under_360"), d0.o.to("num_pauses", 0), d0.o.to("duration_paused", Long.valueOf(b.a(bVar, Float.valueOf(((float) this.i.c(currentTimeMillis)) / 1000.0f)))), d0.o.to("duration_zero_receivers", Long.valueOf(b.a(bVar, Float.valueOf(((float) this.j.c(currentTimeMillis)) / 1000.0f)))), d0.o.to("duration_video_stopped", Long.valueOf(b.a(bVar, Float.valueOf(((float) this.k.c(currentTimeMillis)) / 1000.0f)))), d0.o.to("client_performance_cpu_percentile25", Long.valueOf(report.getPercentile25())), d0.o.to("client_performance_cpu_percentile50", Long.valueOf(report.getPercentile50())), d0.o.to("client_performance_cpu_percentile75", Long.valueOf(report.getPercentile75())), d0.o.to("client_performance_cpu_percentile90", Long.valueOf(report.getPercentile90())), d0.o.to("client_performance_cpu_percentile95", Long.valueOf(report.getPercentile95())), d0.o.to("client_performance_memory_percentile25", Long.valueOf(report2.getPercentile25() / j)), d0.o.to("client_performance_memory_percentile50", Long.valueOf(report2.getPercentile50() / j)), d0.o.to("client_performance_memory_percentile75", Long.valueOf(report2.getPercentile75() / j)), d0.o.to("client_performance_memory_percentile90", Long.valueOf(report2.getPercentile90() / j)), d0.o.to("client_performance_memory_percentile95", Long.valueOf(report2.getPercentile95() / j)), d0.o.to("client_performance_memory_min", Long.valueOf(report2.getMin() / j)), d0.o.to("client_performance_memory_max", Long.valueOf(report2.getMax() / j)));
2021-08-18 07:29:27 +00:00
a aVar = eVar.e;
long a2 = i > 0 ? b.a(bVar, Float.valueOf(((float) (aVar.f * ((long) 8))) / f2)) : 0;
long a3 = i > 0 ? b.a(bVar, Float.valueOf(((float) aVar.a) / f2)) : 0;
Pair[] pairArr = new Pair[10];
pairArr[0] = d0.o.to("avg_bitrate", Long.valueOf(a2));
pairArr[1] = d0.o.to("avg_fps", Long.valueOf(a3));
pairArr[2] = d0.o.to("num_bytes", Long.valueOf(aVar.f));
pairArr[3] = d0.o.to("num_packets_lost", Long.valueOf(aVar.d));
2021-08-31 07:21:49 +00:00
pairArr[4] = d0.o.to("num_packets", Long.valueOf(aVar.f232c));
2021-08-18 07:29:27 +00:00
pairArr[5] = d0.o.to("num_frames", Long.valueOf(aVar.b));
Long l2 = eVar.d;
pairArr[6] = d0.o.to("time_to_first_frame_ms", Long.valueOf(l2 != null ? l2.longValue() : 0));
pairArr[7] = d0.o.to("num_frames_dropped", Long.valueOf(aVar.e));
pairArr[8] = d0.o.to("num_nacks", Long.valueOf(aVar.g));
pairArr[9] = d0.o.to("num_plis", Long.valueOf(aVar.h));
return h0.plus(mapOf, h0.mapOf(pairArr));
}
public final void e(Boolean bool, Integer num, long j) {
boolean z2 = false;
if (num != null) {
this.j.b(num.intValue() == 0, j);
}
if (this.i.a() || this.j.a()) {
z2 = true;
}
if (z2 != this.k.a()) {
this.k.b(z2, j);
this.l.a.clear();
}
}
}