createRoom

fun createRoom(roomId: String, token: String, participantName: String? = null, micEnabled: Boolean = true, camEnabled: Boolean = true, participantId: String? = null, mode: Mode? = null, multiStream: Boolean? = null, customCameraTrack: CustomStreamTrack? = null, customMicrophoneTrack: CustomStreamTrack? = null, metaData: JSONObject? = null, signalingBaseUrl: String? = null, preferredProtocol: VideoSDK.PreferredProtocol? = null, codecSwitchEnabled: Boolean = true, enableBatching: Boolean = true, translationLanguage: String? = null, speakingLanguage: String? = null, maxResolution: MaxResolution? = null, defaultCamera: FacingMode = FacingMode.front, autoConsume: Boolean = true, dynaCast: Boolean = false): Room

Creates a Room for roomId without connecting to it.

Nothing reaches the network here: register your listeners on the returned room, then call Room.join to connect.

Every argument is fixed at join time. To change the microphone, camera, mode or translation language later, use the Room methods rather than calling createRoom again.

Code Example:

val room = VideoSDK.createRoom(
roomId = "abcd-efgh-ijkl",
token = "YOUR_AUTH_TOKEN",
participantName = "Ada Lovelace",
micEnabled = true,
camEnabled = true,
)
room.addEventListener(roomEventListener)
lifecycleScope.launch { room.join() }

Return

a Room ready to call Room.join on.

Parameters

roomId

unique ID of the room to join. Create one with the Create Room API. If empty, throws code 3073 (ERROR_INVALID_PARAMETER).

token

the JWT authentication token, generated on your server with your VideoSDK API key and secret. If empty, throws code 3073 (ERROR_INVALID_PARAMETER); a malformed or expired one is refused by the server, so it surfaces as a failed Room.join.

participantName

display name shown to other participants. If null or empty, a random 6-character name is used.

micEnabled

if true, the microphone is published on join. RECORD_AUDIO must already be granted, or the microphone does not start.

camEnabled

if true, the camera is published on join. CAMERA must already be granted, or the camera does not start and the failure is reported on RoomEventListener.onError.

participantId

unique participant identifier. If null or empty, a random 8-character one is generated.

mode

the room mode. If null, defaults to Mode.SEND_AND_RECV.

multiStream

if true, the camera is published as a simulcast ladder instead of a single stream. If null, defaults to true.

customCameraTrack

the camera track to publish instead of the default camera, from createCameraVideoTrack. If null, the default camera is used.

customMicrophoneTrack

the microphone track to publish instead of the default microphone, from createMicrophoneAudioTrack. If null, the default microphone is used.

metaData

JSON metadata attached to this participant. If null, none is attached.

signalingBaseUrl

custom signaling server base URL. If null, the VideoSDK signaling server is used.

preferredProtocol

preferred network protocol for media. If null, defaults to PreferredProtocol.UDP_OVER_TCP.

codecSwitchEnabled

if true, the video codec you send switches to VP8 when a remote participant cannot decode it, and RoomEventListener.onCodecChanged fires. Unrelated to the hardware-encoder fallback, which always runs.

enableBatching

if true, server notifications are received in batches.

translationLanguage

language incoming speech is translated into. If null, translation is off.

speakingLanguage

language this participant speaks.

maxResolution

the size the default camera opens at. With MaxResolution.sd it opens at 960x540 (or the largest 16:9 size below it the camera offers) instead of 1280x720. A customCameraTrack keeps its own encoderConfig. If null, defaults to MaxResolution.hd.

defaultCamera

the camera the default camera track opens on. A customCameraTrack keeps its own facingMode, and after Room.changeCam the camera stays on the one switched to. Defaults to FacingMode.front.

autoConsume

if true, every remote participant's microphone and camera are received as soon as they publish. If false, nothing is received until you call Participant.consumeMicStreams / Participant.consumeWebcamStreams for that participant, which saves bandwidth in large rooms: call them from RoomEventListener.onParticipantJoined and ParticipantEventListener.onMediaStatusChanged. Until then no onStreamEnabled fires for that media. Screen shares have no consume call. Defaults to true.

dynaCast

if true, the server lowers the quality of the camera stream the local participant sends while no remote participant is watching its larger layers, and raises it again when one is, which saves upload bandwidth. Never goes above the cap set with Room.setWebcamQuality. Has no effect on a camera sending a single layer (multiStream off, or a non-VP8 VideoCodec). Defaults to false.

Throws

if initialize has not been called.

code 3073 (ERROR_INVALID_PARAMETER) if roomId or token is empty.