4#ifndef QAVFCAMERAUTILITY_P_H
5#define QAVFCAMERAUTILITY_P_H
18#include <QtCore/qglobal.h>
19#include <QtCore/qdebug.h>
20#include <QtCore/qlist.h>
21#include <QtCore/qsize.h>
22#include <QtCore/qtclasshelpermacros.h>
24#include <QtMultimedia/qcameradevice.h>
25#include <QtMultimedia/qtmultimediaexports.h>
27#import <AVFoundation/AVCaptureDevice.h>
28#import <AVFoundation/AVCaptureSession.h>
32class AVFConfigurationLock
35 explicit AVFConfigurationLock(AVCaptureDevice *captureDevice)
36 : m_captureDevice(captureDevice),
39 Q_ASSERT(m_captureDevice);
41 m_locked = [m_captureDevice lockForConfiguration:&error];
44 ~AVFConfigurationLock()
47 [m_captureDevice unlockForConfiguration];
56 Q_DISABLE_COPY(AVFConfigurationLock)
58 AVCaptureDevice *m_captureDevice;
84 return static_cast<T *>(get());
89 return static_cast<T *>(release());
94class AVFScopedPointer<dispatch_queue_t>
97 AVFScopedPointer() : m_queue(
nullptr) {}
98 explicit AVFScopedPointer(dispatch_queue_t q) : m_queue(q) {}
99 AVFScopedPointer(AVFScopedPointer &&other)
noexcept :
100 m_queue{ std::exchange(other.m_queue,
nullptr) }
103 QT_MOVE_ASSIGNMENT_OPERATOR_IMPL_VIA_MOVE_AND_SWAP(AVFScopedPointer)
108 dispatch_release(m_queue);
111 void swap(AVFScopedPointer &other)
113 std::swap(m_queue, other.m_queue);
116 operator dispatch_queue_t()
const
122 dispatch_queue_t data()
const
127 void reset(dispatch_queue_t q =
nullptr)
130 dispatch_release(m_queue);
135 dispatch_queue_t m_queue;
137 Q_DISABLE_COPY(AVFScopedPointer)
141Q_MULTIMEDIA_EXPORT AVFPSRange qt_connection_framerates(AVCaptureConnection *videoConnection);
143Q_MULTIMEDIA_EXPORT AVCaptureDeviceFormat *qt_convert_to_capture_device_format(
144 AVCaptureDevice *captureDevice,
const QCameraFormat &format,
145 const std::function<
bool(uint32_t)> &cvFormatValidator =
nullptr);
146Q_MULTIMEDIA_EXPORT QList<AVCaptureDeviceFormat *> qt_unique_device_formats(AVCaptureDevice *captureDevice,
147 FourCharCode preferredFormat);
151Q_MULTIMEDIA_EXPORT QList<AVFPSRange> qt_device_format_framerates(AVCaptureDeviceFormat *format);
152Q_MULTIMEDIA_EXPORT AVCaptureDeviceFormat *qt_find_best_resolution_match(AVCaptureDevice *captureDevice,
const QSize &res,
153 FourCharCode preferredFormat,
bool stillImage =
true);
154Q_MULTIMEDIA_EXPORT AVCaptureDeviceFormat *qt_find_best_framerate_match(AVCaptureDevice *captureDevice,
155 FourCharCode preferredFormat,
157Q_MULTIMEDIA_EXPORT AVFrameRateRange *qt_find_supported_framerate_range(AVCaptureDeviceFormat *format, Float64 fps);
163Q_MULTIMEDIA_EXPORT AVFPSRange qt_current_framerates(AVCaptureDevice *captureDevice, AVCaptureConnection *videoConnection);
165 qreal minFPS, qreal maxFPS);
167Q_MULTIMEDIA_EXPORT QList<AudioValueRange> qt_supported_sample_rates_for_format(
int codecId);
168Q_MULTIMEDIA_EXPORT QList<AudioValueRange> qt_supported_bit_rates_for_format(
int codecId);
169Q_MULTIMEDIA_EXPORT std::optional<QList<UInt32>> qt_supported_channel_counts_for_format(
int codecId);
170Q_MULTIMEDIA_EXPORT QList<UInt32> qt_supported_channel_layout_tags_for_format(
int codecId,
int noChannels);
void qt_set_framerate_limits(AVCaptureDevice *captureDevice, AVCaptureConnection *videoConnection, qreal minFPS, qreal maxFPS)
Q_MULTIMEDIA_EXPORT bool qt_formats_are_equal(AVCaptureDeviceFormat *f1, AVCaptureDeviceFormat *f2)
Q_MULTIMEDIA_EXPORT bool qt_format_supports_framerate(AVCaptureDeviceFormat *format, qreal fps)
Q_MULTIMEDIA_EXPORT bool qt_set_active_format(AVCaptureDevice *captureDevice, AVCaptureDeviceFormat *format, bool preserveFps)
std::pair< qreal, qreal > AVFPSRange
void operator()(NSObject *obj)