Utilities
The Flutter SDK provides the following methods for managing different aspects of video sessions:
- setAudioOnlyMode(): to change to a audio-only call
- stopVideoTracksOnApplicationBackground(): To switch the RTC application to background.
- startVideoTracksOnApplicationForeground(): To switch the RTC application to foreground.
- setScalingType(): To update the scaling type.
- enableProximitySensor(): To manage functions related to Proximity Sensor.
- makeOutboundCall(): To initiate an outbound call to a PSTN number or a SIP URI.
- captureScreenShot(): To take a snapshot of a video stream.
- enableLogs(): To enable or disable logs.
- postClientLogs(): To share logs for auditing.
Audio Only Mode for a Video Room
The EnxRtc.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: EnxRtc
Method: static Future<void> setAudioOnlyMode(bool audioOnly)
Parameter: audioOnly
: Boolean. Set it to true to switch to an audio-only call.
Set it to false to switch to an audio-video call.
Sample Code
EnxRtc.setAudioOnlyMode(true); // Move to Audio Only call
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 EnxRtc.stopVideoTracksOnApplicationBackground()
method switches the RTC application to the background.
Class: EnxRtc
Parameters
Parameter | Data Type | Description |
---|---|---|
videoMuteLocalStream |
Boolean | Set it to false to pause publishing of local video streams. |
videoMuteRemoteStream |
Boolean | Set it to false to pause receiving remote video streams. |
Moving Application to Foreground
The EnxRtc.startVideoTracksOnApplicationForeground()
method switches the RTC application to the foreground.
Class: EnxRtc
Parameters | Data Type | Description |
---|---|---|
restoreVideoLocalStream |
Boolean | Set it to true to resume sending local video streams if they were stopped while switching to the background. |
restoreVideoRemoteStream |
Boolean | Set it to true to resume receiving remote video streams if they were stopped while switching to the background. |
Sample Code
// When application goes to BackgroundEnxRtc.stopVideoTracksOnApplicationBackground(localMuteState, remoteMuteState);// When application comes back to ForegroundEnxRtc.startVideoTracksOnApplicationForeground(remoteUnmuteState,localUnmuteState);
Set Video Scaling Type
The EnxRtc.setScalingType()
method updates the scaling type EnxPlayerWidget
.
Class: EnxRtc
Method: static Future<void>setPlayerScalingType(ScalingType scalingType,int viewId,int uid, bool isLocal)
Parameters
Parameter | Data Type | Description |
---|---|---|
ScalingType | String | Constants: SCALE_ASPECT_BALANCED SCALE_ASPECT_FIT SCALE_ASPECT_FILL |
viewId | String | EnxPlayerWidget Id |
uid | String | EnxPlayerWidget Id |
isLocal | Boolean | Set it to true if the player widget is local. |
Sample Code
EnxRtc.setScalingType(type, viewId, uid, true);
Enable Proximity Sensor
The EnxRtc.enableProximitySensor()
method enables the camera to detect proximity. On most devices, the proximity sensor is implemented as a boolean sensor.
- It returns two values, NEAR or FAR.
- Thresholding is performed on the LUX value, that is, the light Sensor's LUX value is compared with a threshold.
- A LUX value more than the threshold value means the Proximity Sensor returns FAR.
- For any value less than the threshold value, the sensor returns NEAR.
Class: EnxRtc
Method: static Future<void> enableProximitySensor (bool isEnabled)
*Parameter: isEnabled
: Boolean. Set it to true to enable the proximity sensor.
Set it to false to disable the proximity sensor.
Sample Code
EnxRtc.enableProximitySensor(true); // Enable Sensor
Dialing Out To Phone and SIP Endpoint from a Video Room
The EnxRtc.makeOutboundCall()
method initiates an outbound call to a PSTN number or SIP URI while in the session, inviting the called participant to join the session on accepting the call.
Class: EnxRtc
Method: static Future<void> makeOutboundCall(String number)
Parameter: number
: String. Phone number to dial-out.
Event Listeners:
Event Listener | Description |
---|---|
onOutBoundCallInitiated | To get the call initiation status. |
onDialStateEvents | Notification for the status of the dial-out process. Possible status codes are initiated, calling, connecting, connected, terminated, failed, and disconnected. |
Sample Code
EnxRtc.makeOutboundCall ('9896xxxxxx'); // Dial-Out the NumberEnxRtc.onOutBoundCallInitiated= (Map<dynamic, dynamic> map) {// Receives Call State};EnxRtc.onDialStateEvents= (String state) {// Receives Call State};
Error Codes
Error codes for failure conditions to accept a dial-out request:
Code | Description |
---|---|
1141 | The dial-out request is already in progress. |
1142 | CLI does not match with configured phone number. |
Take Image Snapshot of Video Stream
The EnxRtc.captureScreenShot
method captures a snapshot of the video stream. The image from the video stream captures and returns as bitmap image to the callback.
Class: EnxRtc
Method: captureScreenShot(streamId)
Parameters
Parameter | Data Type | Description |
---|---|---|
streamId | String | ID of the stream from which the snapshot is to be taken. |
OnCapturedView | String | Receives base64 encoded string for the captured raw bitmap. |
Sample Code
EnxRtc.captureScreenShot(streamId);EnxRtc.OnCapturedView=(Map<dynamic,dynamic> map){};
Console Logging
The Flutter SDK writes different type of logs to the browser console to help in debugging at development phase. EnableX provides two methods to access and control these log entries.
Enable Log
The EnxRtc.enableLogs()
method enables logging. IO Operations to write logs may be a considerably time-consuming task.
Class: EnxRtc
Method: static Future<void> enableLogs(bool status)
Parameter: status
: Boolean. Set it to true to enable logging.
Set it to false to disable logging.
Sample Code
EnxRtc.enableLogs(true); // To enable loggingEnxRtc.enableLogs(false); // To disable logging
Share Log with EnableX to Audit
The EnxRtc.postClientLogs()
method is used to share console log with EnableX tech team for audit. The method sends 500 log lines of the most recent console log to EnableX. Enable log before sharing the log and request the user's consent before you post a log to EnableX.
Class: EnxRtc
Method: static Future<
void> postClientLogs()`
Sample Code
EnxRtc.postClientLogs(); // To post log to audit