613 lines
28 KiB
Java
613 lines
28 KiB
Java
package com.discord.stores;
|
|
|
|
import androidx.core.app.NotificationCompat;
|
|
import c.a.r.j;
|
|
import c.a.r.p0.e;
|
|
import c.a.r.w;
|
|
import c.d.b.a.a;
|
|
import com.discord.app.App;
|
|
import com.discord.app.AppLog;
|
|
import com.discord.models.domain.ModelApplicationStream;
|
|
import com.discord.models.domain.ModelPayload;
|
|
import com.discord.models.domain.StreamCreateOrUpdate;
|
|
import com.discord.models.domain.StreamServerUpdate;
|
|
import com.discord.rtcconnection.MediaSinkWantsManager;
|
|
import com.discord.rtcconnection.RtcConnection;
|
|
import com.discord.rtcconnection.VideoMetadata;
|
|
import com.discord.rtcconnection.mediaengine.MediaEngine;
|
|
import com.discord.stores.updates.ObservationDeck;
|
|
import com.discord.stores.updates.ObservationDeckProvider;
|
|
import com.discord.utilities.collections.ListenerCollection;
|
|
import com.discord.utilities.collections.ListenerCollectionSubject;
|
|
import com.discord.utilities.debug.DebugPrintBuilder;
|
|
import com.discord.utilities.debug.DebugPrintable;
|
|
import com.discord.utilities.debug.DebugPrintableCollection;
|
|
import com.discord.utilities.logging.Logger;
|
|
import com.discord.utilities.networking.NetworkMonitor;
|
|
import com.discord.utilities.ssl.SecureSocketsLayerUtils;
|
|
import com.discord.utilities.systemlog.SystemLogUtils;
|
|
import com.discord.utilities.time.Clock;
|
|
import d0.z.d.m;
|
|
import java.util.Map;
|
|
import javax.net.ssl.SSLSocketFactory;
|
|
import kotlin.NoWhenBranchMatchedException;
|
|
import kotlin.jvm.internal.DefaultConstructorMarker;
|
|
import rx.Observable;
|
|
/* compiled from: StoreStreamRtcConnection.kt */
|
|
public final class StoreStreamRtcConnection extends StoreV2 implements DebugPrintable {
|
|
public static final Companion Companion = new Companion(null);
|
|
public static final float MAX_STREAM_VOLUME = 300.0f;
|
|
private static int instanceCounter;
|
|
private final StoreAnalytics analyticsStore;
|
|
private final Clock clock;
|
|
private final long debugDisplayId;
|
|
private final Dispatcher dispatcher;
|
|
private final DebugPrintableCollection dpc;
|
|
private final ListenerCollectionSubject<Listener> listenerSubject;
|
|
private final ListenerCollection<Listener> listeners;
|
|
private final Logger logger;
|
|
private final String loggingTag;
|
|
private final StoreMediaEngine mediaEngineStore;
|
|
private NetworkMonitor networkMonitor;
|
|
private final ObservationDeck observationDeck;
|
|
private RtcConnection rtcConnection;
|
|
private String sessionId;
|
|
private State state;
|
|
private final StoreRtcConnection storeRtcConnection;
|
|
private final StoreStream storeStream;
|
|
private Long streamOwner;
|
|
private float streamVolume;
|
|
private final StoreUser userStore;
|
|
|
|
/* compiled from: StoreStreamRtcConnection.kt */
|
|
public static final class Companion {
|
|
private Companion() {
|
|
}
|
|
|
|
public /* synthetic */ Companion(DefaultConstructorMarker defaultConstructorMarker) {
|
|
this();
|
|
}
|
|
}
|
|
|
|
/* compiled from: StoreStreamRtcConnection.kt */
|
|
public static abstract class DefaultListener implements Listener {
|
|
@Override // com.discord.stores.StoreStreamRtcConnection.Listener
|
|
public void onConnected() {
|
|
}
|
|
|
|
@Override // com.discord.stores.StoreStreamRtcConnection.Listener
|
|
public void onConnecting() {
|
|
}
|
|
|
|
@Override // com.discord.stores.StoreStreamRtcConnection.Listener, c.a.r.p0.e.f
|
|
public void onFirstFrameReceived(long j) {
|
|
}
|
|
|
|
@Override // com.discord.stores.StoreStreamRtcConnection.Listener, c.a.r.p0.e.f
|
|
public void onFirstFrameSent() {
|
|
}
|
|
}
|
|
|
|
/* compiled from: StoreStreamRtcConnection.kt */
|
|
public interface Listener extends e.f {
|
|
void onConnected();
|
|
|
|
void onConnecting();
|
|
|
|
@Override // c.a.r.p0.e.f
|
|
/* synthetic */ void onFirstFrameReceived(long j);
|
|
|
|
@Override // c.a.r.p0.e.f
|
|
/* synthetic */ void onFirstFrameSent();
|
|
}
|
|
|
|
/* compiled from: StoreStreamRtcConnection.kt */
|
|
public final class RtcConnectionListener extends RtcConnection.b {
|
|
|
|
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.VIDEO_STREAM_ENDED.ordinal()] = 1;
|
|
iArr[RtcConnection.AnalyticsEvent.MEDIA_SESSION_JOINED.ordinal()] = 2;
|
|
}
|
|
}
|
|
|
|
public RtcConnectionListener() {
|
|
}
|
|
|
|
@Override // com.discord.rtcconnection.RtcConnection.b, com.discord.rtcconnection.RtcConnection.c
|
|
public void onAnalyticsEvent(RtcConnection.AnalyticsEvent analyticsEvent, Map<String, Object> map) {
|
|
m.checkNotNullParameter(analyticsEvent, NotificationCompat.CATEGORY_EVENT);
|
|
m.checkNotNullParameter(map, "properties");
|
|
int ordinal = analyticsEvent.ordinal();
|
|
if (ordinal == 3) {
|
|
StoreStreamRtcConnection.access$getDispatcher$p(StoreStreamRtcConnection.this).schedule(new StoreStreamRtcConnection$RtcConnectionListener$onAnalyticsEvent$1(this, map));
|
|
} else if (ordinal == 4) {
|
|
StoreStreamRtcConnection.access$getAnalyticsStore$p(StoreStreamRtcConnection.this).trackMediaSessionJoined(map);
|
|
}
|
|
}
|
|
|
|
@Override // com.discord.rtcconnection.RtcConnection.b, c.a.r.p0.e.f
|
|
public void onFirstFrameReceived(long j) {
|
|
StoreStreamRtcConnection.access$getListenerSubject$p(StoreStreamRtcConnection.this).notify(new StoreStreamRtcConnection$RtcConnectionListener$onFirstFrameReceived$1(j));
|
|
}
|
|
|
|
@Override // com.discord.rtcconnection.RtcConnection.b, c.a.r.p0.e.f
|
|
public void onFirstFrameSent() {
|
|
StoreStreamRtcConnection.access$getListenerSubject$p(StoreStreamRtcConnection.this).notify(StoreStreamRtcConnection$RtcConnectionListener$onFirstFrameSent$1.INSTANCE);
|
|
}
|
|
|
|
@Override // com.discord.rtcconnection.RtcConnection.b, com.discord.rtcconnection.RtcConnection.c
|
|
public void onMediaSessionIdReceived() {
|
|
StoreStreamRtcConnection.access$getDispatcher$p(StoreStreamRtcConnection.this).schedule(new StoreStreamRtcConnection$RtcConnectionListener$onMediaSessionIdReceived$1(this));
|
|
}
|
|
|
|
@Override // com.discord.rtcconnection.RtcConnection.b, com.discord.rtcconnection.RtcConnection.c
|
|
public void onQualityUpdate(RtcConnection.Quality quality) {
|
|
m.checkNotNullParameter(quality, "quality");
|
|
StoreStreamRtcConnection.access$getDispatcher$p(StoreStreamRtcConnection.this).schedule(new StoreStreamRtcConnection$RtcConnectionListener$onQualityUpdate$1(this, quality));
|
|
}
|
|
|
|
@Override // com.discord.rtcconnection.RtcConnection.b, com.discord.rtcconnection.RtcConnection.c
|
|
public void onStateChange(RtcConnection.StateChange stateChange) {
|
|
m.checkNotNullParameter(stateChange, "stateChange");
|
|
StoreStreamRtcConnection storeStreamRtcConnection = StoreStreamRtcConnection.this;
|
|
StoreStreamRtcConnection.access$recordBreadcrumb(storeStreamRtcConnection, "store state change: " + stateChange);
|
|
if (m.areEqual(stateChange.a, RtcConnection.State.f.a)) {
|
|
StoreStreamRtcConnection.access$getListenerSubject$p(StoreStreamRtcConnection.this).notify(StoreStreamRtcConnection$RtcConnectionListener$onStateChange$1.INSTANCE);
|
|
}
|
|
StoreStreamRtcConnection.access$getDispatcher$p(StoreStreamRtcConnection.this).schedule(new StoreStreamRtcConnection$RtcConnectionListener$onStateChange$2(this, stateChange));
|
|
}
|
|
|
|
@Override // com.discord.rtcconnection.RtcConnection.b, com.discord.rtcconnection.RtcConnection.c
|
|
public void onVideoMetadata(VideoMetadata videoMetadata) {
|
|
m.checkNotNullParameter(videoMetadata, "metadata");
|
|
StoreStreamRtcConnection.access$getDispatcher$p(StoreStreamRtcConnection.this).schedule(new StoreStreamRtcConnection$RtcConnectionListener$onVideoMetadata$1(this, videoMetadata));
|
|
}
|
|
|
|
@Override // com.discord.rtcconnection.RtcConnection.b, com.discord.rtcconnection.RtcConnection.c
|
|
public void onVideoStream(long j, Integer num, int i, int i2, int i3) {
|
|
StoreStreamRtcConnection.access$getDispatcher$p(StoreStreamRtcConnection.this).schedule(new StoreStreamRtcConnection$RtcConnectionListener$onVideoStream$1(this, j, num));
|
|
}
|
|
}
|
|
|
|
/* compiled from: StoreStreamRtcConnection.kt */
|
|
public static final class State {
|
|
private final RtcConnection.Quality connectionQuality;
|
|
private final String mediaSessionId;
|
|
private final RtcConnection rtcConnection;
|
|
private final RtcConnection.State rtcConnectionState;
|
|
|
|
public State(RtcConnection.State state, RtcConnection.Quality quality, String str, RtcConnection rtcConnection) {
|
|
m.checkNotNullParameter(state, "rtcConnectionState");
|
|
this.rtcConnectionState = state;
|
|
this.connectionQuality = quality;
|
|
this.mediaSessionId = str;
|
|
this.rtcConnection = rtcConnection;
|
|
}
|
|
|
|
public static /* synthetic */ State copy$default(State state, RtcConnection.State state2, RtcConnection.Quality quality, String str, RtcConnection rtcConnection, int i, Object obj) {
|
|
if ((i & 1) != 0) {
|
|
state2 = state.rtcConnectionState;
|
|
}
|
|
if ((i & 2) != 0) {
|
|
quality = state.connectionQuality;
|
|
}
|
|
if ((i & 4) != 0) {
|
|
str = state.mediaSessionId;
|
|
}
|
|
if ((i & 8) != 0) {
|
|
rtcConnection = state.rtcConnection;
|
|
}
|
|
return state.copy(state2, quality, str, rtcConnection);
|
|
}
|
|
|
|
public final RtcConnection.State component1() {
|
|
return this.rtcConnectionState;
|
|
}
|
|
|
|
public final RtcConnection.Quality component2() {
|
|
return this.connectionQuality;
|
|
}
|
|
|
|
public final String component3() {
|
|
return this.mediaSessionId;
|
|
}
|
|
|
|
public final RtcConnection component4() {
|
|
return this.rtcConnection;
|
|
}
|
|
|
|
public final State copy(RtcConnection.State state, RtcConnection.Quality quality, String str, RtcConnection rtcConnection) {
|
|
m.checkNotNullParameter(state, "rtcConnectionState");
|
|
return new State(state, quality, str, rtcConnection);
|
|
}
|
|
|
|
public boolean equals(Object obj) {
|
|
if (this == obj) {
|
|
return true;
|
|
}
|
|
if (!(obj instanceof State)) {
|
|
return false;
|
|
}
|
|
State state = (State) obj;
|
|
return m.areEqual(this.rtcConnectionState, state.rtcConnectionState) && m.areEqual(this.connectionQuality, state.connectionQuality) && m.areEqual(this.mediaSessionId, state.mediaSessionId) && m.areEqual(this.rtcConnection, state.rtcConnection);
|
|
}
|
|
|
|
public final RtcConnection.Quality getConnectionQuality() {
|
|
return this.connectionQuality;
|
|
}
|
|
|
|
public final String getMediaSessionId() {
|
|
return this.mediaSessionId;
|
|
}
|
|
|
|
public final RtcConnection getRtcConnection() {
|
|
return this.rtcConnection;
|
|
}
|
|
|
|
public final RtcConnection.State getRtcConnectionState() {
|
|
return this.rtcConnectionState;
|
|
}
|
|
|
|
public int hashCode() {
|
|
RtcConnection.State state = this.rtcConnectionState;
|
|
int i = 0;
|
|
int hashCode = (state != null ? state.hashCode() : 0) * 31;
|
|
RtcConnection.Quality quality = this.connectionQuality;
|
|
int hashCode2 = (hashCode + (quality != null ? quality.hashCode() : 0)) * 31;
|
|
String str = this.mediaSessionId;
|
|
int hashCode3 = (hashCode2 + (str != null ? str.hashCode() : 0)) * 31;
|
|
RtcConnection rtcConnection = this.rtcConnection;
|
|
if (rtcConnection != null) {
|
|
i = rtcConnection.hashCode();
|
|
}
|
|
return hashCode3 + i;
|
|
}
|
|
|
|
public String toString() {
|
|
StringBuilder K = a.K("State(rtcConnectionState=");
|
|
K.append(this.rtcConnectionState);
|
|
K.append(", connectionQuality=");
|
|
K.append(this.connectionQuality);
|
|
K.append(", mediaSessionId=");
|
|
K.append(this.mediaSessionId);
|
|
K.append(", rtcConnection=");
|
|
K.append(this.rtcConnection);
|
|
K.append(")");
|
|
return K.toString();
|
|
}
|
|
}
|
|
|
|
public StoreStreamRtcConnection(StoreMediaEngine storeMediaEngine, StoreUser storeUser, StoreStream storeStream, Dispatcher dispatcher, Clock clock, StoreAnalytics storeAnalytics, StoreRtcConnection storeRtcConnection, ObservationDeck observationDeck, Logger logger, DebugPrintableCollection debugPrintableCollection) {
|
|
m.checkNotNullParameter(storeMediaEngine, "mediaEngineStore");
|
|
m.checkNotNullParameter(storeUser, "userStore");
|
|
m.checkNotNullParameter(storeStream, "storeStream");
|
|
m.checkNotNullParameter(dispatcher, "dispatcher");
|
|
m.checkNotNullParameter(clock, "clock");
|
|
m.checkNotNullParameter(storeAnalytics, "analyticsStore");
|
|
m.checkNotNullParameter(storeRtcConnection, "storeRtcConnection");
|
|
m.checkNotNullParameter(observationDeck, "observationDeck");
|
|
m.checkNotNullParameter(logger, "logger");
|
|
m.checkNotNullParameter(debugPrintableCollection, "dpc");
|
|
this.mediaEngineStore = storeMediaEngine;
|
|
this.userStore = storeUser;
|
|
this.storeStream = storeStream;
|
|
this.dispatcher = dispatcher;
|
|
this.clock = clock;
|
|
this.analyticsStore = storeAnalytics;
|
|
this.storeRtcConnection = storeRtcConnection;
|
|
this.observationDeck = observationDeck;
|
|
this.logger = logger;
|
|
this.dpc = debugPrintableCollection;
|
|
ListenerCollectionSubject<Listener> listenerCollectionSubject = new ListenerCollectionSubject<>();
|
|
this.listenerSubject = listenerCollectionSubject;
|
|
this.listeners = listenerCollectionSubject;
|
|
this.state = new State(new RtcConnection.State.d(false), null, null, this.rtcConnection);
|
|
this.streamVolume = 300.0f;
|
|
StringBuilder K = a.K("StoreStreamRtcConnection ");
|
|
int i = instanceCounter + 1;
|
|
instanceCounter = i;
|
|
K.append(i);
|
|
String sb = K.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 */ StoreStreamRtcConnection(StoreMediaEngine storeMediaEngine, StoreUser storeUser, StoreStream storeStream, Dispatcher dispatcher, Clock clock, StoreAnalytics storeAnalytics, StoreRtcConnection storeRtcConnection, ObservationDeck observationDeck, Logger logger, DebugPrintableCollection debugPrintableCollection, int i, DefaultConstructorMarker defaultConstructorMarker) {
|
|
this(storeMediaEngine, storeUser, storeStream, dispatcher, clock, storeAnalytics, storeRtcConnection, (i & 128) != 0 ? ObservationDeckProvider.get() : observationDeck, (i & 256) != 0 ? AppLog.g : logger, (i & 512) != 0 ? SystemLogUtils.INSTANCE.getDebugPrintables$app_productionBetaRelease() : debugPrintableCollection);
|
|
}
|
|
|
|
public static final /* synthetic */ StoreAnalytics access$getAnalyticsStore$p(StoreStreamRtcConnection storeStreamRtcConnection) {
|
|
return storeStreamRtcConnection.analyticsStore;
|
|
}
|
|
|
|
public static final /* synthetic */ Dispatcher access$getDispatcher$p(StoreStreamRtcConnection storeStreamRtcConnection) {
|
|
return storeStreamRtcConnection.dispatcher;
|
|
}
|
|
|
|
public static final /* synthetic */ ListenerCollectionSubject access$getListenerSubject$p(StoreStreamRtcConnection storeStreamRtcConnection) {
|
|
return storeStreamRtcConnection.listenerSubject;
|
|
}
|
|
|
|
public static final /* synthetic */ RtcConnection access$getRtcConnection$p(StoreStreamRtcConnection storeStreamRtcConnection) {
|
|
return storeStreamRtcConnection.rtcConnection;
|
|
}
|
|
|
|
public static final /* synthetic */ StoreStream access$getStoreStream$p(StoreStreamRtcConnection storeStreamRtcConnection) {
|
|
return storeStreamRtcConnection.storeStream;
|
|
}
|
|
|
|
public static final /* synthetic */ Long access$getStreamOwner$p(StoreStreamRtcConnection storeStreamRtcConnection) {
|
|
return storeStreamRtcConnection.streamOwner;
|
|
}
|
|
|
|
public static final /* synthetic */ float access$getStreamVolume$p(StoreStreamRtcConnection storeStreamRtcConnection) {
|
|
return storeStreamRtcConnection.streamVolume;
|
|
}
|
|
|
|
public static final /* synthetic */ void access$handleMediaSessionIdReceived(StoreStreamRtcConnection storeStreamRtcConnection) {
|
|
storeStreamRtcConnection.handleMediaSessionIdReceived();
|
|
}
|
|
|
|
public static final /* synthetic */ void access$handleQualityUpdate(StoreStreamRtcConnection storeStreamRtcConnection, RtcConnection.Quality quality) {
|
|
storeStreamRtcConnection.handleQualityUpdate(quality);
|
|
}
|
|
|
|
public static final /* synthetic */ void access$handleVideoStreamEndedAnalyticsEvent(StoreStreamRtcConnection storeStreamRtcConnection, Map map) {
|
|
storeStreamRtcConnection.handleVideoStreamEndedAnalyticsEvent(map);
|
|
}
|
|
|
|
public static final /* synthetic */ void access$recordBreadcrumb(StoreStreamRtcConnection storeStreamRtcConnection, String str) {
|
|
storeStreamRtcConnection.recordBreadcrumb(str);
|
|
}
|
|
|
|
public static final /* synthetic */ void access$setRtcConnection$p(StoreStreamRtcConnection storeStreamRtcConnection, RtcConnection rtcConnection) {
|
|
storeStreamRtcConnection.rtcConnection = rtcConnection;
|
|
}
|
|
|
|
public static final /* synthetic */ void access$setStreamOwner$p(StoreStreamRtcConnection storeStreamRtcConnection, Long l) {
|
|
storeStreamRtcConnection.streamOwner = l;
|
|
}
|
|
|
|
public static final /* synthetic */ void access$setStreamVolume$p(StoreStreamRtcConnection storeStreamRtcConnection, float f) {
|
|
storeStreamRtcConnection.streamVolume = f;
|
|
}
|
|
|
|
@StoreThread
|
|
private final RtcConnection createRtcConnection(long j, Long l, long j2, String str, String str2, long j3, String str3) {
|
|
destroyRtcConnection();
|
|
RtcConnection.Metadata rtcConnectionMetadata = this.storeRtcConnection.getRtcConnectionMetadata();
|
|
String str4 = null;
|
|
Long l2 = rtcConnectionMetadata != null ? rtcConnectionMetadata.f2123c : null;
|
|
if (l2 != null && l2.longValue() == j2) {
|
|
str4 = rtcConnectionMetadata.b;
|
|
}
|
|
this.listenerSubject.notify(StoreStreamRtcConnection$createRtcConnection$1.INSTANCE);
|
|
MediaEngine mediaEngine = this.mediaEngineStore.getMediaEngine();
|
|
Logger logger = this.logger;
|
|
Clock clock = this.clock;
|
|
RtcConnection.d.b bVar = new RtcConnection.d.b(j3);
|
|
NetworkMonitor networkMonitor = this.networkMonitor;
|
|
if (networkMonitor == null) {
|
|
m.throwUninitializedPropertyAccessException("networkMonitor");
|
|
}
|
|
RtcConnection rtcConnection = new RtcConnection(l, j2, str, true, str2, j, mediaEngine, logger, clock, bVar, networkMonitor, null, null, str4, false, this.loggingTag, str3, 6144);
|
|
rtcConnection.c(new RtcConnectionListener());
|
|
return rtcConnection;
|
|
}
|
|
|
|
@StoreThread
|
|
private final void destroyRtcConnection() {
|
|
if (this.rtcConnection != null) {
|
|
recordBreadcrumb("destroying stream rtc connection");
|
|
updateRtcConnection(null);
|
|
this.state = State.copy$default(this.state, null, null, null, null, 9, null);
|
|
markChanged();
|
|
}
|
|
}
|
|
|
|
@StoreThread
|
|
private final void handleMediaSessionIdReceived() {
|
|
RtcConnection rtcConnection = this.rtcConnection;
|
|
this.state = State.copy$default(this.state, null, null, rtcConnection != null ? rtcConnection.I : null, null, 11, null);
|
|
markChanged();
|
|
}
|
|
|
|
@StoreThread
|
|
private final void handleQualityUpdate(RtcConnection.Quality quality) {
|
|
this.state = State.copy$default(this.state, null, quality, null, null, 13, null);
|
|
markChanged();
|
|
}
|
|
|
|
@StoreThread
|
|
private final void handleVideoStreamEndedAnalyticsEvent(Map<String, Object> map) {
|
|
this.analyticsStore.trackVideoStreamEnded(map);
|
|
}
|
|
|
|
private final void loge(String str, Throwable th, Map<String, String> map) {
|
|
this.logger.e(this.loggingTag, str, th, map);
|
|
}
|
|
|
|
/* JADX DEBUG: Multi-variable search result rejected for r1v0, resolved type: com.discord.stores.StoreStreamRtcConnection */
|
|
/* JADX WARN: Multi-variable type inference failed */
|
|
public static /* synthetic */ void loge$default(StoreStreamRtcConnection storeStreamRtcConnection, String str, Throwable th, Map map, int i, Object obj) {
|
|
if ((i & 2) != 0) {
|
|
th = null;
|
|
}
|
|
if ((i & 4) != 0) {
|
|
map = null;
|
|
}
|
|
storeStreamRtcConnection.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(StoreStreamRtcConnection storeStreamRtcConnection, String str, Throwable th, int i, Object obj) {
|
|
if ((i & 2) != 0) {
|
|
th = null;
|
|
}
|
|
storeStreamRtcConnection.logi(str, th);
|
|
}
|
|
|
|
private final void logw(String str) {
|
|
Logger.w$default(this.logger, this.loggingTag, str, null, 4, null);
|
|
}
|
|
|
|
private final void recordBreadcrumb(String str) {
|
|
this.logger.recordBreadcrumb(str, this.loggingTag);
|
|
}
|
|
|
|
@StoreThread
|
|
private final void updateRtcConnection(RtcConnection rtcConnection) {
|
|
RtcConnection rtcConnection2 = this.rtcConnection;
|
|
if (rtcConnection2 != null) {
|
|
rtcConnection2.e();
|
|
}
|
|
this.rtcConnection = rtcConnection;
|
|
this.state = State.copy$default(this.state, null, null, null, rtcConnection, 7, null);
|
|
markChanged();
|
|
}
|
|
|
|
@Override // com.discord.utilities.debug.DebugPrintable
|
|
public void debugPrint(DebugPrintBuilder debugPrintBuilder) {
|
|
m.checkNotNullParameter(debugPrintBuilder, "dp");
|
|
debugPrintBuilder.appendKeyValue("sessionId", this.sessionId);
|
|
debugPrintBuilder.appendKeyValue("streamOwner", this.streamOwner);
|
|
debugPrintBuilder.appendKeyValue("streamVolume", Float.valueOf(this.streamVolume));
|
|
debugPrintBuilder.appendKeyValue("state", this.state);
|
|
debugPrintBuilder.appendKeyValue("rtcConnection", (DebugPrintable) this.rtcConnection);
|
|
}
|
|
|
|
public final void finalize() {
|
|
this.dpc.remove(this.debugDisplayId);
|
|
}
|
|
|
|
public final ListenerCollection<Listener> getListeners() {
|
|
return this.listeners;
|
|
}
|
|
|
|
public final State getState() {
|
|
return this.state;
|
|
}
|
|
|
|
public final float getStreamVolume() {
|
|
return this.streamVolume;
|
|
}
|
|
|
|
@StoreThread
|
|
public final void handleConnectionOpen(ModelPayload modelPayload) {
|
|
m.checkNotNullParameter(modelPayload, "payload");
|
|
this.sessionId = modelPayload.getSessionId();
|
|
}
|
|
|
|
@StoreThread
|
|
public final void handleStreamCreate(StreamCreateOrUpdate streamCreateOrUpdate) {
|
|
Long l;
|
|
m.checkNotNullParameter(streamCreateOrUpdate, "streamCreate");
|
|
ModelApplicationStream decodeStreamKey = ModelApplicationStream.Companion.decodeStreamKey(streamCreateOrUpdate.getStreamKey());
|
|
long id2 = this.userStore.getMeInternal$app_productionBetaRelease().getId();
|
|
String str = this.sessionId;
|
|
if (str != null) {
|
|
RtcConnection rtcConnection = this.rtcConnection;
|
|
if (rtcConnection != null && rtcConnection.N == decodeStreamKey.getChannelId()) {
|
|
RtcConnection rtcConnection2 = this.rtcConnection;
|
|
if (m.areEqual(rtcConnection2 != null ? rtcConnection2.O : null, str)) {
|
|
return;
|
|
}
|
|
}
|
|
if (decodeStreamKey instanceof ModelApplicationStream.GuildStream) {
|
|
l = Long.valueOf(((ModelApplicationStream.GuildStream) decodeStreamKey).getGuildId());
|
|
} else if (decodeStreamKey instanceof ModelApplicationStream.CallStream) {
|
|
l = null;
|
|
} else {
|
|
throw new NoWhenBranchMatchedException();
|
|
}
|
|
long channelId = decodeStreamKey.getChannelId();
|
|
String rtcServerId = streamCreateOrUpdate.getRtcServerId();
|
|
m.checkNotNull(rtcServerId);
|
|
updateRtcConnection(createRtcConnection(id2, l, channelId, str, rtcServerId, decodeStreamKey.getOwnerId(), streamCreateOrUpdate.getStreamKey()));
|
|
this.streamOwner = Long.valueOf(decodeStreamKey.getOwnerId());
|
|
}
|
|
}
|
|
|
|
@StoreThread
|
|
public final void handleStreamDelete() {
|
|
RtcConnection rtcConnection = this.rtcConnection;
|
|
if (rtcConnection != null) {
|
|
rtcConnection.u(null, null);
|
|
}
|
|
destroyRtcConnection();
|
|
this.streamOwner = null;
|
|
}
|
|
|
|
@StoreThread
|
|
public final void handleStreamRtcConnectionStateChange(RtcConnection.State state) {
|
|
Long l;
|
|
m.checkNotNullParameter(state, "state");
|
|
if (m.areEqual(state, RtcConnection.State.f.a) && (l = this.streamOwner) != null) {
|
|
long longValue = l.longValue();
|
|
RtcConnection rtcConnection = this.rtcConnection;
|
|
if (rtcConnection != null) {
|
|
rtcConnection.w(longValue, this.streamVolume);
|
|
}
|
|
}
|
|
this.state = State.copy$default(this.state, state, null, null, null, 12, null);
|
|
markChanged();
|
|
}
|
|
|
|
@StoreThread
|
|
public final void handleStreamServerUpdate(StreamServerUpdate streamServerUpdate) {
|
|
m.checkNotNullParameter(streamServerUpdate, "streamServerUpdate");
|
|
App.a aVar = App.j;
|
|
SSLSocketFactory sSLSocketFactory = null;
|
|
if (!App.i) {
|
|
sSLSocketFactory = SecureSocketsLayerUtils.createSocketFactory$default(null, 1, null);
|
|
}
|
|
StringBuilder K = a.K("Voice stream update, connect to server w/ endpoint: ");
|
|
K.append(streamServerUpdate.getEndpoint());
|
|
recordBreadcrumb(K.toString());
|
|
RtcConnection rtcConnection = this.rtcConnection;
|
|
if (rtcConnection == null) {
|
|
loge$default(this, "handleStreamServerUpdate() rtcConnection is null.", null, null, 6, null);
|
|
} else {
|
|
rtcConnection.t(new w(rtcConnection, streamServerUpdate.getEndpoint(), streamServerUpdate.getToken(), sSLSocketFactory));
|
|
}
|
|
}
|
|
|
|
public final void init(NetworkMonitor networkMonitor) {
|
|
m.checkNotNullParameter(networkMonitor, "networkMonitor");
|
|
this.networkMonitor = networkMonitor;
|
|
}
|
|
|
|
public final Observable<RtcConnection.Quality> observeConnectionQuality() {
|
|
return ObservationDeck.connectRx$default(this.observationDeck, new ObservationDeck.UpdateSource[]{this}, false, null, null, new StoreStreamRtcConnection$observeConnectionQuality$1(this), 14, null);
|
|
}
|
|
|
|
public final Observable<RtcConnection> observeRtcConnection() {
|
|
return ObservationDeck.connectRx$default(this.observationDeck, new ObservationDeck.UpdateSource[]{this}, false, null, null, new StoreStreamRtcConnection$observeRtcConnection$1(this), 14, null);
|
|
}
|
|
|
|
public final Observable<Float> observeStreamVolume() {
|
|
return ObservationDeck.connectRx$default(this.observationDeck, new ObservationDeck.UpdateSource[]{this}, false, null, null, new StoreStreamRtcConnection$observeStreamVolume$1(this), 14, null);
|
|
}
|
|
|
|
public final void updateFocusedParticipant(Long l) {
|
|
MediaSinkWantsManager mediaSinkWantsManager;
|
|
RtcConnection rtcConnection = this.rtcConnection;
|
|
if (rtcConnection != null && (mediaSinkWantsManager = rtcConnection.F) != null) {
|
|
mediaSinkWantsManager.b(new j(mediaSinkWantsManager, l));
|
|
}
|
|
}
|
|
|
|
public final void updateStreamVolume(float f) {
|
|
this.dispatcher.schedule(new StoreStreamRtcConnection$updateStreamVolume$1(this, f));
|
|
}
|
|
}
|