Utilities
The iOS SDK provides the following methods for managing different aspects of video sessions:
- adjustLayout(): To adjust the video player layout to fit within its parent view.
- makeOutboundCall(): To initiate an outbound call to a PSTN number or a SIP URI while being in a session.
- cancelOutboundCall(): To cancel an ongoing outbound call to a PSTN number or a SIP URI.
- setAudioOnlyMode(): To switch to an audio-only call.
- stopVideoTracksOnApplicationBackground(): To switch the RTC application to the background.
- startVideoTracksOnApplicationForeground(): To switch the RTC application to the foreground.
- postClientLogs(): To share console log with the EnableX technical team for audit.
- clientDiagnostics(): To detect the issues causing the RTC to fail.
- captureScreenShot(): To take a snapshot of a video stream in your application.
- updateConfiguration(): To reconfigure a stream by adding new or updating existing attributes of the stream.
Adjust Layout
You can play the remote streams in the Active Talker list with a custom-defined view by selecting activeviews : view during connect(). You do not need to handle the UI in this case, as the predefined video grid plays all the streams received at the client endpoint. When choosing this option, you can use the adjustLayout() method to adjust the video player layout to fit within its parent view. This method helps when a user rotates the screen or when the view needs to be adjusted to fit correctly.
Class: enxRoom
Method: -(void)adjustLayout
Sample Code
enxRoom.adjustLayout()
Dialing Out to Phone and SIP Endpoint from a Video Room
DIal Out
The EnxRoom.makeOutboundCall()
method initiates an outbound call to a PSTN number or a SIP URI during a session, inviting the called participant to join the session on accepting the call.
Class: EnxRoom
Methods
Method | Description |
---|---|
-(void)makeOutboundCall:(NSString*_Nonnull)number callerId:(NSString*_Nonnull)callerId withDialOptions:(NSDictionary*_Nonnull)dialOptions; | To dial a single phone number. |
-(void)makeOutboundCalls:(NSArray*_Nonnull)numberList callerId:(NSString*_Nonnull)callerId withDialOptions:(NSDictionary*_Nonnull)dialOptions; | To dial multiple phone numbers (a maximum of 5 phone numbers can be dialed). |
Parameters
Parameter | Key | Data Type | Description |
---|---|---|---|
dialout_number |
Not Applicable | String | It can be either a PSTN number or a SIP URI to dial out. |
numberList |
Not Applicable | Strings | Multiple PSTN or SIP URL to dial out |
callerId |
Not Applicable | Numeric | Calling Line Identification Number to be added as the originator of the Call. In the case of PSTN Phone Numbers, this will be validated against your purchased number or opted Shared Number. If the CLI does not match, the Call will fail with an error "CLI mismatch". |
options |
options.name |
Strings | Name of the dialled participant. If the name is omitted, the dialled Phone Number is used as the name |
options.early_media |
Boolean | Default false
| |
options.silent_join |
Boolean | Default true
|
Notes:
options
parameters are available from the iOS SDK version 2.1.3 and aboveearly_media
andsilent_join
may not be used together
Delegate Methods
Delegate Method | Description |
---|---|
-room:didOutBoundCallInitiated: |
Notification to the call initiator when Dial out call is initiated |
-room:didDialStateEvents: |
Notification to the call initiator about the status of the dial-out process as received from Gateway. The JSON Response returns status codes as: initiated, calling, connecting, connected, and terminated. |
Sample Code
[enxRoom makeOutboundCall:"9999999999" callerId:"8888888888" withDialOptions: dialOptions]; // Make a Callwhere var dialOptions = {"name": "John","early_media": false,"silent_join": true};-(void)room:(EnxRoom *)room didOutBoundCallInitiated:(NSArray *)Data{// Acknowledge that Call has been initiated}-(void)room:(EnxRoom *)room didDialStateEvents:(EnxOutBoundCallState)state{// Notifies repeatedly status of Dialout Process}
Error Codes and Exceptions
Code | Description |
---|---|
1141 | Dial out request already in process. |
1142 | CLI doesn't match with the configured phone number. |
5095 | Invalid phone number. |
Cancel Outbound Call
This functionality is available from the iOS SDK version 2.1.3 and above
The EnxRoom.cancelOutboundCall()
method allows you to cancel an ongoing outbound call to a PSTN number or SIP URI thus disconnects the participant from the session on passing the number.
Class: EnxRoom
Method: -(void)cancelOutboundCall:(NSString*_Nonnull)number;
Parameter: number
: String. A PSTN Number or a SIP URI to disconnect from the session.
Delegate Method: -room:didOutBoundCallCancel:
: Notification to the call initiator when the participant gets disconnected.
Sample Code
[enxRoom cancelOutboundCall:"9999999999"]; // Cancel a Call- (void)room:(EnxRoom *_Nullable)room didOutBoundCallCancel:(NSArray *_Nullable)data{// Acknowledge that the Call has been cancelled}
Send DTMF Response
This functionality is available from iOS SDK v2.3.16+ onwards.
The EnxRoom.sendDTMF()
method allows send DTMF response to pass through an IVR if dialed out PSTN Call is connected to IVR. This method can be executed repeatedly to pass single digit or multiple digits in a single call.
An outbound PSTN Call must have been answered first to make use of sendDTMF()
method to pass DTMF digits on the same PSTN channel.
- Method:
(void)sendDTMF:(NSString*_Nonnull)number digits:((NSString*_Nonnull)digits;
- Parameters:
options
:number
: String. It's the samenumber
used withmakeOutboundCall()
method. It can be either a PSTN Number or a SIP URI to dial out. For Phone Number, use country code without 00 or +.digits
: String. Digit(s) to pass on to Voice Service as DTMF digits.
- Delegate Methods:
-room:didOutBoundCallSendDtmf
: Method call success and failure notifications are given with error codes.
Sample Code
[enxRoom sendDTMF:@“919999988888” digits:@"1"];- (void)room:(EnxRoom *_Nullable)room didOutBoundCallSendDtmf:(NSArray *_Nullable)data {// Acknowledge that the DTMF Sending is successful}
Error Codes
Code | Description |
---|---|
1155 | Invalid options/parameters/values. |
1201 | Invalid Dial-State. |
1202 | Outbound Dial Request not found. |
Audio Only Mode for Video Room
The EnxRoom.setAudioOnlyMode()
method allows you to switch to an audio-only call where you can neither receive anybody's video nor publish your video. You can use this method as a toggle to switch between audio-only and audio-video calls. It doesn't affect others' video streams in the room.
Class: EnxRoom
Method: - (void)setAudioOnlyMode:(BOOL)check;
Parameter: AudioOnly
: Boolean. Set it to true to switch to audio-only call.
Set it to false to switch to audio-video call.
Error Codes and Exceptions
Code | Description |
---|---|
5051 | Repeated setAudioOnlyMode() is called when a previous audio-only request is in process. |
5052 | Repeated setAudioOnlyMode() is called when audio-only mode is already active. |
5053 | Repeated setAudioOnlyMode() is called when audio-video mode already active. |
5054 | Repeated setAudioOnlyMode() is called when a previous audio-video request is in process. |
Handle Application Switch from Foreground to Background
The following methods switch the RTC application to the background and vice versa. The methods allow you to configure whether to continue streaming or pause it after the switch.
Moving Application to Background
The method switches the RTC application to the background.
Method: -(void)stopVideoTracksOnApplicationBackground:(BOOL)flag
Parameter: flag
: Boolean. true
- to stop publishing local video stream on moving the application to the background.
Sample Code
// To stop Video Track when application goes to Background[room stopVideoTracksOnApplicationBackground:true];
Moving Application to Foreground
The method switches the RTC application to the foreground.
Method: -(void)startVideoTracksOnApplicationForeground:(BOOL)flag
Parameter: flag
: Boolean. true
- to start publishing local video stream on moving the application to the foreground.
Sample Code
// To resume Video Track when application comes back to Foreground[room startVideoTracksOnApplicationForeground:true];
Share Log with EnableX
The EnxRoom.postClientLogs()
method is used to share Console Log with EnableX tech team for audit. The method sends 200KB of the most recent Console Log to EnableX. To post Console Logs to EnableX, you must first enable Console logging using EnxLogger
.
Class: EnxRoom
Method: - (void)postClientLogs;
Sample Code
// To enable loggingEnxLogger *logger = [EnxLogger sharedInstance];[logger startLog];[room postclientLogs]; // Post log to EnableX
Error Codes and Exceptions
Code | Description |
---|---|
5056 | Log File upload already in process. |
5083 | Unable to upload an empty log file. |
Pre-Call Test
- This functionality is available from the iOS SDK version 1.9.6 and above.
- This functionality is compatible with the iOS version 13 and above.
The EnxRtc.clientDiagnostics()
method method acts as a diagnostic tool to detect any issue causing the RTC to fail. The API runs through predefined test cases related to WebRTC issues and reports asynchronously through an event as it passes through each test. These test cases are organized in "Test Groups" as shown below:
Test Group | Type |
---|---|
Microphone | Audio capture |
Camera | Check resolution 320×240 |
Check resolution 640×480 | |
Check resolution 1280×720 | |
Check supported resolutions | |
Network | UDP enabled with TURN server |
TCP enabled with TURN server | |
IPv6 enabled with TURN server | |
UDP enabled with STUN server | |
TCP enabled with STUN server | |
IPv6 enabled with STUN server | |
Connectivity | Relay connectivity with TURN server |
Reflexive connectivity with TURN server | |
Host connectivity with TURN server | |
Reflexive connectivity with STUN server | |
Host connectivity with STUN server | |
Throughput | Data throughput with TURN server |
Bandwidth | Video bandwidth with TURN server |
Audio bandwidth with TURN Server | |
Signaling | Signaling connectivity with TURN server |
Notes: Test Groups Camera, Microphone, Bandwidth are not available on SDK version 1.9.6.
You can also build a UI using the following API to initiate the tests and generate a diagnostic report:
Class: EnxRtc
Method: -(void)clientDiagnostics:(NSDictionary *_Nonnull)Options;
Parameters:
Parameter | Key | Data Type | Description |
---|---|---|---|
Options |
Options.testNames |
Array | Array of Test Group names. e.g. [ "microphone", "camera", "network", "connectivity", "throughput", "bandwidth", "signalling"] To test only selected Test Groups, add selected Test Group names e.g.,["microphone", "camera"] To test all the Test Groups, use ["all"] |
Options.audioDeviceId |
String | Optional Device ID of input audio device. | |
Options.videoDeviceId |
String | Optional Device ID of input video device. | |
Options.regionId |
Array | Optional Array of region Ids of ICE Servers, e.g. ["IN", "SG", "US", "DE"]. Get Region-ID list from Portal. | |
Options.testDurationDataThroughput |
String | Optional Test duration of data throughput in seconds [Range: 1-30 sec. Default: 2 sec]. | |
Options.testDurationVideoBandwidth |
String | Optional Test duration of video bandwidth in seconds [Range: 1-30 sec. Default: 10 sec]. | |
Options.testDurationAudioBandwidth |
String |
| |
Options.stop |
Boolean | Optional Set it to true to stop the test cases which are already in execution. |
Delegate Methods
Delegate Method | Description |
---|---|
-didClientDiagnosisFailed: |
Notification of diagnosis failure when the API is called with the wrong parameter or a repeated attempt to call the API is made when the previous request is under process. |
-didClientDiagnosisStopped: |
Notification sent when the API execution is stopped explicitly through the method call. |
-didClientDiagnosisFinished: |
Notification sent when the API completes execution of all the test cases. A JSON object with a complete test result of all the test cases is returned. |
-didClientDiagnosisStatus: |
Notification sent with the test result of each test case as the API passes through the execution of each test till the completion or till it is explicitly stopped. A JSON object with test results is returned. |
Sample Request for Diagnostics
var Options = {testNames: ['microphone', 'camera'],audioDeviceId: 'XXX',videoDeviceId: 'XXX',regionId: ['IN'],testDurationDataThroughput: 2,testDurationVideoBandwidth: 30,testDurationAudioBandwidth: 30,stop: false};[Enxrtc clientDiagnostics: Options]; // Execute Test[Enxrtc setDelegate:self];// Test Execution finished-(void)didClientDiagnosisFinished:(NSArray * _Nullable)data;// Handle JSON from data// It contains complete test result. A response example given later// Test Execution has failed-(void)didClientDiagnosisFailed:(NSArray * _Nullable)data;// Handle error message from data.// Response example:/*- Invalid argument.- Diagnosis is already in progress. Few resources are in use and may not be accessible.*/// Test Execution has stopped-(void)didClientDiagnosisStopped:(NSArray * _Nullable)data;// Handle info message from response.message// Response example:/*- Diagnosis stopped.- Diagnosis not running.*/// Intermediate Test Result of each Test Case-(void)didClientDiagnosisStatus:(NSArray * _Nullable)data;// Handle JSON in response.message// It contains complete test result. A response example given later
Sample Response at the beginning of the test: -didClientDiagnosisStatus:
{"test_group": "microphone","test_case": "audio_capture","status": "started","output": ""}
Sample Code - Intermediate response after finishing a test case: -didClientDiagnosisStatus:
{"test_group": "microphone","test_case": "audio_capture","status": "finished","output": {"audio_capture": {"result": "success","execution_time": "241 ms","success": [{"message": "Audio track created using device=Default - Microphone Array (Synaptics Audio)"},{"message": "Active audio input channels: 2"}],"error": [],"warning": [],"info": [{"message": "Channel 0 levels: -38.3 dB (peak), -48.4 dB (RMS)"},{"message": "Channel 1 levels: -38.3 dB (peak), -48.4 dB (RMS)"},{"message": "Stereo microphone detected."}]}}}
Sample Response after completion of all the test cases: -didClientDiagnosisFinished:
{"microphone": {"audio_capture": {"result": "success","execution_time": "241 ms","success": [{"message": "Audio track created using device=Default - Microphone Array (Synaptics Audio)"},{"message": "Active audio input channels: 2"}],"error": [],"warning": []}},"network": {"udp_enabled": {"IN": {"TURN": {"result": "success","execution_time": "241 ms","success": [{"message": "Gathered candidate of Type: relay Protocol: udp Address: 104.211.155.197"}],"error": [],"warning": [],"server": {"region": "IN","url": "turns:ts.enablex.io:443"}}}},"tcp_enabled": {"IN": {"TURN": {"result": "success","execution_time": "241 ms","success": [{"message": "Gathered candidate of Type: relay Protocol: udp Address: 104.211.155.197"}],"error": [],"warning": [],"server": {"region": "IN","url": "turns:ts.enablex.io:443"}}}}}}
Test Result Explanation:
Test Group | Test Case | Server | Result | Message |
---|---|---|---|---|
Microphone | Audio Capture | Not Applicable | Success | Audio track created using device #device#. |
Success | Active audio input channels #channel#. | |||
Failure | Web audio run failure. | |||
Failure | No audio track found in the returned stream. | |||
Failure | No active input channels are detected. | |||
Failure | No active input channels are detected. Microphone is most likely muted or broken. Check if it is muted in the sound settings or physically on the device, then re-run the test. | |||
Failure | Microphone input level is low. Increase the input volume or move closer to the microphone. | |||
Failure | getUserMedia failed with the #error# error. | |||
Camera | check resolution 240 | Not Applicable | Success | Captured the video using the expected resolution. |
Success | Average FPS is above threshold. | |||
Failure | getUserMedia failed with the #error# error. | |||
Failure | No video track is found in the returned stream. | |||
Failure | The video track has ended, and the camera has stopped working. | |||
Failure | Low average sent to FPS. | |||
Failure | Incorrect captured resolution. | |||
Failure | Could not analyze any video frame. | |||
Failure | Camera is delivering lots of black frames. | |||
Failure | Camera is delivering lots of frozen frames. | |||
Camera | check resolution 480 | Not Applicable | Success | Captured the video using expected resolution. |
Success | Average FPS is above threshold. | |||
Failure | getUserMedia failed with #error# error. | |||
Failure | No video track is found in the returned stream. | |||
Failure | Video track has ended and the camera has stopped working. | |||
Failure | Low average sent to FPS. | |||
Failure | Incorrect captured resolution. | |||
Failure | Could not analyze any video frame. | |||
Failure | Camera is delivering lots of black frames. | |||
Failure | Camera is delivering lots of frozen frames. | |||
Camera | check resolution 720 | Not Applicable | Success | Captured the video using the expected resolution. |
Success | Average FPS is above threshold. | |||
Failure | getUserMedia failed with the #error# error. | |||
Failure | No video track is found in the returned stream. | |||
Failure | The video track has ended and the camera has stopped working. | |||
Failure | Low average is sent FPS. | |||
Failure | Incorrect captured resolution. | |||
Failure | Could not analyze any video frame. | |||
Failure | Camera is delivering lots of black frames. | |||
Failure | Camera is delivering lots of frozen frames. | |||
Camera | check supported resolutions | Not Applicable | Success | Success Supported resolution #resolution# |
Failure | No video track is found in the returned stream. | |||
Failure | The video track has ended and the camera has stopped working. | |||
Network | udp enabled | TURN | Success | Supported resolution #resolution#. |
Failure | No video track is found in the returned stream. | |||
Failure | The video track has ended and the camera has stopped working. | |||
Network | udp enabled | STUN | Success | Gathered candidate of Type: relay Protocol: udp Address: #IP#. |
Failure | Failed to gather specified candidates. | |||
Failure | Failed to create peer connection: . | |||
Network | tcp enabled | TURN | Success | Gathered candidate of Type: relay Protocol: udp Address: #IP#. |
Failure | Failed to gather specified candidates | |||
Failure | Failed to create peer connection: . | |||
Network | tcp enabled | STUN | Success | Gathered candidate of Type: relay Protocol: udp Address: #IP#. |
Failure | Failed to gather specified candidates. | |||
Failure | Failed to create peer connection: #error#. | |||
Network | ipv6 enabled | TURN | Success | Gathered candidate of Type: relay Protocol: udp Address: #IP#. |
Failure | Failed to gather IPv6 candidates. The candidates might not be setup/supported on the network. | |||
Failure | Failed to gather IPv6 candidates. The candidates might not be setup/supported on the network. | |||
Network | ipv6 enabled | STUN | Success | Gathered candidate of Type: relay Protocol: udp Address: #IP#. |
Failure | Failed to gather IPv6 candidates. The candidates might not be setup/supported on the network. | |||
Failure | Failed to gather IPv6 candidates. The candidates might not be setup/supported on the network. | |||
Connectivity | relay connectivity | TURN | Success | Data successfully transmitted between peers. |
Failure | Invalid data is transmitted. | |||
Failure | Time out | |||
Connectivity | relay connectivity | STUN | Success | Data successfully transmitted between peers. |
Failure | Invalid data is transmitted. | |||
Failure | Time out | |||
Connectivity | reflexive connectivity | TURN | Success | Data is successfully transmitted between peers. |
Failure | Invalid data is transmitted. | |||
Failure | Time out | |||
Connectivity | reflexive connectivity | STUN | Success | Data is successfully transmitted between peers. |
Failure | Invalid data is transmitted. | |||
Failure | Time out | |||
Connectivity | host connectivity | TURN | Success | Data is successfully transmitted between peers. |
Failure | Invalid data is transmitted. | |||
Failure | Time out | |||
Connectivity | host connectivity | STUN | Success | Data is successfully transmitted between peers. |
Failure | Invalid data is transmitted. | |||
Failure | Time out | |||
Throughput | Data Throughput | TURN | Success | Total transmitted: #n# kilo-bits in #t# seconds. |
Failure | Timed out | |||
Bandwidth | Video Bandwidth | TURN | Success | Video resolution: #Width# x #Height#. |
Failure | Camera failure: #Width# x #Height#. Cannot test bandwidth without a working camera. | |||
Failure | getUserMedia failed with the #error# error. | |||
Failure | The frame rate mean is 0. The bandwidth cannot be tested without a working camera. | |||
Failure | Could not gather statistics. | |||
Failure | Only Firefox and Chrome getStats implementations are supported. | |||
Bandwidth | Audio Bandwidth | TURN | Subject to quality | Average value of audio bandwidth. |
Subject to quality | Packets lost: value. | |||
Subject to quality | RTT Average: value. | |||
Failure | getUserMedia() failed with an error. | |||
Failure | Only Firefox and Chrome getStats() implementations are supported. | |||
Signaling | Signaling Connectivity | Not Applicable | Success | Token are successfully created. |
Failure | Token creation failed due to the : #error# error. | |||
Failure | Room is not joined due to the : #error# error. | |||
Success | Room is successfully joined. |
Take Image Snapshot of Video Stream
The (void) captureScreenShot
method takes a snapshot of a video stream captures and returns it as a framed image.
Delegate Method: -didCapturedView
: Receives an image in a framed view.
Sample Code
//Set delegateEnxPlayerView.delegate = self;//Capture Snapshot[EnxPlayer captureScreenShot];//Snapshot captured.-(void)didCapturedView:(UIImage*_Nonnull)snapShot;// SnapShot is the Image Frame
Update Stream Configuration
This functionality is available in iOS SDK 1.5.6 and later versions.
The EnxStream.updateConfiguration()
method is used to reconfigure a stream by adding new or updating existing attributes of the stream. This API applies to both remote and local streams.
Class: EnxStream
Method: -(void)updateConfiguration:(NSDictionary *_Nonnull) data
Parameter: data
: JSON Object. New stream configuration options in the Dictionary object.
Sample Code
-(void)updateConfiguration:(NSDictionary *_Nonnull) data;// The data Dictionary object may be like the following/*data = {@"maxVideoBW": @"900",@"minVideoBW": @"150",@"maxAudioBW": @"150",@"minAudioBW":@"150"};*/
Error Codes and Exceptions
Code | Description |
---|---|
5113 | Invalid JSON object is passed as a parameter. |
5114 | Unable to update the stream when canvas streaming is on. Non-contextual method call. |