正在查看: Rilo v2.0.21 应用的 SignalClient.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
正在查看: Rilo v2.0.21 应用的 SignalClient.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
package io.livekit.android.room;
import com.stripe.android.model.PaymentMethodOptionsParams;
import com.stripe.android.networking.FraudDetectionData;
import com.vdurmont.semver4j.Semver;
import io.livekit.android.ConnectOptions;
import io.livekit.android.RoomOptions;
import io.livekit.android.e2ee.E2EEOptions;
import io.livekit.android.room.participant.ParticipantTrackPermission;
import io.livekit.android.room.track.Track;
import io.livekit.android.stats.ClientInfoKt;
import io.livekit.android.stats.NetworkInfo;
import io.livekit.android.util.CloseableCoroutineScope;
import io.livekit.android.util.Either;
import io.livekit.android.util.LKLog;
import io.livekit.android.util.LoggingLevel;
import io.livekit.android.util.UrlUtilsKt;
import io.livekit.android.webrtc.SessionDescriptionExtKt;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Date;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.concurrent.CancellationException;
import javax.inject.Inject;
import javax.inject.Named;
import javax.inject.Singleton;
import kotlin.Metadata;
import kotlin.Pair;
import kotlin.Result;
import kotlin.TuplesKt;
import kotlin.Unit;
import kotlin.collections.ArraysKt;
import kotlin.collections.CollectionsKt;
import kotlin.collections.MapsKt;
import kotlin.coroutines.Continuation;
import kotlin.coroutines.CoroutineContext;
import kotlin.coroutines.intrinsics.IntrinsicsKt;
import kotlin.coroutines.jvm.internal.DebugProbesKt;
import kotlin.jvm.internal.DefaultConstructorMarker;
import kotlin.jvm.internal.Intrinsics;
import kotlinx.coroutines.BuildersKt;
import kotlinx.coroutines.CancellableContinuation;
import kotlinx.coroutines.CancellableContinuationImpl;
import kotlinx.coroutines.CoroutineDispatcher;
import kotlinx.coroutines.CoroutineStart;
import kotlinx.coroutines.Job;
import kotlinx.coroutines.SupervisorKt;
import kotlinx.coroutines.channels.BufferOverflow;
import kotlinx.coroutines.flow.MutableSharedFlow;
import kotlinx.coroutines.flow.SharedFlowKt;
import kotlinx.serialization.StringFormat;
import kotlinx.serialization.json.Json;
import livekit.LivekitModels;
import livekit.LivekitRtc;
import livekit.org.webrtc.IceCandidate;
import livekit.org.webrtc.PeerConnection;
import livekit.org.webrtc.SessionDescription;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.WebSocket;
import okhttp3.WebSocketListener;
import okio.ByteString;
import timber.log.Timber;
@Singleton
@Metadata(d1 = {"\u0000Â\u0002\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\b\u0005\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\u000b\n\u0002\b\u0004\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\u0010\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\u000e\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0005\n\u0002\u0010\t\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\b\u0004\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0010\b\n\u0002\b\n\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u000b\n\u0002\u0010\u0003\n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0018\u0002\n\u0002\b\n\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\b\u0004\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\f\n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0010\u001e\n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0010$\n\u0002\b\u0003\n\u0002\u0010\u0011\n\u0002\u0018\u0002\n\u0002\b\u0004\n\u0002\u0010 \n\u0002\u0018\u0002\n\u0002\b\u0004\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\t\b\u0007\u0018\u0000 «\u00012\u00020\u0001:\u0004«\u0001¬\u0001B1\b\u0007\u0012\u0006\u0010\u0002\u001a\u00020\u0003\u0012\u0006\u0010\u0004\u001a\u00020\u0005\u0012\u0006\u0010\u0006\u001a\u00020\u0007\u0012\b\b\u0001\u0010\b\u001a\u00020\t\u0012\u0006\u0010\n\u001a\u00020\u000b¢\u0006\u0002\u0010\fJ$\u0010B\u001a\u00020!2\b\b\u0002\u0010C\u001a\u00020D2\b\b\u0002\u0010E\u001a\u00020'2\b\b\u0002\u0010F\u001a\u00020\u0018JI\u0010G\u001a\u001a\u0012\u0004\u0012\u00020\u001f\u0012\u0010\u0012\u000e\u0012\u0004\u0012\u00020 \u0012\u0004\u0012\u00020!0\u001e0\u001e2\u0006\u0010H\u001a\u00020'2\u0006\u0010I\u001a\u00020'2\u0006\u0010J\u001a\u00020#2\u0006\u0010K\u001a\u00020%H\u0082@ø\u0001\u0000¢\u0006\u0002\u0010LJ(\u0010M\u001a\u00020'2\u0006\u0010I\u001a\u00020'2\u0006\u0010N\u001a\u00020O2\u0006\u0010J\u001a\u00020#2\u0006\u0010K\u001a\u00020%H\u0002J\u0010\u0010P\u001a\u00020Q2\u0006\u0010R\u001a\u00020SH\u0002J\u0018\u0010T\u001a\u00020!2\u0006\u0010U\u001a\u00020\u00162\u0006\u0010V\u001a\u00020<H\u0002J\u0018\u0010W\u001a\u00020!2\u0006\u0010U\u001a\u00020\u00162\u0006\u0010V\u001a\u00020<H\u0002J\u0018\u0010X\u001a\u00020!2\u0006\u0010E\u001a\u00020'2\u0006\u0010C\u001a\u00020DH\u0002J5\u0010Y\u001a\u00020\u001f2\u0006\u0010H\u001a\u00020'2\u0006\u0010I\u001a\u00020'2\b\b\u0002\u0010J\u001a\u00020#2\b\b\u0002\u0010K\u001a\u00020%H\u0086@ø\u0001\u0000¢\u0006\u0002\u0010LJ \u0010Z\u001a\u00020!2\u0006\u0010[\u001a\u00020\u00162\u0006\u0010C\u001a\u00020D2\u0006\u0010E\u001a\u00020'H\u0016J \u0010\\\u001a\u00020!2\u0006\u0010[\u001a\u00020\u00162\u0006\u0010C\u001a\u00020D2\u0006\u0010E\u001a\u00020'H\u0016J\"\u0010]\u001a\u00020!2\u0006\u0010[\u001a\u00020\u00162\u0006\u0010^\u001a\u00020_2\b\u0010V\u001a\u0004\u0018\u00010`H\u0016J\u0018\u0010a\u001a\u00020!2\u0006\u0010[\u001a\u00020\u00162\u0006\u0010b\u001a\u00020'H\u0016J\u0018\u0010a\u001a\u00020!2\u0006\u0010[\u001a\u00020\u00162\u0006\u0010c\u001a\u00020dH\u0016J\u0006\u0010e\u001a\u00020!J\u0006\u0010f\u001a\u00020!J7\u0010g\u001a\u000e\u0012\u0004\u0012\u00020 \u0012\u0004\u0012\u00020!0\u001e2\u0006\u0010H\u001a\u00020'2\u0006\u0010I\u001a\u00020'2\b\u0010h\u001a\u0004\u0018\u00010'H\u0087@ø\u0001\u0000¢\u0006\u0002\u0010iJ\b\u0010j\u001a\u00020!H\u0002J2\u0010k\u001a\u00020!2\u0006\u0010l\u001a\u00020'2\u0006\u0010m\u001a\u00020'2\u0006\u0010n\u001a\u00020o2\b\u0010p\u001a\u0004\u0018\u00010'2\b\b\u0002\u0010q\u001a\u00020rJ\u000e\u0010s\u001a\u00020!2\u0006\u0010t\u001a\u00020QJ\u0016\u0010u\u001a\u00020!2\u0006\u0010v\u001a\u00020w2\u0006\u0010x\u001a\u00020yJ\u0006\u0010z\u001a\u00020!J\u0016\u0010{\u001a\u00020!2\u0006\u0010|\u001a\u00020'2\u0006\u0010}\u001a\u00020\u0018J\u000e\u0010~\u001a\u00020!2\u0006\u0010\u007f\u001a\u00020QJ\u0007\u0010\u0080\u0001\u001a\u00020/J\u0012\u0010\u0081\u0001\u001a\u00020!2\u0007\u0010\u0082\u0001\u001a\u000206H\u0002J\u0012\u0010\u0083\u0001\u001a\u00020!2\u0007\u0010\u0082\u0001\u001a\u000206H\u0002J\u0019\u0010\u0084\u0001\u001a\u00020!2\b\u0010\u0085\u0001\u001a\u00030\u0086\u0001H\u0000¢\u0006\u0003\b\u0087\u0001J\u0011\u0010\u0088\u0001\u001a\u00020!2\b\u0010\u0089\u0001\u001a\u00030\u008a\u0001J \u0010\u008b\u0001\u001a\u00020!2\u0006\u0010|\u001a\u00020'2\u000f\u0010\u008c\u0001\u001a\n\u0012\u0005\u0012\u00030\u008e\u00010\u008d\u0001J6\u0010\u008f\u0001\u001a\u00020!2\t\u0010\u0090\u0001\u001a\u0004\u0018\u00010'2\b\u0010m\u001a\u0004\u0018\u00010'2\u0018\b\u0002\u0010\u0091\u0001\u001a\u0011\u0012\u0004\u0012\u00020'\u0012\u0004\u0012\u00020'\u0018\u00010\u0092\u0001J.\u0010\u0093\u0001\u001a\u00020!2\u0007\u0010\u0094\u0001\u001a\u00020\u00182\u0016\u0010\u0095\u0001\u001a\f\u0012\u0007\b\u0001\u0012\u00030\u0097\u00010\u0096\u0001\"\u00030\u0097\u0001¢\u0006\u0003\u0010\u0098\u0001J!\u0010\u0099\u0001\u001a\u00020!2\u0007\u0010\u009a\u0001\u001a\u00020\u00182\u000f\u0010\u009b\u0001\u001a\n\u0012\u0005\u0012\u00030\u009d\u00010\u009c\u0001JB\u0010\u009e\u0001\u001a\u00020!2\u0007\u0010\u009f\u0001\u001a\u00020'2\u0007\u0010 \u0001\u001a\u00020\u00182\n\u0010¡\u0001\u001a\u0005\u0018\u00010¢\u00012\n\u0010£\u0001\u001a\u0005\u0018\u00010¤\u00012\t\u0010¥\u0001\u001a\u0004\u0018\u00010D¢\u0006\u0003\u0010¦\u0001J\t\u0010§\u0001\u001a\u00020!H\u0002J\u0012\u0010¨\u0001\u001a\u00020!2\u0007\u0010©\u0001\u001a\u00020/H\u0002J\t\u0010ª\u0001\u001a\u00020!H\u0002R\u001a\u0010\r\u001a\u00020\u000eX\u0086\u000e¢\u0006\u000e\n\u0000\u001a\u0004\b\u000f\u0010\u0010\"\u0004\b\u0011\u0010\u0012R\u000e\u0010\u0013\u001a\u00020\u0014X\u0082.¢\u0006\u0002\n\u0000R\u0010\u0010\u0015\u001a\u0004\u0018\u00010\u0016X\u0082\u000e¢\u0006\u0002\n\u0000R\u000e\u0010\b\u001a\u00020\tX\u0082\u0004¢\u0006\u0002\n\u0000R\u001e\u0010\u0019\u001a\u00020\u00182\u0006\u0010\u0017\u001a\u00020\u0018@BX\u0086\u000e¢\u0006\b\n\u0000\u001a\u0004\b\u0019\u0010\u001aR\u000e\u0010\u001b\u001a\u00020\u0018X\u0082\u000e¢\u0006\u0002\n\u0000R.\u0010\u001c\u001a\"\u0012\u001c\u0012\u001a\u0012\u0004\u0012\u00020\u001f\u0012\u0010\u0012\u000e\u0012\u0004\u0012\u00020 \u0012\u0004\u0012\u00020!0\u001e0\u001e\u0018\u00010\u001dX\u0082\u000e¢\u0006\u0002\n\u0000R\u000e\u0010\u0004\u001a\u00020\u0005X\u0082\u0004¢\u0006\u0002\n\u0000R\u0010\u0010\"\u001a\u0004\u0018\u00010#X\u0082\u000e¢\u0006\u0002\n\u0000R\u0010\u0010$\u001a\u0004\u0018\u00010%X\u0082\u000e¢\u0006\u0002\n\u0000R\u0010\u0010&\u001a\u0004\u0018\u00010'X\u0082\u000e¢\u0006\u0002\n\u0000R\u001c\u0010(\u001a\u0004\u0018\u00010)X\u0086\u000e¢\u0006\u000e\n\u0000\u001a\u0004\b*\u0010+\"\u0004\b,\u0010-R\u000e\u0010\n\u001a\u00020\u000bX\u0082\u0004¢\u0006\u0002\n\u0000R\u000e\u0010\u0006\u001a\u00020\u0007X\u0082\u0004¢\u0006\u0002\n\u0000R\u000e\u0010.\u001a\u00020/X\u0082\u000e¢\u0006\u0002\n\u0000R\u0010\u00100\u001a\u0004\u0018\u000101X\u0082\u000e¢\u0006\u0002\n\u0000R\u000e\u00102\u001a\u00020/X\u0082\u000e¢\u0006\u0002\n\u0000R\u0010\u00103\u001a\u0004\u0018\u000101X\u0082\u000e¢\u0006\u0002\n\u0000R\u0014\u00104\u001a\b\u0012\u0004\u0012\u00020605X\u0082\u0004¢\u0006\u0002\n\u0000R\u0010\u00107\u001a\u0004\u0018\u000101X\u0082\u000e¢\u0006\u0002\n\u0000R\u000e\u00108\u001a\u000209X\u0082\u0004¢\u0006\u0002\n\u0000R \u0010:\u001a\u0014\u0012\u0010\u0012\u000e\u0012\u0004\u0012\u00020\u0016\u0012\u0004\u0012\u00020<0;05X\u0082\u0004¢\u0006\u0002\n\u0000R\u0010\u0010=\u001a\u0004\u0018\u000101X\u0082\u000e¢\u0006\u0002\n\u0000R\u000e\u0010>\u001a\u000209X\u0082\u0004¢\u0006\u0002\n\u0000R\u000e\u0010?\u001a\u00020/X\u0082\u000e¢\u0006\u0002\n\u0000R\u0010\u0010@\u001a\u0004\u0018\u00010AX\u0082\u000e¢\u0006\u0002\n\u0000R\u000e\u0010\u0002\u001a\u00020\u0003X\u0082\u0004¢\u0006\u0002\n\u0000\u0082\u0002\u0004\n\u0002\b\u0019¨\u0006\u00ad\u0001"}, d2 = {"Lio/livekit/android/room/SignalClient;", "Lokhttp3/WebSocketListener;", "websocketFactory", "Lokhttp3/WebSocket$Factory;", "json", "Lkotlinx/serialization/json/Json;", "okHttpClient", "Lokhttp3/OkHttpClient;", "ioDispatcher", "Lkotlinx/coroutines/CoroutineDispatcher;", "networkInfo", "Lio/livekit/android/stats/NetworkInfo;", "(Lokhttp3/WebSocket$Factory;Lkotlinx/serialization/json/Json;Lokhttp3/OkHttpClient;Lkotlinx/coroutines/CoroutineDispatcher;Lio/livekit/android/stats/NetworkInfo;)V", "connectionState", "Lio/livekit/android/room/ConnectionState;", "getConnectionState", "()Lio/livekit/android/room/ConnectionState;", "setConnectionState", "(Lio/livekit/android/room/ConnectionState;)V", "coroutineScope", "Lio/livekit/android/util/CloseableCoroutineScope;", "currentWs", "Lokhttp3/WebSocket;", "<set-?>", "", "isConnected", "()Z", "isReconnecting", "joinContinuation", "Lkotlinx/coroutines/CancellableContinuation;", "Lio/livekit/android/util/Either;", "Llivekit/LivekitRtc$JoinResponse;", "Llivekit/LivekitRtc$ReconnectResponse;", "", "lastOptions", "Lio/livekit/android/ConnectOptions;", "lastRoomOptions", "Lio/livekit/android/RoomOptions;", "lastUrl", "", "listener", "Lio/livekit/android/room/SignalClient$Listener;", "getListener", "()Lio/livekit/android/room/SignalClient$Listener;", "setListener", "(Lio/livekit/android/room/SignalClient$Listener;)V", "pingIntervalDurationMillis", "", "pingJob", "Lkotlinx/coroutines/Job;", "pingTimeoutDurationMillis", "pongJob", "requestFlow", "Lkotlinx/coroutines/flow/MutableSharedFlow;", "Llivekit/LivekitRtc$SignalRequest;", "requestFlowJob", "requestFlowJobLock", "Ljava/lang/Object;", "responseFlow", "Lkotlin/Pair;", "Llivekit/LivekitRtc$SignalResponse;", "responseFlowJob", "responseFlowJobLock", "rtt", "serverVersion", "Lcom/vdurmont/semver4j/Semver;", "close", PaymentMethodOptionsParams.Blik.PARAM_CODE, "", "reason", "shouldClearQueuedRequests", "connect", "url", "token", "options", "roomOptions", "(Ljava/lang/String;Ljava/lang/String;Lio/livekit/android/ConnectOptions;Lio/livekit/android/RoomOptions;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;", "createConnectionParams", "clientInfo", "Llivekit/LivekitModels$ClientInfo;", "fromProtoSessionDescription", "Llivekit/org/webrtc/SessionDescription;", "sd", "Llivekit/LivekitRtc$SessionDescription;", "handleSignalResponse", "ws", "response", "handleSignalResponseImpl", "handleWebSocketClose", "join", "onClosed", "webSocket", "onClosing", "onFailure", "t", "", "Lokhttp3/Response;", "onMessage", "text", "bytes", "Lokio/ByteString;", "onPCConnected", "onReadyForResponses", SignalClient.CONNECT_QUERY_RECONNECT, "participantSid", "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;", "resetPingTimeout", "sendAddTrack", "cid", "name", "type", "Llivekit/LivekitModels$TrackType;", "stream", "builder", "Llivekit/LivekitRtc$AddTrackRequest$Builder;", "sendAnswer", SignalClient.SD_TYPE_ANSWER, "sendCandidate", "candidate", "Llivekit/org/webrtc/IceCandidate;", "target", "Llivekit/LivekitRtc$SignalTarget;", "sendLeave", "sendMuteTrack", "trackSid", "muted", "sendOffer", SignalClient.SD_TYPE_OFFER, "sendPing", "sendRequest", "request", "sendRequestImpl", "sendSimulateScenario", "scenario", "Llivekit/LivekitRtc$SimulateScenario;", "sendSimulateScenario$livekit_android_sdk_release", "sendSyncState", "syncState", "Llivekit/LivekitRtc$SyncState;", "sendUpdateLocalAudioTrack", "features", "", "Llivekit/LivekitModels$AudioTrackFeature;", "sendUpdateLocalMetadata", "metadata", "attributes", "", "sendUpdateSubscription", "subscribe", "participantTracks", "", "Llivekit/LivekitModels$ParticipantTracks;", "(Z[Llivekit/LivekitModels$ParticipantTracks;)V", "sendUpdateSubscriptionPermissions", "allParticipants", "participantTrackPermissions", "", "Lio/livekit/android/room/participant/ParticipantTrackPermission;", "sendUpdateTrackSettings", SignalClient.CONNECT_QUERY_PARTICIPANT_SID, "disabled", "videoDimensions", "Lio/livekit/android/room/track/Track$Dimensions;", "videoQuality", "Llivekit/LivekitModels$VideoQuality;", "fps", "(Ljava/lang/String;ZLio/livekit/android/room/track/Track$Dimensions;Llivekit/LivekitModels$VideoQuality;Ljava/lang/Integer;)V", "startPingJob", "startPingTimeout", FraudDetectionData.KEY_TIMESTAMP, "startRequestQueue", "Companion", "Listener", "livekit-android-sdk_release"}, k = 1, mv = {1, 8, 0}, xi = 48)
public final class SignalClient extends WebSocketListener {
public static final int CLOSE_REASON_NORMAL_CLOSURE = 1000;
public static final int CLOSE_REASON_PING_TIMEOUT = 3000;
public static final int CLOSE_REASON_WEBSOCKET_FAILURE = 3500;
public static final String CONNECT_QUERY_ADAPTIVE_STREAM = "adaptive_stream";
public static final String CONNECT_QUERY_AUTOSUBSCRIBE = "auto_subscribe";
public static final String CONNECT_QUERY_DEVICE_MODEL = "device_model";
public static final String CONNECT_QUERY_NETWORK_TYPE = "network";
public static final String CONNECT_QUERY_OS = "os";
public static final String CONNECT_QUERY_OS_VERSION = "os_version";
public static final String CONNECT_QUERY_PARTICIPANT_SID = "sid";
public static final String CONNECT_QUERY_PROTOCOL = "protocol";
public static final String CONNECT_QUERY_RECONNECT = "reconnect";
public static final String CONNECT_QUERY_SDK = "sdk";
public static final String CONNECT_QUERY_TOKEN = "access_token";
public static final String CONNECT_QUERY_VERSION = "version";
public static final Companion INSTANCE;
private static final List<PeerConnection.IceServer> DEFAULT_ICE_SERVERS;
public static final String SDK_TYPE = "android";
public static final String SD_TYPE_ANSWER = "answer";
public static final String SD_TYPE_OFFER = "offer";
public static final String SD_TYPE_PRANSWER = "pranswer";
private static final List<LivekitRtc.SignalRequest.MessageCase> skipQueueTypes;
private ConnectionState connectionState;
private CloseableCoroutineScope coroutineScope;
private WebSocket currentWs;
private final CoroutineDispatcher ioDispatcher;
private boolean isConnected;
private boolean isReconnecting;
private CancellableContinuation<? super Either<LivekitRtc.JoinResponse, ? extends Either<LivekitRtc.ReconnectResponse, Unit>>> joinContinuation;
private final Json json;
private ConnectOptions lastOptions;
private RoomOptions lastRoomOptions;
private String lastUrl;
private Listener listener;
private final NetworkInfo networkInfo;
private final OkHttpClient okHttpClient;
private long pingIntervalDurationMillis;
private Job pingJob;
private long pingTimeoutDurationMillis;
private Job pongJob;
private final MutableSharedFlow<LivekitRtc.SignalRequest> requestFlow;
private Job requestFlowJob;
private final Object requestFlowJobLock;
private final MutableSharedFlow<Pair<WebSocket, LivekitRtc.SignalResponse>> responseFlow;
private Job responseFlowJob;
private final Object responseFlowJobLock;
private long rtt;
private Semver serverVersion;
private final WebSocket.Factory websocketFactory;
@Metadata(d1 = {"\u0000\u009e\u0001\n\u0002\u0018\u0002\n\u0002\u0010\u0000\n\u0000\n\u0002\u0010\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0010\u000e\n\u0000\n\u0002\u0010\b\n\u0002\b\u0002\n\u0002\u0010 \n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0010\u0003\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\b\u0005\n\u0002\u0010\u000b\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\bf\u0018\u00002\u00020\u0001J\u0010\u0010\u0002\u001a\u00020\u00032\u0006\u0010\u0004\u001a\u00020\u0005H&J\u0018\u0010\u0006\u001a\u00020\u00032\u0006\u0010\u0007\u001a\u00020\b2\u0006\u0010\t\u001a\u00020\nH&J\u0016\u0010\u000b\u001a\u00020\u00032\f\u0010\f\u001a\b\u0012\u0004\u0012\u00020\u000e0\rH&J\u0010\u0010\u000f\u001a\u00020\u00032\u0006\u0010\u0010\u001a\u00020\u0011H&J\u0010\u0010\u0012\u001a\u00020\u00032\u0006\u0010\u0013\u001a\u00020\u0014H&J\u0010\u0010\u0015\u001a\u00020\u00032\u0006\u0010\u0016\u001a\u00020\u0017H&J\u0010\u0010\u0018\u001a\u00020\u00032\u0006\u0010\u0019\u001a\u00020\u001aH&J\u0010\u0010\u001b\u001a\u00020\u00032\u0006\u0010\u001c\u001a\u00020\u001dH&J\u0010\u0010\u001e\u001a\u00020\u00032\u0006\u0010\u0004\u001a\u00020\u0005H&J\u0016\u0010\u001f\u001a\u00020\u00032\f\u0010\f\u001a\b\u0012\u0004\u0012\u00020 0\rH&J\u0010\u0010!\u001a\u00020\u00032\u0006\u0010\"\u001a\u00020\bH&J\u0018\u0010#\u001a\u00020\u00032\u0006\u0010$\u001a\u00020\b2\u0006\u0010%\u001a\u00020&H&J\u0010\u0010'\u001a\u00020\u00032\u0006\u0010(\u001a\u00020)H&J\u0016\u0010*\u001a\u00020\u00032\f\u0010+\u001a\b\u0012\u0004\u0012\u00020,0\rH&J\u0016\u0010-\u001a\u00020\u00032\f\u0010.\u001a\b\u0012\u0004\u0012\u00020/0\rH&J\u0010\u00100\u001a\u00020\u00032\u0006\u00101\u001a\u000202H&J\u0010\u00103\u001a\u00020\u00032\u0006\u00104\u001a\u000205H&J\u0018\u00106\u001a\u00020\u00032\u0006\u00107\u001a\u0002082\u0006\u00109\u001a\u00020:H&¨\u0006;"}, d2 = {"Lio/livekit/android/room/SignalClient$Listener;", "", "onAnswer", "", "sessionDescription", "Llivekit/org/webrtc/SessionDescription;", "onClose", "reason", "", PaymentMethodOptionsParams.Blik.PARAM_CODE, "", "onConnectionQuality", "updates", "", "Llivekit/LivekitRtc$ConnectionQualityInfo;", "onError", "error", "", "onLeave", "leave", "Llivekit/LivekitRtc$LeaveRequest;", "onLocalTrackPublished", "response", "Llivekit/LivekitRtc$TrackPublishedResponse;", "onLocalTrackSubscribed", "trackSubscribed", "Llivekit/LivekitRtc$TrackSubscribed;", "onLocalTrackUnpublished", "trackUnpublished", "Llivekit/LivekitRtc$TrackUnpublishedResponse;", "onOffer", "onParticipantUpdate", "Llivekit/LivekitModels$ParticipantInfo;", "onRefreshToken", "token", "onRemoteMuteChanged", "trackSid", "muted", "", "onRoomUpdate", "update", "Llivekit/LivekitModels$Room;", "onSpeakersChanged", "speakers", "Llivekit/LivekitModels$SpeakerInfo;", "onStreamStateUpdate", "streamStates", "Llivekit/LivekitRtc$StreamStateInfo;", "onSubscribedQualityUpdate", "subscribedQualityUpdate", "Llivekit/LivekitRtc$SubscribedQualityUpdate;", "onSubscriptionPermissionUpdate", "subscriptionPermissionUpdate", "Llivekit/LivekitRtc$SubscriptionPermissionUpdate;", "onTrickle", "candidate", "Llivekit/org/webrtc/IceCandidate;", "target", "Llivekit/LivekitRtc$SignalTarget;", "livekit-android-sdk_release"}, k = 1, mv = {1, 8, 0}, xi = 48)
public interface Listener {
void onAnswer(SessionDescription sessionDescription);
void onClose(String reason, int code);
void onConnectionQuality(List<LivekitRtc.ConnectionQualityInfo> updates);
void onError(Throwable error);
void onLeave(LivekitRtc.LeaveRequest leave);
void onLocalTrackPublished(LivekitRtc.TrackPublishedResponse response);
void onLocalTrackSubscribed(LivekitRtc.TrackSubscribed trackSubscribed);
void onLocalTrackUnpublished(LivekitRtc.TrackUnpublishedResponse trackUnpublished);
void onOffer(SessionDescription sessionDescription);
void onParticipantUpdate(List<LivekitModels.ParticipantInfo> updates);
void onRefreshToken(String token);
void onRemoteMuteChanged(String trackSid, boolean muted);
void onRoomUpdate(LivekitModels.Room update);
void onSpeakersChanged(List<LivekitModels.SpeakerInfo> speakers);
void onStreamStateUpdate(List<LivekitRtc.StreamStateInfo> streamStates);
void onSubscribedQualityUpdate(LivekitRtc.SubscribedQualityUpdate subscribedQualityUpdate);
void onSubscriptionPermissionUpdate(LivekitRtc.SubscriptionPermissionUpdate subscriptionPermissionUpdate);
void onTrickle(IceCandidate candidate, LivekitRtc.SignalTarget target);
}
@Metadata(k = 3, mv = {1, 8, 0}, xi = 48)
public class WhenMappings {
public static final int[] $EnumSwitchMapping$0;
static {
int[] iArr = new int[LivekitRtc.SignalResponse.MessageCase.values().length];
try {
iArr[LivekitRtc.SignalResponse.MessageCase.ANSWER.ordinal()] = 1;
} catch (NoSuchFieldError unused) {
}
try {
iArr[LivekitRtc.SignalResponse.MessageCase.OFFER.ordinal()] = 2;
} catch (NoSuchFieldError unused2) {
}
try {
iArr[LivekitRtc.SignalResponse.MessageCase.TRICKLE.ordinal()] = 3;
} catch (NoSuchFieldError unused3) {
}
try {
iArr[LivekitRtc.SignalResponse.MessageCase.UPDATE.ordinal()] = 4;
} catch (NoSuchFieldError unused4) {
}
try {
iArr[LivekitRtc.SignalResponse.MessageCase.TRACK_SUBSCRIBED.ordinal()] = 5;
} catch (NoSuchFieldError unused5) {
}
try {
iArr[LivekitRtc.SignalResponse.MessageCase.TRACK_PUBLISHED.ordinal()] = 6;
} catch (NoSuchFieldError unused6) {
}
try {
iArr[LivekitRtc.SignalResponse.MessageCase.SPEAKERS_CHANGED.ordinal()] = 7;
} catch (NoSuchFieldError unused7) {
}
try {
iArr[LivekitRtc.SignalResponse.MessageCase.JOIN.ordinal()] = 8;
} catch (NoSuchFieldError unused8) {
}
try {
iArr[LivekitRtc.SignalResponse.MessageCase.LEAVE.ordinal()] = 9;
} catch (NoSuchFieldError unused9) {
}
try {
iArr[LivekitRtc.SignalResponse.MessageCase.MUTE.ordinal()] = 10;
} catch (NoSuchFieldError unused10) {
}
try {
iArr[LivekitRtc.SignalResponse.MessageCase.ROOM_UPDATE.ordinal()] = 11;
} catch (NoSuchFieldError unused11) {
}
try {
iArr[LivekitRtc.SignalResponse.MessageCase.CONNECTION_QUALITY.ordinal()] = 12;
} catch (NoSuchFieldError unused12) {
}
try {
iArr[LivekitRtc.SignalResponse.MessageCase.STREAM_STATE_UPDATE.ordinal()] = 13;
} catch (NoSuchFieldError unused13) {
}
try {
iArr[LivekitRtc.SignalResponse.MessageCase.SUBSCRIBED_QUALITY_UPDATE.ordinal()] = 14;
} catch (NoSuchFieldError unused14) {
}
try {
iArr[LivekitRtc.SignalResponse.MessageCase.SUBSCRIPTION_PERMISSION_UPDATE.ordinal()] = 15;
} catch (NoSuchFieldError unused15) {
}
try {
iArr[LivekitRtc.SignalResponse.MessageCase.REFRESH_TOKEN.ordinal()] = 16;
} catch (NoSuchFieldError unused16) {
}
try {
iArr[LivekitRtc.SignalResponse.MessageCase.TRACK_UNPUBLISHED.ordinal()] = 17;
} catch (NoSuchFieldError unused17) {
}
try {
iArr[LivekitRtc.SignalResponse.MessageCase.PONG.ordinal()] = 18;
} catch (NoSuchFieldError unused18) {
}
try {
iArr[LivekitRtc.SignalResponse.MessageCase.PONG_RESP.ordinal()] = 19;
} catch (NoSuchFieldError unused19) {
}
try {
iArr[LivekitRtc.SignalResponse.MessageCase.RECONNECT.ordinal()] = 20;
} catch (NoSuchFieldError unused20) {
}
try {
iArr[LivekitRtc.SignalResponse.MessageCase.SUBSCRIPTION_RESPONSE.ordinal()] = 21;
} catch (NoSuchFieldError unused21) {
}
try {
iArr[LivekitRtc.SignalResponse.MessageCase.REQUEST_RESPONSE.ordinal()] = 22;
} catch (NoSuchFieldError unused22) {
}
try {
iArr[LivekitRtc.SignalResponse.MessageCase.MESSAGE_NOT_SET.ordinal()] = 23;
} catch (NoSuchFieldError unused23) {
}
$EnumSwitchMapping$0 = iArr;
}
}
@Inject
public SignalClient(WebSocket.Factory factory, Json json, OkHttpClient okHttpClient, @Named("dispatcher_io") CoroutineDispatcher coroutineDispatcher, NetworkInfo networkInfo) {
Intrinsics.checkNotNullParameter(factory, "websocketFactory");
Intrinsics.checkNotNullParameter(json, "json");
Intrinsics.checkNotNullParameter(okHttpClient, "okHttpClient");
Intrinsics.checkNotNullParameter(coroutineDispatcher, "ioDispatcher");
Intrinsics.checkNotNullParameter(networkInfo, "networkInfo");
this.websocketFactory = factory;
this.json = json;
this.okHttpClient = okHttpClient;
this.ioDispatcher = coroutineDispatcher;
this.networkInfo = networkInfo;
this.requestFlow = SharedFlowKt.MutableSharedFlow$default(Integer.MAX_VALUE, 0, (BufferOverflow) null, 6, (Object) null);
this.requestFlowJobLock = new Object();
this.responseFlow = SharedFlowKt.MutableSharedFlow$default(Integer.MAX_VALUE, 0, (BufferOverflow) null, 6, (Object) null);
this.responseFlowJobLock = new Object();
this.connectionState = ConnectionState.DISCONNECTED;
}
public final boolean getIsConnected() {
return this.isConnected;
}
public final Listener getListener() {
return this.listener;
}
public final void setListener(Listener listener) {
this.listener = listener;
}
public final ConnectionState getConnectionState() {
return this.connectionState;
}
public final void setConnectionState(ConnectionState connectionState) {
Intrinsics.checkNotNullParameter(connectionState, "<set-?>");
this.connectionState = connectionState;
}
public final java.lang.Object join(java.lang.String r8, java.lang.String r9, io.livekit.android.ConnectOptions r10, io.livekit.android.RoomOptions r11, kotlin.coroutines.Continuation<? super livekit.LivekitRtc.JoinResponse> r12) throws java.lang.Exception {
throw new UnsupportedOperationException("Method not decompiled: io.livekit.android.room.SignalClient.join(java.lang.String, java.lang.String, io.livekit.android.ConnectOptions, io.livekit.android.RoomOptions, kotlin.coroutines.Continuation):java.lang.Object");
}
public final java.lang.Object reconnect(java.lang.String r27, java.lang.String r28, java.lang.String r29, kotlin.coroutines.Continuation<? super io.livekit.android.util.Either<livekit.LivekitRtc.ReconnectResponse, kotlin.Unit>> r30) throws java.lang.Exception {
throw new UnsupportedOperationException("Method not decompiled: io.livekit.android.room.SignalClient.reconnect(java.lang.String, java.lang.String, java.lang.String, kotlin.coroutines.Continuation):java.lang.Object");
}
public final Object connect(String str, String str2, ConnectOptions connectOptions, RoomOptions roomOptions, Continuation<? super Either<LivekitRtc.JoinResponse, ? extends Either<LivekitRtc.ReconnectResponse, Unit>>> continuation) {
close$default(this, 0, "Starting new connection", false, 1, null);
StringBuilder sb = new StringBuilder();
sb.append(UrlUtilsKt.toWebsocketUrl(str));
sb.append("/rtc");
LivekitModels.ClientInfo clientInfo = ClientInfoKt.getClientInfo();
Intrinsics.checkNotNullExpressionValue(clientInfo, "getClientInfo()");
sb.append(createConnectionParams(str2, clientInfo, connectOptions, roomOptions));
String sb2 = sb.toString();
this.isReconnecting = connectOptions.getReconnect();
LKLog.Companion companion = LKLog.INSTANCE;
if (LoggingLevel.INFO.compareTo(LKLog.INSTANCE.getLoggingLevel()) >= 0 && Timber.treeCount() > 0) {
Timber.i((Throwable) null, "connecting to " + sb2, new Object[0]);
}
this.coroutineScope = new CloseableCoroutineScope(SupervisorKt.SupervisorJob$default((Job) null, 1, (Object) null).plus(this.ioDispatcher));
this.lastUrl = sb2;
this.lastOptions = connectOptions;
this.lastRoomOptions = roomOptions;
Request build = new Request.Builder().url(sb2).build();
CancellableContinuation cancellableContinuationImpl = new CancellableContinuationImpl(IntrinsicsKt.intercepted(continuation), 1);
cancellableContinuationImpl.initCancellability();
this.joinContinuation = cancellableContinuationImpl;
this.currentWs = this.websocketFactory.newWebSocket(build, this);
Object result = cancellableContinuationImpl.getResult();
if (result == IntrinsicsKt.getCOROUTINE_SUSPENDED()) {
DebugProbesKt.probeCoroutineSuspended(continuation);
}
return result;
}
private final String createConnectionParams(String token, LivekitModels.ClientInfo clientInfo, ConnectOptions options, RoomOptions roomOptions) {
ArrayList arrayList = new ArrayList();
arrayList.add(TuplesKt.to(CONNECT_QUERY_TOKEN, token));
arrayList.add(TuplesKt.to(CONNECT_QUERY_PROTOCOL, String.valueOf(options.getProtocolVersion().getValue())));
if (options.getReconnect()) {
arrayList.add(TuplesKt.to(CONNECT_QUERY_RECONNECT, "1"));
String participantSid = options.getParticipantSid();
if (participantSid != null) {
arrayList.add(TuplesKt.to(CONNECT_QUERY_PARTICIPANT_SID, participantSid));
}
}
arrayList.add(TuplesKt.to(CONNECT_QUERY_AUTOSUBSCRIBE, String.valueOf(options.getAutoSubscribe() ? 1 : 0)));
arrayList.add(TuplesKt.to(CONNECT_QUERY_ADAPTIVE_STREAM, String.valueOf(roomOptions.getAdaptiveStream() ? 1 : 0)));
arrayList.add(TuplesKt.to(CONNECT_QUERY_SDK, SDK_TYPE));
arrayList.add(TuplesKt.to(CONNECT_QUERY_VERSION, clientInfo.getVersion()));
arrayList.add(TuplesKt.to(CONNECT_QUERY_DEVICE_MODEL, clientInfo.getDeviceModel()));
arrayList.add(TuplesKt.to(CONNECT_QUERY_OS, clientInfo.getOs()));
arrayList.add(TuplesKt.to(CONNECT_QUERY_OS_VERSION, clientInfo.getOsVersion()));
arrayList.add(TuplesKt.to(CONNECT_QUERY_NETWORK_TYPE, this.networkInfo.getNetworkType().getProtoName()));
int i2 = 0;
String str = "";
for (Object obj : arrayList) {
int i3 = i2 + 1;
if (i2 < 0) {
CollectionsKt.throwIndexOverflow();
}
Pair pair = (Pair) obj;
str = str + (i2 == 0 ? "?" : "&") + ((String) pair.getFirst()) + '=' + ((String) pair.getSecond());
i2 = i3;
}
return str;
}
public final void onReadyForResponses() {
if (this.responseFlowJob != null) {
return;
}
synchronized (this.responseFlowJobLock) {
if (this.responseFlowJob == null) {
CloseableCoroutineScope closeableCoroutineScope = this.coroutineScope;
if (closeableCoroutineScope == null) {
Intrinsics.throwUninitializedPropertyAccessException("coroutineScope");
closeableCoroutineScope = null;
}
this.responseFlowJob = BuildersKt.launch$default(closeableCoroutineScope, (CoroutineContext) null, (CoroutineStart) null, new SignalClient$onReadyForResponses$1$1(this, null), 3, (Object) null);
}
Unit unit = Unit.INSTANCE;
}
}
private final void startRequestQueue() {
if (this.requestFlowJob != null) {
return;
}
synchronized (this.requestFlowJobLock) {
if (this.requestFlowJob == null) {
CloseableCoroutineScope closeableCoroutineScope = this.coroutineScope;
if (closeableCoroutineScope == null) {
Intrinsics.throwUninitializedPropertyAccessException("coroutineScope");
closeableCoroutineScope = null;
}
this.requestFlowJob = BuildersKt.launch$default(closeableCoroutineScope, (CoroutineContext) null, (CoroutineStart) null, new SignalClient$startRequestQueue$1$1(this, null), 3, (Object) null);
}
Unit unit = Unit.INSTANCE;
}
}
public final void onPCConnected() {
startRequestQueue();
}
public void onMessage(WebSocket webSocket, String text) {
Intrinsics.checkNotNullParameter(webSocket, "webSocket");
Intrinsics.checkNotNullParameter(text, "text");
if (Intrinsics.areEqual(webSocket, this.currentWs)) {
LKLog.Companion companion = LKLog.INSTANCE;
if (LoggingLevel.WARN.compareTo(LKLog.INSTANCE.getLoggingLevel()) < 0 || Timber.treeCount() <= 0) {
return;
}
Timber.w((Throwable) null, "received JSON message, unsupported in this version.", new Object[0]);
}
}
public void onMessage(WebSocket webSocket, ByteString bytes) {
Intrinsics.checkNotNullParameter(webSocket, "webSocket");
Intrinsics.checkNotNullParameter(bytes, "bytes");
if (Intrinsics.areEqual(webSocket, this.currentWs)) {
LivekitRtc.SignalResponse signalResponse = (LivekitRtc.SignalResponse) LivekitRtc.SignalResponse.newBuilder().mergeFrom(bytes.toByteArray()).build();
Intrinsics.checkNotNullExpressionValue(signalResponse, "response");
handleSignalResponse(webSocket, signalResponse);
}
}
public void onClosed(WebSocket webSocket, int code, String reason) {
Intrinsics.checkNotNullParameter(webSocket, "webSocket");
Intrinsics.checkNotNullParameter(reason, "reason");
if (Intrinsics.areEqual(webSocket, this.currentWs)) {
handleWebSocketClose(reason, code);
}
}
public void onClosing(WebSocket webSocket, int code, String reason) {
Intrinsics.checkNotNullParameter(webSocket, "webSocket");
Intrinsics.checkNotNullParameter(reason, "reason");
LKLog.Companion companion = LKLog.INSTANCE;
if (LoggingLevel.VERBOSE.compareTo(LKLog.INSTANCE.getLoggingLevel()) < 0 || Timber.treeCount() <= 0) {
return;
}
Timber.v((Throwable) null, "websocket closing", new Object[0]);
}
public void onFailure(okhttp3.WebSocket r10, java.lang.Throwable r11, okhttp3.Response r12) {
throw new UnsupportedOperationException("Method not decompiled: io.livekit.android.room.SignalClient.onFailure(okhttp3.WebSocket, java.lang.Throwable, okhttp3.Response):void");
}
private final void handleWebSocketClose(String reason, int code) {
LKLog.Companion companion = LKLog.INSTANCE;
if (LoggingLevel.VERBOSE.compareTo(LKLog.INSTANCE.getLoggingLevel()) >= 0 && Timber.treeCount() > 0) {
Timber.v((Throwable) null, "websocket closed", new Object[0]);
}
this.isConnected = false;
Listener listener = this.listener;
if (listener != null) {
listener.onClose(reason, code);
}
this.requestFlow.resetReplayCache();
this.responseFlow.resetReplayCache();
Job job = this.pingJob;
if (job != null) {
Job.DefaultImpls.cancel$default(job, (CancellationException) null, 1, (Object) null);
}
Job job2 = this.pongJob;
if (job2 != null) {
Job.DefaultImpls.cancel$default(job2, (CancellationException) null, 1, (Object) null);
}
}
private final SessionDescription fromProtoSessionDescription(LivekitRtc.SessionDescription sd) {
SessionDescription.Type type;
String type2 = sd.getType();
if (type2 != null) {
int hashCode = type2.hashCode();
if (hashCode != -1412808770) {
if (hashCode != -1395375040) {
if (hashCode == 105650780 && type2.equals(SD_TYPE_OFFER)) {
type = SessionDescription.Type.OFFER;
return new SessionDescription(type, sd.getSdp());
}
} else if (type2.equals(SD_TYPE_PRANSWER)) {
type = SessionDescription.Type.PRANSWER;
return new SessionDescription(type, sd.getSdp());
}
} else if (type2.equals(SD_TYPE_ANSWER)) {
type = SessionDescription.Type.ANSWER;
return new SessionDescription(type, sd.getSdp());
}
}
throw new IllegalArgumentException("invalid RTC SdpType: " + sd.getType());
}
public final void sendOffer(SessionDescription offer) {
Intrinsics.checkNotNullParameter(offer, SD_TYPE_OFFER);
LivekitRtc.SignalRequest signalRequest = (LivekitRtc.SignalRequest) LivekitRtc.SignalRequest.newBuilder().setOffer(SessionDescriptionExtKt.toProtoSessionDescription(offer)).build();
Intrinsics.checkNotNullExpressionValue(signalRequest, "request");
sendRequest(signalRequest);
}
public final void sendAnswer(SessionDescription answer) {
Intrinsics.checkNotNullParameter(answer, SD_TYPE_ANSWER);
LivekitRtc.SignalRequest signalRequest = (LivekitRtc.SignalRequest) LivekitRtc.SignalRequest.newBuilder().setAnswer(SessionDescriptionExtKt.toProtoSessionDescription(answer)).build();
Intrinsics.checkNotNullExpressionValue(signalRequest, "request");
sendRequest(signalRequest);
}
public final void sendCandidate(IceCandidate candidate, LivekitRtc.SignalTarget target) {
Intrinsics.checkNotNullParameter(candidate, "candidate");
Intrinsics.checkNotNullParameter(target, "target");
String str = candidate.sdp;
String str2 = candidate.sdpMid;
int i2 = candidate.sdpMLineIndex;
Intrinsics.checkNotNullExpressionValue(str, "sdp");
IceCandidateJSON iceCandidateJSON = new IceCandidateJSON(str, i2, str2);
LivekitRtc.TrickleRequest.Builder newBuilder = LivekitRtc.TrickleRequest.newBuilder();
StringFormat stringFormat = this.json;
stringFormat.getSerializersModule();
LivekitRtc.SignalRequest signalRequest = (LivekitRtc.SignalRequest) LivekitRtc.SignalRequest.newBuilder().setTrickle(newBuilder.setCandidateInit(stringFormat.encodeToString(IceCandidateJSON.INSTANCE.serializer(), iceCandidateJSON)).setTarget(target).build()).build();
Intrinsics.checkNotNullExpressionValue(signalRequest, "request");
sendRequest(signalRequest);
}
public final void sendMuteTrack(String trackSid, boolean muted) {
Intrinsics.checkNotNullParameter(trackSid, "trackSid");
LivekitRtc.SignalRequest signalRequest = (LivekitRtc.SignalRequest) LivekitRtc.SignalRequest.newBuilder().setMute(LivekitRtc.MuteTrackRequest.newBuilder().setSid(trackSid).setMuted(muted).build()).build();
Intrinsics.checkNotNullExpressionValue(signalRequest, "request");
sendRequest(signalRequest);
}
public static void sendAddTrack$default(SignalClient signalClient, String str, String str2, LivekitModels.TrackType trackType, String str3, LivekitRtc.AddTrackRequest.Builder builder, int i2, Object obj) {
if ((i2 & 16) != 0) {
builder = LivekitRtc.AddTrackRequest.newBuilder();
Intrinsics.checkNotNullExpressionValue(builder, "newBuilder()");
}
signalClient.sendAddTrack(str, str2, trackType, str3, builder);
}
public final void sendAddTrack(String cid, String name, LivekitModels.TrackType type, String stream, LivekitRtc.AddTrackRequest.Builder builder) {
LivekitModels.Encryption.Type type2;
E2EEOptions e2eeOptions;
Intrinsics.checkNotNullParameter(cid, "cid");
Intrinsics.checkNotNullParameter(name, "name");
Intrinsics.checkNotNullParameter(type, "type");
Intrinsics.checkNotNullParameter(builder, "builder");
RoomOptions roomOptions = this.lastRoomOptions;
if (roomOptions == null || (e2eeOptions = roomOptions.getE2eeOptions()) == null || (type2 = e2eeOptions.getEncryptionType()) == null) {
type2 = LivekitModels.Encryption.Type.NONE;
}
builder.setCid(cid);
builder.setName(name);
builder.setType(type);
if (stream != null) {
builder.setStream(stream);
} else {
builder.clearStream();
}
builder.setEncryption(type2);
LivekitRtc.SignalRequest signalRequest = (LivekitRtc.SignalRequest) LivekitRtc.SignalRequest.newBuilder().setAddTrack(builder).build();
Intrinsics.checkNotNullExpressionValue(signalRequest, "request");
sendRequest(signalRequest);
}
public final void sendUpdateTrackSettings(String sid, boolean disabled, Track.Dimensions videoDimensions, LivekitModels.VideoQuality videoQuality, Integer fps) {
Intrinsics.checkNotNullParameter(sid, CONNECT_QUERY_PARTICIPANT_SID);
LivekitRtc.UpdateTrackSettings.Builder disabled2 = LivekitRtc.UpdateTrackSettings.newBuilder().addTrackSids(sid).setDisabled(disabled);
if (videoDimensions != null) {
disabled2.setWidth(videoDimensions.getWidth());
disabled2.setHeight(videoDimensions.getHeight());
} else if (videoQuality != null) {
disabled2.setQuality(videoQuality);
} else {
disabled2.setQuality(LivekitModels.VideoQuality.HIGH);
}
if (fps != null) {
disabled2.setFps(fps.intValue());
}
LivekitRtc.SignalRequest signalRequest = (LivekitRtc.SignalRequest) LivekitRtc.SignalRequest.newBuilder().setTrackSetting(disabled2).build();
Intrinsics.checkNotNullExpressionValue(signalRequest, "request");
sendRequest(signalRequest);
}
public final void sendUpdateSubscription(boolean subscribe, LivekitModels.ParticipantTracks... participantTracks) {
Intrinsics.checkNotNullParameter(participantTracks, "participantTracks");
List list = ArraysKt.toList(participantTracks);
ArrayList arrayList = new ArrayList(CollectionsKt.collectionSizeOrDefault(list, 10));
Iterator it2 = list.iterator();
while (it2.hasNext()) {
arrayList.add(((LivekitModels.ParticipantTracks) it2.next()).getTrackSidsList());
}
LivekitRtc.SignalRequest signalRequest = (LivekitRtc.SignalRequest) LivekitRtc.SignalRequest.newBuilder().setSubscription(LivekitRtc.UpdateSubscription.newBuilder().addAllParticipantTracks(ArraysKt.toList(participantTracks)).addAllTrackSids(CollectionsKt.flatten(arrayList)).setSubscribe(subscribe)).build();
Intrinsics.checkNotNullExpressionValue(signalRequest, "request");
sendRequest(signalRequest);
}
public final void sendUpdateSubscriptionPermissions(boolean allParticipants, List<ParticipantTrackPermission> participantTrackPermissions) {
Intrinsics.checkNotNullParameter(participantTrackPermissions, "participantTrackPermissions");
LivekitRtc.SubscriptionPermission.Builder allParticipants2 = LivekitRtc.SubscriptionPermission.newBuilder().setAllParticipants(allParticipants);
List<ParticipantTrackPermission> list = participantTrackPermissions;
ArrayList arrayList = new ArrayList(CollectionsKt.collectionSizeOrDefault(list, 10));
Iterator<T> it2 = list.iterator();
while (it2.hasNext()) {
arrayList.add(((ParticipantTrackPermission) it2.next()).toProto$livekit_android_sdk_release());
}
LivekitRtc.SignalRequest signalRequest = (LivekitRtc.SignalRequest) LivekitRtc.SignalRequest.newBuilder().setSubscriptionPermission(allParticipants2.addAllTrackPermissions(arrayList)).build();
Intrinsics.checkNotNullExpressionValue(signalRequest, "request");
sendRequest(signalRequest);
}
public static void sendUpdateLocalMetadata$default(SignalClient signalClient, String str, String str2, Map map, int i2, Object obj) {
if ((i2 & 4) != 0) {
map = MapsKt.emptyMap();
}
signalClient.sendUpdateLocalMetadata(str, str2, map);
}
public final void sendUpdateLocalMetadata(String metadata, String name, Map<String, String> attributes) {
LivekitRtc.UpdateParticipantMetadata.Builder newBuilder = LivekitRtc.UpdateParticipantMetadata.newBuilder();
if (metadata == null) {
metadata = "";
}
LivekitRtc.UpdateParticipantMetadata.Builder metadata2 = newBuilder.setMetadata(metadata);
if (name == null) {
name = "";
}
LivekitRtc.SignalRequest signalRequest = (LivekitRtc.SignalRequest) LivekitRtc.SignalRequest.newBuilder().setUpdateMetadata(metadata2.setName(name).putAllAttributes(attributes)).build();
Intrinsics.checkNotNullExpressionValue(signalRequest, "request");
sendRequest(signalRequest);
}
public final void sendSyncState(LivekitRtc.SyncState syncState) {
Intrinsics.checkNotNullParameter(syncState, "syncState");
LivekitRtc.SignalRequest signalRequest = (LivekitRtc.SignalRequest) LivekitRtc.SignalRequest.newBuilder().setSyncState(syncState).build();
Intrinsics.checkNotNullExpressionValue(signalRequest, "request");
sendRequest(signalRequest);
}
public final void sendSimulateScenario$livekit_android_sdk_release(LivekitRtc.SimulateScenario scenario) {
Intrinsics.checkNotNullParameter(scenario, "scenario");
LivekitRtc.SignalRequest signalRequest = (LivekitRtc.SignalRequest) LivekitRtc.SignalRequest.newBuilder().setSimulate(scenario).build();
Intrinsics.checkNotNullExpressionValue(signalRequest, "request");
sendRequest(signalRequest);
}
public final void sendLeave() {
LivekitRtc.SignalRequest.Builder newBuilder = LivekitRtc.SignalRequest.newBuilder();
LivekitRtc.LeaveRequest.Builder newBuilder2 = LivekitRtc.LeaveRequest.newBuilder();
newBuilder2.setReason(LivekitModels.DisconnectReason.CLIENT_INITIATED);
newBuilder2.setAction(LivekitRtc.LeaveRequest.Action.DISCONNECT);
newBuilder.setLeave(newBuilder2.build());
LivekitRtc.SignalRequest signalRequest = (LivekitRtc.SignalRequest) newBuilder.build();
Intrinsics.checkNotNullExpressionValue(signalRequest, "request");
sendRequest(signalRequest);
}
public final long sendPing() {
long time = new Date().getTime();
LivekitRtc.SignalRequest.Builder newBuilder = LivekitRtc.SignalRequest.newBuilder();
newBuilder.setPing(time);
LivekitRtc.SignalRequest signalRequest = (LivekitRtc.SignalRequest) newBuilder.build();
Intrinsics.checkNotNullExpressionValue(signalRequest, "with(LivekitRtc.SignalRe… build()\n }");
sendRequest(signalRequest);
LivekitRtc.SignalRequest.Builder newBuilder2 = LivekitRtc.SignalRequest.newBuilder();
LivekitRtc.Ping.Builder newBuilder3 = LivekitRtc.Ping.newBuilder();
newBuilder3.setRtt(this.rtt);
newBuilder3.setTimestamp(time);
newBuilder2.setPingReq(newBuilder3.build());
LivekitRtc.SignalRequest signalRequest2 = (LivekitRtc.SignalRequest) newBuilder2.build();
Intrinsics.checkNotNullExpressionValue(signalRequest2, "with(LivekitRtc.SignalRe… build()\n }");
sendRequest(signalRequest2);
return time;
}
public final void sendUpdateLocalAudioTrack(String trackSid, Collection<? extends LivekitModels.AudioTrackFeature> features) {
Intrinsics.checkNotNullParameter(trackSid, "trackSid");
Intrinsics.checkNotNullParameter(features, "features");
LivekitRtc.SignalRequest.Builder newBuilder = LivekitRtc.SignalRequest.newBuilder();
LivekitRtc.UpdateLocalAudioTrack.Builder newBuilder2 = LivekitRtc.UpdateLocalAudioTrack.newBuilder();
newBuilder2.setTrackSid(trackSid);
newBuilder2.addAllFeatures(features);
newBuilder.setUpdateAudioTrack(newBuilder2.build());
LivekitRtc.SignalRequest signalRequest = (LivekitRtc.SignalRequest) newBuilder.build();
Intrinsics.checkNotNullExpressionValue(signalRequest, "request");
sendRequest(signalRequest);
}
private final void sendRequest(LivekitRtc.SignalRequest request) {
if (skipQueueTypes.contains(request.getMessageCase())) {
sendRequestImpl(request);
} else {
this.requestFlow.tryEmit(request);
}
}
public final void sendRequestImpl(LivekitRtc.SignalRequest request) {
LKLog.Companion companion = LKLog.INSTANCE;
if (LoggingLevel.VERBOSE.compareTo(LKLog.INSTANCE.getLoggingLevel()) >= 0 && Timber.treeCount() > 0) {
Timber.v((Throwable) null, "sending request: " + request, new Object[0]);
}
if (!this.isConnected || this.currentWs == null) {
LKLog.Companion companion2 = LKLog.INSTANCE;
if (LoggingLevel.WARN.compareTo(LKLog.INSTANCE.getLoggingLevel()) < 0 || Timber.treeCount() <= 0) {
return;
}
Timber.w((Throwable) null, "not connected, could not send request " + request, new Object[0]);
return;
}
ByteString.Companion companion3 = ByteString.Companion;
byte[] byteArray = request.toByteArray();
Intrinsics.checkNotNullExpressionValue(byteArray, "request.toByteArray()");
ByteString of$default = ByteString.Companion.of$default(companion3, byteArray, 0, 0, 3, (Object) null);
WebSocket webSocket = this.currentWs;
if (webSocket != null ? webSocket.send(of$default) : false) {
return;
}
LKLog.Companion companion4 = LKLog.INSTANCE;
if (LoggingLevel.ERROR.compareTo(LKLog.INSTANCE.getLoggingLevel()) < 0 || Timber.treeCount() <= 0) {
return;
}
Timber.e((Throwable) null, "error sending request: " + request, new Object[0]);
}
private final void handleSignalResponse(WebSocket ws, LivekitRtc.SignalResponse response) {
if (Intrinsics.areEqual(ws, this.currentWs)) {
LKLog.Companion companion = LKLog.INSTANCE;
boolean z = false;
if (LoggingLevel.VERBOSE.compareTo(LKLog.INSTANCE.getLoggingLevel()) >= 0 && Timber.treeCount() > 0) {
Timber.v((Throwable) null, "response: " + response, new Object[0]);
}
if (!this.isConnected) {
if (response.hasJoin()) {
this.isConnected = true;
startRequestQueue();
long j2 = 1000;
this.pingTimeoutDurationMillis = response.getJoin().getPingTimeout() * j2;
this.pingIntervalDurationMillis = response.getJoin().getPingInterval() * j2;
startPingJob();
try {
this.serverVersion = new Semver(response.getJoin().getServerVersion());
} catch (Throwable th) {
LKLog.Companion companion2 = LKLog.INSTANCE;
if (LoggingLevel.WARN.compareTo(LKLog.INSTANCE.getLoggingLevel()) >= 0 && Timber.treeCount() > 0) {
Timber.w(th, "Thrown while trying to parse server version.", new Object[0]);
}
}
CancellableContinuation<? super Either<LivekitRtc.JoinResponse, ? extends Either<LivekitRtc.ReconnectResponse, Unit>>> cancellableContinuation = this.joinContinuation;
if (cancellableContinuation != null) {
Result.Companion companion3 = Result.INSTANCE;
cancellableContinuation.resumeWith(Result.m1547constructorimpl(new Either.Left(response.getJoin())));
}
} else if (response.hasLeave()) {
handleSignalResponseImpl(ws, response);
} else if (this.isReconnecting) {
this.isReconnecting = false;
this.isConnected = true;
startPingJob();
if (response.hasReconnect()) {
CancellableContinuation<? super Either<LivekitRtc.JoinResponse, ? extends Either<LivekitRtc.ReconnectResponse, Unit>>> cancellableContinuation2 = this.joinContinuation;
if (cancellableContinuation2 != null) {
Result.Companion companion4 = Result.INSTANCE;
cancellableContinuation2.resumeWith(Result.m1547constructorimpl(new Either.Right(new Either.Left(response.getReconnect()))));
}
} else {
CancellableContinuation<? super Either<LivekitRtc.JoinResponse, ? extends Either<LivekitRtc.ReconnectResponse, Unit>>> cancellableContinuation3 = this.joinContinuation;
if (cancellableContinuation3 != null) {
Result.Companion companion5 = Result.INSTANCE;
cancellableContinuation3.resumeWith(Result.m1547constructorimpl(new Either.Right(new Either.Right(Unit.INSTANCE))));
}
z = true;
}
} else {
LKLog.Companion companion6 = LKLog.INSTANCE;
if (LoggingLevel.ERROR.compareTo(LKLog.INSTANCE.getLoggingLevel()) >= 0 && Timber.treeCount() > 0) {
Timber.e((Throwable) null, "Received response while not connected. " + response, new Object[0]);
}
}
if (!z) {
return;
}
}
this.responseFlow.tryEmit(TuplesKt.to(ws, response));
}
}
public final void handleSignalResponseImpl(WebSocket ws, LivekitRtc.SignalResponse response) {
Listener listener;
if (!Intrinsics.areEqual(ws, this.currentWs)) {
LKLog.Companion companion = LKLog.INSTANCE;
if (LoggingLevel.VERBOSE.compareTo(LKLog.INSTANCE.getLoggingLevel()) < 0 || Timber.treeCount() <= 0) {
return;
}
Timber.v((Throwable) null, "received message from old websocket, discarding.", new Object[0]);
return;
}
LivekitRtc.SignalResponse.MessageCase messageCase = response.getMessageCase();
int i2 = messageCase == null ? -1 : WhenMappings.$EnumSwitchMapping$0[messageCase.ordinal()];
if (i2 != -1 && i2 != 23) {
switch (i2) {
case 1:
LivekitRtc.SessionDescription answer = response.getAnswer();
Intrinsics.checkNotNullExpressionValue(answer, "response.answer");
SessionDescription fromProtoSessionDescription = fromProtoSessionDescription(answer);
Listener listener2 = this.listener;
if (listener2 != null) {
listener2.onAnswer(fromProtoSessionDescription);
break;
}
break;
case 2:
LivekitRtc.SessionDescription offer = response.getOffer();
Intrinsics.checkNotNullExpressionValue(offer, "response.offer");
SessionDescription fromProtoSessionDescription2 = fromProtoSessionDescription(offer);
Listener listener3 = this.listener;
if (listener3 != null) {
listener3.onOffer(fromProtoSessionDescription2);
break;
}
break;
case 3:
StringFormat stringFormat = this.json;
String candidateInit = response.getTrickle().getCandidateInit();
Intrinsics.checkNotNullExpressionValue(candidateInit, "response.trickle.candidateInit");
stringFormat.getSerializersModule();
IceCandidateJSON iceCandidateJSON = (IceCandidateJSON) stringFormat.decodeFromString(IceCandidateJSON.INSTANCE.serializer(), candidateInit);
IceCandidate iceCandidate = new IceCandidate(iceCandidateJSON.getSdpMid(), iceCandidateJSON.getSdpMLineIndex(), iceCandidateJSON.getCandidate());
Listener listener4 = this.listener;
if (listener4 != null) {
LivekitRtc.SignalTarget target = response.getTrickle().getTarget();
Intrinsics.checkNotNullExpressionValue(target, "response.trickle.target");
listener4.onTrickle(iceCandidate, target);
break;
}
break;
case 4:
Listener listener5 = this.listener;
if (listener5 != null) {
List<LivekitModels.ParticipantInfo> participantsList = response.getUpdate().getParticipantsList();
Intrinsics.checkNotNullExpressionValue(participantsList, "response.update.participantsList");
listener5.onParticipantUpdate(participantsList);
break;
}
break;
case 5:
Listener listener6 = this.listener;
if (listener6 != null) {
LivekitRtc.TrackSubscribed trackSubscribed = response.getTrackSubscribed();
Intrinsics.checkNotNullExpressionValue(trackSubscribed, "response.trackSubscribed");
listener6.onLocalTrackSubscribed(trackSubscribed);
break;
}
break;
case 6:
Listener listener7 = this.listener;
if (listener7 != null) {
LivekitRtc.TrackPublishedResponse trackPublished = response.getTrackPublished();
Intrinsics.checkNotNullExpressionValue(trackPublished, "response.trackPublished");
listener7.onLocalTrackPublished(trackPublished);
break;
}
break;
case 7:
Listener listener8 = this.listener;
if (listener8 != null) {
List<LivekitModels.SpeakerInfo> speakersList = response.getSpeakersChanged().getSpeakersList();
Intrinsics.checkNotNullExpressionValue(speakersList, "response.speakersChanged.speakersList");
listener8.onSpeakersChanged(speakersList);
break;
}
break;
case 8:
LKLog.Companion companion2 = LKLog.INSTANCE;
if (LoggingLevel.DEBUG.compareTo(LKLog.INSTANCE.getLoggingLevel()) >= 0 && Timber.treeCount() > 0) {
Timber.d((Throwable) null, "received unexpected extra join message?", new Object[0]);
break;
}
break;
case 9:
Listener listener9 = this.listener;
if (listener9 != null) {
LivekitRtc.LeaveRequest leave = response.getLeave();
Intrinsics.checkNotNullExpressionValue(leave, "response.leave");
listener9.onLeave(leave);
break;
}
break;
case 10:
Listener listener10 = this.listener;
if (listener10 != null) {
String sid = response.getMute().getSid();
Intrinsics.checkNotNullExpressionValue(sid, "response.mute.sid");
listener10.onRemoteMuteChanged(sid, response.getMute().getMuted());
break;
}
break;
case 11:
Listener listener11 = this.listener;
if (listener11 != null) {
LivekitModels.Room room = response.getRoomUpdate().getRoom();
Intrinsics.checkNotNullExpressionValue(room, "response.roomUpdate.room");
listener11.onRoomUpdate(room);
break;
}
break;
case 12:
Listener listener12 = this.listener;
if (listener12 != null) {
List<LivekitRtc.ConnectionQualityInfo> updatesList = response.getConnectionQuality().getUpdatesList();
Intrinsics.checkNotNullExpressionValue(updatesList, "response.connectionQuality.updatesList");
listener12.onConnectionQuality(updatesList);
break;
}
break;
case 13:
Listener listener13 = this.listener;
if (listener13 != null) {
List<LivekitRtc.StreamStateInfo> streamStatesList = response.getStreamStateUpdate().getStreamStatesList();
Intrinsics.checkNotNullExpressionValue(streamStatesList, "response.streamStateUpdate.streamStatesList");
listener13.onStreamStateUpdate(streamStatesList);
break;
}
break;
case 14:
Semver semver = new Semver("0.15.1");
Semver semver2 = this.serverVersion;
if ((semver2 != null ? semver2.compareTo(semver) : 1) > 0 && (listener = this.listener) != null) {
LivekitRtc.SubscribedQualityUpdate subscribedQualityUpdate = response.getSubscribedQualityUpdate();
Intrinsics.checkNotNullExpressionValue(subscribedQualityUpdate, "response.subscribedQualityUpdate");
listener.onSubscribedQualityUpdate(subscribedQualityUpdate);
break;
}
break;
case 15:
Listener listener14 = this.listener;
if (listener14 != null) {
LivekitRtc.SubscriptionPermissionUpdate subscriptionPermissionUpdate = response.getSubscriptionPermissionUpdate();
Intrinsics.checkNotNullExpressionValue(subscriptionPermissionUpdate, "response.subscriptionPermissionUpdate");
listener14.onSubscriptionPermissionUpdate(subscriptionPermissionUpdate);
break;
}
break;
case 16:
Listener listener15 = this.listener;
if (listener15 != null) {
String refreshToken = response.getRefreshToken();
Intrinsics.checkNotNullExpressionValue(refreshToken, "response.refreshToken");
listener15.onRefreshToken(refreshToken);
break;
}
break;
case 17:
Listener listener16 = this.listener;
if (listener16 != null) {
LivekitRtc.TrackUnpublishedResponse trackUnpublished = response.getTrackUnpublished();
Intrinsics.checkNotNullExpressionValue(trackUnpublished, "response.trackUnpublished");
listener16.onLocalTrackUnpublished(trackUnpublished);
break;
}
break;
case 18:
resetPingTimeout();
break;
case 19:
this.rtt = new Date().getTime() - response.getPongResp().getLastPingTimestamp();
resetPingTimeout();
break;
}
return;
}
LKLog.Companion companion3 = LKLog.INSTANCE;
if (LoggingLevel.VERBOSE.compareTo(LKLog.INSTANCE.getLoggingLevel()) < 0 || Timber.treeCount() <= 0) {
return;
}
Timber.v((Throwable) null, "empty messageCase!", new Object[0]);
}
private final void startPingJob() {
if (this.pingJob != null || this.pingIntervalDurationMillis == 0) {
return;
}
CloseableCoroutineScope closeableCoroutineScope = this.coroutineScope;
if (closeableCoroutineScope == null) {
Intrinsics.throwUninitializedPropertyAccessException("coroutineScope");
closeableCoroutineScope = null;
}
this.pingJob = BuildersKt.launch$default(closeableCoroutineScope, (CoroutineContext) null, (CoroutineStart) null, new SignalClient$startPingJob$1(this, null), 3, (Object) null);
}
public final void startPingTimeout(long timestamp) {
if (this.pongJob != null) {
return;
}
CloseableCoroutineScope closeableCoroutineScope = this.coroutineScope;
if (closeableCoroutineScope == null) {
Intrinsics.throwUninitializedPropertyAccessException("coroutineScope");
closeableCoroutineScope = null;
}
this.pongJob = BuildersKt.launch$default(closeableCoroutineScope, (CoroutineContext) null, (CoroutineStart) null, new SignalClient$startPingTimeout$1(this, timestamp, null), 3, (Object) null);
}
private final void resetPingTimeout() {
Job job = this.pongJob;
if (job != null) {
Job.DefaultImpls.cancel$default(job, (CancellationException) null, 1, (Object) null);
}
this.pongJob = null;
}
public static void close$default(SignalClient signalClient, int i2, String str, boolean z, int i3, Object obj) {
if ((i3 & 1) != 0) {
i2 = 1000;
}
if ((i3 & 2) != 0) {
str = "Normal Closure";
}
if ((i3 & 4) != 0) {
z = true;
}
signalClient.close(i2, str, z);
}
public final void close(int code, String reason, boolean shouldClearQueuedRequests) {
Intrinsics.checkNotNullParameter(reason, "reason");
LKLog.Companion companion = LKLog.INSTANCE;
Exception exc = new Exception();
if (LoggingLevel.VERBOSE.compareTo(LKLog.INSTANCE.getLoggingLevel()) >= 0 && Timber.treeCount() > 0) {
Timber.v(exc, "Closing SignalClient: code = " + code + ", reason = " + reason, new Object[0]);
}
this.isConnected = false;
this.isReconnecting = false;
CloseableCoroutineScope closeableCoroutineScope = this.coroutineScope;
if (closeableCoroutineScope != null) {
if (closeableCoroutineScope == null) {
Intrinsics.throwUninitializedPropertyAccessException("coroutineScope");
closeableCoroutineScope = null;
}
closeableCoroutineScope.close();
}
Job job = this.requestFlowJob;
if (job != null) {
Job.DefaultImpls.cancel$default(job, (CancellationException) null, 1, (Object) null);
}
this.requestFlowJob = null;
Job job2 = this.responseFlowJob;
if (job2 != null) {
Job.DefaultImpls.cancel$default(job2, (CancellationException) null, 1, (Object) null);
}
this.responseFlowJob = null;
Job job3 = this.pingJob;
if (job3 != null) {
Job.DefaultImpls.cancel$default(job3, (CancellationException) null, 1, (Object) null);
}
this.pingJob = null;
Job job4 = this.pongJob;
if (job4 != null) {
Job.DefaultImpls.cancel$default(job4, (CancellationException) null, 1, (Object) null);
}
this.pongJob = null;
WebSocket webSocket = this.currentWs;
if (webSocket != null) {
webSocket.close(code, reason);
}
this.currentWs = null;
CancellableContinuation<? super Either<LivekitRtc.JoinResponse, ? extends Either<LivekitRtc.ReconnectResponse, Unit>>> cancellableContinuation = this.joinContinuation;
if (cancellableContinuation != null) {
CancellableContinuation.DefaultImpls.cancel$default(cancellableContinuation, (Throwable) null, 1, (Object) null);
}
this.joinContinuation = null;
if (shouldClearQueuedRequests) {
this.requestFlow.resetReplayCache();
}
this.responseFlow.resetReplayCache();
this.lastUrl = null;
this.lastOptions = null;
this.lastRoomOptions = null;
}
@Metadata(d1 = {"\u00000\n\u0002\u0018\u0002\n\u0002\u0010\u0000\n\u0002\b\u0002\n\u0002\u0010\b\n\u0002\b\u0003\n\u0002\u0010\u000e\n\u0002\b\f\n\u0002\u0010 \n\u0002\u0018\u0002\n\u0002\b\b\n\u0002\u0018\u0002\n\u0002\b\u0003\b\u0086\u0003\u0018\u00002\u00020\u0001B\u0007\b\u0002¢\u0006\u0002\u0010\u0002J\u0018\u0010 \u001a\n \u0017*\u0004\u0018\u00010\u00160\u00162\u0006\u0010!\u001a\u00020\bH\u0002R\u000e\u0010\u0003\u001a\u00020\u0004X\u0086T¢\u0006\u0002\n\u0000R\u000e\u0010\u0005\u001a\u00020\u0004X\u0086T¢\u0006\u0002\n\u0000R\u000e\u0010\u0006\u001a\u00020\u0004X\u0086T¢\u0006\u0002\n\u0000R\u000e\u0010\u0007\u001a\u00020\bX\u0086T¢\u0006\u0002\n\u0000R\u000e\u0010\t\u001a\u00020\bX\u0086T¢\u0006\u0002\n\u0000R\u000e\u0010\n\u001a\u00020\bX\u0086T¢\u0006\u0002\n\u0000R\u000e\u0010\u000b\u001a\u00020\bX\u0086T¢\u0006\u0002\n\u0000R\u000e\u0010\f\u001a\u00020\bX\u0086T¢\u0006\u0002\n\u0000R\u000e\u0010\r\u001a\u00020\bX\u0086T¢\u0006\u0002\n\u0000R\u000e\u0010\u000e\u001a\u00020\bX\u0086T¢\u0006\u0002\n\u0000R\u000e\u0010\u000f\u001a\u00020\bX\u0086T¢\u0006\u0002\n\u0000R\u000e\u0010\u0010\u001a\u00020\bX\u0086T¢\u0006\u0002\n\u0000R\u000e\u0010\u0011\u001a\u00020\bX\u0086T¢\u0006\u0002\n\u0000R\u000e\u0010\u0012\u001a\u00020\bX\u0086T¢\u0006\u0002\n\u0000R\u000e\u0010\u0013\u001a\u00020\bX\u0086T¢\u0006\u0002\n\u0000R\u001f\u0010\u0014\u001a\u0010\u0012\f\u0012\n \u0017*\u0004\u0018\u00010\u00160\u00160\u0015¢\u0006\b\n\u0000\u001a\u0004\b\u0018\u0010\u0019R\u000e\u0010\u001a\u001a\u00020\bX\u0086T¢\u0006\u0002\n\u0000R\u000e\u0010\u001b\u001a\u00020\bX\u0086T¢\u0006\u0002\n\u0000R\u000e\u0010\u001c\u001a\u00020\bX\u0086T¢\u0006\u0002\n\u0000R\u000e\u0010\u001d\u001a\u00020\bX\u0086T¢\u0006\u0002\n\u0000R\u0014\u0010\u001e\u001a\b\u0012\u0004\u0012\u00020\u001f0\u0015X\u0082\u0004¢\u0006\u0002\n\u0000¨\u0006\""}, d2 = {"Lio/livekit/android/room/SignalClient$Companion;", "", "()V", "CLOSE_REASON_NORMAL_CLOSURE", "", "CLOSE_REASON_PING_TIMEOUT", "CLOSE_REASON_WEBSOCKET_FAILURE", "CONNECT_QUERY_ADAPTIVE_STREAM", "", "CONNECT_QUERY_AUTOSUBSCRIBE", "CONNECT_QUERY_DEVICE_MODEL", "CONNECT_QUERY_NETWORK_TYPE", "CONNECT_QUERY_OS", "CONNECT_QUERY_OS_VERSION", "CONNECT_QUERY_PARTICIPANT_SID", "CONNECT_QUERY_PROTOCOL", "CONNECT_QUERY_RECONNECT", "CONNECT_QUERY_SDK", "CONNECT_QUERY_TOKEN", "CONNECT_QUERY_VERSION", "DEFAULT_ICE_SERVERS", "", "Llivekit/org/webrtc/PeerConnection$IceServer;", "kotlin.jvm.PlatformType", "getDEFAULT_ICE_SERVERS", "()Ljava/util/List;", "SDK_TYPE", "SD_TYPE_ANSWER", "SD_TYPE_OFFER", "SD_TYPE_PRANSWER", "skipQueueTypes", "Llivekit/LivekitRtc$SignalRequest$MessageCase;", "iceServer", "url", "livekit-android-sdk_release"}, k = 1, mv = {1, 8, 0}, xi = 48)
public static final class Companion {
public Companion(DefaultConstructorMarker defaultConstructorMarker) {
this();
}
private Companion() {
}
public final PeerConnection.IceServer iceServer(String url) {
return PeerConnection.IceServer.builder(url).createIceServer();
}
public final List<PeerConnection.IceServer> getDEFAULT_ICE_SERVERS() {
return SignalClient.DEFAULT_ICE_SERVERS;
}
}
static {
Companion companion = new Companion(null);
INSTANCE = companion;
skipQueueTypes = CollectionsKt.listOf(new LivekitRtc.SignalRequest.MessageCase[]{LivekitRtc.SignalRequest.MessageCase.SYNC_STATE, LivekitRtc.SignalRequest.MessageCase.TRICKLE, LivekitRtc.SignalRequest.MessageCase.OFFER, LivekitRtc.SignalRequest.MessageCase.ANSWER, LivekitRtc.SignalRequest.MessageCase.SIMULATE, LivekitRtc.SignalRequest.MessageCase.LEAVE});
DEFAULT_ICE_SERVERS = CollectionsKt.listOf(new PeerConnection.IceServer[]{companion.iceServer("stun:stun.l.google.com:19302"), companion.iceServer("stun:stun1.l.google.com:19302")});
}
}