Initiate Local Stream

The EnxRoom.getLocalStream() method is used to initialize a local stream at the Client endpoint before it can be published to the Room. The initialization process comprises specifying media tracks, adding custom attributes, etc. in the form of a JSON object passed as a parameter to the method.

ClassEnxRoom

Methodpublic EnxStream getLocalStream( JSONObject publishStreamInfo )

ParameterspublishStreamInfo - A JSON object with Local Stream Options as given below:

JSONObject streamOpt = {
     "audio": true,          // Whether to add Audio to stream
     "video": true,          // Whether to add Video to stream
     "data": true,           // Whether to add Data to stream
     "videoSize":  {         // Video Frame Size - Deprecated in Android SDK v2.0.1+
           "minWidth": number, 
           "minHeight": number,  
           "maxWidth": number,
           "maxHeight": number
       ), 
     "audioMuted": true,     // Audio muted on entry to room  
     "videoMuted": true,     // Video muted on entry to room  
     "attributes": {         // Object to carry custom data  
         "custom1": ""
      },
      "maxVideoBW": number,  // Max Bandwidth - Deprecated in Android SDK v2.0.1+
      "minVideoBW": number   // Min Bandwidth - Deprecated in Android SDK v2.0.1+
 } ;

EnxStream localStream = room.getLocalStream(streamOpt);  // Initiate the Stream

Error Codes / Exceptions

CodeDescription
5015Failed to initialize the Stream without Audio, Video, and Data track.
5016Failed to initialize the Stream due to incorrect values of JSON Keys in publishStreamInfo.
5017Unable to create Stream due to failure to access Camera and Microphone.
5018Unable to create Video Stream due to failure to access Camera. Only Audio Stream created.
5019Unable to create Stream due to failure to access Microphone.
5084Invalid Video Layer. Max allowed Video Layers: 3
5088Invalid Frame Rate. Max allowed Frame Rate: 30

Initiate Stream with Multiple Video Layers

To help stream subscribers receive the best video quality subject to the available bandwidth, stream publishers must ensure that their streams carry multiple video layers of different quality. The Auto Bandwidth Detection feature detects the subscriber’s bandwidth and switches to the respective video layer for a smooth video experience.

JSONObject streamOpt = {
       audio: true, 
       video: true, 
       maxVideoLayers: 3 // Carry 3 layers, viz HD 720p, SD 480p & LD 240p/180p 
 };

// Enumerated Values for  maxVideoLayers: 1, 2, 3                               
// 1=HD 720p layer only                               
// 2=HD 720p & SD 480p layers only                               
// 3=HD 720p, SD 480p & LD 240p/180p layers 

EnxStream localStream = room.getLocalStream(streamOpt); 

Error Codes / Exceptions

CodeDescription
5084Illegible Value for maxVideoLayers. Max 3 Video Layers supported.