Android | Zoom Video SDK + Twilio migration

This guide walks you through how to migrate your existing project from the Twilio Video SDK to the Zoom Video SDK. If you're starting a new project from scratch, see the Video SDK for Android documentation as it contains more details about the usage and features of the Video SDK.

Create a developer account

Create a Video SDK developer account to access your credentials. Choose a plan to get started.

Install the SDK

Download and install the Video SDK from the Zoom Developer Portal or through the Maven Central repository. For example, if you're building using Gradle or Groovy, add this line to your app/build.gradle file:

implementation 'us.zoom.videosdk:ZoomVideoSDK:<VERSION>'

Replace <VERSION> with the version of the SDK, such as 1.5.3.

Authorize

Both Zoom and Twilio use JSON Web Tokens (JWT) to authorize the use of the SDK and to generate a token for users to join. On your auth server, replace your Twilio Video JWT generation logic with the Zoom Video SDK JWT generation logic.

Set up your project

We suggest that you add the Zoom Video SDK to your project through Maven. MavenCentral hosts the Video SDK for Android. Use the following code to add it (replace <version> with your desired version):

implementation 'us.zoom.videosdk:ZoomVideoSDK:<version>'

Remove Twilio SDK

If you like, you can also remove the Twilio SDK from your project with the following.

implementation 'com.twilio:video-android:<version>'

Set permissions

Ensure that you have all of the Android system permissions required by the Video SDK in your project (you can ignore permissions that you already have):

WRITE_EXTERNAL_STORAGE
INTERNET
READ_PHONE_STATE
ACCESS_NETWORK_STATE
ACCESS_WIFI_STATE
MODIFY_AUDIO_SETTINGS
RECORD_AUDIO
CAMERA
BLUETOOTH
BLUETOOTH_ADMIN
BLUETOOTH_CONNECT
BLUETOOTH_SCAN
BROADCAST_STICKY
WAKE_LOCK
CALL_PHONE
SYSTEM_ALERT_WINDOW
FOREGROUND_SERVICE

If your project uses proguard, add the following rules to your project.

-keep class us.zoom**{
   *;
}
-keep interface us.zoom**{
   *;
}
-keep class org.webrtc**{
   *;
}
-keep class com.zipow**{
   *;
}

Code Changes

The code snippets below illustrate the mappings between the Zoom and Twilio SDKs. Low-level functionality may differ between the two platforms, so the mappings may not be perfectly accurate for all use cases.

Initialize the SDK

In order to use The Zoom Video SDK, you must first initialize the main SDK singleton. This is usually done when your app starts, but you can substitute in the Video SDK wherever it is appropriate for your implementation.

There is no equivalent of this in the Twilio Video SDK, so it is important to find the correct place in your app to add initialization logic.

val zoomSdk = ZoomSDK.getInstance()
val initParams = ZoomVideoSDKInitParams().apply {
    domain = "zoom.us" // Required
    enableLog = BuildConfig.DEBUG // Optional for debugging
    logFilePrefix = "MyLogPrefix" // Optional for debugging
}
zoomSdk.initialize(context, initParams)

SDK callbacks

Both SDKs use listeners to detect and stay in sync with state changes. Replace the Twilio listener code with the Zoom Video SDK code.

val roomListener = object : Room.Listener {...}
class ZoomDelegate : ZoomVideoSDKDelegate {...}
val delegate = ZoomDelegate()
zoomSdk.addListener(delegate)

The callbacks in these listeners can reflect a number of different changes including connection to the session/channel, status of other users, errors, and changes in state related to specific features.

There are two main differences to be aware of when migrating to the ZoomVideoSDKDelegate used by Zoom:

  1. For most use cases, the ZoomVideoSDKDelegate contains all of the callbacks you need. In Twilio there are multiple listeners depending on the area of functionality you are using. So it may require some refactoring to consolidate everything into one place.
  2. You can call addListener whenever you're ready to receive callbacks from the Video SDK, while Twilio's connect method requires you to pass in a Room.Listener when connecting to a room.

Join session/room

The Video SDK uses sessions, which are similar to Twilio's concept of a room. Replace Twilio's code with Zoom's.

val connectOptions = ConnectOptions.Builder(joinToken)
    .videoTracks(localVideoTracks)
    .audioTracks(localAudioTracks)
    .roomName(sessionId)
    .build()
Video.connect(context, connectOptions, roomListener)
val sessionContext = ZoomVideoSDKSessionContext().apply {
    sessionName = sessionId
    userName = username
    sessionPassword = password
    token = myToken
}
zoomSdk.joinSession(sessionContext)

Both SDKs use a token for authentication, but the Zoom SDK JWT requires information specific to the session you are trying to join, so it's important to use the correct payload as specified in Generate a Video SDK JWT.

Video

See how to migrate from Twilio to Zoom Video SDK for video controls, local video preview, and displaying other user videos.

Video controls

Turning your own video on or off is conceptually similar between the two SDKs.

val cameraEnumerator = Camera2Enumerator(context)
cameraEnumerator.deviceNames.firstOrNull { cameraEnumerator.isFrontFacing(it) }?.let {
    val cameraCapturer = Camera2Capturer(context, it)
    val localVideoTrack = LocalVideoTrack.create(context, true, cameraCapturer)
    cameraCapturer.startCapture(width, height, framerate)
}
cameraCapturer.stopCapture()
zoomSdk.videoHelper.startVideo()
zoomSdk.videoHelper.stopVideo()

The biggest difference between the implementations is the amount of setup that is required for Twilio. While Twilio requires manually setting up a Camera2Capturer and LocalVideoTrack to specify your input sources, this is all handled internally within the Zoom Video SDK.

Set up local video preview

Additionally, setting up a local video preview is similar between the two SDKs.

val previewVideoView = VideoView(context)
localVideoTrack?.addSink(previewVideoView)
val videoView = ZoomVideoSDKVideoView(context)
val canvas = zoomSdk.session.mySelf.videoCanvas
canvas.subscribe(videoView, ZoomVideoSDKVideoAspect.ZoomVideoSDKVideoAspect_PanAndScan)

Display other user videos

In order to enable your end users to see the video feeds of other users in a session/channel, you can use an approach similar to that used when setting up local video preview. But instead of getting local video, get the ZoomVideoSDKVideoCanvas associated with another user.

val remoteVideoView = VideoView(context)
remoteVideoTrack.addSink(remoteVideoView)
remoteVideoTrack.removeSink(remoteVideoView)
zoomSdk.session.remoteUsers.firstOrNull { userId == it.userID }?.videoCanvas?.subscribe(remoteUserView, ZoomVideoSDKVideoAspect.ZoomVideoSDKVideoAspect_PanAndScan)
zoomSdk.session.remoteUsers.firstOrNull { userId == it.userID }?.videoCanvas?.unSubscribe(remoteUserView)

Audio controls

Similarly to video controls, both SDKs offer a relatively simple approach to controlling audio.

audioTrack.enable(enable)
zoomSdk.audioHelper.startAudio()
val self = zoomSdk.session.mySelf
zoomSdk.audioHelper.unMuteAudio(self)
val self = zoomSdk.session.mySelf
zoomSdk.audioHelper.muteAudio(self)

Leave a session

To leave a session, call the leaveSession function and confirm whether the session should be ended for all users if you are the host.

room.disconnect();
zoomSdk.leaveSession(end)

Clean up Video SDK

When you are no longer using Zoom Video SDK in your app, you can call a simple method to clean up the Zoom Video SDK.

localVideoTrack.release()
localAudioTrack.release()
zoomSdk.cleanup()

With Twilio, you're required to release each track individually.

REST APIs and Webhooks

Zoom Video SDK has a full suite of REST APIs and webhooks.

Learn how to use the Zoom APIs and webhooks.

For reference, here's the Twilio REST API documentation.

Video SDK features and support

Zoom has a number of additional features including live transcription and translation, cloud recording, Public Switched Telephone Network (PSTN) call out and call in to join sessions by phone, chat, screen sharing, and command channel to send data to other users in a session. Zoom also supports additional Video SDK platforms including Android, iOS, Linux, macOS, Windows, and wrappers such as Flutter and React Native. See the Zoom Video SDK documentation to learn more.

For the complete feature map of Twilio Video to Zoom Video SDK, by platform, see the feature map.

Start building with the Video SDK now. For questions, contact us!

Contact Us

See Video SDK Plans & Pricing for Developer for pricing.