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