Java Code Examples for org.webrtc.CameraVideoCapturer#switchCamera()

The following examples show how to use org.webrtc.CameraVideoCapturer#switchCamera() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: WebRTCEngine.java    From webrtc_android with MIT License 7 votes vote down vote up
@Override
public void switchCamera() {
    if (isSwitch) return;
    isSwitch = true;
    if (captureAndroid == null) return;
    if (captureAndroid instanceof CameraVideoCapturer) {
        CameraVideoCapturer cameraVideoCapturer = (CameraVideoCapturer) captureAndroid;
        try {
            cameraVideoCapturer.switchCamera(new CameraVideoCapturer.CameraSwitchHandler() {
                @Override
                public void onCameraSwitchDone(boolean isFrontCamera) {
                    isSwitch = false;
                }

                @Override
                public void onCameraSwitchError(String errorDescription) {
                    isSwitch = false;
                }
            });
        } catch (Exception e) {
            isSwitch = false;
        }
    } else {
        Log.d(TAG, "Will not switch camera, video caputurer is not a camera");
    }
}
 
Example 2
Source File: PeerConnectionClient.java    From sample-videoRTC with Apache License 2.0 5 votes vote down vote up
private void switchCameraInternal() {
  if (videoCapturer instanceof CameraVideoCapturer) {
    if (!videoCallEnabled || isError) {
      Log.e(TAG, "Failed to switch camera. Video: " + videoCallEnabled + ". Error : " + isError);
      return; // No video is sent or only one camera is available or error happened.
    }
    Log.d(TAG, "Switch camera");
    CameraVideoCapturer cameraVideoCapturer = (CameraVideoCapturer) videoCapturer;
    cameraVideoCapturer.switchCamera(null);
  } else {
    Log.d(TAG, "Will not switch camera, video caputurer is not a camera");
  }
}
 
Example 3
Source File: PeerConnectionClient.java    From janus-gateway-android with MIT License 5 votes vote down vote up
private void switchCameraInternal() {
  if (videoCapturer instanceof CameraVideoCapturer) {
    Log.d(TAG, "Switch camera");
    CameraVideoCapturer cameraVideoCapturer = (CameraVideoCapturer) videoCapturer;
    cameraVideoCapturer.switchCamera(null);
  } else {
    Log.d(TAG, "Will not switch camera, video caputurer is not a camera");
  }
}
 
Example 4
Source File: PeerConnectionClient.java    From voip_android with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private void switchCameraInternal() {
    if (videoCapturer instanceof CameraVideoCapturer) {
        if (!isVideoCallEnabled() || isError || videoCapturer == null) {
            Log.e(TAG, "Failed to switch camera. Video: " + isVideoCallEnabled() + ". Error : " + isError);
            return; // No video is sent or only one camera is available or error happened.
        }
        Log.d(TAG, "Switch camera");
        CameraVideoCapturer cameraVideoCapturer = (CameraVideoCapturer) videoCapturer;
        cameraVideoCapturer.switchCamera(null);
    } else {
        Log.d(TAG, "Will not switch camera, video caputurer is not a camera");
    }
}
 
Example 5
Source File: PeerConnectionClient.java    From restcomm-android-sdk with GNU Affero General Public License v3.0 5 votes vote down vote up
private void switchCameraInternal() {
  if (videoCapturer instanceof CameraVideoCapturer) {
    if (!videoCallEnabled || isError) {
      Log.e(TAG, "Failed to switch camera. Video: " + videoCallEnabled + ". Error : " + isError);
      return; // No video is sent or only one camera is available or error happened.
    }
    Log.d(TAG, "Switch camera");
    CameraVideoCapturer cameraVideoCapturer = (CameraVideoCapturer) videoCapturer;
    cameraVideoCapturer.switchCamera(null);
  } else {
    Log.d(TAG, "Will not switch camera, video caputurer is not a camera");
  }
}