Camera: Enable SurfaceView extension output

Allow Camera2 extension clients to register and use
SurfaceView outputs.

Bug: 245406932
Test:atest -c -d
cts/tests/camera/src/android/hardware/camera2/cts/CameraExtensionCharacteristicsTest.java
atest -c -d
cts/tests/camera/src/android/hardware/camera2/cts/CameraExtensionSessionTest.java
atest -c -d
cts/tests/camera/src/android/hardware/camera2/cts/SurfaceViewExtensionPreviewTest.java

Change-Id: I7b07f3312addea2bc0685b2f1167f17410a5174f
This commit is contained in:
Emilian Peev
2023-02-21 16:49:57 -08:00
parent 84bf2e3a0f
commit 42dde26336
4 changed files with 24 additions and 6 deletions

View File

@@ -541,7 +541,8 @@ public final class CameraExtensionCharacteristics {
private static <T> boolean isOutputSupportedFor(Class<T> klass) {
Objects.requireNonNull(klass, "klass must not be null");
if (klass == android.graphics.SurfaceTexture.class) {
if ((klass == android.graphics.SurfaceTexture.class) ||
(klass == android.view.SurfaceView.class)) {
return true;
}
@@ -725,6 +726,12 @@ public final class CameraExtensionCharacteristics {
* backward compatible cameras whereas other output classes are not guaranteed to be supported.
* </p>
*
* <p>Starting with Android {@link android.os.Build.VERSION_CODES#UPSIDE_DOWN_CAKE}
* {@link android.view.SurfaceView} classes are also guaranteed to be supported and include
* the same resolutions as {@link android.graphics.SurfaceTexture}.
* Clients must set the desired SurfaceView resolution by calling
* {@link android.view.SurfaceHolder#setFixedSize}.</p>
*
* @param extension the extension type
* @param klass a non-{@code null} {@link Class} object reference
* @return non-modifiable list of available sizes or an empty list if the Surface output is not

View File

@@ -62,8 +62,6 @@ import android.os.Handler;
import android.os.HandlerThread;
import android.os.RemoteException;
import android.util.Log;
import android.util.Pair;
import android.util.Range;
import android.util.Size;
import android.view.Surface;
@@ -270,6 +268,10 @@ public final class CameraAdvancedExtensionSessionImpl extends CameraExtensionSes
}
}
// The extension processing logic needs to be able to match images to capture results via
// image and result timestamps.
cameraOutput.setTimestampBase(OutputConfiguration.TIMESTAMP_BASE_SENSOR);
cameraOutput.setReadoutTimestampEnabled(false);
cameraOutput.setPhysicalCameraId(output.physicalCameraId);
outputList.add(cameraOutput);
mCameraConfigMap.put(cameraOutput.getSurface(), output);

View File

@@ -60,7 +60,6 @@ import android.os.RemoteException;
import android.util.Log;
import android.util.LongSparseArray;
import android.util.Pair;
import android.util.Range;
import android.util.Size;
import android.view.Surface;
@@ -478,13 +477,21 @@ public final class CameraExtensionSessionImpl extends CameraExtensionSession {
ArrayList<CaptureStageImpl> sessionParamsList = new ArrayList<>();
ArrayList<OutputConfiguration> outputList = new ArrayList<>();
initializeRepeatingRequestPipeline();
outputList.add(new OutputConfiguration(mCameraRepeatingSurface));
OutputConfiguration previewOutput = new OutputConfiguration(mCameraRepeatingSurface);
// The extension processing logic needs to be able to match images to capture results via
// image and result timestamps.
previewOutput.setTimestampBase(OutputConfiguration.TIMESTAMP_BASE_SENSOR);
previewOutput.setReadoutTimestampEnabled(false);
outputList.add(previewOutput);
CaptureStageImpl previewSessionParams = mPreviewExtender.onPresetSession();
if (previewSessionParams != null) {
sessionParamsList.add(previewSessionParams);
}
initializeBurstCapturePipeline();
outputList.add(new OutputConfiguration(mCameraBurstSurface));
OutputConfiguration captureOutput = new OutputConfiguration(mCameraBurstSurface);
captureOutput.setTimestampBase(OutputConfiguration.TIMESTAMP_BASE_SENSOR);
captureOutput.setReadoutTimestampEnabled(false);
outputList.add(captureOutput);
CaptureStageImpl stillCaptureSessionParams = mImageExtender.onPresetSession();
if (stillCaptureSessionParams != null) {
sessionParamsList.add(stillCaptureSessionParams);

View File

@@ -20,6 +20,7 @@ import android.annotation.NonNull;
import android.annotation.Nullable;
import android.graphics.ImageFormat;
import android.graphics.PixelFormat;
import android.hardware.HardwareBuffer;
import android.hardware.camera2.CameraExtensionCharacteristics;
import android.hardware.camera2.params.OutputConfiguration;
import android.hardware.camera2.params.StreamConfigurationMap;
@@ -149,6 +150,7 @@ public final class CameraExtensionUtils {
SurfaceInfo surfaceInfo = querySurface(config.getSurface());
if ((surfaceInfo.mFormat ==
CameraExtensionCharacteristics.NON_PROCESSING_INPUT_FORMAT) ||
((surfaceInfo.mUsage & HardwareBuffer.USAGE_COMPOSER_OVERLAY) != 0) ||
// The default RGBA_8888 is also implicitly supported because camera will
// internally override it to
// 'CameraExtensionCharacteristics.NON_PROCESSING_INPUT_FORMAT'