Enable call vanity when joining a video call.

This commit is contained in:
Alex Hart
2026-02-13 13:12:12 -04:00
parent 97c9728c65
commit ac59528f5c
8 changed files with 177 additions and 14 deletions

View File

@@ -22,6 +22,7 @@ import org.webrtc.CameraVideoCapturer;
import org.webrtc.CapturerObserver;
import org.webrtc.SurfaceTextureHelper;
import org.webrtc.VideoFrame;
import org.webrtc.VideoSink;
import java.util.LinkedList;
import java.util.List;
@@ -47,6 +48,7 @@ public class Camera implements CameraControl, CameraVideoCapturer.CameraSwitchHa
private boolean enabled;
private boolean isInitialized;
private int orientation;
@Nullable private volatile VideoSink vanitySink;
public Camera(@NonNull Context context,
@NonNull CameraEventListener cameraEventListener,
@@ -139,6 +141,15 @@ public class Camera implements CameraControl, CameraVideoCapturer.CameraSwitchHa
this.cameraEventListener = cameraEventListener;
}
/**
* Set a vanity sink that receives camera frames directly from the capturer,
* bypassing the WebRTC VideoTrack pipeline. This allows local preview to work
* even when the video track is disabled (e.g., during incoming call ringing).
*/
public void setVanitySink(@Nullable VideoSink vanitySink) {
this.vanitySink = vanitySink;
}
public void dispose() {
if (capturer != null) {
capturer.dispose();
@@ -327,6 +338,10 @@ public class Camera implements CameraControl, CameraVideoCapturer.CameraSwitchHa
@Override
public void onFrameCaptured(VideoFrame videoFrame) {
observer.onFrameCaptured(videoFrame);
VideoSink sink = vanitySink;
if (sink != null) {
sink.onFrame(videoFrame);
}
}
}
}