GetStream / stream-video-android

📲 Android Video SDK. Stream's versatile Core + Compose UI component libraries that allow you to build video calling, audio room, and, live streaming apps based on Webrtc running on Stream's global edge network.
https://getstream.io/video/docs/android
Other
370 stars 37 forks source link

Call Settings for custom call type are not applied to a call #1173

Open Miara opened 3 weeks ago

Miara commented 3 weeks ago

Describe the bug I created custom call types: video and audio in GetStream Dasboard. I set settings for each of these types. For example for video I set these settings:

image

And in custom settings:

image

Hovewer after call is started - microphone is disabled and speaker is disabled as well - I can hear only voice from Earpiece audio source.

I'm not sure it something is not ok with console web implementation, or backend implementation, or Android SDK implementation, or even I did something wrong - but i guess it's bug on your side, because I create as simple call activity as possible, using only your code:

{
@OptIn(StreamCallActivityDelicateApi::class)
class CallActivity : ComposeStreamCallActivity() {

    override val uiDelegate: StreamActivityUiDelegate<StreamCallActivity> = StreamCallActivityComposeDelegate()
    override val configuration: StreamCallActivityConfiguration =
        StreamCallActivityConfiguration(closeScreenOnCallEnded = false)
}
}

SDK version

To Reproduce Steps to reproduce the behavior:

  1. Create new call type, and set such settings as mentioned above in GetStream Dashboard
  2. Start call with new type
  3. Microphone is disabled, earpiece is selected instead of speakerphone

Expected behavior Microphone is enabled, speaker mode is enabled

Device:

Miara commented 2 weeks ago

I see that the problem is only with audio settings. Video settings seem to work corretly.

Here is the hack I did to make it working as expected:

@OptIn(StreamCallActivityDelicateApi::class)  
class CallActivity : ComposeStreamCallActivity() {  

override val uiDelegate: StreamActivityUiDelegate<StreamCallActivity> = CallActivityUIDelegate()  
override val configuration: StreamCallActivityConfiguration =  
    StreamCallActivityConfiguration(closeScreenOnCallEnded = false)  

override fun create(  
    call: Call,  
  ring: Boolean,  
  members: List<String>,  
  onSuccess: (suspend (Call) -> Unit)?,  
  onError: (suspend (Exception) -> Unit)?  
    ) {  
        val isVideo = call.type == "video"  
  lifecycleScope.launch(Dispatchers.IO) {  
  val instance = StreamVideo.instance()  
            val result = call.create(  
                // List of all users, containing the caller also  
  memberIds = members + instance.userId,  
  // If other users will get push notification.  
  ring = ring,  
  settings = CallSettingsRequest(  
                    audio = AudioSettingsRequest(  
                        defaultDevice = if(isVideo) AudioSettingsRequest.DefaultDevice.Speaker else AudioSettingsRequest.DefaultDevice.Earpiece,  
  micDefaultOn = true  
  ),  
  )  
            )  
            result.onOutcome(call, onSuccess, onError)  
        }  
  }  

    private suspend fun <A : Any> Result<A>.onOutcome(  
        call: Call,  
  onSuccess: (suspend (Call) -> Unit)? = null,  
  onError: (suspend (Exception) -> Unit)? = null,  
  ) = withContext(Dispatchers.Main) {  
  onSuccess?.let {  
  onSuccessSuspend {  
  onSuccess(call)  
            }  
 }  onError?.let {  
  onErrorSuspend {  
  onError(Exception(it.message))  
            }  
 } }}
liviu-timar commented 2 weeks ago

Hi @Miara, we'll look into it as soon as possible, thanks for reporting this issue.

Miara commented 3 days ago

I see that even my hack partially works, because when I have this custom setting:

image

micDefaultOn works, so after call is started, microphone is enabled

but speakerDefaultOn doesn't work. even if this is set to true, speaker is disabled