This guide walks you through how to migrate your existing Twilio Video implementation to Vidyo Android SDK. To complement this guide, we have also developed a sample app that can switch between Twilio SDK and Vidyo SDK simply using a build-time configuration. That app provides a handy “translation guide” between Twilio and VidyoClient Android SDK.
Install the SDK
Download and install the VidyoClient SDK from the Developer Portal. For example, if you're building using Gradle or Groovy, add this line to your app/build.gradle file:
Ensure that you have all of the Android system permissions required by the VidyoClient SDK in your project (you can ignore permissions that you already have):
If your project uses proguard, add the following rules to your project:
-keep class com.vidyo.** { *; }
-dontwarn com.vidyo.**
Code Changes
The code snippets below illustrate the mappings between the Vidyo 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 VidyoClient SDK, you must first initialize the Core SDK:
This is usually done when your app starts, but you can place it wherever it is appropriate for your implementation.
Initialize Connector, SDK instance. Vidyo SDK automatically sets the audio, video, and dominant speaker parameters, so the user does not need to set these parameters explicitly:
vidyoConnector = new Connector(binding.vidyoVideoView,
Connector.ConnectorViewStyle.VIDYO_CONNECTORVIEWSTYLE_Default, 8, logLevel, "", 0);
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.
Join session/room
Twilio uses JSON Web Tokens (JWT) to generate a token for users to join sessions. Vidyo follows a different model – a meeting room is created on a backend middleware (referred to as Vidyo Portal) which generates a meeting link, and users join the room through their browser by clicking on the meeting link.
Twilio requires an Access Token to join a meeting room.
Joining a meeting in Vidyo SDK requires the following:
URL of the VidyoPortal that owns/created the room.
Room name
Room pass code (optional). If this is set for a specific room, then users must enter the passcode to enter the room. This pass code is received as part of the meeting invitation.
In a real production setting, the room creation/meeting link generation functionality is handled by a backend VidyoPlatform component referred to as VidyoPortal.
The VidyoPortal provides a web interface (and REST/SOAP APIs) for creating meeting rooms, generating meeting links & moderating meetings.
While Twilio requires additional configuration to set the quality of the video, Vidyo handles the video quality automatically based on network conditions and device capabilities. In low bandwidth conditions Vidyo prioritizes audio over video, and shared content video tiles over participant video. Vidyo also supports configuration options to limit maximum resolution of local or remote video.
Moreover, Vidyo has a Composite Renderer concept where you just have to pass a container ViewGroup reference e.g. binding.vidyoVideoView and VidyoClient will handle all the Local/Remote participant composition for you.
Vidyo has a selectLocalCamera function to select which of the connected cameras to use in the call:
vidyoConnector.selectLocalCamera(localCamera);
Note: local camera list can be obtained from the: onAdded(LocalCamera localCamera) device events callback.
The biggest difference between the implementations is the amount of setup that is required for Twilio. While Twilio requires manually setting up a CameraCapturerCompat and LocalVideoTrack to specify your input sources, this is all handled internally within the VidyoClient SDK.
Turn the camera off
localVideoTrack.enable(false);
However, you also have to manually hide the renderer.
Vidyo’s implementation requires you to call a single API function to disable the local camera:
vidyoConnector.setCameraPrivacy(true);
Render remote user video
Twilio uses onParticipantConnected and onVideoTrackSubscribed event listeners to determine which remote videos to render.
@Override
public void onParticipantConnected(@NonNull Room room, @NonNull RemoteParticipant remoteParticipant) {
addRemoteParticipant(remoteParticipant);
}
…
@Override
public void onVideoTrackSubscribed(
@NonNull RemoteParticipant remoteParticipant,
@NonNull RemoteVideoTrackPublication remoteVideoTrackPublication, @NonNull RemoteVideoTrack remoteVideoTrack) {
addRemoteParticipantVideo(remoteVideoTrack);
}
…
/*
* Set primary view as renderer for participant video track
*/
private void addRemoteParticipantVideo(VideoTrack videoTrack) {
moveLocalVideoToThumbnailView();
primaryVideoView.setMirror(false);
videoTrack.addSink(primaryVideoView);
}
Based on the Composite Renderer concept, Vidyo manages the video rendering part automatically, but the user can also register callbacks to listen to, for example, when a participant joins or leaves a room (later in this guide).
Mute/Unmute Microphone
Since Twilio API is track based, you have to disable the track individually:
localAudioTrack.enable(false);
Use the setMicrophonePrivacy function to set the selected microphone state:
vidyoConnector.setMicrophonePrivacy(true);
Event Listeners
Twilio has event listeners for room and participant management, allowing you to detect changes that occur during a meeting. 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.