Search in sources :

Example 1 with CameraEnumerator

use of org.webrtc.CameraEnumerator in project Signal-Android by WhisperSystems.

the class PeerConnectionWrapper method createVideoCapturer.

@Nullable
private CameraVideoCapturer createVideoCapturer(@NonNull Context context) {
    Log.w(TAG, "Camera2 enumerator supported: " + Camera2Enumerator.isSupported(context));
    CameraEnumerator enumerator;
    if (Camera2Enumerator.isSupported(context))
        enumerator = new Camera2Enumerator(context);
    else
        enumerator = new Camera1Enumerator(true);
    String[] deviceNames = enumerator.getDeviceNames();
    for (String deviceName : deviceNames) {
        if (enumerator.isFrontFacing(deviceName)) {
            Log.w(TAG, "Creating front facing camera capturer.");
            final CameraVideoCapturer videoCapturer = enumerator.createCapturer(deviceName, null);
            if (videoCapturer != null) {
                Log.w(TAG, "Found front facing capturer: " + deviceName);
                return videoCapturer;
            }
        }
    }
    for (String deviceName : deviceNames) {
        if (!enumerator.isFrontFacing(deviceName)) {
            Log.w(TAG, "Creating other camera capturer.");
            final CameraVideoCapturer videoCapturer = enumerator.createCapturer(deviceName, null);
            if (videoCapturer != null) {
                Log.w(TAG, "Found other facing capturer: " + deviceName);
                return videoCapturer;
            }
        }
    }
    Log.w(TAG, "Video capture not supported!");
    return null;
}
Also used : Camera1Enumerator(org.webrtc.Camera1Enumerator) CameraEnumerator(org.webrtc.CameraEnumerator) Camera2Enumerator(org.webrtc.Camera2Enumerator) CameraVideoCapturer(org.webrtc.CameraVideoCapturer) Nullable(android.support.annotation.Nullable)

Aggregations

Nullable (android.support.annotation.Nullable)1 Camera1Enumerator (org.webrtc.Camera1Enumerator)1 Camera2Enumerator (org.webrtc.Camera2Enumerator)1 CameraEnumerator (org.webrtc.CameraEnumerator)1 CameraVideoCapturer (org.webrtc.CameraVideoCapturer)1