Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
CameraSettings.java
Go to the documentation of this file.
1// Copyright (C) 2026 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3package org.qtproject.qt.android.multimedia.qffmpeg;
4
5import android.hardware.camera2.CameraMetadata;
6import android.hardware.camera2.CaptureRequest;
7import android.util.Range;
8
9// Represents the QCamera settings we should use for
10// a stream or still-photo.
11class CameraSettings {
12 private static final int DEFAULT_FLASH_MODE = CaptureRequest.CONTROL_AE_MODE_ON;
13 private static final int DEFAULT_TORCH_MODE = CameraMetadata.FLASH_MODE_OFF;
14 // Default value in QPlatformCamera is FocusModeAuto, which maps to CONTINUOUS_PICTURE.
15 private static final int DEFAULT_AF_MODE = CaptureRequest.CONTROL_AF_MODE_CONTINUOUS_PICTURE;
16 private static final float DEFAULT_FOCUS_DISTANCE = 1.f;
17 private static final float DEFAULT_ZOOM_FACTOR = 1.0f;
18
19 // Not to be confused with QCamera::FlashMode.
20 // This controls the currently desired CaptureRequest.CONTROL_AE_MODE,
21 // but only for still photos.
22 //
23 // QCamera::FlashMode::FlashOff maps to CaptureRequest.CONTROL_AE_MODE_ON. This implies
24 // regular automatic exposure.
25 // QCamera::FlashMode::FlashAuto maps to CaptureRequest.CONTROL_AE_MODE_ON_AUTO_FLASH.
26 // QCamera::FlashMode::FlashOn should ideally map to
27 // CaptureRequest.CONTROL_AE_MODE_ON_ALWAYS_FLASH, but testing has shown that this is
28 // unreliable. Instead we force flash on using CaptureRequest.FLASH_MODE_ON and
29 // trigger auto-exposure using CaptureRequest.CONTROL_AE_MODE_ON.
30 public int mStillPhotoFlashMode = DEFAULT_FLASH_MODE;
31
32 // Not to be confused with QCamera::TorchMode.
33 // This controls the currently desired CaptureRequest.FLASH_MODE
34 // QCamera::TorchMode::TorchOff maps to CaptureRequest.FLASH_MODE_OFF
35 // QCamera::TorchMode::TorchAuto is not supported.
36 // QCamera::TorhcMode::TorchOn maps to CaptureRequest.FLASH_MODE_TORCH.
37 public int mTorchMode = DEFAULT_TORCH_MODE;
38
39 // Not to be confused with QCamera::FocusMode
40 // This controls the currently desired CaptureRequest.CONTROL_AF_MODE
41 // QCamera::FocusMode::FocusModeAuto maps to CaptureRequest.CONTROL_AF_MODE_CONTINUOUS_PICTURE
42 //
43 // This variable only controls the AF_MODE we desire to apply. If the device
44 // does not support this AF_MODE this will not reflect what the camera is currently doing.
45 public int mAFMode = DEFAULT_AF_MODE;
46
47 // Not to be confused with CaptureRequest.LENS_FOCUS_DISTANCE. This variable stores the
48 // current QCamera::focusDistance. Must be applied whenever the focus-mode is set to
49 // Manual.
50 // Must have the same default value as the one set in QPlatformCamera.
51 public float mFocusDistance = DEFAULT_FOCUS_DISTANCE;
52
53 // Not to be confused with CaptureRequest.CONTROL_ZOOM_RATIO
54 // This matches the current QCamera::zoomFactor of the C++ QCamera object.
55 public float mZoomFactor = DEFAULT_ZOOM_FACTOR;
56
57 Range<Integer> mFpsRange = null;
58
59 public CameraSettings() { }
60
61 public CameraSettings(CameraSettings other) {
62 this.mStillPhotoFlashMode = other.mStillPhotoFlashMode;
63 this.mTorchMode = other.mTorchMode;
64 this.mAFMode = other.mAFMode;
65 this.mFocusDistance = other.mFocusDistance;
66 this.mZoomFactor = other.mZoomFactor;
67 if (other.mFpsRange != null) {
68 this.mFpsRange = new Range<Integer>(other.mFpsRange.getLower(), other.mFpsRange.getUpper());
69 }
70 }
71}