948 lines
31 KiB
Java
948 lines
31 KiB
Java
package com.discord.rtcconnection;
|
|
|
|
import android.content.Intent;
|
|
import android.util.Log;
|
|
import androidx.annotation.AnyThread;
|
|
import androidx.core.app.NotificationCompat;
|
|
import c.a.q.a0;
|
|
import c.a.q.b0;
|
|
import c.a.q.f0;
|
|
import c.a.q.g;
|
|
import c.a.q.g0;
|
|
import c.a.q.h0;
|
|
import c.a.q.j;
|
|
import c.a.q.p;
|
|
import c.a.q.q;
|
|
import c.a.q.r;
|
|
import c.a.q.x;
|
|
import c.a.q.z;
|
|
import co.discord.media_engine.InboundRtpAudio;
|
|
import co.discord.media_engine.OutboundRtpAudio;
|
|
import co.discord.media_engine.Stats;
|
|
import co.discord.media_engine.VoiceQuality;
|
|
import com.discord.models.domain.ModelAuditLogEntry;
|
|
import com.discord.rtcconnection.MediaSinkWantsManager;
|
|
import com.discord.rtcconnection.mediaengine.MediaEngine;
|
|
import com.discord.rtcconnection.mediaengine.MediaEngineConnection;
|
|
import com.discord.rtcconnection.mediaengine.ThumbnailEmitter;
|
|
import com.discord.utilities.debug.DebugPrintBuilder;
|
|
import com.discord.utilities.debug.DebugPrintable;
|
|
import com.discord.utilities.logging.Logger;
|
|
import com.discord.utilities.networking.Backoff;
|
|
import com.discord.utilities.networking.NetworkMonitor;
|
|
import com.discord.utilities.time.Clock;
|
|
import d0.g0.s;
|
|
import d0.t.u;
|
|
import d0.z.d.m;
|
|
import d0.z.d.o;
|
|
import java.util.ArrayList;
|
|
import java.util.HashMap;
|
|
import java.util.LinkedHashMap;
|
|
import java.util.List;
|
|
import java.util.Map;
|
|
import java.util.UUID;
|
|
import java.util.concurrent.CopyOnWriteArrayList;
|
|
import kotlin.NoWhenBranchMatchedException;
|
|
import kotlin.Unit;
|
|
import kotlin.jvm.functions.Function0;
|
|
import kotlin.jvm.internal.DefaultConstructorMarker;
|
|
import rx.Observable;
|
|
import rx.Subscription;
|
|
import rx.subjects.BehaviorSubject;
|
|
/* compiled from: RtcConnection.kt */
|
|
public final class RtcConnection implements DebugPrintable, MediaSinkWantsManager.a {
|
|
public static int i;
|
|
public static final a j = new a(null);
|
|
public final c.a.q.o0.e A;
|
|
public Long B;
|
|
public Long C;
|
|
public int D;
|
|
public Subscription E;
|
|
public Long F;
|
|
public final MediaSinkWantsManager G;
|
|
public final Subscription H;
|
|
public boolean I;
|
|
public String J;
|
|
public long K;
|
|
public final h0 L;
|
|
public final b0 M;
|
|
public final Long N;
|
|
public final long O;
|
|
public String P;
|
|
public final boolean Q;
|
|
public final String R;
|
|
public final long S;
|
|
public final MediaEngine T;
|
|
public final Logger U;
|
|
public final Clock V;
|
|
public final d W;
|
|
public final Map<Long, Boolean> X;
|
|
public final Map<Long, Float> Y;
|
|
public final String Z;
|
|
|
|
/* renamed from: a0 reason: collision with root package name */
|
|
public final boolean f2192a0;
|
|
|
|
/* renamed from: b0 reason: collision with root package name */
|
|
public final String f2193b0;
|
|
|
|
/* renamed from: c0 reason: collision with root package name */
|
|
public final String f2194c0;
|
|
public final String k;
|
|
public final String l;
|
|
public final CopyOnWriteArrayList<c> m;
|
|
public c.a.q.o0.d n;
|
|
public boolean o;
|
|
public final Backoff p;
|
|
public MediaEngineConnection.TransportInfo q;
|
|
public StateChange r;
|
|
|
|
/* renamed from: s reason: collision with root package name */
|
|
public BehaviorSubject<StateChange> f2195s;
|
|
public boolean t;
|
|
public List<Long> u;
|
|
public c.a.q.n0.a v;
|
|
public MediaEngineConnection w;
|
|
|
|
/* renamed from: x reason: collision with root package name */
|
|
public String f2196x;
|
|
|
|
/* renamed from: y reason: collision with root package name */
|
|
public Integer f2197y;
|
|
|
|
/* renamed from: z reason: collision with root package name */
|
|
public int f2198z;
|
|
|
|
/* compiled from: RtcConnection.kt */
|
|
public enum AnalyticsEvent {
|
|
VOICE_CONNECTION_SUCCESS,
|
|
VOICE_CONNECTION_FAILURE,
|
|
VOICE_DISCONNECT,
|
|
VIDEO_STREAM_ENDED,
|
|
MEDIA_SESSION_JOINED
|
|
}
|
|
|
|
/* compiled from: RtcConnection.kt */
|
|
public static final class Metadata {
|
|
public final String a;
|
|
public final String b;
|
|
|
|
/* renamed from: c reason: collision with root package name */
|
|
public final Long f2199c;
|
|
public final Long d;
|
|
public final String e;
|
|
|
|
public Metadata(String str, String str2, Long l, Long l2, String str3) {
|
|
m.checkNotNullParameter(str, "rtcConnectionId");
|
|
this.a = str;
|
|
this.b = str2;
|
|
this.f2199c = l;
|
|
this.d = l2;
|
|
this.e = str3;
|
|
}
|
|
|
|
public boolean equals(Object obj) {
|
|
if (this == obj) {
|
|
return true;
|
|
}
|
|
if (!(obj instanceof Metadata)) {
|
|
return false;
|
|
}
|
|
Metadata metadata = (Metadata) obj;
|
|
return m.areEqual(this.a, metadata.a) && m.areEqual(this.b, metadata.b) && m.areEqual(this.f2199c, metadata.f2199c) && m.areEqual(this.d, metadata.d) && m.areEqual(this.e, metadata.e);
|
|
}
|
|
|
|
public int hashCode() {
|
|
String str = this.a;
|
|
int i = 0;
|
|
int hashCode = (str != null ? str.hashCode() : 0) * 31;
|
|
String str2 = this.b;
|
|
int hashCode2 = (hashCode + (str2 != null ? str2.hashCode() : 0)) * 31;
|
|
Long l = this.f2199c;
|
|
int hashCode3 = (hashCode2 + (l != null ? l.hashCode() : 0)) * 31;
|
|
Long l2 = this.d;
|
|
int hashCode4 = (hashCode3 + (l2 != null ? l2.hashCode() : 0)) * 31;
|
|
String str3 = this.e;
|
|
if (str3 != null) {
|
|
i = str3.hashCode();
|
|
}
|
|
return hashCode4 + i;
|
|
}
|
|
|
|
public String toString() {
|
|
StringBuilder R = c.d.b.a.a.R("Metadata(rtcConnectionId=");
|
|
R.append(this.a);
|
|
R.append(", mediaSessionId=");
|
|
R.append(this.b);
|
|
R.append(", channelId=");
|
|
R.append(this.f2199c);
|
|
R.append(", guildId=");
|
|
R.append(this.d);
|
|
R.append(", streamKey=");
|
|
return c.d.b.a.a.H(R, this.e, ")");
|
|
}
|
|
}
|
|
|
|
/* compiled from: RtcConnection.kt */
|
|
public enum Quality {
|
|
UNKNOWN,
|
|
BAD,
|
|
AVERAGE,
|
|
FINE;
|
|
|
|
public static final a Companion = new a(null);
|
|
|
|
/* compiled from: RtcConnection.kt */
|
|
public static final class a {
|
|
public a(DefaultConstructorMarker defaultConstructorMarker) {
|
|
}
|
|
}
|
|
}
|
|
|
|
/* compiled from: RtcConnection.kt */
|
|
public static abstract class State {
|
|
|
|
/* compiled from: RtcConnection.kt */
|
|
public static final class a extends State {
|
|
public static final a a = new a();
|
|
|
|
public a() {
|
|
super(null);
|
|
}
|
|
}
|
|
|
|
/* compiled from: RtcConnection.kt */
|
|
public static final class b extends State {
|
|
public static final b a = new b();
|
|
|
|
public b() {
|
|
super(null);
|
|
}
|
|
}
|
|
|
|
/* compiled from: RtcConnection.kt */
|
|
public static final class c extends State {
|
|
public static final c a = new c();
|
|
|
|
public c() {
|
|
super(null);
|
|
}
|
|
}
|
|
|
|
/* compiled from: RtcConnection.kt */
|
|
public static final class d extends State {
|
|
public final boolean a;
|
|
|
|
public d(boolean z2) {
|
|
super(null);
|
|
this.a = z2;
|
|
}
|
|
|
|
public boolean equals(Object obj) {
|
|
if (this != obj) {
|
|
return (obj instanceof d) && this.a == ((d) obj).a;
|
|
}
|
|
return true;
|
|
}
|
|
|
|
public int hashCode() {
|
|
boolean z2 = this.a;
|
|
if (z2) {
|
|
return 1;
|
|
}
|
|
return z2 ? 1 : 0;
|
|
}
|
|
|
|
@Override // com.discord.rtcconnection.RtcConnection.State
|
|
public String toString() {
|
|
return c.d.b.a.a.L(c.d.b.a.a.R("Disconnected(willReconnect="), this.a, ")");
|
|
}
|
|
}
|
|
|
|
/* compiled from: RtcConnection.kt */
|
|
public static final class e extends State {
|
|
public static final e a = new e();
|
|
|
|
public e() {
|
|
super(null);
|
|
}
|
|
}
|
|
|
|
/* compiled from: RtcConnection.kt */
|
|
public static final class f extends State {
|
|
public static final f a = new f();
|
|
|
|
public f() {
|
|
super(null);
|
|
}
|
|
}
|
|
|
|
/* compiled from: RtcConnection.kt */
|
|
public static final class g extends State {
|
|
public static final g a = new g();
|
|
|
|
public g() {
|
|
super(null);
|
|
}
|
|
}
|
|
|
|
/* compiled from: RtcConnection.kt */
|
|
public static final class h extends State {
|
|
public static final h a = new h();
|
|
|
|
public h() {
|
|
super(null);
|
|
}
|
|
}
|
|
|
|
public State() {
|
|
}
|
|
|
|
public State(DefaultConstructorMarker defaultConstructorMarker) {
|
|
}
|
|
|
|
public String toString() {
|
|
if (this instanceof d) {
|
|
return super.toString();
|
|
}
|
|
String simpleName = getClass().getSimpleName();
|
|
m.checkNotNullExpressionValue(simpleName, "javaClass.simpleName");
|
|
return simpleName;
|
|
}
|
|
}
|
|
|
|
/* compiled from: RtcConnection.kt */
|
|
public static final class StateChange {
|
|
public final State a;
|
|
public final Metadata b;
|
|
|
|
public StateChange(State state, Metadata metadata) {
|
|
m.checkNotNullParameter(state, "state");
|
|
this.a = state;
|
|
this.b = metadata;
|
|
}
|
|
|
|
public boolean equals(Object obj) {
|
|
if (this == obj) {
|
|
return true;
|
|
}
|
|
if (!(obj instanceof StateChange)) {
|
|
return false;
|
|
}
|
|
StateChange stateChange = (StateChange) obj;
|
|
return m.areEqual(this.a, stateChange.a) && m.areEqual(this.b, stateChange.b);
|
|
}
|
|
|
|
public int hashCode() {
|
|
State state = this.a;
|
|
int i = 0;
|
|
int hashCode = (state != null ? state.hashCode() : 0) * 31;
|
|
Metadata metadata = this.b;
|
|
if (metadata != null) {
|
|
i = metadata.hashCode();
|
|
}
|
|
return hashCode + i;
|
|
}
|
|
|
|
public String toString() {
|
|
StringBuilder R = c.d.b.a.a.R("StateChange(state=");
|
|
R.append(this.a);
|
|
R.append(", metadata=");
|
|
R.append(this.b);
|
|
R.append(")");
|
|
return R.toString();
|
|
}
|
|
}
|
|
|
|
/* compiled from: RtcConnection.kt */
|
|
public static final class a {
|
|
public a(DefaultConstructorMarker defaultConstructorMarker) {
|
|
}
|
|
}
|
|
|
|
/* compiled from: RtcConnection.kt */
|
|
public static abstract class b implements c {
|
|
@Override // com.discord.rtcconnection.RtcConnection.c
|
|
public void onAnalyticsEvent(AnalyticsEvent analyticsEvent, Map<String, Object> map) {
|
|
m.checkNotNullParameter(analyticsEvent, "event");
|
|
m.checkNotNullParameter(map, "properties");
|
|
}
|
|
|
|
@Override // com.discord.rtcconnection.RtcConnection.c
|
|
public void onFatalClose() {
|
|
}
|
|
|
|
public void onFirstFrameReceived(long j) {
|
|
}
|
|
|
|
public void onFirstFrameSent() {
|
|
}
|
|
|
|
@Override // com.discord.rtcconnection.RtcConnection.c
|
|
public void onMediaEngineConnectionConnected(RtcConnection rtcConnection) {
|
|
m.checkNotNullParameter(rtcConnection, "connection");
|
|
}
|
|
|
|
@Override // com.discord.rtcconnection.RtcConnection.c
|
|
public void onMediaSessionIdReceived() {
|
|
}
|
|
|
|
@Override // com.discord.rtcconnection.RtcConnection.c
|
|
public void onQualityUpdate(Quality quality) {
|
|
m.checkNotNullParameter(quality, "quality");
|
|
}
|
|
|
|
@Override // com.discord.rtcconnection.RtcConnection.c
|
|
public void onSpeaking(long j, boolean z2) {
|
|
}
|
|
|
|
@Override // com.discord.rtcconnection.RtcConnection.c
|
|
public abstract void onStateChange(StateChange stateChange);
|
|
|
|
@Override // com.discord.rtcconnection.RtcConnection.c
|
|
public void onUserCreated(RtcConnection rtcConnection, long j) {
|
|
m.checkNotNullParameter(rtcConnection, "connection");
|
|
}
|
|
|
|
@Override // com.discord.rtcconnection.RtcConnection.c
|
|
public void onVideoMetadata(VideoMetadata videoMetadata) {
|
|
m.checkNotNullParameter(videoMetadata, "metadata");
|
|
}
|
|
|
|
@Override // com.discord.rtcconnection.RtcConnection.c
|
|
public void onVideoStream(long j, Integer num, int i, int i2, int i3) {
|
|
}
|
|
}
|
|
|
|
/* compiled from: RtcConnection.kt */
|
|
public interface c {
|
|
void onAnalyticsEvent(AnalyticsEvent analyticsEvent, Map<String, Object> map);
|
|
|
|
void onFatalClose();
|
|
|
|
void onMediaEngineConnectionConnected(RtcConnection rtcConnection);
|
|
|
|
void onMediaSessionIdReceived();
|
|
|
|
void onQualityUpdate(Quality quality);
|
|
|
|
void onSpeaking(long j, boolean z2);
|
|
|
|
void onStateChange(StateChange stateChange);
|
|
|
|
void onUserCreated(RtcConnection rtcConnection, long j);
|
|
|
|
void onVideoMetadata(VideoMetadata videoMetadata);
|
|
|
|
void onVideoStream(long j, Integer num, int i, int i2, int i3);
|
|
}
|
|
|
|
/* compiled from: RtcConnection.kt */
|
|
public static abstract class d {
|
|
|
|
/* compiled from: RtcConnection.kt */
|
|
public static final class a extends d {
|
|
public static final a a = new a();
|
|
|
|
public a() {
|
|
super(null);
|
|
}
|
|
}
|
|
|
|
/* compiled from: RtcConnection.kt */
|
|
public static final class b extends d {
|
|
public final long a;
|
|
|
|
public b(long j) {
|
|
super(null);
|
|
this.a = j;
|
|
}
|
|
|
|
public boolean equals(Object obj) {
|
|
if (this != obj) {
|
|
return (obj instanceof b) && this.a == ((b) obj).a;
|
|
}
|
|
return true;
|
|
}
|
|
|
|
public int hashCode() {
|
|
return a0.a.a.b.a(this.a);
|
|
}
|
|
|
|
public String toString() {
|
|
return c.d.b.a.a.B(c.d.b.a.a.R("Stream(senderId="), this.a, ")");
|
|
}
|
|
}
|
|
|
|
public d(DefaultConstructorMarker defaultConstructorMarker) {
|
|
}
|
|
}
|
|
|
|
/* compiled from: RtcConnection.kt */
|
|
public static final class e extends o implements Function0<Unit> {
|
|
public final /* synthetic */ RtcConnection this$0;
|
|
|
|
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
|
|
public e(RtcConnection rtcConnection) {
|
|
super(0);
|
|
this.this$0 = rtcConnection;
|
|
}
|
|
|
|
/* Return type fixed from 'java.lang.Object' to match base method */
|
|
@Override // kotlin.jvm.functions.Function0
|
|
/* renamed from: invoke */
|
|
public Unit mo1invoke() {
|
|
this.this$0.f("Force Close");
|
|
return Unit.a;
|
|
}
|
|
}
|
|
|
|
public RtcConnection(Long l, long j2, String str, boolean z2, String str2, long j3, MediaEngine mediaEngine, Logger logger, Clock clock, d dVar, NetworkMonitor networkMonitor, Map map, Map map2, String str3, boolean z3, String str4, String str5, int i2) {
|
|
Subscription subscription;
|
|
MediaSinkWantsManager mediaSinkWantsManager;
|
|
d dVar2 = (i2 & 512) != 0 ? d.a.a : dVar;
|
|
Map linkedHashMap = (i2 & 2048) != 0 ? new LinkedHashMap() : map;
|
|
LinkedHashMap linkedHashMap2 = (i2 & 4096) != 0 ? new LinkedHashMap() : null;
|
|
String str6 = (i2 & 8192) != 0 ? null : str3;
|
|
boolean z4 = (i2 & 16384) != 0 ? false : z3;
|
|
String str7 = (i2 & 65536) != 0 ? null : str5;
|
|
m.checkNotNullParameter(str, "sessionId");
|
|
m.checkNotNullParameter(str2, "rtcServerId");
|
|
m.checkNotNullParameter(mediaEngine, "mediaEngine");
|
|
m.checkNotNullParameter(logger, "logger");
|
|
m.checkNotNullParameter(clock, "clock");
|
|
m.checkNotNullParameter(dVar2, "rtcConnectionType");
|
|
m.checkNotNullParameter(networkMonitor, "networkMonitor");
|
|
m.checkNotNullParameter(linkedHashMap, "mutedUsers");
|
|
m.checkNotNullParameter(linkedHashMap2, "userVolumes");
|
|
m.checkNotNullParameter(str4, "loggingTagPrefix");
|
|
this.N = l;
|
|
this.O = j2;
|
|
this.P = str;
|
|
this.Q = z2;
|
|
this.R = str2;
|
|
this.S = j3;
|
|
this.T = mediaEngine;
|
|
this.U = logger;
|
|
this.V = clock;
|
|
this.W = dVar2;
|
|
this.X = linkedHashMap;
|
|
this.Y = linkedHashMap2;
|
|
this.Z = str6;
|
|
this.f2192a0 = z4;
|
|
this.f2193b0 = str4;
|
|
this.f2194c0 = str7;
|
|
StringBuilder V = c.d.b.a.a.V(str4, "->RtcConnection ");
|
|
int i3 = i + 1;
|
|
i = i3;
|
|
V.append(i3);
|
|
this.k = V.toString();
|
|
String uuid = UUID.randomUUID().toString();
|
|
m.checkNotNullExpressionValue(uuid, "UUID.randomUUID().toString()");
|
|
this.l = uuid;
|
|
CopyOnWriteArrayList<c> copyOnWriteArrayList = new CopyOnWriteArrayList<>();
|
|
this.m = copyOnWriteArrayList;
|
|
this.p = new Backoff(1000, 10000, 0, false, null, 28, null);
|
|
StateChange stateChange = new StateChange(new State.d(false), null);
|
|
this.r = stateChange;
|
|
this.f2195s = BehaviorSubject.l0(stateChange);
|
|
this.u = new ArrayList();
|
|
c.a.q.o0.e eVar = new c.a.q.o0.e(logger, clock);
|
|
eVar.f.add(new x(this));
|
|
this.A = eVar;
|
|
if (z4) {
|
|
subscription = null;
|
|
mediaSinkWantsManager = new MediaSinkWantsManager(j3, mediaEngine.c(), new c.a.q.e(null, 1), logger, this);
|
|
} else {
|
|
mediaSinkWantsManager = null;
|
|
subscription = null;
|
|
}
|
|
this.G = mediaSinkWantsManager;
|
|
if (z4) {
|
|
m.checkNotNull(mediaSinkWantsManager);
|
|
Observable<Map<String, EncodeQuality>> q = mediaSinkWantsManager.f.q();
|
|
m.checkNotNullExpressionValue(q, "mediaSinkWantsSubject.distinctUntilChanged()");
|
|
subscription = Observable.j(q, this.f2195s, z.i).V(new g0(new a0(this)));
|
|
}
|
|
this.H = subscription;
|
|
r("Created RtcConnection. GuildID: " + l + " ChannelID: " + j2);
|
|
networkMonitor.observeIsConnected().S(1).W(new p(this), new q(this));
|
|
copyOnWriteArrayList.add(new r(this));
|
|
this.L = new h0(this);
|
|
this.M = new b0(this);
|
|
}
|
|
|
|
public static void j(RtcConnection rtcConnection, boolean z2, String str, Throwable th, boolean z3, int i2) {
|
|
if ((i2 & 4) != 0) {
|
|
th = null;
|
|
}
|
|
if ((i2 & 8) != 0) {
|
|
z3 = true;
|
|
}
|
|
if (z3) {
|
|
o(rtcConnection, str, th, null, 4);
|
|
} else {
|
|
rtcConnection.U.i(rtcConnection.k, str, th);
|
|
}
|
|
c.a.q.o0.d dVar = rtcConnection.n;
|
|
if (dVar != null) {
|
|
dVar.a();
|
|
}
|
|
rtcConnection.n = null;
|
|
MediaEngineConnection mediaEngineConnection = rtcConnection.w;
|
|
if (mediaEngineConnection != null) {
|
|
mediaEngineConnection.destroy();
|
|
}
|
|
rtcConnection.w = null;
|
|
rtcConnection.o = false;
|
|
rtcConnection.p.cancel();
|
|
rtcConnection.u(new State.d(z2));
|
|
if (z2) {
|
|
rtcConnection.q();
|
|
return;
|
|
}
|
|
for (c cVar : rtcConnection.m) {
|
|
cVar.onFatalClose();
|
|
}
|
|
rtcConnection.f(str);
|
|
}
|
|
|
|
public static void o(RtcConnection rtcConnection, String str, Throwable th, Map map, int i2) {
|
|
if ((i2 & 2) != 0) {
|
|
th = null;
|
|
}
|
|
int i3 = i2 & 4;
|
|
rtcConnection.U.e(rtcConnection.k, str, th, null);
|
|
}
|
|
|
|
@Override // com.discord.rtcconnection.MediaSinkWantsManager.a
|
|
public void a(long j2, long j3, long j4, VideoMetadata videoMetadata) {
|
|
d(j2, j3, j4, videoMetadata);
|
|
}
|
|
|
|
public final Map<String, Object> b(Map<String, Object> map) {
|
|
String str = this.f2196x;
|
|
if (str != null) {
|
|
map.put("hostname", str);
|
|
}
|
|
Integer num = this.f2197y;
|
|
if (num != null) {
|
|
map.put("port", Integer.valueOf(num.intValue()));
|
|
}
|
|
return map;
|
|
}
|
|
|
|
public final void c(c cVar) {
|
|
m.checkNotNullParameter(cVar, "listener");
|
|
this.m.add(cVar);
|
|
}
|
|
|
|
public final void d(long j2, long j3, long j4, VideoMetadata videoMetadata) {
|
|
MediaEngineConnection mediaEngineConnection = this.w;
|
|
if (mediaEngineConnection != null) {
|
|
mediaEngineConnection.s(j2, (int) j3, Integer.valueOf((int) j4), g(j2), h(j2));
|
|
}
|
|
for (c cVar : this.m) {
|
|
cVar.onUserCreated(this, j2);
|
|
}
|
|
if (videoMetadata != null) {
|
|
for (c cVar2 : this.m) {
|
|
cVar2.onVideoMetadata(videoMetadata);
|
|
}
|
|
}
|
|
}
|
|
|
|
@Override // com.discord.utilities.debug.DebugPrintable
|
|
public void debugPrint(DebugPrintBuilder debugPrintBuilder) {
|
|
m.checkNotNullParameter(debugPrintBuilder, "dp");
|
|
debugPrintBuilder.appendKeyValue(ModelAuditLogEntry.CHANGE_KEY_ID, this.l);
|
|
debugPrintBuilder.appendKeyValue("mediaSessionId", this.J);
|
|
debugPrintBuilder.appendKeyValue("parentMediaSessionId", this.Z);
|
|
debugPrintBuilder.appendKeyValue("hostname", this.f2196x);
|
|
debugPrintBuilder.appendKeyValue("channelId", Long.valueOf(this.O));
|
|
debugPrintBuilder.appendKeyValue("guildId", this.N);
|
|
debugPrintBuilder.appendKeyValue("streamKey", this.f2194c0);
|
|
debugPrintBuilder.appendKeyValue("isVideoEnabled", Boolean.valueOf(this.Q));
|
|
debugPrintBuilder.appendKeyValue("rtcServerId", this.R);
|
|
debugPrintBuilder.appendKeyValue("userId", Long.valueOf(this.S));
|
|
debugPrintBuilder.appendKeyValue("rtcConnectionType", this.W);
|
|
debugPrintBuilder.appendKeyValue("enableMediaSinkWants", Boolean.valueOf(this.f2192a0));
|
|
debugPrintBuilder.appendKeyValue("socket", (DebugPrintable) this.v);
|
|
debugPrintBuilder.appendKeyValue("sentVideo", Boolean.valueOf(this.o));
|
|
}
|
|
|
|
public final void e() {
|
|
s(new e(this));
|
|
}
|
|
|
|
public final void f(String str) {
|
|
this.p.cancel();
|
|
c.a.q.n0.a aVar = this.v;
|
|
if (aVar != null) {
|
|
aVar.p.clear();
|
|
aVar.c();
|
|
}
|
|
this.v = null;
|
|
c.a.q.o0.e eVar = this.A;
|
|
synchronized (eVar) {
|
|
eVar.o.stop();
|
|
eVar.h = Long.valueOf(eVar.q.currentTimeMillis());
|
|
}
|
|
if (!(this.r.a instanceof State.d)) {
|
|
n(false, str);
|
|
d dVar = this.W;
|
|
if (dVar instanceof d.b) {
|
|
Map<String, Object> c2 = this.A.c(String.valueOf(((d.b) dVar).a));
|
|
if (c2 != null) {
|
|
l(((d.b) this.W).a, c2);
|
|
}
|
|
if (this.o) {
|
|
m(this.S, this.A.d());
|
|
}
|
|
}
|
|
}
|
|
MediaSinkWantsManager mediaSinkWantsManager = this.G;
|
|
if (mediaSinkWantsManager != null) {
|
|
mediaSinkWantsManager.b(new g(mediaSinkWantsManager));
|
|
}
|
|
Subscription subscription = this.H;
|
|
if (subscription != null) {
|
|
subscription.unsubscribe();
|
|
}
|
|
Subscription subscription2 = this.E;
|
|
if (subscription2 != null) {
|
|
subscription2.unsubscribe();
|
|
}
|
|
this.E = null;
|
|
MediaEngineConnection mediaEngineConnection = this.w;
|
|
if (mediaEngineConnection != null) {
|
|
mediaEngineConnection.destroy();
|
|
}
|
|
this.w = null;
|
|
u(new State.d(false));
|
|
r("Destroy internal RTC connection: " + str);
|
|
this.m.clear();
|
|
this.o = false;
|
|
this.t = true;
|
|
}
|
|
|
|
public final boolean g(long j2) {
|
|
Boolean bool = this.X.get(Long.valueOf(j2));
|
|
if (bool != null) {
|
|
return bool.booleanValue();
|
|
}
|
|
return false;
|
|
}
|
|
|
|
public final float h(long j2) {
|
|
Float f = this.Y.get(Long.valueOf(j2));
|
|
if (f != null) {
|
|
return f.floatValue();
|
|
}
|
|
return 1.0f;
|
|
}
|
|
|
|
public final Metadata i() {
|
|
return new Metadata(this.l, this.J, Long.valueOf(this.O), this.N, this.f2194c0);
|
|
}
|
|
|
|
public final void k(long j2, Map<String, ? extends Object> map) {
|
|
HashMap hashMap = new HashMap();
|
|
Long l = this.N;
|
|
if (l != null) {
|
|
l.longValue();
|
|
hashMap.put(ModelAuditLogEntry.CHANGE_KEY_GUILD_ID, this.N);
|
|
}
|
|
hashMap.put(ModelAuditLogEntry.CHANGE_KEY_CHANNEL_ID, Long.valueOf(this.O));
|
|
hashMap.put("sender_user_id", Long.valueOf(j2));
|
|
hashMap.putAll(map);
|
|
p(AnalyticsEvent.VIDEO_STREAM_ENDED, hashMap);
|
|
}
|
|
|
|
public final void l(long j2, Map<String, ? extends Object> map) {
|
|
if (map != null) {
|
|
k(j2, d0.t.h0.plus(map, d0.t.g0.mapOf(d0.o.to("participant_type", "receiver"))));
|
|
}
|
|
}
|
|
|
|
public final void m(long j2, Map<String, ? extends Object> map) {
|
|
if (map != null) {
|
|
k(j2, d0.t.h0.plus(map, d0.t.g0.mapOf(d0.o.to("participant_type", this.W instanceof d.b ? "streamer" : NotificationCompat.MessagingStyle.Message.KEY_SENDER))));
|
|
}
|
|
}
|
|
|
|
public final void n(boolean z2, String str) {
|
|
List<String> list;
|
|
String str2;
|
|
Stats stats;
|
|
VoiceQuality voiceQuality;
|
|
Map<String, Object> mutableMapOf = d0.t.h0.mutableMapOf(d0.o.to("ping_bad_count", Integer.valueOf(this.f2198z)), d0.o.to("connect_count", Integer.valueOf(this.D)), d0.o.to("channel_count", 1));
|
|
b(mutableMapOf);
|
|
mutableMapOf.put("reconnect", Boolean.valueOf(z2));
|
|
if (str != null) {
|
|
mutableMapOf.put(ModelAuditLogEntry.CHANGE_KEY_REASON, str);
|
|
}
|
|
double averageOfLong = u.averageOfLong(this.u);
|
|
if (!Double.isNaN(averageOfLong)) {
|
|
mutableMapOf.put("ping_average", Integer.valueOf(d0.a0.a.roundToInt(averageOfLong)));
|
|
}
|
|
String str3 = this.J;
|
|
if (str3 != null) {
|
|
mutableMapOf.put("media_session_id", str3);
|
|
}
|
|
c.a.q.o0.d dVar = this.n;
|
|
if (!(dVar == null || (stats = (Stats) u.lastOrNull(dVar.a)) == null)) {
|
|
OutboundRtpAudio outboundRtpAudio = stats.getOutboundRtpAudio();
|
|
if (outboundRtpAudio != null) {
|
|
mutableMapOf.put("packets_sent", Long.valueOf(outboundRtpAudio.getPacketsSent()));
|
|
mutableMapOf.put("packets_sent_lost", Integer.valueOf(outboundRtpAudio.getPacketsLost()));
|
|
}
|
|
long j2 = 0;
|
|
long j3 = 0;
|
|
for (InboundRtpAudio inboundRtpAudio : stats.getInboundRtpAudio().values()) {
|
|
j3 += inboundRtpAudio.getPacketsLost();
|
|
j2 += inboundRtpAudio.getPacketsReceived();
|
|
}
|
|
mutableMapOf.put("packets_received", Long.valueOf(j2));
|
|
mutableMapOf.put("packets_received_lost", Long.valueOf(j3));
|
|
c.a.q.o0.d dVar2 = this.n;
|
|
if (!(dVar2 == null || (voiceQuality = dVar2.f) == null)) {
|
|
voiceQuality.getDurationStats(mutableMapOf);
|
|
voiceQuality.getMosStats(mutableMapOf);
|
|
voiceQuality.getPacketStats(mutableMapOf);
|
|
voiceQuality.getBufferStats(mutableMapOf);
|
|
voiceQuality.getFrameOpStats(mutableMapOf);
|
|
}
|
|
}
|
|
Long l = this.C;
|
|
MediaEngineConnection.TransportInfo.Protocol protocol = null;
|
|
Long valueOf = l != null ? Long.valueOf(this.V.currentTimeMillis() - l.longValue()) : null;
|
|
if (valueOf != null) {
|
|
mutableMapOf.put("duration", Long.valueOf(valueOf.longValue()));
|
|
}
|
|
MediaEngineConnection.TransportInfo transportInfo = this.q;
|
|
if (transportInfo != null) {
|
|
protocol = transportInfo.f2212c;
|
|
}
|
|
if (protocol != null) {
|
|
int ordinal = protocol.ordinal();
|
|
if (ordinal == 0) {
|
|
str2 = "udp";
|
|
} else if (ordinal == 1) {
|
|
str2 = "tcp";
|
|
} else {
|
|
throw new NoWhenBranchMatchedException();
|
|
}
|
|
mutableMapOf.put("protocol", str2);
|
|
}
|
|
p(AnalyticsEvent.VOICE_DISCONNECT, mutableMapOf);
|
|
if (this.W instanceof d.a) {
|
|
c.a.q.o0.e eVar = this.A;
|
|
synchronized (eVar) {
|
|
list = u.toList(eVar.m.keySet());
|
|
}
|
|
for (String str4 : list) {
|
|
Long longOrNull = s.toLongOrNull(str4);
|
|
if (longOrNull != null) {
|
|
l(longOrNull.longValue(), this.A.c(str4));
|
|
}
|
|
}
|
|
if (this.o) {
|
|
m(this.S, this.A.d());
|
|
}
|
|
}
|
|
}
|
|
|
|
public final void p(AnalyticsEvent analyticsEvent, Map<String, Object> map) {
|
|
String str;
|
|
map.put("rtc_connection_id", this.l);
|
|
d dVar = this.W;
|
|
if (m.areEqual(dVar, d.a.a)) {
|
|
str = "default";
|
|
} else if (dVar instanceof d.b) {
|
|
str = "stream";
|
|
} else {
|
|
throw new NoWhenBranchMatchedException();
|
|
}
|
|
map.put("context", str);
|
|
String str2 = this.J;
|
|
if (str2 != null) {
|
|
map.put("media_session_id", str2);
|
|
}
|
|
String str3 = this.Z;
|
|
if (str3 != null) {
|
|
map.put("parent_media_session_id", str3);
|
|
}
|
|
for (c cVar : this.m) {
|
|
cVar.onAnalyticsEvent(analyticsEvent, map);
|
|
}
|
|
}
|
|
|
|
public final void q() {
|
|
this.U.recordBreadcrumb("reconnect", this.k);
|
|
if (this.I) {
|
|
this.B = Long.valueOf(this.V.currentTimeMillis());
|
|
}
|
|
this.D++;
|
|
c.a.q.n0.a aVar = this.v;
|
|
if (aVar != null) {
|
|
aVar.c();
|
|
aVar.d();
|
|
}
|
|
}
|
|
|
|
public final void r(String str) {
|
|
this.U.recordBreadcrumb(str, this.k);
|
|
}
|
|
|
|
/* JADX WARN: Multi-variable type inference failed */
|
|
/* JADX WARNING: Unknown variable types count: 1 */
|
|
@AnyThread
|
|
public final void s(Function0<Unit> function0) {
|
|
c.a.q.c c2 = this.T.c();
|
|
if (function0 != null) {
|
|
function0 = new f0(function0);
|
|
}
|
|
c2.k.execute((Runnable) function0);
|
|
}
|
|
|
|
public final void t(Intent intent, ThumbnailEmitter thumbnailEmitter) {
|
|
if (this.W instanceof d.b) {
|
|
r("Setting screenshare " + intent + ' ' + this.w);
|
|
MediaEngineConnection mediaEngineConnection = this.w;
|
|
if (mediaEngineConnection == null) {
|
|
Log.e("RtcConnection", "MediaEngine not connected for setScreenshare.");
|
|
} else if (intent != null) {
|
|
mediaEngineConnection.a(intent, thumbnailEmitter);
|
|
} else {
|
|
mediaEngineConnection.h();
|
|
}
|
|
}
|
|
}
|
|
|
|
public final void u(State state) {
|
|
if (!m.areEqual(this.r.a, state)) {
|
|
StateChange stateChange = new StateChange(state, i());
|
|
this.r = stateChange;
|
|
for (c cVar : this.m) {
|
|
cVar.onStateChange(stateChange);
|
|
}
|
|
}
|
|
}
|
|
|
|
public final void v(long j2, float f) {
|
|
this.Y.put(Long.valueOf(j2), Float.valueOf(f));
|
|
MediaEngineConnection mediaEngineConnection = this.w;
|
|
if (mediaEngineConnection != null) {
|
|
mediaEngineConnection.e(j2, f);
|
|
}
|
|
}
|
|
|
|
public final void w(Long l) {
|
|
MediaSinkWantsManager mediaSinkWantsManager = this.G;
|
|
if (mediaSinkWantsManager != null) {
|
|
mediaSinkWantsManager.b(new j(mediaSinkWantsManager, l));
|
|
}
|
|
}
|
|
}
|