discord-jadx/app/src/main/java/c/a/r/k0/c/e.java

840 lines
36 KiB
Java

package c.a.r.k0.c;
import android.content.Intent;
import android.media.projection.MediaProjection;
import co.discord.media_engine.AudioDecoder;
import co.discord.media_engine.AudioEncoder;
import co.discord.media_engine.Connection;
import co.discord.media_engine.EncryptionSettings;
import co.discord.media_engine.Stats;
import co.discord.media_engine.VideoDecoder;
import co.discord.media_engine.VideoEncoder;
import com.discord.rtcconnection.KrispOveruseDetector;
import com.discord.rtcconnection.mediaengine.MediaEngine;
import com.discord.rtcconnection.mediaengine.MediaEngineConnection;
import com.discord.rtcconnection.mediaengine.ThumbnailEmitter;
import com.discord.utilities.logging.Logger;
import com.hammerandchisel.libdiscord.Discord;
import d0.t.g0;
import d0.t.h0;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.Future;
import kotlin.Unit;
import kotlin.jvm.functions.Function0;
import kotlin.jvm.functions.Function1;
/* compiled from: MediaEngineConnectionLegacy.kt */
public final class e implements MediaEngineConnection {
public static final String a = "e";
public final CopyOnWriteArrayList<MediaEngineConnection.c> b;
/* renamed from: c reason: collision with root package name */
public MediaEngineConnection.ConnectionState f211c;
public boolean d;
public final Map<Long, Integer> e;
public final Map<Long, Integer> f = new LinkedHashMap();
public final Set<Long> g = new LinkedHashSet();
public final Set<Long> h = new LinkedHashSet();
public final Set<Long> i = new LinkedHashSet();
public final List<c.a.r.k0.a> j = new ArrayList();
public final Connection k;
public final c.a.r.c l;
public final Logger m;
public final r n;
public final Discord o;
public final List<c.a.r.k0.a> p;
public final MediaEngineConnection.Type q;
public final long r;
/* compiled from: MediaEngineConnectionLegacy.kt */
public static final class a extends d0.z.d.o implements Function1<Connection, Unit> {
public final /* synthetic */ int $audioSsrc;
public final /* synthetic */ boolean $isMuted;
public final /* synthetic */ int $resolvedVideoSsrc;
public final /* synthetic */ long $userId;
public final /* synthetic */ float $volume;
public final /* synthetic */ e this$0;
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
public a(e eVar, long j, int i, int i2, boolean z2, float f) {
super(1);
this.this$0 = eVar;
this.$userId = j;
this.$audioSsrc = i;
this.$resolvedVideoSsrc = i2;
this.$isMuted = z2;
this.$volume = f;
}
/* 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(Connection connection) {
Connection connection2 = connection;
d0.z.d.m.checkNotNullParameter(connection2, "$receiver");
long j = this.$userId;
int i = this.$audioSsrc;
int i2 = this.$resolvedVideoSsrc;
e eVar = this.this$0;
String str = e.a;
Objects.requireNonNull(eVar);
connection2.connectUser(j, i, i2, i2 > 0 ? i2 + 1 : 0, this.$isMuted, this.$volume);
return Unit.a;
}
}
/* compiled from: MediaEngineConnectionLegacy.kt */
public static final /* synthetic */ class b extends d0.z.d.k implements Function1<Connection, Unit> {
public static final b i = new b();
public b() {
super(1, Connection.class, "dispose", "dispose()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(Connection connection) {
Connection connection2 = connection;
d0.z.d.m.checkNotNullParameter(connection2, "p1");
connection2.dispose();
return Unit.a;
}
}
/* compiled from: MediaEngineConnectionLegacy.kt */
public static final class c extends d0.z.d.o implements Function1<MediaEngineConnection.c, Unit> {
public final /* synthetic */ e this$0;
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
public c(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(MediaEngineConnection.c cVar) {
MediaEngineConnection.c cVar2 = cVar;
d0.z.d.m.checkNotNullParameter(cVar2, "it");
cVar2.onConnectionStateChange(this.this$0, MediaEngineConnection.ConnectionState.DISCONNECTED);
cVar2.onDestroy(this.this$0);
return Unit.a;
}
}
/* compiled from: MediaEngineConnectionLegacy.kt */
public static final class d extends d0.z.d.o implements Function1<Connection, Unit> {
public final /* synthetic */ boolean $disabled;
public final /* synthetic */ long $userId;
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
public d(long j, boolean z2) {
super(1);
this.$userId = j;
this.$disabled = z2;
}
/* 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(Connection connection) {
Connection connection2 = connection;
d0.z.d.m.checkNotNullParameter(connection2, "$receiver");
connection2.disableVideo(this.$userId, this.$disabled);
return Unit.a;
}
}
/* compiled from: MediaEngineConnectionLegacy.kt */
/* renamed from: c.a.r.k0.c.e$e reason: collision with other inner class name */
public static final class C0036e extends d0.z.d.o implements Function1<MediaEngineConnection.c, Unit> {
public final /* synthetic */ KrispOveruseDetector.Status $status;
public final /* synthetic */ e this$0;
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
public C0036e(e eVar, KrispOveruseDetector.Status status) {
super(1);
this.this$0 = eVar;
this.$status = status;
}
/* 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(MediaEngineConnection.c cVar) {
MediaEngineConnection.c cVar2 = cVar;
d0.z.d.m.checkNotNullParameter(cVar2, "it");
cVar2.onKrispStatus(this.this$0, this.$status);
return Unit.a;
}
}
/* compiled from: MediaEngineConnectionLegacy.kt */
public static final class f extends d0.z.d.o implements Function1<Connection, Unit> {
public final /* synthetic */ Function1 $onStats;
public final /* synthetic */ e this$0;
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
public f(e eVar, Function1 function1) {
super(1);
this.this$0 = eVar;
this.$onStats = function1;
}
/* 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(Connection connection) {
Connection connection2 = connection;
d0.z.d.m.checkNotNullParameter(connection2, "$receiver");
connection2.getStats(new f(this));
return Unit.a;
}
}
/* compiled from: MediaEngineConnectionLegacy.kt */
public static final class g extends d0.z.d.o implements Function1<MediaEngineConnection.c, Unit> {
public final /* synthetic */ MediaEngineConnection.FailedConnectionException $e;
public final /* synthetic */ e this$0;
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
public g(e eVar, MediaEngineConnection.FailedConnectionException failedConnectionException) {
super(1);
this.this$0 = eVar;
this.$e = failedConnectionException;
}
/* 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(MediaEngineConnection.c cVar) {
MediaEngineConnection.c cVar2 = cVar;
d0.z.d.m.checkNotNullParameter(cVar2, "it");
cVar2.onError(this.this$0, this.$e);
return Unit.a;
}
}
/* compiled from: MediaEngineConnectionLegacy.kt */
public static final class h extends d0.z.d.o implements Function1<Connection, Unit> {
public final /* synthetic */ AudioDecoder $audioDecoder;
public final /* synthetic */ AudioEncoder $audioEncoder;
public final /* synthetic */ VideoDecoder $videoDecoder;
public final /* synthetic */ VideoEncoder $videoEncoder;
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
public h(AudioEncoder audioEncoder, VideoEncoder videoEncoder, AudioDecoder audioDecoder, VideoDecoder videoDecoder) {
super(1);
this.$audioEncoder = audioEncoder;
this.$videoEncoder = videoEncoder;
this.$audioDecoder = audioDecoder;
this.$videoDecoder = videoDecoder;
}
/* 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(Connection connection) {
Connection connection2 = connection;
d0.z.d.m.checkNotNullParameter(connection2, "$receiver");
connection2.setCodecs(this.$audioEncoder, this.$videoEncoder, new AudioDecoder[]{this.$audioDecoder}, new VideoDecoder[]{this.$videoDecoder});
return Unit.a;
}
}
/* compiled from: MediaEngineConnectionLegacy.kt */
public static final class i extends d0.z.d.o implements Function1<Connection, Unit> {
public final /* synthetic */ EncryptionSettings $encryptionSettings;
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
public i(EncryptionSettings encryptionSettings) {
super(1);
this.$encryptionSettings = encryptionSettings;
}
/* 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(Connection connection) {
Connection connection2 = connection;
d0.z.d.m.checkNotNullParameter(connection2, "$receiver");
connection2.setEncryptionSettings(this.$encryptionSettings);
return Unit.a;
}
}
/* compiled from: MediaEngineConnectionLegacy.kt */
public static final class j extends d0.z.d.o implements Function1<Connection, Unit> {
public final /* synthetic */ MediaEngineConnection.InputMode $inputMode;
public final /* synthetic */ MediaEngineConnection.b $inputModeOptions;
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
public j(MediaEngineConnection.b bVar, MediaEngineConnection.InputMode inputMode) {
super(1);
this.$inputModeOptions = bVar;
this.$inputMode = inputMode;
}
/* 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(Connection connection) {
Connection connection2 = connection;
d0.z.d.m.checkNotNullParameter(connection2, "$receiver");
connection2.setVADLeadingFramesToBuffer(this.$inputModeOptions.b);
connection2.setVADTrailingFramesToSend(this.$inputModeOptions.f2098c);
connection2.setVADTriggerThreshold((float) this.$inputModeOptions.a);
connection2.setVADAutoThreshold(this.$inputModeOptions.d ? 3 : -1);
connection2.setVADUseKrisp(this.$inputModeOptions.e);
connection2.setAudioInputMode(this.$inputMode.getNumeral());
connection2.enableForwardErrorCorrection(true);
connection2.setExpectedPacketLossRate(0.3f);
return Unit.a;
}
}
/* compiled from: MediaEngineConnectionLegacy.kt */
public static final class k extends d0.z.d.o implements Function1<Connection, Unit> {
public final /* synthetic */ boolean $mute;
public final /* synthetic */ long $userId;
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
public k(long j, boolean z2) {
super(1);
this.$userId = j;
this.$mute = z2;
}
/* 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(Connection connection) {
Connection connection2 = connection;
d0.z.d.m.checkNotNullParameter(connection2, "$receiver");
connection2.muteUser(this.$userId, this.$mute);
return Unit.a;
}
}
/* compiled from: MediaEngineConnectionLegacy.kt */
public static final class l extends d0.z.d.o implements Function1<MediaEngineConnection.c, Unit> {
public final /* synthetic */ boolean $mute;
public final /* synthetic */ long $userId;
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
public l(long j, boolean z2) {
super(1);
this.$userId = j;
this.$mute = z2;
}
/* 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(MediaEngineConnection.c cVar) {
MediaEngineConnection.c cVar2 = cVar;
d0.z.d.m.checkNotNullParameter(cVar2, "it");
cVar2.onLocalMute(this.$userId, this.$mute);
return Unit.a;
}
}
/* compiled from: MediaEngineConnectionLegacy.kt */
public static final class m extends d0.z.d.o implements Function1<MediaEngineConnection.c, Unit> {
public final /* synthetic */ boolean $offScreen;
public final /* synthetic */ long $userId;
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
public m(long j, boolean z2) {
super(1);
this.$userId = j;
this.$offScreen = z2;
}
/* 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(MediaEngineConnection.c cVar) {
MediaEngineConnection.c cVar2 = cVar;
d0.z.d.m.checkNotNullParameter(cVar2, "it");
cVar2.onLocalVideoOffScreen(this.$userId, this.$offScreen);
return Unit.a;
}
}
/* compiled from: MediaEngineConnectionLegacy.kt */
public static final class n extends d0.z.d.o implements Function1<Connection, Unit> {
public final /* synthetic */ long $userId;
public final /* synthetic */ float $volume;
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
public n(long j, float f) {
super(1);
this.$userId = j;
this.$volume = f;
}
/* 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(Connection connection) {
Connection connection2 = connection;
d0.z.d.m.checkNotNullParameter(connection2, "$receiver");
connection2.setUserPlayoutVolume(this.$userId, this.$volume / 100.0f);
return Unit.a;
}
}
/* compiled from: MediaEngineConnectionLegacy.kt */
public static final class o extends d0.z.d.o implements Function1<Connection, Unit> {
public final /* synthetic */ boolean $active;
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
public o(boolean z2) {
super(1);
this.$active = z2;
}
/* 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(Connection connection) {
Connection connection2 = connection;
d0.z.d.m.checkNotNullParameter(connection2, "$receiver");
connection2.setPTTActive(this.$active);
return Unit.a;
}
}
/* compiled from: MediaEngineConnectionLegacy.kt */
public static final class p extends d0.z.d.o implements Function1<Connection, Unit> {
public final /* synthetic */ int $framerate;
public final /* synthetic */ MediaEngineConnection.a $quality;
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
public p(MediaEngineConnection.a aVar, int i) {
super(1);
this.$quality = aVar;
this.$framerate = i;
}
/* 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(Connection connection) {
Connection connection2 = connection;
d0.z.d.m.checkNotNullParameter(connection2, "$receiver");
MediaEngineConnection.a aVar = this.$quality;
connection2.setEncodingQuality(aVar.a, aVar.b, aVar.f2097c, aVar.d, this.$framerate);
return Unit.a;
}
}
/* compiled from: MediaEngineConnectionLegacy.kt */
public static final class q extends d0.z.d.o implements Function1<Connection, Unit> {
public final /* synthetic */ boolean $selfDeaf;
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
public q(boolean z2) {
super(1);
this.$selfDeaf = z2;
}
/* 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(Connection connection) {
Connection connection2 = connection;
d0.z.d.m.checkNotNullParameter(connection2, "$receiver");
connection2.deafenLocalUser(this.$selfDeaf);
return Unit.a;
}
}
/* compiled from: MediaEngineConnectionLegacy.kt */
public static final class r extends d0.z.d.o implements Function1<Connection, Unit> {
public final /* synthetic */ boolean $selfMute;
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
public r(boolean z2) {
super(1);
this.$selfMute = z2;
}
/* 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(Connection connection) {
Connection connection2 = connection;
d0.z.d.m.checkNotNullParameter(connection2, "$receiver");
connection2.muteLocalUser(this.$selfMute);
return Unit.a;
}
}
/* compiled from: MediaEngineConnectionLegacy.kt */
public static final class s extends d0.z.d.o implements Function1<Connection, Unit> {
public final /* synthetic */ boolean $isVideoBroadcast;
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
public s(boolean z2) {
super(1);
this.$isVideoBroadcast = z2;
}
/* 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(Connection connection) {
Connection connection2 = connection;
d0.z.d.m.checkNotNullParameter(connection2, "$receiver");
connection2.setVideoBroadcast(this.$isVideoBroadcast);
return Unit.a;
}
}
/* compiled from: MediaEngineConnectionLegacy.kt */
public static final class t extends d0.z.d.o implements Function1<Connection, Unit> {
public final /* synthetic */ c.a.r.k0.b $screenCapturer;
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
public t(c.a.r.k0.b bVar) {
super(1);
this.$screenCapturer = bVar;
}
/* 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(Connection connection) {
Connection connection2 = connection;
d0.z.d.m.checkNotNullParameter(connection2, "$receiver");
c.a.r.k0.b bVar = this.$screenCapturer;
connection2.startScreenshareBroadcast(bVar, bVar.n.getNativeInstance());
return Unit.a;
}
}
/* compiled from: MediaEngineConnectionLegacy.kt */
public static final class u extends MediaProjection.Callback {
@Override // android.media.projection.MediaProjection.Callback
public void onStop() {
}
}
/* compiled from: MediaEngineConnectionLegacy.kt */
public static final class v extends d0.z.d.o implements Function1<Connection, Unit> {
public static final v i = new v();
public v() {
super(1);
}
/* 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(Connection connection) {
Connection connection2 = connection;
d0.z.d.m.checkNotNullParameter(connection2, "$receiver");
connection2.stopScreenshareBroadcast();
return Unit.a;
}
}
public e(c.a.r.c cVar, Logger logger, r rVar, Discord discord, List<c.a.r.k0.a> list, MediaEngineConnection.Type type, long j2, MediaEngine.a aVar, List<? extends MediaEngineConnection.c> list2) {
d0.z.d.m.checkNotNullParameter(cVar, "mediaEngineThreadExecutor");
d0.z.d.m.checkNotNullParameter(logger, "logger");
d0.z.d.m.checkNotNullParameter(rVar, "noiseCancellationConfig");
d0.z.d.m.checkNotNullParameter(discord, "voiceEngineLegacy");
d0.z.d.m.checkNotNullParameter(list, "supportedVideoCodecs");
d0.z.d.m.checkNotNullParameter(type, "type");
d0.z.d.m.checkNotNullParameter(aVar, "connectionOptions");
d0.z.d.m.checkNotNullParameter(list2, "listeners");
this.l = cVar;
this.m = logger;
this.n = rVar;
this.o = discord;
this.p = list;
this.q = type;
this.r = j2;
MediaEngineConnection.ConnectionState connectionState = MediaEngineConnection.ConnectionState.CONNECTING;
this.f211c = connectionState;
this.e = h0.mutableMapOf(d0.o.to(Long.valueOf(j2), Integer.valueOf(aVar.a)));
Connection connectToServer = discord.connectToServer(aVar.a, j2, aVar.b, aVar.f2095c, type == MediaEngineConnection.Type.STREAM, new d(this));
d0.z.d.m.checkNotNullExpressionValue(connectToServer, "voiceEngineLegacy.connec…fo, errorMessage) }\n }");
connectToServer.setOnVideoCallback(new b(this));
connectToServer.setUserSpeakingStatusChangedCallback(new c(this));
this.k = connectToServer;
this.b = new CopyOnWriteArrayList<>(list2);
this.f211c = connectionState;
y(new a(this, connectionState));
}
public static final Future x(e eVar, Function0 function0) {
c.a.r.c cVar = eVar.l;
return cVar.k.submit(new i(function0));
}
@Override // com.discord.rtcconnection.mediaengine.MediaEngineConnection
public synchronized void a(Intent intent, ThumbnailEmitter thumbnailEmitter) {
d0.z.d.m.checkNotNullParameter(intent, "permission");
z(new t(new c.a.r.k0.b(intent, new u(), this.m, thumbnailEmitter)));
}
@Override // com.discord.rtcconnection.mediaengine.MediaEngineConnection
public boolean b() {
return this.n.a;
}
@Override // com.discord.rtcconnection.mediaengine.MediaEngineConnection
public void c(boolean z2) {
this.d = z2;
z(new r(z2));
}
@Override // com.discord.rtcconnection.mediaengine.MediaEngineConnection
public void d(long j2, boolean z2) {
if (z2) {
this.i.add(Long.valueOf(j2));
} else {
this.i.remove(Long.valueOf(j2));
}
y(new m(j2, z2));
}
@Override // com.discord.rtcconnection.mediaengine.MediaEngineConnection
public void destroy() {
Logger logger = this.m;
String str = a;
d0.z.d.m.checkNotNullExpressionValue(str, "TAG");
Logger.i$default(logger, str, "destroy(). Disconnecting from server", null, 4, null);
z(b.i);
y(new c(this));
}
@Override // com.discord.rtcconnection.mediaengine.MediaEngineConnection
public void e(long j2, float f2) {
z(new n(j2, f2));
}
@Override // com.discord.rtcconnection.mediaengine.MediaEngineConnection
public void f(KrispOveruseDetector.Status status) {
d0.z.d.m.checkNotNullParameter(status, "status");
y(new C0036e(this, status));
}
@Override // com.discord.rtcconnection.mediaengine.MediaEngineConnection
public boolean g(long j2) {
return this.h.contains(Long.valueOf(j2));
}
@Override // com.discord.rtcconnection.mediaengine.MediaEngineConnection
public MediaEngineConnection.Type getType() {
return this.q;
}
@Override // com.discord.rtcconnection.mediaengine.MediaEngineConnection
public synchronized void h() {
z(v.i);
}
@Override // com.discord.rtcconnection.mediaengine.MediaEngineConnection
public void i(long j2, boolean z2) {
z(new d(j2, z2));
}
@Override // com.discord.rtcconnection.mediaengine.MediaEngineConnection
public void j(boolean z2) {
z(new s(z2));
}
@Override // com.discord.rtcconnection.mediaengine.MediaEngineConnection
public void k(MediaEngineConnection.InputMode inputMode, MediaEngineConnection.b bVar) {
d0.z.d.m.checkNotNullParameter(inputMode, "inputMode");
d0.z.d.m.checkNotNullParameter(bVar, "inputModeOptions");
r rVar = this.n;
if (inputMode == MediaEngineConnection.InputMode.VOICE_ACTIVITY) {
boolean z2 = bVar.d;
}
Objects.requireNonNull(rVar);
z(new j(bVar, inputMode));
}
@Override // com.discord.rtcconnection.mediaengine.MediaEngineConnection
public void l(MediaEngineConnection.c cVar) {
d0.z.d.m.checkNotNullParameter(cVar, "listener");
this.b.add(cVar);
cVar.onConnectionStateChange(this, this.f211c);
}
@Override // com.discord.rtcconnection.mediaengine.MediaEngineConnection
public void m(MediaEngineConnection.a aVar) {
d0.z.d.m.checkNotNullParameter(aVar, "quality");
z(new p(aVar, this.d ? aVar.e : aVar.f));
}
@Override // com.discord.rtcconnection.mediaengine.MediaEngineConnection
public void n(Function1<? super Stats, Unit> function1) {
d0.z.d.m.checkNotNullParameter(function1, "onStats");
z(new f(this, function1));
}
@Override // com.discord.rtcconnection.mediaengine.MediaEngineConnection
public void o(MediaEngineConnection.c cVar) {
d0.z.d.m.checkNotNullParameter(cVar, "listener");
this.b.remove(cVar);
}
@Override // com.discord.rtcconnection.mediaengine.MediaEngineConnection
public boolean p(long j2) {
return this.i.contains(Long.valueOf(j2));
}
@Override // com.discord.rtcconnection.mediaengine.MediaEngineConnection
public void q(boolean z2) {
z(new o(z2));
}
@Override // com.discord.rtcconnection.mediaengine.MediaEngineConnection
public void r(String str, String str2) {
Object obj;
Object obj2;
d0.z.d.m.checkNotNullParameter(str, "audioCodec");
d0.z.d.m.checkNotNullParameter(str2, "videoCodec");
Iterator<T> it = this.j.iterator();
while (true) {
obj = null;
if (!it.hasNext()) {
obj2 = null;
break;
}
obj2 = it.next();
if (d0.z.d.m.areEqual(((c.a.r.k0.a) obj2).a, str)) {
break;
}
}
c.a.r.k0.a aVar = (c.a.r.k0.a) obj2;
Iterator<T> it2 = this.j.iterator();
while (true) {
if (!it2.hasNext()) {
break;
}
Object next = it2.next();
if (d0.z.d.m.areEqual(((c.a.r.k0.a) next).a, str2)) {
obj = next;
break;
}
}
c.a.r.k0.a aVar2 = (c.a.r.k0.a) obj;
if (aVar == null) {
throw new MediaEngineConnection.FailedConnectionException("Missing audio codec: " + str + '.', MediaEngineConnection.FailedConnectionException.FailureType.CODEC_NEGOTIATION_FAILED);
} else if (aVar2 != null) {
try {
Integer num = aVar2.e;
if (num != null) {
num.intValue();
AudioEncoder audioEncoder = new AudioEncoder(aVar.d, str, 48000, 960, 1, 64000);
AudioDecoder audioDecoder = new AudioDecoder(aVar.d, str, 48000, 2, g0.mapOf(d0.o.to("stereo", "1")));
Map mapOf = h0.mapOf(d0.o.to("level-asymmetry-allowed", "1"), d0.o.to("packetization-mode", "1"), d0.o.to("profile-level-id", "42e01f"));
z(new h(audioEncoder, new VideoEncoder(str2, aVar2.d, aVar2.e.intValue(), mapOf), audioDecoder, new VideoDecoder(str2, aVar2.d, aVar2.e.intValue(), mapOf)));
return;
}
throw new MediaEngineConnection.FailedConnectionException("Video codec " + str2 + " rtxPayloadType was null.", MediaEngineConnection.FailedConnectionException.FailureType.CODEC_NEGOTIATION_FAILED);
} catch (MediaEngineConnection.FailedConnectionException e) {
y(new g(this, e));
}
} else {
throw new MediaEngineConnection.FailedConnectionException("Missing video codec: " + str2 + '.', MediaEngineConnection.FailedConnectionException.FailureType.CODEC_NEGOTIATION_FAILED);
}
}
@Override // com.discord.rtcconnection.mediaengine.MediaEngineConnection
public void s(long j2, int i2, Integer num, boolean z2, float f2) {
if (i2 == 0) {
Logger logger = this.m;
String str = a;
d0.z.d.m.checkNotNullExpressionValue(str, "TAG");
Logger.w$default(logger, str, "Attempting to create user " + j2 + " with 0 audio SSRC", null, 4, null);
return;
}
Integer num2 = num != null ? num : this.f.get(Long.valueOf(j2));
boolean z3 = false;
int intValue = num2 != null ? num2.intValue() : 0;
Integer num3 = this.e.get(Long.valueOf(j2));
boolean z4 = num3 == null || num3.intValue() != i2;
Integer num4 = this.f.get(Long.valueOf(j2));
if (num4 == null || num4.intValue() != intValue) {
z3 = true;
}
if (z4 || z3) {
Logger logger2 = this.m;
String str2 = a;
d0.z.d.m.checkNotNullExpressionValue(str2, "TAG");
Logger.i$default(logger2, str2, "creating user: " + j2 + " with audio SSRC: " + i2 + " and video SSRC: " + num, null, 4, null);
z(new a(this, j2, i2, intValue, z2, f2));
}
if (z2) {
this.g.add(Long.valueOf(j2));
} else {
this.g.remove(Long.valueOf(j2));
}
this.e.put(Long.valueOf(j2), Integer.valueOf(i2));
this.f.put(Long.valueOf(j2), Integer.valueOf(intValue));
}
@Override // com.discord.rtcconnection.mediaengine.MediaEngineConnection
public void t(String str, int[] iArr) {
d0.z.d.m.checkNotNullParameter(str, "mode");
d0.z.d.m.checkNotNullParameter(iArr, "secretKey");
z(new i(new EncryptionSettings(str, iArr)));
}
@Override // com.discord.rtcconnection.mediaengine.MediaEngineConnection
public boolean u(long j2) {
return this.g.contains(Long.valueOf(j2));
}
@Override // com.discord.rtcconnection.mediaengine.MediaEngineConnection
public void v(boolean z2) {
z(new q(z2));
}
@Override // com.discord.rtcconnection.mediaengine.MediaEngineConnection
public void w(long j2, boolean z2) {
z(new k(j2, z2));
if (z2) {
this.g.add(Long.valueOf(j2));
} else {
this.g.remove(Long.valueOf(j2));
}
y(new l(j2, z2));
}
public final void y(Function1<? super MediaEngineConnection.c, Unit> function1) {
for (MediaEngineConnection.c cVar : this.b) {
try {
d0.z.d.m.checkNotNullExpressionValue(cVar, "it");
function1.invoke(cVar);
} catch (Exception e) {
Logger logger = this.m;
String str = a;
d0.z.d.m.checkNotNullExpressionValue(str, "TAG");
Logger.e$default(logger, str, "Error in listener", e, null, 8, null);
}
}
}
public final synchronized void z(Function1<? super Connection, Unit> function1) {
function1.invoke(this.k);
}
}