Canvas Streaming allows you to publish any view into the Room. To support Canvas Streaming in the Room, you need to enable canvas during Room Creation by setting: { canvas: true; }} in the JSON Payload.

Table of Contents

Start Canvas Streaming

The EnxRoom.startCanvas() method is used to start canvas streaming.

Class: EnxRoom

Methodpublic void startCanvas(View view)

Parameter:

View: The View to be used for Canvas Streaming.

Callbacks:

  • onStartCanvasAck – Acknowledgment to the publisher when Canvas Streaming starts.
  • onCanvasStarted – Notification to everyone in the Room when Canvas Streaming starts.
room.startCanvas(view); 

// Publisher receives acknowledgement
public void onStartCanvasAck(JSONObject jsonObject) {
       // Handle JSON Object      
}

// Others in the Room are notified 
public void onCanvasStarted(EnxStream enxStream) {
 // Get EnxPlayerView from ensStream
 // And add to View
 yourView.addView(enxStream.mEnxPlayerView);
} 

Error Codes / Exceptions

CodeDescription
5105Repeated startCanvas() call when Canvas Streaming is already active.
5107Repeated startCanvas() call when a previous request is in process.
5103Canvas Streaming or Screen Share already active in the Room.
5110Failed to publish Canvas Stream.

Stop Canvas Streaming

The EnxRoom.stopCanvas() method is used to stop Canvas Streaming.

Class: EnxRoom

Methodpublic void stopCanvas()

Callbacks

  • onStoppedCanvasAck – Acknowledgment to the publisher when Canvas Streaming stops.
  • onCanvasStopped– Notification to everyone in the Room when Canvas Streaming stops.
room.stopCanvas(); 

// Publisher receives acknowledgement that Canvas Streaming stopped.
public void onStoppedCanvasAck(JSONObject jsonObject) {
       // Handle JSON Object   
}

// Others in the Room are notified that Canvas Streaming stopped.
public void onCanvasStopped(EnxStream enxStream) {
	// And remove View from yourView
	yourView.removeAllViews();
}

Receive & Play Canvas Streams

A Client application developed using Android SDK cannot initiate HTML5 Canvas Streaming. However, it can receive Canvas Streaming initiated by a Client application developed using Web SDK that runs on Web Browsers.

To receive Canvas Streaming, you need to subscribe to the Canvas Stream ID# 102. Once subscribed, you can play it like any other Video Stream using a Video Player.

// A new Canvas Streaming is available, receive Information
public void onCanvasStarted(JSONObject json) {
	String streamId		= json.getString("streamId");
	String canvasName	= json.getString("name");
	
	// Get Remote Streams in the Room
	Map<String, EnxStream> map = room.getRemoteStreams();

	// The Canvas Stream Object
	EnxStream CanvasStream = map.get(streamId); 
	
	// Create playerView for Canvas Stream
	EnxPlayerView canvasPlayerView = new EnxPlayerView(
		Current-Class-Context, ScalingType, mediaOverlay);

	// Attach stream to playerView
	CanvasStream.attachRenderer(canvasPlayerView);
	yourLocalView.addView(canvasPlayerView);
} 

// Canvas Streaming has stopped. Receive Information
public void onCanvasStopped(JSONObject json){
	String streamId		= json.getString("streamId");
} 

Force Stop Canvas Streaming

Availability: Android SDK 2.1.2+

If moderator wishes to force stop any ongoing Canvas Streaming by other user in the Room, he can do so by using EnxRoom.stopAllSharing() method. Note, this is Moderator exclusive feature, can’t be executed from Participant’s end point.

This method also force stops any ongoing Screen Share.

Class: EnxRoom

Observer: ACK CallBack

Method: public void stopAllSharing()

Callbacks:

onStopAllSharingACK – Notification to everyone in the Room when Screen-Sharing stops.

EnxRoom.stopAllSharing()     // Force Stop Canvas Streaming

 
// Notification to all when Canvas Streaming stops
public void onStopAllSharingACK(JSONObject jsonObject);