Camera Control

Control camera capture, switching, and video settings.

Start Camera

// Start with front camera (default)
videoHelper.joinAsHost(serverUrl, token, channelName, localVideoView);

// Or explicitly set camera
videoHelper.setCameraPosition(CameraPosition.FRONT);
videoHelper.publishCamera(localVideoView);

Switch Camera

// Toggle between front and back
videoHelper.switchCamera();

// Or set specific camera
videoHelper.setCameraPosition(CameraPosition.BACK);
videoHelper.setCameraPosition(CameraPosition.FRONT);

Enable/Disable Camera

// Turn off camera (stops capture, keeps track published)
videoHelper.enableCamera(false);

// Turn on camera
videoHelper.enableCamera(true);

// Check state
boolean isEnabled = videoHelper.isCameraEnabled();

Video Quality Settings

// Set video resolution and framerate
VideoEncoderConfig config = new VideoEncoderConfig(
    1280,     // width
    720,      // height
    30,       // fps
    2000000   // bitrate (2 Mbps)
);
videoHelper.setVideoEncoderConfig(config);

// Common presets
// 720p: 1280x720, 30fps, 2Mbps
// 1080p: 1920x1080, 30fps, 4Mbps
// 480p: 854x480, 30fps, 1Mbps

Camera Mirror

// Local preview is mirrored by default (selfie view)
localVideoView.setMirror(true);

// Remote viewers see non-mirrored
remoteVideoView.setMirror(false);

Video Scaling

// Fill the view (may crop)
videoView.setScalingType(ScalingType.SCALE_ASPECT_FILL);

// Fit in view (may letterbox)
videoView.setScalingType(ScalingType.SCALE_ASPECT_FIT);

// Stretch to fill (may distort)
videoView.setScalingType(ScalingType.SCALE_ASPECT_BALANCED);

Flashlight (Torch)

// Enable flash (back camera only)
videoHelper.setFlashEnabled(true);

// Disable flash
videoHelper.setFlashEnabled(false);
ℹ️

Request CAMERA permission before starting camera capture.