Session Management
The iOS 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 a session.
- stopLiveRecording(): To stop live recording s session.
- muteAllUser(): To hard-mute a room where all the participants are muted.
- unMuteAllUser(): 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.
- hardMuteUserAudio(): To hard-mute a participant's audio.
- hardMuteUserVideo(): To hard-mute a participant's video.
- hardUnMuteAudio(): To hard-unmute a participant's audio.
- hardUnMuteVideo(): To hard-unmute a participant's audio.
- hardUnMuteUserAudio(): To hard-unmute a participant's audio.
- hardUnMuteUserVideo(): To hard-unmute a participant's video.
- 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 define the duration of a session.
- destroy(): To conclude an ongoing session.
- switchUserRole(): To promote a participant to act as a moderator in an ongoing session.
- startStreaming(): To forward live video sessions over an RTMP stream.
- stopStreaming(): To stop forwarding an RTMP stream.
- pinUsers(): To pin a user to the Active Talker list.
- unpinUsers(): To unpin a user.
- addSpotlightUsers(): To spotlight a user.
- removeSpotlightUsers(): To remove the spotlight from user's streams.
- switchRoomMode(): To switch the room mode.
Record a Session
You can record an RTC session as an individual stream and get it transcoded through a post-session service to create a single composite video file that can be retrieved and replayed using a video player. You can configure a room for automatic recording or invoke APIs to start recording when required. For more information, see 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.
Start Recording a Session
The EnxRoom.startRecord()
method allows the moderator to start recording the session. You might need to provide this option on UI for the moderator to access it. There is no limit to the number of times a moderator can start recording.
Class: EnxRoom
Method: - (void)startRecord
Delegate Methods
Delegate Method | Description |
---|---|
-startRecordingEvent | Acknowledgment to the moderator when recording starts. |
-roomRecordOn | Notification to all the participants when the recording is turned on. |
Sample Code**
[room startRecord]; // To start recording// To all participants that recording has started-(void)roomRecordOn:(NSArray*)Data{/* Data is[ {"msg":"Room Recording On","result":"0"},"<null>"]*/}// To acknowledge the moderator that recording has started-(void)startRecordingEvent:(NSArray *)response{/* response is[ {"result":0,"msg":"Success"},"<null>"]*/}
Error Codes and Exceptions
Code | Description |
---|---|
5007 | Unauthorized access. A participant has tried to invoke startRecord(). |
5033 | Repeated startRecord() call when the previous request is in process. |
5034 | Repeated startRecord() call when the recording has already started. |
Note: In case of an error,
<null>
is received at the first index, and error info at the second index.
Stop Recording a Session
The EnxRoom.stopRecord()
method is used to stop recording. You might need to provide this option on UI for the moderator to access it. There is no limit to the number of times a moderator can start recording.
Class: EnxRoom
Method: - (void)stopRecord
Delegate Methods
Delegate Method | Description |
---|---|
-stopRecoedingEvent | Acknowledgment to the moderator when session recording stops. |
-roomRecordOff | Notification to all the participants when the recording is turned off. |
Sample Code
[room stopRecord]; // To stop recording// To all participants that recording has stopped-(void)roomRecordOff:(NSArray*)Data{/*Data is[ {"msg":"Room Recording Off","result":"0"},"<null>"]*/}// To acknowledge the moderator that recording has stopped-(void)stopRecordingEvent:(NSArray *)response{/* response is[ {"result":0,"msg":"Success"},"<null>"]*/}
Error Codes and Exceptions
Code | Description |
---|---|
5008 | Unauthorized access. A participant has tried to invoke stopRecord(). |
5035 | Repeated stopRecord() call while the previous request is in process. |
5036 | stopRecord() call without starting to record. Non-Contextual method call. |
Note: In case of an error, <null>
is received at the first index, and error info at the second index.
Live Recording with UI
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 advantages:
- You get a transcoded file within minutes post-session without waiting for long like the previous transcoding process.
- Unlike the previous transcoding processes created in a predefined layout, you can define your own layout for the live recording process.
This functionality is available in iOS SDK 2.1.2 and later versions.
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, go through the Room Creation Payload using our Server API and check How to Create Custom View for Live Recording. It is the same way as a view is created 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 the moderator to start live recording a session.
Class: EnxRoom
Method: -(void)startLiveRecording:(NSDictionary *_Nonnull)streamingConfig;
Parameter: streamingConfig
: JSONObject. Streaming configuration.
Callbacks
Callback | Description |
---|---|
didACKStartLiveRecording | Acknowledgment callback to the moderator when the live recording starts. |
didRoomLiveRecordingOn | Notification to all users in the conference that the live recording has started. |
didRoomLiveRecordingFailed | Notification to the users that recording failed to start or failed later after getting started. |
didRoomLiveRecordingUpdated | Intermediate notifications to all users with updates on the live recording start request. |
Sample Code
[enxRoom startLiveRecording: streamingConfig];-(void)room:(EnxRoom* _Nullable)room didACKStartLiveRecording:(NSArray *_Nullable)data {// To the Moderator - Live Recording has started}-(void)room:(EnxRoom* _Nullable)room didRoomLiveRecordingOn:(NSArray *_Nullable)data {// To all the participants - Live Recording started}-(void)room:(EnxRoom* _Nullable)room didRoomliverecordingFailed:(NSArray*_Nullable)data {// To the executor of Method - Live Recording failed to start}-(void)room:(EnxRoom* _Nullable)room didRoomliverecordingUpdated:(NSArray*_Nullable)data {// To the executor of Method - Intermediate updates on the start recording progress}
Error Codes and Exceptions
Code | Description |
---|---|
5086 | The endpoint application is not connected to the room. |
5097 | The Start Live Recording methods are not available in the Chat-Only room. |
5138 | Failed to start live recording with an invalid configuration parameter. |
5122 | Starting of live recording is in progress. Retrying to start it is illegible. |
5139 | Live recording is already running. Retrying to start it is illegible. |
Stop Live Recording
The EnxRoom.stoptLiveRecording()
method allows the moderator to start live recording the session.
Class: EnxRoom
Method:
-(void)stopLiveRecording:(NSDictionary *_Nonnull)streamingConfig;
This method is available in iOS SDK 2.1.2 and later versions.-(void)stopLiveRecording
: This method is available in iOS SDK 2.1.3 and later versions.
Parameter: streamingConfig
: Optional. Streaming configuration.
Callbacks
Callback | Description |
---|---|
didACKStopLiveRecording | Acknowledgment callback to the moderator when the live recording stops. |
didRoomLiveRecordingOff | Notification to all the participants in the conference that live Recording has stopped. |
Sample Code
[enxRoom stopLiveRecording:streamingConfig]; // For v2.1.2[enxRoom stopLiveRecording]; // For v2.1.3+-(void)room:(EnxRoom* _Nullable)room didACKStopLiveRecording:(NSArray *_Nullable)data {// To the Moderator - Live Recording has stopped}-(void)room:(EnxRoom* _Nullable)room didRoomliverecordingOff:(NSArray*_Nullable)data {// To all the participants - Live Recording stopped}
Error Codes and Exceptions
Code | Description |
---|---|
5086 | The endpoint application is not connected to the room. |
5097 | The Start Live Recording methods are not available in the Chat-Only room. |
5138 | Failed to start live recording with the invalid configuration parameter passed. |
5122 | Start of live recording is in progress. Retrying to start is illegible. |
5140 | Live recording is not running in the room. Stopping it is illegible. |
5141 | Stopping of live recording is in progress. Retrying to stop it is illegible. |
Error Codes
Live Recording Waiting Queue
Code | Description |
---|---|
7039 | The live recording request was in waiting. It is successfully removed from waiting. |
7046 | The streaming request was in waiting. It is successfully removed from waiting. |
7080 | The live recording/streaming request in the waiting queue has failed to start. |
7081 | The live recording/streaming request in the waiting queue has failed to start. |
7104 | The streaming request is in waiting. It will be started soon. |
7105 | The last streaming request is in waiting. |
7207 | The live recording request is in waiting. It will be started soon. |
7208 | The last live Recording request is in waiting. |
Play the Recording Files
The recored files on the EnableX server are password protected. EnableX has implemented HTTP Basic authentication to secure the storage of recorded files. Therefore, a video player must provide access credentials to pass through the authentication process to play the file from the EnableX server.
Sample Code
let headerString = "USERNAME:PASSWORD"let videoFileURL = "URL"let data = headerString.data(using: .utf8)let basicAuth = "Basic" + date!.base64EncodedString(options: NSData.Base64EncodingOptions(rawValue: 0))let headers = {"Authorization" : basicAuth }let asset = AVURLAsset(url: videoFileURL,options: {"AVURLAssetHTTPHeaderFieldsKey" : headers})let playerItem = AVPlayerItem(asset: asset)player = AVPlayer(playerItem: item)
Notes:: As an alternate way, download the files from the EnableX server to your server and play the files with or without any security measures you may like to deploy. Files are deleted after 72 hours of creation from from the EnableX storage. So, playing the files directly from the EnableX server beyond 72 hours is not nguaranteed.
Hard Muting
Hard Mute a Room
The EnxRoom.muteAllUser()
method allows moderators to hard-mute a room where all the participants are muted. A new participant joining a room in a hard-mute state is muted by default. The right to unmute a hard-mute room lies only with the moderator, and participants cannot unmute their local streams either.
Class: EnxRoom
Method: - (void)muteAllUser;
Delegate Methods
Delegate Method | Description |
---|---|
–didHardMutedAll | Notification to all the participants in a room when the room is hard-muted. |
–didMutedAllUser | Acknowledgment to the moderator when a room is hard-muted. |
Sample Code
[room muteAllUser]; // To hard-mute room- (void) didMutedAllUser:(NSArray *Data){// You hard-muted room}- (void)didHardMutedAll:(NSArray *Data){// Room is hard-muted - to all}
Error Codes and Exceptions
Code | Description |
---|---|
5001 | Unauthorized access. A user with the participant role has tried to invoke muteAllUser(). |
5037 | Repeated muteAllUser() request when the previous request is in process. |
5038 | Invalid muteAllUser() request when the room is already in a hard-mute state. |
Hard Unmute a Room
The EnxRoom.unMuteAllUser()
method is used to put the room off the hard-mute state.
Class: EnxRoom
Method: - (void)unMuteAllUser;
Delegate Methods
Delegate Method | Description |
---|---|
–didHardUnMuteAllUser | Notification to all the participants in a room when the room is put off the hard-mute state. |
–didUnMutedAllUser | Acknowledgment to the moderator when the room is put off the hard-mute state. |
Sample Code
[room unMuteAllUser]; // To hard-unmute room- (void) didUnMutedAllUser:(NSArray *Data){// You hard-unuted room}- (void)didHardUnMuteAllUser:(NSArray *Data){// Room is hard-unmuted - to all}
Error Codes and Exceptions
Code | Description |
---|---|
5002 | Unauthorized access. A user with the participant role has tried to invoke unMuteAllUser(). |
5039 | Invalid unMuteAllUser() request when the room is not in a hard-mute state. |
5040 | Repeated unMuteAllUser() request when the previous request is in process. |
Hard Mute a Participant
The EnxStream.hardMuteAudio()
and EnxStream.hardMuteVideo()
methods allow moderators to hard-mute a participant's audio and video streams, respectively. The affected participants cannot unmute their audio or video streams.
Note: For iOS SDK 2.1.3 and later versions, click here for detailed information.
Class: EnxStream
Methods:
- (void)hardMuteAudio:(NSString *)clientId
- (void)hardMuteVideo:(NSString *)clientId
Parameter: clientId
: The participant whose audio/video needs to be hard-muted.
Delegate Methods
Delegate Method | Description |
---|---|
- didReceiveHardMutedAudio | Notification to the affected participants when their audio is hard-muted. |
- didReceiveHardMutedVideo | Notification to the affected participants when their video is hard-muted. |
- didHardMuteAudio | Acknowledgment to the moderator when a participant's audio is hard-muted. |
-didHardMuteVideo | Acknowledgment to the moderator when a participant's video is hard-muted. |
Sample Code
[stream hardMuteAudio:@"clientId"]; // To hard-mute participant's audio-(void)didReceiveHardMutedAudio:(NSArray *)Data{// Your audio is hard-muted}-(void)didHardMuteAudio:(NSArray *)Data{// You hard-muted the user's audio}// Video Hard-Mute will be used in the same way as audio.
Error Codes and Exceptions
Code | Description |
---|---|
5009 | Unauthorized access. A user with the participant role has tried to invoke hardMuteAudio(). |
5011 | Unauthorized access. A user with the participant role has tried to invoke hardMuteVideo(). |
Hard Mute a Participant (v2.1.3)
The EnxRoom.hardMuteUserAudio()
and EnxRoom.hardMuteUserVideo()
methods allows moderators to hard-mute a participant's audio and video streams, respectively. The affected participants cannot unmute their audio or video streams.
Class: EnxRoom
Method:
-(void)hardMuteUserAudio:(NSString*_Nonnull)clientId
-(void)hardMuteUserVideo(NSString*_Nonnull)clientId
These methods are available in iOS SDK 2.1.3 and later versions.
Parameter: clientId
: The participant whose audio/video needs to be hard-muted.
Delegate Methods
Delegate Method | Description |
---|---|
- didReceiveHardMutedAudio | Notification to the affected participants when their audio is hard-muted. |
- didReceiveHardMutedVideo | Notification to the affected participants when their video is hard-muted. |
- didAckHardMuteUserAudio | Acknowledgment to the moderator when a participant's audio is hard-muted. |
-didAckHardMuteUserVideo | Acknowledgment to the moderator when a participant's video is hard-muted. |
Sample Code
[enxRoom hardMuteUserAudio:"clientID"]; // To hard-mute user's audio-(void)didReceiveHardMutedAudio:(NSArray *)Data{// Your audio is hard-muted}-(void)didHardMuteAudio:(NSArray *)Data{// You hard-muted the user's audio}// Video Hard-Mute/Hard-Unmute will be used in the same way as audio.
Hard Unmute a Participant
A moderator can unmute a participant's audio or video streams using EnxStream.hardUnMuteAudio()
and EnxStream.hardUnMuteVideo()
methods respectively.
Note: For iOS SDK 2.1.3 and later, click here for detailed information.
Class: EnxStream
Method:
- (void)hardMuteVideo:(NSString *)clientId
- (void)hardUnMuteVideo:(NSString *)clientId
Parameters: clientId
: The participant whose audio/video needs to be hard-unmuted.
Delegate Methods
Delegate Method | Description |
---|---|
- didReceiveHardUnmutedAudio | Notification to the affected participants when their audio is lifted off the hard-mute state. |
- didReceiveHardUnmutedVideo | Notification to the affected participants when their video is lifted off the hard-mute state. |
- didHardUnMuteAudio | Acknowledgment to the moderator when a participant's audio is lifted off the hard-mute state. |
- didHardUnMuteVideo | Acknowledgment to the moderator when a participant's video is lifted off the hard-mute state. |
Sample Code
[stream hardUnMuteAudio:@"clientId"]; // To hard-unmute participant's audio[stream hardUnMuteAudio:@"clientId"]; //To hard un-mute uparticipantser's audio-(void)didReceivedHardUnmutedAudio:(NSArray *)Data{// Your audio is hard-unmuted}-(void)didHardUnMuteAudio:(NSArray *)Data{// You hard-unmuted user's audio}// Video Hard-Unmute will be used in the same way as audio.
Error Codes and Exceptions
Code | Description |
---|---|
5010 | Unauthorized access. A user with the participant role has tried to invoke hardUnMuteAudio(). |
5012 | Unauthorized access. A user with the participant role has tried to invoke hardUnMuteAudio(). |
Hard Unmute a Participant (v2.1.3)
A moderator can unmute the participant's audio or video streams using EnxRoom.hardUnMuteUserAudio()
and EnxRoom.hardUnMuteUserVideo()
methods respectively.
Class: EnxRoom
Method:
-(void)hardUnmuteUserAudio:(NSString*_Nonnull)clientId
-(void)hardUnmuteUserVideo:(NSString*_Nonnull)clientId
These methods are available in iOS SDK 2.1.3 and later versions.
Parameter: clientId
: The participant whose audio/video needs to be hard-unmuted.
Delegate Methods
Delegate Method | Description |
---|---|
- didReceiveHardUnmutedAudio | Notification to the affected participants when their audio is lifted off the hard-mute state. |
- didReceiveHardUnmutedVideo | Notification to the affected participant when their video is lifted off the hard-mute state. |
- didAckHardunMuteUserAudio | Acknowledgment to the moderator when a participant's audio is lifted off the hard-mute state. |
- didAckHardUnMuteUserVideo | Acknowledgment to the moderator when a participant's video is lifted off the hard-mute state. |
Sample Code
[enxRoom hardUnmuteUserAudio:"clientID"]; //To hard un-mute user's audio-(void)didReceivedHardUnmutedAudio:(NSArray *)Data{// Your audio is hard-unmuted}-(void)didHardUnMuteUserAudio:(NSArray *)Data{// You hard-unmuted user's audio}// Video Hard-Mute/Hard-Unmute will be used in the same way as audio.
Room Entry Restriction
Lock a room
The EnxRoom.lockRoom()
method allows the moderator to lock the room, which forbids new users from joining a session.
Class: EnxRoom
Method: - (void)lockRoom;
Delegate Methods
Delegate Method | Description |
---|---|
-room:didAckLockRoom | Acknowledgment to the moderator when the room is locked. |
-room:didLockroom | Notification to all the participants in a room when the room is locked. |
Sample Code
[room lockRoom];// Moderator is acknowledged that room has been locked- (void)room:(EnxRoom *_Nullable)room didAckLockRoom:(NSArray *_Nullable)data;// Participants are notified that room has been locked- (void)room:(EnxRoom *_Nullable)room didLockRoom:(NSArray *_Nullable)data;
Error Codes and Exceptions
Code | Description |
---|---|
5115 | Unauthorized access. A user with the participant role has tried to invoke lockRoom(). |
5117 | Invalid request. When the moderator invokes lockRoom() for a locked room. |
Unlock a Room
Moderator can unlock a room by using EnxRoom.unlockRoom()
method to allow subsequent users to join the session.
Class: EnxRoom
Method: - (void)unlockRoom;
Delegate Methods
Delegate Method Name | Description |
---|---|
-room:didAckUnlockRoom | Acknowledgment to the moderator when the room is unlocked. |
-room:didUnlockRoom | Notification to all the participants in the room when the room is unlocked. |
Sample Code
[room unlockRoom];// Moderator is acknowledged that room has been unlocked- (void)room:(EnxRoom *_Nullable)room didAckUnlockRoom:(NSArray *_Nullable)data;// Participants are notified that room has been unlocked- (void)room:(EnxRoom *_Nullable)room didUnlockRoom:(NSArray *_Nullable)data;
Code | Description |
---|---|
5115 | Unauthorized access. A user with the participant role has tried to invoke unlockRoom(). |
5118 | Invalid request. When the moderator invokes unlockRoom() on a locked room. |
Moderate Participant's Entry to a session
In a Knock-enabled Room, users need to wait until the moderator of the room grants them permission to join the session.
Approve a User's Entry
The EnxRoom.approveAwaitedUser()
method allows moderators to approve a user's entry to a knock-enabled room.
Method: -approveAwaitedUser:clientID
Parameter: clientID
: Client ID of the user awaiting moderator's approval.
Delegate Methods
Delegate Method | Description |
---|---|
-room:diduserAwaited | Not Applicable |
-room:didRoomAwaited | Not Applicable |
-room:didAckForApproveAwaitedUser | Not Applicable |
-room:didConnect | Not Applicable |
Sample Code
// Moderator is notified about awaited user-(void)room:(EnxRoom *_Nullable)room diduserAwaited:(NSArray *_Nullable)data {// Awaited Client Info in the data, e.g.// [{"id","String", "name": "String"}][room approveAwaitedUser:id]; // To allow};-(void)room:(EnxRoom *_Nullable)room didAckForApproveAwaitedUser:(NSArray *_Nullable)data;{ // User has been allowed entry}
Decline a User's Entry
The EnxRoom.denyAwaitedUser()
method is used to decline a user's entry to a session.
Class: EnxRoom
Method: -denyAwaitedUser: clientID
Parameter: clientId
: Client ID of the user awaiting moderator's approval.
Delegate Methods
Delegate Method | Description |
---|---|
-room:diduserAwaited | Notification to the moderator when a user awaits moderator's permission to join a room. |
-room:didRoomAwaited | Notification to a user when the user awaits moderator's permission to connect to a room with { "event_type": "knock" } in the JSON payload. |
-room:didAckForDenyAwaitedUser | Acknowledgment to the moderator when a user is denied permission to join a room. |
-room:didRoomDisconnect | Notification to a user along with the reason for denial when the user is denied access to a room. |
Sample Code
// Moderator is notified about awaited user-(void)room:(EnxRoom *_Nullable)room diduserAwaited:(NSArray *_Nullable)data {// Awaited Client Info in the data, e.g.// [{"id","String", "name": "String"}][room denyAwaitedUser:id]; // To deny};-(void)room:(EnxRoom *_Nullable)room didAckForDenyAwaitedUser:(NSArray *_Nullable)data {// 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 the room.awaitedParticipants
method. 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/force-drop one or more participants from a session.
Method: -(void)dropUser:(NSArray *_Nonnull)clientIds;
Parameter: clientIds
: Required. Array of Client IDs to be disconnected.
Delegate Methods
Delegate Method | Description |
---|---|
room:didAckDropUser | Acknowledgment to the moderator when the user is disconnected. |
room:didRoomDisconnected | Notification to the affected user with the reason to be disconnected from the room. |
Error Codes and Exceptions
Code | Description |
---|---|
5116 | Unauthorized access. A user with the participant role has tried to invoke dropUser(). |
Session Extension and Closure
Extend a Session
The duration of a room is limited. It is specified in minutes and defined during the room creation. This time is counted as soon as the first user joins the session. The session is dropped when the session duration elapses.
For practical reasons, a session may need to get extended. The EnxRoom.extendConferenceDuration()
allows you to extend the duration of a session beyond the configured value. The extension process is explained below.
1.An Extension window opens 10 minutes before the specified closure time of a session. All the connected users are notified of this event.
2. Users can trigger an extension of the session by calling extendConferenceDuration()
. Once triggered, the Extension Window is closed, thus preventing subsequent extension requests.
3. 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.
4. 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.
5. When a session is extended, the previous steps are repeated.
Method: -(void)extendConferenceDuration
Delegate Methods
Delegate Method | Description |
---|---|
-room:didConferenceRemainingDuration | Called when an Extension Window is open. A JSON shows how many minutes are left to the scheduled session closure. |
-room:didConferencessExtended | Called when the session is extended. |
Sample Code
//Extend Request[enxRoon extendConferenceDuration];// Notifies that session is scheduled to close in N Minutes- (void)room:(EnxRoom *_Nullable)room didConferenceRemainingDuration:(NSArray *_Nullable)data;// Notifies that session is extended- (void)room:(EnxRoom *_Nullable)room didConferencessExtended:(NSArray *_Nullable)data;
Destroy a Session
The EnxRoom.destroy()
method allows moderators to conclude an ongoing session.
Method: -(void)destroy;
Delegate Methods
Delegate Method | Description |
---|---|
-room:didAckDestroy | Acknowledgment to the moderator when the session is destroyed. |
-room:didRoomDisconnected | Notification to all the users in a room when the session is destroyed. |
Sample Code
[room destroy];// Acknowledgement to moderator that the session is destroyed(void)room:(EnxRoom *_Nullable)room didAckDestroy:(NSArray *_Nullable)data;
Error Codes and Exceptions
Code | Description |
---|---|
5116 | Unauthorized access. A user with the participant role has tried to invoke destroy(). |
Switch Participant Roles
The EnxRoom.switchUserRole()
method allows moderators to promote a participant to act as a moderator in the ongoing session. This newly appointed moderator gets access to 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.
Class: EnxRoom
Method: - (void)switchUserRole:(NSString *)clientId;
Parameter: clientId
: String. Client ID of the participant who is designated as the moderator.
Delegate Methods
Delegate Method | Description |
---|---|
-room:didSwitchUserRole | Acknowledgment to a moderator when the moderator is requested to switch a user's role. |
-room:didUserRoleChanged | Notification to the new moderator when the moderator's role is changed from a participant role to the moderator role. |
Sample Code
// Switching user with ClientId to Moderator Role[_remoteRoom switchUserRole:@"clientId"];- (void)room:(EnxRoom *)room didSwitchUserRole:(NSArray *)data {// Moderator is acknowledged}- (void)room:(EnxRoom *)room didUserRoleChanged:(NSArray *)data {// New Moderator is notified that// his role is promoted to Moderator}
Error Codes and Exceptions
Code | Description |
---|---|
5085 | Unauthorized access. A user with the participant role has tried to invoke switchUserRole(). |
RTMP Live Streaming
Forward live Video Sessions
The EnxRoom.startStreaming()
method allows moderators to forward live video sessions over an RTMP stream to any live streaming CDNs supporting this protocol.
Class: EnxRoom
Method: -(void)startStreaming:(NSDictionary *_Nonnull)streamingConfig;
Parameters | Keys | Data Type | Description |
---|---|---|---|
streamingConfig |
rtmpDetails.rtmpUrl |
String | Use "RTM-URL/RTMP-KEY" from CDN Provider |
rtmpDetails.urlDetails.url |
String | Optional. The URL of the RTMP streaming view. If not provided, a default streaming view is applied. |
Delegate Methods
Delegate Method | Description |
---|---|
-room:didAckStartStreaming | Acknowledgment to the moderator when RTMP streaming starts. |
-room:didAckStopStreaming | Acknowledgment to the moderator when RTMP streaming stops. |
-room: didStreamingStarted | Notification to all users that live streaming has started. |
-room: didStreamingStopped | Notification to all users that live streaming has stopped. |
-room: didStreamingUpdated | Intermediate notification to all the users about the live streaming process. |
-room: didStreamingFailed | Notification to all the users that live streaming has failed to start or failed subsequently after getting started. |
Sample Code
//Start Live StreamingNSDictionary *StreamInfo = @{@"rtmpDetails"::@{@"rtmpUrl":@"rtmp://a.rtmp.youtube.com/live2/4rjb-hprf-7wf5-9923"},:@"urlDetails":@{@"url":@"https://meeting-qa.enablex.io/room/?token="}}[EnxRoom startStreaming: StreamInfo];//All are notified that Streaming has started- (void)room:(EnxRoom *_Nullable)room didStreamingStarted:(NSArray *_Nullable)data;//All are notified that Streaming has failed- (void)room:(EnxRoom *_Nullable)room didStreamingFailed:(NSArray *_Nullable)data;//All are notified that Streaming process updates- (void)room:(EnxRoom *_Nullable)room didStreamingUpdated:(NSArray *_Nullable)data;
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 RTMP Stream
The EnxRoom.stopStreaming()
method is used to stop forwarding an RTMP stream.
Class: EnxRoom
Method: -(void)stopStreaming:(NSDictionary *_Nonnull)streamingConfig;
Parameterss | Keys | Data Type | Description |
---|---|---|---|
streamingConfig |
rtmpDetails.rtmpUrl |
String | Use "RTM-URL/RTMP-KEY" from CDN Provider |
rtmpDetails.urlDetails.url |
String | Optional. The URL of RTMP streaming view. If not provided, a default streaming view is applied. |
Delegate Methods
Delegate Method | Description |
---|---|
-room:didAckStartStreaming | Acknowledgment to the moderator when RTMP streaming starts. |
-room:didAckStopStreaming | Acknowledgment to the moderator when RTMP streaming stops. |
-room: didStreamingStarted | Notification to all users that live streaming has started. |
-room: didStreamingStopped | Notification to all users that live streaming has stopped. |
-room: didStreamingUpdated | Intermediate notification to all the users about the live streaming process. |
-room: didStreamingFailed | Notification to all the users that live streaming has failed to start or failed subsequently after getting started. |
Sample Code
// Stop Live Streaming[EnxRoom stopStreaming: StreamInfo];//All are notified that Streaming has stopped- (void)room:(EnxRoom *_Nullable)room didStreamingStopped:(NSArray *_Nullable)data;//All are notified that Streaming process updates- (void)room:(EnxRoom *_Nullable)room didStreamingUpdated:(NSArray *_Nullable)data;
Error Codes and Exceptions
Code | Description |
---|---|
5123 | Repeated stopStreaming() call when the previous request is in process. |
5124 | stopStreaming() is called without starting a stream. Non-contextual method call. |
5125 | Invalid stream configuration. |
HLS Streaming
HLS streaming helps you to reach a large number of audiences with your video session in real-time. It supports adaptive bitrate streaming to get the best quality video based on available network bandwidth at the receiving end.
HLS streaming helps 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 automatically joins the video room and creates an HLS stream using the same view. As the stream is ready, endpoints receive an HLS stream URL from playing in the HLS Player.
HLS Service Subscription
HLS streaming Infrastructure is owned and managed by EnableX. Therefore, it is a subscription-based service. For subscription details, connect to the Sales/Account Manager.
If you look to live stream on YouTube, Vimeo, LinkedIn, and/or Facebook, you need to implement RTMP Live Streaming.
HLS View
HLS streaming experience for audiences can be achieved through the video UI. You can include 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 need not code for it. It is available with EnableX. However, it provides limited customization options.
- Develop Custom View: For a custom view, a web-based application must be developed, hosted over a publicly accessible "https" URL, and linked to the video room. For detailed information, click develop a custom view for your stream.
HLS Enabled Room
Even if the HLS service is subscribed, you must configure the following room-level "settings" to include HLS streaming in a video session.
Parameters | Data Type | Description |
---|---|---|
audiences | Numeric | Optional Number of audience needed in a room. It cannot be more significant than the capping set at the subscription. If any of the following settings are configured with the room, the audience count must be set to some positive number. |
send_audiences_stats | Boolean | By default it is set to false. Set it to true, if the configured endpoints need to receive user-connected and user-disconnected events on entry and exit of an audience. |
hls_view_url | String | Optional A custom view URL. If not passed, the default HLS streaming view is used. However, you may explicitly pass "DEFAULT" as value to this key. |
For more information,
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: Room definition with HLS settings is not permitted if HLS is not subscribed.
Audience Token to Join
A new role named audience
, has been introduced for HLS audience to join a room. This role requires a token to join a session. When the first audience joins a video room, HLS streaming is automatically initiated. It is stopped when all audiences exit or disconnect from the video room. For more information to create a token, see How to create a Token?.
Sample Code: Create Token JSON Payload for audience role.
{"name": "John","user_ref": "XOXO","role": "audience"}
Room Notifications
HLS streaming starts as soon as the first audience joins a video room and stops when the last audience exits/disconnects from the room. So, use the related delegate methods to handle UI and create the user experience.
Observer: public void setEnxHlsObserver(EnxHlsStreamObserver enxHlsObserver)
: Add this observer to start receiving HLS notifications.
Callbacks
Callback | Description |
---|---|
didHlsStarted | When an HLS stream is started, it is sent to the publisher and the audience is logged-in. Subsequently it is sent to the new audience on room connection. It carries hls_url to play. |
didHlsStopped | When an HLS stream stops, it is sent to the publisher when the last audience leaves the video room. |
didHlsWaiting | When an HLS stream initiation process is waiting to get started, it is sent to audiences only. |
-room:didHlsFailed | When an HLS stream fails. |
Sample Code
// On HLS Start- (void)room:(EnxRoom* _Nullable)room didHlsStarted:(NSArray *_Nonnull)data;// data has hls_url key to play in HLS Player// On HLS Stop- (void)room:(EnxRoom* _Nullable)room didHlsStopped:(NSArray *_Nonnull)data;// On HLS Waiting- (void)room:(EnxRoom* _Nullable)room didHlsWaiting:(NSArray *_Nonnull)data;// On HLS Failure- (void)room:(EnxRoom* _Nullable)room didHlsFailed:(NSArray *_Nonnull)data;
Error Codes
On HLS Start
Code | Description |
---|---|
7501 | Start HLS streaming input parameters are 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 has timed-out. Internal server error. |
7505 | The HLS streaming request is in waiting. It will be started. |
7506 | HLS streaming cannot be started now. Try after 2 minutes. |
7507 | Start HLS streaming input parameters are missing. Internal server error. |
7508 | Start HLS streaming input parameters are missing. Internal server error. |
On HLS Stop
Code | Description |
---|---|
7520 | The HLS streaming request was in waiting. It is successfully removed from waiting. |
7521 | Stop HLS streaming has failed. Internal server error. |
7522 | Stop HLS streaming has timed-out. Internal server error. |
On HLS Waiting
Code | Description |
---|---|
7509 | HLS streaming cannot be started. Internal server error. Try after 2 minutes. |
7510 | HLS streaming start has failed. Internal server error. Try after 2 minutes. |
7511 | Last HLS streaming request is in waiting. |
7512 | HLS streaming cannot be started. Try again. Internal server error. |
7513 | HLS streaming failed to start. Internal server error. |
HLS Generic Error
Code | Description |
---|---|
7000 | Start HLS streaming input parameters are missing. Internal server error. |
HLS Player
The HLS stream URL received through the Video SDK needs to be played using an HLS player. Apple provides AVPlayerViewController
to play HLS streams. The following code snippet provides details about using it:
AVPlayerItem *avPlayerItem =[[AVPlayerItem alloc]initWithAsset:avAsset];AVPlayer *player = [AVPlayer playerWithPlayerItem:avPlayerItem];AVPlayerViewController *vc = [[AVPlayerViewController alloc]init];vc.player = player;[self presentViewController:vc animated:true completion:^{[player play];}];
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 their activity level, with the most active talker on top of the list. Based on the Room configuration, the total number of pinned users in a room is restricted to (max_active_talkers – 1).
On joining a room, a user is notified with Room Meta Information through the -room:didConnect:
event. This event provides the list of pinned users as "pinnedUsers": [ /*client-ids*/ ]
.
Method: -(void)pinUsers:(NSArray *_Nonnull)clientIds
Parameter: clientIds
: Array. Array of Client IDs of users whose streams need to be pinned.
Delegate Methods
Delegate Method | Description |
---|---|
-room:didAckPinUsers | Acknowledgment to the moderator when the users are pinned. |
-room:didPinnedUsers | Notification to everyone in a room with an updated list of pinned users. |
Sample Code
[enxRoom pinUsers:[clientID1, clientID2]]; // Pin Users-(void)room:(EnxRoom *_Nullable)channel didAckPinUsers:(NSArray *_Nullable)data{// Acknowledges that Users are pinned}-(void)room:(EnxRoom *_Nullable)channel didPinnedUsers:(NSArray *_Nullable)data{// Notifies with updated pinned user list}
Error Codes and Exceptions
Code | Description |
---|---|
5003 | Unauthorized access. A user with the participant role has tried to invoke pinUser(). |
5126 | Invalid client IDs are passed. |
Unpin a User
The EnxRoom.unpinUsers()
method is used to unpin users.
Method: -(void)unpinUsers:(NSArray *_Nonnull)clientIds
Parameter: clientIds
: Array. Array of Client IDs of users whose streams need to be unpinned.
Delegate Methods
Delegate Method | Description |
---|---|
-room:didAckUnpinUsers | Acknowledgment to the moderator when the users are unpinned. |
-room:didPinnedUsers | Notification to everyone in the room with an updated list of pinned users. |
Sample Code
[enxRoom unpinUsers:[clientID1, clientID2]];// Unpin Users-(void)room:(EnxRoom *_Nullable)channel didAckUnpinUsers:(NSArray *_Nullable)data{// Acknowledges that Users are unpinned}-(void)room:(EnxRoom *_Nullable)channel didPinnedUsers:(NSArray *_Nullable)data{// Notifies with updated pinned user list}
Error Codes and Exceptions
Code | Description |
---|---|
5003 | Unauthorized access. A user with the participant role has tried to invoke unpinUser(). |
5126 | Invalid client IDs are passed. |
Spotlight a User
The EnxRoom.addSpotlightUsers()
method allows the moderator 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, a user is notified with Room Meta Information through the onRoomConnected
event. This event provides the list of spotlightUsers
.
Subsequent active talkers list (JSON) received with the didActiveTalkersUpdated
callback includes a "spotlight" key with a boolean value. This key is set to true for spotlighted users.
Class: EnxRoom
Method: -(void)addSpotlightUsers:(NSArray *_Nonnull)clientIds
Parameter: clientIds
: Array. Array of Client IDs of users whose streams are spotlighted.
Delegate Methods
Delegate Method | Description |
---|---|
-room:didAckAddSpotlightUsers | Acknowledgment to the moderator when a spotlight request is received with the following JSON: { "result": 0, clients: \[\] } :result: 0 for success. clients: Array of Client IDs of users added for spotlight. |
-room:didUpdatedSpotlightUsers | Notification to everyone in a room when the spotlighted user list update is received with the following JSON: { "moderator_id": String, clients: \[\] } :
|
Sample Code
[enxRoom addSpotlightUsers:[clientID1, clientID2]]; // To add Spotlight-(void)room:(EnxRoom *_Nullable)channel didAckAddSpotlightUsers:(NSArray *_Nullable)data {// Moderator who adds users to Spotlight is acknowledged// data { "result": 0, clients: [] }}- (void)room:(EnxRoom *_Nullable)channel didUpdatedSpotlightUsers:(NSArray *_Nullable)data {// Everyone is notified wtih updated Spotlight list// data { "moderator_id": "String", clients: [] }}
Remove the Spotlight from a User
The EnxRoom.removeSpotlightUsers()
method removes the spotlight from user streams.
Class: EnxRoom
Method: -(void)removeSpotlightUsers:(NSArray *_Nonnull)clientIds
Parameter: clientIds
: Array of Client IDs of users whose streams are removed from the spotlight.
Delegate Method
Delegate Method | Description |
---|---|
-room:didAckAddSpotlightUsers | Acknowledgment to the moderator when the spotlight request is received with the following JSON: { "result": 0, clients: \[\] } :result: 0 for success clients: Array of Client IDs of users added for spotlight. |
-room:didAckRemoveSpotlightUsers | Acknowledgment to the moderator when spotlight removal request is received with the following JSON: { "result": 0, clients: \[\] } :result: 0 for success clients: Array of Client IDs of users added for spotlight. |
-room:didUpdatedSpotlightUsers | Notification to everyone in a room when the spotlighted user list update is received with the following JSON: { "moderator_id": String, clients: \[\] } :
|
Sample Code
[enxRoom removeSpotlightUsers:[clientID1, clientID2]]; // To remove from Spotlight-(void)room:(EnxRoom *_Nullable)channel didAckRemoveSpotlightUsers:(NSArray *_Nullable)data {// Moderator who removes users from Spotlight is acknowledged// data { "result": 0, clients: [] }};- (void)room:(EnxRoom *_Nullable)channel didUpdatedSpotlightUsers:(NSArray *_Nullable)data {// Everyone is notified wtih updated Spotlight list// data { "moderator_id": "String", clients: [] }};
Room Mode Switch
A room defined with either group
or lecture
mode may be switched to the other mode at runtime during an ongoing session. The EnxRoom.switchRoomMode()
method is executed by the moderator to switch to another mode instantly.
When a room is switched from group
or lecture
mode:
- The audio/video streams of all the participants are dropped from the room with a notification to each participant.
- All the features of 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 group
or lecture
mode:
- A notification is sent to each participant, allowing the participants to publish their audio/video streams into the room.
- Due to privacy concerns, SDK does not automatically start publishing audio/video streams in such cases, but application developers must decide whether to publish them automatically or to prompt the participants to publish them.
Class: EnxRoom
Method: -(void)switchRoomMode:(NSString *_Nonnull)roomMode
Parameter: roomMode
: String. Enumerated values lecture, group. Use the mode that you want to switch to.
Delegate Methods
Delegate Method | Description |
---|---|
-room:didAckSwitchedRoom | Acknowledgment to the moderator with status of the room mode switch request. |
-room:didRoomModeSwitched | Notification to everyone in a room that the room is switched to the other mode. |
Sample Code
[enxRoom switchRoomMode:@" lecture"]; // To switch to group mode// Moderator is acknowledged- (void)room:(enxRoom *_Nullable)room didAckSwitchedRoom:(NSArray *_Nullable)data {/* data example:{"result": 1715,"moderator": "String","msg": "Room switched to lecture mode","mode": "lecture"}*/}// Everyone is notified-(void)room:(enxRoom *_Nullable)room didRoomModeSwitched:(NSArray *_Nullable)data {/* data 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 has tried to invoke switchRoomMode() . |
5126 | Invalid room mode. |
5086 | The room is not connected. |
5136 | Non-contextual method call. |
1716 | Room is in Lecture mode. Trying to switch to Lecture mode while being in the same mode. |
1717 | Room is in Group mode. Trying to switch to Group mode while being in the same mode. |