Skip to content

Add Video Calling Feature#68

Open
DivyanshuChipa wants to merge 2 commits intomasterfrom
feat/video-calling-18390055824140193157
Open

Add Video Calling Feature#68
DivyanshuChipa wants to merge 2 commits intomasterfrom
feat/video-calling-18390055824140193157

Conversation

@DivyanshuChipa
Copy link
Copy Markdown
Owner

This commit adds video calling support to the WebRTC-based communication flow in the Android application.

Key changes:

  • WebRTCClient.kt: Added logic to manage video sources, tracks, and capturers using Camera2Enumerator.
  • CallScreen.kt: Implemented video rendering using AndroidView and SurfaceViewRenderer with a PiP layout. Added buttons for toggling video and switching cameras.
  • ChatScreen.kt & MainActivity.kt: Differentiated between audio and video call buttons, updating signaling payloads with an is_video_call flag.
  • AndroidManifest.xml: Requested the necessary CAMERA permission.

All WebRTC lifecycle issues (e.g., re-initialization crashes during re-composition) were fixed by correctly managing renderer init() and release() in Compose.


PR created automatically by Jules for task 18390055824140193157 started by @DivyanshuChipa

Implemented video calling features in the Android application by extending the WebRTCClient and adding dedicated UI controls in ChatScreen and CallScreen. Introduced a separate video call button and the ability to toggle video or switch cameras during an active call. The remote and local video streams are displayed using a Picture-in-Picture layout via SurfaceViewRenderer embedded in Jetpack Compose's AndroidView. Handled proper lifecycle initialization and cleanup to prevent EGL crashes. Added CAMERA permission and updated WebSocket signaling to include the `is_video_call` parameter transparently routed by the backend.

Co-authored-by: DivyanshuChipa <211708943+DivyanshuChipa@users.noreply.github.com>
@google-labs-jules
Copy link
Copy Markdown
Contributor

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 0dfaa00a4d

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

}

if (localVideoSource == null) {
localVideoSource = peerConnectionFactory?.createVideoSource(videoCapturer!!.isScreencast)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Guard null capturer before creating video source

createVideoCapturer() can legitimately return null (for example when CAMERA permission is denied or no compatible camera is available), but this path force-unwraps it via videoCapturer!! and will crash as soon as a video call starts. This turns a recoverable device/permission condition into an app crash; handle the null case and fall back gracefully (e.g., abort video setup or downgrade to audio).

Useful? React with 👍 / 👎.

Comment on lines +456 to +457
localVideoSource?.dispose()
localVideoSource = null
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Reset local video track during call cleanup

Cleanup disposes and nulls the capturer/source, but leaves localVideoTrack intact; on the next video call startLocalVideo() skips recreating the track because it is non-null, so the peer connection can reuse a track bound to a disposed source and fail to publish video after the first call. Dispose/null the video track in endCall() so subsequent calls rebuild a valid capture pipeline.

Useful? React with 👍 / 👎.

Comment on lines +124 to 125
// Note: For background intent handling we default to audio right now unless we extract it from intent
callViewModel.onIncomingCall(intentSender, fullPhotoUrl)
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-call flag in intent incoming-call path

This intent-handling branch still calls onIncomingCall without passing isVideoCall, so calls opened from notification/background intent are always initialized as audio even when the sender requested video. The websocket foreground path already parses is_video_call; this one should carry the same flag through intent extras and pass it here to avoid inconsistent behavior between foreground and background incoming calls.

Useful? React with 👍 / 👎.

Extended the existing WebRTC voice calling system in the web client (`backend/static/`) to fully support video calls, completing cross-platform feature parity with the Android app.

- Added a new 'Call Type' dialog to let users pick between 'Voice Call' and 'Video Call'.
- Updated `chat.html` to include local and remote `<video>` elements using a Picture-in-Picture layout.
- Added buttons and logic to toggle the local video stream and switch camera orientation (front/back).
- Modified `app.js` to handle the `is_video_call` signaling flag, acquire correct `getUserMedia` tracks based on the call type, and attach those streams to the DOM.

Co-authored-by: DivyanshuChipa <211708943+DivyanshuChipa@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant