azure-sdk-for-android
azure-sdk-for-android copied to clipboard
[BUG][Android] When in conference, upon switching cameras , the user can notice a small delay in the process
Describe the bug When a user is in conference and changes camera , there is a small delay in the process( 2-3 seconds )
**To Reproduce **
- Host a Teams conference
- Join with an Android device with Calling 1.3.0-beta.1
- Change participant camera
- Notice a small delay in the process
Code Snippet
private fun checkCameraFacingSwitch() {
consultationViewModel.cameraEnabledLiveData.value?.let { isCameraEnabled->
if(isCameraEnabled){
when (localVideoStream?.source?.cameraFacing?.name?.toLowerCase(Locale.getDefault())) {
FACING_BACK_CAMERA -> consultationViewModel.setCameraFacingFront(true)
FACING_FRONT_CAMERA -> consultationViewModel.setCameraFacingFront(false)
}
}else{
showToast(getString(R.string.virtual_consultation_camera_off_toast))
call?.stopVideo(context, localVideoStream)
disposeLocalVideoStream()
onLocalCameraNotConnected()
}
}?: run {
showToast(getString(R.string.virtual_consultation_camera_off_toast))
call?.stopVideo(context, localVideoStream)
disposeLocalVideoStream()
onLocalCameraNotConnected()
}
}
We are using a viewmodel because we want to know at anytime what the state of the camera is. The observer for the livedata is below :
val cameraFacingObserver = Observer<Boolean> { cameraFacingFront ->
Timber.d("cameraFacingObserver: $cameraFacingFront")
call?.stopVideo(context, localVideoStream)
if (cameraFacingFront) {
fetchLocalVideoStream(FACING_FRONT_CAMERA, false)
} else {
fetchLocalVideoStream(FACING_BACK_CAMERA, false)
}
}
And the method
private fun fetchLocalVideoStream(cameraFacing: String, joinCall: Boolean) {
val deviceManager = callClient.getDeviceManager(context).get()
deviceManager.cameras.forEach {
val cameraFacingName = it.cameraFacing.name
if (cameraFacingName.equals(cameraFacing, ignoreCase = true)) {
Timber.e("local video stream found")
localVideoStream = LocalVideoStream(it, context)
if (joinCall) {
joinCall()
} else {
call?.startVideo(context, localVideoStream)
if (consultationViewModel.waitingRoomState.value == true) {
loadWaitingRoomState(localVideoStream)
} else {
loadConsultationState(localVideoStream, true)
}
}
return
}
}
}
Expected behavior Camera should be changed instatly.
Screenshots If applicable, add screenshots to help explain your problem.
Setup (please complete the following information):
- OS: Android 10 (Huawei P30 Pro)
- Version of the Library used: Calling 1.3.0-beta.1