Search in sources :

Example 16 with StreamConfiguration

use of android.hardware.camera2.params.StreamConfiguration in project android_frameworks_base by ResurrectionRemix.

the class LegacyMetadataMapper method appendStreamConfig.

private static void appendStreamConfig(ArrayList<StreamConfiguration> configs, int format, List<Camera.Size> sizes) {
    for (Camera.Size size : sizes) {
        StreamConfiguration config = new StreamConfiguration(format, size.width, size.height, /*input*/
        false);
        configs.add(config);
    }
}
Also used : StreamConfiguration(android.hardware.camera2.params.StreamConfiguration) Camera(android.hardware.Camera)

Example 17 with StreamConfiguration

use of android.hardware.camera2.params.StreamConfiguration in project android_frameworks_base by ResurrectionRemix.

the class CameraMetadataNative method getStreamConfigurationMap.

private StreamConfigurationMap getStreamConfigurationMap() {
    StreamConfiguration[] configurations = getBase(CameraCharacteristics.SCALER_AVAILABLE_STREAM_CONFIGURATIONS);
    StreamConfigurationDuration[] minFrameDurations = getBase(CameraCharacteristics.SCALER_AVAILABLE_MIN_FRAME_DURATIONS);
    StreamConfigurationDuration[] stallDurations = getBase(CameraCharacteristics.SCALER_AVAILABLE_STALL_DURATIONS);
    StreamConfiguration[] depthConfigurations = getBase(CameraCharacteristics.DEPTH_AVAILABLE_DEPTH_STREAM_CONFIGURATIONS);
    StreamConfigurationDuration[] depthMinFrameDurations = getBase(CameraCharacteristics.DEPTH_AVAILABLE_DEPTH_MIN_FRAME_DURATIONS);
    StreamConfigurationDuration[] depthStallDurations = getBase(CameraCharacteristics.DEPTH_AVAILABLE_DEPTH_STALL_DURATIONS);
    HighSpeedVideoConfiguration[] highSpeedVideoConfigurations = getBase(CameraCharacteristics.CONTROL_AVAILABLE_HIGH_SPEED_VIDEO_CONFIGURATIONS);
    ReprocessFormatsMap inputOutputFormatsMap = getBase(CameraCharacteristics.SCALER_AVAILABLE_INPUT_OUTPUT_FORMATS_MAP);
    int[] capabilities = getBase(CameraCharacteristics.REQUEST_AVAILABLE_CAPABILITIES);
    boolean listHighResolution = false;
    for (int capability : capabilities) {
        if (capability == CameraCharacteristics.REQUEST_AVAILABLE_CAPABILITIES_BURST_CAPTURE) {
            listHighResolution = true;
            break;
        }
    }
    return new StreamConfigurationMap(configurations, minFrameDurations, stallDurations, depthConfigurations, depthMinFrameDurations, depthStallDurations, highSpeedVideoConfigurations, inputOutputFormatsMap, listHighResolution);
}
Also used : StreamConfigurationDuration(android.hardware.camera2.params.StreamConfigurationDuration) MarshalQueryableStreamConfigurationDuration(android.hardware.camera2.marshal.impl.MarshalQueryableStreamConfigurationDuration) MarshalQueryableStreamConfiguration(android.hardware.camera2.marshal.impl.MarshalQueryableStreamConfiguration) StreamConfiguration(android.hardware.camera2.params.StreamConfiguration) StreamConfigurationMap(android.hardware.camera2.params.StreamConfigurationMap) ReprocessFormatsMap(android.hardware.camera2.params.ReprocessFormatsMap) MarshalQueryableReprocessFormatsMap(android.hardware.camera2.marshal.impl.MarshalQueryableReprocessFormatsMap) MarshalQueryableHighSpeedVideoConfiguration(android.hardware.camera2.marshal.impl.MarshalQueryableHighSpeedVideoConfiguration) HighSpeedVideoConfiguration(android.hardware.camera2.params.HighSpeedVideoConfiguration) Point(android.graphics.Point)

Example 18 with StreamConfiguration

use of android.hardware.camera2.params.StreamConfiguration in project android_frameworks_base by crdroidandroid.

the class LegacyMetadataMapper method mapScalerStreamConfigs.

private static void mapScalerStreamConfigs(CameraMetadataNative m, Camera.Parameters p) {
    ArrayList<StreamConfiguration> availableStreamConfigs = new ArrayList<>();
    /*
         * Implementation-defined (preview, recording, etc) -> use camera1 preview sizes
         * YUV_420_888 cpu callbacks -> use camera1 preview sizes
         * Other preview callbacks (CPU) -> use camera1 preview sizes
         * JPEG still capture -> use camera1 still capture sizes
         *
         * Use platform-internal format constants here, since StreamConfigurationMap does the
         * remapping to public format constants.
         */
    List<Camera.Size> previewSizes = p.getSupportedPreviewSizes();
    List<Camera.Size> jpegSizes = p.getSupportedPictureSizes();
    /*
         * Work-around for b/17589233:
         * - Some HALs's largest preview size aspect ratio does not match the largest JPEG size AR
         * - This causes a large amount of problems with focus/metering because it's relative to
         *   preview, making the difference between the JPEG and preview viewport inaccessible
         * - This boils down to metering or focusing areas being "arbitrarily" cropped
         *   in the capture result.
         * - Work-around the HAL limitations by removing all of the largest preview sizes
         *   until we get one with the same aspect ratio as the jpeg size.
         */
    {
        SizeAreaComparator areaComparator = new SizeAreaComparator();
        // Sort preview to min->max
        Collections.sort(previewSizes, areaComparator);
        Camera.Size maxJpegSize = SizeAreaComparator.findLargestByArea(jpegSizes);
        float jpegAspectRatio = maxJpegSize.width * 1.0f / maxJpegSize.height;
        if (DEBUG) {
            Log.v(TAG, String.format("mapScalerStreamConfigs - largest JPEG area %dx%d, AR=%f", maxJpegSize.width, maxJpegSize.height, jpegAspectRatio));
        }
        // Now remove preview sizes from the end (largest->smallest) until aspect ratio matches
        while (!previewSizes.isEmpty()) {
            // max is always at the end
            int index = previewSizes.size() - 1;
            Camera.Size size = previewSizes.get(index);
            float previewAspectRatio = size.width * 1.0f / size.height;
            if (Math.abs(jpegAspectRatio - previewAspectRatio) >= PREVIEW_ASPECT_RATIO_TOLERANCE) {
                // Assume removing from end is O(1)
                previewSizes.remove(index);
                if (DEBUG) {
                    Log.v(TAG, String.format("mapScalerStreamConfigs - removed preview size %dx%d, AR=%f " + "was not the same", size.width, size.height, previewAspectRatio));
                }
            } else {
                break;
            }
        }
        if (previewSizes.isEmpty()) {
            // Fall-back to the original faulty behavior, but at least work
            Log.w(TAG, "mapScalerStreamConfigs - failed to find any preview size matching " + "JPEG aspect ratio " + jpegAspectRatio);
            previewSizes = p.getSupportedPreviewSizes();
        }
        // Sort again, this time in descending order max->min
        Collections.sort(previewSizes, Collections.reverseOrder(areaComparator));
    }
    appendStreamConfig(availableStreamConfigs, HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED, previewSizes);
    appendStreamConfig(availableStreamConfigs, ImageFormat.YUV_420_888, previewSizes);
    for (int format : p.getSupportedPreviewFormats()) {
        if (ImageFormat.isPublicFormat(format) && format != ImageFormat.NV21) {
            appendStreamConfig(availableStreamConfigs, format, previewSizes);
        } else if (DEBUG) {
            /*
                 *  Do not add any formats unknown to us
                 * (since it would fail runtime checks in StreamConfigurationMap)
                 */
            Log.v(TAG, String.format("mapStreamConfigs - Skipping format %x", format));
        }
    }
    appendStreamConfig(availableStreamConfigs, HAL_PIXEL_FORMAT_BLOB, p.getSupportedPictureSizes());
    /*
         * scaler.availableStreamConfigurations
         */
    m.set(SCALER_AVAILABLE_STREAM_CONFIGURATIONS, availableStreamConfigs.toArray(new StreamConfiguration[0]));
    /*
         * scaler.availableMinFrameDurations
         */
    // No frame durations available
    m.set(SCALER_AVAILABLE_MIN_FRAME_DURATIONS, new StreamConfigurationDuration[0]);
    StreamConfigurationDuration[] jpegStalls = new StreamConfigurationDuration[jpegSizes.size()];
    int i = 0;
    long longestStallDuration = -1;
    for (Camera.Size s : jpegSizes) {
        long stallDuration = calculateJpegStallDuration(s);
        jpegStalls[i++] = new StreamConfigurationDuration(HAL_PIXEL_FORMAT_BLOB, s.width, s.height, stallDuration);
        if (longestStallDuration < stallDuration) {
            longestStallDuration = stallDuration;
        }
    }
    /*
         * scaler.availableStallDurations
         */
    // Set stall durations for jpeg, other formats use default stall duration
    m.set(SCALER_AVAILABLE_STALL_DURATIONS, jpegStalls);
    /*
         * sensor.info.maxFrameDuration
         */
    m.set(SENSOR_INFO_MAX_FRAME_DURATION, longestStallDuration);
}
Also used : StreamConfigurationDuration(android.hardware.camera2.params.StreamConfigurationDuration) Size(android.util.Size) ArrayList(java.util.ArrayList) StreamConfiguration(android.hardware.camera2.params.StreamConfiguration) Camera(android.hardware.Camera)

Example 19 with StreamConfiguration

use of android.hardware.camera2.params.StreamConfiguration in project android_frameworks_base by crdroidandroid.

the class LegacyMetadataMapper method appendStreamConfig.

private static void appendStreamConfig(ArrayList<StreamConfiguration> configs, int format, List<Camera.Size> sizes) {
    for (Camera.Size size : sizes) {
        StreamConfiguration config = new StreamConfiguration(format, size.width, size.height, /*input*/
        false);
        configs.add(config);
    }
}
Also used : StreamConfiguration(android.hardware.camera2.params.StreamConfiguration) Camera(android.hardware.Camera)

Example 20 with StreamConfiguration

use of android.hardware.camera2.params.StreamConfiguration in project android_frameworks_base by crdroidandroid.

the class CameraMetadataNative method getStreamConfigurationMap.

private StreamConfigurationMap getStreamConfigurationMap() {
    StreamConfiguration[] configurations = getBase(CameraCharacteristics.SCALER_AVAILABLE_STREAM_CONFIGURATIONS);
    StreamConfigurationDuration[] minFrameDurations = getBase(CameraCharacteristics.SCALER_AVAILABLE_MIN_FRAME_DURATIONS);
    StreamConfigurationDuration[] stallDurations = getBase(CameraCharacteristics.SCALER_AVAILABLE_STALL_DURATIONS);
    StreamConfiguration[] depthConfigurations = getBase(CameraCharacteristics.DEPTH_AVAILABLE_DEPTH_STREAM_CONFIGURATIONS);
    StreamConfigurationDuration[] depthMinFrameDurations = getBase(CameraCharacteristics.DEPTH_AVAILABLE_DEPTH_MIN_FRAME_DURATIONS);
    StreamConfigurationDuration[] depthStallDurations = getBase(CameraCharacteristics.DEPTH_AVAILABLE_DEPTH_STALL_DURATIONS);
    HighSpeedVideoConfiguration[] highSpeedVideoConfigurations = getBase(CameraCharacteristics.CONTROL_AVAILABLE_HIGH_SPEED_VIDEO_CONFIGURATIONS);
    ReprocessFormatsMap inputOutputFormatsMap = getBase(CameraCharacteristics.SCALER_AVAILABLE_INPUT_OUTPUT_FORMATS_MAP);
    int[] capabilities = getBase(CameraCharacteristics.REQUEST_AVAILABLE_CAPABILITIES);
    boolean listHighResolution = false;
    for (int capability : capabilities) {
        if (capability == CameraCharacteristics.REQUEST_AVAILABLE_CAPABILITIES_BURST_CAPTURE) {
            listHighResolution = true;
            break;
        }
    }
    return new StreamConfigurationMap(configurations, minFrameDurations, stallDurations, depthConfigurations, depthMinFrameDurations, depthStallDurations, highSpeedVideoConfigurations, inputOutputFormatsMap, listHighResolution);
}
Also used : StreamConfigurationDuration(android.hardware.camera2.params.StreamConfigurationDuration) MarshalQueryableStreamConfigurationDuration(android.hardware.camera2.marshal.impl.MarshalQueryableStreamConfigurationDuration) MarshalQueryableStreamConfiguration(android.hardware.camera2.marshal.impl.MarshalQueryableStreamConfiguration) StreamConfiguration(android.hardware.camera2.params.StreamConfiguration) StreamConfigurationMap(android.hardware.camera2.params.StreamConfigurationMap) ReprocessFormatsMap(android.hardware.camera2.params.ReprocessFormatsMap) MarshalQueryableReprocessFormatsMap(android.hardware.camera2.marshal.impl.MarshalQueryableReprocessFormatsMap) MarshalQueryableHighSpeedVideoConfiguration(android.hardware.camera2.marshal.impl.MarshalQueryableHighSpeedVideoConfiguration) HighSpeedVideoConfiguration(android.hardware.camera2.params.HighSpeedVideoConfiguration) Point(android.graphics.Point)

Aggregations

StreamConfiguration (android.hardware.camera2.params.StreamConfiguration)15 Point (android.graphics.Point)10 Camera (android.hardware.Camera)10 StreamConfigurationDuration (android.hardware.camera2.params.StreamConfigurationDuration)10 StreamConfigurationMap (android.hardware.camera2.params.StreamConfigurationMap)10 MarshalQueryableHighSpeedVideoConfiguration (android.hardware.camera2.marshal.impl.MarshalQueryableHighSpeedVideoConfiguration)5 MarshalQueryableReprocessFormatsMap (android.hardware.camera2.marshal.impl.MarshalQueryableReprocessFormatsMap)5 MarshalQueryableStreamConfiguration (android.hardware.camera2.marshal.impl.MarshalQueryableStreamConfiguration)5 MarshalQueryableStreamConfigurationDuration (android.hardware.camera2.marshal.impl.MarshalQueryableStreamConfigurationDuration)5 HighSpeedVideoConfiguration (android.hardware.camera2.params.HighSpeedVideoConfiguration)5 ReprocessFormatsMap (android.hardware.camera2.params.ReprocessFormatsMap)5 SmallTest (android.test.suitebuilder.annotation.SmallTest)5 Size (android.util.Size)5 ArrayList (java.util.ArrayList)5