In-Session Communication

This page covers all APIs for communicating inside an EnableX Android video session: text chat (including edit and delete), custom data signalling, file sharing, screen sharing, canvas streaming, annotation, and live transcription.

Chat

EnableX supports public (broadcast), private (one-to-one), and group chat messaging. Messaging does not require the sender to have a published stream or the receiver to have a subscribed stream.

Send a Chat Message

EnxRoom.sendMessage() sends a text message to one or more participants in the session.

ParameterTypeDescription
messageStringThe text message to send.
isBroadcastBooleantrue to send to all participants (public); false to send to specific recipients (private/group).
recipientIDsArrayList of client IDs to receive the message. Applicable only when isBroadcast is false.
CallbackDelivered ToDescription
onACKSendMessageSenderAcknowledgment that the message was sent, including a unique messageId.
onMessageReceivedRecipientsDelivers the received message as a JSONObject.
// Public broadcast — send to all
room.sendMessage("Hello everyone!", true, null);

// Private or group — send to specific recipients
List<String> recipientClientIds = new ArrayList<>();
recipientClientIds.add("clientId1");
room.sendMessage("Hello!", false, recipientClientIds);

// Sender receives acknowledgment
@Override
public void onACKSendMessage(JSONObject jsonObject) {
    // Contains message details including messageId
}

// Recipients receive the message
@Override
public void onMessageReceived(JSONObject jsonObject) {
    String textMessage = jsonObject.getString("msg");
}

Edit a Chat Message

EnxRoom.transactMessage() edits a previously sent chat message. The messageId is received via onACKSendMessage or onMessageReceived when the original message was sent.

ParameterTypeDescription
messageStringThe updated (edited) message text.
messageIdStringUnique ID of the original message to be edited.
typeStringUse "chat-update" to edit a message.
CallbackDelivered ToDescription
onACKUpdateMessageSenderAcknowledgment that the edit request was received.
onMessageUpdateRecipientsDelivers the updated message to all recipients.
JSONObject option = new JSONObject();
option.put("message", "This is my edited message");
option.put("messageId", "3889493030");
option.put("type", "chat-update");

room.transactMessage(option);

// Sender receives acknowledgment
@Override
public void onACKUpdateMessage(JSONObject data) {
    // Acknowledgment of the edit request
}

// Recipients receive the updated message
@Override
public void onMessageUpdate(JSONObject data) {
    // data contains the updated message
}

Delete a Chat Message

EnxRoom.transactMessage() also handles message deletion. Use "chat-delete" as the type and provide the messageId of the message to remove.

ParameterTypeDescription
messageIdStringUnique ID of the message to be deleted.
typeStringUse "chat-delete" to delete a message.
CallbackDelivered ToDescription
onACKDeleteMessageSenderAcknowledgment that the delete request was received.
onMessageDeleteRecipientsNotifies recipients that a message has been deleted.
JSONObject option = new JSONObject();
option.put("messageId", "3889493030");
option.put("type", "chat-delete");

room.transactMessage(option);

// Sender receives acknowledgment
@Override
public void onACKDeleteMessage(JSONObject data) {
    // Acknowledgment that the deletion was processed
}

// Recipients are notified of the deletion
@Override
public void onMessageDelete(JSONObject data) {
    // data contains deleted message information
}
Custom Signalling

EnxRoom.sendUserData() sends a structured JSON payload to one or more participants without any EnableX message structure constraints. Use this to exchange application-specific instructions, polls, or any custom data during a session.

ParameterTypeDescription
dataJSON ObjectA JSON object with custom keys. Passed to recipients without structure enforcement.
isBroadcastBooleantrue to broadcast to all participants; false to signal specific recipients.
recipientIDsArrayList of client IDs of intended recipients. Not used when isBroadcast is true.
CallbackDescription
onUserDataReceivedDelivers the received custom data as a JSONObject to the intended recipients. Available from Android SDK v1.5.3 and later.
// Build your custom payload
JSONObject data = new JSONObject();
data.put("sender", "Alice");
data.put("message", "Custom instruction");
data.put("custom_key", "value");

// Broadcast to all participants
room.sendUserData(data, true, null);

// Send to specific recipients
List<String> recipientClientIds = new ArrayList<>();
recipientClientIds.add("clientId1");
room.sendUserData(data, false, recipientClientIds);

// Recipients receive the signal
@Override
public void onUserDataReceived(JSONObject jsonObject) {
    // Handle the custom JSON payload
}
Error CodeDescription
5127Exceeding the maximum allowed data transfer rate of 100 Kbps.
File Sharing

File sharing allows participants to upload and download files within an RTC session. Available from Android SDK v1.5.3 and later. You must call setFileShareObserver(this) before using any file sharing API.

Required: Call room.setFileShareObserver(this) after connecting to the room before calling any file sharing methods.

Upload a File

EnxRoom.sendFiles() initiates a file transfer to the EnableX server. A UI is presented to the user to select the file to upload.

ParameterTypeDescription
viewFrameLayoutThe layout where the file-picker UI is displayed.
isBroadcastBooleantrue to share with all participants; false to share with specific users.
clientIdListArrayList of client IDs of intended recipients. Not used when isBroadcast is true.
CallbackDelivered ToDescription
onInitFileUploadSenderNotified when the file upload process is initiated.
onFileUploadedSenderNotified when the file has been uploaded successfully.
onFileUploadFailedSenderNotified when the file upload fails.
onFileUploadStartedReceiversNotified when a file upload begins (file is being uploaded).
onFileAvailableReceiversNotified when a file is ready to download.
room.setFileShareObserver(this);

// Broadcast the file to all participants
room.sendFiles(frameLayoutView, true, null);

// Callbacks at sender
@Override
public void onInitFileUpload(JSONObject jsonObject) {
    // File upload has started
}

@Override
public void onFileUploaded(JSONObject jsonObject) {
    // File uploaded successfully
}

@Override
public void onFileUploadFailed(JSONObject jsonObject) {
    // File upload failed — handle error
}

// Callbacks at receivers
@Override
public void onFileUploadStarted(JSONObject jsonObject) {
    // A file is being uploaded by another participant
}

@Override
public void onFileAvailable(JSONObject jsonObject) {
    // A file is now available for download
}

Get Available Files

EnxRoom.getAvailableFiles() returns all files currently available for download in the session. Call this after joining the room to retrieve any files shared before you connected.

JSONArray myFiles = room.getAvailableFiles();
// Returns an array of file info objects, e.g.:
// [ { "name": "report.pdf", "size": 191002, "index": 0 } ]

Download a Shared File

EnxRoom.downloadFile() downloads a file identified by its file info object (received via onFileAvailable or getAvailableFiles()).

ParameterTypeDescription
fileInfoJSON ObjectFile information object obtained from onFileAvailable or getAvailableFiles().
isAutoSaveBooleantrue to save the file automatically (callback includes the saved file path); false to receive Base64-encoded raw data to handle saving manually.
CallbackDescription
onInitFileDownloadNotified when the file download process is initiated.
onFileDownloadedNotified when the file has been downloaded (with or without auto-save).
onFileDownloadFailedNotified when the file download fails.
room.downloadFile(fileInfoJsonObject, true);

@Override
public void onFileDownloaded(JSONObject jsonObject) {
    // File downloaded — jsonObject contains path or Base64 data
}

@Override
public void onFileDownloadFailed(JSONObject jsonObject) {
    // Download failed — handle error
}

Cancel a File Upload

Use cancelUpload() to cancel a specific ongoing upload, or cancelAllUploads() to cancel all uploads you initiated.

// Cancel a specific upload job
enxRoom.cancelUpload(jobId);

// Cancel all ongoing uploads
enxRoom.cancelAllUploads();

// Acknowledgment callback
@Override
public void onFileUploadCancelled(JSONObject jsonObject) {
    // Upload has been cancelled
}
Error CodeDescription
5089Storage access is denied.
5090Failed to save the file.
5091File sharing is not available in this context.
5092Too many files to upload — maximum one file per request.
5098Unable to cancel upload after upload is complete.
5099Failed to cancel — invalid upload ID.
5100Failed to upload a possibly corrupt file.
1182Failed to upload file.
1185File size exceeds the maximum allowed size.

Cancel a File Download

Use cancelDownload() to cancel a specific ongoing download, or cancelAllDownloads() to cancel all downloads at your endpoint.

// Cancel a specific download job
enxRoom.cancelDownload(jobId);

// Cancel all ongoing downloads
enxRoom.cancelAllDownloads();

// Acknowledgment callback
@Override
public void onFileDownloadCancelled(JSONObject jsonObject) {
    // Download has been cancelled
}
Error CodeDescription
5089Storage access is denied.
5090Failed to save the file.
5101The file is already downloaded.
1181File download is not available. Non-contextual method call.
1183Failed to download the file.
Screen Sharing

Screen sharing publishes the device screen as a video stream (Stream ID 101) at 6 fps. To receive shared screens, subscribe to Stream ID 101. Screen sharing must be enabled when creating the room: { "screen_share": true }.

You must call room.setScreenShareObserver(this) before calling any screen sharing method.

Android 11+ Note: On Android 11 (API level 30) or later, you must create a foreground service with mediaProjection foreground service type declared in your manifest before starting screen sharing. Screen sharing continues even when the application is in the background.

Start Screen Sharing

EnxRoom.startScreenShare() creates and publishes a screen share stream into the room.

CallbackDelivered ToDescription
onScreenSharedStartedEveryone in roomNotifies all participants that screen sharing has started, providing the screen share stream object.
// Register the observer before starting
room.setScreenShareObserver(this);

// Start screen sharing
room.startScreenShare();

// Received by everyone — screen share stream available (Stream ID 101)
@Override
public void onScreenSharedStarted(EnxStream enxStream) {
    // enxStream is the screen share stream (ID 101)
    // Attach to a player view and add to your layout
    yourView.addView(enxStream.mEnxPlayerView);
}

Stop Screen Sharing

EnxRoom.stopScreenShare() stops the active screen sharing session initiated by the local user.

CallbackDelivered ToDescription
onScreenSharedStoppedEveryone in roomNotifies all participants that screen sharing has stopped.
room.stopScreenShare();

@Override
public void onScreenSharedStopped(EnxStream enxStream) {
    // Remove the screen share view from layout
    yourView.removeAllViews();
}
Error CodeDescription
5107Repeated startScreenShare() call while a previous request is in process.
1170Screen sharing is not supported in your subscription.

Force Stop Sharing (Moderator Only)

EnxRoom.stopAllSharing() allows a moderator to force stop any ongoing screen sharing or canvas streaming by any participant in the room. This method is restricted to moderators and is not available to regular participants.

Moderator only: stopAllSharing() can only be called by a moderator. It stops both screen sharing and canvas streaming. Available from Android SDK v2.1.2 and later.
CallbackDelivered ToDescription
onStopAllSharingACKEveryone in roomNotifies all participants that all sharing has been stopped by the moderator.
// Moderator force-stops all screen sharing and canvas streaming
EnxRoom.stopAllSharing();

@Override
public void onStopAllSharingACK(JSONObject jsonObject) {
    // All sharing has been stopped — update your UI accordingly
}
Canvas Streaming

Canvas streaming publishes any Android View as a video stream (Stream ID 102) into the room. Canvas streaming must be enabled when creating the room: { "canvas": true }. To receive a canvas stream, subscribe to Stream ID 102.

Start Canvas Streaming

EnxRoom.startCanvas() starts publishing the specified view as a canvas stream into the room.

CallbackDelivered ToDescription
onStartCanvasAckPublisherAcknowledgment to the publisher when canvas streaming starts.
onCanvasStartedEveryone in roomNotifies all participants that canvas streaming has started, providing the canvas stream object.
room.startCanvas(yourView);

// Publisher receives acknowledgment
@Override
public void onStartCanvasAck(JSONObject jsonObject) {
    // Canvas streaming started successfully
}

// Received by all participants — canvas stream available (Stream ID 102)
@Override
public void onCanvasStarted(EnxStream enxStream) {
    // enxStream is the canvas stream (ID 102)
    // Attach to a player view and display
    EnxPlayerView canvasPlayerView = new EnxPlayerView(
        CurrentClassContext, ScalingType, mediaOverlay);
    enxStream.attachRenderer(canvasPlayerView);
    yourView.addView(canvasPlayerView);
}
Error CodeDescription
5103Canvas streaming or screen sharing is already active in the room.
5105Repeated startCanvas() call when canvas stream is already active.
5107Repeated startCanvas() call while a previous request is being processed.
5110Failed to publish the canvas stream.

Stop Canvas Streaming

EnxRoom.stopCanvas() stops the active canvas streaming session.

CallbackDelivered ToDescription
onStoppedCanvasAckPublisherAcknowledgment to the publisher when canvas streaming stops.
onCanvasStoppedEveryone in roomNotifies all participants that canvas streaming has stopped.
room.stopCanvas();

// Publisher receives acknowledgment
@Override
public void onStoppedCanvasAck(JSONObject jsonObject) {
    // Canvas streaming stopped
}

// Received by all participants
@Override
public void onCanvasStopped(EnxStream enxStream) {
    // Remove the canvas view from layout
    yourView.removeAllViews();
}
Note: A moderator can force stop canvas streaming using stopAllSharing(). See Force Stop Sharing above. Available from Android SDK v2.1.2 and later.
Annotation

Annotation allows users to draw on a remote stream. To enable annotation, canvas streaming must be enabled when creating the room: { "canvas": true }. Available from Android SDK v2.1.2 and later.

You must add the annotation toolbar to your layout XML and set the setAnnotationObserver after connecting to the room.

Add Annotation Toolbar to Layout

<enx_rtc_android.annotations.EnxAnnotationsToolbar
    android:id="@+id/annotations_bar"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"/>

Start Annotation

EnxRoom.startAnnotation() begins annotation on a given stream object.

CallbackDelivered ToDescription
onStartAnnotationAckAnnotatorAcknowledgment to the annotator when annotation starts.
onAnnotationStartedEveryone in roomNotifies all participants that annotation has started.
// Set the annotation observer after connecting to the room
room.setAnnotationObserver(annotationsObserverInstance);

// Start annotation on a stream
room.startAnnotation(enxStream);

// Annotator receives acknowledgment
@Override
public void onStartAnnotationAck(JSONObject jsonObject) {
    // Annotation started — update UI
}

// Notification to all participants
@Override
public void onAnnotationStarted(EnxStream enxStream) {
    // Add the annotation view to your layout
    ((ViewGroup) mAnnotationViewContainer).addView(enxStream.EnxPlayerView);
}

Stop Annotation

EnxRoom.stopAnnotation() stops the current annotation.

CallbackDelivered ToDescription
onStoppedAnnotationAckAnnotatorAcknowledgment to the annotator when annotation stops.
onAnnotationStoppedEveryone in roomNotifies all participants that annotation has stopped.
room.stopAnnotation();

// Annotator receives acknowledgment
@Override
public void onStoppedAnnotationAck(JSONObject jsonObject) {
    // Annotation stopped — update UI
}

// Notification to all participants
@Override
public void onAnnotationStopped(EnxStream enxStream) {
    // Remove the annotation view from your layout
    ((ViewGroup) mAnnotationViewContainer).removeView(enxStream.EnxPlayerView);
}
Error CodeDescription
5093Annotation access is denied.
5094Repeated stopAnnotation() while a previous request is in process.
5104Repeated startAnnotation() — annotations are already active in the room.
5106Repeated startAnnotation() while a previous request is in process.
5108Invalid stream passed to startAnnotation().
5109Failed to publish annotation stream.
5112Annotation is only supported in landscape mode.
Live Transcription

Live transcription converts the speech of all Active Talkers in a session to text in near real time. All endpoints that request transcription subscribe to the same transcription feed. The process starts when the first user requests it and stops when the last subscriber opts out — unless auto_transcribe is enabled at the room level, in which case it runs for the full session.

Subscription required: Live transcription is a subscription-based service. Contact your EnableX Account Manager to enable it. If not subscribed, rooms configured with live transcription settings will be rejected.

Start Live Transcription

Two methods are available to start live transcription:

When the method is called for the first time in a session, it starts the transcription process and subscribes the endpoint. Subsequent calls from other endpoints only subscribe them to the existing feed.

CallbackDescription
onACKStartLiveTranscriptionAcknowledgment that the start request was received.
onSelfTranscriptionOnNotifies the endpoint that self-transcription is enabled.
onRoomTranscriptionOnNotifies when transcription is promoted to room-level.
onTranscriptionEventsDelivers live transcription events containing recognized text.

Transcription Event Payload

The onTranscriptionEvents callback delivers a JSONObject with the following fields:

FieldDescription
type"speech_recognising" — intermediate event while audio is being recognized. "speech_recognised" — final event when a phrase is fully recognized (typically at a pause or speech end).
textThe transcribed text string.
durationDuration from the offset at which the speech was identified.
clientIdClient ID of the user whose speech is being recognized.
// Start self-transcription
enxRoom.startLiveTranscription("english_us");

// Or start room-level transcription
enxRoom.startLiveTranscriptionForRoom("english_us");

// Acknowledgment of start request
@Override
public void onACKStartLiveTranscription(JSONObject jsonObject) {
    // Start request acknowledged
}

// Self-transcription is now active
@Override
public void onSelfTranscriptionOn(JSONObject jsonObject) {
    // This endpoint is now receiving transcription
}

// Room-level transcription is active
@Override
public void onRoomTranscriptionOn(JSONObject jsonObject) {
    // All subscribed endpoints are receiving transcription
}

// Receive transcription events
@Override
public void onTranscriptionEvents(JSONObject jsonObject) {
    String type     = jsonObject.getString("type");     // "speech_recognising" or "speech_recognised"
    String text     = jsonObject.getString("text");     // Transcribed text
    String clientId = jsonObject.getString("clientId"); // Speaker's client ID
    // Display or process the transcribed text
}
Error CodeDescription
3002Live transcription subscription is not enabled.
3002Live transcription is already in progress.

Stop Live Transcription

EnxRoom.stopLiveTranscription() unsubscribes the calling endpoint from the live transcription feed. When the last subscribed endpoint calls this method, the transcription process stops in the room — unless auto_transcribe is enabled at the room level, in which case it continues until the session ends.

CallbackDescription
onACKStopLiveTranscriptionAcknowledgment that the stop request was received.
onSelfTranscriptionOffNotifies the endpoint that self-transcription has been turned off.
onRoomTranscriptionOffNotifies when room-level transcription has been stopped.
enxRoom.stopLiveTranscription();

// Acknowledgment of stop request
@Override
public void onACKStopLiveTranscription(JSONObject jsonObject) {
    // Stop request acknowledged
}

// This endpoint is no longer receiving transcription
@Override
public void onSelfTranscriptionOff(JSONObject jsonObject) {
    // Hide transcription UI
}

// Room-level transcription has been stopped
@Override
public void onRoomTranscriptionOff(JSONObject jsonObject) {
    // Transcription has ended for all participants
}
Error CodeDescription
3001Live transcription request not found — transcription may not have been started.