private void changeCaptureFormatInternal(int width, int height, int framerate) {
   if (!videoCallEnabled || isError || videoCapturer == null) {
     Log.e(
         TAG,
         "Failed to change capture format. Video: " + videoCallEnabled + ". Error : " + isError);
     return;
   }
   Log.d(TAG, "changeCaptureFormat: " + width + "x" + height + "@" + framerate);
   videoCapturer.onOutputFormatRequest(width, height, framerate);
 }
 private void closeInternal() {
   if (factory != null && peerConnectionParameters.aecDump) {
     factory.stopAecDump();
   }
   Log.d(TAG, "Closing peer connection.");
   statsTimer.cancel();
   if (peerConnection != null) {
     peerConnection.dispose();
     peerConnection = null;
   }
   Log.d(TAG, "Closing audio source.");
   if (audioSource != null) {
     audioSource.dispose();
     audioSource = null;
   }
   Log.d(TAG, "Stopping capture.");
   if (videoCapturer != null) {
     try {
       videoCapturer.stopCapture();
     } catch (InterruptedException e) {
       throw new RuntimeException(e);
     }
     videoCapturer.dispose();
     videoCapturer = null;
   }
   Log.d(TAG, "Closing video source.");
   if (videoSource != null) {
     videoSource.dispose();
     videoSource = null;
   }
   Log.d(TAG, "Closing peer connection factory.");
   if (factory != null) {
     factory.dispose();
     factory = null;
   }
   options = null;
   Log.d(TAG, "Closing peer connection done.");
   events.onPeerConnectionClosed();
   PeerConnectionFactory.stopInternalTracingCapture();
   PeerConnectionFactory.shutdownInternalTracer();
 }
 private void switchCameraInternal() {
   if (!videoCallEnabled || numberOfCameras < 2 || isError || videoCapturer == null) {
     Log.e(
         TAG,
         "Failed to switch camera. Video: "
             + videoCallEnabled
             + ". Error : "
             + isError
             + ". Number of cameras: "
             + numberOfCameras);
     return; // No video is sent or only one camera is available or error happened.
   }
   Log.d(TAG, "Switch camera");
   videoCapturer.switchCamera(null);
 }