use of android.hardware.camera2.impl.CameraDeviceImpl in project android_frameworks_base by AOSPA.
the class CameraDeviceImpl method createCaptureSessionInternal.
private void createCaptureSessionInternal(InputConfiguration inputConfig, List<OutputConfiguration> outputConfigurations, CameraCaptureSession.StateCallback callback, Handler handler, boolean isConstrainedHighSpeed) throws CameraAccessException {
synchronized (mInterfaceLock) {
if (DEBUG) {
Log.d(TAG, "createCaptureSessionInternal");
}
checkIfCameraClosedOrInError();
if (isConstrainedHighSpeed && inputConfig != null) {
throw new IllegalArgumentException("Constrained high speed session doesn't support" + " input configuration yet.");
}
// After this call completes, the session is not allowed to call into CameraDeviceImpl
if (mCurrentSession != null) {
mCurrentSession.replaceSessionClose();
}
// TODO: dont block for this
boolean configureSuccess = true;
CameraAccessException pendingException = null;
Surface input = null;
try {
// configure streams and then block until IDLE
configureSuccess = configureStreamsChecked(inputConfig, outputConfigurations, isConstrainedHighSpeed);
if (configureSuccess == true && inputConfig != null) {
input = mRemoteDevice.getInputSurface();
}
} catch (CameraAccessException e) {
configureSuccess = false;
pendingException = e;
input = null;
if (DEBUG) {
Log.v(TAG, "createCaptureSession - failed with exception ", e);
}
}
List<Surface> outSurfaces = new ArrayList<>(outputConfigurations.size());
for (OutputConfiguration config : outputConfigurations) {
outSurfaces.add(config.getSurface());
}
// Fire onConfigured if configureOutputs succeeded, fire onConfigureFailed otherwise.
CameraCaptureSessionCore newSession = null;
if (isConstrainedHighSpeed) {
newSession = new CameraConstrainedHighSpeedCaptureSessionImpl(mNextSessionId++, outSurfaces, callback, handler, this, mDeviceHandler, configureSuccess, mCharacteristics);
} else {
newSession = new CameraCaptureSessionImpl(mNextSessionId++, input, outSurfaces, callback, handler, this, mDeviceHandler, configureSuccess);
}
// TODO: wait until current session closes, then create the new session
mCurrentSession = newSession;
if (pendingException != null) {
throw pendingException;
}
mSessionStateCallback = mCurrentSession.getDeviceStateCallback();
}
}
use of android.hardware.camera2.impl.CameraDeviceImpl in project robolectric by robolectric.
the class ShadowCameraManager method openCameraDeviceUserAsync.
@Implementation(minSdk = Build.VERSION_CODES.S)
protected CameraDevice openCameraDeviceUserAsync(String cameraId, CameraDevice.StateCallback callback, Executor executor, int unusedClientUid, int unusedOomScoreOffset) {
CameraCharacteristics characteristics = getCameraCharacteristics(cameraId);
Context context = RuntimeEnvironment.getApplication();
CameraDeviceImpl deviceImpl = ReflectionHelpers.callConstructor(CameraDeviceImpl.class, ClassParameter.from(String.class, cameraId), ClassParameter.from(CameraDevice.StateCallback.class, callback), ClassParameter.from(Executor.class, executor), ClassParameter.from(CameraCharacteristics.class, characteristics), ClassParameter.from(Map.class, Collections.emptyMap()), ClassParameter.from(int.class, context.getApplicationInfo().targetSdkVersion), ClassParameter.from(Context.class, context));
createdCameras.add(deviceImpl);
updateCameraCallback(deviceImpl, callback, null, executor);
executor.execute(() -> callback.onOpened(deviceImpl));
return deviceImpl;
}
use of android.hardware.camera2.impl.CameraDeviceImpl in project robolectric by robolectric.
the class ShadowCameraManager method openCameraDeviceUserAsync.
@Implementation(minSdk = VERSION_CODES.N_MR1, maxSdk = VERSION_CODES.O_MR1)
protected CameraDevice openCameraDeviceUserAsync(String cameraId, CameraDevice.StateCallback callback, Handler handler, final int uid) throws CameraAccessException {
CameraCharacteristics characteristics = getCameraCharacteristics(cameraId);
Context context = reflector(ReflectorCameraManager.class, realObject).getContext();
CameraDeviceImpl deviceImpl;
if (Build.VERSION.SDK_INT == VERSION_CODES.N_MR1) {
deviceImpl = ReflectionHelpers.callConstructor(CameraDeviceImpl.class, ClassParameter.from(String.class, cameraId), ClassParameter.from(CameraDevice.StateCallback.class, callback), ClassParameter.from(Handler.class, handler), ClassParameter.from(CameraCharacteristics.class, characteristics));
} else {
deviceImpl = ReflectionHelpers.callConstructor(CameraDeviceImpl.class, ClassParameter.from(String.class, cameraId), ClassParameter.from(CameraDevice.StateCallback.class, callback), ClassParameter.from(Handler.class, handler), ClassParameter.from(CameraCharacteristics.class, characteristics), ClassParameter.from(int.class, context.getApplicationInfo().targetSdkVersion));
}
createdCameras.add(deviceImpl);
updateCameraCallback(deviceImpl, callback, handler, null);
handler.post(() -> callback.onOpened(deviceImpl));
return deviceImpl;
}
Aggregations