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
qavfcamerabase_p.h
Go to the documentation of this file.
1// Copyright (C) 2016 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
3
4#ifndef QAVFCAMERABASE_H
5#define QAVFCAMERABASE_H
6
7//
8// W A R N I N G
9// -------------
10//
11// This file is not part of the Qt API. It exists purely as an
12// implementation detail. This header file may change from version to
13// version without notice, or even be removed.
14//
15// We mean it.
16//
17
18#include <QtCore/qobject.h>
19#include <QtMultimedia/private/qplatformcamera_p.h>
20
22
24
25// The purpose of this class is to provide camera controls on
26// both the old native Darwin backend and the FFmpeg backend.
27class Q_MULTIMEDIA_EXPORT QAVFCameraBase : public QPlatformCamera
28{
29Q_OBJECT
30public:
31 QAVFCameraBase(QCamera *camera);
32 ~QAVFCameraBase();
33
34 bool isActive() const override;
35 void setActive(bool active) override final;
36
37 void setCamera(const QCameraDevice &camera) override final;
38 bool setCameraFormat(const QCameraFormat &format) override final;
39
40 void setFocusMode(QCamera::FocusMode mode) override;
41
42 // FocusModeAuto maps to AVCaptureFocusModeContinuousFocusMode.
43 //
44 // FocusModeManual does not map to any specific AVCaptureFocusMode
45 // value, but rather to the setting setFocusModeLockedWithLensPosition.
46 // This setting doesn't actually change the AVCaptureFocusMode but puts it
47 // into a state where the AVCaptureFocusMode no longer applies.
48 // You can go back into autofocus mode by setting the AVCaptureDevice
49 // focus mode.
50 bool isFocusModeSupported(QCamera::FocusMode mode) const override;
51
52 void setCustomFocusPoint(const QPointF &point) override;
53
54 void setFocusDistance(float distance) override;
55 void zoomTo(float factor, float rate) override;
56
57 void setFlashMode(QCamera::FlashMode mode) override;
58 bool isFlashModeSupported(QCamera::FlashMode mode) const override;
59 bool isFlashReady() const override;
60
61 void setTorchMode(QCamera::TorchMode mode) override;
62 bool isTorchModeSupported(QCamera::TorchMode mode) const override;
63
64 void setExposureMode(QCamera::ExposureMode) override;
65 bool isExposureModeSupported(QCamera::ExposureMode mode) const override;
66
67 void setExposureCompensation(float bias) override;
68 void setManualIsoSensitivity(int value) override;
69 virtual int isoSensitivity() const override;
70 void setManualExposureTime(float value) override;
71 virtual float exposureTime() const override;
72
73#ifdef Q_OS_IOS
74 // not supported on macOS
75 bool isWhiteBalanceModeSupported(QCamera::WhiteBalanceMode mode) const override;
76 void setWhiteBalanceMode(QCamera::WhiteBalanceMode /*mode*/) override;
77 void setColorTemperature(int /*temperature*/) override;
78#endif
79
80 AVCaptureDevice *device() const;
81 [[nodiscard]] static AVCaptureDevice* tryGetAvCaptureDevice(const QCameraDevice &device);
82
83protected:
84 // Called by setActive() when the active status is successfully changed.
85 // If called with parameter active = true, camera permissions are
86 // guaranteed to have been granted already.
87 virtual void onActiveChanged(bool active) = 0;
88 // Called by setCamera() when the camera is successfully changed.
89 virtual void onCameraDeviceChanged(const QCameraDevice &device) = 0;
90 // Should be implemented by the backend to apply the camera-format
91 // to the physical camera if possible.
92 // Returns true if the format was successfully applied.
93 [[nodiscard]] virtual bool tryApplyCameraFormat(const QCameraFormat&) = 0;
94
95 bool checkCameraPermission();
96
97 void updateCameraConfiguration();
98 void updateSupportedFeatures();
99 void applyFlashSettings();
100
101 // Applies the focusDistance to the AVCaptureDevice.
102 // Does NOT trigger focusDistanceChanged
103 void applyFocusDistanceToAVCaptureDevice(float distance);
104
105 QCameraDevice m_cameraDevice;
106 bool m_active = false;
107private:
108 bool isFlashSupported = false;
109 bool isFlashAutoSupported = false;
110 bool isTorchSupported = false;
111 bool isTorchAutoSupported = false;
112
113 void forceSetFocusMode(QCamera::FocusMode mode);
114 void forceZoomTo(float factor, float rate);
115};
116
117QT_END_NAMESPACE
118
119#endif
Q_FORWARD_DECLARE_OBJC_CLASS(AVCaptureDevice)