Room class

A room, and the object you listen to for everything that happens in it.

Create one with VideoSDK.createRoom, listen with on, call join, and when you are done call leave (or end to close the room for everyone). A room is single-use: once Events.roomLeft is delivered it removes every handler and releases itself; create a new one to rejoin.

Example

final room = VideoSDK.createRoom(
  roomId: 'abcd-efgh-ijkl',
  token: token,
  participantName: 'Alice',
);

room.on(Events.roomJoined, () {
  print('joined ${room.id}');
});

room.on(Events.streamEnabled, (RTCStream stream) {
  // a participant's audio, video or screen share is available
});

await room.join();

// later, when the call screen closes:
await room.leave();

Errors

Methods that talk to the room return a Future that throws a VideoSDKError when the Android or iOS SDK refuses — for example because the room is not joined yet. Always await them (or catch the error): a call left unawaited turns a refusal into an unhandled async error.

Properties

agentParticipants → Map<String, Participant>
Just the AI agents, keyed by participant id.
final
agentPeerId → String?
The participant id of the first AI agent in the room, or null if there is none. The agent itself is in agentParticipants.
no setter
e2eeEnabled → bool
Whether end-to-end encryption is active.
no setter
hlsState → String
Latest HLS status, e.g. HLS_PLAYABLE.
no setter
hlsUrl → HLSUrl?
The URLs of the running HLS stream, once it is playable.
no setter
id → String
The room id. After switchTo lands, the id of the room switched to.
no setter
isCamEnabled → bool
Whether the local camera is on.
no setter
isMicEnabled → bool
Whether the local microphone is on.
no setter
isScreenSharing → bool
Whether the local participant is sharing their screen.
no setter
liveStreamState → String
Latest RTMP livestream status, e.g. LIVESTREAM_STARTED.
no setter
localParticipant ↔ Participant
The local participant. Before join it carries the requested id and name (empty when none was given); join fills in the ones the room assigned.
latefinal
participants → Map<String, Participant>
The remote participants, keyed by participant id. Includes AI agents. The local participant is localParticipant and is not in this map, as in 3.x.
final
pinnedParticipants → Map<String, ParticipantPinState>
Pin state per participant.
final
pubSub ↔ PubSub
Publish/subscribe messaging for this room.
getter/setter pair
realtimeStore ↔ RealtimeStore
Shared key/value state for this room.
getter/setter pair
recordingState → String
Latest recording status, e.g. RECORDING_STARTED.
no setter
roomState → RoomState
The connection state, as last reported by Events.roomStateChanged.
no setter
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
transcriptionState → TranscriptionState
Latest transcription status, as Events.transcriptionStateChanged reports.
no setter
translationState → TranslationState
Latest translation status, as Events.translationStateChanged reports.
no setter

Methods

changeCam({String? deviceId, CustomStreamTrack? customCameraTrack}) → Future<void>
Switches the camera to customCameraTrack (turns the camera on), to the camera deviceId, or to the next camera when both are null. A device switch keeps the camera on or off. An unknown deviceId throws 3051.
changeMic({String? deviceId, CustomStreamTrack? customMicrophoneTrack}) → Future<void>
Switches the mic to customMicrophoneTrack (unmutes), to the device deviceId, or to the next mic when both are null. A device switch keeps the mute state. An unknown deviceId throws 3059. Outside a room a deviceId is selected and applied on the next join.
changeMode(Mode mode) → Future<void>
Changes what the local participant may send and receive.
changeTranslationLanguage(String language) → Future<void>
Changes the language this participant reads translations in.
disableAdaptiveSubscription() → Future<void>
Stops adaptive subscription.
disableCam() → Future<void>
Turns the local camera off.
disableScreenShare() → Future<void>
Stops sharing the screen.
enableAdaptiveSubscription() → Future<void>
Lets the SDK choose stream quality from the visible layout.
enableCam([CustomStreamTrack? customCameraTrack]) → Future<void>
Turns the local camera on, optionally with a custom camera track.
enableScreenShare({CustomStreamTrack? customTrack}) → Future<void>
Starts sharing the screen.
end() → Future<void>
Ends the room for everyone.
fetchBase64File({required String url, required String token}) → Future<String?>
Fetches a previously uploaded file as base64.
getActivePresenterId() → String?
The participant currently sharing their screen, if any.
getActiveSpeakerId() → String?
The participant currently detected as speaking, if any.
getAppliedVideoConfig() → Future<Map<String, dynamic>?>
The camera capture config in force — {width, height, frameRate, facingMode, codec, applied}. Null until the camera has been opened once; applied is false when a config is set but capture is not running.
getAppliedVideoEffectsConfig() → Future<Map<String, dynamic>?>
The video-effects config in force, same shape as setVideoEffects.
getAttributes() → Future<Map<String, dynamic>>
Server-side attributes for this room (logs, observability, traces).
join() → Future<void>
Joins the room.
leave() → Future<void>
Leaves the room. Other participants stay in it.
muteMic() → Future<void>
Mutes the local microphone.
off(Events event, Function handler) → void
Removes a handler previously passed to on.
on(Events event, Function handler) → void
Subscribes handler to event.
pauseAllStreams({StreamKind? kind}) → Future<void>
Pauses every incoming stream, or only those of kind.
publishFramingSubject({required double cx, required double cy, required double width, required double height}) → Future<void>
Publishes the subject box that auto-framing follows; see VideoSDK.publishFramingSubject.
removeAllEventListeners() → void
Removes every handler added with on.
removeVideoProcessor() → Future<void>
Stops the video processor set with setVideoProcessor.
requestMediaRelay(String destinationRoomId, {String? token, List<StreamKind>? kinds}) → Future<void>
Relays this participant's media into the room destinationRoomId.
respondEntry(String participantId, String decision) → Future<void>
Answers participantId's request to join: decision is "allowed" or "denied". The same as the allow/deny functions in Events.entryRequested.
resumeAllStreams({StreamKind? kind}) → Future<void>
Resumes every incoming stream, or only those of kind.
send(Object message, {bool reliable = true}) → Future<void>
Sends message to every other participant over the data channel.
setAudioDevice(MicrophoneDeviceInfo device) → Future<void>
Routes audio to device without changing the mute state. Android and iOS expose one audio route, so this is also the microphone.
setAudioDeviceChangeListener(void listener(MicrophoneDeviceInfo? selectedDevice, List<MicrophoneDeviceInfo> devices)?) → void
Calls listener whenever the audio route changes — a headset or Bluetooth device connects or disconnects — with the device now in use and every one available. Pass null to stop.
setVideoEffects(VideoEffectsConfig config) → Future<Map<String, dynamic>?>
Applies config to the outgoing camera video; see VideoSDK.setVideoEffects for the two engines.
setVideoProcessor(String processorName) → Future<void>
Runs the camera through the video processor registered natively under processorName. Works before join: the room exists from VideoSDK.createRoom.
setWebcamQuality(VideoQuality quality) → Future<void>
Caps the outgoing camera stream at quality.
startHLS({HLSConfig? config, PostTranscriptionConfig? transcription}) → Future<void>
Starts HLS. Follow it with Events.hlsStateChanged.
startLivestream(List<LivestreamOutput> outputs, {LivestreamConfig? config}) → Future<void>
Starts an RTMP livestream to outputs.
startRecording({String? webhookUrl, String? awsDirPath, RecordingConfig? config, PostTranscriptionConfig? transcription}) → Future<void>
Starts recording the room.
startTranscription({TranscriptionConfig? config}) → Future<void>
Starts real-time transcription.
startTranslation({Map<String, dynamic>? config}) → Future<void>
Starts real-time translation.
startWhiteboard() → Future<void>
Opens a shared whiteboard.
stopHLS() → Future<void>
Stops HLS.
stopLivestream() → Future<void>
Stops the livestream.
stopMediaRelay(String destinationRoomId) → Future<void>
Stops relaying into destinationRoomId.
stopRecording() → Future<void>
Stops recording.
stopTranscription() → Future<void>
Stops transcription.
stopTranslation() → Future<void>
Stops translation.
stopWhiteboard() → Future<void>
Closes the whiteboard.
switchTo(String roomId, {String? token}) → Future<void>
Moves the local participant to the room roomId, optionally with a new token.
unmuteMic([CustomStreamTrack? customMicrophoneTrack]) → Future<void>
Unmutes the local microphone, optionally with a custom microphone track.
uploadBase64File({required String base64Data, required String token, required String fileName}) → Future<String?>
Uploads a base64 file and returns its URL.