268 lines
11 KiB
Java
268 lines
11 KiB
Java
|
package com.discord.stores;
|
||
|
|
||
|
import c.d.b.a.a;
|
||
|
import com.discord.api.voice.state.VoiceState;
|
||
|
import com.discord.app.AppLog;
|
||
|
import com.discord.gateway.GatewaySocket;
|
||
|
import com.discord.models.domain.ModelPayload;
|
||
|
import com.discord.utilities.logging.Logger;
|
||
|
import com.discord.utilities.time.Clock;
|
||
|
import d0.o;
|
||
|
import d0.t.h0;
|
||
|
import d0.z.d.m;
|
||
|
/* compiled from: ConnectionTimeStats.kt */
|
||
|
public final class ConnectionTimeStats {
|
||
|
private final Stat connectionStreamFirstFrame;
|
||
|
private final Stat connectionVideoFirstFrame;
|
||
|
private final Stat gatewayConnection;
|
||
|
private final Stat gatewayHello;
|
||
|
private final Stat mediaEngineConnection;
|
||
|
private Long myUserId;
|
||
|
private final Stat streamConnection;
|
||
|
private final Stat streamFirstFrame;
|
||
|
private final Stat streamRequested;
|
||
|
private final Stat videoFirstFrame;
|
||
|
private final Stat voiceConnection;
|
||
|
|
||
|
/* compiled from: ConnectionTimeStats.kt */
|
||
|
public static final class Stat {
|
||
|
private final Clock clock;
|
||
|
private Long endTime;
|
||
|
private Long startTime;
|
||
|
private final StatType type;
|
||
|
|
||
|
public Stat(Clock clock, StatType statType) {
|
||
|
m.checkNotNullParameter(clock, "clock");
|
||
|
m.checkNotNullParameter(statType, "type");
|
||
|
this.clock = clock;
|
||
|
this.type = statType;
|
||
|
}
|
||
|
|
||
|
public static /* synthetic */ void end$default(Stat stat, boolean z2, int i, Object obj) {
|
||
|
if ((i & 1) != 0) {
|
||
|
z2 = false;
|
||
|
}
|
||
|
stat.end(z2);
|
||
|
}
|
||
|
|
||
|
public static /* synthetic */ void start$default(Stat stat, boolean z2, int i, Object obj) {
|
||
|
if ((i & 1) != 0) {
|
||
|
z2 = false;
|
||
|
}
|
||
|
stat.start(z2);
|
||
|
}
|
||
|
|
||
|
public final void clear() {
|
||
|
this.startTime = null;
|
||
|
this.endTime = null;
|
||
|
}
|
||
|
|
||
|
public final void end(boolean z2) {
|
||
|
if (this.endTime == null) {
|
||
|
Long l = this.startTime;
|
||
|
long currentTimeMillis = this.clock.currentTimeMillis();
|
||
|
if (l == null) {
|
||
|
AppLog appLog = AppLog.g;
|
||
|
StringBuilder K = a.K("ConnectionTimeStats: \"");
|
||
|
K.append(this.type);
|
||
|
K.append("\" ended without starting!");
|
||
|
Logger.w$default(appLog, K.toString(), null, 2, null);
|
||
|
return;
|
||
|
}
|
||
|
long longValue = currentTimeMillis - l.longValue();
|
||
|
if (longValue < 0) {
|
||
|
AppLog appLog2 = AppLog.g;
|
||
|
StringBuilder K2 = a.K("ConnectionTimeStats: \"");
|
||
|
K2.append(this.type);
|
||
|
K2.append("\" has a negative time!");
|
||
|
Logger.e$default(appLog2, K2.toString(), null, h0.mapOf(o.to(this.type.toString(), "type"), o.to(String.valueOf(longValue), "elapsedMs"), o.to(String.valueOf(l.longValue()), "start"), o.to(String.valueOf(currentTimeMillis), "end")), 2, null);
|
||
|
return;
|
||
|
}
|
||
|
this.endTime = Long.valueOf(currentTimeMillis);
|
||
|
StringBuilder K3 = a.K("ConnectionTimeStats: \"");
|
||
|
K3.append(this.type);
|
||
|
K3.append("\" took ");
|
||
|
K3.append(longValue);
|
||
|
K3.append(" ms (");
|
||
|
K3.append(l);
|
||
|
K3.append(" to ");
|
||
|
K3.append(currentTimeMillis);
|
||
|
K3.append(')');
|
||
|
AppLog.i(K3.toString());
|
||
|
} else if (!z2) {
|
||
|
AppLog appLog3 = AppLog.g;
|
||
|
StringBuilder K4 = a.K("ConnectionTimeStats: \"");
|
||
|
K4.append(this.type);
|
||
|
K4.append("\" attempting to end while endTime is set!");
|
||
|
Logger.w$default(appLog3, K4.toString(), null, 2, null);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public final void start(boolean z2) {
|
||
|
if (this.startTime != null) {
|
||
|
if (!z2) {
|
||
|
AppLog appLog = AppLog.g;
|
||
|
StringBuilder K = a.K("ConnectionTimeStats: \"");
|
||
|
K.append(this.type);
|
||
|
K.append("\" attempting to re-start without reset!");
|
||
|
Logger.w$default(appLog, K.toString(), null, 2, null);
|
||
|
}
|
||
|
} else if (this.endTime != null) {
|
||
|
AppLog appLog2 = AppLog.g;
|
||
|
StringBuilder K2 = a.K("ConnectionTimeStats: \"");
|
||
|
K2.append(this.type);
|
||
|
K2.append("\" attempting to re-start while endTime is set!");
|
||
|
Logger.w$default(appLog2, K2.toString(), null, 2, null);
|
||
|
} else {
|
||
|
long currentTimeMillis = this.clock.currentTimeMillis();
|
||
|
this.startTime = Long.valueOf(currentTimeMillis);
|
||
|
StringBuilder K3 = a.K("ConnectionTimeStats: \"");
|
||
|
K3.append(this.type);
|
||
|
K3.append("\" started @ ");
|
||
|
K3.append(currentTimeMillis);
|
||
|
AppLog.i(K3.toString());
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
/* compiled from: ConnectionTimeStats.kt */
|
||
|
public enum StatType {
|
||
|
GatewayConnection,
|
||
|
GatewayHello,
|
||
|
VoiceConnection,
|
||
|
StreamRequested,
|
||
|
StreamConnection,
|
||
|
MediaEngineConnection,
|
||
|
StreamFirstFrame,
|
||
|
VideoFirstFrame,
|
||
|
ConnectionStreamFirstFrame,
|
||
|
ConnectionVideoFirstFrame
|
||
|
}
|
||
|
|
||
|
public ConnectionTimeStats(Clock clock) {
|
||
|
m.checkNotNullParameter(clock, "clock");
|
||
|
this.gatewayConnection = new Stat(clock, StatType.GatewayConnection);
|
||
|
this.gatewayHello = new Stat(clock, StatType.GatewayHello);
|
||
|
this.voiceConnection = new Stat(clock, StatType.VoiceConnection);
|
||
|
this.streamRequested = new Stat(clock, StatType.StreamRequested);
|
||
|
this.streamConnection = new Stat(clock, StatType.StreamConnection);
|
||
|
this.streamFirstFrame = new Stat(clock, StatType.StreamFirstFrame);
|
||
|
this.videoFirstFrame = new Stat(clock, StatType.VideoFirstFrame);
|
||
|
this.mediaEngineConnection = new Stat(clock, StatType.MediaEngineConnection);
|
||
|
this.connectionVideoFirstFrame = new Stat(clock, StatType.ConnectionVideoFirstFrame);
|
||
|
this.connectionStreamFirstFrame = new Stat(clock, StatType.ConnectionStreamFirstFrame);
|
||
|
}
|
||
|
|
||
|
public static final /* synthetic */ Stat access$getConnectionStreamFirstFrame$p(ConnectionTimeStats connectionTimeStats) {
|
||
|
return connectionTimeStats.connectionStreamFirstFrame;
|
||
|
}
|
||
|
|
||
|
public static final /* synthetic */ Stat access$getConnectionVideoFirstFrame$p(ConnectionTimeStats connectionTimeStats) {
|
||
|
return connectionTimeStats.connectionVideoFirstFrame;
|
||
|
}
|
||
|
|
||
|
public static final /* synthetic */ Stat access$getGatewayConnection$p(ConnectionTimeStats connectionTimeStats) {
|
||
|
return connectionTimeStats.gatewayConnection;
|
||
|
}
|
||
|
|
||
|
public static final /* synthetic */ Stat access$getGatewayHello$p(ConnectionTimeStats connectionTimeStats) {
|
||
|
return connectionTimeStats.gatewayHello;
|
||
|
}
|
||
|
|
||
|
public static final /* synthetic */ Stat access$getMediaEngineConnection$p(ConnectionTimeStats connectionTimeStats) {
|
||
|
return connectionTimeStats.mediaEngineConnection;
|
||
|
}
|
||
|
|
||
|
public static final /* synthetic */ Stat access$getStreamConnection$p(ConnectionTimeStats connectionTimeStats) {
|
||
|
return connectionTimeStats.streamConnection;
|
||
|
}
|
||
|
|
||
|
public static final /* synthetic */ Stat access$getStreamFirstFrame$p(ConnectionTimeStats connectionTimeStats) {
|
||
|
return connectionTimeStats.streamFirstFrame;
|
||
|
}
|
||
|
|
||
|
public static final /* synthetic */ Stat access$getStreamRequested$p(ConnectionTimeStats connectionTimeStats) {
|
||
|
return connectionTimeStats.streamRequested;
|
||
|
}
|
||
|
|
||
|
public static final /* synthetic */ Stat access$getVideoFirstFrame$p(ConnectionTimeStats connectionTimeStats) {
|
||
|
return connectionTimeStats.videoFirstFrame;
|
||
|
}
|
||
|
|
||
|
public static final /* synthetic */ Stat access$getVoiceConnection$p(ConnectionTimeStats connectionTimeStats) {
|
||
|
return connectionTimeStats.voiceConnection;
|
||
|
}
|
||
|
|
||
|
private final void clear(boolean z2) {
|
||
|
if (!z2) {
|
||
|
this.gatewayConnection.clear();
|
||
|
this.gatewayHello.clear();
|
||
|
}
|
||
|
this.voiceConnection.clear();
|
||
|
this.streamRequested.clear();
|
||
|
this.streamConnection.clear();
|
||
|
this.streamFirstFrame.clear();
|
||
|
this.videoFirstFrame.clear();
|
||
|
this.mediaEngineConnection.clear();
|
||
|
this.connectionVideoFirstFrame.clear();
|
||
|
this.connectionStreamFirstFrame.clear();
|
||
|
}
|
||
|
|
||
|
public static /* synthetic */ void clear$default(ConnectionTimeStats connectionTimeStats, boolean z2, int i, Object obj) {
|
||
|
if ((i & 1) != 0) {
|
||
|
z2 = false;
|
||
|
}
|
||
|
connectionTimeStats.clear(z2);
|
||
|
}
|
||
|
|
||
|
public final void addListener(GatewaySocket gatewaySocket) {
|
||
|
m.checkNotNullParameter(gatewaySocket, "socket");
|
||
|
gatewaySocket.getListeners().add(new ConnectionTimeStats$addListener$1(this));
|
||
|
}
|
||
|
|
||
|
public final void addListener(StoreMediaEngine storeMediaEngine) {
|
||
|
m.checkNotNullParameter(storeMediaEngine, "storeMediaEngine");
|
||
|
storeMediaEngine.getListeners().add(new ConnectionTimeStats$addListener$4(this));
|
||
|
}
|
||
|
|
||
|
public final void addListener(StoreRtcConnection storeRtcConnection) {
|
||
|
m.checkNotNullParameter(storeRtcConnection, "rtcConnection");
|
||
|
storeRtcConnection.getListeners().add(new ConnectionTimeStats$addListener$2(this));
|
||
|
}
|
||
|
|
||
|
public final void addListener(StoreStreamRtcConnection storeStreamRtcConnection) {
|
||
|
m.checkNotNullParameter(storeStreamRtcConnection, "streamRtcConnection");
|
||
|
storeStreamRtcConnection.getListeners().add(new ConnectionTimeStats$addListener$3(this));
|
||
|
}
|
||
|
|
||
|
public final void handleApplicationStreamUpdate(long j, Integer num) {
|
||
|
this.streamFirstFrame.start(true);
|
||
|
}
|
||
|
|
||
|
public final void handleConnectionOpen(ModelPayload modelPayload) {
|
||
|
m.checkNotNullParameter(modelPayload, "payload");
|
||
|
clear$default(this, false, 1, null);
|
||
|
this.myUserId = Long.valueOf(modelPayload.getMe().i());
|
||
|
}
|
||
|
|
||
|
public final void handleStreamWatch(String str) {
|
||
|
m.checkNotNullParameter(str, "streamKey");
|
||
|
Stat.start$default(this.streamRequested, false, 1, null);
|
||
|
}
|
||
|
|
||
|
public final void handleVideoStreamUpdate(long j, Integer num, int i, int i2, int i3) {
|
||
|
if (i2 != 0) {
|
||
|
this.videoFirstFrame.start(true);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public final void handleVoiceStateUpdate(VoiceState voiceState) {
|
||
|
m.checkNotNullParameter(voiceState, "voiceState");
|
||
|
long m = voiceState.m();
|
||
|
Long l = this.myUserId;
|
||
|
if (l != null && m == l.longValue() && voiceState.a() == null) {
|
||
|
clear(true);
|
||
|
}
|
||
|
}
|
||
|
}
|