Camera filter is a feature that you can use to apply face filters on the host's face. By using various face filters, the host will be able to offer an engaging and entertaining live event experience for the participants. Follow this guide to integrate Banuba Face Filters SDK to Sendbird Live SDK.
The minium requirements to implement camera filter for Live SDK for Android are:
- Android 5.0 (API level 21) or higher
- Java 8 or higher
- Android Gradle plugin 4.0.1 or higher
- Sendbird Live SDK 1.0.0-beta.5 or higher
- Banuba Face Filters SDK
Before you start
Before installing the Live SDK, create a Sendbird account to acquire an application ID which you will need to initialize the Live SDK. Go to Sendbird Dashboard and create an application by selecting Calls+Live in product type. Once you have created an application, go to Overview and you will see the Application ID.
How it works
In this guide, you will be installing Sendbird Live SDK and Banuba Face Filters SDK. After installing and initializing the two SDKs, you will set up a live event by using some essential UI components to integrate face filters to a live event in the quickest manner.
Once you create a user to act as a host, you can start a live event and add face filters on the host's camera feed. You can also enter the live event to watch as a participant using our UIKit sample. Follow along this guide using the sample app for camera filter which you can download here.
Install the Live SDK and Face Filters SDK
First, you can install the Live UIKit for Android through
Gradle. If you use Gradle 6.7 or lower, add the following code to your root
Note: Make sure the above code block isn't added to your module
If you use Gradle 6.8 or higher, add the following code to your
Note: To learn more about updates to Gradle, visit this page.
Next, for all Gradle versions, open the
build.gradle file at the application level. For both
Kotlin, add the following code block and dependencies.
Request permission to access camera and microphone
To use camera and microphone on a mobile device, you need to ask the users to grant the media access permission on their devices. This permission is also needed to access the photo library.
Initialize the Live SDK
To integrate the Live SDK in a client app, initialize the Live SDK with a Sendbird application ID by adding the code below.
If you already have an application ID, log in to Sendbird Dashboard, go to Overview and you will see the Application ID, or get one by creating an application by selecting Calls+Live in product type.
Authenticate a user
To use the interfaces of the Live SDK, you need to authenticate a user. You can authenticate a user by providing their user ID and access token in
SendbirdLive.authenticate. This will establish a connection between the Sendbird server and the user. Once you have authenticated and connected the user, the user can act as a host to create, enter, and start a live event.
Set up a live event with UI components
To set up a live event, provide UI views to create, enter, and start a live event. This will allow you to start a live event using the most essential and minimal components which would look like views shown in the image below.
Step 1 Create and enter a live event
First, provide credentials to log into the client app. After logging in, select the Go live button to create and enter the live event. When you enter, you will be the host of the live event which allows you to control the live event such as whether to start or stop your media stream.
Step 2 Start the live event
When you start the live event, participants can enter your live event, view the host's media stream, and chat. To start the live event, follow the code below.
If you would like to learn more about using the full-fledged UI features for Sendbird Live, go to Live UIKit Overview page.
Initialize the Face Filters SDK
You need to initialize the Face Filters SDK that you downloaded previously by using Banuba's SDK token. Visit their website to get a valid token and follow the code shown below to initialize the SDK.
Stream with Face Filters SDK
Once the Face Filters SDK is initialized, you can select filters to apply to the host's face. To stream a live event that has filters applied, you need to let the Live SDK know that such external video will be streaming. Then, the Face Filters SDK delivers modified video frames through its handler which the Live SDK can use to stream to the participants. Take the steps below to apply the filters and stream the modified video.
Step 1 Configure the Face Filters SDK
First, set up the Face Filters SDK with the correct configurations then choose the desired face filter. You can learn more about the core feature that applies face filters from here.
Step 2 Streaming with external video frames
To receive the external video frames, the
enterAsHost() method must be called before adding the listener and streaming with an external video. By implementing the code below, you can pass the video frames from the Live SDK to the Face Filters SDK.
addVideoFrameListener to receive events about video frames from the Live SDK.
To start streaming your live event with external video frames, call
Step 3 Apply face filters to external video frames
You can select face filters to apply to the host's face. Once you select filters, the Face Filters SDK modifies the camera feed to apply the filters and returns the processed frames through its handler. Pass the frames to the live event to stream to the participants.
Step 4 Stop streaming with external video frames
If you would like to stop streaming with face filters, call
stopUsingExternalVideo(). If you would like the host to stream from another camera, specify the device using the
Watch the live event as a participant
To watch the ongoing live event as a participant, download Sendbird Live sample app for iOS from The App Store, for Android from Google Play, or from Github. You can also use Live studio from Sendbird Dashboard to test Sendbird Live.