Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 29ebb303 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Camera: Add new hidden tag for multiResolutionStream support" into sc-dev

parents faa060ae 1b639e5f
Loading
Loading
Loading
Loading
+27 −0
Original line number Diff line number Diff line
@@ -3165,6 +3165,33 @@ public final class CameraCharacteristics extends CameraMetadata<CameraCharacteri
    public static final Key<android.hardware.camera2.params.MandatoryStreamCombination[]> SCALER_MANDATORY_MAXIMUM_RESOLUTION_STREAM_COMBINATIONS =
            new Key<android.hardware.camera2.params.MandatoryStreamCombination[]>("android.scaler.mandatoryMaximumResolutionStreamCombinations", android.hardware.camera2.params.MandatoryStreamCombination[].class);

    /**
     * <p>Whether the camera device supports multi-resolution input or output streams</p>
     * <p>A logical multi-camera or an ultra high resolution camera may support multi-resolution
     * input or output streams. With multi-resolution output streams, the camera device is able
     * to output different resolution images depending on the current active physical camera or
     * pixel mode. With multi-resolution input streams, the camera device can reprocess images
     * of different resolutions from different physical cameras or sensor pixel modes.</p>
     * <p>When set to TRUE:
     * * For a logical multi-camera, the camera framework derives
     * {@link CameraCharacteristics#SCALER_MULTI_RESOLUTION_STREAM_CONFIGURATION_MAP android.scaler.multiResolutionStreamConfigurationMap} by combining the
     * android.scaler.physicalCameraMultiResolutionStreamConfigurations from its physical
     * cameras.
     * * For an ultra-high resolution sensor camera, the camera framework directly copies
     * the value of android.scaler.physicalCameraMultiResolutionStreamConfigurations to
     * {@link CameraCharacteristics#SCALER_MULTI_RESOLUTION_STREAM_CONFIGURATION_MAP android.scaler.multiResolutionStreamConfigurationMap}.</p>
     * <p><b>Optional</b> - The value for this key may be {@code null} on some devices.</p>
     * <p><b>Limited capability</b> -
     * Present on all camera devices that report being at least {@link CameraCharacteristics#INFO_SUPPORTED_HARDWARE_LEVEL_LIMITED HARDWARE_LEVEL_LIMITED} devices in the
     * {@link CameraCharacteristics#INFO_SUPPORTED_HARDWARE_LEVEL android.info.supportedHardwareLevel} key</p>
     *
     * @see CameraCharacteristics#INFO_SUPPORTED_HARDWARE_LEVEL
     * @see CameraCharacteristics#SCALER_MULTI_RESOLUTION_STREAM_CONFIGURATION_MAP
     * @hide
     */
    public static final Key<Boolean> SCALER_MULTI_RESOLUTION_STREAM_SUPPORTED =
            new Key<Boolean>("android.scaler.multiResolutionStreamSupported", boolean.class);

    /**
     * <p>The area of the image sensor which corresponds to active pixels after any geometric
     * distortion correction has been applied.</p>
+23 −7
Original line number Diff line number Diff line
@@ -379,17 +379,36 @@ public final class CameraManager {
     * <p>For a logical multi-camera, query the map between physical camera id and
     * the physical camera's multi-resolution stream configuration. This map is in turn
     * combined to form the logical camera's multi-resolution stream configuration map.</p>
     *
     * <p>For an ultra high resolution camera, directly use
     * android.scaler.physicalCameraMultiResolutionStreamConfigurations as the camera device's
     * multi-resolution stream configuration map.</p>
     */
    private Map<String, StreamConfiguration[]> getPhysicalCameraMultiResolutionConfigs(
            CameraMetadataNative info, ICameraService cameraService)
            String cameraId, CameraMetadataNative info, ICameraService cameraService)
            throws CameraAccessException {
        HashMap<String, StreamConfiguration[]> multiResolutionStreamConfigurations =
                new HashMap<String, StreamConfiguration[]>();

        Boolean multiResolutionStreamSupported = info.get(
                CameraCharacteristics.SCALER_MULTI_RESOLUTION_STREAM_SUPPORTED);
        if (multiResolutionStreamSupported == null || !multiResolutionStreamSupported) {
            return multiResolutionStreamConfigurations;
        }

        // Query the characteristics of all physical sub-cameras, and combine the multi-resolution
        // stream configurations. Note that framework derived formats such as HEIC and DEPTH_JPEG
        // aren't supported as multi-resolution input or output formats.
        // stream configurations. Alternatively, for ultra-high resolution camera, direclty use
        // its multi-resolution stream configurations. Note that framework derived formats such as
        // HEIC and DEPTH_JPEG aren't supported as multi-resolution input or output formats.
        Set<String> physicalCameraIds = info.getPhysicalCameraIds();
        if (physicalCameraIds.size() == 0 && info.isUltraHighResolutionSensor()) {
            StreamConfiguration[] configs = info.get(CameraCharacteristics.
                    SCALER_PHYSICAL_CAMERA_MULTI_RESOLUTION_STREAM_CONFIGURATIONS);
            if (configs != null) {
                multiResolutionStreamConfigurations.put(cameraId, configs);
            }
            return multiResolutionStreamConfigurations;
        }
        try {
            for (String physicalCameraId : physicalCameraIds) {
                CameraMetadataNative physicalCameraInfo =
@@ -401,9 +420,6 @@ public final class CameraManager {
                    multiResolutionStreamConfigurations.put(physicalCameraId, configs);
                }
            }

            // TODO: If this is an ultra high resolution sensor camera, combine the multi-resolution
            // stream combination from "info" as well.
        } catch (RemoteException e) {
            ServiceSpecificException sse = new ServiceSpecificException(
                    ICameraService.ERROR_DISCONNECTED,
@@ -468,7 +484,7 @@ public final class CameraManager {
                info.setDisplaySize(displaySize);

                Map<String, StreamConfiguration[]> multiResolutionSizeMap =
                        getPhysicalCameraMultiResolutionConfigs(info, cameraService);
                        getPhysicalCameraMultiResolutionConfigs(cameraId, info, cameraService);
                if (multiResolutionSizeMap.size() > 0) {
                    info.setMultiResolutionStreamConfigurationMap(multiResolutionSizeMap);
                }
+12 −2
Original line number Diff line number Diff line
@@ -265,8 +265,18 @@ public class MultiResolutionImageReader implements AutoCloseable {
     * @return a {@link Surface} to use as the target for a capture request.
     */
    public @NonNull Surface getSurface() {
        //TODO: Pick the surface from the reader for default mode stream.
        return mReaders[0].getSurface();
        // Pick the surface of smallest size. This is necessary for an ultra high resolution
        // camera not to default to maximum resolution pixel mode.
        int minReaderSize = mReaders[0].getWidth() * mReaders[0].getHeight();
        Surface candidateSurface = mReaders[0].getSurface();
        for (int i = 1; i < mReaders.length; i++) {
            int readerSize =  mReaders[i].getWidth() * mReaders[i].getHeight();
            if (readerSize < minReaderSize) {
                minReaderSize = readerSize;
                candidateSurface = mReaders[i].getSurface();
            }
        }
        return candidateSurface;
    }

    /**
+4 −1
Original line number Diff line number Diff line
@@ -1322,7 +1322,10 @@ public class CameraMetadataNative implements Parcelable {
        return ret;
    }

    private boolean isUltraHighResolutionSensor() {
    /**
     * @hide
     */
    public boolean isUltraHighResolutionSensor() {
        return isCapabilitySupported(
                CameraCharacteristics.REQUEST_AVAILABLE_CAPABILITIES_ULTRA_HIGH_RESOLUTION_SENSOR);

+0 −1
Original line number Diff line number Diff line
@@ -90,7 +90,6 @@ public final class InputConfiguration {
    public InputConfiguration(@NonNull Collection<MultiResolutionStreamInfo> multiResolutionInputs,
            @Format int format) {
        checkCollectionNotEmpty(multiResolutionInputs, "Input multi-resolution stream info");
        //TODO: Pick the default mode stream info for ultra-high resolution sensor camera
        MultiResolutionStreamInfo info = multiResolutionInputs.iterator().next();
        mWidth = info.getWidth();
        mHeight = info.getHeight();
Loading