Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reconnect v2 #1219

Draft
wants to merge 69 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
69 commits
Select commit Hold shift + click to select a range
5c4ae39
Initial socket from chat implementation
aleksandar-apostolov Jul 9, 2024
1ab9358
Authenticate on connected in coordinator socket.
aleksandar-apostolov Jul 10, 2024
3bd89aa
Spotless
aleksandar-apostolov Jul 10, 2024
c797080
Merge branch 'refs/heads/develop' into socket_improvements
aleksandar-apostolov Jul 15, 2024
9cc4fe4
Migrate `CoordinatorSocket`
aleksandar-apostolov Jul 15, 2024
50f31cc
Spotless and API dump
aleksandar-apostolov Jul 15, 2024
8a2b619
Merge branch 'refs/heads/develop' into socket_improvements
aleksandar-apostolov Aug 5, 2024
26f36fc
Fix an issue where StreamCallActivity would leave the call when going…
aleksandar-apostolov Aug 8, 2024
8ed0fd3
Initial reconnect V2 implementation
aleksandar-apostolov Aug 8, 2024
2dbe94c
API dump
aleksandar-apostolov Aug 8, 2024
f4859b9
Spotless
aleksandar-apostolov Aug 8, 2024
e33637a
Correct JoinRequest
aleksandar-apostolov Aug 8, 2024
c0dc0fa
Merge branch 'refs/heads/socket_improvements' into feature/reconnect-v2
aleksandar-apostolov Aug 14, 2024
12b48f9
[WIP] Refactored Coordinator and SFU sockets
aleksandar-apostolov Aug 19, 2024
1b31488
Update correct type for SfuSocketStateEvent
aleksandar-apostolov Aug 19, 2024
4f53329
Update state in Connection module, package renaming
aleksandar-apostolov Aug 21, 2024
0ac3e31
Merge branch 'refs/heads/develop' into socket_improvements
aleksandar-apostolov Sep 10, 2024
a7f3576
Merge branch 'refs/heads/develop' into socket_improvements
aleksandar-apostolov Sep 17, 2024
18f0a98
Merge branch 'refs/heads/develop' into socket_improvements
aleksandar-apostolov Sep 25, 2024
ac25fe7
Resolve merge conflicts
aleksandar-apostolov Sep 25, 2024
ab6a883
Merge branch 'refs/heads/socket_improvements' into feature/reconnect-v2
aleksandar-apostolov Sep 26, 2024
a33a1aa
Continue refactoring
aleksandar-apostolov Sep 27, 2024
f108d6e
Add connection common implementation
aleksandar-apostolov Sep 30, 2024
374ef24
Keep refactoring the SFU socket
aleksandar-apostolov Oct 1, 2024
bd43828
Merge branch 'refs/heads/develop' into feature/reconnect-v2
aleksandar-apostolov Oct 14, 2024
300a892
Merge conflicts
aleksandar-apostolov Oct 14, 2024
41adbcf
Update
aleksandar-apostolov Oct 16, 2024
601deb1
Update
aleksandar-apostolov Oct 16, 2024
07262c4
Update
aleksandar-apostolov Oct 16, 2024
ca02dd5
Update
aleksandar-apostolov Oct 16, 2024
227bd86
Merge branch 'refs/heads/develop' into feature/reconnect-v2
aleksandar-apostolov Oct 16, 2024
9ad0baf
Update
aleksandar-apostolov Oct 16, 2024
3f907cd
Update
aleksandar-apostolov Oct 17, 2024
643073f
Update
aleksandar-apostolov Oct 17, 2024
35cc663
Update
aleksandar-apostolov Oct 17, 2024
c1beaa2
Update
aleksandar-apostolov Oct 17, 2024
db55df3
Update
aleksandar-apostolov Oct 21, 2024
0192d7b
Update
aleksandar-apostolov Oct 21, 2024
d68524d
Update
aleksandar-apostolov Oct 21, 2024
f147afd
Update
aleksandar-apostolov Oct 21, 2024
5130870
Update
aleksandar-apostolov Oct 23, 2024
a19336c
Merge branch 'refs/heads/develop' into feature/reconnect-v2
aleksandar-apostolov Oct 23, 2024
16d9cf9
Update
aleksandar-apostolov Oct 23, 2024
e81e161
Update
aleksandar-apostolov Oct 24, 2024
b08055f
Update
aleksandar-apostolov Oct 28, 2024
90a1567
Update
aleksandar-apostolov Oct 29, 2024
e509dc0
Update
aleksandar-apostolov Oct 30, 2024
8d785f0
Update
aleksandar-apostolov Oct 30, 2024
451d09d
Update
aleksandar-apostolov Oct 31, 2024
e202a7a
Update
aleksandar-apostolov Oct 31, 2024
87e9134
Update
aleksandar-apostolov Oct 31, 2024
1319c88
Update
aleksandar-apostolov Oct 31, 2024
7bf183a
Update
aleksandar-apostolov Oct 31, 2024
229fe86
Update
aleksandar-apostolov Oct 31, 2024
0552bcd
Update
aleksandar-apostolov Oct 31, 2024
b0c5999
Update
aleksandar-apostolov Oct 31, 2024
6b081fb
Spotless & ApiDump
aleksandar-apostolov Oct 31, 2024
a9c9dfd
Merge branch 'develop' into feature/reconnect-v2
aleksandar-apostolov Nov 4, 2024
bd47ddf
Adapt for the new token provider
aleksandar-apostolov Nov 4, 2024
becca24
Update tests
aleksandar-apostolov Nov 4, 2024
a6c0990
Spotless apidump
aleksandar-apostolov Nov 4, 2024
b5d3f56
Merge branch 'develop' into feature/reconnect-v2
aleksandar-apostolov Nov 4, 2024
b73572c
Update
aleksandar-apostolov Nov 7, 2024
0be905d
Sotless api dump
aleksandar-apostolov Nov 7, 2024
084bf88
Update
aleksandar-apostolov Nov 11, 2024
0c445e3
Spotless
aleksandar-apostolov Nov 11, 2024
c0d260f
Move call health monitor into call
aleksandar-apostolov Nov 11, 2024
e064aa9
Spotless
aleksandar-apostolov Nov 11, 2024
fdd64d2
Update
aleksandar-apostolov Nov 12, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -331,33 +331,36 @@ fun CallScreen(
)
},
floatingVideoRenderer = { _, _ ->
FloatingParticipantVideo(
call = call,
participant = me!!,
parentBounds = IntSize(
[email protected],
[email protected],
),
videoRenderer = { participant ->
ParticipantVideo(
modifier = Modifier
.fillMaxSize()
.clip(VideoTheme.shapes.dialog),
call = call,
participant = participant,
reactionContent = {
CustomReactionContent(
participant = participant,
style = RegularVideoRendererStyle().copy(
isShowingConnectionQualityIndicator = false,
reactionPosition = Alignment.TopCenter,
reactionDuration = 5000,
),
)
},
)
},
)
val meLocal by call.state.me.collectAsState()
meLocal?.let {
FloatingParticipantVideo(
call = call,
participant = it,
parentBounds = IntSize(
[email protected],
[email protected],
),
videoRenderer = { participant ->
ParticipantVideo(
modifier = Modifier
.fillMaxSize()
.clip(VideoTheme.shapes.dialog),
call = call,
participant = participant,
reactionContent = {
CustomReactionContent(
participant = participant,
style = RegularVideoRendererStyle().copy(
isShowingConnectionQualityIndicator = false,
reactionPosition = Alignment.TopCenter,
reactionDuration = 5000,
),
)
},
)
},
)
}
},
videoOverlayContent = {
Crossfade(
Expand Down Expand Up @@ -493,10 +496,11 @@ fun CallScreen(
onNoiseCancellation = {
isNoiseCancellationEnabled = call.toggleAudioProcessing()
},
) {
isShowingStats = true
isShowingSettingMenu = false
}
onShowCallStats = {
isShowingStats = true
isShowingSettingMenu = false
},
)
}

if (isShowingFeedbackDialog) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -461,7 +461,7 @@ private fun JoinCallForm(
mutableStateOf(
TextFieldValue(
if (BuildConfig.FLAVOR == StreamFlavors.development) {
"default:79cYh3J5JgGk"
"default:123lexgvg"
} else {
""
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,9 @@ 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
import androidx.compose.material.icons.filled.SettingsVoice
import androidx.compose.material.icons.filled.SpatialAudioOff
import androidx.compose.material.icons.filled.SpeakerPhone
Expand Down Expand Up @@ -57,11 +58,12 @@ fun defaultStreamMenu(
onToggleAudioFilterClick: () -> Unit,
onRestartSubscriberIceClick: () -> Unit,
onRestartPublisherIceClick: () -> Unit,
onKillSfuWsClick: () -> Unit,
onSwitchSfuClick: () -> Unit,
onShowFeedback: () -> Unit,
onNoiseCancellation: () -> Unit,
onDeviceSelected: (StreamAudioDevice) -> Unit,
onSfuRejoinClick: () -> Unit,
onSfuFastReconnectClick: () -> Unit,
availableDevices: List<StreamAudioDevice>,
loadRecordings: suspend () -> List<MenuItem>,
) = buildList<MenuItem> {
Expand Down Expand Up @@ -133,8 +135,9 @@ fun defaultStreamMenu(
onToggleAudioFilterClick,
onRestartSubscriberIceClick,
onRestartPublisherIceClick,
onKillSfuWsClick,
onSwitchSfuClick,
onSfuRejoinClick,
onSfuFastReconnectClick,
),
),
)
Expand All @@ -159,17 +162,52 @@ fun codecMenu(codecList: List<MediaCodecInfo>, onCodecSelected: (MediaCodecInfo)
)
}

fun reconnectMenu(
onRestartPublisherIceClick: () -> Unit,
onRestartSubscriberIceClick: () -> Unit,
onSwitchSfuClick: () -> Unit,
onSfuRejoinClick: () -> Unit,
onSfuFastReconnectClick: () -> Unit,
) = listOf(
ActionMenuItem(
title = "Publisher - ICE restart",
icon = Icons.Default.SettingsBackupRestore,
action = onRestartPublisherIceClick,
),
ActionMenuItem(
title = "Subscriber - ICE restart",
icon = Icons.Default.SettingsBackupRestore,
action = onRestartSubscriberIceClick,
),
ActionMenuItem(
title = "Reconnect SFU - migrate",
icon = Icons.Default.SwitchLeft,
action = onSwitchSfuClick,
),
ActionMenuItem(
title = "Reconnect SFU - rejoin",
icon = Icons.Default.Replay,
action = onSfuRejoinClick,
),
ActionMenuItem(
title = "Reconnect SFU - fast",
icon = Icons.Default.RestartAlt,
action = onSfuFastReconnectClick,
),
)

/**
* Optionally defines the debug sub-menu of the demo app.
*/
fun debugSubmenu(
codecList: List<MediaCodecInfo>,
onCodecSelected: (MediaCodecInfo) -> Unit,
onToggleAudioFilterClick: () -> Unit,
onRestartSubscriberIceClick: () -> Unit,
onRestartPublisherIceClick: () -> Unit,
onKillSfuWsClick: () -> Unit,
onRestartSubscriberIceClick: () -> Unit,
onSwitchSfuClick: () -> Unit,
onSfuRejoinClick: () -> Unit,
onSfuFastReconnectClick: () -> Unit,
) = listOf(
SubMenuItem(
title = "Available video codecs",
Expand All @@ -181,24 +219,15 @@ fun debugSubmenu(
icon = Icons.Default.Audiotrack,
action = onToggleAudioFilterClick,
),
ActionMenuItem(
title = "Restart subscriber Ice",
icon = Icons.Default.RestartAlt,
action = onRestartSubscriberIceClick,
),
ActionMenuItem(
title = "Restart publisher Ice",
icon = Icons.Default.RestartAlt,
action = onRestartPublisherIceClick,
),
ActionMenuItem(
title = "Shut down SFU web-socket",
icon = Icons.Default.PortableWifiOff,
action = onKillSfuWsClick,
),
ActionMenuItem(
title = "Switch SFU",
icon = Icons.Default.SwitchLeft,
action = onSwitchSfuClick,
SubMenuItem(
title = "Reconnect V2",
icon = Icons.Default.Replay,
items = reconnectMenu(
onRestartPublisherIceClick,
onRestartSubscriberIceClick,
onSwitchSfuClick,
onSfuRejoinClick,
onSfuFastReconnectClick,
),
),
)
Original file line number Diff line number Diff line change
Expand Up @@ -135,19 +135,25 @@ internal fun SettingsMenu(
Toast.makeText(context, "Restart Publisher Ice", Toast.LENGTH_SHORT).show()
}

val onKillSfuWsClick: () -> Unit = {
call.debug.doFullReconnection()
val onSfuRejoinClick: () -> Unit = {
call.debug.rejoin()
onDismissed.invoke()
Toast.makeText(context, "Killing SFU WS. Should trigger reconnect...", Toast.LENGTH_SHORT)
.show()
}

val onSwitchSfuClick: () -> Unit = {
call.debug.switchSfu()
call.debug.migrate()
onDismissed.invoke()
Toast.makeText(context, "Switch sfu", Toast.LENGTH_SHORT).show()
}

val onSfuFastReconnectClick: () -> Unit = {
call.debug.fastReconnect()
onDismissed.invoke()
Toast.makeText(context, "Fast Reconnect SFU", Toast.LENGTH_SHORT).show()
}

val codecInfos = remember {
MediaCodecList(MediaCodecList.ALL_CODECS).codecInfos.filter {
it.name.contains("encoder") && it.supportedTypes.firstOrNull {
Expand Down Expand Up @@ -222,13 +228,14 @@ internal fun SettingsMenu(
},
onShowFeedback = onShowFeedback,
onToggleScreenShare = onScreenShareClick,
onKillSfuWsClick = onKillSfuWsClick,
onRestartPublisherIceClick = onRestartPublisherIceClick,
onRestartSubscriberIceClick = onRestartSubscriberIceClick,
onToggleAudioFilterClick = onToggleAudioFilterClick,
onSwitchSfuClick = onSwitchSfuClick,
onShowCallStats = onShowCallStats,
onNoiseCancellation = onNoiseCancellation,
onSfuRejoinClick = onSfuRejoinClick,
onSfuFastReconnectClick = onSfuFastReconnectClick,
isScreenShareEnabled = isScreenSharing,
loadRecordings = onLoadRecordings,
),
Expand Down Expand Up @@ -285,7 +292,8 @@ private fun SettingsMenuPreview() {
onToggleAudioFilterClick = { },
onRestartSubscriberIceClick = { },
onRestartPublisherIceClick = { },
onKillSfuWsClick = { },
onSfuRejoinClick = { },
onSfuFastReconnectClick = {},
onSwitchSfuClick = { },
availableDevices = emptyList(),
onDeviceSelected = {},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ import io.getstream.video.android.compose.ui.components.base.StreamToggleButton
import io.getstream.video.android.compose.ui.components.base.styling.StyleSize
import io.getstream.video.android.ui.menu.debugSubmenu
import io.getstream.video.android.ui.menu.defaultStreamMenu
import io.getstream.video.android.ui.menu.reconnectMenu

/**
* A composable capable of loading a menu based on a list structure of menu items and sub menus.
Expand Down Expand Up @@ -217,7 +218,8 @@ private fun DynamicMenuPreview() {
onToggleAudioFilterClick = { },
onRestartSubscriberIceClick = { },
onRestartPublisherIceClick = { },
onKillSfuWsClick = { },
onSfuRejoinClick = { },
aleksandar-apostolov marked this conversation as resolved.
Show resolved Hide resolved
onSfuFastReconnectClick = {},
onSwitchSfuClick = { },
availableDevices = emptyList(),
onDeviceSelected = {},
Expand All @@ -244,7 +246,8 @@ private fun DynamicMenuDebugOptionPreview() {
onToggleAudioFilterClick = { },
onRestartSubscriberIceClick = { },
onRestartPublisherIceClick = { },
onKillSfuWsClick = { },
onSfuRejoinClick = { },
onSfuFastReconnectClick = {},
onSwitchSfuClick = { },
availableDevices = emptyList(),
onDeviceSelected = {},
Expand All @@ -264,7 +267,8 @@ private fun DynamicMenuDebugPreview() {
items = debugSubmenu(
codecList = emptyList(),
onCodecSelected = {},
onKillSfuWsClick = { },
onSfuRejoinClick = { },
onSfuFastReconnectClick = {},
onRestartPublisherIceClick = { },
onRestartSubscriberIceClick = { },
onToggleAudioFilterClick = { },
Expand All @@ -273,3 +277,19 @@ private fun DynamicMenuDebugPreview() {
)
}
}

@Preview
@Composable
private fun DynamicMenuReconnectPreview() {
VideoTheme {
DynamicMenu(
items = reconnectMenu(
onSfuRejoinClick = { },
onSfuFastReconnectClick = {},
onRestartPublisherIceClick = { },
onRestartSubscriberIceClick = { },
onSwitchSfuClick = { },
),
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import io.getstream.video.android.core.StreamVideo
import io.getstream.video.android.core.StreamVideoBuilder
import io.getstream.video.android.core.logging.LoggingLevel
import io.getstream.video.android.core.notifications.NotificationConfig
import io.getstream.video.android.core.socket.common.token.TokenProvider
import io.getstream.video.android.data.services.stream.GetAuthDataResponse
import io.getstream.video.android.data.services.stream.StreamService
import io.getstream.video.android.datastore.delegate.StreamUserDataStore
Expand Down Expand Up @@ -199,13 +200,15 @@ object StreamVideoInitHelper {
FirebasePushDeviceGenerator(providerName = "firebase"),
),
),
tokenProvider = {
val email = user.custom?.get("email")
val authData = StreamService.instance.getAuthData(
environment = AppConfig.currentEnvironment.value!!.env,
userId = email,
)
authData.token
tokenProvider = object : TokenProvider {
override suspend fun loadToken(): String {
val email = user.custom?.get("email")
val authData = StreamService.instance.getAuthData(
environment = AppConfig.currentEnvironment.value!!.env,
userId = email,
)
return authData.token
}
},
appName = "Stream Video Demo App",
audioProcessing = NoiseCancellation(context),
Expand Down
Loading
Loading