setQuality(bandwidth, quality) method

If an OzCamera object is added to the program, this method can run on it. It is used to set the quality of the camera feed.

Sets the maximum amount of bandwidth per second or the required picture quality of the current outgoing video feed. Use this method to specify which element of the outgoing video feed is more important to your application—bandwidth use or picture quality.

  • To indicate that bandwidth use takes precedence, pass a positive value for bandwidth and 0 for quality. The runtime transmits video at the highest quality possible within the specified bandwidth. If necessary, the runtime reduces picture quality to avoid exceeding the specified bandwidth. In general, as motion increases, quality decreases. e.g. myCam.setQuality(500000,0);

  • To indicate that quality takes precedence, pass 0 for bandwidth and a value between 1 and 100 for quality. The runtime uses as much bandwidth as required to maintain the specified quality. If necessary, the runtime reduces the frame rate to maintain picture quality. In general, as motion increases, bandwidth use also increases. e.g. myCam.setQuality(0,100);

  • To specify that both bandwidth and quality are equally important, pass positive values for both parameters. The runtime transmits video that achieves the specified quality and that doesn't exceed the specified bandwidth. If necessary, the runtime reduces the frame rate to maintain picture quality without exceeding the specified bandwidth. e.g. myCam.setQuality(500000,50);

Parameters

bandwidth: It is an integer parameter. Specifies the maximum amount of bandwidth that the current outgoing video feed can use, in bytes per second. To specify that the video can use as much bandwidth as needed to maintain the value of quality, pass 0 for bandwidth.

quality: It is an integer parameter that specifies the required level of picture quality, as determined by the amount of compression being applied to each video frame. Acceptable values range from 1 (lowest quality, maximum compression) to 100 (highest quality, no compression). To specify that picture quality can vary as needed to avoid exceeding bandwidth, pass 0 for quality.

Method usage example

In this example we create a Call and an OzCamera object, set the camera feed quality and attach the camera to the call.

First we make the myCam object in the OzCamera class and the myFirstVideoCall object in the call class. We set the called number, register to the onCallStateChanged event and start the call. Next we set the quality to maximum with no bandwidth limit. By registering to the onCallStateChanged event everytime the state of the call changes the callStateChanged function is called if the state changes to "IN_CALL" the myCam object will be attached to the call. The attachCamera method can only run in "IN_CALL" state (Code example 1).

var calledNumber = "1000";
//constructor of the myCam object, the default camera is used
var myCam = OzCamera.getCameraByName(); 
var myFirstVideoCall = OzWebClient.createCall(calledNumber); //constructor of the call

//registers to the onCallStateChanged event
ymFirstVideoCall.onCallStateChanged(callStateChanged); 
myFirstVideoCall.start();	//starts the call	
myCam.setQuality(0,100); //provides maximum quality with no bandwidth limit

function callStateChanged(state){
  if (state == "IN_CALL") //if callstate is "IN_CALL" then
    myFirstVideoCall.attachCamera(myCam); //attach myCam object to the call
}
	
Code example 1 - setQuality(bandwidth, quality) method example

More information