Create setHasFrameProcessors API

pull/493/head
Mattia Iavarone 5 years ago
parent ccdc50ea42
commit d9d213e67b
  1. 46
      cameraview/src/androidTest/java/com/otaliastudios/cameraview/engine/MockCameraEngine.java
  2. 10
      cameraview/src/main/java/com/otaliastudios/cameraview/CameraView.java
  3. 4
      cameraview/src/main/java/com/otaliastudios/cameraview/engine/Camera1Engine.java
  4. 36
      cameraview/src/main/java/com/otaliastudios/cameraview/engine/Camera2Engine.java
  5. 11
      cameraview/src/main/java/com/otaliastudios/cameraview/engine/CameraEngine.java

@ -119,10 +119,6 @@ public class MockCameraEngine extends CameraEngine {
mExposureCorrectionChanged = true;
}
@Override
public void setFacing(@NonNull Facing facing) {
mFacing = facing;
}
@Override
public void setFlash(@NonNull Flash flash) {
@ -134,21 +130,11 @@ public class MockCameraEngine extends CameraEngine {
mWhiteBalance = whiteBalance;
}
@Override
public void setMode(@NonNull Mode mode) {
mMode = mode;
}
@Override
public void setHdr(@NonNull Hdr hdr) {
mHdr = hdr;
}
@Override
public void setAudio(@NonNull Audio audio) {
mAudio = audio;
}
@Override
public void setLocation(@Nullable Location location) {
mLocation = location;
@ -165,7 +151,8 @@ public class MockCameraEngine extends CameraEngine {
}
@Override
public void takeVideo(@NonNull VideoResult.Stub stub, @NonNull File file) {
protected void onTakeVideo(@NonNull VideoResult.Stub stub) {
}
@Override
@ -197,4 +184,33 @@ public class MockCameraEngine extends CameraEngine {
public void setPlaySounds(boolean playSounds) {
}
@Override
public void setHasFrameProcessors(boolean hasFrameProcessors) {
}
@Override
protected boolean collectCameraInfo(@NonNull Facing facing) {
return true;
}
/*
@Override
public void setFacing(@NonNull Facing facing) {
mFacing = facing;
}
@Override
public void setMode(@NonNull Mode mode) {
mMode = mode;
}
@Override
public void setAudio(@NonNull Audio audio) {
mAudio = audio;
}
*/
}

@ -1301,6 +1301,9 @@ public class CameraView extends FrameLayout implements LifecycleObserver {
public void addFrameProcessor(@Nullable FrameProcessor processor) {
if (processor != null) {
mFrameProcessors.add(processor);
if (mFrameProcessors.size() == 1) {
mCameraEngine.setHasFrameProcessors(true);
}
}
}
@ -1313,6 +1316,9 @@ public class CameraView extends FrameLayout implements LifecycleObserver {
public void removeFrameProcessor(@Nullable FrameProcessor processor) {
if (processor != null) {
mFrameProcessors.remove(processor);
if (mFrameProcessors.size() == 0) {
mCameraEngine.setHasFrameProcessors(false);
}
}
}
@ -1322,7 +1328,11 @@ public class CameraView extends FrameLayout implements LifecycleObserver {
* to preview frames.
*/
public void clearFrameProcessors() {
boolean had = mFrameProcessors.size() > 0;
mFrameProcessors.clear();
if (had) {
mCameraEngine.setHasFrameProcessors(false);
}
}

@ -279,6 +279,10 @@ public class Camera1Engine extends CameraEngine implements Camera.PreviewCallbac
return false;
}
@Override
public void setHasFrameProcessors(boolean hasFrameProcessors) {
mHasFrameProcessors = hasFrameProcessors;
}
@Override
public void onBufferAvailable(@NonNull byte[] buffer) {

@ -437,6 +437,11 @@ public class Camera2Engine extends CameraEngine {
mPictureRecorder.take();
}
@Override
public void takePicture(@NonNull PictureResult.Stub stub) {
// TODO
}
//endregion
//region Videos
@ -726,32 +731,39 @@ public class Camera2Engine extends CameraEngine {
mPlaySoundsOp.end(null);
}
//endregion
@Override
public void onBufferAvailable(@NonNull byte[] buffer) {
}
@Override
public void setZoom(float zoom, @Nullable PointF[] points, boolean notify) {
// TODO
}
@Override
public void setExposureCorrection(float EVvalue, @NonNull float[] bounds, @Nullable PointF[] points, boolean notify) {
// TODO
}
//endregion
//region FrameProcessing
@Override
public void takePicture(@NonNull PictureResult.Stub stub) {
public void onBufferAvailable(@NonNull byte[] buffer) {
// TODO
}
@Override
public void setHasFrameProcessors(boolean hasFrameProcessors) {
mHasFrameProcessors = hasFrameProcessors;
}
//endregion
//region Auto focus
@Override
public void startAutoFocus(@Nullable Gesture gesture, @NonNull PointF point) {
// TODO
}
//endregion
}

@ -166,6 +166,7 @@ public abstract class CameraEngine implements
protected float mZoomValue;
protected float mExposureCorrectionValue;
protected boolean mPlaySounds;
protected boolean mHasFrameProcessors;
@Nullable private SizeSelector mPreviewStreamSizeSelector;
private SizeSelector mPictureSizeSelector;
@ -916,6 +917,8 @@ public abstract class CameraEngine implements
public abstract void setPlaySounds(boolean playSounds);
public abstract void setHasFrameProcessors(boolean hasFrameProcessors);
//endregion
//region picture and video control
@ -1160,12 +1163,16 @@ public abstract class CameraEngine implements
public final long getAutoFocusResetDelay() { return mAutoFocusResetDelayMillis; }
final boolean shouldResetAutoFocus() {
return mAutoFocusResetDelayMillis > 0 && mAutoFocusResetDelayMillis != Long.MAX_VALUE;
public boolean getHasFrameProcessors() {
return mHasFrameProcessors;
}
//endregion
final boolean shouldResetAutoFocus() {
return mAutoFocusResetDelayMillis > 0 && mAutoFocusResetDelayMillis != Long.MAX_VALUE;
}
//region Orientation utils
private int computeSensorToViewOffset() {

Loading…
Cancel
Save