diff --git a/demo-app/src/main/kotlin/io/getstream/video/android/ui/call/CallScreen.kt b/demo-app/src/main/kotlin/io/getstream/video/android/ui/call/CallScreen.kt index de97cbf15c1..9aad60cb25c 100644 --- a/demo-app/src/main/kotlin/io/getstream/video/android/ui/call/CallScreen.kt +++ b/demo-app/src/main/kotlin/io/getstream/video/android/ui/call/CallScreen.kt @@ -44,7 +44,6 @@ import androidx.compose.material.icons.filled.RadioButtonChecked import androidx.compose.material.rememberModalBottomSheetState import androidx.compose.runtime.Composable import androidx.compose.runtime.LaunchedEffect -import androidx.compose.runtime.collectAsState import androidx.compose.runtime.getValue import androidx.compose.runtime.mutableIntStateOf import androidx.compose.runtime.mutableStateListOf @@ -108,7 +107,6 @@ import io.getstream.video.android.ui.menu.availableVideoFilters import io.getstream.video.android.util.config.AppConfig import kotlinx.coroutines.GlobalScope import kotlinx.coroutines.delay -import kotlinx.coroutines.flow.firstOrNull import kotlinx.coroutines.launch import org.openapitools.client.models.OwnCapability @@ -153,7 +151,7 @@ fun CallScreen( var preferredScaleType by remember { mutableStateOf(VideoScalingType.SCALE_ASPECT_FILL) } val connection by call.state.connection.collectAsStateWithLifecycle() - val me by call.state.me.collectAsState() + val me by call.state.me.collectAsStateWithLifecycle() LaunchedEffect(key1 = connection) { if (connection == RealtimeConnection.Disconnected) { @@ -335,8 +333,7 @@ fun CallScreen( ) }, floatingVideoRenderer = { _, _ -> - val myself = me ?: participantsSize.firstOrNull { it.sessionId == call.sessionId } - myself?.let { + me?.let { FloatingParticipantVideo( call = call, participant = it, diff --git a/stream-video-android-core/src/main/kotlin/io/getstream/video/android/core/CallState.kt b/stream-video-android-core/src/main/kotlin/io/getstream/video/android/core/CallState.kt index b3a62edf7c7..43ae1ac3f04 100644 --- a/stream-video-android-core/src/main/kotlin/io/getstream/video/android/core/CallState.kt +++ b/stream-video-android-core/src/main/kotlin/io/getstream/video/android/core/CallState.kt @@ -223,8 +223,8 @@ public class CallState( val totalParticipants = _participantCounts.mapState { it?.total ?: 0 } /** Your own participant state */ - public val me: StateFlow = _participants.mapState { - it[call.sessionId] + public val me: StateFlow = _participants.mapState { map -> + map[call.sessionId] ?: participants.value.find { it.isLocal } } /** Your own participant state */ diff --git a/stream-video-android-core/src/main/kotlin/io/getstream/video/android/core/call/RtcSession.kt b/stream-video-android-core/src/main/kotlin/io/getstream/video/android/core/call/RtcSession.kt index 0287768d4f5..96c3859199f 100644 --- a/stream-video-android-core/src/main/kotlin/io/getstream/video/android/core/call/RtcSession.kt +++ b/stream-video-android-core/src/main/kotlin/io/getstream/video/android/core/call/RtcSession.kt @@ -693,8 +693,7 @@ public class RtcSession internal constructor( throw IllegalStateException( "Cant send audio and video since publisher hasn't been setup to connect", ) - } - publisher?.let { publisher -> + } else { // step 2 ensure all tracks are setup correctly // start capturing the video diff --git a/stream-video-android-core/src/main/kotlin/io/getstream/video/android/core/socket/sfu/SfuSocketConnection.kt b/stream-video-android-core/src/main/kotlin/io/getstream/video/android/core/socket/sfu/SfuSocketConnection.kt index 404a95d8160..07693ed8019 100644 --- a/stream-video-android-core/src/main/kotlin/io/getstream/video/android/core/socket/sfu/SfuSocketConnection.kt +++ b/stream-video-android-core/src/main/kotlin/io/getstream/video/android/core/socket/sfu/SfuSocketConnection.kt @@ -40,6 +40,7 @@ import io.getstream.video.android.model.ApiKey import io.getstream.video.android.model.SfuToken import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.channels.BufferOverflow +import kotlinx.coroutines.delay import kotlinx.coroutines.flow.MutableSharedFlow import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.StateFlow @@ -149,6 +150,7 @@ class SfuSocketConnection( scope.launch { internalSocket.awaitConnection(connectionTimeout) internalSocket.connectionIdOrError().also { + delay(500) // Wait for the connection to settle then call `connected` connected(it) } }