Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ Supported platforms: Android (minimum API level 21)

- Assemble: `./gradlew assemble`
- Run tests: `./gradlew test`
- Run detekt (static analysis): `./gradlew detektDebug`
- Run detekt with baseline: `./gradlew detektRelease`
- Install example app: `./gradlew sample-app-compose:installDebug`

## Architecture
Expand Down
6 changes: 5 additions & 1 deletion config/detekt/detekt.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ config:
warningsAsErrors: true
excludes: ''

empty-blocks:
EmptyFunctionBlock:
ignoreOverridden: true

style:
active: false

Expand All @@ -20,4 +24,4 @@ livekit-rules:

exceptions:
TooGenericExceptionCaught:
active: false
active: false
2 changes: 1 addition & 1 deletion livekit-android-sdk/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ protobuf {
}

jacoco {
toolVersion = "0.8.10"
toolVersion = "0.8.14"
}

tasks.withType(Test) {
Expand Down
33 changes: 0 additions & 33 deletions livekit-android-sdk/detekt-baseline-release.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,32 +27,9 @@
<ID>CyclomaticComplexMethod:Room.kt$Room$@Throws(Exception::class) suspend fun connect(url: String, token: String, options: ConnectOptions = ConnectOptions())</ID>
<ID>CyclomaticComplexMethod:RoomEvent.kt$fun LivekitModels.DisconnectReason?.convert(): DisconnectReason</ID>
<ID>CyclomaticComplexMethod:SignalClient.kt$SignalClient$private fun handleSignalResponseImpl(ws: WebSocket, response: LivekitRtc.SignalResponse)</ID>
<ID>DoubleMutabilityForCollection:CoroutineSdpObserver.kt$CoroutineSdpObserver$private var pendingCreate = mutableListOf&lt;Continuation&lt;Either&lt;SessionDescription, String?>>>()</ID>
<ID>DoubleMutabilityForCollection:CoroutineSdpObserver.kt$CoroutineSdpObserver$private var pendingSets = mutableListOf&lt;Continuation&lt;Either&lt;Unit, String?>>>()</ID>
<ID>DoubleMutabilityForCollection:E2EEManager.kt$E2EEManager$private var frameCryptors = mutableMapOf&lt;Pair&lt;String, Participant.Identity>, FrameCryptor>()</ID>
<ID>DoubleMutabilityForCollection:PeerConnectionTransport.kt$PeerConnectionTransport$private var trackBitrates = mutableMapOf&lt;TrackBitrateInfoKey, TrackBitrateInfo>()</ID>
<ID>DoubleMutabilityForCollection:RegionUrlProvider.kt$RegionUrlProvider$private var attemptedRegions = mutableSetOf&lt;RegionInfo>()</ID>
<ID>DoubleMutabilityForCollection:Room.kt$Room$private var sidToIdentity = mutableMapOf&lt;Participant.Sid, Participant.Identity>()</ID>
<ID>DoubleMutabilityForCollection:Room.kt$Room$private var transcriptionReceivedTimes = mutableMapOf&lt;String, Long>()</ID>
<ID>EmptyCatchBlock:EndpointTokenSource.kt$EndpointTokenSource.&lt;no name provided>${ }</ID>
<ID>EmptyDefaultConstructor:CachingTokenSource.kt$InMemoryTokenStore$()</ID>
<ID>EmptyDefaultConstructor:LocalScreencastVideoTrack.kt$LocalScreencastVideoTrack.MediaProjectionCallback$()</ID>
<ID>EmptyFunctionBlock:CommunicationWorkaround.kt$NoopCommunicationWorkaround${ }</ID>
<ID>EmptyFunctionBlock:LocalVideoTrack.kt$LocalVideoTrack.&lt;no name provided>.&lt;no name provided>${ }</ID>
<ID>EmptyFunctionBlock:NoAudioHandler.kt$NoAudioHandler${ }</ID>
<ID>EmptyFunctionBlock:PublisherTransportObserver.kt$PublisherTransportObserver${ }</ID>
<ID>EmptyFunctionBlock:RTCEngine.kt$RTCEngine${ }</ID>
<ID>EmptyFunctionBlock:Room.kt$Room${ }</ID>
<ID>EmptyFunctionBlock:SubscriberTransportObserver.kt$SubscriberTransportObserver${ }</ID>
<ID>EmptyFunctionBlock:TextureViewRenderer.kt$TextureViewRenderer${}</ID>
<ID>EmptyFunctionBlock:VideoFrameCapturer.kt$VideoFrameCapturer${ }</ID>
<ID>HasPlatformType:DataChannelManager.kt$DataChannelManager$@get:FlowObservable var state by flowDelegate(dataChannel.state()) private set</ID>
<ID>HasPlatformType:RTCModule.kt$RTCModule$@Provides fun sdpFactory()</ID>
<ID>IgnoredReturnValue:BaseStreamReceiver.kt$BaseStreamReceiver$catch { }</ID>
<ID>InjectDispatcher:CoroutinesModule.kt$CoroutinesModule$Default</ID>
<ID>InjectDispatcher:CoroutinesModule.kt$CoroutinesModule$IO</ID>
<ID>InjectDispatcher:CoroutinesModule.kt$CoroutinesModule$Unconfined</ID>
<ID>InjectDispatcher:NetworkMonitor.kt$NetworkMonitor$IO</ID>
<ID>InstanceOfCheckForException:LocalParticipant.kt$LocalParticipant$e is RpcError</ID>
<ID>LargeClass:LocalParticipant.kt$LocalParticipant : ParticipantOutgoingDataStreamManagerRpcManager</ID>
<ID>LargeClass:RTCEngine.kt$RTCEngine : Listener</ID>
Expand Down Expand Up @@ -106,14 +83,9 @@
<ID>NestedBlockDepth:RTCEngine.kt$RTCEngine$private fun makeRTCConfig( serverResponse: Either&lt;JoinResponse, ReconnectResponse>, connectOptions: ConnectOptions, ): RTCConfiguration</ID>
<ID>NestedBlockDepth:Room.kt$Room$override suspend fun onPostReconnect(isFullReconnect: Boolean)</ID>
<ID>NestedBlockDepth:SignalClient.kt$SignalClient$override fun onFailure(webSocket: WebSocket, t: Throwable, response: Response?)</ID>
<ID>SwallowedException:EndpointTokenSource.kt$EndpointTokenSource.&lt;no name provided>$e: Exception</ID>
<ID>SwallowedException:FlowExt.kt$e: CancellationException</ID>
<ID>SwallowedException:LocalVideoTrack.kt$LocalVideoTrack$e: Exception</ID>
<ID>SwallowedException:NetworkCallbackManager.kt$NetworkCallbackManagerImpl$e: IllegalArgumentException</ID>
<ID>SwallowedException:RemoteParticipant.kt$RemoteParticipant$e: Exception</ID>
<ID>SwallowedException:TextureViewRenderer.kt$TextureViewRenderer$e: NotFoundException</ID>
<ID>ThrowingExceptionsWithoutMessageOrCause:LKDebugTree.kt$LKDebugTree$Throwable()</ID>
<ID>ThrowingExceptionsWithoutMessageOrCause:SignalClient.kt$SignalClient$Exception()</ID>
<ID>TooManyFunctions:CommunicationWorkaround.kt$CommunicationWorkaroundImpl : CommunicationWorkaround</ID>
<ID>TooManyFunctions:E2EEManager.kt$E2EEManager</ID>
<ID>TooManyFunctions:IncomingDataStreamManager.kt$IncomingDataStreamManagerImpl : IncomingDataStreamManager</ID>
Expand All @@ -135,17 +107,12 @@
<ID>TooManyFunctions:SimulcastVideoEncoderFactoryWrapper.kt$SimulcastVideoEncoderFactoryWrapper$StreamEncoderWrapper : VideoEncoder</ID>
<ID>TooManyFunctions:SubscriberTransportObserver.kt$SubscriberTransportObserver : ObserverPeerConnectionStateObservable</ID>
<ID>TooManyFunctions:TextureViewRenderer.kt$TextureViewRenderer : TextureViewCallbackSurfaceTextureListenerVideoSinkRendererEventsNotifier</ID>
<ID>UnnecessaryNotNullOperator:E2EEManager.kt$E2EEManager$room!!</ID>
<ID>UnnecessaryNotNullOperator:Room.kt$Room$e2eeManager!!</ID>
<ID>UnnecessarySafeCall:E2EEManager.kt$E2EEManager$(publication.track!! as LocalAudioTrack)?.sender</ID>
<ID>UnnecessarySafeCall:E2EEManager.kt$E2EEManager$(publication.track!! as LocalVideoTrack)?.sender</ID>
<ID>UnsafeCallOnNullableType:AudioSwitchHandler.kt$AudioSwitchHandler$thread!!</ID>
<ID>UnsafeCallOnNullableType:CustomAudioProcessingFactory.kt$CustomAudioProcessingFactory.AudioProcessingBridge$buffer!!</ID>
<ID>UnsafeCallOnNullableType:DataPacketBuffer.kt$DataPacketBuffer$item!!</ID>
<ID>UnsafeCallOnNullableType:E2EEManager.kt$E2EEManager$participant.identity!!</ID>
<ID>UnsafeCallOnNullableType:E2EEManager.kt$E2EEManager$publication.track!!</ID>
<ID>UnsafeCallOnNullableType:E2EEManager.kt$E2EEManager$rtpReceiver!!</ID>
<ID>UnsafeCallOnNullableType:E2EEManager.kt$E2EEManager$rtpSender!!</ID>
<ID>UnsafeCallOnNullableType:E2EEManager.kt$E2EEManager$this.room!!</ID>
<ID>UnsafeCallOnNullableType:EncodingUtils.kt$EncodingUtils$encodings.first().scalabilityMode!!</ID>
<ID>UnsafeCallOnNullableType:LocalParticipant.kt$LocalParticipant$options.backupCodec!!</ID>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2023-2024 LiveKit, Inc.
* Copyright 2023-2026 LiveKit, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -25,6 +25,7 @@ import javax.inject.Named
* @suppress
*/
@Module
@Suppress("InjectDispatcher")
internal object CoroutinesModule {
@Provides
@Named(InjectionNames.DISPATCHER_DEFAULT)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,7 @@ internal object RTCModule {
fun videoHwAccel() = true

@Provides
fun sdpFactory() = SdpFactory.getInstance()
fun sdpFactory(): SdpFactory = SdpFactory.getInstance()
}

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2023-2025 LiveKit, Inc.
* Copyright 2023-2026 LiveKit, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -48,7 +48,7 @@ constructor(
dataPacketCryptorManagerFactory: DataPacketCryptorManager.Factory,
) {
private var room: Room? = null
private var frameCryptors = mutableMapOf<Pair<String, Participant.Identity>, FrameCryptor>()
private val frameCryptors = mutableMapOf<Pair<String, Participant.Identity>, FrameCryptor>()
private var algorithm: FrameCryptorAlgorithm = FrameCryptorAlgorithm.AES_GCM
private lateinit var emitEvent: (roomEvent: RoomEvent) -> Unit?

Expand Down Expand Up @@ -116,7 +116,7 @@ constructor(
LKLog.i { "Receiver::onFrameCryptionStateChanged: $trackId, state: $state" }
emitEvent(
RoomEvent.TrackE2EEStateEvent(
room!!,
room,
publication.track!!,
publication,
participant,
Expand All @@ -138,15 +138,15 @@ constructor(
}

fun addPublishedTrack(track: Track, publication: TrackPublication, participant: LocalParticipant, room: Room) {
val rtpSender: RtpSender? = when (publication.track!!) {
is LocalAudioTrack -> (publication.track!! as LocalAudioTrack)?.sender
is LocalVideoTrack -> (publication.track!! as LocalVideoTrack)?.sender
val rtpSender: RtpSender = when (publication.track!!) {
is LocalAudioTrack -> (publication.track!! as LocalAudioTrack).sender
is LocalVideoTrack -> (publication.track!! as LocalVideoTrack).sender
else -> {
throw IllegalArgumentException("unsupported track type")
}
} ?: throw IllegalArgumentException("rtpSender is null")

val frameCryptor = addRtpSender(rtpSender!!, participant.identity!!, publication.sid, publication.track!!.kind.name.lowercase())
val frameCryptor = addRtpSender(rtpSender, participant.identity!!, publication.sid, publication.track!!.kind.name.lowercase())
frameCryptor.setObserver { trackId, state ->
LKLog.i { "Sender::onFrameCryptionStateChanged: $trackId, state: $state" }
emitEvent(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2023-2025 LiveKit, Inc.
* Copyright 2023-2026 LiveKit, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -93,7 +93,7 @@ constructor(

private var renegotiate = false

private var trackBitrates = mutableMapOf<TrackBitrateInfoKey, TrackBitrateInfo>()
private val trackBitrates = mutableMapOf<TrackBitrateInfoKey, TrackBitrateInfo>()
private var isClosed = AtomicBoolean(false)

private val latestOfferId = AtomicInteger(0)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2024-2025 LiveKit, Inc.
* Copyright 2024-2026 LiveKit, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -47,7 +47,7 @@ constructor(
private var regionSettings: RegionSettings? = null
private var lastUpdateAt: Long = 0L
private var settingsCacheTimeMs = 30000
private var attemptedRegions = mutableSetOf<RegionInfo>()
private val attemptedRegions = mutableSetOf<RegionInfo>()

fun isLKCloud() = serverUrl.isLKCloud()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ constructor(
val serverInfo: ServerInfo?
get() = engine.serverInfo

private var sidToIdentity = mutableMapOf<Participant.Sid, Participant.Identity>()
private val sidToIdentity = mutableMapOf<Participant.Sid, Participant.Identity>()

private var mutableActiveSpeakers by flowDelegate(emptyList<Participant>())

Expand All @@ -364,7 +364,7 @@ constructor(
private var regionUrlProvider: RegionUrlProvider? = null
private var regionUrl: String? = null

private var transcriptionReceivedTimes = mutableMapOf<String, Long>()
private val transcriptionReceivedTimes = mutableMapOf<String, Long>()

internal var isPrerecording by defaultsManager::isPrerecording

Expand Down Expand Up @@ -1521,9 +1521,7 @@ constructor(
* @suppress
*/
override fun onTrackUnpublished(publication: LocalTrackPublication, participant: LocalParticipant) {
e2eeManager?.let { e2eeManager ->
e2eeManager!!.removePublishedTrack(publication.track!!, publication, participant, this)
}
e2eeManager?.removePublishedTrack(publication.track!!, publication, participant, this)
eventBus.postEvent(RoomEvent.TrackUnpublished(this, publication, participant), coroutineScope)
}

Expand Down Expand Up @@ -1556,9 +1554,7 @@ constructor(
publication: RemoteTrackPublication,
participant: RemoteParticipant,
) {
e2eeManager?.let { e2eeManager ->
e2eeManager!!.removeSubscribedTrack(track, publication, participant, this)
}
e2eeManager?.removeSubscribedTrack(track, publication, participant, this)
eventBus.postEvent(RoomEvent.TrackUnsubscribed(this, track, publication, participant), coroutineScope)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -866,6 +866,7 @@ constructor(
* Can be reused afterwards.
*/
fun close(code: Int = CLOSE_REASON_NORMAL_CLOSURE, reason: String = "Normal Closure", shouldClearQueuedRequests: Boolean = true) {
@Suppress("ThrowingExceptionsWithoutMessageOrCause")
LKLog.v(Exception()) { "Closing SignalClient: code = $code, reason = $reason" }
isConnected = false
isReconnecting = false
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2024 LiveKit, Inc.
* Copyright 2024-2026 LiveKit, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -88,6 +88,7 @@ class NetworkCallbackManagerImpl(
@Synchronized
override fun unregisterCallback() {
if (!isClosed.get() && isRegistered.compareAndSet(true, false)) {
@Suppress("SwallowedException")
try {
connectivityManager.unregisterNetworkCallback(networkCallback)
} catch (e: IllegalArgumentException) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2023-2025 LiveKit, Inc.
* Copyright 2023-2026 LiveKit, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -206,6 +206,7 @@ class RemoteParticipant(

val track = publication.track
if (track != null) {
@Suppress("SwallowedException")
try {
track.stop()
} catch (e: Exception) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2023-2025 LiveKit, Inc.
* Copyright 2023-2026 LiveKit, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -210,7 +210,7 @@ constructor(
/**
* Needed to deal with circular dependency.
*/
class MediaProjectionCallback() : MediaProjection.Callback() {
class MediaProjectionCallback : MediaProjection.Callback() {

var track: Track? = null

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2023-2024 LiveKit, Inc.
* Copyright 2023-2026 LiveKit, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -53,7 +53,7 @@ internal open class CoroutineSdpObserver : SdpObserver {
}
}

private var pendingCreate = mutableListOf<Continuation<Either<SessionDescription, String?>>>()
private val pendingCreate = mutableListOf<Continuation<Either<SessionDescription, String?>>>()

private var setOutcome: Either<Unit, String?>? = null
set(value) {
Expand All @@ -75,7 +75,7 @@ internal open class CoroutineSdpObserver : SdpObserver {
}
}
}
private var pendingSets = mutableListOf<Continuation<Either<Unit, String?>>>()
private val pendingSets = mutableListOf<Continuation<Either<Unit, String?>>>()

override fun onCreateSuccess(sdp: SessionDescription?) {
createOutcome = if (sdp == null) {
Expand Down

This file was deleted.

Loading
Loading