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;
}
Aggregations