Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 17 additions & 5 deletions app/src/main/java/com/example/intra/WebRTCClient.kt
Original file line number Diff line number Diff line change
Expand Up @@ -202,10 +202,17 @@ class WebRTCClient(
videoCapturer = createVideoCapturer()
}

val activeCapturer = videoCapturer
if (activeCapturer == null) {
Log.w("WebRTC", "⚠️ No compatible camera capturer available. Falling back to audio-only call.")
isVideoCall = false
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Propagate video fallback to negotiation metadata

When createVideoCapturer() fails, startLocalVideo() flips the field isVideoCall to false, but startCall()/answerCall() still build SDP constraints and signaling JSON from their isVideoCall parameter (the original requested mode). In the no-camera path, this means the app logs an audio-only fallback locally yet still advertises a video call remotely, which can leave the peer/UI in a mismatched call mode and expect video that will never be published.

Useful? React with 👍 / 👎.

return
}

if (localVideoSource == null) {
localVideoSource = peerConnectionFactory?.createVideoSource(videoCapturer!!.isScreencast)
videoCapturer?.initialize(surfaceTextureHelper, context, localVideoSource?.capturerObserver)
videoCapturer?.startCapture(1024, 720, 30) // Resolution can be adjusted
localVideoSource = peerConnectionFactory?.createVideoSource(activeCapturer.isScreencast)
activeCapturer.initialize(surfaceTextureHelper, context, localVideoSource?.capturerObserver)
activeCapturer.startCapture(1024, 720, 30) // Resolution can be adjusted
}

if (localVideoTrack == null) {
Expand Down Expand Up @@ -414,7 +421,9 @@ class WebRTCClient(

if (isVideoCall) {
startLocalVideo()
peerConnection?.addTrack(localVideoTrack, listOf("local_video_stream"))
localVideoTrack?.let { track ->
peerConnection?.addTrack(track, listOf("local_video_stream"))
} ?: Log.w("WebRTC", "⚠️ Local video track unavailable. Continuing call without publishing video.")
}
}

Expand Down Expand Up @@ -456,6 +465,9 @@ class WebRTCClient(
localVideoSource?.dispose()
localVideoSource = null

localVideoTrack?.dispose()
localVideoTrack = null

surfaceTextureHelper?.dispose()
surfaceTextureHelper = null

Expand All @@ -468,4 +480,4 @@ class WebRTCClient(

Log.d("WebRTC", "❌ Call Ended & Audio/Video Cleaned")
}
}
}