Search in sources :

Example 66 with StreamConfigurationMap

use of android.hardware.camera2.params.StreamConfigurationMap 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 67 with StreamConfigurationMap

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

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 68 with StreamConfigurationMap

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

the class Camera2RecordingTest method constrainedHighSpeedRecording.

private void constrainedHighSpeedRecording() throws Exception {
    for (String id : mCameraIds) {
        try {
            Log.i(TAG, "Testing constrained high speed recording for camera " + id);
            // Re-use the MediaRecorder object for the same camera device.
            mMediaRecorder = new MediaRecorder();
            openDevice(id);
            if (!mStaticInfo.isConstrainedHighSpeedVideoSupported()) {
                Log.i(TAG, "Camera " + id + " doesn't support high speed recording, skipping.");
                continue;
            }
            // Test iteration starts...
            for (int iteration = 0; iteration < getIterationCount(); ++iteration) {
                Log.v(TAG, String.format("Constrained high speed recording: %d/%d", iteration + 1, getIterationCount()));
                StreamConfigurationMap config = mStaticInfo.getValueFromKeyNonNull(CameraCharacteristics.SCALER_STREAM_CONFIGURATION_MAP);
                Size[] highSpeedVideoSizes = config.getHighSpeedVideoSizes();
                for (Size size : highSpeedVideoSizes) {
                    List<Range<Integer>> fixedFpsRanges = getHighSpeedFixedFpsRangeForSize(config, size);
                    mCollector.expectTrue("Unable to find the fixed frame rate fps range for " + "size " + size, fixedFpsRanges.size() > 0);
                    // Test recording for each FPS range
                    for (Range<Integer> fpsRange : fixedFpsRanges) {
                        int captureRate = fpsRange.getLower();
                        final int VIDEO_FRAME_RATE = 30;
                        // Skip the test if the highest recording FPS supported by CamcorderProfile
                        if (fpsRange.getUpper() > getFpsFromHighSpeedProfileForSize(size)) {
                            Log.w(TAG, "high speed recording " + size + "@" + captureRate + "fps" + " is not supported by CamcorderProfile");
                            continue;
                        }
                        mOutMediaFileName = VIDEO_FILE_PATH + "/test_cslowMo_video_" + captureRate + "fps_" + id + "_" + size.toString() + ".mp4";
                        prepareRecording(size, VIDEO_FRAME_RATE, captureRate);
                        // prepare preview surface by using video size.
                        updatePreviewSurfaceWithVideo(size, captureRate);
                        // Start recording
                        SimpleCaptureCallback resultListener = new SimpleCaptureCallback();
                        startSlowMotionRecording(/*useMediaRecorder*/
                        true, VIDEO_FRAME_RATE, captureRate, fpsRange, resultListener, /*useHighSpeedSession*/
                        true);
                        // Record certain duration.
                        SystemClock.sleep(RECORDING_DURATION_MS);
                        // Stop recording and preview
                        stopRecording(/*useMediaRecorder*/
                        true);
                        // Convert number of frames camera produced into the duration in unit of ms.
                        int durationMs = (int) (resultListener.getTotalNumFrames() * 1000.0f / VIDEO_FRAME_RATE);
                        // Validation.
                        validateRecording(size, durationMs);
                    }
                    getResultPrinter().printStatus(getIterationCount(), iteration + 1, id);
                    Thread.sleep(getTestWaitIntervalMs());
                }
            }
        } finally {
            closeDevice();
            releaseRecorder();
        }
    }
}
Also used : Size(android.util.Size) StreamConfigurationMap(android.hardware.camera2.params.StreamConfigurationMap) MediaRecorder(android.media.MediaRecorder) Range(android.util.Range) SimpleCaptureCallback(com.android.mediaframeworktest.helpers.CameraTestUtils.SimpleCaptureCallback)

Example 69 with StreamConfigurationMap

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

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 70 with StreamConfigurationMap

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

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)

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