Search in sources :

Example 76 with StreamConfigurationMap

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

the class CameraDeviceImpl method createConstrainedHighSpeedCaptureSession.

@Override
public void createConstrainedHighSpeedCaptureSession(List<Surface> outputs, android.hardware.camera2.CameraCaptureSession.StateCallback callback, Handler handler) throws CameraAccessException {
    if (outputs == null || outputs.size() == 0 || outputs.size() > 2) {
        throw new IllegalArgumentException("Output surface list must not be null and the size must be no more than 2");
    }
    StreamConfigurationMap config = getCharacteristics().get(CameraCharacteristics.SCALER_STREAM_CONFIGURATION_MAP);
    SurfaceUtils.checkConstrainedHighSpeedSurfaces(outputs, /*fpsRange*/
    null, config);
    List<OutputConfiguration> outConfigurations = new ArrayList<>(outputs.size());
    for (Surface surface : outputs) {
        outConfigurations.add(new OutputConfiguration(surface));
    }
    createCaptureSessionInternal(null, outConfigurations, callback, handler, /*isConstrainedHighSpeed*/
    true);
}
Also used : OutputConfiguration(android.hardware.camera2.params.OutputConfiguration) ArrayList(java.util.ArrayList) StreamConfigurationMap(android.hardware.camera2.params.StreamConfigurationMap) Surface(android.view.Surface)

Example 77 with StreamConfigurationMap

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

the class CameraTestUtils method getSupportedSizeForClass.

/**
     * Get the available output sizes for the given class.
     *
     */
public static Size[] getSupportedSizeForClass(Class klass, String cameraId, CameraManager cameraManager) throws CameraAccessException {
    CameraCharacteristics properties = cameraManager.getCameraCharacteristics(cameraId);
    assertNotNull("Can't get camera characteristics!", properties);
    if (VERBOSE) {
        Log.v(TAG, "get camera characteristics for camera: " + cameraId);
    }
    StreamConfigurationMap configMap = properties.get(CameraCharacteristics.SCALER_STREAM_CONFIGURATION_MAP);
    Size[] availableSizes = configMap.getOutputSizes(klass);
    assertArrayNotEmpty(availableSizes, "availableSizes should not be empty for class: " + klass);
    Size[] highResAvailableSizes = configMap.getHighResolutionOutputSizes(ImageFormat.PRIVATE);
    if (highResAvailableSizes != null && highResAvailableSizes.length > 0) {
        Size[] allSizes = new Size[availableSizes.length + highResAvailableSizes.length];
        System.arraycopy(availableSizes, 0, allSizes, 0, availableSizes.length);
        System.arraycopy(highResAvailableSizes, 0, allSizes, availableSizes.length, highResAvailableSizes.length);
        availableSizes = allSizes;
    }
    if (VERBOSE)
        Log.v(TAG, "Supported sizes are: " + Arrays.deepToString(availableSizes));
    return availableSizes;
}
Also used : Size(android.util.Size) CameraCharacteristics(android.hardware.camera2.CameraCharacteristics) StreamConfigurationMap(android.hardware.camera2.params.StreamConfigurationMap)

Example 78 with StreamConfigurationMap

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

the class CameraTestUtils method getSupportedSizeForFormat.

/**
     * Get the available output sizes for the user-defined {@code format}.
     *
     * <p>Note that implementation-defined/hidden formats are not supported.</p>
     */
public static Size[] getSupportedSizeForFormat(int format, String cameraId, CameraManager cameraManager) throws CameraAccessException {
    CameraCharacteristics properties = cameraManager.getCameraCharacteristics(cameraId);
    assertNotNull("Can't get camera characteristics!", properties);
    if (VERBOSE) {
        Log.v(TAG, "get camera characteristics for camera: " + cameraId);
    }
    StreamConfigurationMap configMap = properties.get(CameraCharacteristics.SCALER_STREAM_CONFIGURATION_MAP);
    Size[] availableSizes = configMap.getOutputSizes(format);
    assertArrayNotEmpty(availableSizes, "availableSizes should not be empty for format: " + format);
    Size[] highResAvailableSizes = configMap.getHighResolutionOutputSizes(format);
    if (highResAvailableSizes != null && highResAvailableSizes.length > 0) {
        Size[] allSizes = new Size[availableSizes.length + highResAvailableSizes.length];
        System.arraycopy(availableSizes, 0, allSizes, 0, availableSizes.length);
        System.arraycopy(highResAvailableSizes, 0, allSizes, availableSizes.length, highResAvailableSizes.length);
        availableSizes = allSizes;
    }
    if (VERBOSE)
        Log.v(TAG, "Supported sizes are: " + Arrays.deepToString(availableSizes));
    return availableSizes;
}
Also used : Size(android.util.Size) CameraCharacteristics(android.hardware.camera2.CameraCharacteristics) StreamConfigurationMap(android.hardware.camera2.params.StreamConfigurationMap)

Example 79 with StreamConfigurationMap

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

the class StaticMetadata method getAvailableSizesForFormatChecked.

/**
     * Get available sizes for given format and direction, and whether to limit to slow or fast
     * resolutions.
     *
     * @param format The format for the requested size array.
     * @param direction The stream direction, input or output.
     * @param fastSizes whether to include getOutputSizes() sizes (generally faster)
     * @param slowSizes whether to include getHighResolutionOutputSizes() sizes (generally slower)
     * @return The sizes of the given format, empty array if no available size is found.
     */
public Size[] getAvailableSizesForFormatChecked(int format, StreamDirection direction, boolean fastSizes, boolean slowSizes) {
    Key<StreamConfigurationMap> key = CameraCharacteristics.SCALER_STREAM_CONFIGURATION_MAP;
    StreamConfigurationMap config = getValueFromKeyNonNull(key);
    if (config == null) {
        return new Size[0];
    }
    Size[] sizes = null;
    switch(direction) {
        case Output:
            Size[] fastSizeList = null;
            Size[] slowSizeList = null;
            if (fastSizes) {
                fastSizeList = config.getOutputSizes(format);
            }
            if (slowSizes) {
                slowSizeList = config.getHighResolutionOutputSizes(format);
            }
            if (fastSizeList != null && slowSizeList != null) {
                sizes = new Size[slowSizeList.length + fastSizeList.length];
                System.arraycopy(fastSizeList, 0, sizes, 0, fastSizeList.length);
                System.arraycopy(slowSizeList, 0, sizes, fastSizeList.length, slowSizeList.length);
            } else if (fastSizeList != null) {
                sizes = fastSizeList;
            } else if (slowSizeList != null) {
                sizes = slowSizeList;
            }
            break;
        case Input:
            sizes = config.getInputSizes(format);
            break;
        default:
            throw new IllegalArgumentException("direction must be output or input");
    }
    if (sizes == null) {
        sizes = new Size[0];
    }
    return sizes;
}
Also used : Size(android.util.Size) StreamConfigurationMap(android.hardware.camera2.params.StreamConfigurationMap)

Example 80 with StreamConfigurationMap

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

the class StaticMetadata method getAvailableFormats.

/**
     * Get available formats for a given direction.
     *
     * @param direction The stream direction, input or output.
     * @return The formats of the given direction, empty array if no available format is found.
     */
public int[] getAvailableFormats(StreamDirection direction) {
    Key<StreamConfigurationMap> key = CameraCharacteristics.SCALER_STREAM_CONFIGURATION_MAP;
    StreamConfigurationMap config = getValueFromKeyNonNull(key);
    if (config == null) {
        return new int[0];
    }
    switch(direction) {
        case Output:
            return config.getOutputFormats();
        case Input:
            return config.getInputFormats();
        default:
            throw new IllegalArgumentException("direction must be output or input");
    }
}
Also used : StreamConfigurationMap(android.hardware.camera2.params.StreamConfigurationMap)

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