pull/704/head
Mattia Iavarone 6 years ago
parent 4f677aa9b2
commit 4a9a5ee4d9
  1. 11
      cameraview/src/androidTest/java/com/otaliastudios/cameraview/engine/Camera1IntegrationTest.java
  2. 6
      cameraview/src/androidTest/java/com/otaliastudios/cameraview/engine/Camera2IntegrationTest.java
  3. 5
      cameraview/src/androidTest/java/com/otaliastudios/cameraview/engine/CameraIntegrationTest.java
  4. 8
      cameraview/src/main/java/com/otaliastudios/cameraview/engine/Camera2Engine.java

@ -1,6 +1,13 @@
package com.otaliastudios.cameraview.engine;
import com.otaliastudios.cameraview.CameraLogger;
import com.otaliastudios.cameraview.CameraOptions;
import com.otaliastudios.cameraview.controls.Engine;
import com.otaliastudios.cameraview.frame.Frame;
import com.otaliastudios.cameraview.frame.FrameProcessor;
import com.otaliastudios.cameraview.tools.Op;
import com.otaliastudios.cameraview.tools.Retry;
import com.otaliastudios.cameraview.tools.SdkExclude;
import org.junit.Test;
import org.junit.runner.RunWith;
@ -10,6 +17,10 @@ import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.filters.LargeTest;
import androidx.test.filters.RequiresDevice;
import java.util.Collection;
import static org.junit.Assert.assertNotNull;
/**
* These tests work great on real devices, and are the only way to test actual CameraEngine
* implementation - we really need to open the camera device.

@ -77,4 +77,10 @@ public class Camera2IntegrationTest extends CameraIntegrationTest<Camera2Engine>
if (shouldOpen) closeSync(true);
return result;
}
@Override
public void testFrameProcessing_freezeRelease() {
// Camera2 Frames are not freezable.
// super.testFrameProcessing_freezeRelease();
}
}

@ -1137,20 +1137,17 @@ public abstract class CameraIntegrationTest<E extends CameraBaseEngine> extends
public void testFrameProcessing_format() {
CameraOptions o = openSync(true);
Collection<Integer> formats = o.getSupportedFrameProcessingFormats();
closeSync(true);
for (int format : formats) {
LOG.i("[TEST FRAME FORMAT]", "Testing", format, "...");
Op<Boolean> op = testFrameProcessorFormat(format);
assertNotNull(op.await(DELAY));
}
}
@NonNull
private Op<Boolean> testFrameProcessorFormat(final int format) {
final Op<Boolean> op = new Op<>();
camera.setFrameProcessingFormat(format);
camera.clearFrameProcessors();
camera.addFrameProcessor(new FrameProcessor() {
@Override
public void process(@NonNull Frame frame) {

@ -82,6 +82,7 @@ public class Camera2Engine extends CameraBaseEngine implements
ActionHolder {
private static final int FRAME_PROCESSING_POOL_SIZE = 2;
private static final int FRAME_PROCESSING_FORMAT = ImageFormat.YUV_420_888;
@VisibleForTesting static final long METER_TIMEOUT = 2500;
private final CameraManager mManager;
@ -115,7 +116,8 @@ public class Camera2Engine extends CameraBaseEngine implements
public Camera2Engine(Callback callback) {
super(callback);
mManager = (CameraManager) getCallback().getContext().getSystemService(Context.CAMERA_SERVICE);
mManager = (CameraManager) getCallback().getContext()
.getSystemService(Context.CAMERA_SERVICE);
new LogAction().start(this);
}
@ -1455,6 +1457,8 @@ public class Camera2Engine extends CameraBaseEngine implements
@Override
public void setFrameProcessingFormat(final int format) {
// This is called during initialization. Set our default first.
if (mFrameProcessingFormat == 0) mFrameProcessingFormat = FRAME_PROCESSING_FORMAT;
// Frame processing format is used both when binding and when starting the preview.
// If the value is changed between the two, the preview step can crash.
getOrchestrator().schedule("frame processing format (" + format + ")",
@ -1467,7 +1471,7 @@ public class Camera2Engine extends CameraBaseEngine implements
setFrameProcessingFormat(format);
return;
}
mFrameProcessingFormat = format > 0 ? format : ImageFormat.YUV_420_888;
mFrameProcessingFormat = format > 0 ? format : FRAME_PROCESSING_FORMAT;
if (getState().isAtLeast(CameraState.BIND)) {
restartBind();
}

Loading…
Cancel
Save