Skip to main content
Version: 5.x.x

VideoSDK Class Methods - Flutter

createRoom()​

  • This method is provided by SDK to build instance of VideoSDK Room based on given configuration.
  • The room is not connected yet. Add event handlers with room.on(), then call join().
  • room.localParticipant exists from createRoom(). 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.
  • token

    • type: String
    • REQUIRED
    • Sets AuthToken, which is used for authentication purposes.
  • participantName

    • type: String
    • OPTIONAL
    • The name other participants see. Leave it out, and the SDK picks a random name.
  • micEnabled

    • type: bool
    • OPTIONAL
    • Whether mic of the participant will be on, while joining the room. If it is set to false, then mic of that participant will be disabled by default, but can be enabled or disabled later.
    • Default value of micEnabled is true.
  • camEnabled

    • type: bool
    • OPTIONAL
    • Whether camera of the participant will be on, while joining the room. If it is set to false, then camera of that participant will be disabled by default, but can be enabled or disabled later.
    • Default value of camEnabled is true.
  • 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.
  • 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.
  • 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 customCameraTrack keeps its own encoder config.
  • defaultCamera

    • type: FacingMode
    • OPTIONAL
    • Default value is FacingMode.FRONT.
    • Sets the camera that the default webcam opens on: FacingMode.FRONT or FacingMode.BACK.
    • A customCameraTrack keeps its own facing mode.
  • customCameraTrack

    • type: CustomStreamTrack
    • OPTIONAL
    • Set the initial custom video track, created with createCameraVideoTrack() using different encoding parameters, camera facing mode, bitrate mode and codec.
  • customMicrophoneTrack

    • type: CustomStreamTrack
    • OPTIONAL
    • Set the initial custom audio track, created with createMicrophoneAudioTrack() using different encoding parameters and noise configuration.
  • mode

    • type: Mode
    • OPTIONAL
    • Set the participant mode: Mode.SEND_AND_RECV, Mode.RECV_ONLY or Mode.SIGNALLING_ONLY.
    • Leave it out, and the SDK uses Mode.SEND_AND_RECV.
  • 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.
  • autoConsume

  • 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 multiStream is false.
  • 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 codecChanged event.
  • enableBatching

    • type: bool
    • OPTIONAL
    • Default value is true.
    • Whether the SDK batches room events.
  • preferredProtocol

    • type: PreferredProtocol
    • OPTIONAL
    • Sets the transport for media: UDP_ONLY, UDP_OVER_TCP (try UDP first, and fall back to TCP) or TCP_ONLY. With UDP_ONLY, the connection fails where UDP is blocked.
    • Leave it out, and the SDK uses PreferredProtocol.UDP_OVER_TCP.
  • signalingBaseUrl

    • type: String
    • OPTIONAL
    • A custom signaling server. Pass a host name without https://, for example proxy.yourwebsite.com. Leave it out to use the VideoSDK server. See Cloud Proxy.
  • translationLanguage

    • type: String
    • OPTIONAL
    • The language to translate into when translation runs.
  • speakingLanguage

    • type: String
    • OPTIONAL
    • The language that the local participant speaks, for transcription and translation.

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 of DeviceInfo objects describing the devices. Each one is a CameraDeviceInfo or a MicrophoneDeviceInfo.

  • DeviceInfo class has these properties :

    1. DeviceInfo.deviceId

      • Returns a string that is an identifier for the represented device, persisted across sessions.
    2. DeviceInfo.kind

      • Returns videoinput for a camera. For an audio device it returns audioinput or audiooutput; see getMics().
    3. DeviceInfo.label

      • Returns a string describing this device (for example BLUETOOTH).
note
  • 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_HEADSET and BLUETOOTH, and deviceId is the same string as label. Camera labels look like Camera 1 (Front Camera).
  • On iOS, deviceId is the same string as label for 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, as CameraDeviceInfo objects.

  • CameraDeviceInfo class has these properties :

    1. CameraDeviceInfo.deviceId

      • Returns a string that is an identifier for the represented device, persisted across sessions. Pass it as cameraId to createCameraVideoTrack().
    2. CameraDeviceInfo.kind

      • Returns an enumerated value that is videoinput.
    3. CameraDeviceInfo.label

      • Returns a string describing this device (for example Camera 1 (Front Camera)).
    4. CameraDeviceInfo.facingMode

      • Returns FacingMode.FRONT or FacingMode.BACK, or null when the platform does not say which way the camera points.

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, as MicrophoneDeviceInfo objects.

  • MicrophoneDeviceInfo class has these properties :

    1. MicrophoneDeviceInfo.deviceId

      • Returns a string that is an identifier for the represented device, persisted across sessions.
    2. MicrophoneDeviceInfo.kind

      • On Android, every entry is audiooutput. On iOS, the built-in microphone is audioinput and the other routes are audiooutput.
    3. MicrophoneDeviceInfo.label

      • Returns a string describing this device (for example BLUETOOTH).
note
  • 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_HEADSET and BLUETOOTH, and deviceId is the same string as label. On iOS, deviceId is the same string as label.

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 returns null before 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() or room.setAudioDevice(), or the one the platform switched to, for example when a headset connects. From join it reports the audio device in use. It returns null before 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 a Map<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 CAMERA and RECORD_AUDIO permissions in android/app/src/main/AndroidManifest.xml.
  • On iOS, add the camera and microphone usage descriptions to your app's Info.plist:
ios/Runner/Info.plist
<key>NSCameraUsageDescription</key>
<string>$(PRODUCT_NAME) Camera Usage!</string>
<key>NSMicrophoneUsageDescription</key>
<string>$(PRODUCT_NAME) Microphone Usage!</string>
note

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 Permissions specifying the specific kinds of media, that you want to request.
    • Optional
    • Allowed Values : Permissions.AUDIO, Permissions.VIDEO, Permissions.AUDIO_VIDEO
    • Default : Permissions.AUDIO_VIDEO

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 a Map<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 Permissions specifying the types of media to check.
    • Optional
    • Allowed Values : Permissions.AUDIO, Permissions.VIDEO, Permissions.AUDIO_VIDEO
    • Default : Permissions.AUDIO_VIDEO

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 checkBluetoothPermission method 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>
info
  • Bluetooth audio needs the BLUETOOTH_CONNECT permission on Android 12 or later, so use this method there, and declare android.permission.BLUETOOTH_CONNECT in your app's AndroidManifest.xml. iOS needs no Bluetooth permission for audio. On iOS, this method always returns false, 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>
info
  • Bluetooth audio needs the BLUETOOTH_CONNECT permission on Android 12 or later, so use this method there, and declare android.permission.BLUETOOTH_CONNECT in your app's AndroidManifest.xml. iOS needs no Bluetooth permission for audio. On iOS, this method always returns false, 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 of VideoSDK class.
  • 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 example 3017 without camera permission, 3021 when there is no camera, 3023 when the camera is in use, 3026 when the camera fails to open, or 3071 for an unknown cameraId.
  • 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 deviceId of a camera from getCameras().
  • 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.
note

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.
  • 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:false is regarded as best practice.
  • 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.
  • 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 multiStream is true. For a single layer, set multiStream to false.
  • 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.

Returns​

  • Future<CustomStreamTrack>
  • If the track cannot be created, the method throws a VideoSDKError. It never returns null.

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 of VideoSDK class.
  • 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 example 3018 without microphone permission, 3022 when there is no microphone, 3024 when the microphone is in use, or 3071 for an unknown microphoneId.

Parameters​

  • microphoneId:

    • type: String
    • required: false
    • It will be the id of the mic from which the audio should be captured. Use the deviceId of a device from getMics().
  • 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.
  • noiseConfig

    • type: NoiseConfig

    • required: false

    • If you pass noiseConfig, every value you leave out is turned on, except highPassFilter, which stays off. Pass no noiseConfig to use the values of the encoderConfig profile.

    • echoCancellation

      • type: bool?
      • required: false
      • If true echo cancellation will turned on else it would be turned off.
    • autoGainControl

      • type: bool?
      • required: false
      • If true auto gain will turned on else it would be turned off.
    • noiseSuppression

      • type: bool?
      • required: false
      • If true noise suppression will turned on else it would be turned off.
    • highPassFilter

      • type: bool?
      • required: false
      • If true the high-pass filter, which cuts low-frequency noise, will turned on else it would be turned off.

Returns​

  • Future<CustomStreamTrack>
  • If the track cannot be created, the method throws a VideoSDKError. It never returns null.

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 of VideoSDK class, and pass it to room.enableScreenShare(customTrack:).
  • On Android, this method asks the user for screen-capture consent, and returns null if the user declines. It throws a VideoSDKError (3071) for an unknown profile. On iOS, no prompt opens here: the system broadcast picker opens when you call room.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
  • multiStream

    • type: bool
    • required: false
    • default: false
    • It will specify if the screen share should send multiple resolution layers or single resolution layer.
  • 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.

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 with ERROR_PRECALL_AFTER_INIT.
  • Creating a room does not stop a test that is still running, so stop it with stopPreCallTest() before you call createRoom().
  • 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. token is required. samplingDuration, audioOnly, videoTrack, audioTrack, videoConfig and audioConfig are optional.
  • onStatsChange

    • type: void Function(PreCallNetworkQuality stats)
    • required: false
    • It is called with the latest network quality while the test runs.

Returns​

  • Future<PreCallTestResult>. It completes with the result, also when the test is stopped (with aborted set to true), or fails with a PreCallTestException, whose code is a String.

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, with aborted set to true.
  • 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.GRAPH runs them on the GPU, and its framing follows the subject you publish with publishFramingSubject().
  • Background blur works on VideoEffectsPipeline.LEGACY only. On Android, framing on that pipeline needs com.google.mlkit:face-detection:16.1.7, and background blur needs com.google.mlkit:segmentation-selfie:16.0.0-beta6 in your app's build.gradle. On iOS, background blur needs iOS 15 or later.
  • room.setVideoEffects() does the same for a room. To run your own video processor, use room.setVideoProcessor().

Parameters​

  • config:

    • type: VideoEffectsConfig
    • required: true
    • The effects to apply, set with pipeline, framing, lighting, style, filter and background.

Returns​

  • Future<Map<String, dynamic>?> - the effects that are running, under the keys engine, applied, reason, pipeline, framing, lighting, style, filter and background. When applied is false, reason says 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 default VideoEffectsPipeline.LEGACY finds the face itself and needs no call.
  • cx and cy are the center of the subject, and width and height its size, all from 0 to 1 of the video frame. Pass 0 as width and height when 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 with flash: CaptureFlash.ON.
  • Pass true to cover the screen in warm white at full brightness for the capture, or false to capture without it. The screen flash is off until you call this method.

Parameters​

  • enabled:

    • type: bool
    • required: true

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

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(), or null when 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 null as key to remove that participant's key.
  • A shared key set on the key provider wins over this one.
  • It throws an ArgumentError for an empty participantId or an empty key.

Parameters​

  • participantId:

    • type: String
    • required: true
  • key:

    • type: String?
    • required: true

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 ArgumentError for an empty participantId.

Parameters​

  • participantId:

    • type: String
    • required: true

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.DEBUG or LogLevel.ALL.
  • getLogLevel() returns the current level.
  • To learn more, see the Log Level guide.

Parameters​

  • level:

    • type: LogLevel
    • required: false
    • default: LogLevel.INFO

Returns​

  • void

Example​

VideoSDK.setLogLevel(LogLevel.DEBUG);

getLogLevel()​

  • This method returns the current log level. It returns LogLevel.INFO until you call setLogLevel().

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, info or debug) and its message. Forwarded logs follow the level you set with setLogLevel().
  • Calling it again replaces the listener.

Parameters​

  • listener:

    • type: void Function(String level, String message)
    • required: true

Returns​

  • Future<bool> - false when 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 unknown when 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.sdkVersion returns the version of the Flutter SDK, as in its pubspec.yaml.

Returns​

  • String

Example​

print("VideoSDK version: ${VideoSDK.sdkVersion}");

Got a Question? Ask us on discord