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
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ import io.getstream.video.android.compose.ui.components.call.renderer.LayoutType
import io.getstream.video.android.compose.ui.components.call.renderer.ParticipantVideo
import io.getstream.video.android.compose.ui.components.call.renderer.RegularVideoRendererStyle
import io.getstream.video.android.compose.ui.components.call.renderer.copy
import io.getstream.video.android.compose.ui.components.video.VideoScalingType
import io.getstream.video.android.core.Call
import io.getstream.video.android.core.RealtimeConnection
import io.getstream.video.android.core.call.state.ChooseLayout
Expand Down Expand Up @@ -149,6 +150,7 @@ fun CallScreen(
val scope = rememberCoroutineScope()
val messageScope = rememberCoroutineScope()
var showingLandscapeControls by remember { mutableStateOf(false) }
var preferredScaleType by remember { mutableStateOf(VideoScalingType.SCALE_ASPECT_FILL) }

val connection by call.state.connection.collectAsStateWithLifecycle()
val me by call.state.me.collectAsState()
Expand Down Expand Up @@ -320,6 +322,7 @@ fun CallScreen(
call = call,
participant = participant,
style = style,
scalingType = preferredScaleType,
reactionContent = {
CustomReactionContent(
participant = participant,
Expand Down Expand Up @@ -501,6 +504,10 @@ fun CallScreen(
onNoiseCancellation = {
isNoiseCancellationEnabled = call.toggleAudioProcessing()
},
onSelectScaleType = {
preferredScaleType = it
isShowingSettingMenu = false
},
onShowCallStats = {
isShowingStats = true
isShowingSettingMenu = false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,13 @@ import android.os.Build
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.automirrored.filled.MobileScreenShare
import androidx.compose.material.icons.automirrored.filled.ReadMore
import androidx.compose.material.icons.filled.AspectRatio
import androidx.compose.material.icons.filled.Audiotrack
import androidx.compose.material.icons.filled.AutoGraph
import androidx.compose.material.icons.filled.Balance
import androidx.compose.material.icons.filled.BluetoothAudio
import androidx.compose.material.icons.filled.Crop
import androidx.compose.material.icons.filled.CropFree
import androidx.compose.material.icons.filled.Feedback
import androidx.compose.material.icons.filled.Headphones
import androidx.compose.material.icons.filled.HeadsetMic
Expand All @@ -37,6 +41,7 @@ import androidx.compose.material.icons.filled.SwitchLeft
import androidx.compose.material.icons.filled.VideoFile
import androidx.compose.material.icons.filled.VideoLibrary
import androidx.compose.material.icons.filled.VideoSettings
import io.getstream.video.android.compose.ui.components.video.VideoScalingType
import io.getstream.video.android.core.audio.StreamAudioDevice
import io.getstream.video.android.ui.menu.base.ActionMenuItem
import io.getstream.video.android.ui.menu.base.DynamicSubMenuItem
Expand Down Expand Up @@ -64,6 +69,7 @@ fun defaultStreamMenu(
onDeviceSelected: (StreamAudioDevice) -> Unit,
onSfuRejoinClick: () -> Unit,
onSfuFastReconnectClick: () -> Unit,
onSelectScaleType: (VideoScalingType) -> Unit,
availableDevices: List<StreamAudioDevice>,
loadRecordings: suspend () -> List<MenuItem>,
) = buildList<MenuItem> {
Expand Down Expand Up @@ -138,6 +144,7 @@ fun defaultStreamMenu(
onSwitchSfuClick,
onSfuRejoinClick,
onSfuFastReconnectClick,
onSelectScaleType,
),
),
)
Expand Down Expand Up @@ -196,6 +203,24 @@ fun reconnectMenu(
),
)

fun scaleTypeMenu(onSelectScaleType: (VideoScalingType) -> Unit): List<MenuItem> = listOf(
ActionMenuItem(
title = "Scale FIT",
icon = Icons.Default.CropFree,
action = { onSelectScaleType(VideoScalingType.SCALE_ASPECT_FIT) },
),
ActionMenuItem(
title = "Scale FILL",
icon = Icons.Default.Crop,
action = { onSelectScaleType(VideoScalingType.SCALE_ASPECT_FILL) },
),
ActionMenuItem(
title = "Scale BALANCED",
icon = Icons.Default.Balance,
action = { onSelectScaleType(VideoScalingType.SCALE_ASPECT_BALANCED) },
),
)

/**
* Optionally defines the debug sub-menu of the demo app.
*/
Expand All @@ -208,6 +233,7 @@ fun debugSubmenu(
onSwitchSfuClick: () -> Unit,
onSfuRejoinClick: () -> Unit,
onSfuFastReconnectClick: () -> Unit,
onSelectScaleType: (VideoScalingType) -> Unit,
) = listOf(
SubMenuItem(
title = "Available video codecs",
Expand All @@ -219,6 +245,13 @@ fun debugSubmenu(
icon = Icons.Default.Audiotrack,
action = onToggleAudioFilterClick,
),
SubMenuItem(
title = "Scale type",
icon = Icons.Default.AspectRatio,
items = scaleTypeMenu(
onSelectScaleType,
),
),
SubMenuItem(
title = "Reconnect V2",
icon = Icons.Default.Replay,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ import com.google.accompanist.permissions.ExperimentalPermissionsApi
import com.google.accompanist.permissions.PermissionStatus
import com.google.accompanist.permissions.rememberPermissionState
import io.getstream.video.android.compose.theme.VideoTheme
import io.getstream.video.android.compose.ui.components.video.VideoScalingType
import io.getstream.video.android.core.Call
import io.getstream.video.android.core.call.audio.InputAudioFilter
import io.getstream.video.android.core.mapper.ReactionMapper
Expand All @@ -75,6 +76,7 @@ internal fun SettingsMenu(
onShowFeedback: () -> Unit,
onNoiseCancellation: () -> Unit,
onShowCallStats: () -> Unit,
onSelectScaleType: (VideoScalingType) -> Unit,
) {
val context = LocalContext.current
val scope = rememberCoroutineScope()
Expand Down Expand Up @@ -237,6 +239,7 @@ internal fun SettingsMenu(
onSfuRejoinClick = onSfuRejoinClick,
onSfuFastReconnectClick = onSfuFastReconnectClick,
isScreenShareEnabled = isScreenSharing,
onSelectScaleType = onSelectScaleType,
loadRecordings = onLoadRecordings,
),
)
Expand Down Expand Up @@ -298,6 +301,7 @@ private fun SettingsMenuPreview() {
availableDevices = emptyList(),
onDeviceSelected = {},
onShowFeedback = {},
onSelectScaleType = {},
onNoiseCancellation = {},
loadRecordings = { emptyList() },
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,7 @@ private fun DynamicMenuPreview() {
onDeviceSelected = {},
onShowFeedback = {},
onNoiseCancellation = {},
onSelectScaleType = {},
loadRecordings = { emptyList() },
),
)
Expand Down Expand Up @@ -252,6 +253,7 @@ private fun DynamicMenuDebugOptionPreview() {
availableDevices = emptyList(),
onDeviceSelected = {},
onShowFeedback = {},
onSelectScaleType = { },
onNoiseCancellation = {},
loadRecordings = { emptyList() },
),
Expand All @@ -272,6 +274,7 @@ private fun DynamicMenuDebugPreview() {
onRestartPublisherIceClick = { },
onRestartSubscriberIceClick = { },
onToggleAudioFilterClick = { },
onSelectScaleType = { },
onSwitchSfuClick = { },
),
)
Expand Down
Loading