Skip to main content
Version: 0.1.x

VideoSDK Class Methods - Android

initialize()

To initialize the meeting, first you have to initialize the VideoSDK. You can initialize the VideoSDK using initialize() method provided by the SDK.

Parameters

  • context: Context

Returns

  • void
initialize
  VideoSDK.initialize(Context context)

config()

By using config() method, you can set the token property of VideoSDK class.

Please refer this documentation to generate a token.

Parameters

  • token: String

Returns

  • void
config
 VideoSDK.config(String token)

initMeeting()

  • Initialize the meeting using a factory method provided by the SDK called initMeeting().
  • initMeeting() will generate a new Meeting class and the initiated meeting will be returned.
initMeeting
   VideoSDK.initMeeting(
Context context,
String meetingId,
String name,
boolean micEnabled,
boolean webcamEnabled,
String participantId,
String mode,
boolean multiStream,
Map<String, CustomStreamTrack> customTracks
JSONObject metaData,
String signalingBaseUrl
PreferredProtocol preferredProtocol
)
  • Please refer this documentation to know more about initMeeting().

getDevices()

  • The getDevices() method returns a list of the currently available media devices, such as microphones, cameras, headsets, and so forth. The method returns a list of DeviceInfo objects describing the devices.

  • DeviceInfo class has four properties :

    1. DeviceInfo.deviceId

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

      • Returns a string describing this device (for example BLUETOOTH).
    3. DeviceInfo.kind

      • Returns an enumerated value that is either video or audio.
    4. DeviceInfo.FacingMode

      • Returns a value of type FacingMode indicating which camera device is in use (front or back).

Returns

  • Set<DeviceInfo>

Example

val devices: Set<DeviceInfo> = VideoSDK.getDevices()
for (deviceInfo in devices) {
Log.d("VideoSDK", "Device's DeviceId " + deviceInfo.deviceId)
Log.d("VideoSDK", "Device's Label " + deviceInfo.label)
Log.d("VideoSDK", "Device's Kind " + deviceInfo.kind)
Log.d("VideoSDK", "Device's Facing Mode " + deviceInfo.facingMode) //Value will be null for Audio Devices
}

getVideoDevices()

  • The getVideoDevices method returns a list of currently available video devices. The method returns a list of VideoDeviceInfo objects describing the video devices.

  • VideoDeviceInfo class has four properties :

    1. VideoDeviceInfo.deviceId

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

      • Returns a string describing this device (for example BLUETOOTH).
    3. VideoDeviceInfo.kind

      • Returns an enumerated value that is video .
    4. VideoDeviceInfo.FacingMode

      • Returns a value of type FacingMode indicating which camera device is in use (front or back).

Returns

  • Set<VideoDeviceInfo>

Example

val videoDevices: Set<VideoDeviceInfo> = VideoSDK.getVideoDevices()
for (videoDevice in videoDevices) {
Log.d("VideoSDK", "Video Device's DeviceId " + videoDevice.deviceId)
Log.d("VideoSDK", "Video Device's Label " + videoDevice.label)
Log.d("VideoSDK", "Video Device's Kind " + videoDevice.kind)
}

getAudioDevices()

  • The getAudioDevices method returns a list of currently available audio devices. The method returns a list of AudioDeviceInfo objects describing the audio devices.

  • AudioDeviceInfo class has three properties :

    1. AudioDeviceInfo.deviceId

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

      • Returns a string describing this device (for example BLUETOOTH).
    3. AudioDeviceInfo.kind

      • Returns an enumerated value that is audio.

Returns

  • Set<AudioDeviceInfo>

Example

val audioDevices: Set<AudioDeviceInfo> = VideoSDK.getAudioDevices()
for (audioDevice in audioDevices) {
Log.d("VideoSDK", "Audio Device's DeviceId " + audioDevice.deviceId)
Log.d("VideoSDK", "Audio Device's Label " + audioDevice.label)
Log.d("VideoSDK", "Audio Device's Kind " + audioDevice.kind)
}

setAudioDeviceChangeListener()

  • The AudioDeviceChangeEvent is emitted when an audio device, is connected to or removed from the device. This event can be set by using setAudioDeviceChangeListener() method.

Parameters

  • audioDeviceChangeEvent: AudioDeviceChangeEvent

Returns

  • void

Example

VideoSDK.setAudioDeviceChangeListener { selectedAudioDevice: AudioDeviceInfo, audioDevices: Set<AudioDeviceInfo> ->
Log.d(
"VideoSDK",
"Selected Audio Device: " + selectedAudioDevice.label
)
for (audioDevice in audioDevices) {
Log.d("VideoSDK", "Audio Devices" + audioDevice.label)
}
}

checkPermissions()

  • The checkPermissions() method verifies whether permissions to access camera and microphone devices have been granted. If the required permissions are not granted, the method will proceed to request these permissions from the user.

Parameters

  • context

    • type: Context
    • REQUIRED
    • The android context.
  • permission

    • type: List<Permission>
    • REQUIRED
    • The permission to be requested.
  • permissionHandler

    • type: PermissionHandler
    • REQUIRED
    • The permission handler object for handling callbacks of various user actions such as permission granted, permission denied, etc.
  • rationale

    • type: String
    • OPTIONAL
    • Explanation to be shown to user if they have denied permission earlier. If this parameter is not provided, permissions will be requested without showing the rationale dialog.
  • options

    • type: Permissions.Options
    • OPTIONAL
    • The options object for setting title and description of dialog box that prompts users to manually grant permissions by navigating to device settings. If this parameter is not provided,the default title and decription will be used for the dialog box.

Returns

  • void

Example

private val permissionHandler: PermissionHandler = object : PermissionHandler() {
override fun onGranted() {}
override fun onBlocked(
context: Context,
blockedList: java.util.ArrayList<Permission>
): Boolean {
for (blockedPermission in blockedList) {
Log.d("VideoSDK Permission", "onBlocked: $blockedPermission")
}
return super.onBlocked(context, blockedList)
}

override fun onDenied(
context: Context,
deniedPermissions: java.util.ArrayList<Permission>
) {
for (deniedPermission in deniedPermissions) {
Log.d("VideoSDK Permission", "onDenied: $deniedPermission")
}
super.onDenied(context, deniedPermissions)
}

override fun onJustBlocked(
context: Context,
justBlockedList: java.util.ArrayList<Permission>,
deniedPermissions: java.util.ArrayList<Permission>
) {
for (justBlockedPermission in justBlockedList) {
Log.d("VideoSDK Permission", "onJustBlocked: $justBlockedPermission")
}
super.onJustBlocked(context, justBlockedList, deniedPermissions)
}
}
val permissionList: MutableList<Permission> = ArrayList()
permissionList.add(Permission.audio)
permissionList.add(Permission.video)
permissionList.add(Permission.bluetooth)
val rationale = "Please provide permissions"
val options =
Permissions.Options().setRationaleDialogTitle("Info").setSettingsDialogTitle("Warning")
//If you wish to disable the dialog box that prompts
//users to manually grant permissions by navigating to device settings,
//you can set options.sendDontAskAgainToSettings(false)
VideoSDK.checkPermissions(this, permissionList, rationale, options, permissionHandler)

setSelectedAudioDevice()

  • It sets the selected audio device, allowing the user to specify which audio device to use in the meeting.

Parameters

  • selectedAudioDevice: AudioDeviceInfo

Returns

  • void

Example

val audioDevices: Set<AudioDeviceInfo> = VideoSDK.getAudioDevices()
val audioDeviceInfo: AudioDeviceInfo = audioDevices.toTypedArray().get(0) as AudioDeviceInfo
VideoSDK.setSelectedAudioDevice(audioDeviceInfo)

setSelectedVideoDevice()

  • It sets the selected video device, allowing the user to specify which video device to use in the meeting.

Parameters

  • selectedVideoDevice: VideoDeviceInfo

Returns

  • void

Example

val videoDevices: Set<VideoDeviceInfo> = VideoSDK.getVideoDevices()
val videoDeviceInfo: VideoDeviceInfo = videoDevices.toTypedArray().get(1) as VideoDeviceInfo
VideoSDK.setSelectedVideoDevice(videoDeviceInfo)

applyVideoProcessor()

  • This method allows users to dynamically apply virtual background to their video stream during a live session.

Parameters

  • videoFrameProcessor

    • type: VideoFrameProcessor
    • This is an object of the VideoFrameProcessor class, which overrides the onFrameCaptured(VideoFrame videoFrame) method.

Returns

  • void

Example

val uri = Uri.parse("https://st.depositphotos.com/2605379/52364/i/450/depositphotos_523648932-stock-photo-concrete-rooftop-night-city-view.jpg")
val backgroundImageProcessor = BackgroundImageProcessor(uri)
VideoSDK.applyVideoProcessor(backgroundImageProcessor)

removeVideoProcessor()

  • This method provides users with a convenient way to revert their video background to its original state, removing any previously applied virtual background.

    • Returns:
      • void

Example

VideoSDK.removeVideoProcessor();

Got a Question? Ask us on discord