A link to the repo can be found here:
Android SDKProject structure
- SDK project: sdk module, containing all Telnyx SDK components as well as tests.
- Demo application: app module, containing a sample demo application utilizing the sdk module.
Adding the SDK to your Android client application
Add Jitpack.io as a repository within your root level build file:Remember to add and handle INTERNET, RECORD_AUDIO and ACCESS_NETWORK_STATE permissions in order to properly use the SDK.
Before connecting to a Room
Get an API Key
You’ll need an API key which is associated with your Mission Control Portal account under API Keys. You can learn how to do that here. An API key is your credential to access our API. It allows you to:- to authenicate to the Rest API
- to manage your access tokens
Create a Room to join (if it doesn’t exist)
In order to join a room you must create it, if it doesn’t already exist. See our Room Rest API to create one. There’s also additional resources on other endpoints available to perform basic operations on aRoom.
Generate an a client token to join a room
In order to join a room you must have a client token for thatRoom. The client token is short lived and you will be able to refresh it using the refresh token provided with it when you request a client token.
Please see the docs here to learn how to create a client token.
Now you are ready to connect to a video room that you previously created using the REST API.
Connect to Room
To connect, you’ll need to provide a participantName that will identify your user in that room. You’ll also need to provide an instance of ExternalData that will contain a username of type String and an Integer id. You will also provide your Android application’s context in contextPublish video/audio stream
To publish as video or audio stream, we will need an instance of PublishConfigHelper with the application context, camera direction, streamKey (unique for each stream published), and streamId (unique for each stream published)Since stream is already created, it is only necessary to add the video track to PublishConfigHelper, and “update” the stream.
Remove video/audio track
To remove a video or audio track, publishConfigHelper has to be modified in order to remove the unwanted trackRemove stream
By removing the stream, we will remove all tracks added to it.Video/Audio Observables
The Telnyx Video SDK for android works with mutable live data, and all the information you need to build your UI is provided through observables that will contain the most up to date information of the state of the room, such as current participant list, talking events, stream information, participants added, participants leaving, etcState Observable
val status: String
is the status of the Room session, when that action happened
val participants: List<Participant>
is the list of participants present in a room. A Participant is a UI representation in variables, for an attendee to the room session.
val streams: HashMap<Long, Stream>
this hash map, contains a track of the currently available streams and the id of the publisher streaming them.
A stream, will contain tracks for video, audio or both.
val publishers: List<Publisher>
This will track all publishers in the room. A Publisher is an instance of an attendee or participant sharing some stream content in the room.
A single Participant, sharing multiple streams can be also linked to multiple Publisher ids.
val subscriptions: List<Subscription>
Each time a publisher starts streaming information, we will have the option of subscribe/unsubscribe to/from it. This list will track all the subscriptions.
Event observables
Some observables will have a MutableLiveData of Event. Event is a wrapper of LiveData, and provide the means to ensure we only handle an observable once, no matter how many times we’re set to observe it. If the contents have already been handled, we won’t get that content again, unless we peekContent() instead.Participants Observable
Joined Room Observable
This will be different to Status-CONNECTED that will be issued when we have successfully joined our plugins to handle session audio. See Status.