package com.discord.stores; import a0.a.a.b; import android.content.Context; import android.util.Log; import c.a.r.w; import c.d.b.a.a; import co.discord.media_engine.VideoInputDeviceDescription; import com.discord.api.channel.Channel; import com.discord.api.stageinstance.StageInstance; import com.discord.api.voice.server.VoiceServer; import com.discord.api.voice.state.VoiceState; import com.discord.app.App; import com.discord.app.AppLog; import com.discord.gateway.io.OutgoingPayload; import com.discord.models.domain.ModelPayload; import com.discord.models.experiments.domain.Experiment; import com.discord.rtcconnection.RtcConnection; import com.discord.rtcconnection.VideoMetadata; import com.discord.rtcconnection.mediaengine.MediaEngine; import com.discord.rtcconnection.mediaengine.MediaEngineConnection; import com.discord.stores.StoreMediaSettings; import com.discord.stores.StoreStream; import com.discord.utilities.analytics.AnalyticsTracker; import com.discord.utilities.debug.DebugPrintBuilder; import com.discord.utilities.debug.DebugPrintable; import com.discord.utilities.debug.DebugPrintableCollection; import com.discord.utilities.io.NetworkUtils; import com.discord.utilities.logging.Logger; import com.discord.utilities.networking.NetworkMonitor; import com.discord.utilities.rx.ObservableExtensionsKt; import com.discord.utilities.ssl.SecureSocketsLayerUtils; import com.discord.utilities.systemlog.SystemLogUtils; import com.discord.utilities.time.Clock; import com.discord.utilities.time.ClockFactory; import com.google.firebase.crashlytics.FirebaseCrashlytics; import d0.t.h0; import d0.z.d.m; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import java.util.Objects; import java.util.concurrent.TimeUnit; import javax.net.ssl.SSLSocketFactory; import kotlin.jvm.functions.Function0; import kotlin.jvm.functions.Function1; import kotlin.jvm.internal.DefaultConstructorMarker; import rx.Observable; import rx.subjects.BehaviorSubject; import rx.subjects.PublishSubject; import rx.subjects.SerializedSubject; /* compiled from: StoreRtcConnection.kt */ public final class StoreRtcConnection extends RtcConnection.b implements DebugPrintable { public static final Companion Companion = new Companion(null); private static final long SPEAKING_UPDATES_BUFFER_MS = 300; private static int instanceCounter; private final Clock clock; private final Observable connectionState; private final SerializedSubject connectionStateSubject; private Context context; private OutgoingPayload.VoiceStateUpdate currentVoiceState; private final long debugDisplayId; private final Dispatcher dispatcher; private final DebugPrintableCollection dpc; private boolean hasSelectedVoiceChannel; private Long joinedChannelTimestamp; private final Logger logger; private final String loggingTag; private NetworkMonitor networkMonitor; private final Observable quality; private final BehaviorSubject qualitySubject; private RtcConnection rtcConnection; private RtcConnection.Metadata rtcConnectionMetadata; private final BehaviorSubject rtcConnectionMetadataSubject; private Channel selectedVoiceChannel; private String sessionId; private final Observable> speakingUpdates; private final PublishSubject speakingUsersSubject; private final StoreAnalytics storeAnalytics; private final StoreRtcRegion storeRtcRegion; private final StoreVoiceStates storeVoiceStates; private final StoreStream stream; private VoicePropsTracker voicePropsTracker; private VoiceServer voiceServer; /* compiled from: StoreRtcConnection.kt */ public static final class Companion { private Companion() { } public /* synthetic */ Companion(DefaultConstructorMarker defaultConstructorMarker) { this(); } } /* compiled from: StoreRtcConnection.kt */ public static final class SpeakingUserUpdate { private final boolean isSpeaking; private final long userId; public SpeakingUserUpdate(long j, boolean z2) { this.userId = j; this.isSpeaking = z2; } public static /* synthetic */ SpeakingUserUpdate copy$default(SpeakingUserUpdate speakingUserUpdate, long j, boolean z2, int i, Object obj) { if ((i & 1) != 0) { j = speakingUserUpdate.userId; } if ((i & 2) != 0) { z2 = speakingUserUpdate.isSpeaking; } return speakingUserUpdate.copy(j, z2); } public final long component1() { return this.userId; } public final boolean component2() { return this.isSpeaking; } public final SpeakingUserUpdate copy(long j, boolean z2) { return new SpeakingUserUpdate(j, z2); } public boolean equals(Object obj) { if (this == obj) { return true; } if (!(obj instanceof SpeakingUserUpdate)) { return false; } SpeakingUserUpdate speakingUserUpdate = (SpeakingUserUpdate) obj; return this.userId == speakingUserUpdate.userId && this.isSpeaking == speakingUserUpdate.isSpeaking; } public final long getUserId() { return this.userId; } public int hashCode() { int a = b.a(this.userId) * 31; boolean z2 = this.isSpeaking; if (z2) { z2 = true; } int i = z2 ? 1 : 0; int i2 = z2 ? 1 : 0; int i3 = z2 ? 1 : 0; return a + i; } public final boolean isSpeaking() { return this.isSpeaking; } public String toString() { StringBuilder L = a.L("SpeakingUserUpdate(userId="); L.append(this.userId); L.append(", isSpeaking="); return a.G(L, this.isSpeaking, ")"); } } public final /* synthetic */ class WhenMappings { public static final /* synthetic */ int[] $EnumSwitchMapping$0; static { RtcConnection.AnalyticsEvent.values(); int[] iArr = new int[5]; $EnumSwitchMapping$0 = iArr; iArr[RtcConnection.AnalyticsEvent.VOICE_CONNECTION_SUCCESS.ordinal()] = 1; iArr[RtcConnection.AnalyticsEvent.VOICE_CONNECTION_FAILURE.ordinal()] = 2; iArr[RtcConnection.AnalyticsEvent.VOICE_DISCONNECT.ordinal()] = 3; iArr[RtcConnection.AnalyticsEvent.VIDEO_STREAM_ENDED.ordinal()] = 4; iArr[RtcConnection.AnalyticsEvent.MEDIA_SESSION_JOINED.ordinal()] = 5; } } public StoreRtcConnection(StoreStream storeStream, Dispatcher dispatcher, Clock clock, StoreRtcRegion storeRtcRegion, StoreAnalytics storeAnalytics, StoreVoiceStates storeVoiceStates, Logger logger, DebugPrintableCollection debugPrintableCollection) { m.checkNotNullParameter(storeStream, "stream"); m.checkNotNullParameter(dispatcher, "dispatcher"); m.checkNotNullParameter(clock, "clock"); m.checkNotNullParameter(storeRtcRegion, "storeRtcRegion"); m.checkNotNullParameter(storeAnalytics, "storeAnalytics"); m.checkNotNullParameter(storeVoiceStates, "storeVoiceStates"); m.checkNotNullParameter(logger, "logger"); m.checkNotNullParameter(debugPrintableCollection, "dpc"); this.stream = storeStream; this.dispatcher = dispatcher; this.clock = clock; this.storeRtcRegion = storeRtcRegion; this.storeAnalytics = storeAnalytics; this.storeVoiceStates = storeVoiceStates; this.logger = logger; this.dpc = debugPrintableCollection; PublishSubject k0 = PublishSubject.k0(); this.speakingUsersSubject = k0; BehaviorSubject l0 = BehaviorSubject.l0(RtcConnection.Quality.UNKNOWN); this.qualitySubject = l0; this.currentVoiceState = new OutgoingPayload.VoiceStateUpdate(null, null, false, false, false, null, 32, null); SerializedSubject serializedSubject = new SerializedSubject<>(BehaviorSubject.l0(new RtcConnection.StateChange(new RtcConnection.State.d(false), null))); this.connectionStateSubject = serializedSubject; this.rtcConnectionMetadataSubject = BehaviorSubject.l0(null); Observable r = ObservableExtensionsKt.computationLatest(serializedSubject).r(); m.checkNotNullExpressionValue(r, "connectionStateSubject\n … .distinctUntilChanged()"); this.connectionState = r; m.checkNotNullExpressionValue(l0, "qualitySubject"); Observable r2 = ObservableExtensionsKt.computationLatest(l0).r(); m.checkNotNullExpressionValue(r2, "qualitySubject\n … .distinctUntilChanged()"); this.quality = r2; Observable> a = k0.a(300, TimeUnit.MILLISECONDS); m.checkNotNullExpressionValue(a, "speakingUsersSubject\n …S, TimeUnit.MILLISECONDS)"); Observable> r3 = ObservableExtensionsKt.computationLatest(a).r(); m.checkNotNullExpressionValue(r3, "speakingUsersSubject\n … .distinctUntilChanged()"); this.speakingUpdates = r3; StringBuilder L = a.L("StoreRtcConnection "); int i = instanceCounter + 1; instanceCounter = i; L.append(i); String sb = L.toString(); this.loggingTag = sb; this.debugDisplayId = debugPrintableCollection.add(this, sb); } /* JADX INFO: this call moved to the top of the method (can break code semantics) */ public /* synthetic */ StoreRtcConnection(StoreStream storeStream, Dispatcher dispatcher, Clock clock, StoreRtcRegion storeRtcRegion, StoreAnalytics storeAnalytics, StoreVoiceStates storeVoiceStates, Logger logger, DebugPrintableCollection debugPrintableCollection, int i, DefaultConstructorMarker defaultConstructorMarker) { this(storeStream, dispatcher, clock, storeRtcRegion, storeAnalytics, storeVoiceStates, (i & 64) != 0 ? AppLog.g : logger, (i & 128) != 0 ? SystemLogUtils.INSTANCE.getDebugPrintables$app_productionBetaRelease() : debugPrintableCollection); } public static final /* synthetic */ Dispatcher access$getDispatcher$p(StoreRtcConnection storeRtcConnection) { return storeRtcConnection.dispatcher; } public static final /* synthetic */ StoreAnalytics access$getStoreAnalytics$p(StoreRtcConnection storeRtcConnection) { return storeRtcConnection.storeAnalytics; } public static final /* synthetic */ StoreStream access$getStream$p(StoreRtcConnection storeRtcConnection) { return storeRtcConnection.stream; } public static final /* synthetic */ VoicePropsTracker access$getVoicePropsTracker$p(StoreRtcConnection storeRtcConnection) { return storeRtcConnection.voicePropsTracker; } public static final /* synthetic */ void access$handleMediaSessionIdReceived(StoreRtcConnection storeRtcConnection) { storeRtcConnection.handleMediaSessionIdReceived(); } public static final /* synthetic */ void access$handleSelfDeafened(StoreRtcConnection storeRtcConnection, boolean z2) { storeRtcConnection.handleSelfDeafened(z2); } public static final /* synthetic */ void access$handleSelfMuted(StoreRtcConnection storeRtcConnection, boolean z2) { storeRtcConnection.handleSelfMuted(z2); } public static final /* synthetic */ void access$handleSelfVideo(StoreRtcConnection storeRtcConnection, boolean z2) { storeRtcConnection.handleSelfVideo(z2); } public static final /* synthetic */ void access$handleUsersMuted(StoreRtcConnection storeRtcConnection, Map map) { storeRtcConnection.handleUsersMuted(map); } public static final /* synthetic */ void access$handleUsersOffScreen(StoreRtcConnection storeRtcConnection, Map map) { storeRtcConnection.handleUsersOffScreen(map); } public static final /* synthetic */ void access$handleUsersVolume(StoreRtcConnection storeRtcConnection, Map map) { storeRtcConnection.handleUsersVolume(map); } public static final /* synthetic */ void access$setVoicePropsTracker$p(StoreRtcConnection storeRtcConnection, VoicePropsTracker voicePropsTracker) { storeRtcConnection.voicePropsTracker = voicePropsTracker; } private final void applyVoiceConfiguration(RtcConnection rtcConnection, Long l) { StoreMediaSettings.VoiceConfiguration voiceConfigurationBlocking = this.stream.getMediaSettings$app_productionBetaRelease().getVoiceConfigurationBlocking(); for (Map.Entry entry : voiceConfigurationBlocking.getUserOutputVolumes().entrySet()) { long longValue = entry.getKey().longValue(); float floatValue = entry.getValue().floatValue(); if (l == null || longValue == l.longValue()) { rtcConnection.v(longValue, floatValue); } } for (Map.Entry entry2 : voiceConfigurationBlocking.getMutedUsers().entrySet()) { long longValue2 = entry2.getKey().longValue(); boolean booleanValue = entry2.getValue().booleanValue(); if (l == null || longValue2 == l.longValue()) { rtcConnection.V.put(Long.valueOf(longValue2), Boolean.valueOf(booleanValue)); MediaEngineConnection mediaEngineConnection = rtcConnection.w; if (mediaEngineConnection != null) { mediaEngineConnection.w(longValue2, booleanValue); } } } for (Map.Entry entry3 : voiceConfigurationBlocking.getOffScreenUsers().entrySet()) { long longValue3 = entry3.getKey().longValue(); boolean booleanValue2 = entry3.getValue().booleanValue(); if (l == null || longValue3 == l.longValue()) { MediaEngineConnection mediaEngineConnection2 = rtcConnection.w; if (mediaEngineConnection2 == null) { Log.e("RtcConnection", "MediaEngine not connected for setLocalVideoOffscreen."); } else { mediaEngineConnection2.d(longValue3, booleanValue2); } } } } public static /* synthetic */ void applyVoiceConfiguration$default(StoreRtcConnection storeRtcConnection, RtcConnection rtcConnection, Long l, int i, Object obj) { if ((i & 2) != 0) { l = null; } storeRtcConnection.applyVoiceConfiguration(rtcConnection, l); } @StoreThread private final void checkForVoiceServerUpdate() { String str; RtcConnection rtcConnection = this.rtcConnection; VoiceServer voiceServer = this.voiceServer; if (rtcConnection != null && voiceServer != null) { if (voiceServer.c() == null || !(!m.areEqual(voiceServer.c(), rtcConnection.L))) { if (voiceServer.a() != null) { Long a = voiceServer.a(); long j = rtcConnection.M; if (a == null || a.longValue() != j) { return; } } App.a aVar = App.j; SSLSocketFactory sSLSocketFactory = null; if (App.i) { str = ""; } else { str = voiceServer.b(); sSLSocketFactory = SecureSocketsLayerUtils.createSocketFactory$default(null, 1, null); } recordBreadcrumb(a.u("Voice server update, connect to server w/ endpoint: ", str)); rtcConnection.s(new w(rtcConnection, str, voiceServer.d(), sSLSocketFactory)); } } } /* JADX WARNING: Removed duplicated region for block: B:11:0x0036 */ /* JADX WARNING: Removed duplicated region for block: B:12:0x0040 */ @StoreThread private final void createRtcConnection() { Long l; long id2 = this.stream.getUsers$app_productionBetaRelease().getMeInternal$app_productionBetaRelease().getId(); String str = this.sessionId; Channel channel = this.selectedVoiceChannel; long j = 0; String str2 = null; if (channel != null) { Long valueOf = Long.valueOf(channel.f()); if (valueOf.longValue() > 0) { l = valueOf; Channel channel2 = this.selectedVoiceChannel; Long valueOf2 = channel2 == null ? Long.valueOf(channel2.h()) : null; MediaEngine mediaEngine = StoreStream.Companion.getMediaEngine().getMediaEngine(); if (str != null && valueOf2 != null) { RtcConnection rtcConnection = this.rtcConnection; if (m.areEqual(rtcConnection != null ? Long.valueOf(rtcConnection.M) : null, valueOf2)) { RtcConnection rtcConnection2 = this.rtcConnection; if (rtcConnection2 != null) { str2 = rtcConnection2.N; } if (m.areEqual(str2, str)) { return; } } if (l != null) { j = l.longValue(); } this.voicePropsTracker = new VoicePropsTracker(j, valueOf2.longValue(), id2, this.storeVoiceStates.get().get(Long.valueOf(j))); Experiment userExperiment = this.stream.getExperiments$app_productionBetaRelease().getUserExperiment("2021-03_android_media_sink_wants", false); boolean z2 = userExperiment != null && userExperiment.getBucket() == 1; RtcConnection rtcConnection3 = this.rtcConnection; if (rtcConnection3 != null) { rtcConnection3.e(); } long longValue = valueOf2.longValue(); String valueOf3 = String.valueOf(l != null ? l.longValue() : valueOf2.longValue()); Logger logger = this.logger; String str3 = this.loggingTag; NetworkMonitor networkMonitor = this.networkMonitor; if (networkMonitor == null) { m.throwUninitializedPropertyAccessException("networkMonitor"); } RtcConnection rtcConnection4 = new RtcConnection(l, longValue, str, true, valueOf3, id2, mediaEngine, logger, ClockFactory.get(), null, networkMonitor, h0.toMutableMap(this.stream.getMediaSettings$app_productionBetaRelease().getMutedUsers()), null, null, z2, str3, null, 78336); rtcConnection4.c(this); this.rtcConnection = rtcConnection4; updateMetadata(); return; } } } l = null; Channel channel2 = this.selectedVoiceChannel; if (channel2 == null) { } MediaEngine mediaEngine = StoreStream.Companion.getMediaEngine().getMediaEngine(); if (str != null) { } } @StoreThread private final void destroyRtcConnection(String str) { RtcConnection rtcConnection = this.rtcConnection; if (rtcConnection != null) { recordBreadcrumb(a.u("destroying rtc connection: ", str)); rtcConnection.e(); this.rtcConnection = null; updateMetadata(); } } @StoreThread private final void handleMediaSessionIdReceived() { AppLog appLog = AppLog.g; RtcConnection rtcConnection = this.rtcConnection; String str = rtcConnection != null ? rtcConnection.H : null; Objects.requireNonNull(appLog); FirebaseCrashlytics instance = FirebaseCrashlytics.getInstance(); if (str == null) { str = ""; } instance.setCustomKey("mediaSessionId", str); updateMetadata(); } @StoreThread private final void handleSelfDeafened(boolean z2) { this.currentVoiceState = OutgoingPayload.VoiceStateUpdate.copy$default(this.currentVoiceState, null, null, false, z2, false, null, 55, null); onVoiceStateUpdated(); } @StoreThread private final void handleSelfMuted(boolean z2) { this.currentVoiceState = OutgoingPayload.VoiceStateUpdate.copy$default(this.currentVoiceState, null, null, z2, false, false, null, 59, null); onVoiceStateUpdated(); } @StoreThread private final void handleSelfVideo(boolean z2) { this.currentVoiceState = OutgoingPayload.VoiceStateUpdate.copy$default(this.currentVoiceState, null, null, false, false, z2, null, 47, null); onVoiceStateUpdated(); } @StoreThread private final void handleUsersMuted(Map map) { for (Map.Entry entry : map.entrySet()) { long longValue = entry.getKey().longValue(); boolean booleanValue = entry.getValue().booleanValue(); RtcConnection rtcConnection = this.rtcConnection; if (rtcConnection != null) { rtcConnection.V.put(Long.valueOf(longValue), Boolean.valueOf(booleanValue)); MediaEngineConnection mediaEngineConnection = rtcConnection.w; if (mediaEngineConnection != null) { mediaEngineConnection.w(longValue, booleanValue); } } } } @StoreThread private final void handleUsersOffScreen(Map map) { for (Map.Entry entry : map.entrySet()) { long longValue = entry.getKey().longValue(); boolean booleanValue = entry.getValue().booleanValue(); RtcConnection rtcConnection = this.rtcConnection; if (rtcConnection != null) { MediaEngineConnection mediaEngineConnection = rtcConnection.w; if (mediaEngineConnection == null) { Log.e("RtcConnection", "MediaEngine not connected for setLocalVideoOffscreen."); } else { mediaEngineConnection.d(longValue, booleanValue); } } } } @StoreThread private final void handleUsersVolume(Map map) { for (Map.Entry entry : map.entrySet()) { long longValue = entry.getKey().longValue(); float floatValue = entry.getValue().floatValue(); RtcConnection rtcConnection = this.rtcConnection; if (rtcConnection != null) { rtcConnection.v(longValue, floatValue); } } } @StoreThread private final void logChannelJoin(Channel channel) { String str; long id2 = this.stream.getUsers$app_productionBetaRelease().getMeInternal$app_productionBetaRelease().getId(); RtcConnection rtcConnection = this.rtcConnection; if (rtcConnection != null && (str = rtcConnection.l) != null) { StageInstance stageInstanceForChannel = this.stream.getStageInstances$app_productionBetaRelease().getStageInstanceForChannel(channel.h()); Long valueOf = stageInstanceForChannel != null ? Long.valueOf(stageInstanceForChannel.c()) : null; AnalyticsTracker analyticsTracker = AnalyticsTracker.INSTANCE; Map map = (Map) a.c(channel, this.stream.getVoiceStates$app_productionBetaRelease().get()); if (map == null) { map = h0.emptyMap(); } VideoInputDeviceDescription selectedVideoInputDeviceBlocking = this.stream.getMediaEngine$app_productionBetaRelease().getSelectedVideoInputDeviceBlocking(); NetworkUtils networkUtils = NetworkUtils.INSTANCE; Context context = this.context; if (context == null) { m.throwUninitializedPropertyAccessException("context"); } analyticsTracker.voiceChannelJoin(id2, str, channel, map, selectedVideoInputDeviceBlocking, networkUtils.getNetworkType(context), valueOf); } } @StoreThread private final void logChannelLeave(Channel channel) { String str; long id2 = this.stream.getUsers$app_productionBetaRelease().getMeInternal$app_productionBetaRelease().getId(); RtcConnection rtcConnection = this.rtcConnection; if (rtcConnection != null && (str = rtcConnection.l) != null) { Long l = null; String str2 = rtcConnection != null ? rtcConnection.H : null; StageInstance stageInstanceForChannel = this.stream.getStageInstances$app_productionBetaRelease().getStageInstanceForChannel(channel.h()); Long valueOf = stageInstanceForChannel != null ? Long.valueOf(stageInstanceForChannel.c()) : null; LinkedHashMap linkedHashMap = new LinkedHashMap(); VoicePropsTracker voicePropsTracker = this.voicePropsTracker; if (voicePropsTracker != null) { voicePropsTracker.getProps(linkedHashMap); } this.voicePropsTracker = null; AnalyticsTracker analyticsTracker = AnalyticsTracker.INSTANCE; Map map = (Map) a.c(channel, this.stream.getVoiceStates$app_productionBetaRelease().get()); if (map == null) { map = h0.emptyMap(); } Long l2 = this.joinedChannelTimestamp; if (l2 != null) { l = Long.valueOf(this.clock.currentTimeMillis() - l2.longValue()); } analyticsTracker.voiceChannelLeave(id2, str, channel, map, str2, linkedHashMap, l, valueOf); } } private final void loge(String str, Throwable th, Map map) { this.logger.e(this.loggingTag, str, th, map); } /* JADX DEBUG: Multi-variable search result rejected for r1v0, resolved type: com.discord.stores.StoreRtcConnection */ /* JADX WARN: Multi-variable type inference failed */ public static /* synthetic */ void loge$default(StoreRtcConnection storeRtcConnection, String str, Throwable th, Map map, int i, Object obj) { if ((i & 2) != 0) { th = null; } if ((i & 4) != 0) { map = null; } storeRtcConnection.loge(str, th, map); } private final void logi(String str, Throwable th) { this.logger.i(this.loggingTag, str, th); } public static /* synthetic */ void logi$default(StoreRtcConnection storeRtcConnection, String str, Throwable th, int i, Object obj) { if ((i & 2) != 0) { th = null; } storeRtcConnection.logi(str, th); } private final void logw(String str) { Logger.w$default(this.logger, this.loggingTag, str, null, 4, null); } @StoreThread private final void onVoiceStateUpdated() { String str; if (this.hasSelectedVoiceChannel) { StringBuilder L = a.L("Voice state update: "); L.append(this.currentVoiceState); recordBreadcrumb(L.toString()); } StoreGatewayConnection gatewaySocket = StoreStream.Companion.getGatewaySocket(); Long guildId = this.currentVoiceState.getGuildId(); Long channelId = this.currentVoiceState.getChannelId(); boolean selfMute = this.currentVoiceState.getSelfMute(); boolean selfDeaf = this.currentVoiceState.getSelfDeaf(); boolean selfVideo = this.currentVoiceState.getSelfVideo(); Long channelId2 = this.currentVoiceState.getChannelId(); if (channelId2 != null) { channelId2.longValue(); str = this.storeRtcRegion.getPreferredRegion(); } else { str = null; } gatewaySocket.voiceStateUpdate(guildId, channelId, selfMute, selfDeaf, selfVideo, str, this.storeRtcRegion.shouldIncludePreferredRegion(this.currentVoiceState.getGuildId())); } private final void recordBreadcrumb(String str) { this.logger.recordBreadcrumb(str, this.loggingTag); } @StoreThread private final void updateMetadata() { RtcConnection rtcConnection = this.rtcConnection; RtcConnection.Metadata i = rtcConnection != null ? rtcConnection.i() : null; this.rtcConnectionMetadata = i; this.rtcConnectionMetadataSubject.onNext(i); } @Override // com.discord.utilities.debug.DebugPrintable public void debugPrint(DebugPrintBuilder debugPrintBuilder) { m.checkNotNullParameter(debugPrintBuilder, "dp"); debugPrintBuilder.appendKeyValue("sessionId", this.sessionId); debugPrintBuilder.appendKeyValue("rtcConnection", (DebugPrintable) this.rtcConnection); } public final void finalize() { this.dpc.remove(this.debugDisplayId); } public final long getConnectedGuildId() { Long l; RtcConnection rtcConnection = this.rtcConnection; if (rtcConnection == null || (l = rtcConnection.L) == null) { return 0; } return l.longValue(); } public final Observable getConnectionState() { return this.connectionState; } public final Observable getQuality() { return this.quality; } public final RtcConnection getRtcConnection$app_productionBetaRelease() { return this.rtcConnection; } @StoreThread public final RtcConnection.Metadata getRtcConnectionMetadata() { return this.rtcConnectionMetadata; } public final Observable> getSpeakingUpdates() { return this.speakingUpdates; } @StoreThread public final void handleConnectionOpen(ModelPayload modelPayload) { m.checkNotNullParameter(modelPayload, "payload"); this.sessionId = modelPayload.getSessionId(); RtcConnection rtcConnection = this.rtcConnection; if (rtcConnection != null) { String sessionId = modelPayload.getSessionId(); m.checkNotNullExpressionValue(sessionId, "payload.sessionId"); m.checkNotNullParameter(sessionId, ""); rtcConnection.N = sessionId; } } @StoreThread public final void handleConnectionReady(boolean z2) { if (z2) { Channel channel = this.selectedVoiceChannel; handleVoiceChannelSelected(Long.valueOf(channel != null ? channel.h() : 0)); } } /* JADX WARNING: Removed duplicated region for block: B:27:0x007e */ /* JADX WARNING: Removed duplicated region for block: B:28:0x0088 */ /* JADX WARNING: Removed duplicated region for block: B:31:0x0098 */ /* JADX WARNING: Removed duplicated region for block: B:32:0x00ad */ @StoreThread public final void handleVoiceChannelSelected(Long l) { Long l2; Channel channel = this.selectedVoiceChannel; if (!m.areEqual(l, channel != null ? Long.valueOf(channel.h()) : null)) { Channel channel2 = this.selectedVoiceChannel; if (channel2 != null) { logChannelLeave(channel2); } this.joinedChannelTimestamp = null; StringBuilder sb = new StringBuilder(); sb.append("Channel ID changed, "); sb.append(l); sb.append(" != "); Channel channel3 = this.selectedVoiceChannel; sb.append(channel3 != null ? Long.valueOf(channel3.h()) : null); destroyRtcConnection(sb.toString()); } Channel findChannelByIdInternal$app_productionBetaRelease = l != null ? this.stream.getChannels$app_productionBetaRelease().findChannelByIdInternal$app_productionBetaRelease(l.longValue()) : null; this.selectedVoiceChannel = findChannelByIdInternal$app_productionBetaRelease; OutgoingPayload.VoiceStateUpdate voiceStateUpdate = this.currentVoiceState; if (findChannelByIdInternal$app_productionBetaRelease != null) { Long valueOf = Long.valueOf(findChannelByIdInternal$app_productionBetaRelease.f()); if (valueOf.longValue() > 0) { l2 = valueOf; this.currentVoiceState = OutgoingPayload.VoiceStateUpdate.copy$default(voiceStateUpdate, l2, findChannelByIdInternal$app_productionBetaRelease == null ? Long.valueOf(findChannelByIdInternal$app_productionBetaRelease.h()) : null, false, false, false, null, 60, null); if (findChannelByIdInternal$app_productionBetaRelease == null) { this.hasSelectedVoiceChannel = true; createRtcConnection(); this.joinedChannelTimestamp = Long.valueOf(this.clock.currentTimeMillis()); logChannelJoin(findChannelByIdInternal$app_productionBetaRelease); } else { this.voiceServer = null; } onVoiceStateUpdated(); } } l2 = null; this.currentVoiceState = OutgoingPayload.VoiceStateUpdate.copy$default(voiceStateUpdate, l2, findChannelByIdInternal$app_productionBetaRelease == null ? Long.valueOf(findChannelByIdInternal$app_productionBetaRelease.h()) : null, false, false, false, null, 60, null); if (findChannelByIdInternal$app_productionBetaRelease == null) { } onVoiceStateUpdated(); } @StoreThread public final void handleVoiceServerUpdate(VoiceServer voiceServer) { m.checkNotNullParameter(voiceServer, "voiceServer"); recordBreadcrumb("handling voice server update: " + voiceServer); this.voiceServer = voiceServer; checkForVoiceServerUpdate(); } @StoreThread public final void handleVoiceStateUpdate(VoiceState voiceState) { m.checkNotNullParameter(voiceState, "voiceState"); VoicePropsTracker voicePropsTracker = this.voicePropsTracker; if (voicePropsTracker != null) { voicePropsTracker.handleVoiceStateUpdate(voiceState); } } @StoreThread public final void init(Context context, NetworkMonitor networkMonitor) { m.checkNotNullParameter(context, "context"); m.checkNotNullParameter(networkMonitor, "networkMonitor"); this.context = context; this.networkMonitor = networkMonitor; StoreStream.Companion companion = StoreStream.Companion; ObservableExtensionsKt.appSubscribe$default(companion.getMediaSettings().isSelfMuted(), StoreRtcConnection.class, (Context) null, (Function1) null, (Function1) null, (Function0) null, (Function0) null, new StoreRtcConnection$init$1(this), 62, (Object) null); ObservableExtensionsKt.appSubscribe$default(companion.getMediaSettings().isSelfDeafened(), StoreRtcConnection.class, (Context) null, (Function1) null, (Function1) null, (Function0) null, (Function0) null, new StoreRtcConnection$init$2(this), 62, (Object) null); Observable F = companion.getMediaEngine().getSelectedVideoInputDevice().F(StoreRtcConnection$init$3.INSTANCE); m.checkNotNullExpressionValue(F, "StoreStream\n .get…viceDescription != null }"); ObservableExtensionsKt.appSubscribe$default(F, StoreRtcConnection.class, (Context) null, (Function1) null, (Function1) null, (Function0) null, (Function0) null, new StoreRtcConnection$init$4(this), 62, (Object) null); ObservableExtensionsKt.appSubscribe$default(this.stream.getMediaSettings$app_productionBetaRelease().getUsersVolume(), StoreRtcConnection.class, (Context) null, (Function1) null, (Function1) null, (Function0) null, (Function0) null, new StoreRtcConnection$init$5(this), 62, (Object) null); ObservableExtensionsKt.appSubscribe$default(this.stream.getMediaSettings$app_productionBetaRelease().getUsersMuted(), StoreRtcConnection.class, (Context) null, (Function1) null, (Function1) null, (Function0) null, (Function0) null, new StoreRtcConnection$init$6(this), 62, (Object) null); ObservableExtensionsKt.appSubscribe$default(this.stream.getMediaSettings$app_productionBetaRelease().getUsersOffScreen(), StoreRtcConnection.class, (Context) null, (Function1) null, (Function1) null, (Function0) null, (Function0) null, new StoreRtcConnection$init$7(this), 62, (Object) null); } public final Observable observeRtcConnectionMetadata() { BehaviorSubject behaviorSubject = this.rtcConnectionMetadataSubject; m.checkNotNullExpressionValue(behaviorSubject, "rtcConnectionMetadataSubject"); return behaviorSubject; } @Override // com.discord.rtcconnection.RtcConnection.b, com.discord.rtcconnection.RtcConnection.c public void onAnalyticsEvent(RtcConnection.AnalyticsEvent analyticsEvent, Map map) { m.checkNotNullParameter(analyticsEvent, "event"); m.checkNotNullParameter(map, "properties"); int ordinal = analyticsEvent.ordinal(); if (ordinal == 0) { this.storeAnalytics.trackVoiceConnectionSuccess(map); } else if (ordinal == 1) { this.storeAnalytics.trackVoiceConnectionFailure(map); } else if (ordinal == 2) { this.storeAnalytics.trackVoiceDisconnect(map); } else if (ordinal == 3) { this.dispatcher.schedule(new StoreRtcConnection$onAnalyticsEvent$1(this, map)); } else if (ordinal == 4) { this.storeAnalytics.trackMediaSessionJoined(map); } } @Override // com.discord.rtcconnection.RtcConnection.b, com.discord.rtcconnection.RtcConnection.c public void onFatalClose() { this.stream.getVoiceChannelSelected$app_productionBetaRelease().clear(); } @Override // com.discord.rtcconnection.RtcConnection.b, com.discord.rtcconnection.RtcConnection.c public void onMediaEngineConnectionConnected(RtcConnection rtcConnection) { m.checkNotNullParameter(rtcConnection, "connection"); this.dispatcher.schedule(new StoreRtcConnection$onMediaEngineConnectionConnected$1(this, rtcConnection)); } @Override // com.discord.rtcconnection.RtcConnection.b, com.discord.rtcconnection.RtcConnection.c public void onMediaSessionIdReceived() { this.dispatcher.schedule(new StoreRtcConnection$onMediaSessionIdReceived$1(this)); } @Override // com.discord.rtcconnection.RtcConnection.b, com.discord.rtcconnection.RtcConnection.c public void onQualityUpdate(RtcConnection.Quality quality) { m.checkNotNullParameter(quality, "quality"); this.qualitySubject.onNext(quality); } @Override // com.discord.rtcconnection.RtcConnection.b, com.discord.rtcconnection.RtcConnection.c public void onSpeaking(long j, boolean z2) { PublishSubject publishSubject = this.speakingUsersSubject; publishSubject.j.onNext(new SpeakingUserUpdate(j, z2)); this.dispatcher.schedule(new StoreRtcConnection$onSpeaking$1(this, j, z2)); } @Override // com.discord.rtcconnection.RtcConnection.b, com.discord.rtcconnection.RtcConnection.c public void onStateChange(RtcConnection.StateChange stateChange) { m.checkNotNullParameter(stateChange, "stateChange"); recordBreadcrumb("connection state change: " + stateChange); this.connectionStateSubject.j.onNext(stateChange); } @Override // com.discord.rtcconnection.RtcConnection.b, com.discord.rtcconnection.RtcConnection.c public void onUserCreated(RtcConnection rtcConnection, long j) { m.checkNotNullParameter(rtcConnection, "connection"); applyVoiceConfiguration(rtcConnection, Long.valueOf(j)); } @Override // com.discord.rtcconnection.RtcConnection.b, com.discord.rtcconnection.RtcConnection.c public void onVideoMetadata(VideoMetadata videoMetadata) { m.checkNotNullParameter(videoMetadata, "metadata"); this.dispatcher.schedule(new StoreRtcConnection$onVideoMetadata$1(this, videoMetadata)); } @Override // com.discord.rtcconnection.RtcConnection.b, com.discord.rtcconnection.RtcConnection.c public void onVideoStream(long j, Integer num) { this.dispatcher.schedule(new StoreRtcConnection$onVideoStream$1(this, j, num)); } }