Camera2: Add support for extension specific session types
Allow extension vendors to specify the camera capture session type. Bug: 254351814 Test: Camera CTS Change-Id: I36d70f6f168cd51f19ea517a98428c02a96842cc
This commit is contained in:
@@ -24,4 +24,5 @@ parcelable CameraSessionConfig
|
||||
List<CameraOutputConfig> outputConfigs;
|
||||
CameraMetadataNative sessionParameter;
|
||||
int sessionTemplateId;
|
||||
int sessionType;
|
||||
}
|
||||
|
||||
@@ -31,6 +31,7 @@ interface IImageCaptureExtenderImpl
|
||||
@nullable CaptureStageImpl onPresetSession();
|
||||
@nullable CaptureStageImpl onEnableSession();
|
||||
@nullable CaptureStageImpl onDisableSession();
|
||||
int getSessionType();
|
||||
|
||||
boolean isExtensionAvailable(in String cameraId, in CameraMetadataNative chars);
|
||||
void init(in String cameraId, in CameraMetadataNative chars);
|
||||
|
||||
@@ -34,6 +34,7 @@ interface IPreviewExtenderImpl
|
||||
void init(in String cameraId, in CameraMetadataNative chars);
|
||||
boolean isExtensionAvailable(in String cameraId, in CameraMetadataNative chars);
|
||||
@nullable CaptureStageImpl getCaptureStage();
|
||||
int getSessionType();
|
||||
|
||||
const int PROCESSOR_TYPE_REQUEST_UPDATE_ONLY = 0;
|
||||
const int PROCESSOR_TYPE_IMAGE_PROCESSOR = 1;
|
||||
|
||||
@@ -243,9 +243,16 @@ public final class CameraAdvancedExtensionSessionImpl extends CameraExtensionSes
|
||||
mCameraConfigMap.put(cameraOutput.getSurface(), output);
|
||||
}
|
||||
|
||||
SessionConfiguration sessionConfiguration = new SessionConfiguration(
|
||||
SessionConfiguration.SESSION_REGULAR, outputList,
|
||||
new CameraExtensionUtils.HandlerExecutor(mHandler), new SessionStateHandler());
|
||||
int sessionType = SessionConfiguration.SESSION_REGULAR;
|
||||
if (sessionConfig.sessionType != -1 &&
|
||||
(sessionConfig.sessionType != SessionConfiguration.SESSION_HIGH_SPEED)) {
|
||||
sessionType = sessionConfig.sessionType;
|
||||
Log.v(TAG, "Using session type: " + sessionType);
|
||||
}
|
||||
|
||||
SessionConfiguration sessionConfiguration = new SessionConfiguration(sessionType,
|
||||
outputList, new CameraExtensionUtils.HandlerExecutor(mHandler),
|
||||
new SessionStateHandler());
|
||||
|
||||
if ((sessionConfig.sessionParameter != null) &&
|
||||
(!sessionConfig.sessionParameter.isEmpty())) {
|
||||
|
||||
@@ -415,6 +415,18 @@ public final class CameraExtensionSessionImpl extends CameraExtensionSession {
|
||||
"Session already initialized");
|
||||
return;
|
||||
}
|
||||
int previewSessionType = mPreviewExtender.getSessionType();
|
||||
int imageSessionType = mImageExtender.getSessionType();
|
||||
if (previewSessionType != imageSessionType) {
|
||||
throw new IllegalStateException("Preview extender session type: " + previewSessionType +
|
||||
"and image extender session type: " + imageSessionType + " mismatch!");
|
||||
}
|
||||
int sessionType = SessionConfiguration.SESSION_REGULAR;
|
||||
if ((previewSessionType != -1) &&
|
||||
(previewSessionType != SessionConfiguration.SESSION_HIGH_SPEED)) {
|
||||
sessionType = previewSessionType;
|
||||
Log.v(TAG, "Using session type: " + sessionType);
|
||||
}
|
||||
|
||||
ArrayList<CaptureStageImpl> sessionParamsList = new ArrayList<>();
|
||||
ArrayList<OutputConfiguration> outputList = new ArrayList<>();
|
||||
@@ -432,7 +444,7 @@ public final class CameraExtensionSessionImpl extends CameraExtensionSession {
|
||||
}
|
||||
|
||||
SessionConfiguration sessionConfig = new SessionConfiguration(
|
||||
SessionConfiguration.SESSION_REGULAR,
|
||||
sessionType,
|
||||
outputList,
|
||||
new CameraExtensionUtils.HandlerExecutor(mHandler),
|
||||
new SessionStateHandler());
|
||||
|
||||
@@ -19,7 +19,6 @@ import android.app.Service;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.graphics.Camera;
|
||||
import android.graphics.GraphicBuffer;
|
||||
import android.graphics.Rect;
|
||||
import android.hardware.HardwareBuffer;
|
||||
@@ -124,26 +123,31 @@ public class CameraExtensionsProxyService extends Service {
|
||||
|
||||
private static final String CAMERA_EXTENSION_VERSION_NAME =
|
||||
"androidx.camera.extensions.impl.ExtensionVersionImpl";
|
||||
private static final String LATEST_VERSION = "1.3.0";
|
||||
private static final String LATEST_VERSION = "1.4.0";
|
||||
// No support for the init sequence
|
||||
private static final String NON_INIT_VERSION_PREFIX = "1.0";
|
||||
// Support advanced API and latency queries
|
||||
private static final String ADVANCED_VERSION_PREFIX = "1.2";
|
||||
// Support for the capture request & result APIs
|
||||
private static final String RESULTS_VERSION_PREFIX = "1.3";
|
||||
private static final String[] ADVANCED_VERSION_PREFIXES = {ADVANCED_VERSION_PREFIX,
|
||||
RESULTS_VERSION_PREFIX};
|
||||
private static final String[] SUPPORTED_VERSION_PREFIXES = {RESULTS_VERSION_PREFIX,
|
||||
ADVANCED_VERSION_PREFIX, "1.1", NON_INIT_VERSION_PREFIX};
|
||||
// Support for various latency improvements
|
||||
private static final String LATENCY_VERSION_PREFIX = "1.4";
|
||||
private static final String[] ADVANCED_VERSION_PREFIXES = {LATENCY_VERSION_PREFIX,
|
||||
ADVANCED_VERSION_PREFIX, RESULTS_VERSION_PREFIX };
|
||||
private static final String[] SUPPORTED_VERSION_PREFIXES = {LATENCY_VERSION_PREFIX,
|
||||
RESULTS_VERSION_PREFIX, ADVANCED_VERSION_PREFIX, "1.1", NON_INIT_VERSION_PREFIX};
|
||||
private static final boolean EXTENSIONS_PRESENT = checkForExtensions();
|
||||
private static final String EXTENSIONS_VERSION = EXTENSIONS_PRESENT ?
|
||||
(new ExtensionVersionImpl()).checkApiVersion(LATEST_VERSION) : null;
|
||||
private static final boolean LATENCY_API_SUPPORTED = checkForLatencyAPI();
|
||||
private static final boolean LATENCY_IMPROVEMENTS_SUPPORTED = EXTENSIONS_PRESENT &&
|
||||
(EXTENSIONS_VERSION.startsWith(LATENCY_VERSION_PREFIX));
|
||||
private static final boolean ADVANCED_API_SUPPORTED = checkForAdvancedAPI();
|
||||
private static final boolean INIT_API_SUPPORTED = EXTENSIONS_PRESENT &&
|
||||
(!EXTENSIONS_VERSION.startsWith(NON_INIT_VERSION_PREFIX));
|
||||
private static final boolean RESULT_API_SUPPORTED = EXTENSIONS_PRESENT &&
|
||||
(EXTENSIONS_VERSION.startsWith(RESULTS_VERSION_PREFIX));
|
||||
(EXTENSIONS_VERSION.startsWith(RESULTS_VERSION_PREFIX) ||
|
||||
EXTENSIONS_VERSION.startsWith(LATENCY_VERSION_PREFIX));
|
||||
|
||||
private HashMap<String, CameraCharacteristics> mCharacteristicsHashMap = new HashMap<>();
|
||||
private HashMap<String, Long> mMetadataVendorIdMap = new HashMap<>();
|
||||
@@ -1169,6 +1173,10 @@ public class CameraExtensionsProxyService extends Service {
|
||||
ret.outputConfigs.add(entry);
|
||||
}
|
||||
ret.sessionTemplateId = sessionConfig.getSessionTemplateId();
|
||||
ret.sessionType = -1;
|
||||
if (LATENCY_IMPROVEMENTS_SUPPORTED) {
|
||||
ret.sessionType = sessionConfig.getSessionType();
|
||||
}
|
||||
ret.sessionParameter = initializeParcelableMetadata(
|
||||
sessionConfig.getSessionParameters(), cameraId);
|
||||
mCameraId = cameraId;
|
||||
@@ -1311,6 +1319,15 @@ public class CameraExtensionsProxyService extends Service {
|
||||
return initializeParcelable(mPreviewExtender.getCaptureStage(), mCameraId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSessionType() {
|
||||
if (LATENCY_IMPROVEMENTS_SUPPORTED) {
|
||||
return mPreviewExtender.onSessionType();
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getProcessorType() {
|
||||
ProcessorType processorType = mPreviewExtender.getProcessorType();
|
||||
@@ -1406,6 +1423,15 @@ public class CameraExtensionsProxyService extends Service {
|
||||
return initializeParcelable(mImageExtender.onDisableSession(), mCameraId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSessionType() {
|
||||
if (LATENCY_IMPROVEMENTS_SUPPORTED) {
|
||||
return mImageExtender.onSessionType();
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(String cameraId, CameraMetadataNative chars) {
|
||||
CameraCharacteristics c = new CameraCharacteristics(chars);
|
||||
|
||||
Reference in New Issue
Block a user