Created
May 1, 2017 12:58
-
-
Save vivek1794/b9f2cdfbd4a7295efe17092ccb54ee81 to your computer and use it in GitHub Desktop.
Method to create and return a video capturer for WebRTC using Camera 1 API
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private VideoCapturer createVideoCapturer() { | |
VideoCapturer videoCapturer; | |
videoCapturer = createCameraCapturer(new Camera1Enumerator(false)); | |
return videoCapturer; | |
} | |
private VideoCapturer createCameraCapturer(CameraEnumerator enumerator) { | |
final String[] deviceNames = enumerator.getDeviceNames(); | |
// Trying to find a front facing camera! | |
for (String deviceName : deviceNames) { | |
if (enumerator.isFrontFacing(deviceName)) { | |
VideoCapturer videoCapturer = enumerator.createCapturer(deviceName, null); | |
if (videoCapturer != null) { | |
return videoCapturer; | |
} | |
} | |
} | |
// We were not able to find a front cam. Look for other cameras | |
for (String deviceName : deviceNames) { | |
if (!enumerator.isFrontFacing(deviceName)) { | |
VideoCapturer videoCapturer = enumerator.createCapturer(deviceName, null); | |
if (videoCapturer != null) { | |
return videoCapturer; | |
} | |
} | |
} | |
return null; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment