Skip to content

Commit

Permalink
Spotless & ApiDump
Browse files Browse the repository at this point in the history
  • Loading branch information
aleksandar-apostolov committed Oct 31, 2024
1 parent b0c5999 commit 6b081fb
Show file tree
Hide file tree
Showing 41 changed files with 1,444 additions and 360 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import android.os.Bundle
import android.util.Log
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.compose.foundation.isSystemInDarkTheme
import androidx.lifecycle.Lifecycle
import androidx.lifecycle.lifecycleScope
import androidx.lifecycle.repeatOnLifecycle
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -498,7 +498,7 @@ fun CallScreen(
onShowCallStats = {
isShowingStats = true
isShowingSettingMenu = false
}
},
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ import androidx.compose.material.icons.filled.BluetoothAudio
import androidx.compose.material.icons.filled.Feedback
import androidx.compose.material.icons.filled.Headphones
import androidx.compose.material.icons.filled.HeadsetMic
import androidx.compose.material.icons.filled.PortableWifiOff
import androidx.compose.material.icons.filled.Replay
import androidx.compose.material.icons.filled.RestartAlt
import androidx.compose.material.icons.filled.SettingsBackupRestore
Expand Down Expand Up @@ -168,7 +167,7 @@ fun reconnectMenu(
onRestartSubscriberIceClick: () -> Unit,
onSwitchSfuClick: () -> Unit,
onSfuRejoinClick: () -> Unit,
onSfuFastReconnectClick: () -> Unit
onSfuFastReconnectClick: () -> Unit,
) = listOf(
ActionMenuItem(
title = "Publisher - ICE restart",
Expand All @@ -194,7 +193,7 @@ fun reconnectMenu(
title = "Reconnect SFU - fast",
icon = Icons.Default.RestartAlt,
action = onSfuFastReconnectClick,
)
),
)

/**
Expand All @@ -208,7 +207,7 @@ fun debugSubmenu(
onRestartSubscriberIceClick: () -> Unit,
onSwitchSfuClick: () -> Unit,
onSfuRejoinClick: () -> Unit,
onSfuFastReconnectClick: () -> Unit
onSfuFastReconnectClick: () -> Unit,
) = listOf(
SubMenuItem(
title = "Available video codecs",
Expand All @@ -228,7 +227,7 @@ fun debugSubmenu(
onRestartSubscriberIceClick,
onSwitchSfuClick,
onSfuRejoinClick,
onSfuFastReconnectClick
onSfuFastReconnectClick,
),
)
),
)
926 changes: 781 additions & 145 deletions stream-video-android-core/api/stream-video-android-core.api

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -230,10 +230,14 @@ public class Call(
logger.d { "[onConnected] no args" }
val elapsedTimeMils = System.currentTimeMillis() - lastDisconnect
if (lastDisconnect > 0 && elapsedTimeMils < reconnectDeadlineMils) {
logger.d { "[onConnected] Reconnecting (fast) time since last disconnect is ${elapsedTimeMils / 1000} seconds. Deadline is ${reconnectDeadlineMils / 1000} seconds" }
logger.d {
"[onConnected] Reconnecting (fast) time since last disconnect is ${elapsedTimeMils / 1000} seconds. Deadline is ${reconnectDeadlineMils / 1000} seconds"
}
rejoin()
} else {
logger.d { "[onConnected] Reconnecting (full) time since last disconnect is ${elapsedTimeMils / 1000} seconds. Deadline is ${reconnectDeadlineMils / 1000} seconds" }
logger.d {
"[onConnected] Reconnecting (full) time since last disconnect is ${elapsedTimeMils / 1000} seconds. Deadline is ${reconnectDeadlineMils / 1000} seconds"
}
rejoin()
}
}
Expand All @@ -243,7 +247,9 @@ public class Call(
lastDisconnect = System.currentTimeMillis()
leaveTimeoutAfterDisconnect = scope.launch {
delay(clientImpl.leaveAfterDisconnectSeconds * 1000)
logger.d { "[onDisconnected] Leaving after being disconnected for ${clientImpl.leaveAfterDisconnectSeconds}" }
logger.d {
"[onDisconnected] Leaving after being disconnected for ${clientImpl.leaveAfterDisconnectSeconds}"
}
leave()
}
logger.d { "[onDisconnected] at $lastDisconnect" }
Expand Down Expand Up @@ -620,7 +626,7 @@ public class Call(
} else {
logger.e {
"[switchSfu] Failed to get a join response during " +
"migration - falling back to reconnect. Error ${joinResponse.errorOrNull()}"
"migration - falling back to reconnect. Error ${joinResponse.errorOrNull()}"
}
state._connection.value = RealtimeConnection.Reconnecting
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -933,13 +933,13 @@ public class CallState(
Log.d(
"RingingState",
"Flags: [\n" +
"acceptedByMe: $isAcceptedByMe,\n" +
"rejectedByMe: $isRejectedByMe,\n" +
"rejectReason: $rejectReason,\n" +
"hasActiveCall: $hasActiveCall\n" +
"hasRingingCall: $hasRingingCall\n" +
"userIsParticipant: $userIsParticipant,\n" +
"]",
"acceptedByMe: $isAcceptedByMe,\n" +
"rejectedByMe: $isRejectedByMe,\n" +
"rejectReason: $rejectReason,\n" +
"hasActiveCall: $hasActiveCall\n" +
"hasRingingCall: $hasRingingCall\n" +
"userIsParticipant: $userIsParticipant,\n" +
"]",
)

// no members - call is empty, we can join
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ class ClientState(private val client: StreamVideo) {
// Stream video client is used until full decoupling is archived between `CallState` and `StreamVideoClient (former StreamVideoImpl)
private val streamVideoClient: StreamVideoClient = client as StreamVideoClient


// API
/** Current user for the client. */
public val user: StateFlow<User?> = _user
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ import android.app.Notification
import android.content.Context
import androidx.lifecycle.ProcessLifecycleOwner
import com.jakewharton.threetenabp.AndroidThreeTen
import io.getstream.log.android.AndroidStreamLogger
import io.getstream.log.StreamLog
import io.getstream.log.android.AndroidStreamLogger
import io.getstream.log.streamLog
import io.getstream.video.android.core.internal.module.CoordinatorConnectionModule
import io.getstream.video.android.core.logging.LoggingLevel
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ import kotlinx.coroutines.withContext
import kotlinx.serialization.encodeToString
import kotlinx.serialization.json.Json
import okio.IOException
import org.openapitools.client.models.CallEndedEvent
import org.openapitools.client.models.OwnCapability
import org.openapitools.client.models.VideoEvent
import org.webrtc.CameraEnumerationAndroid.CaptureFormat
Expand All @@ -106,7 +105,6 @@ import org.webrtc.RtpParameters.Encoding
import org.webrtc.RtpTransceiver
import org.webrtc.SessionDescription
import retrofit2.HttpException
import stream.video.sfu.event.CallEnded
import stream.video.sfu.event.JoinRequest
import stream.video.sfu.event.LeaveCallRequest
import stream.video.sfu.event.Migration
Expand Down Expand Up @@ -394,11 +392,13 @@ public class RtcSession internal constructor(
sfuConnectionModule.socketConnection.state().collect { sfuSocketState ->
_sfuSfuSocketState.value = sfuSocketState
when (sfuSocketState) {
is SfuSocketState.Connected -> call.state._connection.value =
RealtimeConnection.Connected
is SfuSocketState.Connected ->
call.state._connection.value =
RealtimeConnection.Connected

is SfuSocketState.Connecting -> call.state._connection.value =
RealtimeConnection.InProgress
is SfuSocketState.Connecting ->
call.state._connection.value =
RealtimeConnection.InProgress
else -> {
// Ignore it
}
Expand Down Expand Up @@ -447,7 +447,7 @@ public class RtcSession internal constructor(
}
logger.e(
it.streamError.extractCause()
?: IllegalStateException("Error emitted without a cause on SFU connection.")
?: IllegalStateException("Error emitted without a cause on SFU connection."),
) { "permanent failure on socket connection" }
}
}
Expand Down Expand Up @@ -494,7 +494,7 @@ public class RtcSession internal constructor(
token = sfuToken,
fast_reconnect = false,
client_details = clientDetails,
reconnect_details = reconnectDetails
reconnect_details = reconnectDetails,
)
logger.d { "Connecting RTC, $request" }
listenToSfuSocket()
Expand Down Expand Up @@ -613,7 +613,7 @@ public class RtcSession internal constructor(
)
val trackType =
trackTypeMap[trackTypeString] ?: TrackType.fromValue(trackTypeString.toInt())
?: throw IllegalStateException("trackType not recognized: $trackTypeString")
?: throw IllegalStateException("trackType not recognized: $trackTypeString")

logger.i { "[addStream] #sfu; mediaStream: $mediaStream" }
mediaStream.audioTracks.forEach { track ->
Expand Down Expand Up @@ -1189,7 +1189,7 @@ public class RtcSession internal constructor(
if (it == null) {
logger.e {
"[handleEvent] Failed to remove track on ParticipantLeft " +
"- track ID: ${participant.session_id}). Tracks: $tracks"
"- track ID: ${participant.session_id}). Tracks: $tracks"
}
}
}
Expand All @@ -1202,15 +1202,15 @@ public class RtcSession internal constructor(
if (it == null) {
logger.e {
"[handleEvent] Failed to remove track dimension on ParticipantLeft " +
"- track ID: ${participant.session_id}). TrackDimensions: $newTrackDimensions"
"- track ID: ${participant.session_id}). TrackDimensions: $newTrackDimensions"
}
}
}
trackDimensions.value = newTrackDimensions
}

/**
Section, basic webrtc calls
Section, basic webrtc calls
*/

/**
Expand Down Expand Up @@ -1436,7 +1436,9 @@ public class RtcSession internal constructor(
delay(delayInMs[attempt])
attempt++
} else {
logger.e { "setPublisher failed after $attempt retries, asking the call monitor to do an ice restart" }
logger.e {
"setPublisher failed after $attempt retries, asking the call monitor to do an ice restart"
}
coroutineScope.launch { call.monitor.reconnect(forceRestart = true) }
break
}
Expand Down Expand Up @@ -1525,8 +1527,8 @@ public class RtcSession internal constructor(
sdpSession.parse(sdp)
val media = sdpSession.media.find { m ->
m.mline?.type == track.kind() &&
// if `msid` is not present, we assume that the track is the first one
(m.msid?.equals(track.id()) ?: true)
// if `msid` is not present, we assume that the track is the first one
(m.msid?.equals(track.id()) ?: true)
}

if (media?.mid == null) {
Expand Down Expand Up @@ -1812,7 +1814,9 @@ public class RtcSession internal constructor(
val publisherTracks = publisher?.let { pub ->
if (pub.connection.remoteDescription != null) {
getPublisherTracks(pub.connection.localDescription.description)
} else null
} else {
null
}
} ?: emptyList()
return Triple(previousSessionId, currentSubscriptions, publisherTracks)
}
Expand All @@ -1828,7 +1832,7 @@ public class RtcSession internal constructor(
session_id = sessionId,
token = sfuToken,
client_details = clientDetails,
reconnect_details = reconnectDetails
reconnect_details = reconnectDetails,
)
logger.d { "Connecting RTC, $request" }
listenToSfuSocket()
Expand Down Expand Up @@ -1917,7 +1921,7 @@ public class RtcSession internal constructor(

sfuConnectionModule.socketConnection.whenConnected {
sfuConnectionMigrationModule!!.socketConnection.sendEvent(
SfuDataRequest(SfuRequest(join_request = request))
SfuDataRequest(SfuRequest(join_request = request)),
)
}
// Wait until the socket connects - if it fails to connect then return to "Reconnecting"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,8 @@ public class StreamPeerConnection(
return when (state.value) {
PeerConnection.PeerConnectionState.NEW,
PeerConnection.PeerConnectionState.CONNECTED,
PeerConnection.PeerConnectionState.CONNECTING -> true
PeerConnection.PeerConnectionState.CONNECTING,
-> true
else -> false
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
/*
* Copyright (c) 2014-2024 Stream.io Inc. All rights reserved.
*
* Licensed under the Stream License;
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://github.com/GetStream/stream-video-android/blob/main/LICENSE
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package io.getstream.video.android.core.internal.module

import androidx.lifecycle.Lifecycle
Expand All @@ -6,14 +22,13 @@ import io.getstream.video.android.core.logging.LoggingLevel
import io.getstream.video.android.core.socket.common.scope.ClientScope
import io.getstream.video.android.core.socket.common.scope.UserScope
import io.getstream.video.android.model.ApiKey
import io.getstream.video.android.model.UserToken
import kotlinx.coroutines.CoroutineScope
import okhttp3.OkHttpClient

/**
* Api definition for any connection module.
*/
internal interface ConnectionModuleDeclaration<Api, SocketConnection, Http: OkHttpClient, Token> {
internal interface ConnectionModuleDeclaration<Api, SocketConnection, Http : OkHttpClient, Token> {
/**
* The application key.
*/
Expand Down Expand Up @@ -52,7 +67,7 @@ internal interface ConnectionModuleDeclaration<Api, SocketConnection, Http: OkHt
/**
* Logging levels.
*/
val loggingLevel: LoggingLevel get() = LoggingLevel()
val loggingLevel: LoggingLevel get() = LoggingLevel()

/**
* The user token.
Expand Down Expand Up @@ -83,4 +98,4 @@ internal interface ConnectionModuleDeclaration<Api, SocketConnection, Http: OkHt
* API to update the authentication type.
*/
fun updateAuthType(authType: String)
}
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
/*
* Copyright (c) 2014-2024 Stream.io Inc. All rights reserved.
*
* Licensed under the Stream License;
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://github.com/GetStream/stream-video-android/blob/main/LICENSE
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package io.getstream.video.android.core.internal.module

import okhttp3.Interceptor
Expand Down Expand Up @@ -42,4 +58,4 @@ internal class CoordinatorAuthInterceptor(
private const val STREAM_AUTH_TYPE = "stream-auth-type"
private const val HEADER_AUTHORIZATION = "Authorization"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ internal class CoordinatorConnectionModule(
.addConverterFactory(MoshiConverterFactory.create(Serializer.moshi))
.client(http).build()
}

// API
override val http: OkHttpClient = OkHttpClient.Builder().addInterceptor(HeadersInterceptor())
.addInterceptor(authInterceptor).addInterceptor(
Expand All @@ -76,7 +77,9 @@ internal class CoordinatorConnectionModule(
override val networkStateProvider: NetworkStateProvider by lazy {
NetworkStateProvider(
scope,
connectivityManager = context.getSystemService(Context.CONNECTIVITY_SERVICE) as ConnectivityManager,
connectivityManager = context.getSystemService(
Context.CONNECTIVITY_SERVICE,
) as ConnectivityManager,
)
}
override val api: ProductvideoApi by lazy { retrofit.create(ProductvideoApi::class.java) }
Expand All @@ -101,4 +104,3 @@ internal class CoordinatorConnectionModule(
authInterceptor.authType = authType
}
}

Loading

0 comments on commit 6b081fb

Please sign in to comment.