Table of Contents

Handle Active Talkers

To avoid excessive consumption of the server and client resources, EnableX sends a maximum of 12 actively talking users in the Room to the client endpoint. Additionally, it sends Screen Sharing (StreamID# 101) and Canvas Stream (StreamID# 102) if the client application supports these features. The decision on which of the participant’s streams would be played depends upon the Active Talker List. 

After getting connected to the Room, your Client endpoint will also receive onStreamAdded() callback for all the Streams (as per the max_active_talkers configured during Room Creation) available in the Room. You need to subscribe to each of these Streams along with two extra Streams for Screen-Share and Canvas.

After you connect to the room and subscribe to the available Streams, the active-talkers-updated event is triggered, which creates a new entry in the Active Talker List. This list keeps getting updated depending upon the latest talker in the Room. Hence the Active Talker List contains a list of talkers in ascending order at any point in time which means that the latest talker would be moved up in the list. Therefore, you may expect to receive the event too frequently in a noisy room. The list of Active Talkers is available in JSON format and sent through Callback onActiveTalkerList() to each connected endpoint whenever there is a change in the Active Talker List if activeviews : list during joinRoom(). If activeviews: view then onActiveTalkerList() is called only once after joining the Room and subscribing to the Active Talker List.

Apart from the activity level, EnableX also allows pinning of user streams in the Active Talker List regardless of their activity level in the Room. So, the Active Talkers List consists of the inactive pinned users and active talkers in ascending order.  

It must also be noted that the Active Talkers List contains Remote Streams only and hence the Active Talkers List varies for each participant in the Room. 

Observer:

  • setActiveTalkerListObserver – This observer needs to be used when activeviews is set to "list” in the roomInfo parameter in joinRoom() method.
  • setActiveTalkerViewObserver – This observer needs to be used when activeviews is set to "view” in the roomInfo parameter in joinRoom() method.

Playing Active Talker Streams with a Customized View

You can choose to create your custom view for displaying the Remote Streams out of the Active Talker List by selecting activeviews : list during joinRoom(). To play a stream out of the Active Talker List, you need to fetch every Stream’s player (EnxPlayerView) from the list and attach it to your chosen UI.

Class: EnxRooom

Callback: onActiveTalkerList(List enxStreamList) 

Parameter:

enxStreamList – List of Streams received at the endpoint.

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);
     }
}

Playing Active Talker Streams with predefined Recycler View

You can also choose to play the Remote Streams in the Active Talker List with a custom-defined Recycler View by selecting activeviews : view during joinRoom(). In this case, you don’t have to handle the UI as the pre-defined Video Grid plays all the Streams received at the Client endpoint.

When choosing this option, you can use adjustLayout() method to adjust the Video player layout to fit within its parent view. This method helps when the user rotates the screen or when the view needs to be adjusted to fit properly.

Class: EnxRoom

Callback: onActiveTalkerView(RecyclerView recyclerView) 

Parameter:

  • recyclerView – Recycle View

Method: public void adjustLayout() – No Parameter required.

enxRoom.setActiveTalkerViewObserver(this); // Called after getting connected to the Room

@Override

public void onActiveTalkerView(RecyclerView recyclerView) {
	yourRemoteView.addView(recyclerView);
}
room.adjustLayout();

Note: The Local Stream will not be included in the RecycleView even if the endpoint is talking as Local Stream is not present in the Active Talker List.

Get maximum permissible Talker Count

The EnxRoom.getMaxTalkers() method provides the maximum active talkers allowed for the Room as per max_active_talkers configuration during Room Creation. This count could be of interest to the user if they choose to receive less active talkers in the Room. By default, the max_active_talkers is restricted to 12. 

Class: EnxRoom

Method: public void getMaxTalkers() – No Parameter required.

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} 
}

Set Talker Count

The EnxRoom.setTalkerCount() method is used to set the number of active talkers in the Active Talkers List to a particular value not exceeding the maximum permissible talker count. This could either be ingrained at the application level or be implemented as a UI feature where the end-user has the flexibility to control the number of remote streams they want to receive.  This method allows you to control how many Streams you would like to receive. 

Class: EnxRoom

Method: public void setTalkerCount(int numTalkers)

ParametersnumTalkers – The Number of Talker Streams you want to receive. Range limited by max_active_talkers, typically 0-12.

  • If you set numTalkers to any value from 1 to 12, you receive those many talkers in the Active Talker List.
  • If you set numTalkers to 0 (zero), then the list doesn’t become empty, it carries 3 audio streams and no video Streams.

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} 
}

Error Codes / Exceptions

CodeDescription
5055Repeated setTalkerCount () call made while a previous request is in process.

Get Talker Count

The EnxRoom.getTalkerCount() method provides you the number of active talkers to be received through onActiveTalkerList() callback. The method returns the number of currently active streams in the Room restricted either by the maximum permissible talker count or by the set talker count API when invoked by the application or the user through UI.  

Class: EnxRoom

Method: public void getTalkerCount() – No Parameter required.

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 } 
}

Note: The Observer setTalkerObserver() needs to be initiated only once for any one or all of these method calls to receive callbacks.

Switch Active Talker View

Availability: Android SDK 2.1.2+

The EnxRoom.switchATView() method provides the option to switch their talker view from leader/gallery or vice versa. By default, the SDK gives a gallery view layout.

Class: EnxRoom

Method: public void switchATView(String param);

Parametersparam – where param is leader/gallery

Observer:

  • For Leader View – public void setActiveTalkerLeaderObserver(EnxActiveTalkerLeaderObserver enxActiveTalkerLeaderObserver)
  • For Gallery View – public void setActiveTalkerViewObserver(EnxActiveTalkerViewObserver enxActiveTalkerViewObserver)

// Initiate AT Switch Observer to receive Callbacks for Leader View
EnxRoom.setActiveTalkerLeaderObserver(this);  

// Initiate AT Switch Observer to receive Callbacks for Gallery View
EnxRoom.setActiveTalkerViewObserver(this);  


// Initiate leader/gallery view

EnxRoom.switchATView("leader");                                      

public void onActiveTalkerList(RelativeLayout view);            // If the user requests for Leader View

public void onActiveTalkerList(RecyclerView recyclerView);     // If the user requests for Gallery View

PlayerView

Availability: Android SDK 2.1.3+

The PlayerView methods provide option to custom the active talker view. With the help of these methods, you get a particular Player View, and further highlight the selected player border and change the background colour of the Player View.

Switch to Player View

The getPlayer() method provides the option to get a particular Player View.

Class: EnxRoom

Method: public void EnxPlayerView getPlayer(String clientId)

Parameters:

clientId – The user that requires a particular Player View

// Initiate EnxPlayerView
EnxPlayerView playerView = enxRoom.getPlayer(clientID)  

Highlight the EnxPlayer Border

The highlightBorderForClient() method provides the choice to highlight the Player border colour using the custom ActiveTalker View option. You can highlight the player border by passing the list of clientids.

Class: EnxRoom

Method: public void highlightBorderForClient(ArrayList<String> clientIds)

Parameters:

  • @param {Array} clientID - An array of Client Ids to be highlighted.
// Highlight EnxPlayer border
EnxRoom.highlightBorderForClient([clientid1,clientid2.......clientidn]);

Change EnxPlayerView Background Colour

The changeBgColorForClients() method provides the choice to change the background colour for a Player View using the custom ActiveTalker View option. To change the background colour of the Player, you need to pass the clientID of that EnxPlayer.

Class: EnxRoom

Method: public void changeBgColorForClients(ArrayList<String> clientIds,String color)

Parameters:

  • @param {Array} clientID - An array of Client Ids for the background color to be changed.
  • Color – String. Color code of the background color.
// Change EnxPlayer background colour
EnxRoom.ChangeBgColorForClients([clientId1,Clientid2.....clientIdn],”#ff669900”)

Force Reload Active Talker View

The forceUpdateATList() method provides the option to force reload the active talker view after any manipulation in the view as the case may be.

Class: EnxRoom

Method: public void forceUpdateATList;

// Force reload Active Talker view
EnxRoom.forceUpdateATList();