org.webrtc.Camera2Enumerator Java Examples

The following examples show how to use org.webrtc.Camera2Enumerator. 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 6 votes vote down vote up
/**
 * 创建媒体方式
 *
 * @return VideoCapturer
 */
private VideoCapturer createVideoCapture() {
    VideoCapturer videoCapturer;


    if (screencaptureEnabled) {
        return createScreenCapturer();
    }

    if (Camera2Enumerator.isSupported(mContext)) {
        videoCapturer = createCameraCapture(new Camera2Enumerator(mContext));
    } else {
        videoCapturer = createCameraCapture(new Camera1Enumerator(true));
    }
    return videoCapturer;
}
 
Example #2
Source File: Camera.java    From mollyim-android with GNU General Public License v3.0 5 votes vote down vote up
private @NonNull CameraEnumerator getCameraEnumerator(@NonNull Context context) {
  boolean camera2EnumeratorIsSupported = false;
  try {
    camera2EnumeratorIsSupported = Camera2Enumerator.isSupported(context);
  } catch (final Throwable throwable) {
    Log.w(TAG, "Camera2Enumator.isSupport() threw.", throwable);
  }

  Log.i(TAG, "Camera2 enumerator supported: " + camera2EnumeratorIsSupported);

  return camera2EnumeratorIsSupported ? new FilteredCamera2Enumerator(context)
                                      : new Camera1Enumerator(true);
}
 
Example #3
Source File: PeerConnectionWrapper.java    From bcm-android with GNU General Public License v3.0 5 votes vote down vote up
private @NonNull CameraEnumerator getCameraEnumerator(@NonNull Context context) {
    boolean camera2EnumeratorIsSupported = false;
    try {
        camera2EnumeratorIsSupported = Camera2Enumerator.isSupported(context);
    } catch (final Throwable throwable) {
        ALog.w(TAG, "Camera2Enumator.isSupport() threw. " + throwable.getMessage());
    }

    ALog.i(TAG, "Camera2 enumerator supported: " + camera2EnumeratorIsSupported);

    return camera2EnumeratorIsSupported ? new Camera2Enumerator(context)
            : new Camera1Enumerator(true);
}
 
Example #4
Source File: CallActivity.java    From RTCStartupDemo with GNU General Public License v3.0 5 votes vote down vote up
private VideoCapturer createVideoCapturer() {
    if (Camera2Enumerator.isSupported(this)) {
        return createCameraCapturer(new Camera2Enumerator(this));
    } else {
        return createCameraCapturer(new Camera1Enumerator(true));
    }
}
 
Example #5
Source File: CallActivity.java    From sample-videoRTC with Apache License 2.0 5 votes vote down vote up
private VideoCapturer createVideoCapturer() {
    final VideoCapturer videoCapturer;
    Logging.d(TAG, "Creating capturer using camera2 API.");
    videoCapturer = createCameraCapturer(new Camera2Enumerator(this));
    if (videoCapturer == null) {
        reportError("Failed to open camera");
        return null;
    }
    return videoCapturer;
}
 
Example #6
Source File: MainActivity.java    From janus-gateway-android with MIT License 5 votes vote down vote up
private VideoCapturer createVideoCapturer() {
    VideoCapturer videoCapturer = null;
    if (useCamera2()) {
        Log.d(TAG, "Creating capturer using camera2 API.");
        videoCapturer = createCameraCapturer(new Camera2Enumerator(this));
    } else {
        Log.d(TAG, "Creating capturer using camera1 API.");
        videoCapturer = createCameraCapturer(new Camera1Enumerator(captureToTexture()));
    }
    if (videoCapturer == null) {
        Log.e(TAG, "Failed to open camera");
        return null;
    }
    return videoCapturer;
}
 
Example #7
Source File: WebRTCWrapper.java    From Pix-Art-Messenger with GNU General Public License v3.0 5 votes vote down vote up
private CameraEnumerator getCameraEnumerator() {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        return new Camera2Enumerator(requireContext());
    } else {
        return new Camera1Enumerator();
    }
}
 
Example #8
Source File: WebRTCWrapper.java    From Conversations with GNU General Public License v3.0 5 votes vote down vote up
private CameraEnumerator getCameraEnumerator() {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        return new Camera2Enumerator(requireContext());
    } else {
        return new Camera1Enumerator();
    }
}
 
Example #9
Source File: MainActivity.java    From janus-gateway-android with MIT License 4 votes vote down vote up
private boolean useCamera2() {
    return Camera2Enumerator.isSupported(this);
}
 
Example #10
Source File: VideoCapturers.java    From VideoCRE with MIT License 4 votes vote down vote up
public static VideoCapturer createCamera2Capturer(Context context) {
    return createCameraCapturer(new Camera2Enumerator(context));
}
 
Example #11
Source File: WebRTCActivity.java    From voip_android with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
private boolean useCamera2() {
    return Camera2Enumerator.isSupported(this) && getIntent().getBooleanExtra(EXTRA_CAMERA2, true);
}