Add legacy implementation stup

v2
Mattia Iavarone 6 years ago
parent 2cc2f217b6
commit cbc6df035a
  1. 16
      cameraview/src/main/java/com/otaliastudios/cameraview/SnapshotPictureRecorder.java

@ -4,6 +4,7 @@ import android.graphics.ImageFormat;
import android.graphics.Rect; import android.graphics.Rect;
import android.graphics.YuvImage; import android.graphics.YuvImage;
import android.hardware.Camera; import android.hardware.Camera;
import android.opengl.GLSurfaceView;
import java.io.ByteArrayOutputStream; import java.io.ByteArrayOutputStream;
@ -17,6 +18,7 @@ class SnapshotPictureRecorder extends PictureRecorder {
private Camera1 mController; private Camera1 mController;
private Camera mCamera; private Camera mCamera;
private CameraPreview mPreview;
private AspectRatio mOutputRatio; private AspectRatio mOutputRatio;
private Size mSensorPreviewSize; private Size mSensorPreviewSize;
private int mFormat; private int mFormat;
@ -24,6 +26,7 @@ class SnapshotPictureRecorder extends PictureRecorder {
SnapshotPictureRecorder(PictureResult stub, Camera1 controller, Camera camera, AspectRatio viewRatio) { SnapshotPictureRecorder(PictureResult stub, Camera1 controller, Camera camera, AspectRatio viewRatio) {
super(stub, controller); super(stub, controller);
mController = controller; mController = controller;
mPreview = controller.mPreview;
mCamera = camera; mCamera = camera;
mOutputRatio = viewRatio; mOutputRatio = viewRatio;
mFormat = mController.mPreviewFormat; mFormat = mController.mPreviewFormat;
@ -32,6 +35,19 @@ class SnapshotPictureRecorder extends PictureRecorder {
@Override @Override
void take() { void take() {
if (mPreview instanceof GLCameraPreview) {
takeGl((GLCameraPreview) mPreview);
} else {
takeLegacy();
}
}
private void takeGl(GLCameraPreview preview) {
// TODO implement.
takeLegacy();
}
private void takeLegacy() {
mCamera.setOneShotPreviewCallback(new Camera.PreviewCallback() { mCamera.setOneShotPreviewCallback(new Camera.PreviewCallback() {
@Override @Override
public void onPreviewFrame(final byte[] yuv, Camera camera) { public void onPreviewFrame(final byte[] yuv, Camera camera) {

Loading…
Cancel
Save