正在显示
15 个修改的文件
包含
201 行增加
和
88 行删除
| @@ -4,9 +4,28 @@ import android.content.Context | @@ -4,9 +4,28 @@ import android.content.Context | ||
| 4 | import io.livekit.android.dagger.DaggerLiveKitComponent | 4 | import io.livekit.android.dagger.DaggerLiveKitComponent |
| 5 | import io.livekit.android.room.Room | 5 | import io.livekit.android.room.Room |
| 6 | import io.livekit.android.room.RoomListener | 6 | import io.livekit.android.room.RoomListener |
| 7 | +import io.livekit.android.util.LKLog | ||
| 8 | +import io.livekit.android.util.LoggingLevel | ||
| 9 | +import timber.log.Timber | ||
| 7 | 10 | ||
| 8 | class LiveKit { | 11 | class LiveKit { |
| 9 | companion object { | 12 | companion object { |
| 13 | + var loggingLevel: LoggingLevel | ||
| 14 | + get() = LKLog.loggingLevel | ||
| 15 | + set(value) { | ||
| 16 | + LKLog.loggingLevel = value | ||
| 17 | + | ||
| 18 | + // Plant debug tree if needed. | ||
| 19 | + if (value != LoggingLevel.OFF) { | ||
| 20 | + val forest = Timber.forest() | ||
| 21 | + val needsPlanting = forest.none { it is Timber.DebugTree } | ||
| 22 | + | ||
| 23 | + if (needsPlanting) { | ||
| 24 | + Timber.plant(Timber.DebugTree()) | ||
| 25 | + } | ||
| 26 | + } | ||
| 27 | + } | ||
| 28 | + | ||
| 10 | /** | 29 | /** |
| 11 | * Connect to a LiveKit room | 30 | * Connect to a LiveKit room |
| 12 | * @param url URL to LiveKit server (i.e. ws://mylivekitdeploy.io) | 31 | * @param url URL to LiveKit server (i.e. ws://mylivekitdeploy.io) |
| 1 | package io.livekit.android.dagger | 1 | package io.livekit.android.dagger |
| 2 | 2 | ||
| 3 | import android.content.Context | 3 | import android.content.Context |
| 4 | -import com.github.ajalt.timberkt.Timber | ||
| 5 | import dagger.Module | 4 | import dagger.Module |
| 6 | import dagger.Provides | 5 | import dagger.Provides |
| 6 | +import io.livekit.android.util.LKLog | ||
| 7 | import org.webrtc.* | 7 | import org.webrtc.* |
| 8 | import org.webrtc.audio.AudioDeviceModule | 8 | import org.webrtc.audio.AudioDeviceModule |
| 9 | import org.webrtc.audio.JavaAudioDeviceModule | 9 | import org.webrtc.audio.JavaAudioDeviceModule |
| @@ -21,46 +21,46 @@ class RTCModule { | @@ -21,46 +21,46 @@ class RTCModule { | ||
| 21 | // Set audio record error callbacks. | 21 | // Set audio record error callbacks. |
| 22 | val audioRecordErrorCallback = object : JavaAudioDeviceModule.AudioRecordErrorCallback { | 22 | val audioRecordErrorCallback = object : JavaAudioDeviceModule.AudioRecordErrorCallback { |
| 23 | override fun onWebRtcAudioRecordInitError(errorMessage: String?) { | 23 | override fun onWebRtcAudioRecordInitError(errorMessage: String?) { |
| 24 | - Timber.e { "onWebRtcAudioRecordInitError: $errorMessage" } | 24 | + LKLog.e { "onWebRtcAudioRecordInitError: $errorMessage" } |
| 25 | } | 25 | } |
| 26 | 26 | ||
| 27 | override fun onWebRtcAudioRecordStartError( | 27 | override fun onWebRtcAudioRecordStartError( |
| 28 | errorCode: JavaAudioDeviceModule.AudioRecordStartErrorCode?, | 28 | errorCode: JavaAudioDeviceModule.AudioRecordStartErrorCode?, |
| 29 | errorMessage: String? | 29 | errorMessage: String? |
| 30 | ) { | 30 | ) { |
| 31 | - Timber.e { "onWebRtcAudioRecordStartError: $errorCode. $errorMessage" } | 31 | + LKLog.e { "onWebRtcAudioRecordStartError: $errorCode. $errorMessage" } |
| 32 | } | 32 | } |
| 33 | 33 | ||
| 34 | override fun onWebRtcAudioRecordError(errorMessage: String?) { | 34 | override fun onWebRtcAudioRecordError(errorMessage: String?) { |
| 35 | - Timber.e { "onWebRtcAudioRecordError: $errorMessage" } | 35 | + LKLog.e { "onWebRtcAudioRecordError: $errorMessage" } |
| 36 | } | 36 | } |
| 37 | } | 37 | } |
| 38 | 38 | ||
| 39 | val audioTrackErrorCallback = object : JavaAudioDeviceModule.AudioTrackErrorCallback { | 39 | val audioTrackErrorCallback = object : JavaAudioDeviceModule.AudioTrackErrorCallback { |
| 40 | override fun onWebRtcAudioTrackInitError(errorMessage: String?) { | 40 | override fun onWebRtcAudioTrackInitError(errorMessage: String?) { |
| 41 | - Timber.e { "onWebRtcAudioTrackInitError: $errorMessage" } | 41 | + LKLog.e { "onWebRtcAudioTrackInitError: $errorMessage" } |
| 42 | } | 42 | } |
| 43 | 43 | ||
| 44 | override fun onWebRtcAudioTrackStartError( | 44 | override fun onWebRtcAudioTrackStartError( |
| 45 | errorCode: JavaAudioDeviceModule.AudioTrackStartErrorCode?, | 45 | errorCode: JavaAudioDeviceModule.AudioTrackStartErrorCode?, |
| 46 | errorMessage: String? | 46 | errorMessage: String? |
| 47 | ) { | 47 | ) { |
| 48 | - Timber.e { "onWebRtcAudioTrackStartError: $errorCode. $errorMessage" } | 48 | + LKLog.e { "onWebRtcAudioTrackStartError: $errorCode. $errorMessage" } |
| 49 | } | 49 | } |
| 50 | 50 | ||
| 51 | override fun onWebRtcAudioTrackError(errorMessage: String?) { | 51 | override fun onWebRtcAudioTrackError(errorMessage: String?) { |
| 52 | - Timber.e { "onWebRtcAudioTrackError: $errorMessage" } | 52 | + LKLog.e { "onWebRtcAudioTrackError: $errorMessage" } |
| 53 | } | 53 | } |
| 54 | 54 | ||
| 55 | } | 55 | } |
| 56 | val audioRecordStateCallback: JavaAudioDeviceModule.AudioRecordStateCallback = object : | 56 | val audioRecordStateCallback: JavaAudioDeviceModule.AudioRecordStateCallback = object : |
| 57 | JavaAudioDeviceModule.AudioRecordStateCallback { | 57 | JavaAudioDeviceModule.AudioRecordStateCallback { |
| 58 | override fun onWebRtcAudioRecordStart() { | 58 | override fun onWebRtcAudioRecordStart() { |
| 59 | - Timber.i { "Audio recording starts" } | 59 | + LKLog.i { "Audio recording starts" } |
| 60 | } | 60 | } |
| 61 | 61 | ||
| 62 | override fun onWebRtcAudioRecordStop() { | 62 | override fun onWebRtcAudioRecordStop() { |
| 63 | - Timber.i { "Audio recording stops" } | 63 | + LKLog.i { "Audio recording stops" } |
| 64 | } | 64 | } |
| 65 | } | 65 | } |
| 66 | 66 | ||
| @@ -68,11 +68,11 @@ class RTCModule { | @@ -68,11 +68,11 @@ class RTCModule { | ||
| 68 | val audioTrackStateCallback: JavaAudioDeviceModule.AudioTrackStateCallback = object : | 68 | val audioTrackStateCallback: JavaAudioDeviceModule.AudioTrackStateCallback = object : |
| 69 | JavaAudioDeviceModule.AudioTrackStateCallback { | 69 | JavaAudioDeviceModule.AudioTrackStateCallback { |
| 70 | override fun onWebRtcAudioTrackStart() { | 70 | override fun onWebRtcAudioTrackStart() { |
| 71 | - Timber.i { "Audio playout starts" } | 71 | + LKLog.i { "Audio playout starts" } |
| 72 | } | 72 | } |
| 73 | 73 | ||
| 74 | override fun onWebRtcAudioTrackStop() { | 74 | override fun onWebRtcAudioTrackStop() { |
| 75 | - Timber.i { "Audio playout stops" } | 75 | + LKLog.i { "Audio playout stops" } |
| 76 | } | 76 | } |
| 77 | } | 77 | } |
| 78 | 78 |
| 1 | package io.livekit.android.room | 1 | package io.livekit.android.room |
| 2 | 2 | ||
| 3 | -import com.github.ajalt.timberkt.Timber | ||
| 4 | import dagger.assisted.Assisted | 3 | import dagger.assisted.Assisted |
| 5 | import dagger.assisted.AssistedFactory | 4 | import dagger.assisted.AssistedFactory |
| 6 | import dagger.assisted.AssistedInject | 5 | import dagger.assisted.AssistedInject |
| 7 | import io.livekit.android.dagger.InjectionNames | 6 | import io.livekit.android.dagger.InjectionNames |
| 8 | import io.livekit.android.room.util.* | 7 | import io.livekit.android.room.util.* |
| 9 | import io.livekit.android.util.Either | 8 | import io.livekit.android.util.Either |
| 9 | +import io.livekit.android.util.LKLog | ||
| 10 | import io.livekit.android.util.debounce | 10 | import io.livekit.android.util.debounce |
| 11 | import kotlinx.coroutines.CoroutineDispatcher | 11 | import kotlinx.coroutines.CoroutineDispatcher |
| 12 | import kotlinx.coroutines.CoroutineScope | 12 | import kotlinx.coroutines.CoroutineScope |
| @@ -77,7 +77,7 @@ constructor( | @@ -77,7 +77,7 @@ constructor( | ||
| 77 | val iceRestart = | 77 | val iceRestart = |
| 78 | constraints.findConstraint(MediaConstraintKeys.ICE_RESTART) == MediaConstraintKeys.TRUE | 78 | constraints.findConstraint(MediaConstraintKeys.ICE_RESTART) == MediaConstraintKeys.TRUE |
| 79 | if (iceRestart) { | 79 | if (iceRestart) { |
| 80 | - Timber.d { "restarting ice" } | 80 | + LKLog.d { "restarting ice" } |
| 81 | restartingIce = true | 81 | restartingIce = true |
| 82 | } | 82 | } |
| 83 | 83 | ||
| @@ -96,16 +96,16 @@ constructor( | @@ -96,16 +96,16 @@ constructor( | ||
| 96 | } | 96 | } |
| 97 | 97 | ||
| 98 | // actually negotiate | 98 | // actually negotiate |
| 99 | - Timber.d { "starting to negotiate" } | 99 | + LKLog.d { "starting to negotiate" } |
| 100 | val sdpOffer = when (val outcome = peerConnection.createOffer(constraints)) { | 100 | val sdpOffer = when (val outcome = peerConnection.createOffer(constraints)) { |
| 101 | is Either.Left -> outcome.value | 101 | is Either.Left -> outcome.value |
| 102 | is Either.Right -> { | 102 | is Either.Right -> { |
| 103 | - Timber.d { "error creating offer: ${outcome.value}" } | 103 | + LKLog.d { "error creating offer: ${outcome.value}" } |
| 104 | return | 104 | return |
| 105 | } | 105 | } |
| 106 | } | 106 | } |
| 107 | 107 | ||
| 108 | - Timber.v { "sdp offer = $sdpOffer, description: ${sdpOffer.description}, type: ${sdpOffer.type}" } | 108 | + LKLog.v { "sdp offer = $sdpOffer, description: ${sdpOffer.description}, type: ${sdpOffer.type}" } |
| 109 | peerConnection.setLocalDescription(sdpOffer) | 109 | peerConnection.setLocalDescription(sdpOffer) |
| 110 | listener?.onOffer(sdpOffer) | 110 | listener?.onOffer(sdpOffer) |
| 111 | } | 111 | } |
| 1 | package io.livekit.android.room | 1 | package io.livekit.android.room |
| 2 | 2 | ||
| 3 | -import com.github.ajalt.timberkt.Timber | 3 | +import io.livekit.android.util.LKLog |
| 4 | import livekit.LivekitRtc | 4 | import livekit.LivekitRtc |
| 5 | import org.webrtc.* | 5 | import org.webrtc.* |
| 6 | 6 | ||
| @@ -18,7 +18,7 @@ class PublisherTransportObserver( | @@ -18,7 +18,7 @@ class PublisherTransportObserver( | ||
| 18 | 18 | ||
| 19 | override fun onIceCandidate(iceCandidate: IceCandidate?) { | 19 | override fun onIceCandidate(iceCandidate: IceCandidate?) { |
| 20 | val candidate = iceCandidate ?: return | 20 | val candidate = iceCandidate ?: return |
| 21 | - Timber.v { "onIceCandidate: $candidate" } | 21 | + LKLog.v { "onIceCandidate: $candidate" } |
| 22 | client.sendCandidate(candidate, target = LivekitRtc.SignalTarget.PUBLISHER) | 22 | client.sendCandidate(candidate, target = LivekitRtc.SignalTarget.PUBLISHER) |
| 23 | } | 23 | } |
| 24 | 24 | ||
| @@ -27,7 +27,7 @@ class PublisherTransportObserver( | @@ -27,7 +27,7 @@ class PublisherTransportObserver( | ||
| 27 | } | 27 | } |
| 28 | 28 | ||
| 29 | override fun onIceConnectionChange(newState: PeerConnection.IceConnectionState?) { | 29 | override fun onIceConnectionChange(newState: PeerConnection.IceConnectionState?) { |
| 30 | - Timber.v { "onIceConnection new state: $newState" } | 30 | + LKLog.v { "onIceConnection new state: $newState" } |
| 31 | iceConnectionChangeListener?.invoke(newState) | 31 | iceConnectionChangeListener?.invoke(newState) |
| 32 | } | 32 | } |
| 33 | 33 |
| 1 | package io.livekit.android.room | 1 | package io.livekit.android.room |
| 2 | 2 | ||
| 3 | import android.os.SystemClock | 3 | import android.os.SystemClock |
| 4 | -import com.github.ajalt.timberkt.Timber | ||
| 5 | import io.livekit.android.ConnectOptions | 4 | import io.livekit.android.ConnectOptions |
| 6 | import io.livekit.android.dagger.InjectionNames | 5 | import io.livekit.android.dagger.InjectionNames |
| 7 | import io.livekit.android.room.track.DataPublishReliability | 6 | import io.livekit.android.room.track.DataPublishReliability |
| @@ -11,6 +10,7 @@ import io.livekit.android.room.track.TrackPublication | @@ -11,6 +10,7 @@ import io.livekit.android.room.track.TrackPublication | ||
| 11 | import io.livekit.android.room.util.* | 10 | import io.livekit.android.room.util.* |
| 12 | import io.livekit.android.util.CloseableCoroutineScope | 11 | import io.livekit.android.util.CloseableCoroutineScope |
| 13 | import io.livekit.android.util.Either | 12 | import io.livekit.android.util.Either |
| 13 | +import io.livekit.android.util.LKLog | ||
| 14 | import kotlinx.coroutines.CoroutineDispatcher | 14 | import kotlinx.coroutines.CoroutineDispatcher |
| 15 | import kotlinx.coroutines.SupervisorJob | 15 | import kotlinx.coroutines.SupervisorJob |
| 16 | import kotlinx.coroutines.delay | 16 | import kotlinx.coroutines.delay |
| @@ -50,15 +50,15 @@ internal constructor( | @@ -50,15 +50,15 @@ internal constructor( | ||
| 50 | when (value) { | 50 | when (value) { |
| 51 | IceState.CONNECTED -> { | 51 | IceState.CONNECTED -> { |
| 52 | if (oldVal == IceState.DISCONNECTED) { | 52 | if (oldVal == IceState.DISCONNECTED) { |
| 53 | - Timber.d { "publisher ICE connected" } | 53 | + LKLog.d { "publisher ICE connected" } |
| 54 | listener?.onIceConnected() | 54 | listener?.onIceConnected() |
| 55 | } else if (oldVal == IceState.RECONNECTING) { | 55 | } else if (oldVal == IceState.RECONNECTING) { |
| 56 | - Timber.d { "publisher ICE reconnected" } | 56 | + LKLog.d { "publisher ICE reconnected" } |
| 57 | listener?.onIceReconnected() | 57 | listener?.onIceReconnected() |
| 58 | } | 58 | } |
| 59 | } | 59 | } |
| 60 | IceState.DISCONNECTED -> { | 60 | IceState.DISCONNECTED -> { |
| 61 | - Timber.d { "publisher ICE disconnected" } | 61 | + LKLog.d { "publisher ICE disconnected" } |
| 62 | listener?.onDisconnect("Peer connection disconnected") | 62 | listener?.onDisconnect("Peer connection disconnected") |
| 63 | } | 63 | } |
| 64 | else -> { | 64 | else -> { |
| @@ -133,11 +133,11 @@ internal constructor( | @@ -133,11 +133,11 @@ internal constructor( | ||
| 133 | iceServers.addAll(SignalClient.DEFAULT_ICE_SERVERS) | 133 | iceServers.addAll(SignalClient.DEFAULT_ICE_SERVERS) |
| 134 | } | 134 | } |
| 135 | joinResponse.iceServersList.forEach { | 135 | joinResponse.iceServersList.forEach { |
| 136 | - Timber.v { "username = \"${it.username}\"" } | ||
| 137 | - Timber.v { "credential = \"${it.credential}\"" } | ||
| 138 | - Timber.v { "urls: " } | 136 | + LKLog.v { "username = \"${it.username}\"" } |
| 137 | + LKLog.v { "credential = \"${it.credential}\"" } | ||
| 138 | + LKLog.v { "urls: " } | ||
| 139 | it.urlsList.forEach { | 139 | it.urlsList.forEach { |
| 140 | - Timber.v { " $it" } | 140 | + LKLog.v { " $it" } |
| 141 | } | 141 | } |
| 142 | } | 142 | } |
| 143 | 143 | ||
| @@ -162,7 +162,7 @@ internal constructor( | @@ -162,7 +162,7 @@ internal constructor( | ||
| 162 | val iceConnectionStateListener: (PeerConnection.IceConnectionState?) -> Unit = { newState -> | 162 | val iceConnectionStateListener: (PeerConnection.IceConnectionState?) -> Unit = { newState -> |
| 163 | val state = | 163 | val state = |
| 164 | newState ?: throw NullPointerException("unexpected null new state, what do?") | 164 | newState ?: throw NullPointerException("unexpected null new state, what do?") |
| 165 | - Timber.v { "onIceConnection new state: $newState" } | 165 | + LKLog.v { "onIceConnection new state: $newState" } |
| 166 | if (state == PeerConnection.IceConnectionState.CONNECTED) { | 166 | if (state == PeerConnection.IceConnectionState.CONNECTED) { |
| 167 | iceState = IceState.CONNECTED | 167 | iceState = IceState.CONNECTED |
| 168 | } else if (state == PeerConnection.IceConnectionState.FAILED) { | 168 | } else if (state == PeerConnection.IceConnectionState.FAILED) { |
| @@ -242,11 +242,11 @@ internal constructor( | @@ -242,11 +242,11 @@ internal constructor( | ||
| 242 | val url = sessionUrl | 242 | val url = sessionUrl |
| 243 | val token = sessionToken | 243 | val token = sessionToken |
| 244 | if (url == null || token == null) { | 244 | if (url == null || token == null) { |
| 245 | - Timber.w { "couldn't reconnect, no url or no token" } | 245 | + LKLog.w { "couldn't reconnect, no url or no token" } |
| 246 | return | 246 | return |
| 247 | } | 247 | } |
| 248 | if (iceState == IceState.DISCONNECTED || wsRetries >= MAX_SIGNAL_RETRIES) { | 248 | if (iceState == IceState.DISCONNECTED || wsRetries >= MAX_SIGNAL_RETRIES) { |
| 249 | - Timber.w { "could not connect to signal after max attempts, giving up" } | 249 | + LKLog.w { "could not connect to signal after max attempts, giving up" } |
| 250 | close() | 250 | close() |
| 251 | listener?.onDisconnect("could not reconnect after limit") | 251 | listener?.onDisconnect("could not reconnect after limit") |
| 252 | return | 252 | return |
| @@ -259,13 +259,13 @@ internal constructor( | @@ -259,13 +259,13 @@ internal constructor( | ||
| 259 | coroutineScope.launch { | 259 | coroutineScope.launch { |
| 260 | delay(startDelay) | 260 | delay(startDelay) |
| 261 | if (iceState == IceState.DISCONNECTED) { | 261 | if (iceState == IceState.DISCONNECTED) { |
| 262 | - Timber.e { "Ice is disconnected" } | 262 | + LKLog.e { "Ice is disconnected" } |
| 263 | return@launch | 263 | return@launch |
| 264 | } | 264 | } |
| 265 | 265 | ||
| 266 | client.reconnect(url, token) | 266 | client.reconnect(url, token) |
| 267 | 267 | ||
| 268 | - Timber.v { "reconnected, restarting ICE" } | 268 | + LKLog.v { "reconnected, restarting ICE" } |
| 269 | wsRetries = 0 | 269 | wsRetries = 0 |
| 270 | 270 | ||
| 271 | // trigger publisher reconnect | 271 | // trigger publisher reconnect |
| @@ -396,9 +396,9 @@ internal constructor( | @@ -396,9 +396,9 @@ internal constructor( | ||
| 396 | //---------------------------------- SignalClient.Listener --------------------------------------// | 396 | //---------------------------------- SignalClient.Listener --------------------------------------// |
| 397 | 397 | ||
| 398 | override fun onAnswer(sessionDescription: SessionDescription) { | 398 | override fun onAnswer(sessionDescription: SessionDescription) { |
| 399 | - Timber.v { "received server answer: ${sessionDescription.type}, ${publisher.peerConnection.signalingState()}" } | 399 | + LKLog.v { "received server answer: ${sessionDescription.type}, ${publisher.peerConnection.signalingState()}" } |
| 400 | coroutineScope.launch { | 400 | coroutineScope.launch { |
| 401 | - Timber.i { sessionDescription.toString() } | 401 | + LKLog.i { sessionDescription.toString() } |
| 402 | when (val outcome = publisher.setRemoteDescription(sessionDescription)) { | 402 | when (val outcome = publisher.setRemoteDescription(sessionDescription)) { |
| 403 | is Either.Left -> { | 403 | is Either.Left -> { |
| 404 | // when reconnecting, ICE might not have disconnected and won't trigger | 404 | // when reconnecting, ICE might not have disconnected and won't trigger |
| @@ -408,20 +408,20 @@ internal constructor( | @@ -408,20 +408,20 @@ internal constructor( | ||
| 408 | } | 408 | } |
| 409 | } | 409 | } |
| 410 | is Either.Right -> { | 410 | is Either.Right -> { |
| 411 | - Timber.e { "error setting remote description for answer: ${outcome.value} " } | 411 | + LKLog.e { "error setting remote description for answer: ${outcome.value} " } |
| 412 | } | 412 | } |
| 413 | } | 413 | } |
| 414 | } | 414 | } |
| 415 | } | 415 | } |
| 416 | 416 | ||
| 417 | override fun onOffer(sessionDescription: SessionDescription) { | 417 | override fun onOffer(sessionDescription: SessionDescription) { |
| 418 | - Timber.v { "received server offer: ${sessionDescription.type}, ${subscriber.peerConnection.signalingState()}" } | 418 | + LKLog.v { "received server offer: ${sessionDescription.type}, ${subscriber.peerConnection.signalingState()}" } |
| 419 | coroutineScope.launch { | 419 | coroutineScope.launch { |
| 420 | run<Unit> { | 420 | run<Unit> { |
| 421 | when (val outcome = | 421 | when (val outcome = |
| 422 | subscriber.setRemoteDescription(sessionDescription)) { | 422 | subscriber.setRemoteDescription(sessionDescription)) { |
| 423 | is Either.Right -> { | 423 | is Either.Right -> { |
| 424 | - Timber.e { "error setting remote description for answer: ${outcome.value} " } | 424 | + LKLog.e { "error setting remote description for answer: ${outcome.value} " } |
| 425 | return@launch | 425 | return@launch |
| 426 | } | 426 | } |
| 427 | } | 427 | } |
| @@ -431,7 +431,7 @@ internal constructor( | @@ -431,7 +431,7 @@ internal constructor( | ||
| 431 | when (val outcome = subscriber.peerConnection.createAnswer(MediaConstraints())) { | 431 | when (val outcome = subscriber.peerConnection.createAnswer(MediaConstraints())) { |
| 432 | is Either.Left -> outcome.value | 432 | is Either.Left -> outcome.value |
| 433 | is Either.Right -> { | 433 | is Either.Right -> { |
| 434 | - Timber.e { "error creating answer: ${outcome.value}" } | 434 | + LKLog.e { "error creating answer: ${outcome.value}" } |
| 435 | return@launch | 435 | return@launch |
| 436 | } | 436 | } |
| 437 | } | 437 | } |
| @@ -440,7 +440,7 @@ internal constructor( | @@ -440,7 +440,7 @@ internal constructor( | ||
| 440 | run<Unit> { | 440 | run<Unit> { |
| 441 | when (val outcome = subscriber.peerConnection.setLocalDescription(answer)) { | 441 | when (val outcome = subscriber.peerConnection.setLocalDescription(answer)) { |
| 442 | is Either.Right -> { | 442 | is Either.Right -> { |
| 443 | - Timber.e { "error setting local description for answer: ${outcome.value}" } | 443 | + LKLog.e { "error setting local description for answer: ${outcome.value}" } |
| 444 | return@launch | 444 | return@launch |
| 445 | } | 445 | } |
| 446 | } | 446 | } |
| @@ -451,29 +451,29 @@ internal constructor( | @@ -451,29 +451,29 @@ internal constructor( | ||
| 451 | } | 451 | } |
| 452 | 452 | ||
| 453 | override fun onTrickle(candidate: IceCandidate, target: LivekitRtc.SignalTarget) { | 453 | override fun onTrickle(candidate: IceCandidate, target: LivekitRtc.SignalTarget) { |
| 454 | - Timber.v { "received ice candidate from peer: $candidate, $target" } | 454 | + LKLog.v { "received ice candidate from peer: $candidate, $target" } |
| 455 | when (target) { | 455 | when (target) { |
| 456 | LivekitRtc.SignalTarget.PUBLISHER -> publisher.addIceCandidate(candidate) | 456 | LivekitRtc.SignalTarget.PUBLISHER -> publisher.addIceCandidate(candidate) |
| 457 | LivekitRtc.SignalTarget.SUBSCRIBER -> subscriber.addIceCandidate(candidate) | 457 | LivekitRtc.SignalTarget.SUBSCRIBER -> subscriber.addIceCandidate(candidate) |
| 458 | - else -> Timber.i { "unknown ice candidate target?" } | 458 | + else -> LKLog.i { "unknown ice candidate target?" } |
| 459 | } | 459 | } |
| 460 | } | 460 | } |
| 461 | 461 | ||
| 462 | override fun onLocalTrackPublished(response: LivekitRtc.TrackPublishedResponse) { | 462 | override fun onLocalTrackPublished(response: LivekitRtc.TrackPublishedResponse) { |
| 463 | val cid = response.cid ?: run { | 463 | val cid = response.cid ?: run { |
| 464 | - Timber.e { "local track published with null cid?" } | 464 | + LKLog.e { "local track published with null cid?" } |
| 465 | return | 465 | return |
| 466 | } | 466 | } |
| 467 | 467 | ||
| 468 | val track = response.track | 468 | val track = response.track |
| 469 | if (track == null) { | 469 | if (track == null) { |
| 470 | - Timber.d { "local track published with null track info?" } | 470 | + LKLog.d { "local track published with null track info?" } |
| 471 | } | 471 | } |
| 472 | 472 | ||
| 473 | - Timber.v { "local track published $cid" } | 473 | + LKLog.v { "local track published $cid" } |
| 474 | val cont = pendingTrackResolvers.remove(cid) | 474 | val cont = pendingTrackResolvers.remove(cid) |
| 475 | if (cont == null) { | 475 | if (cont == null) { |
| 476 | - Timber.d { "missing track resolver for: $cid" } | 476 | + LKLog.d { "missing track resolver for: $cid" } |
| 477 | return | 477 | return |
| 478 | } | 478 | } |
| 479 | cont.resume(response.track) | 479 | cont.resume(response.track) |
| @@ -489,7 +489,7 @@ internal constructor( | @@ -489,7 +489,7 @@ internal constructor( | ||
| 489 | 489 | ||
| 490 | override fun onClose(reason: String, code: Int) { | 490 | override fun onClose(reason: String, code: Int) { |
| 491 | // TODO: reconnect logic | 491 | // TODO: reconnect logic |
| 492 | - Timber.i { "received close event: $reason, code: $code" } | 492 | + LKLog.i { "received close event: $reason, code: $code" } |
| 493 | listener?.onDisconnect(reason) | 493 | listener?.onDisconnect(reason) |
| 494 | } | 494 | } |
| 495 | 495 | ||
| @@ -528,7 +528,7 @@ internal constructor( | @@ -528,7 +528,7 @@ internal constructor( | ||
| 528 | } | 528 | } |
| 529 | LivekitModels.DataPacket.ValueCase.VALUE_NOT_SET, | 529 | LivekitModels.DataPacket.ValueCase.VALUE_NOT_SET, |
| 530 | null -> { | 530 | null -> { |
| 531 | - Timber.v { "invalid value for data packet" } | 531 | + LKLog.v { "invalid value for data packet" } |
| 532 | } | 532 | } |
| 533 | } | 533 | } |
| 534 | } | 534 | } |
| @@ -5,7 +5,6 @@ import android.net.ConnectivityManager | @@ -5,7 +5,6 @@ import android.net.ConnectivityManager | ||
| 5 | import android.net.Network | 5 | import android.net.Network |
| 6 | import android.net.NetworkCapabilities | 6 | import android.net.NetworkCapabilities |
| 7 | import android.net.NetworkRequest | 7 | import android.net.NetworkRequest |
| 8 | -import com.github.ajalt.timberkt.Timber | ||
| 9 | import dagger.assisted.Assisted | 8 | import dagger.assisted.Assisted |
| 10 | import dagger.assisted.AssistedFactory | 9 | import dagger.assisted.AssistedFactory |
| 11 | import dagger.assisted.AssistedInject | 10 | import dagger.assisted.AssistedInject |
| @@ -17,6 +16,7 @@ import io.livekit.android.room.participant.Participant | @@ -17,6 +16,7 @@ import io.livekit.android.room.participant.Participant | ||
| 17 | import io.livekit.android.room.participant.ParticipantListener | 16 | import io.livekit.android.room.participant.ParticipantListener |
| 18 | import io.livekit.android.room.participant.RemoteParticipant | 17 | import io.livekit.android.room.participant.RemoteParticipant |
| 19 | import io.livekit.android.room.track.* | 18 | import io.livekit.android.room.track.* |
| 19 | +import io.livekit.android.util.LKLog | ||
| 20 | import livekit.LivekitModels | 20 | import livekit.LivekitModels |
| 21 | import livekit.LivekitRtc | 21 | import livekit.LivekitRtc |
| 22 | import org.webrtc.* | 22 | import org.webrtc.* |
| @@ -68,7 +68,7 @@ constructor( | @@ -68,7 +68,7 @@ constructor( | ||
| 68 | suspend fun connect(url: String, token: String, options: ConnectOptions?) { | 68 | suspend fun connect(url: String, token: String, options: ConnectOptions?) { |
| 69 | state = State.CONNECTING | 69 | state = State.CONNECTING |
| 70 | val response = engine.join(url, token, options) | 70 | val response = engine.join(url, token, options) |
| 71 | - Timber.i { "Connected to server, server version: ${response.serverVersion}, client version: ${Version.CLIENT_VERSION}" } | 71 | + LKLog.i { "Connected to server, server version: ${response.serverVersion}, client version: ${Version.CLIENT_VERSION}" } |
| 72 | 72 | ||
| 73 | sid = Sid(response.room.sid) | 73 | sid = Sid(response.room.sid) |
| 74 | name = response.room.name | 74 | name = response.room.name |
| @@ -249,7 +249,7 @@ constructor( | @@ -249,7 +249,7 @@ constructor( | ||
| 249 | if (!hasLostConnectivity) { | 249 | if (!hasLostConnectivity) { |
| 250 | return | 250 | return |
| 251 | } | 251 | } |
| 252 | - Timber.i { "network connection available, reconnecting" } | 252 | + LKLog.i { "network connection available, reconnecting" } |
| 253 | reconnect() | 253 | reconnect() |
| 254 | hasLostConnectivity = false | 254 | hasLostConnectivity = false |
| 255 | } | 255 | } |
| @@ -270,7 +270,7 @@ constructor( | @@ -270,7 +270,7 @@ constructor( | ||
| 270 | */ | 270 | */ |
| 271 | override fun onAddTrack(track: MediaStreamTrack, streams: Array<out MediaStream>) { | 271 | override fun onAddTrack(track: MediaStreamTrack, streams: Array<out MediaStream>) { |
| 272 | if (streams.count() < 0) { | 272 | if (streams.count() < 0) { |
| 273 | - Timber.i { "add track with empty streams?" } | 273 | + LKLog.i { "add track with empty streams?" } |
| 274 | return | 274 | return |
| 275 | } | 275 | } |
| 276 | 276 | ||
| @@ -340,7 +340,7 @@ constructor( | @@ -340,7 +340,7 @@ constructor( | ||
| 340 | * @suppress | 340 | * @suppress |
| 341 | */ | 341 | */ |
| 342 | override fun onDisconnect(reason: String) { | 342 | override fun onDisconnect(reason: String) { |
| 343 | - Timber.v { "engine did disconnect: $reason" } | 343 | + LKLog.v { "engine did disconnect: $reason" } |
| 344 | handleDisconnect() | 344 | handleDisconnect() |
| 345 | } | 345 | } |
| 346 | 346 |
| 1 | package io.livekit.android.room | 1 | package io.livekit.android.room |
| 2 | 2 | ||
| 3 | -import com.github.ajalt.timberkt.Timber | ||
| 4 | import com.google.protobuf.util.JsonFormat | 3 | import com.google.protobuf.util.JsonFormat |
| 5 | import io.livekit.android.ConnectOptions | 4 | import io.livekit.android.ConnectOptions |
| 6 | import io.livekit.android.Version | 5 | import io.livekit.android.Version |
| 7 | import io.livekit.android.dagger.InjectionNames | 6 | import io.livekit.android.dagger.InjectionNames |
| 8 | import io.livekit.android.room.track.Track | 7 | import io.livekit.android.room.track.Track |
| 9 | import io.livekit.android.util.Either | 8 | import io.livekit.android.util.Either |
| 9 | +import io.livekit.android.util.LKLog | ||
| 10 | import io.livekit.android.util.safe | 10 | import io.livekit.android.util.safe |
| 11 | import kotlinx.coroutines.CancellableContinuation | 11 | import kotlinx.coroutines.CancellableContinuation |
| 12 | import kotlinx.coroutines.suspendCancellableCoroutine | 12 | import kotlinx.coroutines.suspendCancellableCoroutine |
| @@ -92,7 +92,7 @@ constructor( | @@ -92,7 +92,7 @@ constructor( | ||
| 92 | } | 92 | } |
| 93 | } | 93 | } |
| 94 | 94 | ||
| 95 | - Timber.i { "connecting to $wsUrlString" } | 95 | + LKLog.i { "connecting to $wsUrlString" } |
| 96 | 96 | ||
| 97 | isConnected = false | 97 | isConnected = false |
| 98 | currentWs?.cancel() | 98 | currentWs?.cancel() |
| @@ -124,7 +124,7 @@ constructor( | @@ -124,7 +124,7 @@ constructor( | ||
| 124 | } | 124 | } |
| 125 | 125 | ||
| 126 | override fun onMessage(webSocket: WebSocket, text: String) { | 126 | override fun onMessage(webSocket: WebSocket, text: String) { |
| 127 | - Timber.v { text } | 127 | + LKLog.v { text } |
| 128 | val signalResponseBuilder = LivekitRtc.SignalResponse.newBuilder() | 128 | val signalResponseBuilder = LivekitRtc.SignalResponse.newBuilder() |
| 129 | fromJsonProtobuf.merge(text, signalResponseBuilder) | 129 | fromJsonProtobuf.merge(text, signalResponseBuilder) |
| 130 | val response = signalResponseBuilder.build() | 130 | val response = signalResponseBuilder.build() |
| @@ -142,13 +142,13 @@ constructor( | @@ -142,13 +142,13 @@ constructor( | ||
| 142 | } | 142 | } |
| 143 | 143 | ||
| 144 | override fun onClosed(webSocket: WebSocket, code: Int, reason: String) { | 144 | override fun onClosed(webSocket: WebSocket, code: Int, reason: String) { |
| 145 | - Timber.v { "websocket closed" } | 145 | + LKLog.v { "websocket closed" } |
| 146 | 146 | ||
| 147 | listener?.onClose(reason, code) | 147 | listener?.onClose(reason, code) |
| 148 | } | 148 | } |
| 149 | 149 | ||
| 150 | override fun onClosing(webSocket: WebSocket, code: Int, reason: String) { | 150 | override fun onClosing(webSocket: WebSocket, code: Int, reason: String) { |
| 151 | - Timber.v { "websocket closing" } | 151 | + LKLog.v { "websocket closing" } |
| 152 | } | 152 | } |
| 153 | 153 | ||
| 154 | override fun onFailure(webSocket: WebSocket, t: Throwable, response: Response?) { | 154 | override fun onFailure(webSocket: WebSocket, t: Throwable, response: Response?) { |
| @@ -165,14 +165,14 @@ constructor( | @@ -165,14 +165,14 @@ constructor( | ||
| 165 | } | 165 | } |
| 166 | } | 166 | } |
| 167 | } catch (e: Throwable) { | 167 | } catch (e: Throwable) { |
| 168 | - Timber.e(e) { "failed to validate connection" } | 168 | + LKLog.e(e) { "failed to validate connection" } |
| 169 | } | 169 | } |
| 170 | 170 | ||
| 171 | if (reason != null) { | 171 | if (reason != null) { |
| 172 | - Timber.e(t) { "websocket failure: $reason" } | 172 | + LKLog.e(t) { "websocket failure: $reason" } |
| 173 | listener?.onError(Exception(reason)) | 173 | listener?.onError(Exception(reason)) |
| 174 | } else { | 174 | } else { |
| 175 | - Timber.e(t) { "websocket failure: $response" } | 175 | + LKLog.e(t) { "websocket failure: $response" } |
| 176 | listener?.onError(t as Exception) | 176 | listener?.onError(t as Exception) |
| 177 | } | 177 | } |
| 178 | } | 178 | } |
| @@ -302,9 +302,9 @@ constructor( | @@ -302,9 +302,9 @@ constructor( | ||
| 302 | } | 302 | } |
| 303 | 303 | ||
| 304 | private fun sendRequest(request: LivekitRtc.SignalRequest) { | 304 | private fun sendRequest(request: LivekitRtc.SignalRequest) { |
| 305 | - Timber.v { "sending request: $request" } | 305 | + LKLog.v { "sending request: $request" } |
| 306 | if (!isConnected || currentWs == null) { | 306 | if (!isConnected || currentWs == null) { |
| 307 | - Timber.w { "not connected, could not send request $request" } | 307 | + LKLog.w { "not connected, could not send request $request" } |
| 308 | return | 308 | return |
| 309 | } | 309 | } |
| 310 | val sent: Boolean | 310 | val sent: Boolean |
| @@ -317,7 +317,7 @@ constructor( | @@ -317,7 +317,7 @@ constructor( | ||
| 317 | } | 317 | } |
| 318 | 318 | ||
| 319 | if (!sent) { | 319 | if (!sent) { |
| 320 | - Timber.e { "error sending request: $request" } | 320 | + LKLog.e { "error sending request: $request" } |
| 321 | } | 321 | } |
| 322 | } | 322 | } |
| 323 | 323 | ||
| @@ -328,12 +328,12 @@ constructor( | @@ -328,12 +328,12 @@ constructor( | ||
| 328 | isConnected = true | 328 | isConnected = true |
| 329 | joinContinuation?.resumeWith(Result.success(Either.Left(response.join))) | 329 | joinContinuation?.resumeWith(Result.success(Either.Left(response.join))) |
| 330 | } else { | 330 | } else { |
| 331 | - Timber.e { "Received response while not connected. ${toJsonProtobuf.print(response)}" } | 331 | + LKLog.e { "Received response while not connected. ${toJsonProtobuf.print(response)}" } |
| 332 | } | 332 | } |
| 333 | return | 333 | return |
| 334 | } | 334 | } |
| 335 | 335 | ||
| 336 | - Timber.v { "response: $response" } | 336 | + LKLog.v { "response: $response" } |
| 337 | when (response.messageCase) { | 337 | when (response.messageCase) { |
| 338 | LivekitRtc.SignalResponse.MessageCase.ANSWER -> { | 338 | LivekitRtc.SignalResponse.MessageCase.ANSWER -> { |
| 339 | val sd = fromProtoSessionDescription(response.answer) | 339 | val sd = fromProtoSessionDescription(response.answer) |
| @@ -363,7 +363,7 @@ constructor( | @@ -363,7 +363,7 @@ constructor( | ||
| 363 | listener?.onSpeakersChanged(response.speakersChanged.speakersList) | 363 | listener?.onSpeakersChanged(response.speakersChanged.speakersList) |
| 364 | } | 364 | } |
| 365 | LivekitRtc.SignalResponse.MessageCase.JOIN -> { | 365 | LivekitRtc.SignalResponse.MessageCase.JOIN -> { |
| 366 | - Timber.d { "received unexpected extra join message?" } | 366 | + LKLog.d { "received unexpected extra join message?" } |
| 367 | } | 367 | } |
| 368 | LivekitRtc.SignalResponse.MessageCase.LEAVE -> { | 368 | LivekitRtc.SignalResponse.MessageCase.LEAVE -> { |
| 369 | listener?.onLeave() | 369 | listener?.onLeave() |
| @@ -376,7 +376,7 @@ constructor( | @@ -376,7 +376,7 @@ constructor( | ||
| 376 | } | 376 | } |
| 377 | LivekitRtc.SignalResponse.MessageCase.MESSAGE_NOT_SET, | 377 | LivekitRtc.SignalResponse.MessageCase.MESSAGE_NOT_SET, |
| 378 | null -> { | 378 | null -> { |
| 379 | - Timber.v { "empty messageCase!" } | 379 | + LKLog.v { "empty messageCase!" } |
| 380 | } | 380 | } |
| 381 | }.safe() | 381 | }.safe() |
| 382 | } | 382 | } |
| 1 | package io.livekit.android.room | 1 | package io.livekit.android.room |
| 2 | 2 | ||
| 3 | -import com.github.ajalt.timberkt.Timber | 3 | +import io.livekit.android.util.LKLog |
| 4 | import livekit.LivekitRtc | 4 | import livekit.LivekitRtc |
| 5 | import org.webrtc.* | 5 | import org.webrtc.* |
| 6 | 6 | ||
| @@ -15,33 +15,33 @@ class SubscriberTransportObserver( | @@ -15,33 +15,33 @@ class SubscriberTransportObserver( | ||
| 15 | var iceConnectionChangeListener: ((PeerConnection.IceConnectionState?) -> Unit)? = null | 15 | var iceConnectionChangeListener: ((PeerConnection.IceConnectionState?) -> Unit)? = null |
| 16 | 16 | ||
| 17 | override fun onIceCandidate(candidate: IceCandidate) { | 17 | override fun onIceCandidate(candidate: IceCandidate) { |
| 18 | - Timber.v { "onIceCandidate: $candidate" } | 18 | + LKLog.v { "onIceCandidate: $candidate" } |
| 19 | client.sendCandidate(candidate, LivekitRtc.SignalTarget.SUBSCRIBER) | 19 | client.sendCandidate(candidate, LivekitRtc.SignalTarget.SUBSCRIBER) |
| 20 | } | 20 | } |
| 21 | 21 | ||
| 22 | override fun onAddTrack(receiver: RtpReceiver, streams: Array<out MediaStream>) { | 22 | override fun onAddTrack(receiver: RtpReceiver, streams: Array<out MediaStream>) { |
| 23 | val track = receiver.track() ?: return | 23 | val track = receiver.track() ?: return |
| 24 | - Timber.v { "onAddTrack: ${track.kind()}, ${track.id()}, ${streams.fold("") { sum, it -> "$sum, $it" }}" } | 24 | + LKLog.v { "onAddTrack: ${track.kind()}, ${track.id()}, ${streams.fold("") { sum, it -> "$sum, $it" }}" } |
| 25 | engine.listener?.onAddTrack(track, streams) | 25 | engine.listener?.onAddTrack(track, streams) |
| 26 | } | 26 | } |
| 27 | 27 | ||
| 28 | override fun onTrack(transceiver: RtpTransceiver) { | 28 | override fun onTrack(transceiver: RtpTransceiver) { |
| 29 | when (transceiver.mediaType) { | 29 | when (transceiver.mediaType) { |
| 30 | - MediaStreamTrack.MediaType.MEDIA_TYPE_AUDIO -> Timber.v { "peerconn started receiving audio" } | ||
| 31 | - MediaStreamTrack.MediaType.MEDIA_TYPE_VIDEO -> Timber.v { "peerconn started receiving video" } | ||
| 32 | - else -> Timber.d { "peerconn started receiving unknown media type: ${transceiver.mediaType}" } | 30 | + MediaStreamTrack.MediaType.MEDIA_TYPE_AUDIO -> LKLog.v { "peerconn started receiving audio" } |
| 31 | + MediaStreamTrack.MediaType.MEDIA_TYPE_VIDEO -> LKLog.v { "peerconn started receiving video" } | ||
| 32 | + else -> LKLog.d { "peerconn started receiving unknown media type: ${transceiver.mediaType}" } | ||
| 33 | } | 33 | } |
| 34 | } | 34 | } |
| 35 | 35 | ||
| 36 | override fun onDataChannel(channel: DataChannel) { | 36 | override fun onDataChannel(channel: DataChannel) { |
| 37 | - Timber.v { "onDataChannel" } | 37 | + LKLog.v { "onDataChannel" } |
| 38 | } | 38 | } |
| 39 | 39 | ||
| 40 | override fun onStandardizedIceConnectionChange(newState: PeerConnection.IceConnectionState?) { | 40 | override fun onStandardizedIceConnectionChange(newState: PeerConnection.IceConnectionState?) { |
| 41 | } | 41 | } |
| 42 | 42 | ||
| 43 | override fun onConnectionChange(newState: PeerConnection.PeerConnectionState?) { | 43 | override fun onConnectionChange(newState: PeerConnection.PeerConnectionState?) { |
| 44 | - Timber.v { "onConnectionChange new state: $newState" } | 44 | + LKLog.v { "onConnectionChange new state: $newState" } |
| 45 | } | 45 | } |
| 46 | 46 | ||
| 47 | override fun onSelectedCandidatePairChanged(event: CandidatePairChangeEvent?) { | 47 | override fun onSelectedCandidatePairChanged(event: CandidatePairChangeEvent?) { |
| @@ -51,7 +51,7 @@ class SubscriberTransportObserver( | @@ -51,7 +51,7 @@ class SubscriberTransportObserver( | ||
| 51 | } | 51 | } |
| 52 | 52 | ||
| 53 | override fun onIceConnectionChange(newState: PeerConnection.IceConnectionState?) { | 53 | override fun onIceConnectionChange(newState: PeerConnection.IceConnectionState?) { |
| 54 | - Timber.v { "onIceConnection new state: $newState" } | 54 | + LKLog.v { "onIceConnection new state: $newState" } |
| 55 | iceConnectionChangeListener?.invoke(newState) | 55 | iceConnectionChangeListener?.invoke(newState) |
| 56 | } | 56 | } |
| 57 | 57 |
| 1 | package io.livekit.android.room.participant | 1 | package io.livekit.android.room.participant |
| 2 | 2 | ||
| 3 | import android.content.Context | 3 | import android.content.Context |
| 4 | -import com.github.ajalt.timberkt.Timber | ||
| 5 | import com.google.protobuf.ByteString | 4 | import com.google.protobuf.ByteString |
| 6 | import dagger.assisted.Assisted | 5 | import dagger.assisted.Assisted |
| 7 | import dagger.assisted.AssistedFactory | 6 | import dagger.assisted.AssistedFactory |
| 8 | import dagger.assisted.AssistedInject | 7 | import dagger.assisted.AssistedInject |
| 9 | import io.livekit.android.room.RTCEngine | 8 | import io.livekit.android.room.RTCEngine |
| 10 | import io.livekit.android.room.track.* | 9 | import io.livekit.android.room.track.* |
| 10 | +import io.livekit.android.util.LKLog | ||
| 11 | import livekit.LivekitModels | 11 | import livekit.LivekitModels |
| 12 | import livekit.LivekitRtc | 12 | import livekit.LivekitRtc |
| 13 | import org.webrtc.* | 13 | import org.webrtc.* |
| @@ -124,7 +124,7 @@ internal constructor( | @@ -124,7 +124,7 @@ internal constructor( | ||
| 124 | fun unpublishTrack(track: Track) { | 124 | fun unpublishTrack(track: Track) { |
| 125 | val publication = localTrackPublications.firstOrNull { it.track == track } | 125 | val publication = localTrackPublications.firstOrNull { it.track == track } |
| 126 | if (publication === null) { | 126 | if (publication === null) { |
| 127 | - Timber.d { "this track was never published." } | 127 | + LKLog.d { "this track was never published." } |
| 128 | return | 128 | return |
| 129 | } | 129 | } |
| 130 | val sid = publication.sid | 130 | val sid = publication.sid |
| 1 | package io.livekit.android.room.participant | 1 | package io.livekit.android.room.participant |
| 2 | 2 | ||
| 3 | -import com.github.ajalt.timberkt.Timber | ||
| 4 | import io.livekit.android.room.SignalClient | 3 | import io.livekit.android.room.SignalClient |
| 5 | import io.livekit.android.room.track.* | 4 | import io.livekit.android.room.track.* |
| 6 | import io.livekit.android.util.CloseableCoroutineScope | 5 | import io.livekit.android.util.CloseableCoroutineScope |
| 6 | +import io.livekit.android.util.LKLog | ||
| 7 | import kotlinx.coroutines.SupervisorJob | 7 | import kotlinx.coroutines.SupervisorJob |
| 8 | import kotlinx.coroutines.delay | 8 | import kotlinx.coroutines.delay |
| 9 | import kotlinx.coroutines.launch | 9 | import kotlinx.coroutines.launch |
| @@ -83,7 +83,7 @@ class RemoteParticipant( | @@ -83,7 +83,7 @@ class RemoteParticipant( | ||
| 83 | if (triesLeft == 0) { | 83 | if (triesLeft == 0) { |
| 84 | val message = "Could not find published track with sid: $sid" | 84 | val message = "Could not find published track with sid: $sid" |
| 85 | val exception = TrackException.InvalidTrackStateException(message) | 85 | val exception = TrackException.InvalidTrackStateException(message) |
| 86 | - Timber.e { "remote participant ${this.sid} --- $message" } | 86 | + LKLog.e { "remote participant ${this.sid} --- $message" } |
| 87 | 87 | ||
| 88 | internalListener?.onTrackSubscriptionFailed(sid, exception, this) | 88 | internalListener?.onTrackSubscriptionFailed(sid, exception, this) |
| 89 | listener?.onTrackSubscriptionFailed(sid, exception, this) | 89 | listener?.onTrackSubscriptionFailed(sid, exception, this) |
| 1 | package io.livekit.android.room.track | 1 | package io.livekit.android.room.track |
| 2 | 2 | ||
| 3 | import android.content.Context | 3 | import android.content.Context |
| 4 | -import com.github.ajalt.timberkt.Timber | 4 | +import io.livekit.android.util.LKLog |
| 5 | import org.webrtc.* | 5 | import org.webrtc.* |
| 6 | import java.util.* | 6 | import java.util.* |
| 7 | 7 | ||
| @@ -114,7 +114,7 @@ class LocalVideoTrack( | @@ -114,7 +114,7 @@ class LocalVideoTrack( | ||
| 114 | createCameraCapturer(Camera1Enumerator(true), position) | 114 | createCameraCapturer(Camera1Enumerator(true), position) |
| 115 | } | 115 | } |
| 116 | if (videoCapturer == null) { | 116 | if (videoCapturer == null) { |
| 117 | - Timber.d { "Failed to open camera" } | 117 | + LKLog.d { "Failed to open camera" } |
| 118 | return null | 118 | return null |
| 119 | } | 119 | } |
| 120 | return videoCapturer | 120 | return videoCapturer |
| @@ -125,13 +125,13 @@ class LocalVideoTrack( | @@ -125,13 +125,13 @@ class LocalVideoTrack( | ||
| 125 | 125 | ||
| 126 | for (deviceName in deviceNames) { | 126 | for (deviceName in deviceNames) { |
| 127 | if (enumerator.isFrontFacing(deviceName) && position == CameraPosition.FRONT) { | 127 | if (enumerator.isFrontFacing(deviceName) && position == CameraPosition.FRONT) { |
| 128 | - Timber.v { "Creating front facing camera capturer." } | 128 | + LKLog.v { "Creating front facing camera capturer." } |
| 129 | val videoCapturer = enumerator.createCapturer(deviceName, null) | 129 | val videoCapturer = enumerator.createCapturer(deviceName, null) |
| 130 | if (videoCapturer != null) { | 130 | if (videoCapturer != null) { |
| 131 | return videoCapturer | 131 | return videoCapturer |
| 132 | } | 132 | } |
| 133 | } else if (enumerator.isBackFacing(deviceName) && position == CameraPosition.BACK) { | 133 | } else if (enumerator.isBackFacing(deviceName) && position == CameraPosition.BACK) { |
| 134 | - Timber.v { "Creating back facing camera capturer." } | 134 | + LKLog.v { "Creating back facing camera capturer." } |
| 135 | val videoCapturer = enumerator.createCapturer(deviceName, null) | 135 | val videoCapturer = enumerator.createCapturer(deviceName, null) |
| 136 | if (videoCapturer != null) { | 136 | if (videoCapturer != null) { |
| 137 | return videoCapturer | 137 | return videoCapturer |
| 1 | +package io.livekit.android.util | ||
| 2 | + | ||
| 3 | +import io.livekit.android.util.LoggingLevel.* | ||
| 4 | +import timber.log.Timber | ||
| 5 | + | ||
| 6 | +/* | ||
| 7 | +Copyright 2017-2018 AJ Alt | ||
| 8 | +Licensed under the Apache License, Version 2.0 (the "License"); | ||
| 9 | +you may not use this file except in compliance with the License. | ||
| 10 | +You may obtain a copy of the License at | ||
| 11 | + | ||
| 12 | +http://www.apache.org/licenses/LICENSE-2.0 | ||
| 13 | + | ||
| 14 | +Unless required by applicable law or agreed to in writing, software | ||
| 15 | +distributed under the License is distributed on an "AS IS" BASIS, | ||
| 16 | +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| 17 | +See the License for the specific language governing permissions and | ||
| 18 | +limitations under the License. | ||
| 19 | + | ||
| 20 | +Original repo can be found at: https://github.com/ajalt/LKLogkt | ||
| 21 | + */ | ||
| 22 | + | ||
| 23 | +internal class LKLog { | ||
| 24 | + | ||
| 25 | + companion object { | ||
| 26 | + var loggingLevel = OFF | ||
| 27 | + | ||
| 28 | + | ||
| 29 | + /** Log a verbose exception and a message that will be evaluated lazily when the message is printed */ | ||
| 30 | + @JvmStatic | ||
| 31 | + inline fun v(t: Throwable? = null, message: () -> String) = | ||
| 32 | + log(VERBOSE) { Timber.v(t, message()) } | ||
| 33 | + | ||
| 34 | + @JvmStatic | ||
| 35 | + inline fun v(t: Throwable?) = log(VERBOSE) { Timber.v(t) } | ||
| 36 | + | ||
| 37 | + /** Log a debug exception and a message that will be evaluated lazily when the message is printed */ | ||
| 38 | + @JvmStatic | ||
| 39 | + inline fun d(t: Throwable? = null, message: () -> String) = | ||
| 40 | + log(DEBUG) { Timber.d(t, message()) } | ||
| 41 | + | ||
| 42 | + @JvmStatic | ||
| 43 | + inline fun d(t: Throwable?) = log(DEBUG) { Timber.d(t) } | ||
| 44 | + | ||
| 45 | + /** Log an info exception and a message that will be evaluated lazily when the message is printed */ | ||
| 46 | + @JvmStatic | ||
| 47 | + inline fun i(t: Throwable? = null, message: () -> String) = | ||
| 48 | + log(INFO) { Timber.i(t, message()) } | ||
| 49 | + | ||
| 50 | + @JvmStatic | ||
| 51 | + inline fun i(t: Throwable?) = log(INFO) { Timber.i(t) } | ||
| 52 | + | ||
| 53 | + /** Log a warning exception and a message that will be evaluated lazily when the message is printed */ | ||
| 54 | + @JvmStatic | ||
| 55 | + inline fun w(t: Throwable? = null, message: () -> String) = | ||
| 56 | + log(WARN) { Timber.w(t, message()) } | ||
| 57 | + | ||
| 58 | + @JvmStatic | ||
| 59 | + inline fun w(t: Throwable?) = log(WARN) { Timber.w(t) } | ||
| 60 | + | ||
| 61 | + /** Log an error exception and a message that will be evaluated lazily when the message is printed */ | ||
| 62 | + @JvmStatic | ||
| 63 | + inline fun e(t: Throwable? = null, message: () -> String) = | ||
| 64 | + log(ERROR) { Timber.e(t, message()) } | ||
| 65 | + | ||
| 66 | + @JvmStatic | ||
| 67 | + inline fun e(t: Throwable?) = log(ERROR) { Timber.e(t) } | ||
| 68 | + | ||
| 69 | + /** Log an assert exception and a message that will be evaluated lazily when the message is printed */ | ||
| 70 | + @JvmStatic | ||
| 71 | + inline fun wtf(t: Throwable? = null, message: () -> String) = | ||
| 72 | + log(WTF) { Timber.wtf(t, message()) } | ||
| 73 | + | ||
| 74 | + @JvmStatic | ||
| 75 | + inline fun wtf(t: Throwable?) = log(WTF) { Timber.wtf(t) } | ||
| 76 | + | ||
| 77 | + /** @suppress */ | ||
| 78 | + internal inline fun log(loggingLevel: LoggingLevel, block: () -> Unit) { | ||
| 79 | + if (loggingLevel >= LKLog.loggingLevel && Timber.treeCount() > 0) block() | ||
| 80 | + } | ||
| 81 | + } | ||
| 82 | +} |
| 1 | package io.livekit.android.composesample | 1 | package io.livekit.android.composesample |
| 2 | 2 | ||
| 3 | import android.app.Application | 3 | import android.app.Application |
| 4 | -import timber.log.Timber | 4 | +import io.livekit.android.LiveKit |
| 5 | +import io.livekit.android.util.LoggingLevel | ||
| 5 | 6 | ||
| 6 | class SampleApplication : Application() { | 7 | class SampleApplication : Application() { |
| 7 | 8 | ||
| 8 | override fun onCreate() { | 9 | override fun onCreate() { |
| 9 | super.onCreate() | 10 | super.onCreate() |
| 10 | - Timber.plant(Timber.DebugTree()) | 11 | + LiveKit.loggingLevel = LoggingLevel.OFF |
| 11 | } | 12 | } |
| 12 | } | 13 | } |
| 1 | package io.livekit.android.sample | 1 | package io.livekit.android.sample |
| 2 | 2 | ||
| 3 | import android.app.Application | 3 | import android.app.Application |
| 4 | -import timber.log.Timber | 4 | +import io.livekit.android.LiveKit |
| 5 | +import io.livekit.android.util.LoggingLevel | ||
| 5 | 6 | ||
| 6 | class SampleApplication : Application() { | 7 | class SampleApplication : Application() { |
| 7 | 8 | ||
| 8 | override fun onCreate() { | 9 | override fun onCreate() { |
| 9 | super.onCreate() | 10 | super.onCreate() |
| 10 | - Timber.plant(Timber.DebugTree()) | 11 | + LiveKit.loggingLevel = LoggingLevel.VERBOSE |
| 11 | } | 12 | } |
| 12 | } | 13 | } |
-
请 注册 或 登录 后发表评论