mirror of
https://github.com/SchildiChat/SchildiChat-android.git
synced 2025-01-23 15:51:11 +01:00
Remove singletin instance from callback param
This commit is contained in:
parent
21a42e310f
commit
1e0bc51fa2
@ -90,17 +90,17 @@ class VectorCallViewModel @AssistedInject constructor(
|
||||
override fun onCurrentCallChange(call: MxCall?) {
|
||||
}
|
||||
|
||||
override fun onCaptureStateChanged(mgr: WebRtcPeerConnectionManager) {
|
||||
override fun onCaptureStateChanged() {
|
||||
setState {
|
||||
copy(
|
||||
isVideoCaptureInError = mgr.capturerIsInError,
|
||||
isHD = mgr.currentCaptureFormat() is CaptureFormat.HD
|
||||
isVideoCaptureInError = webRtcPeerConnectionManager.capturerIsInError,
|
||||
isHD = webRtcPeerConnectionManager.currentCaptureFormat() is CaptureFormat.HD
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onAudioDevicesChange(mgr: WebRtcPeerConnectionManager) {
|
||||
val currentSoundDevice = mgr.callAudioManager.getCurrentSoundDevice()
|
||||
override fun onAudioDevicesChange() {
|
||||
val currentSoundDevice = webRtcPeerConnectionManager.callAudioManager.getCurrentSoundDevice()
|
||||
if (currentSoundDevice == CallAudioManager.SoundDevice.PHONE) {
|
||||
proximityManager.start()
|
||||
} else {
|
||||
@ -109,17 +109,17 @@ class VectorCallViewModel @AssistedInject constructor(
|
||||
|
||||
setState {
|
||||
copy(
|
||||
availableSoundDevices = mgr.callAudioManager.getAvailableSoundDevices(),
|
||||
availableSoundDevices = webRtcPeerConnectionManager.callAudioManager.getAvailableSoundDevices(),
|
||||
soundDevice = currentSoundDevice
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onCameraChange(mgr: WebRtcPeerConnectionManager) {
|
||||
override fun onCameraChange() {
|
||||
setState {
|
||||
copy(
|
||||
canSwitchCamera = mgr.canSwitchCamera(),
|
||||
isFrontCamera = mgr.currentCameraType() == CameraType.FRONT
|
||||
canSwitchCamera = webRtcPeerConnectionManager.canSwitchCamera(),
|
||||
isFrontCamera = webRtcPeerConnectionManager.currentCameraType() == CameraType.FRONT
|
||||
)
|
||||
}
|
||||
}
|
||||
|
@ -79,9 +79,9 @@ class WebRtcPeerConnectionManager @Inject constructor(
|
||||
|
||||
interface CurrentCallListener {
|
||||
fun onCurrentCallChange(call: MxCall?)
|
||||
fun onCaptureStateChanged(mgr: WebRtcPeerConnectionManager) {}
|
||||
fun onAudioDevicesChange(mgr: WebRtcPeerConnectionManager) {}
|
||||
fun onCameraChange(mgr: WebRtcPeerConnectionManager) {}
|
||||
fun onCaptureStateChanged() {}
|
||||
fun onAudioDevicesChange() {}
|
||||
fun onCameraChange() {}
|
||||
}
|
||||
|
||||
private val currentCallsListeners = emptyList<CurrentCallListener>().toMutableList()
|
||||
@ -95,7 +95,7 @@ class WebRtcPeerConnectionManager @Inject constructor(
|
||||
|
||||
val callAudioManager = CallAudioManager(context.applicationContext) {
|
||||
currentCallsListeners.forEach {
|
||||
tryThis { it.onAudioDevicesChange(this) }
|
||||
tryThis { it.onAudioDevicesChange() }
|
||||
}
|
||||
}
|
||||
|
||||
@ -174,7 +174,7 @@ class WebRtcPeerConnectionManager @Inject constructor(
|
||||
set(value) {
|
||||
field = value
|
||||
currentCallsListeners.forEach {
|
||||
tryThis { it.onCaptureStateChanged(this) }
|
||||
tryThis { it.onCaptureStateChanged() }
|
||||
}
|
||||
}
|
||||
|
||||
@ -741,7 +741,7 @@ class WebRtcPeerConnectionManager @Inject constructor(
|
||||
Timber.v("## VOIP onCameraSwitchDone isFront $isFrontCamera")
|
||||
cameraInUse = availableCamera.first { if (isFrontCamera) it.type == CameraType.FRONT else it.type == CameraType.BACK }
|
||||
currentCallsListeners.forEach {
|
||||
tryThis { it.onCameraChange(this@WebRtcPeerConnectionManager) }
|
||||
tryThis { it.onCameraChange() }
|
||||
}
|
||||
}
|
||||
|
||||
@ -767,7 +767,7 @@ class WebRtcPeerConnectionManager @Inject constructor(
|
||||
// videoCapturer?.stopCapture()
|
||||
videoCapturer?.changeCaptureFormat(format.width, format.height, format.fps)
|
||||
currentCaptureMode = format
|
||||
currentCallsListeners.forEach { tryThis { it.onCaptureStateChanged(this) } }
|
||||
currentCallsListeners.forEach { tryThis { it.onCaptureStateChanged() } }
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user