Room

class Room

A room session.

Obtain one from VideoSDK.createRoom(...), then call join and use muteMic, unmuteMic, enableCam and the rest.

Every action needs a joined room. Actions here — and on Participant, RTCStream, PubSub and RealtimeStore — check the room state first; a rejected call sends nothing, changes nothing locally and returns without throwing, unless its own docs list the code under @throws. The reason reaches RoomEventListener.onError:

  • before join completes, or after the room ended — 3035 (ERROR_ACTION_PERFORMED_BEFORE_ROOM_JOINED), with the rejected method named in the message;

  • while the room is RoomState.RECONNECTING — 3065 (ERROR_ROOM_RECONNECTING); rejected calls are not replayed once it reconnects;

  • accepted while connected but overtaken by the room closing — 3056 (ERROR_OPERATION_ABORTED).

Two exceptions: RealtimeStore.stopObserving detaches a listener locally, so it always runs and reports nothing; leave stays available while reconnecting and throws 3054 (ERROR_ALREADY_IN_REQUESTED_STATE) once the room has ended.

Every suspend member here is main-safe — call it from Dispatchers.Main and it will not block — and room events reach listeners on the main thread, though the onError raised by a rejected call or a capture fault arrives on the thread that raised it.

Types

Link copied to clipboard
object Companion
Link copied to clipboard
inner class PubSub

Publish and subscribe messaging attached to this room.

Link copied to clipboard
inner class RealtimeStore

Shared key/value store synchronized across participants.

Properties

Link copied to clipboard

true when media is actually being encrypted, not merely when a key provider was set.

Link copied to clipboard

The last HLS state, as RoomEventListener.onHlsStateChanged reported it; HLSState.HLS_STOPPED before any was reported.

Link copied to clipboard

The ID of the room this object is in: the roomId passed to createRoom, then the target of the last successful switchTo.

Link copied to clipboard

true while the local camera is publishing.

Link copied to clipboard

true while the local microphone is publishing.

Link copied to clipboard

true while the local participant's screen share is published.

Link copied to clipboard

The last livestream state, as RoomEventListener.onLivestreamStateChanged reported it; LiveStreamState.LIVESTREAM_STOPPED before any was reported.

Link copied to clipboard

The local participant. Available before join, but its id is only final once RoomEventListener.onRoomJoined has fired — until then it is the participantId you passed to createRoom, or empty.

Link copied to clipboard

The other participants, keyed by participant id. localParticipant is not in here.

Link copied to clipboard

Publish and subscribe to messages on this room's topics.

Link copied to clipboard

Shared key-value state for this room.

Link copied to clipboard

The last cloud-recording state, as RoomEventListener.onRecordingStateChanged reported it; RecordingState.RECORDING_STOPPED before any was reported.

Link copied to clipboard

The current RoomState. Reports DISCONNECTED before join is called.

Link copied to clipboard
Link copied to clipboard

Functions

Link copied to clipboard

Registers a listener for room events. Do it before join, or the join itself and the first participants can be missed.

Link copied to clipboard
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.

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.

Link copied to clipboard
suspend fun changeMic(deviceId: String? = null)

Switches the call's audio route to the device deviceId names: it becomes the selected device, and a live mic is muted and unmuted on it. A muted mic stays muted; the next unmuteMic uses the new device.

suspend fun changeMic(customMicrophoneTrack: CustomStreamTrack)

Switches the microphone to customMicrophoneTrack: a live mic is muted and unmuted with the track, so its audio profile takes effect at once. A muted mic is simply unmuted with it, so the mic is on either way.

Link copied to clipboard
suspend fun changeMode(mode: Mode)

Changes the room mode of the local participant.

Link copied to clipboard
suspend fun changeTranslationLanguage(language: String)

Changes the language this participant receives translations in. Only this device is affected; everyone else keeps the language they chose.

Link copied to clipboard

Turns adaptive subscription off: every stream goes back to the layer its publisher sends.

Link copied to clipboard
suspend fun disableCam()

Stops sending video and closes the camera, so the OS camera indicator goes away rather than staying on with a black frame. Other participants see it through ParticipantEventListener.onStreamDisabled.

Link copied to clipboard
suspend fun disableScreenShare()

Stops sharing the screen and stops the foreground service that backed the share.

Link copied to clipboard

Turns on adaptive subscription: the server picks each incoming stream's quality from the viewport the app reported through Participant.setViewPort rather than whatever the publisher sends.

Link copied to clipboard
suspend fun enableCam(customCameraTrack: CustomStreamTrack? = null)

Enables the local participant's webcam and publishes it to the room.

Link copied to clipboard
@RequiresApi(api = 21)
suspend fun enableScreenShare(customTrack: CustomStreamTrack? = null)

Starts sharing the screen with a track from VideoSDK.createScreenShareVideoTrack, which carries the user's consent, the encoder profile, whether to publish simulcast layers and whether to capture system audio.

@RequiresApi(api = 21)
suspend fun enableScreenShare(data: Intent, enableAudio: Boolean = false)

Starts sharing the screen from a MediaProjection consent the app already collected.

Link copied to clipboard
suspend fun end()

Ends the room for every participant. Whether your token may do this is the server's call; a refusal leaves the local participant in the room.

Link copied to clipboard
suspend fun fetchBase64File(url: String, token: String): String

Fetches a previously uploaded base64 file and returns its content.

Link copied to clipboard

Returns the participant now sharing their screen, or null when nobody is. Follows RoomEventListener.onPresenterChanged.

Link copied to clipboard

Returns the participant now speaking, or null when the room is quiet. Follows RoomEventListener.onSpeakerChanged.

Link copied to clipboard

The camera capture config currently in force: {"width","height","frameRate","facingMode","codec","applied"}.

Link copied to clipboard

The video effects configuration currently in force.

Link copied to clipboard
suspend fun join()

Joins the room and starts publishing the microphone and camera requested in VideoSDK.createRoom.

Link copied to clipboard
suspend fun leave()

Leaves the room, disconnecting the local participant.

Link copied to clipboard
suspend fun muteMic()

Stops sending audio and releases the microphone, so the OS recording indicator goes away rather than staying on with a silent track. Other participants see it through ParticipantEventListener.onStreamDisabled.

Link copied to clipboard
suspend fun pauseAllStreams(kind: StreamKind? = null)

Stops the server sending this participant remote media of one kind, which saves the bandwidth as well as the rendering — unlike simply hiding the tiles. Nobody else is affected.

Link copied to clipboard

Removes every registered RoomEventListener.

Link copied to clipboard

Removes a previously registered listener; an unknown listener is ignored.

Link copied to clipboard

Uninstalls the frame processor; frames go straight to the encoder again. Idempotent.

Link copied to clipboard
suspend fun requestMediaRelay(destinationRoomId: String, token: String? = null, kinds: List<StreamKind>? = null)

Asks another room to accept this one's media, so a broadcast can be forwarded into a second room without anyone rejoining.

Link copied to clipboard
suspend fun respondEntry(participantId: String, decision: EntryDecision)

Lets a waiting participant in, or turns them away.

Link copied to clipboard
suspend fun resumeAllStreams(kind: StreamKind? = null)

Starts remote media of one kind flowing to this participant again after pauseAllStreams. RoomEventListener.onResumedAllStreams confirms it, once per kind.

Link copied to clipboard
suspend fun send(data: ByteArray, reliable: Boolean = true)

Broadcasts a binary payload to every other participant.

suspend fun send(message: String, reliable: Boolean = true)

Broadcasts a text message to every other participant.

Link copied to clipboard

Routes call audio to device and notifies the audio device listener. Works before join too. Unlike changeMic, a live microphone is not restarted.

Link copied to clipboard

Registers the listener told whenever a headset or Bluetooth device is plugged in or removed, or the selected route changes.

Link copied to clipboard

Changes the video effects configuration while the room is running.

Link copied to clipboard

Installs a processor that sees every captured camera frame before it is encoded — for an effect or overlay the SDK does not provide. Works before join too, so a pre-join preview is processed.

Link copied to clipboard
suspend fun setWebcamQuality(quality: VideoQuality)

Caps the quality of the camera stream the local participant is sending.

Link copied to clipboard
suspend fun startHLS(config: HLSConfig? = null, transcription: PostTranscriptionConfig? = null)

Asks the server to publish the room as an HLS stream, for viewers who only watch — a webinar audience, say. They never join the room.

Link copied to clipboard
suspend fun startLivestream(outputs: List<LivestreamOutput>, config: LivestreamConfig? = null)

Asks the server to push the room to one or more RTMP destinations — YouTube Live, Twitch, your own ingest.

Link copied to clipboard
suspend fun startRecording(webhookUrl: String? = null, awsDirPath: String? = null, config: RecordingConfig? = null, transcription: PostTranscriptionConfig? = null)

Asks the server to start recording the room to VideoSDK's cloud.

Link copied to clipboard
suspend fun startTranscription(config: TranscriptionConfig? = null)

Starts live transcription for the whole room: everyone's speech, not just yours.

Link copied to clipboard
suspend fun startTranslation(config: JSONObject? = null)

Starts live translation for the room.

Link copied to clipboard
suspend fun startWhiteboard()

Opens a shared whiteboard for the room. RoomEventListener.onWhiteboardStarted delivers the URL to load in a WebView.

Link copied to clipboard
suspend fun stopHLS()

Stops the HLS stream. RoomEventListener.onHlsStateChanged reports HLS_STOPPED once it has.

Link copied to clipboard
suspend fun stopLivestream()

Stops the RTMP livestream. RoomEventListener.onLivestreamStopped confirms it.

Link copied to clipboard
suspend fun stopMediaRelay(destinationRoomId: String)

Tears the whole relay to one room down, every kind at once. RoomEventListener.onMediaRelayStopped confirms it in this room; in the destination the relayed participants leave with REMOVE_PEER_MEDIA_RELAY_STOP.

Link copied to clipboard
suspend fun stopRecording()

Asks the server to stop recording. RoomEventListener.onRecordingStopped is the confirmation; the call returning is not.

Link copied to clipboard
suspend fun stopTranscription()

Stops live transcription for the room. RoomEventListener.onTranscriptionStateChanged reports the service winding down.

Link copied to clipboard
suspend fun stopTranslation()

Stops live translation for the room, for every participant, not just this one.

Link copied to clipboard
suspend fun stopWhiteboard()

Closes the shared whiteboard for everyone. RoomEventListener.onWhiteboardStopped confirms it.

Link copied to clipboard
suspend fun switchTo(roomId: String, token: String? = null)

Moves this participant into another room without tearing the session down — a breakout room, say. Faster than leave plus a fresh join, and the same Room object keeps working.

Link copied to clipboard
suspend fun unmuteMic(customMicrophoneTrack: CustomStreamTrack? = null)

Unmutes the local microphone.

Link copied to clipboard
suspend fun uploadBase64File(base64Data: String, token: String, fileName: String): String

Uploads a base64-encoded file and returns its URL.