summaryrefslogtreecommitdiffstats
path: root/tests/Camera2Tests
diff options
context:
space:
mode:
authorEino-Ville Talvala <etalvala@google.com>2014-07-02 14:29:26 -0700
committerEino-Ville Talvala <etalvala@google.com>2014-07-06 17:31:14 -0700
commit0a160acf297b583e12a9710c929c4ba9a38f7353 (patch)
tree33147e4171781db62bf31c42be1b3e4bf9ce2722 /tests/Camera2Tests
parent0c116e1573184f33883bc3722277ecc6560ebca9 (diff)
downloadframeworks_base-0a160acf297b583e12a9710c929c4ba9a38f7353.zip
frameworks_base-0a160acf297b583e12a9710c929c4ba9a38f7353.tar.gz
frameworks_base-0a160acf297b583e12a9710c929c4ba9a38f7353.tar.bz2
Camera2: Hide all the deprecated methods and interfaces
Leave them in for now until bundled clients complete updating Change-Id: Ibd0fc971258ce6b649000c48dd7a6716f1ab91d4
Diffstat (limited to 'tests/Camera2Tests')
-rw-r--r--tests/Camera2Tests/SmartCamera/SimpleCamera/Android.mk2
-rw-r--r--tests/Camera2Tests/SmartCamera/SimpleCamera/src/androidx/media/filterfw/samples/simplecamera/Camera2Source.java20
2 files changed, 16 insertions, 6 deletions
diff --git a/tests/Camera2Tests/SmartCamera/SimpleCamera/Android.mk b/tests/Camera2Tests/SmartCamera/SimpleCamera/Android.mk
index 801c81c..4e3675f 100644
--- a/tests/Camera2Tests/SmartCamera/SimpleCamera/Android.mk
+++ b/tests/Camera2Tests/SmartCamera/SimpleCamera/Android.mk
@@ -23,7 +23,7 @@ LOCAL_MODULE_TAGS := tests
LOCAL_PROGUARD_ENABLED := disabled
# comment it out for now since we need use some hidden APIs
-# LOCAL_SDK_VERSION := current
+LOCAL_SDK_VERSION := current
LOCAL_STATIC_JAVA_LIBRARIES := android-ex-camera2
diff --git a/tests/Camera2Tests/SmartCamera/SimpleCamera/src/androidx/media/filterfw/samples/simplecamera/Camera2Source.java b/tests/Camera2Tests/SmartCamera/SimpleCamera/src/androidx/media/filterfw/samples/simplecamera/Camera2Source.java
index 6876f5a..05057f2 100644
--- a/tests/Camera2Tests/SmartCamera/SimpleCamera/src/androidx/media/filterfw/samples/simplecamera/Camera2Source.java
+++ b/tests/Camera2Tests/SmartCamera/SimpleCamera/src/androidx/media/filterfw/samples/simplecamera/Camera2Source.java
@@ -22,6 +22,7 @@ import android.graphics.ImageFormat;
import android.hardware.camera2.CameraAccessException;
import android.hardware.camera2.CameraCharacteristics;
import android.hardware.camera2.CameraDevice;
+import android.hardware.camera2.CameraCaptureSession;
import android.hardware.camera2.CameraManager;
import android.hardware.camera2.CaptureFailure;
import android.hardware.camera2.CaptureRequest;
@@ -37,6 +38,7 @@ import android.util.Log;
import android.view.Surface;
import com.android.ex.camera2.blocking.BlockingCameraManager;
import com.android.ex.camera2.blocking.BlockingCameraManager.BlockingOpenException;
+import com.android.ex.camera2.blocking.BlockingSessionListener;
import androidx.media.filterfw.Filter;
import androidx.media.filterfw.Frame;
import androidx.media.filterfw.FrameImage2D;
@@ -56,6 +58,7 @@ public class Camera2Source extends Filter implements Allocation.OnBufferAvailabl
private static final String TAG = "Camera2Source";
private CameraManager mCameraManager;
private CameraDevice mCamera;
+ private CameraCaptureSession mCameraSession;
private RenderScript mRS;
private Surface mSurface;
private CameraCharacteristics mProperties;
@@ -67,6 +70,8 @@ public class Camera2Source extends Filter implements Allocation.OnBufferAvailabl
private Allocation mAllocationOut;
private Bitmap mBitmap;
+ private static final long SESSION_TIMEOUT_MS = 2000;
+
class MyCameraListener extends CameraManager.AvailabilityListener {
@Override
@@ -83,10 +88,10 @@ public class Camera2Source extends Filter implements Allocation.OnBufferAvailabl
}
- class MyCaptureListener extends CameraDevice.CaptureListener {
+ class MyCaptureListener extends CameraCaptureSession.CaptureListener {
@Override
- public void onCaptureCompleted(CameraDevice camera, CaptureRequest request,
+ public void onCaptureCompleted(CameraCaptureSession camera, CaptureRequest request,
TotalCaptureResult result) {
// TODO Auto-generated method stub
Log.v(TAG, "in onCaptureComplete");
@@ -94,7 +99,7 @@ public class Camera2Source extends Filter implements Allocation.OnBufferAvailabl
}
@Override
- public void onCaptureFailed(CameraDevice camera, CaptureRequest request,
+ public void onCaptureFailed(CameraCaptureSession camera, CaptureRequest request,
CaptureFailure failure) {
// TODO Auto-generated method stub
Log.v(TAG, "onCaptureFailed is being called");
@@ -184,16 +189,21 @@ public class Camera2Source extends Filter implements Allocation.OnBufferAvailabl
surfaces.add(mSurface);
CaptureRequest.Builder mCaptureRequest = null;
try {
- mCamera.configureOutputs(surfaces);
+ BlockingSessionListener blkSession = new BlockingSessionListener();
+
+ mCamera.createCaptureSession(surfaces, blkSession, mHandler);
mCaptureRequest = mCamera.createCaptureRequest(CameraDevice.TEMPLATE_PREVIEW);
mCaptureRequest.addTarget(mSurface);
+
+ mCameraSession = blkSession.waitAndGetSession(SESSION_TIMEOUT_MS);
+
} catch (CameraAccessException e) {
e.printStackTrace();
throw new RuntimeException(e);
}
try {
- mCamera.setRepeatingRequest(mCaptureRequest.build(), new MyCaptureListener(),
+ mCameraSession.setRepeatingRequest(mCaptureRequest.build(), new MyCaptureListener(),
mHandler);
} catch (CameraAccessException e) {
e.printStackTrace();