Search in sources :

Example 6 with StreamConfigurationMap

use of android.hardware.camera2.params.StreamConfigurationMap in project platform_frameworks_base by android.

the class StaticMetadata method getAvailableMinFrameDurationsForFormatChecked.

/**
     * Get available minimal frame durations for a given format.
     *
     * @param format One of the format from {@link ImageFormat}.
     * @return HashMap of minimal frame durations for different sizes, empty HashMap
     *         if availableMinFrameDurations is null.
     */
public HashMap<Size, Long> getAvailableMinFrameDurationsForFormatChecked(int format) {
    HashMap<Size, Long> minDurationMap = new HashMap<Size, Long>();
    Key<StreamConfigurationMap> key = CameraCharacteristics.SCALER_STREAM_CONFIGURATION_MAP;
    StreamConfigurationMap config = getValueFromKeyNonNull(key);
    if (config == null) {
        return minDurationMap;
    }
    for (Size size : getAvailableSizesForFormatChecked(format, StreamDirection.Output)) {
        long minFrameDuration = config.getOutputMinFrameDuration(format, size);
        if (minFrameDuration != 0) {
            minDurationMap.put(new Size(size.getWidth(), size.getHeight()), minFrameDuration);
        }
    }
    return minDurationMap;
}
Also used : HashMap(java.util.HashMap) Size(android.util.Size) StreamConfigurationMap(android.hardware.camera2.params.StreamConfigurationMap)

Example 7 with StreamConfigurationMap

use of android.hardware.camera2.params.StreamConfigurationMap in project platform_frameworks_base by android.

the class StaticMetadata method getValidOutputFormatsForInput.

/**
     * Get valid output formats for a given input format.
     *
     * @param inputFormat The input format used to produce the output images.
     * @return The output formats for the given input format, empty array if
     *         no available format is found.
     */
public int[] getValidOutputFormatsForInput(int inputFormat) {
    Key<StreamConfigurationMap> key = CameraCharacteristics.SCALER_STREAM_CONFIGURATION_MAP;
    StreamConfigurationMap config = getValueFromKeyNonNull(key);
    if (config == null) {
        return new int[0];
    }
    return config.getValidOutputFormatsForInput(inputFormat);
}
Also used : StreamConfigurationMap(android.hardware.camera2.params.StreamConfigurationMap)

Example 8 with StreamConfigurationMap

use of android.hardware.camera2.params.StreamConfigurationMap in project cameraview by google.

the class Camera2 method collectCameraInfo.

/**
     * <p>Collects some information from {@link #mCameraCharacteristics}.</p>
     * <p>This rewrites {@link #mPreviewSizes}, {@link #mPictureSizes}, and optionally,
     * {@link #mAspectRatio}.</p>
     */
private void collectCameraInfo() {
    StreamConfigurationMap map = mCameraCharacteristics.get(CameraCharacteristics.SCALER_STREAM_CONFIGURATION_MAP);
    if (map == null) {
        throw new IllegalStateException("Failed to get configuration map: " + mCameraId);
    }
    mPreviewSizes.clear();
    for (android.util.Size size : map.getOutputSizes(mPreview.getOutputClass())) {
        mPreviewSizes.add(new Size(size.getWidth(), size.getHeight()));
    }
    mPictureSizes.clear();
    collectPictureSizes(mPictureSizes, map);
    if (!mPreviewSizes.ratios().contains(mAspectRatio)) {
        mAspectRatio = mPreviewSizes.ratios().iterator().next();
    }
}
Also used : StreamConfigurationMap(android.hardware.camera2.params.StreamConfigurationMap)

Example 9 with StreamConfigurationMap

use of android.hardware.camera2.params.StreamConfigurationMap in project platform_frameworks_base by android.

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");
        }
    }
}
Also used : Size(android.util.Size) StreamConfigurationMap(android.hardware.camera2.params.StreamConfigurationMap)

Example 10 with StreamConfigurationMap

use of android.hardware.camera2.params.StreamConfigurationMap in project platform_frameworks_base by android.

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

StreamConfigurationMap (android.hardware.camera2.params.StreamConfigurationMap)81 Size (android.util.Size)46 ArrayList (java.util.ArrayList)23 CameraCharacteristics (android.hardware.camera2.CameraCharacteristics)16 Surface (android.view.Surface)15 Point (android.graphics.Point)11 StreamConfiguration (android.hardware.camera2.params.StreamConfiguration)10 StreamConfigurationDuration (android.hardware.camera2.params.StreamConfigurationDuration)10 Range (android.util.Range)10 MediaRecorder (android.media.MediaRecorder)6 Camera (android.hardware.Camera)5 CaptureRequest (android.hardware.camera2.CaptureRequest)5 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 OutputConfiguration (android.hardware.camera2.params.OutputConfiguration)5 ReprocessFormatsMap (android.hardware.camera2.params.ReprocessFormatsMap)5 SmallTest (android.test.suitebuilder.annotation.SmallTest)5