changeCam

suspend fun changeCam(deviceId: String? = null)

Switches the webcam to the camera deviceId names: the camera is selected for this room, and a running webcam is disabled and re-enabled on it. A webcam that is off stays off — only the selection changes, and the next enableCam opens it.

A failed switch restores the previous camera as the selected one and rethrows, so a camera that cannot open is not used again by enableCam or by a reconnect.

Parameters

deviceId

a Camera2 device id from VideoSDK.getCameras, or null for the camera after the current one in that list, wrapping around

Throws

code 3051 (ERROR_NO_WEBCAM_DEVICE_FOUND) if deviceId matches no camera, changing nothing; code 3033 (ERROR_CAMERA_ACCESS_UNAVAILABLE) if the camera list cannot be read; code 3035 / 3065 if the room is not joined or is reconnecting; or any code disableCam or enableCam throws. 3051, 3035 and 3065 are also reported on RoomEventListener.onError.


suspend fun changeCam(customCameraTrack: CustomStreamTrack)

Switches the webcam to customCameraTrack: a running camera is disabled and re-enabled with the track, so its encoder profile, facing and device id all take effect at once. A camera that is off is simply enabled with it, so the webcam is on either way.

The track replaces the room's stored camera config, so later enableCam calls rebuild from it.

Nothing is rolled back on failure: a refused disable leaves the previous camera publishing and skips the enable, and a failed enable leaves nothing publishing.

Parameters

customCameraTrack

Throws

code 3035 or 3065 if the room is not joined or is reconnecting (also reported on RoomEventListener.onError), or any code disableCam or enableCam throws.