VideoSDK Class Methods - Flutter
createRoom()
- This method is provided by SDK to build instance of
VideoSDK Roombased on given configuration. - The room is not connected yet. Add event handlers with
room.on(), then calljoin(). room.localParticipantexists fromcreateRoom(). Before join it carries the id and name you passed, empty when you passed none; join fills in the ones the room assigned.- One room exists at a time. Creating a new room releases the previous one.
- A room joins once. After it leaves the room, create a new room to join again.
Parameters
-
roomId
- type:
String REQUIRED- Id of the Room to be created.
- type:
-
token
- type:
String REQUIRED- Sets AuthToken, which is used for authentication purposes.
- type:
-
participantName
- type:
String OPTIONAL- The name other participants see. Leave it out, and the SDK picks a random name.
- type:
-
micEnabled
- type:
bool OPTIONAL- Whether
micof the participant will beon, while joining the room. If it is set tofalse, then mic of that participant will bedisabledby default, but can beenabledordisabledlater. - Default value of
micEnabledis true.
- type:
-
camEnabled
- type:
bool OPTIONAL- Whether
cameraof the participant will beon, while joining the room. If it is set tofalse, then camera of that participant will bedisabledby default, but can beenabledordisabledlater. - Default value of
camEnabledis true.
- type:
-
multiStream
- type:
bool OPTIONAL- It will specify if the stream should send multiple resolution layers or single resolution.
- Leave it out, and the SDK sends multiple layers.
- type:
-
participantId
- type:
String OPTIONAL- Unique Id of the participant. If not passed then SDK will create an Id by itself and will use that id.
- type:
-
maxResolution
- type:
MaxResolution OPTIONAL- Sets the highest resolution the room works at. Leave it out, and the SDK uses
MaxResolution.HD. - With
MaxResolution.HD, the default camera opens at 1280x720. - With
MaxResolution.SD, the default camera opens at 960x540. - A
customCameraTrackkeeps its own encoder config.
- type:
-
defaultCamera
- type:
FacingMode OPTIONAL- Default value is
FacingMode.FRONT. - Sets the camera that the default webcam opens on:
FacingMode.FRONTorFacingMode.BACK. - A
customCameraTrackkeeps its own facing mode.
- type:
-
customCameraTrack
- type:
CustomStreamTrack OPTIONAL- Set the initial custom video track, created with
createCameraVideoTrack()using different encoding parameters, camera facing mode, bitrate mode and codec.
- type:
-
customMicrophoneTrack
- type:
CustomStreamTrack OPTIONAL- Set the initial custom audio track, created with
createMicrophoneAudioTrack()using different encoding parameters and noise configuration.
- type:
-
mode
- type:
Mode OPTIONAL- Set the participant mode:
Mode.SEND_AND_RECV,Mode.RECV_ONLYorMode.SIGNALLING_ONLY. - Leave it out, and the SDK uses
Mode.SEND_AND_RECV.
- type:
-
metaData
- type:
Map<String,dynamic> OPTIONAL- If you want to provide additional details about a user joining a room, such as their profile image, you can pass that information in this parameter.
- type:
-
autoConsume
- type:
bool OPTIONAL- Default value is
true. - If it is set to
false, remote audio and video arrive only after you callconsumeMicStreams()orconsumeWebcamStreams()on a participant. This saves bandwidth in large rooms.
- type:
-
dynaCast
- type:
bool OPTIONAL- Default value is
false. - If it is set to
true, the server lowers the quality of the webcam video you send while no one is watching its larger layers, and raises it again when someone is. - It has no effect when
multiStreamisfalse.
- type:
-
codecSwitchEnabled
- type:
bool OPTIONAL- Default value is
true. - When a participant cannot decode the video codec in use, the room switches to VP8 so that everyone can see each other. The room reports the switch with the
codecChangedevent.
- type:
-
enableBatching
- type:
bool OPTIONAL- Default value is
true. - Whether the SDK batches room events.
- type:
-
preferredProtocol
- type:
PreferredProtocol OPTIONAL- Sets the transport for media:
UDP_ONLY,UDP_OVER_TCP(try UDP first, and fall back to TCP) orTCP_ONLY. WithUDP_ONLY, the connection fails where UDP is blocked. - Leave it out, and the SDK uses
PreferredProtocol.UDP_OVER_TCP.
- type:
-
signalingBaseUrl
- type:
String OPTIONAL- A custom signaling server. Pass a host name without
https://, for exampleproxy.yourwebsite.com. Leave it out to use the VideoSDK server. See Cloud Proxy.
- type:
-
translationLanguage
- type:
String OPTIONAL- The language to translate into when translation runs.
- type:
-
speakingLanguage
- type:
String OPTIONAL- The language that the local participant speaks, for transcription and translation.
- type:
Returns
Example
// The SDK does not ask for permission when it creates a track.
await VideoSDK.requestPermissions();
CustomStreamTrack videoTrack = await VideoSDK.createCameraVideoTrack(
encoderConfig: CustomCameraTrackConfig.h720p_w1280p,
multiStream: false,
);
//Creating Custom Audio Track
CustomStreamTrack audioTrack = await VideoSDK.createMicrophoneAudioTrack(
encoderConfig: CustomMicrophoneTrackConfig.HIGH_QUALITY);
// Create VideoSDK Room
Room room = VideoSDK.createRoom(
roomId: "<ROOM-ID>",
token: "<TOKEN>",
participantName: "<PARTICIPANT-NAME>",
micEnabled: false,
camEnabled: false,
maxResolution: MaxResolution.HD,
multiStream: false,
defaultCamera: FacingMode.FRONT,
customCameraTrack: videoTrack, // custom video track :: optional
customMicrophoneTrack: audioTrack, // custom audio track :: optional
metaData: {},
);
getDevices()
-
The
getDevices()method returns a list of the currently available cameras and audio devices. The method returns a list ofDeviceInfoobjects describing the devices. Each one is aCameraDeviceInfoor aMicrophoneDeviceInfo. -
DeviceInfoclass has these properties :-
DeviceInfo.deviceId- Returns a string that is an identifier for the represented device, persisted across sessions.
-
DeviceInfo.kind- Returns
videoinputfor a camera. For an audio device it returnsaudioinputoraudiooutput; seegetMics().
- Returns
-
DeviceInfo.label- Returns a string describing this device (for example
BLUETOOTH).
- Returns a string describing this device (for example
-
- On Android and iOS, an audio device is an audio route. Switching to it with
room.setAudioDevice()changes both the microphone and the speaker. - On Android, the audio devices are
SPEAKER_PHONE,EARPIECE,WIRED_HEADSETandBLUETOOTH, anddeviceIdis the same string aslabel. Camera labels look likeCamera 1 (Front Camera). - On iOS,
deviceIdis the same string aslabelfor cameras and audio devices.
Returns
Future<List<DeviceInfo>?>
Example
import 'package:videosdk/videosdk.dart';
void getDeviceList() async {
try {
List<DeviceInfo>? devices = await VideoSDK.getDevices();
} catch (ex) {
print("Error in getDevices ");
}
}
getCameras()
-
The
getCameras()method returns a list of the cameras on the device, asCameraDeviceInfoobjects. -
CameraDeviceInfoclass has these properties :-
CameraDeviceInfo.deviceId- Returns a string that is an identifier for the represented device, persisted across sessions. Pass it as
cameraIdtocreateCameraVideoTrack().
- Returns a string that is an identifier for the represented device, persisted across sessions. Pass it as
-
CameraDeviceInfo.kind- Returns an enumerated value that is
videoinput.
- Returns an enumerated value that is
-
CameraDeviceInfo.label- Returns a string describing this device (for example
Camera 1 (Front Camera)).
- Returns a string describing this device (for example
-
CameraDeviceInfo.facingMode- Returns
FacingMode.FRONTorFacingMode.BACK, ornullwhen the platform does not say which way the camera points.
- Returns
-
Returns
Future<List<CameraDeviceInfo>?>
Example
import 'package:videosdk/videosdk.dart';
void getCameraList() async {
try {
List<CameraDeviceInfo>? cameras = await VideoSDK.getCameras();
} catch (ex) {
print("Error in getCameras");
}
}
getMics()
-
The
getMics()method returns a list of the audio devices on the device, asMicrophoneDeviceInfoobjects. -
MicrophoneDeviceInfoclass has these properties :-
MicrophoneDeviceInfo.deviceId- Returns a string that is an identifier for the represented device, persisted across sessions.
-
MicrophoneDeviceInfo.kind- On Android, every entry is
audiooutput. On iOS, the built-in microphone isaudioinputand the other routes areaudiooutput.
- On Android, every entry is
-
MicrophoneDeviceInfo.label- Returns a string describing this device (for example
BLUETOOTH).
- Returns a string describing this device (for example
-
- On Android and iOS, an audio device is an audio route. Switching to it with
room.setAudioDevice()changes both the microphone and the speaker. - On Android, the audio devices are
SPEAKER_PHONE,EARPIECE,WIRED_HEADSETandBLUETOOTH, anddeviceIdis the same string aslabel. On iOS,deviceIdis the same string aslabel.
Returns
Future<List<MicrophoneDeviceInfo>?>
Example
import 'package:videosdk/videosdk.dart';
List<MicrophoneDeviceInfo> audioDevices = [];
void getAudioDeviceList() async {
try {
// Every device in the list is an audio route.
// Note: Changing the audio device using `room.setAudioDevice()` will affect both the microphone and the speaker.
List<MicrophoneDeviceInfo>? mics = await VideoSDK.getMics();
audioDevices = mics ?? [];
} catch (ex) {
print("Error in getMics ");
}
}
getSelectedVideoDevice()
- This method returns the camera in use: the one the room opened when you joined, or the one you last selected with
room.changeCam(). It returnsnullbefore either.
Returns
CameraDeviceInfo?
Example
CameraDeviceInfo? camera = VideoSDK.getSelectedVideoDevice();
print("Camera in use: ${camera?.label}");
getSelectedAudioDevice()
- This method returns the audio device last selected with
room.changeMic()orroom.setAudioDevice(), or the one the platform switched to, for example when a headset connects. From join it reports the audio device in use. It returnsnullbefore join.
Returns
MicrophoneDeviceInfo?
Example
MicrophoneDeviceInfo? audioDevice = VideoSDK.getSelectedAudioDevice();
print("Audio device in use: ${audioDevice?.label}");
requestPermissions()
- The
requestPermissions()method prompts the user for permission to access camera and microphone devices. It returns aMap<String, bool>object, where the keys in the map can be'audio'for the microphone and'video'for the camera. - The SDK does not ask for camera or microphone permission when it creates a track, and on Android it does not ask when you join or turn a device on either. Call
requestPermissions()before you create tracks or join a room. - On Android, declare the
CAMERAandRECORD_AUDIOpermissions inandroid/app/src/main/AndroidManifest.xml. - On iOS, add the camera and microphone usage descriptions to your app's
Info.plist:
<key>NSCameraUsageDescription</key>
<string>$(PRODUCT_NAME) Camera Usage!</string>
<key>NSMicrophoneUsageDescription</key>
<string>$(PRODUCT_NAME) Microphone Usage!</string>
If you add these keys after your first iOS build, delete Xcode's DerivedData folder once, so that the next build picks them up.
Parameters
Permissions- A
Permissionsspecifying the specific kinds of media, that you want to request. Optional- Allowed Values :
Permissions.AUDIO,Permissions.VIDEO,Permissions.AUDIO_VIDEO - Default :
Permissions.AUDIO_VIDEO
- A
Returns
Future<Map<String, bool>>
Example
import 'package:videosdk/videosdk.dart';
void requestMediaPermissions() async {
try {
//By default both audio and video permissions will be requested.
Map<String, bool> reqPermissions = await VideoSDK.requestPermissions();
//For requesting just audio permission.
Map<String, bool> reqAudioPermissions = await VideoSDK.requestPermissions(Permissions.AUDIO);
//For requesting just video permission.
Map<String, bool> reqVideoPermissions = await VideoSDK.requestPermissions(Permissions.VIDEO);
//For requesting both audio and video permissions.
Map<String, bool> reqAudioVideoPermissions = await VideoSDK.requestPermissions(Permissions.AUDIO_VIDEO);
print("Request Permissions ${reqAudioVideoPermissions['audio']} ${reqAudioVideoPermissions['video']} ");
} catch (ex) {
print("Error in requestPermission ");
}
}
checkPermissions()
- The
checkPermissions()method checks for permission to access camera and microphone devices. It returns aMap<String, bool>object, where the keys in the map can be'audio'for the microphone and'video'for the camera. - It does not ask the user. To ask, call
requestPermissions(), which needs the same Android and iOS setup.
Parameters
- permissions
- A
Permissionsspecifying the types of media to check. Optional- Allowed Values :
Permissions.AUDIO,Permissions.VIDEO,Permissions.AUDIO_VIDEO - Default :
Permissions.AUDIO_VIDEO
- A
Returns
Future<Map<String, bool>>
Example
import 'package:videosdk/videosdk.dart';
void checkMediaPermissions() async {
try {
//By default both audio and video permissions will be checked.
Map<String, bool> checkPermissions = await VideoSDK.checkPermissions();
//For checking just audio permission.
Map<String, bool> checkAudioPermissions = await VideoSDK.checkPermissions(permissions: Permissions.AUDIO);
//For checking just video permission.
Map<String, bool> checkVideoPermissions = await VideoSDK.checkPermissions(permissions: Permissions.VIDEO);
//For checking both audio and video permissions.
Map<String, bool> checkAudioVideoPermissions = await VideoSDK.checkPermissions(permissions: Permissions.AUDIO_VIDEO);
print("Check Permissions ${checkAudioVideoPermissions['audio']} ${checkAudioVideoPermissions['video']} ");
} catch (ex) {
print("Error in checkPermission ");
}
}
checkBluetoothPermission()
- The
checkBluetoothPermissionmethod checks if the application has permission to access Bluetooth on the device. It returns a boolean value indicating whether Bluetooth permission is granted or not.
Returns
Future<bool>
- Bluetooth audio needs the
BLUETOOTH_CONNECTpermission on Android 12 or later, so use this method there, and declareandroid.permission.BLUETOOTH_CONNECTin your app'sAndroidManifest.xml. iOS needs no Bluetooth permission for audio. On iOS, this method always returnsfalse, so do not gate Bluetooth audio on it there.
Example
import 'package:videosdk/videosdk.dart';
void checkBluetooth() async {
try {
bool bluetoothPerm = await VideoSDK.checkBluetoothPermission();
} catch (ex) {
print("Error in checkBluetoothPermission ");
}
}
requestBluetoothPermission()
- The
requestBluetoothPermission()method requests permission to access Bluetooth on the device. It returns a boolean value indicating whether the permission request was successful or not.
Returns
Future<bool>
- Bluetooth audio needs the
BLUETOOTH_CONNECTpermission on Android 12 or later, so use this method there, and declareandroid.permission.BLUETOOTH_CONNECTin your app'sAndroidManifest.xml. iOS needs no Bluetooth permission for audio. On iOS, this method always returnsfalse, so do not gate Bluetooth audio on it there.
Example
import 'package:videosdk/videosdk.dart';
void requestBluetooth() async {
try {
bool bluetoothPerm = await VideoSDK.requestBluetoothPermission();
} catch (ex) {
print("Error in requestBluetoothPermission ");
}
}
createCameraVideoTrack
- You can create a Video Track using
createCameraVideoTrack()method ofVideoSDKclass. - This method can be used to create video track using different encoding parameters, camera facing mode, bitrate mode and codec.
- This method does not ask for camera permission. Call
requestPermissions()before you create the track. - If the track cannot be created, the method throws a
VideoSDKError, for example3017without camera permission,3021when there is no camera,3023when the camera is in use,3026when the camera fails to open, or3071for an unknowncameraId. - To learn more, see Custom Tracks.
Parameters
-
cameraId:
- type:
String - required:
false - It will be the id of the camera from which the video should be captured. Use the
deviceIdof a camera fromgetCameras().
- type:
-
encoderConfig:
- type:
CustomCameraTrackConfig - required:
false - default:
h720p_w1280p - Allowed values :
h90p_w160p|h180p_w320p|h360p_w640p|h540p_w960p|h720p_w1280p|h1080p_w1920p|h120p_w160p|h180p_w240p|h240p_w320p|h360p_w480p|h480p_w640p|h720p_w960p|h1080p_w1440p - It will be the encoderConfigs you can want to use for the Video Track.
- type:
Above mentioned encoder configurations are valid for both, landscape as well as portrait mode.
-
facingMode:
- type:
FacingMode - required:
false - default:
FacingMode.FRONT - Allowed values :
FacingMode.FRONT|FacingMode.BACK - It will specify whether to use front or back camera for the video track.
- type:
-
multiStream
- type:
bool - required:
false - default: true
- It will specify if the stream should send multiple resolution layers or single resolution layer.
info- For rooms with fewer than or equal to four participants, setting
multiStream:falseis regarded as best practice.
- type:
-
bitrateMode
- type:
BitrateMode - required:
false - default:
BitrateMode.BALANCED - Allowed values :
BitrateMode.BANDWIDTH_OPTIMIZED|BitrateMode.BALANCED|BitrateMode.HIGH_QUALITY - It will specify how the encoder trades video quality against bandwidth.
- type:
-
maxLayer
- type:
EncodingLayer - required:
false - default:
EncodingLayer.MAX_LAYER_3 - Allowed values :
EncodingLayer.MAX_LAYER_2|EncodingLayer.MAX_LAYER_3 - It will specify how many resolution layers the stream sends when
multiStreamistrue. For a single layer, setmultiStreamtofalse.
- type:
-
codec
- type:
VideoCodec - required:
false - default:
VideoCodec.VP8 - Allowed values :
VideoCodec.VP8|VideoCodec.H264|VideoCodec.VP9|VideoCodec.AV1 - It will specify the codec used to encode the video. To pick one, refer to the Video Codecs guide.
- type:
Returns
Future<CustomStreamTrack>- If the track cannot be created, the method throws a
VideoSDKError. It never returnsnull.
Example
try {
CustomStreamTrack videoTrack = await VideoSDK.createCameraVideoTrack(
encoderConfig: CustomCameraTrackConfig.h720p_w1280p,
multiStream: false,
facingMode: FacingMode.FRONT,
);
} on VideoSDKError catch (error) {
print("Could not create the track: ${error.code} ${error.name}");
}
createMicrophoneAudioTrack
- You can create a Audio Track using
createMicrophoneAudioTrack()method ofVideoSDKclass. - This method can be used to create audio track using different encoding parameters and noise cancellation configuration.
- This method does not ask for microphone permission. Call
requestPermissions()before you create the track. - If the track cannot be created, the method throws a
VideoSDKError, for example3018without microphone permission,3022when there is no microphone,3024when the microphone is in use, or3071for an unknownmicrophoneId.
Parameters
-
microphoneId:
- type:
String - required:
false - It will be the id of the mic from which the audio should be captured. Use the
deviceIdof a device fromgetMics().
- type:
-
encoderConfig:
- type:
CustomMicrophoneTrackConfig - required:
false - default:
SPEECH_STANDARD - Allowed values :
SPEECH_LOW_QUALITY|SPEECH_STANDARD|MUSIC_STANDARD|STANDARD_STEREO|HIGH_QUALITY|HIGH_QUALITY_STEREO - It will be the encoder configuration you want to use for Audio Track.
- type:
-
noiseConfig
-
type:
NoiseConfig -
required:
false -
If you pass
noiseConfig, every value you leave out is turned on, excepthighPassFilter, which stays off. Pass nonoiseConfigto use the values of theencoderConfigprofile. -
echoCancellation
- type:
bool? - required:
false - If
trueecho cancellation will turned on else it would be turned off.
- type:
-
autoGainControl
- type:
bool? - required:
false - If
trueauto gain will turned on else it would be turned off.
- type:
-
noiseSuppression
- type:
bool? - required:
false - If
truenoise suppression will turned on else it would be turned off.
- type:
-
highPassFilter
- type:
bool? - required:
false - If
truethe high-pass filter, which cuts low-frequency noise, will turned on else it would be turned off.
- type:
-
Returns
Future<CustomStreamTrack>- If the track cannot be created, the method throws a
VideoSDKError. It never returnsnull.
Example
try {
CustomStreamTrack audioTrack = await VideoSDK.createMicrophoneAudioTrack(
encoderConfig: CustomMicrophoneTrackConfig.HIGH_QUALITY,
noiseConfig: NoiseConfig(noiseSuppression: true, echoCancellation: true),
);
} on VideoSDKError catch (error) {
print("Could not create the track: ${error.code} ${error.name}");
}
createScreenShareVideoTrack
- You can create a Screen Share Track using
createScreenShareVideoTrack()method ofVideoSDKclass, and pass it toroom.enableScreenShare(customTrack:). - On Android, this method asks the user for screen-capture consent, and returns
nullif the user declines. It throws aVideoSDKError(3071) for an unknown profile. On iOS, no prompt opens here: the system broadcast picker opens when you callroom.enableScreenShare().
Parameters
-
encoderConfig:
- type:
CustomScreenShareTrackConfig - required:
false - default:
h720p_15fps - Allowed values :
h360p_30fps|h480p_15fps|h480p_30fps|h720p_5fps|h720p_15fps|h720p_30fps|h1080p_15fps|h1080p_30fps
- type:
-
multiStream
- type:
bool - required:
false - default:
false - It will specify if the screen share should send multiple resolution layers or single resolution layer.
- type:
-
withAudio
- type:
bool - required:
false - default:
false - If
true, the audio playing on the device is captured too and mixed into your microphone track, so muting the microphone mutes both. This works on Android 10 or later only.
- type:
Returns
Future<CustomStreamTrack?>
Example
final CustomStreamTrack? shareTrack = await VideoSDK.createScreenShareVideoTrack(
encoderConfig: CustomScreenShareTrackConfig.h720p_15fps,
withAudio: true, // Android only
);
// On Android, null means the user declined the capture prompt.
if (shareTrack != null) {
await room.enableScreenShare(customTrack: shareTrack);
}
runPreCallTest()
- This method tests the camera, the microphone and the network before the user joins a room, and scores the network quality.
- Run it before
createRoom(). After that, a new test is refused withERROR_PRECALL_AFTER_INIT. - Creating a room does not stop a test that is still running, so stop it with
stopPreCallTest()before you callcreateRoom(). - Only one test runs at a time.
- To learn more about the options and the result, see the Precall guide and the Pre-call Test reference.
Parameters
-
options
- type:
PreCallTestOptions - required:
true - The test options.
tokenis required.samplingDuration,audioOnly,videoTrack,audioTrack,videoConfigandaudioConfigare optional.
- type:
-
onStatsChange
- type:
void Function(PreCallNetworkQuality stats) - required:
false - It is called with the latest network quality while the test runs.
- type:
Returns
Future<PreCallTestResult>. It completes with the result, also when the test is stopped (withabortedset totrue), or fails with aPreCallTestException, whosecodeis aString.
Example
try {
final PreCallTestResult result = await VideoSDK.runPreCallTest(
PreCallTestOptions(token: "<TOKEN>"),
onStatsChange: (stats) => print("Uplink quality: ${stats.uplink.quality}"),
);
print("Downlink quality: ${result.networkQuality?.downlink.quality}");
} on PreCallTestException catch (error) {
print("Pre-call test failed: ${error.code} ${error.message}");
}
stopPreCallTest()
- This method stops the pre-call test that is running. Its
runPreCallTest()future still completes, withabortedset totrue. - A failure throws a
PreCallTestException.
Returns
Future<void>
Example
await VideoSDK.stopPreCallTest();
setVideoEffects()
- This method applies video effects to the camera video you send: framing, low-light correction, style, color filter and background blur. It works before and after you join a room.
- Send the whole configuration each time: an effect you leave out goes back to its default.
VideoEffectsPipeline.LEGACY, the default, runs the effects on the CPU, and its framing follows the face it detects.VideoEffectsPipeline.GRAPHruns them on the GPU, and its framing follows the subject you publish withpublishFramingSubject().- Background blur works on
VideoEffectsPipeline.LEGACYonly. On Android, framing on that pipeline needscom.google.mlkit:face-detection:16.1.7, and background blur needscom.google.mlkit:segmentation-selfie:16.0.0-beta6in your app'sbuild.gradle. On iOS, background blur needs iOS 15 or later. room.setVideoEffects()does the same for a room. To run your own video processor, useroom.setVideoProcessor().
Parameters
-
config:
- type:
VideoEffectsConfig - required:
true - The effects to apply, set with
pipeline,framing,lighting,style,filterandbackground.
- type:
Returns
Future<Map<String, dynamic>?>- the effects that are running, under the keysengine,applied,reason,pipeline,framing,lighting,style,filterandbackground. Whenappliedisfalse,reasonsays why.
Example
final Map<String, dynamic>? applied = await VideoSDK.setVideoEffects(
const VideoEffectsConfig(
lighting: VideoEffectsLighting(enabled: true),
background: VideoEffectsBackground(mode: VideoEffectsBackgroundMode.BLUR),
),
);
if (applied?['applied'] != true) {
print("Effects not running: ${applied?['reason']}");
}
getAppliedVideoEffectsConfig()
- This method returns the video effects in use, in the same shape that
setVideoEffects()returns.
Returns
Future<Map<String, dynamic>?>
Example
Map<String, dynamic>? effects = await VideoSDK.getAppliedVideoEffectsConfig();
publishFramingSubject()
- This method tells auto-framing where the subject is when you use
VideoEffectsPipeline.GRAPH. Call it each time your own face or person detection finds the subject. The defaultVideoEffectsPipeline.LEGACYfinds the face itself and needs no call. cxandcyare the center of the subject, andwidthandheightits size, all from0to1of the video frame. Pass0aswidthandheightwhen the subject is lost, and the frame zooms back out.
Parameters
- cx:
double, required - cy:
double, required - width:
double, required - height:
double, required
Returns
Future<void>
Example
await VideoSDK.publishFramingSubject(cx: 0.5, cy: 0.4, width: 0.3, height: 0.4);
setScreenFlash()
- This method turns the screen flash on or off. The screen flash lights a front camera without a torch when
captureImage()runs withflash: CaptureFlash.ON. - Pass
trueto cover the screen in warm white at full brightness for the capture, orfalseto capture without it. The screen flash is off until you call this method.
Parameters
-
enabled:
- type:
bool - required:
true
- type:
Returns
Future<void>
Example
await VideoSDK.setScreenFlash(true);
setKeyProvider()
- This method sets the key provider for end-to-end encryption. Add your keys to a
BaseKeyProvider, and call this method before you join the room. - To turn end-to-end encryption off, call
removeKeyProvider(). getKeyProvider()returns the key provider you set.- To learn more, see the E2EE guide.
Parameters
-
provider:
- type:
BaseKeyProvider - required:
true
- type:
Returns
void
Example
final BaseKeyProvider keyProvider = BaseKeyProvider();
await keyProvider.setSharedKey("<SHARED-KEY>");
VideoSDK.setKeyProvider(keyProvider);
removeKeyProvider()
- This method turns end-to-end encryption off and clears the key provider set with
setKeyProvider(). Call it before you join the room.
Returns
void
Example
VideoSDK.removeKeyProvider();
getKeyProvider()
- This method returns the key provider set with
setKeyProvider(), ornullwhen end-to-end encryption is off.
Returns
BaseKeyProvider?
Example
final BaseKeyProvider? provider = VideoSDK.getKeyProvider();
setParticipantKey()
- This method sets the encryption key for one participant. It applies at once.
- Pass
nullaskeyto remove that participant's key. - A shared key set on the key provider wins over this one.
- It throws an
ArgumentErrorfor an emptyparticipantIdor an emptykey.
Parameters
-
participantId:
- type:
String - required:
true
- type:
-
key:
- type:
String? - required:
true
- type:
Returns
Future<void>
Example
await VideoSDK.setParticipantKey("<PARTICIPANT-ID>", "<PARTICIPANT-KEY>");
// Remove the key
await VideoSDK.setParticipantKey("<PARTICIPANT-ID>", null);
BaseKeyProvider.removeKey()
- This method removes one participant's encryption key. Call it on the key provider you passed to
setKeyProvider(). - On that provider it does the same as
VideoSDK.setParticipantKey(participantId, null): that participant's media stops being decrypted at once. On any other provider it does nothing. - It throws an
ArgumentErrorfor an emptyparticipantId.
Parameters
-
participantId:
- type:
String - required:
true
- type:
Returns
Future<void>
Example
final BaseKeyProvider keyProvider = BaseKeyProvider();
VideoSDK.setKeyProvider(keyProvider);
await VideoSDK.setParticipantKey("<PARTICIPANT-ID>", "<PARTICIPANT-KEY>");
// Later, remove that participant's key
await keyProvider.removeKey("<PARTICIPANT-ID>");
setLogLevel()
- This method sets how much the SDK logs:
LogLevel.NONE,LogLevel.ERROR,LogLevel.WARN,LogLevel.INFO,LogLevel.DEBUGorLogLevel.ALL. getLogLevel()returns the current level.- To learn more, see the Log Level guide.
Parameters
-
level:
- type:
LogLevel - required:
false - default:
LogLevel.INFO
- type:
Returns
void
Example
VideoSDK.setLogLevel(LogLevel.DEBUG);
getLogLevel()
- This method returns the current log level. It returns
LogLevel.INFOuntil you callsetLogLevel().
Returns
LogLevel
Example
final LogLevel level = VideoSDK.getLogLevel();
enableLogForwarding()
- The SDK writes its logs to Logcat on Android and to the Xcode console on iOS, so they do not appear in
flutter run. This method sends them to a listener in your app, so you can print them there. - The listener receives the level of each log (
error,warn,infoordebug) and its message. Forwarded logs follow the level you set withsetLogLevel(). - Calling it again replaces the listener.
Parameters
-
listener:
- type:
void Function(String level, String message) - required:
true
- type:
Returns
Future<bool>-falsewhen forwarding could not be turned on.
Example
final bool forwarding = await VideoSDK.enableLogForwarding((level, message) {
print("[$level] $message");
});
disableLogForwarding()
- This method stops log forwarding and removes the listener.
Returns
Future<void>
Example
await VideoSDK.disableLogForwarding();
getBuildId()
- This method returns the build ID of the Android or iOS SDK that the Flutter SDK runs on, or
unknownwhen the platform does not report one. - Add it to bug reports together with
sdkVersion.
Returns
Future<String>
Example
final String buildId = await VideoSDK.getBuildId();
print("SDK ${VideoSDK.sdkVersion}, build $buildId");
sdkVersion
VideoSDK.sdkVersionreturns the version of the Flutter SDK, as in itspubspec.yaml.
Returns
String
Example
print("VideoSDK version: ${VideoSDK.sdkVersion}");
Got a Question? Ask us on discord

