use of android.hardware.camera2.params.InputConfiguration in project android_frameworks_base by crdroidandroid.
the class CameraDeviceImpl method createReprocessableCaptureSessionByConfigurations.
@Override
public void createReprocessableCaptureSessionByConfigurations(InputConfiguration inputConfig, List<OutputConfiguration> outputs, android.hardware.camera2.CameraCaptureSession.StateCallback callback, Handler handler) throws CameraAccessException {
if (DEBUG) {
Log.d(TAG, "createReprocessableCaptureSessionWithConfigurations");
}
if (inputConfig == null) {
throw new IllegalArgumentException("inputConfig cannot be null when creating a " + "reprocessable capture session");
}
if (outputs == null) {
throw new IllegalArgumentException("Output configurations cannot be null when " + "creating a reprocessable capture session");
}
// OutputConfiguration objects aren't immutable, make a copy before using.
List<OutputConfiguration> currentOutputs = new ArrayList<OutputConfiguration>();
for (OutputConfiguration output : outputs) {
currentOutputs.add(new OutputConfiguration(output));
}
createCaptureSessionInternal(inputConfig, currentOutputs, callback, handler, /*isConstrainedHighSpeed*/
false);
}
use of android.hardware.camera2.params.InputConfiguration in project android_frameworks_base by crdroidandroid.
the class CameraTestUtils method configureReprocessableCameraSession.
public static CameraCaptureSession configureReprocessableCameraSession(CameraDevice camera, InputConfiguration inputConfiguration, List<Surface> outputSurfaces, CameraCaptureSession.StateCallback listener, Handler handler) throws CameraAccessException {
BlockingSessionCallback sessionListener = new BlockingSessionCallback(listener);
camera.createReprocessableCaptureSession(inputConfiguration, outputSurfaces, sessionListener, handler);
Integer[] sessionStates = { BlockingSessionCallback.SESSION_READY, BlockingSessionCallback.SESSION_CONFIGURE_FAILED };
int state = sessionListener.getStateWaiter().waitForAnyOfStates(Arrays.asList(sessionStates), SESSION_CONFIGURE_TIMEOUT_MS);
assertTrue("Creating a reprocessable session failed.", state == BlockingSessionCallback.SESSION_READY);
CameraCaptureSession session = sessionListener.waitAndGetSession(SESSION_CONFIGURE_TIMEOUT_MS);
assertTrue("Camera session should be a reprocessable session", session.isReprocessable());
return session;
}
use of android.hardware.camera2.params.InputConfiguration in project android_frameworks_base by AOSPA.
the class Camera2ReprocessCaptureTest method setupReprocessableSession.
/**
* Set up a reprocessable session and create an ImageWriter with the sessoin's input surface.
*/
private void setupReprocessableSession(Surface previewSurface, int numImageWriterImages) throws Exception {
// create a reprocessable capture session
List<Surface> outSurfaces = new ArrayList<Surface>();
outSurfaces.add(mFirstImageReader.getSurface());
if (!mShareOneImageReader) {
outSurfaces.add(mSecondImageReader.getSurface());
}
if (previewSurface != null) {
outSurfaces.add(previewSurface);
}
InputConfiguration inputConfig = new InputConfiguration(mFirstImageReader.getWidth(), mFirstImageReader.getHeight(), mFirstImageReader.getImageFormat());
String inputConfigString = inputConfig.toString();
if (VERBOSE) {
Log.v(TAG, "InputConfiguration: " + inputConfigString);
}
assertTrue(String.format("inputConfig is wrong: %dx%d format %d. Expect %dx%d format %d", inputConfig.getWidth(), inputConfig.getHeight(), inputConfig.getFormat(), mFirstImageReader.getWidth(), mFirstImageReader.getHeight(), mFirstImageReader.getImageFormat()), inputConfig.getWidth() == mFirstImageReader.getWidth() && inputConfig.getHeight() == mFirstImageReader.getHeight() && inputConfig.getFormat() == mFirstImageReader.getImageFormat());
mSessionListener = new BlockingSessionCallback();
mSession = configureReprocessableCameraSession(mCamera, inputConfig, outSurfaces, mSessionListener, mHandler);
// create an ImageWriter
mInputSurface = mSession.getInputSurface();
mImageWriter = ImageWriter.newInstance(mInputSurface, numImageWriterImages);
mImageWriterListener = new SimpleImageWriterListener(mImageWriter);
mImageWriter.setOnImageReleasedListener(mImageWriterListener, mHandler);
}
use of android.hardware.camera2.params.InputConfiguration in project android_frameworks_base by AOSPA.
the class CameraDeviceImpl method createReprocessableCaptureSession.
@Override
public void createReprocessableCaptureSession(InputConfiguration inputConfig, List<Surface> outputs, CameraCaptureSession.StateCallback callback, Handler handler) throws CameraAccessException {
if (DEBUG) {
Log.d(TAG, "createReprocessableCaptureSession");
}
if (inputConfig == null) {
throw new IllegalArgumentException("inputConfig cannot be null when creating a " + "reprocessable capture session");
}
List<OutputConfiguration> outConfigurations = new ArrayList<>(outputs.size());
for (Surface surface : outputs) {
outConfigurations.add(new OutputConfiguration(surface));
}
createCaptureSessionInternal(inputConfig, outConfigurations, callback, handler, /*isConstrainedHighSpeed*/
false);
}
use of android.hardware.camera2.params.InputConfiguration in project android_frameworks_base by AOSPA.
the class CameraDeviceImpl method checkInputConfiguration.
private void checkInputConfiguration(InputConfiguration inputConfig) {
if (inputConfig != null) {
StreamConfigurationMap configMap = mCharacteristics.get(CameraCharacteristics.SCALER_STREAM_CONFIGURATION_MAP);
int[] inputFormats = configMap.getInputFormats();
boolean validFormat = false;
for (int format : inputFormats) {
if (format == inputConfig.getFormat()) {
validFormat = true;
}
}
if (validFormat == false) {
throw new IllegalArgumentException("input format " + inputConfig.getFormat() + " is not valid");
}
boolean validSize = false;
Size[] inputSizes = configMap.getInputSizes(inputConfig.getFormat());
for (Size s : inputSizes) {
if (inputConfig.getWidth() == s.getWidth() && inputConfig.getHeight() == s.getHeight()) {
validSize = true;
}
}
if (validSize == false) {
throw new IllegalArgumentException("input size " + inputConfig.getWidth() + "x" + inputConfig.getHeight() + " is not valid");
}
}
}
Aggregations