Java Code Examples for org.webrtc.CameraEnumerator#createCapturer()

The following examples show how to use org.webrtc.CameraEnumerator#createCapturer() . 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: Camera.java    From mollyim-android with GNU General Public License v3.0 5 votes vote down vote up
private @Nullable CameraVideoCapturer createVideoCapturer(@NonNull CameraEnumerator enumerator,
                                                          @NonNull CameraState.Direction direction)
{
  String[] deviceNames = enumerator.getDeviceNames();
  for (String deviceName : deviceNames) {
    if ((direction == FRONT && enumerator.isFrontFacing(deviceName)) ||
        (direction == BACK  && enumerator.isBackFacing(deviceName)))
      {
        return enumerator.createCapturer(deviceName, null);
      }
  }

  return null;
}
 
Example 2
Source File: RTCCall.java    From meshenger-android with GNU General Public License v3.0 5 votes vote down vote up
private CameraVideoCapturer createCapturer() {
    CameraEnumerator enumerator = new Camera1Enumerator();
    for (String name : enumerator.getDeviceNames()) {
        if (enumerator.isFrontFacing(name)) {
            return enumerator.createCapturer(name, null);
        }
    }
    return null;
}
 
Example 3
Source File: PeerConnectionWrapper.java    From bcm-android with GNU General Public License v3.0 5 votes vote down vote up
private @Nullable CameraVideoCapturer createVideoCapturer(@NonNull CameraEnumerator enumerator, @NonNull CameraState.Direction direction) {
    String[] deviceNames = enumerator.getDeviceNames();
    for (String deviceName : deviceNames) {
        if ((direction == FRONT && enumerator.isFrontFacing(deviceName)) || (direction == BACK  && enumerator.isBackFacing(deviceName))) {
            return enumerator.createCapturer(deviceName, null);
        }
    }

    return null;
}
 
Example 4
Source File: RTCCall.java    From Meshenger with GNU General Public License v3.0 5 votes vote down vote up
private CameraVideoCapturer createCapturer() {
    CameraEnumerator enumerator = new Camera1Enumerator();
    for (String name : enumerator.getDeviceNames()) {
        if (enumerator.isFrontFacing(name)) {
            return enumerator.createCapturer(name, null);
        }
    }
    return null;
}
 
Example 5
Source File: WebRTCWrapper.java    From Pix-Art-Messenger with GNU General Public License v3.0 5 votes vote down vote up
@Nullable
private static CapturerChoice of(CameraEnumerator enumerator, final String deviceName, Set<String> availableCameras) {
    final CameraVideoCapturer capturer = enumerator.createCapturer(deviceName, null);
    if (capturer == null) {
        return null;
    }
    final ArrayList<CameraEnumerationAndroid.CaptureFormat> choices = new ArrayList<>(enumerator.getSupportedFormats(deviceName));
    Collections.sort(choices, (a, b) -> b.width - a.width);
    for (final CameraEnumerationAndroid.CaptureFormat captureFormat : choices) {
        if (captureFormat.width <= CAPTURING_RESOLUTION) {
            return new CapturerChoice(capturer, captureFormat, availableCameras);
        }
    }
    return null;
}
 
Example 6
Source File: WebRTCWrapper.java    From Conversations with GNU General Public License v3.0 5 votes vote down vote up
@Nullable
private static CapturerChoice of(CameraEnumerator enumerator, final String deviceName, Set<String> availableCameras) {
    final CameraVideoCapturer capturer = enumerator.createCapturer(deviceName, null);
    if (capturer == null) {
        return null;
    }
    final ArrayList<CameraEnumerationAndroid.CaptureFormat> choices = new ArrayList<>(enumerator.getSupportedFormats(deviceName));
    Collections.sort(choices, (a, b) -> b.width - a.width);
    for (final CameraEnumerationAndroid.CaptureFormat captureFormat : choices) {
        if (captureFormat.width <= CAPTURING_RESOLUTION) {
            return new CapturerChoice(capturer, captureFormat, availableCameras);
        }
    }
    return null;
}