diff --git a/vector/src/main/java/im/vector/app/features/call/VectorCallViewModel.kt b/vector/src/main/java/im/vector/app/features/call/VectorCallViewModel.kt index cee67cd818..97a6f72177 100644 --- a/vector/src/main/java/im/vector/app/features/call/VectorCallViewModel.kt +++ b/vector/src/main/java/im/vector/app/features/call/VectorCallViewModel.kt @@ -146,7 +146,7 @@ class VectorCallViewModel @AssistedInject constructor( } override fun onAudioDevicesChange(mgr: WebRtcPeerConnectionManager) { - val currentSoundDevice = mgr.audioManager.getCurrentSoundDevice() + val currentSoundDevice = mgr.callAudioManager.getCurrentSoundDevice() if (currentSoundDevice == CallAudioManager.SoundDevice.PHONE) { proximityManager.start() } else { @@ -155,7 +155,7 @@ class VectorCallViewModel @AssistedInject constructor( setState { copy( - availableSoundDevices = mgr.audioManager.getAvailableSoundDevices(), + availableSoundDevices = mgr.callAudioManager.getAvailableSoundDevices(), soundDevice = currentSoundDevice ) } @@ -182,7 +182,7 @@ class VectorCallViewModel @AssistedInject constructor( mxCall.addListener(callStateListener) - val currentSoundDevice = webRtcPeerConnectionManager.audioManager.getCurrentSoundDevice() + val currentSoundDevice = webRtcPeerConnectionManager.callAudioManager.getCurrentSoundDevice() if (currentSoundDevice == CallAudioManager.SoundDevice.PHONE) { proximityManager.start() } @@ -193,7 +193,7 @@ class VectorCallViewModel @AssistedInject constructor( callState = Success(mxCall.state), otherUserMatrixItem = item?.let { Success(it) } ?: Uninitialized, soundDevice = currentSoundDevice, - availableSoundDevices = webRtcPeerConnectionManager.audioManager.getAvailableSoundDevices(), + availableSoundDevices = webRtcPeerConnectionManager.callAudioManager.getAvailableSoundDevices(), isFrontCamera = webRtcPeerConnectionManager.currentCameraType() == CameraType.FRONT, canSwitchCamera = webRtcPeerConnectionManager.canSwitchCamera(), isHD = mxCall.isVideoCall && webRtcPeerConnectionManager.currentCaptureFormat() is CaptureFormat.HD @@ -250,10 +250,10 @@ class VectorCallViewModel @AssistedInject constructor( Unit } is VectorCallViewActions.ChangeAudioDevice -> { - webRtcPeerConnectionManager.audioManager.setCurrentSoundDevice(action.device) + webRtcPeerConnectionManager.callAudioManager.setCurrentSoundDevice(action.device) setState { copy( - soundDevice = webRtcPeerConnectionManager.audioManager.getCurrentSoundDevice() + soundDevice = webRtcPeerConnectionManager.callAudioManager.getCurrentSoundDevice() ) } } diff --git a/vector/src/main/java/im/vector/app/features/call/WebRtcPeerConnectionManager.kt b/vector/src/main/java/im/vector/app/features/call/WebRtcPeerConnectionManager.kt index b53be292c8..916df8892b 100644 --- a/vector/src/main/java/im/vector/app/features/call/WebRtcPeerConnectionManager.kt +++ b/vector/src/main/java/im/vector/app/features/call/WebRtcPeerConnectionManager.kt @@ -23,6 +23,9 @@ import im.vector.app.ActiveSessionDataSource import im.vector.app.core.services.BluetoothHeadsetReceiver import im.vector.app.core.services.CallService import im.vector.app.core.services.WiredHeadsetStateReceiver +import io.reactivex.disposables.Disposable +import io.reactivex.subjects.PublishSubject +import io.reactivex.subjects.ReplaySubject import org.matrix.android.sdk.api.MatrixCallback import org.matrix.android.sdk.api.extensions.tryThis import org.matrix.android.sdk.api.session.Session @@ -35,9 +38,6 @@ import org.matrix.android.sdk.api.session.room.model.call.CallAnswerContent import org.matrix.android.sdk.api.session.room.model.call.CallCandidatesContent import org.matrix.android.sdk.api.session.room.model.call.CallHangupContent import org.matrix.android.sdk.api.session.room.model.call.CallInviteContent -import io.reactivex.disposables.Disposable -import io.reactivex.subjects.PublishSubject -import io.reactivex.subjects.ReplaySubject import org.webrtc.AudioSource import org.webrtc.AudioTrack import org.webrtc.Camera1Enumerator @@ -93,7 +93,7 @@ class WebRtcPeerConnectionManager @Inject constructor( currentCallsListeners.remove(listener) } - val audioManager = CallAudioManager(context.applicationContext) { + val callAudioManager = CallAudioManager(context.applicationContext) { currentCallsListeners.forEach { tryThis { it.onAudioDevicesChange(this) } } @@ -577,7 +577,7 @@ class WebRtcPeerConnectionManager @Inject constructor( fun close() { Timber.v("## VOIP WebRtcPeerConnectionManager close() >") CallService.onNoActiveCall(context) - audioManager.stop() + callAudioManager.stop() val callToEnd = currentCall currentCall = null // This must be done in this thread @@ -631,7 +631,7 @@ class WebRtcPeerConnectionManager @Inject constructor( val createdCall = currentSession?.callSignalingService()?.createOutgoingCall(signalingRoomId, otherUserId, isVideoCall) ?: return val callContext = CallContext(createdCall) - audioManager.startForCall(createdCall) + callAudioManager.startForCall(createdCall) currentCall = callContext val name = currentSession?.getUser(createdCall.otherUserId)?.getBestName() @@ -684,7 +684,7 @@ class WebRtcPeerConnectionManager @Inject constructor( val callContext = CallContext(mxCall) currentCall = callContext - audioManager.startForCall(mxCall) + callAudioManager.startForCall(mxCall) executor.execute { callContext.remoteCandidateSource = ReplaySubject.create() } @@ -798,12 +798,12 @@ class WebRtcPeerConnectionManager @Inject constructor( Timber.v("## VOIP onWiredDeviceEvent $event") currentCall ?: return // sometimes we received un-wanted unplugged... - audioManager.wiredStateChange(event) + callAudioManager.wiredStateChange(event) } fun onWirelessDeviceEvent(event: BluetoothHeadsetReceiver.BTHeadsetPlugEvent) { Timber.v("## VOIP onWirelessDeviceEvent $event") - audioManager.bluetoothStateChange(event.plugged) + callAudioManager.bluetoothStateChange(event.plugged) } override fun onCallAnswerReceived(callAnswerContent: CallAnswerContent) { @@ -858,7 +858,7 @@ class WebRtcPeerConnectionManager @Inject constructor( */ PeerConnection.PeerConnectionState.CONNECTED -> { callContext.mxCall.state = CallState.Connected(newState) - audioManager.onCallConnected(callContext.mxCall) + callAudioManager.onCallConnected(callContext.mxCall) } /** * One or more of the ICE transports on the connection is in the "failed" state.