public Camera1Capturer( String cameraName, CameraEventsHandler eventsHandler, boolean captureToTexture) { super(cameraName, eventsHandler, new Camera1Enumerator(captureToTexture)); this.captureToTexture = captureToTexture; }
static synchronized List<CaptureFormat> getSupportedFormats(int cameraId) { if (cachedSupportedFormats == null) { cachedSupportedFormats = new ArrayList<List<CaptureFormat>>(); for (int i = 0; i < CameraEnumerationAndroid.getDeviceCount(); ++i) { cachedSupportedFormats.add(enumerateFormats(i)); } } return cachedSupportedFormats.get(cameraId); }
@Override public boolean isBackFacing(String deviceName) { android.hardware.Camera.CameraInfo info = getCameraInfo(getCameraIndex(deviceName)); return info != null && info.facing == android.hardware.Camera.CameraInfo.CAMERA_FACING_BACK; }
@Override public List<CaptureFormat> getSupportedFormats(String deviceName) { return getSupportedFormats(getCameraIndex(deviceName)); }
/** * @deprecated * Please use Camera1Enumerator.getDeviceNames().length instead. */ @Deprecated public static int getDeviceCount() { return new Camera1Enumerator().getDeviceNames().length; }
/** * @deprecated * Please use Camera1Enumerator.getDeviceNames().get(index) instead. */ @Deprecated public static String getDeviceName(int index) { return new Camera1Enumerator().getDeviceName(index); }
private static CaptureFormat findClosestCaptureFormat( android.hardware.Camera.Parameters parameters, int width, int height, int framerate) { // Find closest supported format for |width| x |height| @ |framerate|. final List<CaptureFormat.FramerateRange> supportedFramerates = Camera1Enumerator.convertFramerates(parameters.getSupportedPreviewFpsRange()); Logging.d(TAG, "Available fps ranges: " + supportedFramerates); final CaptureFormat.FramerateRange fpsRange = CameraEnumerationAndroid.getClosestSupportedFramerateRange(supportedFramerates, framerate); final Size previewSize = CameraEnumerationAndroid.getClosestSupportedSize( Camera1Enumerator.convertSizes(parameters.getSupportedPreviewSizes()), width, height); return new CaptureFormat(previewSize.width, previewSize.height, fpsRange); }
@Override protected void createCameraSession(CameraSession.CreateSessionCallback createSessionCallback, CameraSession.Events events, Context applicationContext, SurfaceTextureHelper surfaceTextureHelper, String cameraName, int width, int height, int framerate) { Camera1Session.create(createSessionCallback, events, captureToTexture, applicationContext, surfaceTextureHelper, Camera1Enumerator.getCameraIndex(cameraName), width, height, framerate); } }
static String getDeviceName(int index) { android.hardware.Camera.CameraInfo info = getCameraInfo(index); if (info == null) { return null; } String facing = (info.facing == android.hardware.Camera.CameraInfo.CAMERA_FACING_FRONT) ? "front" : "back"; return "Camera " + index + ", Facing " + facing + ", Orientation " + info.orientation; } }
private static Size findClosestPictureSize( android.hardware.Camera.Parameters parameters, int width, int height) { return CameraEnumerationAndroid.getClosestSupportedSize( Camera1Enumerator.convertSizes(parameters.getSupportedPictureSizes()), width, height); }
/** * @deprecated * Please use Camera1Enumerator.getDeviceNames() instead. */ @Deprecated public static String[] getDeviceNames() { return new Camera1Enumerator().getDeviceNames(); }
Camera1Enumerator.convertFramerates(parameters.getSupportedPreviewFpsRange()); Logging.d(TAG, "Available fps ranges: " + supportedFramerates); Camera1Enumerator.convertSizes(parameters.getSupportedPreviewSizes()); final Size previewSize = CameraEnumerationAndroid.getClosestSupportedSize(supportedPreviewSizes, width, height); Camera1Enumerator.convertSizes(parameters.getSupportedPictureSizes()), width, height); parameters.setPictureSize(pictureSize.width, pictureSize.height);
public VideoCapturerAndroid( String cameraName, CameraEventsHandler eventsHandler, boolean captureToTexture) { if (android.hardware.Camera.getNumberOfCameras() == 0) { throw new RuntimeException("No cameras available"); } if (cameraName == null || cameraName.equals("")) { this.id = 0; } else { this.id = Camera1Enumerator.getCameraIndex(cameraName); } this.eventsHandler = eventsHandler; isCapturingToTexture = captureToTexture; Logging.d(TAG, "VideoCapturerAndroid isCapturingToTexture : " + isCapturingToTexture); }
/** * Get a camera enumerator * * @param context the context * @return the camera enumerator */ private static CameraEnumerator getCameraEnumerator(Context context) { if (useCamera2(context)) { return new Camera2Enumerator(context); } else { return new Camera1Enumerator(false); } }
@Override public boolean isFrontFacing(String deviceName) { android.hardware.Camera.CameraInfo info = getCameraInfo(getCameraIndex(deviceName)); return info != null && info.facing == android.hardware.Camera.CameraInfo.CAMERA_FACING_FRONT; }
private CameraVideoCapturer createCapturer() { CameraEnumerator enumerator = new Camera1Enumerator(); for (String name : enumerator.getDeviceNames()) { if (enumerator.isFrontFacing(name)) { return enumerator.createCapturer(name, null); } } return null; }
private VideoCapturer createVideoCapturer() { VideoCapturer videoCapturer; if (useCamera2()) { videoCapturer = createCameraCapturer(new Camera2Enumerator(this)); } else { videoCapturer = createCameraCapturer(new Camera1Enumerator(true)); } return videoCapturer; }
private VideoCapturer createVideoCapturer() { VideoCapturer videoCapturer; if (useCamera2()) { videoCapturer = createCameraCapturer(new Camera2Enumerator(this)); } else { videoCapturer = createCameraCapturer(new Camera1Enumerator(true)); } return videoCapturer; }
private VideoCapturer createVideoCapturer() { if (Camera2Enumerator.isSupported(this)) { return createCameraCapturer(new Camera2Enumerator(this)); } else { return createCameraCapturer(new Camera1Enumerator(true)); } }
private VideoCapturer createVideoCapturer() { VideoCapturer videoCapturer; if (useCamera2()) { videoCapturer = createCameraCapturer(new Camera2Enumerator(this)); } else { videoCapturer = createCameraCapturer(new Camera1Enumerator(true)); } return videoCapturer; }