Session Management
The Android SDK provides the following methods for managing video sessions:
- startRecord(): To start recording a session
- stopRecord(): To stop recording a session
- startLiveRecording(): To start live recording of a session.
- stopLiveRecording(): To stop live recording of a session.
- hardMute(): To hard-mute a room.
- hardUnMute(): To put the room off a hard-mute state.
- hardMuteAudio(): To hard-mute a participant's audio.
- hardMuteVideo(): To hard-mute a participant's video.
- hardUnMuteAudio(): To unmute a participant's audio.
- hardUnMuteVideo(): To unmute a participant's video.
- hardMuteUserAudio(): To hard-mute audio streams of a participant.
- hardMuteUserVideo(): To hard-mute video streams of a participant.
- hardUnMuteUserAudio(): To unmute audio streams of a participant.
- hardUnMuteUserVideo(): To unmute video streams of a participant.
- lockRoom(): To lock a room.
- unLockRoom(): To unlock a room.
- approveAwaitedUser(): To approve a user's entry.
- denyAwaitedUser(): To decline a user's entry.
- dropUser(): To disconnect/force-drop one or more participants from a session.
- extendConferenceDuration(): To extend the duration of a session.
- destroy(): To conclude an ongoing session.
- switchUserRole(): To promote a participant to act as a moderator in the ongoing session.
- startStreaming(): To forward live video sessions over RTMP stream.
- stopStreaming(): To stop forwarding RTMP stream.
- pinUsers(): To pin a user to the Active Talker list.
- unpinUsers(): To unpin a user from the Active Talker list.
- addSpotlightUsers(): To spotlight a user.
- removeSpotlightUsers(): To remove the spotlight from users streams.
- switchRoomMode(): To switch the room mode.
Record a Session
You can record an RTC session as individual streams and get it transcoded through a post-session service to create a single composite video file that can be retrieved and replayed using any video player. You can configure the room for auto-recording or invoke APIs to start recording when required. For details on fetching recorded sessions, refer to How to fetch Recordings?
Ways to Record a Session
A session can be recorded in the following ways:
Auto-Recording a Session
You can configure a Room with { settings: { auto_recording: true }}
during Room Creation to automatically start recording the RTC session taking place in the room. The moderator of the room can stop the recording using the stopRecord() method.
On-Demand Recording
Start Recording a Session
The EnxRoom.startRecord()
method allows the moderator to start recording a session. You can use this method to provide options on the UI for the moderator to access them.
There is no limit to the number of times a moderator can start recording.
Class: EnxRoom
Method: public void startRecord()
Observer: public void setRecordingObserver(EnxRecordingObserver-Object)
Callbacks
Callback | Description |
---|---|
setRecordingObserver | Initiates recording observer to receive callbacks. |
onStartRecordingEvent | Notification to the moderator in a room when the recording starts. |
onRoomRecordingOn | Notification to all the participants in a room when the recording starts. |
Sample Code
// Initiate Recording Observer to receive Callbacksroom.setRecordingObserver(this);room.startRecord(); // To start recordingpublic void onStartRecordingEvent(JSONObject jsonobject){// You started recording}public void onRoomRecordingOn(JSONObject jsonobject){// Recording has started - to all}
Error codes and Exceptions
Code | Description |
---|---|
5007 | Unauthorized access. When a participant tries to invoke startRecord(). |
5033 | Repeated startRecord() call when the previous request is in process. |
5034 | Repeated startRecord() call when the recording has already started. |
Stop Recording a Session
The EnxRoom.stopRecord()
method allows the moderator to stop recording of a session. You can use this method to provide options on the UI for the moderator to access them.
There is no limit to the number of times a moderator can stop recording.
Class: EnxRoom
Method: public void startRecord()
Observer: public void setRecordingObserver(EnxRecordingObserver-Object)
Callbacks
Callback | Description |
---|---|
setRecordingObserver | Initiates recording observer to receive callbacks. |
onStopRecordingEvent | Notification to the moderator when the recording stops. |
onRoomRecordingOff | Notification to all the participants in a room when the recording stops. |
Sample Code
// Initiate Recording Observer to receive Callbacksroom.setRecordingObserver(this);room.stopRecord(); // To stop recordingpublic void onStopRecordingEvent(JSONObject jsonobject){// You stopped recording}public void onRoomRecordingOff(JSONObject jsonobject){// Recording has stopped - to all}
Error codes and Exceptions
Code | Description |
---|---|
5008 | Unauthorized access. When a participant tries to invoke stopRecord(). |
5035 | Repeated stopRecord() call when the recording has already stopped. |
5036 | Invoke the stopRecord() call without starting to record. Non-contextual method call. |
Live Recording with UI
Note: This functionality available from the Android SDK v2.1.2 version and later.
Recording live refers to a new process of creating a transcoded file in a live session with a custom layout without recording individual streams. It provides the following advantage:
- You get a transcoded file within minutes post-session without waiting for long like the previous transcoding process.
- Unlike previous transcoding processes created in a predefined layout, you can define your own layout for the live recording process.
Auto Live Recording
You can configure a room to automatically start live recording when the first person joins the room. To do this, add the following settings while creating a room:
"settings": {"live_recording": {"auto_recording: true,"url": "https://your-custom-view-url"}}
For more information, see:
- The room creation payload by using the EnableX Server API.
How to Create a Custom View for Live Recording. It is the same as creating a view for live streaming.
A moderator can stop live recording in a room by using the stopRecord() method.
On-Demand Live Recording
Start Live Recording
The EnxRoom.startLiveRecording()
method allows moderators to start live recording of video sessions.
Class: EnxRoom
Observer: public void setLiveRecordingObserver(EnxLiveRecordingObserver enxLiveRecordingObserver)
Method: public void startLiveRecording(JSONObject jsonObject)
Parameters | Data Type | Description |
---|---|---|
streamingConfig |
JSON Object | Streaming configuration. streamingConfig.urlDetails : To define custom view and its options.
|
Callback: onACKStartLiveRecording
: Acknowledgment callback to the Moderator when the Live Recording starts.
Sample Response
{data ={confNum = 534010000012;isRecordingInitiated = 1;type = RecordingInitiated;};status ={error ={errorCode = 0;errorDesc = "";};resultCode = 0;success = 1;};}
Callbacks
Callback | Description |
---|---|
onRoomLiveRecordingOn | Notification to all the users in the room that the Live Recording has started. |
onRoomLiveRecordingUpdate | Intermediate Notifications to all users about progress of the Live-Recording process. |
onRoomLiveRecordingFailed | Notification to all users if Live Recording failed to start or failed after getting started. |
Sample Code 1
{data = {data = {data = {confNum = 534010000012;isRecordingInitiated = 1;type = RecordingInitiated;};status = {error = {errorCode = 0;errorDesc = "";};resultCode = 0;success = 1;};streamerDetails = {agentId = "d6acdf34-01f3-ca66-2bcc-789363adc043";broadCastStreamerID = "b5296afd-1357-1de1-c89d-5dc0aca3e5ae";};};startedBy = "7f0f2b04-1ad4-4231-8fdc-9f9e014053b4";};type = "liveRecording-started";},
enxRoom.setLiveRecordingObserver(this); //To get Live recording callback, the user needs to set this live recording observerenxRoom.startLiveRecording(jsonObject)// Where streamingConfig/jsonObject ={"urlDetails": {"url": "url","layOut": {},"chatOverlay": true/false}}public void onACKStartLiveRecording( JSONObject jsonobject) {// To the Moderator - Live Recording has started}public void onRoomLiveRecordingOn( JSONObject jsonobject) {// To all the participants - Live Recording started}public void onRoomLiveRecordingUpdate( JSONObject jsonobject) {// To all the participants - Live Recording updates}public void onRoomLiveRecordingFailed( JSONObject jsonobject) {// To all the participants - Live Recording failed}
Error Codes and Exceptions
Code | Description |
---|---|
5086 | The Endpoint application is not connected to the Room |
5097 | Start Live Recording methods are not available in the Chat-Only Room |
5138 | Failed to Start Live Recording with an invalid configuration parameter |
5122 | Start Live Recording is in progress. Retrying to Start Live Recording is illegible |
5139 | Live Recording is already running. Retrying to Start Live Recording is illegible |
Stop Live Recording
The EnxRoom.stopLiveRecording()
method allows moderators to stop live recording of video session.
Class: EnxRoom
Method: public void stopLiveRecording(JSONObject jsonObject)
Note: This method is available only for Android SDK 2.1.2 and later versions.
Method: public void stopLiveRecording()
Note: This method is available only for Android SDK 2.1.3 and later versions.
Parameter | Data Type | Description |
---|---|---|
streamingConfig | JSON Object | Optional Streaming configuration You can pass streaming configuration data as it was passed with startLiveRecording() method. |
Callbacks:
Callback | Description |
---|---|
onACKStopLiveRecording | Acknowledgment callback when the live recording stops. |
onRoomLiveRecordingOff | Notification to all users in the conference that the live recording has stopped. |
Sample Response
{data ={data ={confNum = 534010000012;isRecordingStopped = 1;type = recordingStopped;};isRecordingStarted = 0;status ={error = {errorCode = 0;errorDesc = "";};resultCode = 0;success = 1;};streamerDetails ={agentId = "d6acdf34-01f3-ca66-2bcc-789363adc043";broadCastStreamerID = "b5296afd-1357-1de1-c89d-5dc0aca3e5ae";};};status = {error ={errorCode = 0;errorDesc = "";};resultCode = 0;success = 1;};streamerDetails = {agentId = "d6acdf34-01f3-ca66-2bcc-789363adc043";broadCastStreamerID = "b5296afd-1357-1de1-c89d-5dc0aca3e5ae";};}
Sample Code 1
{data = {data = {data = {data = {confNum = 534010000012;isRecordingStopped = 1;type = recordingStopped;};isRecordingStarted = 0;status = {error = {errorCode = 0;errorDesc = "";};resultCode = 0;success = 1;};streamerDetails = {agentId = "d6acdf34-01f3-ca66-2bcc-789363adc043";broadCastStreamerID = "b5296afd-1357-1de1-c89d-5dc0aca3e5ae";};};status = {error = {errorCode = 0;errorDesc = "";};resultCode = 0;success = 1;};streamerDetails = {agentId = "d6acdf34-01f3-ca66-2bcc-789363adc043";broadCastStreamerID = "b5296afd-1357-1de1-c89d-5dc0aca3e5ae";};};stoppedBy = "7f0f2b04-1ad4-4231-8fdc-9f9e014053b4";};type = "liveRecording-stopped";}
enxRoom.stopLiveRecording(jsonObject)// For v2.1.2 - Where streamingConfig/jsonObject ={"urlDetails": {"url": "url","layOut": {},"chatOverlay": true/false}}enxRoom.stopLiveRecording() // For v2.1.3+public void onACKStopLiveRecording( JSONObject jsonobject) {// To the owner - Live Recording has stopped}public void onRoomLiveRecordingOff ( JSONObject jsonobject) {// To the participants - Live Recording stopped}
Error Codes and Exceptions
Code | Description |
---|---|
5086 | The Endpoint application is not connected to the Room |
5097 | Start Live Recording methods are not available in the Chat-Only Room |
5138 | Failed to Start Live Recording with invalid configuration parameter passed |
5122 | Start Live Recording is in progress. Retrying to Start Live Recording is illegible |
5140 | Live Recording is not running in the room. To Stop Live Recording is illegible |
5141 | Stop Live Recording is in progress. Retrying to Stop Live Recording is illegible |
Error Codes
Live Recording Waiting Queue
Code | Description |
---|---|
7039 | The live recording request was in waiting, successfully removed the request from waiting |
7046 | The streaming request was in waiting, successfully removed the request from waiting |
7080 | Live recording/streaming requests in the waiting queue failed to start |
7081 | Live recording/streaming requests in the waiting queue failed to start |
7104 | The streaming request is in waiting and will start soon |
7105 | The last streaming request is in waiting |
7207 | The live recording request is in waiting and will start soon |
7208 | The last live Recording request is in waiting |
Play a Recorded File
If you want to play a recorded file directly from the EnableX server, note that those files are password protected. EnableX implemented HTTP basic authentication to secure recorded file storage.
Therefore, any video player may not use the file paths only to play them from the EnableX server. The player must provide access credentials to pass through the authentication process to play the file.
Sample Code
Map<String, String> header= new HashMap<String, String>(1);final String cred = "USERNAME" + ":" + "PASSWORD";final String auth = "Basic "+ Base64.encodeToString(cred.getBytes(),Base64.URL_SAFE|Base64.NO_WRAP);header.put("Authorization", auth);videoView.setVideoURI(Uri.parse("VIDEO_URL"),header);videoView.start();
Notes:
- There is an alternate way. You can download the files from EnableX server to your server and play from there without or with any security measures you may like to deploy.
- Files from EnableX storage get deleted after 72 hours. So, accessing them from the EnableX server to play is not guaranteed beyond 72 hours.
Hard Mute or Unmute a Room
Hard Mute a Room
The EnxRoom.hardMute()
method allows moderator to hard-mute a room where all the participants are muted. A new participant joining a room in a hard-mute state is automatically muted. The right to unmute a hard-muted room lies only with the moderator. Participants can neither unmute a room or their local streams.
Class: EnxRoom
Method: public void hardMute()
Observer: public void setMuteRoomObserver(EnxMuteRoomObserver-Object)
Callbacks
Callback | Description |
---|---|
onReceivedMuteRoom | Notification to all the participants in a room when the room is hard-muted. |
onMutedRoom | Notification to the moderator when the room is hard-muted. |
Sample Code
// Initiate Hard-Mute Observer to receive Callbacksroom.setMuteRoomObserver(this);room.hardMute(); // To hard-mute Roompublic void onMutedRoom(JSONObject jsonobject){// You hard-muted Room}public void onReceivedMuteRoom(JSONObject jsonobject){// Room is hard-muted - notification to all paricipants}
Error Codes and Exceptions
Code | Description |
---|---|
5001 | Unauthorized access. A user with the participant role invokes hardMute(). |
5037 | Repeated hardMute()request when the previous request is in process. |
5038 | An invalid hardMute() request when the room is already in a hard-mute state. |
Hard Unmute a Room
The EnxRoom.hardUnMute()
method is used to change the hard-mute state of a room. The right to unmute a hard-muted room lies only with the moderator. Participants can neither unmute a room or their local streams.
Class: EnxRoom
Method: public void hardUnMute()
Observer: public void setMuteRoomObserver(EnxMuteRoomObserver-Object)
Callbacks
Callback | Description |
---|---|
onReceivedUnMuteRoom | Notification to all the participants in a room when the room is hard-unmuted. |
onUnMutedRoom | Notification to the moderator when the room is hard-unmuted. |
Sample Code
room.hardUnMute(); // To hard-unmute Roompublic void onUnMutedRoom(JSONObject jsonobject){// You hard-unuted Room}public void onReceivedUnMuteRoom(JSONObject jsonobject){// Room is hard-unmuted - to all}
Error Codes and Exceptions
Code | Description |
---|---|
5002 | Unauthorized access. A user with the participant role invokes hardUnMute(). |
5039 | An invalid hardUnMuteRoom() request when the room is not in a hard-mute state. |
5040 | Repeated hardUnMuteRoom() request when the previous request is in process. |
Hard Mute or Unmute a Participant
Hard Mute a Participant
Note: Methods below are available for Android SDK version 2.1.3 and fewer.
The EnxStream.hardMuteAudio()
and EnxStream.hardMuteVideo()
methods allow the moderators to hard-mute the audio and video streams of participants. The affected participants cannot unmute their audio and video streams.
Class: EnxStream
Methods:
public void hardMuteAudio(String clientId)
public void hardMuteVideo(String clientId)
Parameter: clientID
: The user whose audio/video needs to be hard muted.
Callbacks
Callback | Description |
---|---|
onHardMutedAudio | Notification to the affected participants when their audio is hard-muted. |
onHardMutedVideo | Notification to the affected participants when their video is hard-muted. |
onReceivedHardMuteAudio | Notification to all the participants in the room when a user's audio is hard-muted. |
onReceivedHardMuteVideo | Notification to all the participants in the room when a user's video is hard-muted. |
Sample Code
stream.hardMuteAudio(clientId); // To hard-mute user's Audio Streampublic void onHardMutedAudio(JSONObject jsonobject){// Your audio is hard-muted}public void onReceivedHardMuteAudio(JSONObject jsonobject){// A User's audio is hardmuted - to all}// Video Hard-Mute will used in the same way as Audio.
Error Codes and Exceptions
Code | Description |
---|---|
5009 | Unauthorized access. A user with the participant role invokes hardMuteAudio(). |
5011 | Unauthorized access. A user with the participant role invokes hardMuteVideo(). |
Note: The following methods are available only for Android SDK 2.1.3 and later versions.
Hard Unmute a Participant
Moderators can unmute a participant's audio or video streams using EnxStream.hardUnMuteAudio()
and EnxStream.hardUnMuteVideo()
methods.
Class: EnxRoom
Methods:
public void hardUnMuteAudio(String clientId)
public void hardUnMuteVideo(String clientId)
Note: These methods are available only for Android SDK 2.1.3 and later versions.
Parameter: clientID
: The user whose audio/video needs to be hard unmuted.
Callbacks
Callback | Description |
---|---|
onHardUnMutedAudio | Notification to the affected participants when their audio is hard-unmuted. |
onHardUnMutedVideo | Notification to the affected participants when their video is hard-unmuted. |
onReceivedHardUnMuteAudio | Notification to all the participants in the room when a user's audio is hard-unmuted. |
onReceivedHardUnMuteVideo | Notification to all the participants in the room when a user's video is hard-unmuted. |
Sample Code
stream.hardUnMuteAudio(clientId); // To hard-unmute user's Audio Streampublic void onHardUnMutedAudio(JSONObject jsonobject){// Your audio is hard-unmuted}public void onReceivedHardUnMuteAudio(JSONObject jsonObject){// A User's audio is hard-unmuted - to all}// Video Hard-Unmute will used in the same way as Audio.
Error Codes and Exceptions
Code | Description |
---|---|
5010 | Unauthorized access. A user with the participant role invokes hardUnMuteAudio(). |
5012 | Unauthorized Access. A user with the participant role invokes hardUnMuteVideo(). |
Room Entry Restriction
Lock a Room
The EnxRoom.lockRoom()
method allows moderators to lock a room, which forbids any new user from joining the session.
Class: EnxRoom
Method: public void lockRoom()
Callbacks
Callback | Description |
---|---|
onAckLockRoom | Acknowledgment to the moderator when the room is locked. |
onLockedRoom | Notification to all the participants in the room when the room is locked. |
Sample Code
room.lockRoom();// Moderator is acknowledged that room has been lockedpublic void onAckLockRoom(JSONObject jsonObject) {// Handle JSONObject}// Participants are notified that room has been lockedpublic void onLockedRoom(JSONObject jsonObject) {// Handle JSONObject}
Error Codes and Exceptions
Code | Description |
---|---|
5115 | Unauthorized access. A user with the participant role invokes lockRoom(). |
5117 | Invalid request. The moderator invokes lockRoom() on a locked room. |
Unlock a Room
Moderators can unlock a room using the EnxRoom.unLockRoom()
method to allow subsequent users to join the session.
Class: EnxRoom
Method: public void unLockRoom()
Callbacks
Callback | Description |
---|---|
onAckUnLockRoom | Acknowledgment to the moderator when the room is unlocked. |
onUnLockedRoom | Notification to all the participants in the room when the room is unlocked. |
Sample Code
room.unLockRoom();// Moderator is acknowledged that room has been unlockedpublic void onAckUnLockRoom(JSONObject jsonObject) {// Handle JSONObject}// Participants are notified that room has been unlockedpublic void onUnLockedRoom(JSONObject jsonObject) {// Handle JSONObject}
Error Codes and Exceptions
Code | Description |
---|---|
5115 | Unauthorized access. A user with the participant role invokes unlockRoom(). |
5118 | Invalid request. When the moderator invokes unlockRoom() on an unlocked room. |
Moderate Participant's Entry to a Session
Approve a User's Entry to Join a Room
In a knock-enabled Room, users must wait until the moderator permits them to join a session. The EnxRoom.approveAwaitedUser()
method allows moderators to approve a user's entry to join a room.
Method: public void approveAwaitedUser(String clientId)
Callbacks
Callback | Description |
---|---|
onUserAwaited | Notification to the moderator when a user awaits permission to join a room. |
onRoomAwaited | Notification to the user when they await moderator's permission to join a room with { "event_type": "knock" } in the JSON payload. |
onAckForApproveAwaitedUser | Acknowledgment to the moderator when the user is granted permission to join a room. |
onRoomConnected | Notification to the user when the user is permitted to join a room. |
Sample Code
// Moderator is notified about awaited userpublic void onUserAwaited(JSONObject jsonObject) {// Awaited Client Info in the jsonObject, e.g.// {"id","String", "name": "String"}enxRoom.approveAwaitedUser(jsonObject.id); // To allow user to join room};public void onAckForApproveAwaitedUser(JSONObject jsonObject) {// User has been allowed entry}
Decline a User's Entry to Join a Room
The EnxRoom.denyAwaitedUser()
method allows moderators to decline a user's entry to join a room.
Class: EnxRoom
Method: public void denyAwaitedUser(String clientId)
Callbacks
Callback | Description |
---|---|
onUserAwaited | Notification to the moderator when a user awaits permission to join a room. |
onRoomAwaited | Notification to the user when they await moderators permission to join a room with { "event_type": "knock" } in the JSON payload. |
onAckForDenyAwaitedUser | Acknowledgment to the moderator when the user denied permission to join a room. |
onRoomDisconnected | Notification to the user along with a reason for denial when the user is denied access to the room. |
Sample Code
// Moderator is notified about awaited userpublic void onUserAwaited(JSONObject jsonObject) {// Awaited Client Info in the jsonObject, e.g.// {"id","String", "name": "String"}enxRoom.denyAwaitedUser(jsonObject.id); // To deny user};public void onAckForDenyAwaitedUser(JSONObject jsonObject) {// User has been denied entry}
Manage Awaited Users When the Moderator Joins Late
If a moderator joins a session after the participants have sent a request to join the session in a knock-enabled room, then the moderator can get a list of participants awaiting moderator's approval using room.awaitedParticipants
. You can utilize this attribute to build the UI for moderator controls to handle pending approvals.
Sample Code
// e.g. room.awaitedParticipants[{ "clientId": "String","name": "String"}]
Disconnect a User
The EnxRoom.dropUser()
method allows moderators to disconnect or force-drop one or more participants from a session.
Class: EnxRoom
Method: public void dropUser(List<String> clientIds)
Parameter: clientIDs
: Required. List of Client IDs to be disconnected.
Callbacks
Callback | Description |
---|---|
onAckDropUser | Acknowledgment to the moderator when the user is disconnected. |
onRoomDisconnected | Notification to the affected users with the reason of disconnection from the room. |
Sample Code
room.dropUser(list);// Moderator is acknowledged that user has been droppedpublic void onAckDropUser(JSONObject jsonObject) {// Handle JSONObject}
Error Codes and Exceptions
Code | Description |
---|---|
5116 | Unauthorized access. A user with the participant role invokes dropUser(). |
Session Extension and Closure
Extend a Session
Each Room is defined with a duration value in minutes. This duration defines the total length of a single session. This time is counted as soon as the first user joins the session. EnableX drops the session when the session duration elapses.
For practical reasons, a session may need to get extend. Therefore, EnableX allows users to extend a session duration at runtime. The extension process is explained below.
- An Extension window opens 10 minutes before the specified closure time of a session. All the connected users are notified of this event.
- Users can trigger an extension of the session by calling a method. Once triggered, the Extension Window is closed, thus preventing subsequent extension requests.
- If the extension is not triggered, the final Extension window opens 5 minutes before the scheduled closure of the session. All the connected users are notified of this event.
- The session can be extended by 10 to 30 minutes. The extended period can vary as there is no restriction on the number of times a session is extended.
- When a session is extended, the previous steps are repeated.
Method: public void extendConferenceDuration()
Callbacks
Callback | Description |
---|---|
onConferenceRemainingDuration | Notification to everyone in the room when an Extension window is open. It carries a JSON to show how many minutes are left before the closure of the scheduled session. |
onConferencessExtended | Notification to everyone when the session is extended. |
Sample Code
//Extend Requestroom.extendConferenceDuration();// Notifies that Session is scheduled to close in N Minutespublic void onConferenceRemainingDuration(JSONObject jsonObject) {// Handle JSONObject}// Notifies that Session is extendedpublic void onConferencessExtended(JSONObject jsonObject) {// Handle JSONObject}
Conclude an Ongoing Session
The EnxRoom.destroy()
method lets moderators to conclude an ongoing session.
Method: public void destroy()
Callbacks
Callback | Description |
---|---|
onAckDestroy | Acknowledgment to the moderator when the session is destroyed. |
onRoomDisconnected | Notification to all users in the room when a session is destroyed. |
Sample Code
room.destroy();// Moderator is acknowledged that session is destroyedpublic void onAckDestroy(JSONObject jsonObject) {// Handle JSONObject}
Error Codes and Exeptions
Code | Description |
---|---|
5116 | Unauthorized access. A user with the participant role invokes destroy(). |
Switch Participant Roles
The EnxRoom.switchUserRole()
method allows moderators to promote a participant to act as a moderator in an ongoing session. The newly appointed moderator is provided access to the moderator controls, and the former moderator becomes a participant in the session. If desired, the new moderator can grant the moderator role to another participant in the session.
Class: EnxRoom
Method: public void switchUserRole(String ClientId)
Parameter: clientId
: Client ID of the participant who is designated as moderator.
Callbacks
Callback | Description |
---|---|
onSwitchedUserRoleChange | Acknowledgment to the moderator when a switch user role is requested. |
onUserRoleChanged | Notification to all the participants in a room when a participant is newly appointed as the moderator. The appointed moderator is notified with extra information required to moderate the session. |
Sample Code
room.switchUserRole(clientId); // Role Change Request from Moderatorpublic void onSwitchedUserRole(JSONObject jsonObject){// Moderator is acknowledged}public void onUserRoleChanged(JSONObject jsonObject){// All Participants are notified - jsonObject/*{ "moderator": false, // You are not a moderator"clientId": "XXX" // New Moderator's Client ID}*/// New Moderator is notified - jsonObject/*{ "moderator": true, // You are a moderator"clientId": "XXX", // New Moderator's Client ID i.e. You"raisedHands":[], // List of Client IDs requesting Floor Access"approvedHands":[] // List of Client IDs with Floor Access}*/}
Error Codes and Exceptions
Code | Description |
---|---|
5085 | Unauthorized access. A user with the participant role invokes switchUserRole(). |
RTMP Live Streaming
Start Forwarding Live Video Session
The EnxRoom.startStreaming()
method allows moderators to forward live video sessions over RTMP stream to any live streaming CDNs supporting this protocol.
Class: EnxRoom
Method: public void startStreaming(JSONObject streamingDetails)
Parameters
Parameter | Data Type | Description |
---|---|---|
streamingDetails |
JSON Object | Configuration options for forwarding streams. rtmpDetails.rtmpUrl : "RTM-URL/RTMP-KEY" from CDN provider. rtmpDetails.urlDetails.urlUse : Optional RTMP streaming view URL. If it is not given then a default streaming view will be applied. |
Callbacks
Callback | Description |
---|---|
onAckStartStreaming | Acknowledgment to the moderator when RTMP streaming starts. |
onStreamingStarted | Notification to all the users in a room when RTMP streaming starts. |
onStreamingFailed | Notification to all the users in a room when RTMP streaming fails to start or fails subsequently after getting started. |
onStreamingUpdated | Intermediate notification to all the users in a room with updates on the RTMP streaming process. |
Sample Code
JSONObject jsonObject = new JSONObject();JSONObject rtmpDetails = new JSONObject();rtmpDetails.put("rtmpUrl", "RTMP_URL/RTMP_KEY"");jsonObject.put("rtmpDetails", rtmpDetails);/* Optional Streaming View URL */JSONObject urlDetails = new JSONObject();urlDetails.put("url", "URL-TO-USE-AS-STREAMING-VIEW");jsonObject.put("urlDetails", urlDetails);room.startStreaming(jsonObject); // Start Streamingpublic void onAckStartStreaming(JSONObject jsonObject){// Acknowledges that Streaming started}public void onStreamingStarted(JSONObject jsonObject) {// Notifies all that Streaming started}public void onStreamingFailed(JSONObject jsonObject) {// Notifies all that Streaming failed}public void onStreamingUpdated(JSONObject jsonObject) {// Notifies all with Streaming process updates}
Error Codes and Exceptions
Code | Description |
---|---|
5121 | Repeated startStreaming() call while the previous request is in process |
5122 | Repeated startStreaming() call after Streaming has started |
5125 | Invalid Stream configuration |
Stop Forwarding Live Video Session
The EnxRoom.stopStreaming()
method stops forwarding RTMP stream.
Class: EnxRoom
Method: public void stopStreaming(JSONObject streamingDetails)
Parameters
Parameter | Data Type | Description |
---|---|---|
streamingDetails |
JSON Object | Configuration options for forwarding streams. rtmpDetails.rtmpUrl : "RTM-URL/RTMP-KEY" from CDN provider. rtmpDetails.urlDetails.urlUse : Optional RTMP streaming view URL. If it is not given then a default streaming view will be applied. |
Callbacks
Callback | Description |
---|---|
onAckStopStreaming | Acknowledgment to the moderator when RTMP streaming stops. |
onStreamingStopped | Notification to all the users in a room when RTMP streaming stops. |
Sample Code
JSONObject jsonObject = new JSONObject();JSONObject rtmpDetails = new JSONObject();rtmpDetails.put("rtmpUrl", "RTMP_URL/RTMP_KEY"");jsonObject.put("rtmpDetails", rtmpDetails);/* Optional Streaming View URL */JSONObject urlDetails = new JSONObject();urlDetails.put("url", "URL-TO-USE-AS-STREAMING-VIEW");jsonObject.put("urlDetails", urlDetails);room.stopStreaming(jsonObject); // Stop Streamingpublic void onAckStopStreaming(JSONObject jsonObject){// Acknowledges that Streaming stopped}public void onStreamingStopped(JSONObject jsonObject) {// Notifies all that Streaming stopped}
Error Codes and Exceptions
Code | Description |
---|---|
5123 | Repeated stopStreaming() call while the previous request is in process |
5124 | stopStreaming() called without starting a Stream first. Non-Contextual Method Call |
HLS Streaming
HLS streaming helps to scale up your reach to a larger audience with your real-time video session, meetings, and webinar. Audiences receive the best quality video streaming based on the available bandwidth at their end. A web-based video UI may be linked to define the view of your streaming which will be played across devices.
In the background, the linked video UI is automatically made to join the video room, and an HLS stream is created using the same view. As the stream is ready, endpoints receive an HLS stream URL from playing in HLS Player.
Service Subscription
HLS streaming infrastructure is owned and managed by EnableX. Therefore, it's a subscription-based service. Connect to the Sales/Account Manager for the subscription.
If you have a look to live stream on YouTube, Vimeo, LinkedIn, and/or Facebook, you need to know RTMP Live Streaming.
HLS View
HLS Streaming experience for audiences may be achieved through the video UI. You can have a video UI or HLS view in either of the following ways:
- Use Default View: The simplest and quickest way is to use the default view for HLS streaming. You don't need to code it; it's available in EnableX. Limited customization option are available.
- Develop Custom View: To have a custom view, a web-based application needs to be developed, hosted over a publicly accessible "https" URL, and linked to the video room. For more information, see how to develop a custom view for your stream.
HLS Enabled Room
Even if the HLS service is subscribed, the following room Level settings is done to have HLS Streaming in video session.
Parameters | Data Type | Description |
---|---|---|
audiences | Numeric | Optional Number of audiences needed in the room cannot be higher than the limit set during the subscription If any of the following settings are being set with the room, audience count must be set to some positive number. |
send_audiences_stats | Boolean | The default is false It can be set to true, if endpoint receives user-connected and user-disconnected event on entry and exit of an audience. |
hls_view_url | String | Optional If a custom view URL is not passed then the default HLS streaming view will be used. You may explicitly pass "DEFAULT" as a value to this key. |
For more information, see
Sample Code: Room Definition JSON Payload to enable HLS Streaming
{"name": "HLS Trial","owner_ref": "XOXO","settings": {"description": "HLS Trial","mode": "group","scheduled": false,"adhoc": false,"duration": 30,"moderators": "1","participants": "2","audiences": 6,"hls_view_url": "https://URL-DOMAIN/PATH/?token=","send_audiences_stats": true,"auto_recording": false,"quality": "SD"}}
Note: If HLS is not subscribed then room definition with HLS-related settings is not permitted.
HLS Audience Token to Join
A new role has been introduced for HLS audience joining a room. They can get a token for an audience role to join a session. HLS streaming gets initiated automatically as soon as the first audience joins the video room. HLS streaming stops when all audiences exit or disconnected from the video room.
For more information, see how to Create Token?.
Sample Code: Create Token JSON Payload for the audience role
{"name": "John","user_ref": "XOXO","role": "audience"}
Room Notifications
HLS Streaming starts as soon as the first audience joins the video room and stops when the last audience exits or disconnects from the room. So, use related HLS callbacks to handle the UI to create the user experience.
Observer: public void setEnxHlsObserver(EnxHlsStreamObserver enxHlsObserver)
: Add this Observer to start receiving HLS notifications.
Callbacks
Callback | Description |
---|---|
onHlsStarted | When HLS streaming starts, it's sent to the publisher and logged-in audiences. Subsequently, it's sent to a new audience on room connection. It carries hls_url to play. |
onHlsStopped | When HLS streaming stops. It's sent to the publisher when the last audience leaves the video room. |
onHlsWaiting | When the HLS streaming initiation process is on and waiting to get started, it is sent to the audiences only. |
onHlsFailed | This event is called when HLS streaming fails. |
Sample Code
//Set ObserverenxRoom.setEnxHlsObserver(this);// On HLS Startpublic void onHlsStarted(JSONObject jsonObject) {// JSON has hls_url key to play in HLS Player}// On HLS Stoppublic void onHlsStopped(JSONObject jsonObject) {}// On HLS Waitingpublic void onHlsWaiting(JSONObject jsonObject) {}// On HLS Failurepublic void onHlsFailed(JSONObject jsonObject) {}
Error Codes
On HLS Start
Code | Description |
---|---|
7501 | Start HLS Streaming input parameters missing, internal server error. |
7502 | Start HLS Streaming timeout, internal server error. |
7503 | Start HLS Streaming request is in process. |
7504 | Start HLS Streaming request timeout, internal server error. |
7505 | HLS Streaming request is in waiting and will be started. |
7506 | HLS Streaming cannot be started now. Try again after 2 minutes. |
7507 | Start HLS Streaming input parameters missing, internal server error. |
7508 | Start HLS Streaming input parameters missing, internal server error. |
On HLS Stop
Code | Description |
---|---|
7520 | The HLS Streaming request was in waiting, successfully removed the request from waiting. |
7521 | Stop HLS Streaming failed, internal server error. |
7522 | Stop HLS Streaming timeout, internal server error. |
On HLS Waiting
Code | Description |
---|---|
7509 | HLS Streaming cannot be started due to an internal server error. Try again after 2 minutes. |
7510 | HLS Streaming start failed, internal server error. Try again after 2 minutes. |
7511 | The last HLS streaming request is in waiting. |
7512 | HLS Streaming cannot be started, internal server error. Try again after 2 minutes. |
7513 | HLS Streaming failed to start, internal server error. |
HLS Generic Error
Code | Description |
---|---|
7000 | Start HLS Streaming input parameters missing, internal server error. |
HLS Player
HLS stream URL received through video SDK needs to be played using HLS Player. The following code explains how to use ExoPlayer to play HLS stream.
Sample Code
<com.google.android.exoplayer2.ui.PlayerViewandroid:id="@+id/exoplayer"android:layout_width="match_parent"android:layout_height="wrap_content"android:minHeight="100dp"app:resize_mode="fixed_width"/>PlayerView ePlayer= findViewById(R.id.exoplayer);String m3u8URL = "https://moctobpltc-i.akamaihd.net/hls/live/571329/eight/playlist.m3u8";// Create a data source factory.DefaultHttpDataSource.Factory dataSourceFactory = new DefaultHttpDataSource.Factory();// Create a HLS media source pointing to a playlist uri.HlsMediaSource hlsMediaSource =new HlsMediaSource.Factory(dataSourceFactory).createMediaSource(MediaItem.fromUri(m3u8URL));// Create a player instance.ExoPlayer player = new ExoPlayer.Builder(context).build();// Set the media item to be played.player.setMediaSource(hlsMediaSource);// Prepare the player.player.prepare();ePlayer.setPlayer(player);
Pin a User
The EnxRoom.pinUsers()
method allows moderators to pin a user to the Active Talker List irrespective of the user's activity level. A pinned user's stream is always published in the room, even if the user is not talking. The inactive pinned users are placed in the Active Talker List after the actively talking users in a descending order based on the activity level, with the most active talkers at the top of the list. The total number of pinned users in a room is restricted to (max_active_talkers
: 1) based on the room configuration.
On joining a Room, the user is notified through a onRoomConnected
event with room meta information, which contains the list of pinned users as "pinnedUsers": [ /*client-ids*/ ]
.
Class: EnxRoom
Method: public void pinUsers(List<String> clientIds)
Parameters: clientIds
: Array of Client IDs of users whose streams need to be pinned.
Callbacks
Callback | Description |
---|---|
onAckPinUsers | Acknowledgment to the moderator when the users are pinned. |
onPinnedUsers | Notification to all the participants in the room with an updated list of pinned users. |
Sample Code
List<String> clientIds = new ArrayList<>();clientIds.add("clientId1");clientIds.add("clientId2");enxRoom.pinUsers(clientIds); // To pin// Moderator is acknowledged for pinning userpublic void onAckPinUsers(JSONObject jsonObject){}// Everyone is notified wtih updated pinned listpublic void onPinnedUsers(JSONObject jsonObject){}
Error Codes and Exceptions
Code | Description |
---|---|
5003 | Unauthorized access. A user with the participant role invokes pinUser(). |
5126 | Invalid client IDs are passed. |
Unpin a User
The EnxRoom.unpinUsers()
method is used to unpin the users.
Class: EnxRoom
Method: public void unpinUsers(List<String> clientIds)
Parameters: clientIds
: Array of Client IDs of users whose streams need to be unpinned.
Callbacks
Callback | Description |
---|---|
onAckUnpinUsers | Acknowledgment to the moderator when the users are unpinned. |
onPinnedUsers | Notification to all the participants in the room with an updated list of pinned users. |
Sample Code
List<String> clientIds = new ArrayList<>();clientIds.add("clientId1");clientIds.add("clientId2");enxRoom.unpinUsers(clientIds); // To unpin// Moderator is acknowledged for unpinning userpublic void onAckUnpinUsers(JSONObject jsonObject){}// Everyone is notified wtih updated pinned listpublic void onPinnedUsers(JSONObject jsonObject){}
Error Codes and Exceptions
Code | Description |
---|---|
5003 | Unauthorized access. A user with the participant role invokes unpinUser(). |
5126 | Invalid client IDs are passed. |
Spotlight a User
The EnxRoom.addSpotlightUsers()
method allows moderators to spotlight a user, pushing the user's stream to the top of the Active Talker List irrespective of the user's activity level. Spotlighting publishes the chosen user's stream in the room even if the user is not talking. The moderator can spotlight as many users as max_active_talkers
defined in the room configuration.
On joining a room, the user is notified through a room-connected
event with Room Meta Information, which contains the list of spotlightUsers
.
In addition, the JSON containing the active talkers list received with the onActiveTalkersUpdated
callback includes a "spotlight" key with a boolean value. Spotlighted users have spotlight: true
in the list.
Class: EnxRoom
Method: public void addSpotlightUsers(List clientIds)
Parameters: clientIds
: An array of Client IDs of users whose streams are spotlighted.
Callbacks
Callback | Description |
---|---|
onAckAddSpotlightUsers | Acknowledgment to the moderator when spotlight request is received with the following JSON { "result": 0, clients: \[\] } result: 0 if success. It returns an appropriate error code if an error is encountered. clients: Array of each Client IDs passed for spotlight. |
onUpdateSpotlightUsers | Notification to everyone in the room when the updated spotlighted user list is received with the following JSON { "moderator_id": String, clients: \[\] }
|
Sample Code
List clientIds = new ArrayList<>();clientIds.add("clientId1");clientIds.add("clientId2");enxRoom.addSpotlightUsers(clientIds); // To spotlight// Moderator who spotlights users is acknowledgedpublic void onAckAddSpotlightUsers (JSONObject jsonObject){// JSON { "result": 0, clients: [] }}// Everyone is notified with updated Spotlight listpublic void onUpdateSpotlightUsers(JSONObject jsonObject){// JSON { "moderator_id": "String", clients: [] }}
Remove the Spotlight from a User
The EnxRoom.removeSpotlightUsers()
method removes the spotlight from user streams.
Class: EnxRoom
Method: public void removeSpotlightUsers(List clientIds)
Parameters: clientIds
: An array of Client IDs of users whose streams are spotlighted.
Callbacks
Callback | Description |
---|---|
onAckRemoveSpotlightUsers | On success, it returns the response information of the requests in the JSON format: { "result": 0, clients: \[\] } result: 0. It returns an appropriate error code if an error encountered. clients: Array of each Client IDs removed from the spotlight. |
onUpdateSpotlightUsers | Notification to everyone in the room when the updated spotlighted user list is received with the following JSON { "moderator_id": String, clients: \[\] }
|
Sample Code
List clientIds = new ArrayList<>();clientIds.add("clientId1");clientIds.add("clientId2");enxRoom.removeSpotlightUsers(clientIds);// To remove from spotlight// Moderator who removes users from Spotlight is acknowledgedpublic void onAckRemoveSpotlightUsers (JSONObject jsonObject){// JSON { "result": 0, clients: [] }}// Everyone is notified with updated Spotlight listpublic void onUpdateSpotlightUsers(JSONObject jsonObject){// JSON { "moderator_id": "String", clients: [] }}
Switch the Room Mode
A room defined with Group or Lecture mode may be switched to the other mode at runtime, that is, in an ongoing session. The EnxRoom.switchRoomMode()
method is executed by the moderator to switch to other modes instantly.
When a room is switched from Group to Lecture mode:
- The audio/video streams of all participants are dropped from the room with a notification to each participant.
- All the features of the Lecture mode, such as floor access control are activated.
- All active breakout rooms are terminated.
On the other hand, when a room is switched from Lecture to Group mode:
- A notification is sent to each participant, allowing them to publish their audio/video streams into the room.
- Due to privacy concerns, the SDK does not automatically start publishing audio/video streams, but application developers must decide whether to automatically publish the streams or prompt the participants to publish.
Class: EnxRoom
Observer: EnxSwitchRoomObserver
Method: public void switchRoomMode(String roomMode)
Parameter: roomMode
: String. Enumerated values lecture, group
The mode to which you want to switch the room into.
Callbacks
Callback | Description |
---|---|
onAckSwitchedRoom | Acknowledgment to the moderator with status of the request. |
onRoomModeSwitched | Notification to everyone in the room when the mode of operation of the room is switched to the desired mode. |
Sample Code
enxRoom.setEnxSwitchRoomObserver(this);enxRoom.switchRoomMode("group"); // To switch to group mode// Moderator is acknowledgedpublic void onAckSwitchedRoom(JSONObject jsonobject){/* JSONObject example:{"result": 1715,"moderator": "String","msg": "Room switched to lecture mode","mode": "lecture"}*/}// Everyone is notifiedpublic void onRoomModeSwitched(JSONObject jsonObject){/* JSONObject example:{"result": 1715,"moderator": "String","msg": "Room switched to lecture mode","mode": "lecture"}*/}
Error Codes and Exceptions
Code | Description |
---|---|
5003 | Unauthorized access. A user with the participant role invokes switchRoomMode(). |
5126 | Invalid room mode. |
5086 | Room is not connected. |
5136 | Non-contextual method call. |
1716 | The room is in Lecture mode. Trying to switch to the Lecture mode while being in the same mode. |
1717 | The room is in Group mode. Trying to switch to the Group mode while being in the same mode. |