Advance Features Flutter SDK covers API capabilities to build feature-rich End-Point Applications. as Moderator Controls.

Table of Contents

Switch Source Media Devices of Published Stream

A user may want to switch to alternate Media Devices for his published stream. EnableX API allows Media Device switching on the fly.

The APIs allows you to switch between Rear and Front Camera and to alternate available Microphone.

Method: static Future<void> switchMediaDevice(String deviceName)

Parameters:

  • @param Sting deviceName – deviceName client end point needs to set

Event Listeners:

  • onNotifyDeviceUpdate– This callback method notify on media device change.
EnxRtc.switchMediaDevice(‘deviceName’); // Switch to new Device

// Listen when Device has been switched
EnxRtc.onNotifyDeviceUpdate = (String deviceName) {
};

Switch between Rear & Front Camera

If user looks to switch between Rear and Front Camera as a source for published Stream, use switchCamera() method.

Method: static Future<void> switchCamera()

EnxRtc.switchCamera();

Update Stream Configuration

If you like to re-configure your stream by adding new or udpating existing specification parameters of a stream. Please use EnxStream.updateConfiguration() method to update the parameters of a stream. Both remote and local streams can use this method of updating the stream parameters.

Methodstatic Future<void>updateConfiguration(Map<String, dynamic> config)

Parametersconfig– Map containing new configuration options

Map<String, dynamic> mapConfig  = {           
	'maxVideoBW': 150, 
	'minVideoBW': 150,
	'maxAudioBW': 150, 
	'minAudioBW': 150
};

EnxRtc.updateConfiguration(mapConfig);

Mute / Unmute Audio in a Stream

Use await EnxRtc.muteSelfAudio() method to mute and unmute audio from Local Stream. When a user mutes or unmutes audio from own Published Stream, Self user notified with event onAudioEvent and all other connected users of the room are notified with event listeners onRemoteStreamAudioMute and onRemoteStreamAudioUnMute callbacks respectively. Listen to these events to update related UI elements.

Methods: static Future<void> muteSelfAudio(bool isMute) – Pass true to mute, false to unmute audio

Parameters: @param {Boolean} audio –  Pass true to mute, false to unmute audio

Event Listeners:

  • onRemoteStreamAudioMute– to all participants notifying user has muted audio
  • onRemoteStreamAudioUnMute – to all participants notifying user has unmuted audio
  • onAudioEvent– to self that audio is either muted or unmuted
EnxRtc.muteSelfAudio(true);	// Muting Audio

EnxRtc.onAudioEvent = (Map<dynamic,dynamic> map) {
};

EnxRtc.onRemoteStreamAudioMute=(Map<dynamic,dynamic> map) {
};

EnxRtc.onRemoteStreamAudioUnMute=(Map<dynamic,dynamic> map) {
};

Mute / Unmute Video in a Stream

Use await EnxRtc.muteSelfVideo() method to mute and unmute video from Local Stream. When a user mutes or unmutes video from own Published Stream, self user notified with event onVideoEvent and all all other connected users of the room are notified with onRemoteStreamVideoMute and onRemoteStreamVideoUnMute callbacks respectively.

Methods: static Future<void> muteSelfVideo(bool isMute) – Pass true to mute, false to unmute video

Parameters: @param {Boolean} isMute–  Pass true to mute, false to unmute audio

Event Listeners:

  • onRemoteStreamVideoMute– to all participants notifying user has muted video
  • onRemoteStreamVideoUnMute – to all participants notifying user has unmuted video
  • onVideoEvent – to self that video is either muted or unmuted
EnxRtc.muteSelfVideo(true);	// Muting Video

EnxRtc.onVideoEvent = (Map<dynamic,dynamic> map) {
};

EnxRtc.onRemoteStreamVideoMute=(Map<dynamic,dynamic> map) {
};

EnxRtc.onRemoteStreamVideoUnMute=(Map<dynamic,dynamic> map) {
};

Private, Public & Group Messaging

This is an advance messaging feature between Session participants. You can do following type of messaging in a session among participants:

  • Public Messaging: To send message to all connected users.
  • Private Messaging: To send message to a specific user.
  • Group Messaging: To send message to more than one specified users.

Messaging feature neither require the sender to publish his Stream, nor receivers to subscribe.

Method: static Future<void> sendMessage(String message, bool isBroadCast, List<dynamic> recipientIDs)essage(String Message, boolean isBroadcast, array RecipientIDs)

Parameters:

  • @param Strings message– String type message.
  • @param bool isBroadcast– Boolean. Use true for Public Broadcast, Use false for private messaging to one or more recipients.
  • @param List clientIds – Array of ClientIDs whom you wish to send private messages.

Callback:

  • onAcknowledgeSendData – It notifies when message is successfully sent to another user or group of users
  • onMessageReceived – It notifies at receiver end tat a new message arrived
EnxRtc.sendMessage(”message”,true,[]); // Send Message to all

EnxRtc.onAcknowledgeSendData = (Map<dynamic,dynamic> map) {
	// Message has been sent
};

EnxRtc.onMessageReceived = (Map<dynamic,dynamic> map) {
	// New Message has been received
};

File Sharing

EnableX File Share API allows users of a RTC session to send and receive file(s) to/from each other. Using the available APIs, you can initiate file transfer to share, cancel a file transfer, get notified on a shared file and receive/download shared file.

Upload File to share

The file sharing process starts with a user initiating a file transfer to EnableX Server. To initiate a file transfer use sendFiles() method.

Method: static Future<void> sendFiles(bool isBroadCast, List<dynamic> recipientIDs)

Parameters:

  • @param bool isBroadcast – Boolean. This is to share file among all participants in the Session. If you need to target the file share to specific user, then set it to false.
  • @param List recipientIDs– List of Client IDs. This is to share the file among specified Clients only. If broadcast is set to true, recipientIDs is ignored.

Callbacks at Sender End:

  • onInitFileUpload – To notify sender that file upload process is initiated
  • OnFileUploaded– To notify sender that file has been uploaded
  • OnFileUploadFailed – To notify sender that file upload process has failed

Callbacks at Receiver End:

  • OnFileUploadStarted – To notify intended receiver that a file is being uploaded
  • OnFileAvailable – To notify intended received that a file is ready to download
EnxRtc.sendFile(true,[]);	// Send Files

EnxRtc.onInitFileUpload = (Map<dynamic,dynamic> map) {
	// File upload started
};

EnxRtc.onFileUploaded = (Map<dynamic,dynamic> map) {
	// File is uploaded
};

EnxRtc.onFileUploadFailed = (Map<dynamic,dynamic> map) {
	// File upload failed
};

EnxRtc.onFileUploadStarted = (Map<dynamic,dynamic> map) {
	// File upload started... to recipient
};

EnxRtc.onFileAvailable = (Map<dynamic,dynamic> map) {
	// Files available for download... to recipient
};

Error Codes: Upload process may encounter error.

Error CodeError Description
5089Storage Access denied
5091 File Sharing not available in this context
1185Too large file. Max allowed Size: NNNN
1182Failed to upload file

Cancel a File Upload

Sender of a file may like to cancel an ongoing file upload. To do so use cancelUpload() method.

Method: static Future<void> cancelUpload(int jobId)

Parameters: @param int jobId – Job ID which is to be cancelled.

Event Listeners: onFileUploadCancelled – It notifies when the file upload cancelled successfully

EnxRtc.cancelFileUpload(jobId);		// Cancel File uploading

EnxRtc.onFileUploadCancelled = (Map<dynamic,dynamic> map) {
	// Upload has been cancelled
};

Cancel all Files Upload

Sender of multiple files may like to cancel an ongoing files upload. To do so use cancelAllUploads() method.

Method: static Future<void> cancelAllUploads()

Parameters: @param int jobId – Job ID which is to be cancelled.

Event Listeners: onFileUploadCancelled – It notifies when the file upload cancelled successfully

EnxRtc.cancelAllUploads();	// Cancel Files uploading

EnxRtc.onFileUploadCancelled = (Map<dynamic,dynamic> map) {
	// Upload has been cancelled
};

Download shared File

Intended Recipients needs to download each file shared with them individually. Therefore, recipient needs to know information on the available files to download to initiate a download process.

Know files to download

Room Lookup: To know what all files are available for download, you may call EnxRoom.getAvailableFiles() method. It returns list of File data.

Method: static Future<List<dynamic> getAvailableFiles()

List<dynamic> list= EnxRtc.getAvailableFiles();

When New File is availble: A receive end point is notified as and when a file is made available for download using Event Listener onFileAvailable

Initiate File Download

As you know about the file(s) to download, you need to initiate download individually using downloadFile() method.

Method: static Future<void> downloadFile(Map<String,dynamic> file, bool autoSave)

Parameters:

  • @param Map fileInfo– Map of file to be downloaded.
  • @param bool autosave– Whether to save the file automatically. If not to be save automatically, you would receive Base64 encoded RAW data to handle file saving processes manually. If auto-saving is on, you would receive saved file path.

Callbacks at Receiver End:

  • onFileDownloaded – To notify file has been downloaded with either Base64 Raw data to be saved (When auto-saving is false) or saved file path.
  • OnFileDownloadFailed – To notify download failure
EnxRtc.downloadFile(fileInfo,true);	// Download a File

EnxRtc.onFileDownloaded = (Map<dynamic,dynamic> map) {
	// File has been downloaded
};

EnxRtc.onFileDownloadFailed = (Map<dynamic,dynamic> map) {
	// File Download has failed 
};

Error Codes: Download process may encounter error.

Error CodeError Description
5089Storage Access denied
5090Failed to save file
1183Failed to download file
1181File Download not available in this context

Cancel downloading a File

Receiver of a file may like to cancel an ongoing download of a file by using cancelDownload() method.

Method: static Future<void> cancelDownload(int jobId)

Parameters: @param int jobId – Job ID which is to be cancelled.

Event Listeners: onFileDownloadCancelled– It notifies when the file download is cancelled.

EnxRtc.cancelFileDownload(jobId);	// Cancel a download job

EnxRtc.onFileDownloadCancelled=(Map<dynamic,dynamic> map) {
	// File download has been cancelled
};

Cancel downloading of all Files

Receiver of files may like to cancel ongoing download of all files by using cancelAllDownloads() method.

Method: static Future<void> cancelAllDownloads()

Event Listeners: onFileDownloadCancelled– It notifies when the file download is cancelled.

EnxRtc.cancelAllDownloads();	// Cancel  download job

EnxRtc.onFileDownloadCancelled=(Map<dynamic,dynamic> map) {
	// File download has been cancelled
};

Change to Audio only call

If you want change to a audio-only call, i.e. you neither want to receive anyone’s video not want to publish your video; you may use setAudioOnlyMode() method. This method acts as a toggle to switch between audio-only and audio-video call.

This opt-in is only for the specific End-Point and doesn’t affect others in the room.

Method: static Future<void> setAudioOnlyMode(bool audioOnly)

Parameter: @param bool audioOnly true: audio-only call, false: audio-video call

EnxRtc.setAudioOnlyMode(true); // Move to Audio Only call

Set Advanced Options

Use await EnxRtc.setAdvancedOptions() to set the advanced options.

Method: static Future<void> setAdvancedOptions(List<dynamic> advanceOptions)

Parameters:

  • @param List advanceOptions– A list of advance options to set. e.g. [“battery_updates”, “notify-video-resolution-change”]
EnxRtc.setAdvancedOptions([“battery_updates”, “notify-video-resolution-change”]);

Get Advanced Options

Use await EnxRtc.getAdvancedOptions() to get the advanced options.

Method: static Future<void> getAdvancedOptions()

Event Listeners: onGetAdvanceOptions – Gets the options

EnxRtc.getAdvancedOptions();

EnxRtc.onGetAdvancedOptions= (Map<dynamic, dynamic> map) {      
};

Set Video Scaling Type

Use await EnxRtc.setScalingType() to update the scaling type EnxPlayerWidget.

Method: static Future<void>setPlayerScalingType(ScalingType scalingType,int viewId,int uid, bool isLocal)

Parameters:

  • @param ScalingType ScalingType – One of the following constants:
    • SCALE_ASPECT_BALANCED
    • SCALE_ASPECT_FIT
    • SCALE_ASPECT_FILL
  • @param int viewId – EnxPlayerWidget Id
  • @param int uid – EnxPlayerWidget Id
  • @param boolean isLocal – true if the Player Widget is Local
EnxRtc.setScalingType(type,viewId,uid,true);

Handle Application Switch from Foreground to Background

User may switch to different application pushing your RTC Application to Background and vice versa. You need to handle such activity using following methods:

Method: static Future<void> stopVideoTracksOnApplicationBackground(bool videoMuteLocalStream, bool videoMuteRemoteStream)

Parameters:

  • @param bool videoMuteLocalStream– Boolean. Pass false to pause local Video Stream, true to continue with publishing
  • @param bool videoMuteRemoteStream– Boolean. Pass false to pause receiving remote Video Stream, true to continue receiving

Method: static Future<void> startVideoTracksOnApplicationForeground( bool restoreVideoRemoteStream, bool restoreVideoLocalStream)

Parameters:

  • @param bool restoreVideoLocalStream– Boolean. Pass true to resume sending local Video Stream if it was stopped while getting to Background.
  • @param bool restoreVideoRemoteStream– Boolean. Pass true to resume receiving remote Video Streams if they stopped while getting to Background.
// When application goes to Background 
EnxRtc. stopVideoTracksOnApplicationBackground (localMuteState, remoteMuteState);

// When application comes back to Foreground 
 EnxRtc.startVideoTracksOnApplicationForeground(remoteUnmuteState, localUnmuteState); 

Get Video Quality Received

The Client End Point may now about the video quality it receives.

Method: static Future<String> getReceiveVideoQuality(String streamType)

Parameters: @param String streamType – Enumerated Values: talkercanvas

await EnxRtc.getReceiveVideoQuality(streamType);

Use Custom Signaling

Your Application might require to send instructions, data to one or more recipient connected in a Session to deploy new features, business workflow. For example, you wan to create a Polling mechanism among participants. EnableX supports Custom Signaling method through which you can build such utility that requires passing of messages among participants.

Using Custom Signaling Method, you might send message to all or selected participants in a Room. You can define your custom data structure to pass to meet your business requirement.

Method:  static Future<void> sendUserData(Map<String,dynamic> message, bool isBroadCast, List<dynamic> recipientIDs)

Parameters:

  • @param Map message – Map containing custom keys. This object is passed to Recipients as is. EnableX doesn’t enforce it’s structure. Be advised to define keys effectively for signaling needs.
  • @param bool isBroadcast– Boolean. Use true for Public Broadcast, Use false for signaling to one or more recipients.
  • @param List clientIds – Array of ClientIDs whom you wish to send private messages.

Callback

  • onAcknowledgeSendData – It notifies when signaling mesage is sent to another user or group of users
  • onUserDataReceived – Receives a new signaling message

message – Example of custom chat Map:

// Example: Important Information you can put with custom keys
// You may define the Map as per your business needs

map message = {
    "sender": "Sender's Name",
    "message": "Message body",
    "custom_key": "Data"
}

To send & receive Custom Signaling

EnxRtc.sendUserData(”message”,true,[]);	// Send Custom Signaling

EnxRtc.onAcknowledgeSendData = (Map<dynamic,dynamic> map) {
	// Signaling Message has been sent
};

EnxRtc.onUserDataReceived = (Map<dynamic,dynamic> map) {
	// New Signaling Message is received
};

Enable Proximity Sensor

EnxProximitySensor manages functions related to the “Proximity Sensor”. On most device, the Proximity Sensor is implemented as a boolean-sensor.

  • It returns just two values NEAR or FAR.
  • Thresholding is done on the LUX value i.e. the LUX value of the light Sensor is compared with a threshold.
  • A LUX-value more than the threshold means the Proximity Sensor returns FAR.
  • Anything less than the threshold value, the Sensor returns NEAR

Method: static Future<void> enableProximitySensor (bool isEnabled)

Parameters: @param bool isEnabled – Boolean. true to enable and false to disable Proximity Sensor.

EnxRtc.enableProximitySensor(true); // Enable Sensor

Extend Session

Each Room is defined with duration value in minutes. This duration defines total length of single session and it’s counted from the time first user joins the session. EnableX drops the session when the session duration elapses.

For practical reasons, a session may need to get extended. Therefore, EnableX allows users to extend a session duration at run-time. Follow explanation given below:

  1. An “Extension Window” opens 10 minutes prior to the end of scheduled closure of the Session. All connected users are notified with an Event.
  2. Any user can trigger extension of the Session by calling a Method. If any user trigger extension, the Extension Window is closed. This prevents EnableX to process further Extension Request within the same Extension Window.
  3. If extension is not triggered by any user, another “Extension Window” opens 5 minutes prior to the end of scheduled closure of the Session. This is the final Extension Window. All connected users are notified with an Event.
  4. EnableX processes extension request and extends the session by 10 to 30 minutes. So, the extended period may vary.
  5. There is no cap on number of times you may extend your Session. Once extended, Step 1-4 will get repeated.

Method: static Future<void> extendConferenceDuration() – To trigger extension by any user, available only when an Extension Window is open.

Notification Event: 

  • onConferenceRemainingDuration  – Event is received when an Extension Window is open. It bring a JSON to show how many minutes is left to scheduled session closure.
  • onConferencessExtended – Event to notify that the Session has been extended.
// Listen to event to know when Extension Window is open
EnxRtc.onConferenceRemainingDuration= (Map<dynamic, dynamic> map) {
};

EnxRtc.extendConferenceDuration(); // Extend Session

// Listen when Session is extended
EnxRtc.onConferencessExtended= (Map<dynamic, dynamic> map) {
};

Make Outbound Call

Being within EnableX Session, you may initiate an Outbound Call to PSTN Number or SIP URI inviting the called participant to join the session on accepting the call.

Method: static Future<void> makeOutboundCall(String number)

Parameters:

  • @param String number – String. Phone Number to dial-out.

Event Listener:

  • onOutBoundCallInitiated – Event Listener to get call initiation status
  • onDialStateEvents – Status of the Dialout Process is notified as and when received from Gateway. The JSON Response returns following status codes: initiated, calling, connecting, connected, terminated, failed and disconnected
EnxRtc.makeOutboundCall ('9896xxxxxx');	// Dial-Out the Number

EnxRtc.onOutBoundCallInitiated= (Map<dynamic, dynamic> map) {
	// Receives Call State
};

EnxRtc.onDialStateEvents= (String state) {
	// Receives Call State
};

Error Codes – Failure Conditions to accept Dial-Out request

Error CodeDescription
1141Dial-Out request is already in progress
1142CLI doesn’t match with configured phone number

Get Live Stream Statistics

For debugging purposes, you can get life statistics of each stream you are playing at any end-point, be it a local stream or subscribed stream. The following information for each stream is displayed using a Overlay over respective player:

  • For Local Streams
    • Transmission Bandwidth
    • Video Resolution
  • For Subscribed Streams
    • Receiving Bandwidth
    • Video Resolution
    • Available Bandwidth for Remote User
    • Packet Loss

Method: static Future<void> enableStats (bool enableStats)

Parameters:

  • @param bool enableStats: Boolean. Use true to enable Statistics display, false to disable.

Event Listeners:

  • onAcknowledgeStats – It notifies user that webRTC stats are enabled successfully
  • onReceivedStats – It notifies all the webRTC stats received
EnxRtc.enableStats(true);	// Enable Stats

EnxRtc.onAcknowledgeStats = (Map<dynamic,dynamic> map) {
};

EnxRtc. onReceivedStats = (Map<dynamic,dynamic> map) {
};

Explore Flutter SDK