Basic Functions of Android SDK describes the necessary tasks to achieve basic Audio/Video communication between participants connected from their End-Point Applications to an EnableX hosted Room. For more advanced use cases, please refer Advance Features & Moderator Controls.
Table of Contents
- Get list of Audio Devices
- Get selected Audio Device by User
- Initiate a Room
- Connect to Room
- Initiate Local Stream
- Join a Room with Stream
- Disconnect from a Room
- Publish / Unpublish Local Stream
- Subscribe Remote Streams
- Handle Active Talkers
- Handle Disconnection & Reconnections
- Play Stream
- Adjust Layout
- Know Stream Information
- Get Room Information
Get list of Audio Devices
You will need to specify Audio Device ID (Microphone Device ID) or use the default Microphone Device ID of your Mobility Device to initiate a Stream. EnableX provides API support to get a list of Audio Devices (Microphone) available with your Device running the Client End Point application along with their device IDs.
The EnxRoom.getDevices()
method is used to return a List containing all the Microphones available with your Device. You can build UI Element with the List to choose a Microphone to use for Stream.
Class: EnxRoom
Method: public List <String> getDevices()
– No parameter needed
List deviceList = enxRoom.getDevices(); // Returns [SPEAKER_PHONE, WIRED_HEADSET, EARPIECE, BLUETOOTH, NONE ]
Get selected Audio Device by User
EnxRoom.getSelectedDevice()
method is used to get the selected or used Audio Device for the Stream.
Class: EnxRoom
Method: public String getSelectedDevice()
– No parameter needed
String selectedDevice = room.getSelectedDevice();
Initiate a Room
Android SDJ is used by the Client End Point Application to connect to the Virtual Room hosted at EnableX to establish a session. The process starts with initializing a Room Object using the EnxRoom
Class. The Constructor requires two Parameters with EnxRoomObserver
Instance and EnxStreamObserver
Instance. After Object is instantiated, you neet to call EnxRoom.init()
method.
Class: EnxRoom
Method: public void init( Context context )
EnxRoom room = new EnxRoom( EnxRoomObserver-Instance, EnxStreamObserver-Instance ); room.init( activity-class-context );
Connect to Room
After Room’s initialization the Client End Point needs to connect to the EnableX Server to join a session. The EnxRoom.connect()
method is used to connect to the virtual Room hosted by EnableX. Unless an End Point is connected to EnableX, no other communication is possible between the two entities, viz. EnableX Server & Client End Point.
The connect method requires a String Parameter with a Token that the Client End Point received from EnableX platform via their Application Server. When connected, a Bi-Directional Communication Channel will be established between the End Point and EnableX Server over a Web Socket. Both entities communicate with each other using Socket Events. Communication would fail if any network issue disconnects the Web Socket.
Note:
- Client End Point may not get connected to the room due to network problem, invalid or expired Token. If it fails to connect, you will be notified accordingly using callback
onRoomError
. - End Point is notified with callback
onRoomConnected
on successful connection to the room with complete run-time Meta Information of the Room. - Auto-Reconnect doesn’t work on:
- Last Participant disconnected from Adhoc Room
- User is dropped from Room by Moderator
- User disconnects explicitly
Class: EnxRoom
Method: public void connect(String Token, JSONObject RoomInfo, JSONObject advanceOptions)
Parameters:
Token
: Token to connect to the Room, as received from Server API CallRoomInfo
– Optional. JSON Object with Reconnection Options. JSON keys explained below:allow_reconnect
Boolean. Default: true. Whether to enable Auto-Reconnect feature. If you set to false, Client End Point will not try reconnecting to EnableXnumber_of_attempts
Numeric. Min Value: 1. Max Value: Not specified, use any number. Default: 3. Maxi number of times Client End Point tries to reconnect to EnableXtimeout_interval
Numeric. Timeout Interval in Millisecond to wait before attempting reconnectaudio_only
Boolean. Set it to true if you want to join with audio only call.
advanceOptions
– Optional. JSON Object with array of Advanced Options. Each Element of Array hasid
andenable
keys. Following IDs are used:battery_updates
Boolean. Set to true to enable Auto-Battery Updates feature, otherwse set it to falsenotify-video-resolution-change
Boolean. Set to true to enable enable Video Resolution Change Notification feature, otherwise set it to false
Callbacks:
onRoomConnected
– To the end-point when its connected to RoomonRoomError
– To the end-point when it fails to connect to RoomonUserConnected
– To notify all connected users that a new user is connected to RoomonActiveTalkerList
– To the end-point with list of Talkers after few seconds of receivingonRoomConnected
event. Refer how to handle Active Talkers
String token = "XXX": JSONObject roomInfo = { "allow_recnnect": true, "number_of_attempts": 3, "timeout_interval": 10000, "audio_only": true } JSONObject advancedOptions = { [ { "id": " battery_updates", "enable": true, }, { "id": " notify-video-resolution-change", "enable": true, } ] } // Initiates Room EnxRoom room = new EnxRoom(this, this, this); // Connects with Re-Connection & Advance Options room.connect(token, roomInfo, advanceOptions); public void onRoomConnected(EnxRoom room, JSONObject roomMetaData) { // Connected. //Callback received with room object and Room Meta JSON } public void onRoomError(JSONObject roomError) { // Connection failed. Find error } public void onUserConnected(JSONObject userData) { // Notification to all that a new user is connected. // userData json has user information } public void onActiveTalkerList(JSONObject userData) { // List of Current Active Talkers in the Room // Received after onRoomConnected }
Initiate Local Stream
A local stream has to be initialized at the Client End Point before you can publish it to the Room. The initialization process includes specifying media tracks, adding custom attributes etc. in a form of a JSON object.
Class: EnxRoom
Method: public EnxStream getLocalStream( JSONObject publishStreamInfo )
Parameters: publishStreamInfo
– A JSON with Publishing Stream options as given below:
{ "audio": true, // Whether to add Audio to stream "video": true, // Whether to add Video to stream "data": true, // Whether to add Data to stream "videoSize": { // Video Frame Size "minWidth": number, "minHeight": number, "maxWidth": number, "maxHeight": number ), "audioMuted": true, // Audio muted on entry to room "videoMuted": true, // Video muted on entry to room "attributes": { // Object to carry custom data "custom1": "" }, "maxVideoBW": number, // Max Bandwidth "minVideoBW": number // Min Bandwidth }
Initiate Stream with Multiple Video Layers
EnableX provides Auto Bandwidth Detection feature. To help subscribers receive best video quality subject to the available bandwidth at their end, Stream publishers must ensure that their Streams carry multiple video layers of different quality. Client SDK at Subscriber end automatically would switch to the video layer that it can receive to play.
JSONObject streamOpt = { audio: true, video: true, maxVideoLayers: 3 // Carry 3 layers, viz HD 720p, SD 480p & LD 240p/180p }; // Enumerated Values for maxVideoLayers: 1, 2, 3 // 1=HD 720p layer only // 2=HD 720p & SD 480p layers only // 3=HD 720p, SD 480p & LD 240p/180p layers EnxStream localStream = room.getLocalStream(streamOpt);
Join a Room with Stream
Connecting and joining a Room is a complex chain of events. You will need to ensure success status of previous event to proceed to the next event. The following basic steps are required to join room successfully
- Initiate Room & Connect
- If connected, initiate Stream.
- Publish Stream
EnxRtc.joinRoom()
method comes as a handy tool for developer. It handles all complexities of connecting and joining the room.
Class: EnxRtc
Method: public EnxStream joinRoom(String Token, JSONObject publishStreamInfo, JSONObject roomInfo, JSONArray advanceOptions)
Parameters:
Token
– JWT Token received through Server API CallpublishStreamInfo
– Stream Initialization Meta Info. Optional.roomInfo
– Room Informationallow_reconnect
Boolean. Default: true. Re-connection parameter. Whether to enable Auto-Reconnect feature. If you set to false, Client End Point will not try reconnecting to EnableXnumber_of_attempts
Numeric. Min Value: 1. Max Value: Not specified, use any number. Default: 3. Re-connection parameter. Max number of times Client End Point tries to reconnect to EnableXtimeout_interval
Numeric. Re-connection parameter. Timeout Interval in Millisecond to wait before attempting reconnect.activeviews
– Enumerated Values,list
orview
. If you set toview
, you get a predefined view of all videos in a session. If you set tolist
, you get individual streams to create your own view with the video streams.forceTurn
– Boolean. Default: false. If enabled, Video Streams are forced through a TURN Server.chat_only
: Boolean. Default: false. If only text-chat to be enabled disabling audio-video communications.playerConfiguration
– JSON Object with Video Player Configurations.audiomute
– Boolean. Default: true. Show / Hide Audio Mute/Unmute Buttonvideomute
– Boolean. Default: true. Show / Hide Video Mute/Unmute Buttonbandwidth
– Boolean. Default: true. Show / Hide Low Bandwidth Notification Buttonscreenshot
– Boolean. Default: true. Show / Hide Screen Shot Buttonavatar
– Boolean. Default: true. Show / Hide Avatar for No-Video StreamiconColor
– String. Default #FFFFFF. HEX Color Code for Icons.iconHeight
– Number. Default 30. Icon Height in PixeliconWidth
– Number. Default 30. Icon Width in PixelavatarHeight
– Number. Default 200. Avatar Height in PixelavatarWidth
– Number. Default 200. Avatar Width in Pixel
advanceOptions
– Optional. JSON Object with array of Advanced Options. Each Element of Array hasid
andenable
keys. Following IDs are used:battery_updates
Boolean. Set toenable
key to true to enable Auto-Battery Updates feature, otherwise set it to falsenotify-video-resolution-change
Boolean. Setenable
to true to enable Video Resolution Change Notification feature, otherwise set it to false
Returns: EnxStream
– Published Local Stream Object
JSONObject publishStreamInfo = { video: true, audio: true, data: true, attributes: { name: "XX" } }; JSONObject roomInfo = { allow_reconnect: true, number_of_attempts: 3, timeout_interval: 15, activeviews: "view", forceTurn: false, chat_only: false, playerConfiguration: { audiomute: true, videomute: true, bandwidth: true, screenshot: true, avatar: true, iconColor: "#FFFFFF", iconHeight: 30, iconWidth: 30, avatarHeight: 200, avatarWidth: 200 } }; JSONObject advanceOptions = [ { "id": "notify-video-resolution-change", "enable": true }, { "id": "battery_updates", "enable": true } ] String token = "XXX"; EnxRtc enxRtc = new EnxRtc( Current-Class-Context, EnxRoomOberver-Instance, EnxStreamObserver-Instance); EnxStream localStream = enxRtc.joinRoom(token, publishStreamInfo, roomInfo, advanceOptions); public void onRoomConnected(EnxRoom room, JSONObject roomMetaData) { // Connected. //Callback received with room object and Room Meta JSON } public void onRoomError(JSONObject roomError) { // Connection failed. Find error }
Disconnect from a Room
A Client End Point can disconnect itself from the room to close its session. A disconnected End-Point will loose media and signaling socket immediately.
Once disconnected, the SDK will receive callback onRoomDisconnected
for you to handle UI. Also, all connected users of the session will receive callback onUserDisconnected
so that they all can update the status of their UI.
Class: EnxRoom
Method: public void disconnect()
– Without any parameter
Observers:
onRoomDisconnected
– To the user who is disconnectedonUserDisconnected
– To all other connected users
room.disconnect(); public void onRoomDisConnected( JSONObject jsonobject) { // You are disconnected } public void onUserConnected( JSONObject userData ) { // One user is disconnected // User Information of disconnected user }
Publish / Unpublish Local Stream
The local stream with audio/video needs to be started and published to the Room for other participants to see and hear you. Please use the API methods below to publish, unpublish and close local stream.
Publish Local Stream
enxRoom.publish()
method is used to publish a local stream to the connected Room. After the local stream is published to the Room, all participants are notified with an callback named onStreamAdded
.
Class: EnxRoom
Method: public void publish(EnxStream localStream)
Parameters:
localStream
– Initiated Stream Object
Observers:
onPublishedStream
– to the publisher that the stream has been publishedonStreamAdded
– to all participants announcing new stream in room
room.publish(localStream); // To publish initialized Local Stream public void onPublishedStream(EnxStream stream) { // Your stream is published } public void onStreamAdded(EnxStream stream) { // To tell others that a New Stream is added to the Room // You may subscribe to the Stream }
Unpublish Local Stream
Unpublishing a published stream will disconnect the local stream from the Room. The process will not release device access so that subsequent re-publishing will not require the user to grant device access again.
To unpublish, use EnxRoom.unpublish()
method. Please use the callback to handle if stream is unpublished successfully. All users connected to the room will be notified that a Published Stream is unpublished or removed from the Room using the callback named onRemoveStream
Class: EnxRoom
Method: public void unpublish()
– without any parameter
Observers: onRemoveStream -
to all participants that a Stream is taken off the Room.
room.unpublish(); // To unpublish all Local Streams public void onRemoveStream(EnxStream stream) { // To tell others that stream is taken off the Room }
Subscribe Remote Streams
To receive media streams of other participants connected to a Room, you must subscribe to the streams individually. Unless you subscribe a stream, you will not receive anything.
When a new stream is added to the Room a callback onAddedStream()
is received with Stream Object. The receive the stream, you need to subscribe to it using EnxRoom.subscribe()
method.
Class: EnxRoom
Method: public void subscribe(EnxStream remoteStream)
Parameters:
remoteStream
– The Stream Object to subscribe
Observer:
onStreamAdded
– You are notified that a new Stream is added in the Room with Stream Object to subscribe.onSubscribedStream
– You are notified that the Stream has been subscribed.
public void onStreamAdded(EnxStream remoteStream) { // There is a new stream room.subscribe(remoteStream); // Subscribe to it. } public void onSubscribedStream(EnxStream stream) { // You are subscribed }
Note! Please do not subscribe to your local stream. EnableX platform will not return your locat audio/video stream. Details can be found in Active Talkers Section below. However, as a publisher you will receive your own Screen Share and Canvas Streaming.
Handle Active Talkers
During a multi-party video conference, more server and Client-End-Point resources are consumed. Therefore, EnableX sends only 6 streams of users actively talking (generating sound) in the Room to each end-point. Additionally, it sends 2 streams, viz. Screen Share (Stream# 11) and Canvas Stream (Stream# 21).
On getting connected to Room, your Client End Point will also receive onStreamAdded()
Callback for all these 6+2 Streams available in the Room. You need to subscribe to each of these Streams.
Subsequently, whenever there is change in Talkers List, EnableX sends out an updated Active Talkers List to each End Point.
The list of Active-Talkers is available in JSON format and sent along the Observer through Observer onActiveTalkerList()
. The list of Active Talkers comprises list will have talkers in ascending order i.e. latest talker will be listed first. Therefore, you may expect to receive the event too frequently in a noisy room.
EnableX v1.8 introduces pinning of user-streams that forces pinned users also in the Active Talkers List irrespective they are talking or not. So, active talkers appear first in the list and then pinned non-talkers. stream.pinned
returns true if the stream is pinned.
Observer:
setActiveTalkerListObserver
– This observer needs to be used when “activeviews:list
” has been set as a Optional Configuration withjoinRoom()
method.setActiveTalkerViewObserver
– This observer needs to be used when “activeviews:view
” has been set as a Optional Configuration withjoinRoom()
method.
Handling Active Talker with setActiveTalkerListObserver
These Active Talkers Streams are used for playing on the UI. To play a specific stream, you need the EnxPlayerView
from the List.
Class: EnxRooom
Callback: onActiveTalkerList(List enxStreamList)
Parameter: enxStreamList
– List of Streams received at the end point
enxRoom.setActiveTalkerListObserver(this); // Called after getting connected to the Room @Override public void onActiveTalkerList(List<EnxStream> enxStreamList) { for(int i = 0 ; i <=enxStreamList.size();i++) { EnxPlayerView enxPlayerView = enxStreamList.get(i).mEnxPlayerView; yourview.addView(enxPlayerView); } }
Note: The local Stream will not be included in the list of Active Talkers receive at an an End-Point even if the End Point is talking. Hence the Active Talker list sent to different End Points varies. In case you need to play own stream, please use the local stream.
Handling Talkers List with setActiveTalkerViewObserver
The Video Layout is a pre-defined Video Grid playing all Streams received at the End Point
Class: EnxRooom
Callback: onActiveTalkerList(RecyclerView recyclerView)
Parameter: recyclerView
– Recycle View
enxRoom.setActiveTalkerViewObserver(this); // Called after getting connected to the Room @Override public void onActiveTalkerList(RecyclerView recyclerView) { yourRemoteView.addView(recyclerView); }
Note: The local Stream will not be included in the RecycleView
even if the End Point is talking.
Get maximum permissible Talker Count
To know maximum permissible Active Talkers that you may receive and you can set, you may use EnxRoom.getMaxTalkers()
method.
Class: EnxRoom
Method: public void getMaxTalkers()
– without parameter
Observer: public void setTalkerObserver( EnxTalkerObserver-Object )
Callback: onMaxTalkerCount()
// Initiate Talker Observer to receive Callbacks room.setTalkerObserver(this); room.getMaxTalkers(); public void onMaxTalkerCount(JSONObject jsonobject) { // Talker info in response jsonobject: // {"result": 0, "maxTalkers": 4} }
Get Talker Count
It may be necessary to know how many talkers are expected to receive with onActiveTalkerLis()
Observer, i.e. to know either the preset value of talkers or any custom value in effect which is either by the Application Developer or opted by End-Point User.
Class: EnxRoom
Method: public void getTalkerCount()
– without parameter
Observer: public void setTalkerObserver( EnxTalkerObserver-Object )
Callback: onGetTalkerCount()
// Initiate Talker Observer to receive Callbacks room.setTalkerObserver(this); room.getTalkerCount(); public void onGetTalkerCount(JSONObject jsonobject) { // Talker info in response jsonobject // { "result": 0, "numTalkers": 4 } }
Set Talker Count
EnableX sets a maximum of 6 active talkers in the active talker-list with onActiveTalkerList()
Callback. However, you may opt to receive less talkers at a Client End Point if you so require. This may either be a predefined value, or this value may be set at run-time in a connected session. If needed, you can create UI for the connected user to opt for number of active-talkers the user wants to receive.
Class: EnxRoom
Method: public void setTalkerCount(int numTalkers)
Parameters: numTalkers
– No. of talkers you want to receive. Range 0-6
- If you set
numTalkers
to any value from 1 to 6 – you will receive those many talkers in the list. - If you set
numTalkers
to 0 (zero), then list doesn’t become empty. Rather, you would start receiving 3 audio streams only. Video Streams will not be carried.
Observer: public void setTalkerObserver( EnxTalkerObserver-Object )
Callback: onSetTalkerCount()
// Initiate Talker Observer to receive Callbacks room.setTalkerObserver(this); int numTalkers = 5; room.setTalkerCount(numTalkers); public void onSetTalkerCount(JSONObject jsonobject) { // Talker info in response jsonobject: // {"result": 0, "maxTalkers": 4} }
Note: The Observer setTalkerObserver()
needs to be initiated only once for any one or all of these method calls to receive callbacks.
Handle Disconnection & Reconnection
A Client End Point is connected with EnableX over Secured Web Socket. A connected End Point might get disconnected from EnableX due to network issues. The End Point gets notified with an callback onConnectionLost
.
Calbacks:
onConnectionLost
– When End Point looses network connectiononConnectionInterrupted
– When connection is interrupted e.g Switch from WiFi to 4G and vice versa
public void onConnectionLost(JSONObject json){ // Disconnected. Handle UI } public void onConnectionInterrupted(JSONObject json){ // Interrupted. Handle UI }
For disconnected end-points, EnableX supports Auto Re-connection to the Session ensuring better user experience. To use Automatic Re-Connection feature, you must initiate the Connection with Room with Re-Connection options. Note that Auto-Re-Connect doesn’t work when:
- Last Participant disconnected from Adhoc Room
- User is dropped from Room by Moderator
- User disconnects explicitly
Callbacks:
onUserReconnectSuccess
– When End-Point successfully gets reconnected with EnableXonReconnect
– When End-Point trying to reconnect within given time period
JSONObject jsonobject reconnectInfo = { // Re-Connect Options "allow_reconnect": true, "number_of_attempts": 3, "timeout_interval": 10000, "audio_only": false }; room.connect(String token, JSONObject reconnectInfo, JSONObject advOptions) public void onUserReconnectSuccess(EnxRoom room, JSONObject roomMetaData){ // Got reconnected } public void onReconnect(String message){ // Reconnecting }
Play Stream
You can play a local stream, all subscribed remote streams including screen-share, canvas streams within EnxPlayerView
Object. Therefore, you need to create an Object of EnxPlayerView
Class and then attach the Stream to Player View.
In case you want to stop playing stream, detach the Stream from PlayerView.
Class:
EnxPlayerView
– To initiate an Player View Object.EnxStream
– To attach the Stream to Player View
Method:
public void attachRenderer( EnxPlayerView playerView)
– To play streampublic void detachRenderer()
– To stop playing stream. No parameter needed
Parameters:
- playerView – A Player View Object
EnxPlayerView playerView = new EnxPlayerView( Current-Class-Context, ScalingType, mediaOverlay); stream.attachRenderer(playerView); // Attach stream to playerview to play yourCustomView.addView(playerView); // Add playerView to your view stream.detachRenderer(); // Detaching Renderer to stop playing
Adjust Layout
This Method helps to adjust Video Player Layout in case you have received complete Active Talker View using onActiveTalkerList
. In case user rotates Screen, this method will help Video layout to re-adjust to fit within its Parent View.
Method:
-
public void adjustLayout()
– To adjust Video Layout
Note: room.adjustLayout()
method works only if you have passed activeviews:"view"
in the room-info while joining room.
room.adjustLayout();
Know Stream Information
EnableX API provides different methods to access stream information.
Get Stream ID
Every Stream is identified by its Stream ID, be it a local or a remote stream, a canvas stream or a screen share stream. You may obtain the ID of the stream using EnxStream.getId()
method.
Class: EnxStream
Method: public String getID()
Return: StreamId
String streamID = stream.getId();
Get Stream Attributes
Stream attributes are defined as part of stream initialization process in the JSON Payload as custom keys in attributes
. e.g.
var StreamOpt = { "attributes": { "name": "Stream Name", "custom_key": "String", "custom_key2": Number } }
You may use EnxStream.getAttributes()
method to obtain all the current keys and their values in the attributes
object of stream definition,
Class: EnxStream
Method: public JSONObject getAttributes()
– No parameter needed.
Returns: Attributes JSON object of the Stream.
JSONObject attrbutes = stream.getAttributes();
Verify availability of Media Tracks in Stream
EnxStream class has number of methods to verify whether the stream has one or more type of media tracks.. The methods (with no parameters) returning a true/false are listed below:
Class: EnxStream
Methods:
-
public boolean hasAudio()
– To check if Stream has Audio Track -
public boolean hasVideo()
– To check if Stream has Video Track -
public boolean hasData()
– To check if Stream has Data Track -
public boolean hasScreen()
– To check if Stream has Screen Share
if (stream.hasVideo()) { // The Stream has a Video Track in it } // Other methods are also used similar way
Check Audio Video Track Status in Stream
EnxStream class has methods to verify current status of Audio & Video Track in a Stream i.e. to know whether Audio & Video tracks are active or being carried in the Stream. The methods (with no parameters) returning a true/false are listed below:
Class: EnxStream
Methods:
public boolean isAudioActive()
– No parameter. To know if Audio Track is currently active.-
public boolean isVideoActive()
– No parameter. To know if Video Track is currently active.
if (stream.isAudioActive()) { // The Audio track is active in thee Stream } if (stream.isVideoActive()) { // The Video track is active in thee Stream }
Know if Stream is Local or Remote
To know if a stream is a Local Stream or Remote Stream use EnxStram.ifLocal()
method. It returns true for Local Stream, returns false otherwise.
Class: EnxStream
Method: public boolean ifLocal()
– No parameter needed.
if (stream.ifLocal()) { // Its a Local Stream } else { // Its a Remote Stream }
Know current state of Stream
To know current state of Stream, use EnxStream.getState()
method. It returns String Constants (listed below).
Class: EnxStream
Method: public String getState()
– No parameter needed
Returns: It returns one the following String Constants, viz.
- UNKNOWN
- OPENING
- ACTIVE
- CLOSING
- DESTROYED
- LOCAL
- BLOCKED
String CurrneState = stream.getState();
Get Media of Stream
To get media of a stream, use EnxStream.getMedia()
method. It returns Media Stream Object.
Class: EnxStream
Method: public MediaStream getMedia()
MediaStream mStream = stream.getMedia();
Know Room Information
EnableX API provides different methods to access Room Information.
Get Room ID
Every Room is assigned with a Unique Room ID while creating the Room. The Room ID of the room to which you are connected may be known by using EnxRoom.getRoomId()
method.
Class: EnxRoom
Method: public String getRoomId()
– No parameter needed
String roomID = room.getRoomId();
Get Room Meta Information
To know Meta Information of the Room to which you are connected, you may use EnxRoom.getRoomMetaData()
method. Room Meta information contains complete Room Definition along with many Run-Time parameters with their current values & room stats of connected users and streams. This is received by all end-points after getting connected to Room along with onRoomConnected
observer. Some of the run-time parameters are updated internally by the SDK on various events.
Class: EnxRoom
Method: public JSONObject getRoomMetaData()
– No parameter needed
Returns: Room META Information JSON Sample
JSONObject roomMeta = getRoomMetaData();
Get Room Mode
A connected Room may be on group or lecture mode. Use EnxRoom.getMode()
to know mode of Room.
Class: EnxRoom
Method: public String getMode()
Returns: Enumerated Values: group, lecture
String mode = room.getMode();
Get connected User ID or Client ID
Each connected user to the Room is assigned with a Unique Client ID for the session. To know the Client ID of the connected user from the enc-point, use EnxRoom.getClientId()
method.
Class: EnxRoom
Method: public String getClientId()
– No parameter needed
String ClientId = room.getClientId();
Get connected User Name
To know the name of connected user from the end-point, use EnxRoom.getClientName()
method.
Class: EnxRoom
Method: public String getClientName()
– No parameter needed
String ClientName = room.getClientName();
Get connected User Role
A User connected to a Room with either role of moderator or participant. Use EnxRoom.getRole()
to know role of the user
Class: EnxRoom
Method: public String getRole()
– No parameter needed
Returns: Enumerated Values: moderator, participant
String role = room.getRole();
Get connected User Information at an End-Point
To get connected user information at an End-Point, use EnxRoom.whoami()
method. It returns complete user-meta for the connected user in a JSON Object.
Class: EnxRoom
Method: public JSONObject whoami()
– No parameter needed
JSONObject myinfo = room.whoami();
Note: Refer JSON Object structure for User Meta – i.e. for myinfo in above example.
Get connected User List
To get a list of connected users to the Room to which the enc-point is also connected to, use EnxRoom.getUserList()
method. It returns a JSON with list of connected user’s information.
Class: EnxRoom
Method: public JSONObject getUserList()
– No parameter needed
JSONObject Users = room.getUserList() // Return JSON Users /* [ { "clientId": "", // Unique Client ID assigned by EnableX "name": "", // User's name "user_ref": "", // User's Reference "role": "participant", // Enum: moderator, participant "permissions": { // In-Session Permission of User "publish": Boolean, // Whether user can pubish local stream "subscribe": Boolean, // Whether user can subscribe remote streams "record": Boolean, // Whether user can initiate recording "stats": Boolean, // Whether user can view stream status "controlhandlers": Boolean } } ] */
Get Local Stream ID
Every Stream is identified by its Stream ID, be it a local or a remote stream, a canvas stream or a screen share stream. You may obtain the ID of the Local Stream using EnxRoom.getLocalStreamID()
method.
Class: EnxRoom
Method: public String getLocalStreamID()
– No parameter needed
Returns: Stream-ID
String localStreamID = room.getLocalStreamId();
Get Stream by Stream ID
To get Stream Object for given Stream-ID, use method EnxRoom.getStreamByStreamId()
.
Class: EnxRoom
Method: public EnxStream getStreamByStreamId( String Stream-Id)
EnxStream stream = room.getStreamByStreamId( StreamID );
Get list of Remote Streams
To get all the Remote Streams available in the Room, use EnxRoom.getRemoteStreams()
method.
Class: EnxRoom
Method: public Map < String, EnxStream > getRemoteStreams()
– No parameter needed
Map <String, EnxStream> remoteStreams = room.getRemoteStreams();
Get Publish Status of Local Stream
To check if the local stream is currently being published into the connected Room, use EnxRoom.isPublishing()
method. It returns true if currently being published, otherwise returns false.
Class: EnxRoom
Method: public boolean isPublishing() – No parameter needed
if (room.isPublishing()) { // Local Stream is being publishing } else { // Local Stream is not published }
Explore Android SDK