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.

Method(void) startCanvas:(UIView*_Nonnull)view

Parameter:

UIView – The UI View to be used for Canvas Streaming.

Delegate Methods:

  • - room:didStartCanvasACK: – Acknowledgment to the publisher when Canvas Streaming starts.
  • - room:didCanvasStarted: – Notification to everyone in the Room when Canvas Streaming starts.
[room startCanvas: UIView];

// Callback method for Publisher to
// acknowledge that Canvas Streaming has started
-(void)room:(EnxRoom *_Nullable)room didStartCanvasACK:(NSArray *_Nullable)Data; 

// Callback method for all participants in 
// the room to notify that canvas streaming has started
-(void)room:(EnxRoom*)room didCanvasStarted:(EnxStream *_Nullable)stream{
	stream.enxPlayer.frame = yourFrame;
	[yourView addSubview:stream.enxPlayer];
}

-(void)room:(EnxRoom *)room didStartCanvasACK:(NSArray *)Data{
	// Acknowledge to the Publisher that Canvas Stream started.
	
}

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

Method-(void)stopCanvas;

Delegate Methods

  • - room:didStopCanvasACK: – Acknowledgment to the publisher when Canvas Streaming stops.
  • - room:didCanvasStopped: – Notification to everyone in the Room when Canvas Streaming stops.
[room stopCanvas];

// Callback method for Publisher to
// acknowledge that Canvas Streaming has stopped
-(void)room:(EnxRoom *_Nullable)room didStoppedCanvasACK:(NSArray *_Nullable)Data; 

// Everyone notified that Canvas Streaming has stopped
-(void)room:(EnxRoom *)room didCanvasStopped:(EnxStream *_Nullable)stream{
	[stream.enxPlayer removeFromSuperview];
}

Receive & Play Canvas Streams

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.

// You are notified when Canvas Streaming started
-(void)room:(EnxRoom *)room canvasStarted:(NSArray *)Data{
	/*Data is 
	[	{ 
			"clientId" : "XXXX", 
			"name" : "Canvas Streaming from Web",
			"result" : 0, 
			"streamId" : 102
		},
		"<null>"
	]
	*/


	NSDictionary *responseDict = Data[0];
	
	// Get remote stream using streamId
	NSString *streamId = *responseDict[@”streamId”];
	EnxStream *stream = room.streamsByStreamId[streamId]; 
	  
	// init player view
	EnxPlayerView *playerView = [[EnxPlayerView alloc] initWithFrame:frame];
	[stream attachRenderer:playerView];
	[playerView setDelegate:self];
}


// You are notified when Canvas Streaming stopped
-(void)room:(EnxRoom *)room canvasStopped:(NSArray *)Data{
	/* Data is 
	[	{ 
			"clientId" : "XXXX", 
			"name" : "Canvas Streaming from Web",
			"result" : 0, 
			"streamId" : 102
		},
		"<null>"
	]
	*/

	// Update your UI here.

}

Note: In case of error, <null> is received at the first Index and Error Info at the second Index.

Force Stop Canvas Streaming

Availability: iOS 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: -(void)stopAllSharing

Callbacks:

didACKStopAllSharing – Notification to everyone in the Room when Canvas Streaming stops.

[EnxRoom stopAllSharing];     // Force Stop the Canvas Streaming

 
// Notification to all when share stops
- (void)signalingChannel:(EnxSignalingChannel *_Nullable)channel didACKStopAllSharing:(NSArray *_Nonnull)data