createCameraVideoTrack

fun createCameraVideoTrack(encoderConfig: String, facingMode: String, optimizationMode: CustomStreamTrack.VideoMode, multiStream: Boolean, context: Context, videoDeviceInfo: VideoDeviceInfo, maxLayer: Integer, bitrateMode: BitrateMode): CustomStreamTrack

Creates a custom camera video track with full control over simulcast layers and bitrate mode.

Use this to create a video track before joining a meeting or to replace the active video track during a meeting using enableWebcam. This is the most configurable overload, allowing you to specify the maximum number of simulcast layers and the bitrate mode in addition to the standard video configuration.

Return

A CustomStreamTrack for the camera, or null if creation fails (e.g., camera permission denied).

Code Example:


val videoTrack = VideoSDK.createCameraVideoTrack(
    "h720p_w1280p",                        // 720p resolution
    "front",                                // front camera
    CustomStreamTrack.VideoMode.MOTION,     // optimize for motion
    true,                                   // enable simulcast
    context,
    null,                                   // use default camera
    3,                                      // 3 simulcast layers
    BitrateMode.HIGH_QUALITY                 // higher quality bitrate
)

// Use the track when enabling webcam
meeting.enableWebcam(videoTrack)

Parameters

encoderConfig

Video resolution preset (e.g., "h480p_w720p", "h720p_w1280p"). If null or empty, defaults to "h480p_w720p". Available presets: "h144p_w176p", "h240p_w320p", "h360p_w640p", "h480p_w640p", "h480p_w720p", "h720p_w960p", "h720p_w1280p", "h1080p_w1440p".

facingMode

Camera facing mode: "front" or "back".

optimizationMode

Video optimization mode. MOTION prioritizes frame rate (ideal for video calls), while TEXT prioritizes resolution (ideal for screen content). See CustomStreamTrack.VideoMode.

multiStream

If true, enables simulcast encoding (multiple quality layers sent to the server). Required for adaptive subscription and per-participant quality control via setViewPort or setQuality.

context

Application context.

videoDeviceInfo

(Optional) Specific camera device. Use getVideoDevices to enumerate available cameras. If null, the default camera for the specified facingMode is used.

maxLayer

(Optional) Maximum number of simulcast layers (e.g., 2, or 3). More layers provide finer quality adaptation at the cost of higher encoding overhead. Only effective when multiStream is true. If null, the SDK default is used.

bitrateMode

(Optional) The bitrate mode for encoding. HIGH_QUALITY provides better quality at the expense of higher bandwidth, BALANCED is suitable for most conditions, and BANDWIDTH_OPTIMIZED conserves bandwidth. If null, the SDK default is used. See BitrateMode.

See also