Client
The documentation for Huddle01 Android SDK to connect your Android App to Huddle01 servers.
Getting Started
Add Jitpack
Add Jitpack in the repositories block inside allprojects block in your project-level build.gradle file.
2. Add Huddle01 Android SDK Dependency
Add the dependency in your app-level build.gradle file inside the dependency block. Also, replace the version number with the latest one.
3. Initialize HuddleClient
To initialize the HuddleClient, call the initApp function inside the onCreate of your Application class.
You will need to create your own class extending the Android Application class and make necessary changes in your AndroidManifest.xml file.
Creating and Joining Room
To create a new Room, you will need to create a new object of HuddleClient type.
Here, some mandatory things to do are are:
Passing context in Builder()
Passing an API key inside the Builder()
Setting event listener of type RoomEventListener in setRoomEventListener()
Setting event listener of type MeListener in setMeListener()
The defaults for rest of the fields are:
peerId - A random string of size 8
roomId - A random string of size 8
displayName - A random string of size 6
canConsume - true
canProduce - true
canUseDataChannel - true
frontCamEnabledOnInit - true (false means that the session will start with a rear camera)
build() function will terminate the object creation process and create a room with the provided parameters.
You may use this sample API Key: i4pzqbpxza8vpijQMwZsP1H7nZZEH0TN3vR4NdNS
To join room, once the room is created, call the joinRoom() function. Do check for RECORD_AUDIO, INTERNET, CAMERA permissions before joining the room.
Event Listeners
When you create a room, you need to supply two Event Listeners:
RoomEventListener
MeListener
RoomEventListener
Trigger: on Room URL generation complete in the SDK.
Returns: A string roomUrl corresponding to the roomId
MeListener
Trigger: when SDK registers your information while creating the room.
Returns: String peerId denoting your peerId, string displayName denoting your display name, deviceInfo of type DeviceInfo denoting your device information.
Available Methods
The following methods solve complex video conferencing tasks in a single line:
Function | Purpose | Remarks |
joinRoom() | joins the room when the room is created | Use only when permissions are granted and room is created. |
closeRoom() | leaves the room, if there are no remaining participants then disposes the room | To be called after the joinRoom() function. |
sendChatMessage(String message) | sends chat message to all other peers via data channels | make sure useDataChannel is set to true while creating the room. |
sendReaction(String reaction) | sends a reaction via data channels. The reaction should be a unicode of the emoji in the String format. | make sure useDataChannel is set to true while creating the room. |
changeCam() | toggles between front and back cameras if available. | -- |
enableCam() | enables camera and related producers. | Preferably used when the camera is already disabled. |
disableCam() | disables camera and related producers. | Preferably used when the camera is already enabled. |
muteMic() | mutes the audio and pauses the related producers. | Preferably used when the mic is already unmuted. |
unmuteMic() | unmutes the audio and resumes the related producers. | Preferably used when the mic is already muted. |
changeDisplayName() | changes the device's display name. | -- |
Introduced Data Types
The Huddle01 Android SDK offers you flexibility to perform state management according to the design pattern that is being used in your app (MVVM, MVI, etc.). However, we also expose certain data types that may definitely come handy while performing state management as these data types are capable of internal state management.
State Data Types
Peers
Maintains info related to all the peers.
Function | Parameters | Return Type |
addPeer |
| void |
removePeer | String peerId | void |
setPeerDisplayName |
| void |
addConsumer |
| void |
removeConsumer |
| void |
addDataConsumer |
| void |
removeDataConsumer |
| void |
getPeer | String peerId | Peer |
getAllPeers | -- | List<Peer> |
clear | -- | void |
Consumers
Maintains info related to all the consumers in the session.
Function | Parameters | Return Type |
addConsumer |
| void |
removeConsumer |
| void |
setConsumerPaused |
| void |
setConsumerResumed |
| void |
clear | -- | void |
Producers
Maintains info related to all the producers in the session.
Function | Parameters | Return Type |
addProducer | HuddleProducer producer | void |
removeProducer | String producerId | void |
setProducerPaused | String producerId | void |
setProducerResumed | String producerId | void |
filter | String kind("audio"/"video") | ProducersWrapper |
clear | -- | void |
DataProducers
Maintains info related to all data producers in the session.
Function | Parameters | Return Type |
addDataProducer | HuddleDataProducer producer | void |
removeDataProducer | String producerId | void |
clear | -- | void |
DataConsumers
Maintains info related to all data consumers in the session.
Function | Parameters | Return Type |
addDataConsumer | HuddleDataConsumer consumer | void |
removeDataConsumer | String consumerId | void |
clear | -- | void |
Other Data Types
Huddle01 Android SDK also exposes some other data types which are used internally as well as exposed to the app.
Peer
Field | Getter | Setter | DataType |
id | String | ||
displayName | String | ||
deviceInfo | DeviceInfo | ||
consumers | Set<String> | ||
dataConsumers | Set<String> |
DeviceInfo
Field | Getter | Setter | DataType |
flag | String | ||
name | String | ||
version | String |
HuddleConsumer
Function | Return Type |
getId() | String |
getRtpParameters() | String |
getKind() | String |
resume() | void |
close() | void |
dispose() | void |
pause() | void |
getTrack() | org.webrtc.MediaStreamTrack |
getPaused() | boolean |
getClosed() | boolean |
HuddleProducer
Function | Return Type |
getId() | String |
getRtpParameters | String |
getKind() | String |
resume() | void |
close() | void |
dispose() | void |
pause() | void |
getTrack() | org.webrtc.MediaStreamTrack |
getPaused() | boolean |
getClosed() | boolean |
HuddleDataConsumer
Function | Return Type |
getId() | String |
getLabel() | String |
getSctpStreamParameters() | String |
getProtocol() | String |
getDataProducerId() | String |
getClosed() | boolean |
close() | void |
dispose() | void |
HuddleDataProducer
Function | Return Type |
getId() | String |
getLabel() | String |
getSctpStreamParameters() | String |
getProtocol() | String |
getClosed() | boolean |
Notify
Function | Return Type |
getId() | String |
getType() | String |
getText() | String |
getTimeout | int |
For any help, reach out to us on Slack. We are available 24*7 at: Huddle01 Community.
Last updated