From 1f5b39a9e41ed5820e1cf64bf9c0d0e09a668b98 Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 2 Apr 2026 14:24:13 +0000 Subject: [PATCH] fix: enable video toggle during voice calls When a call starts as voice-only, no video track exists. Tapping the camera toggle was calling setVideoEnabled(true) on a null track, doing nothing. Now toggleVideo() checks if a video track exists. If not, it creates one on-demand (addVideoTrack + startCamera), upgrading the voice call to include video. If toggling off, it stops the camera to save battery. https://claude.ai/code/session_017hZm7yu7CzmcQgZGSaqSXS --- .../amethyst/service/call/CallController.kt | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/service/call/CallController.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/service/call/CallController.kt index 8ff3a6535..1592fea0b 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/service/call/CallController.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/service/call/CallController.kt @@ -227,9 +227,20 @@ class CallController( } fun toggleVideo() { + val session = webRtcSession ?: return val enabled = !_isVideoEnabled.value _isVideoEnabled.value = enabled - webRtcSession?.setVideoEnabled(enabled) + + if (enabled && session.getLocalVideoTrack() == null) { + // Video track doesn't exist yet (voice call upgraded to video) + session.addVideoTrack() + _localVideoTrack.value = session.getLocalVideoTrack() + } else { + session.setVideoEnabled(enabled) + if (!enabled) { + session.stopCamera() + } + } } fun cycleAudioRoute() {