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#include <AVFoundation/AVFoundation.h>
30#import <UIKit/UIDevice.h>
35class AVFConfigurationLock
38 explicit AVFConfigurationLock(AVCaptureDevice *captureDevice)
39 : m_captureDevice(captureDevice),
42 Q_ASSERT(m_captureDevice);
44 m_locked = [m_captureDevice lockForConfiguration:&error];
47 ~AVFConfigurationLock()
50 [m_captureDevice unlockForConfiguration];
59 Q_DISABLE_COPY(AVFConfigurationLock)
61 AVCaptureDevice *m_captureDevice;
87 return static_cast<T *>(get());
92 return static_cast<T *>(release());
97class AVFScopedPointer<dispatch_queue_t>
100 AVFScopedPointer() : m_queue(
nullptr) {}
101 explicit AVFScopedPointer(dispatch_queue_t q) : m_queue(q) {}
102 AVFScopedPointer(AVFScopedPointer &&other)
noexcept :
103 m_queue{ std::exchange(other.m_queue,
nullptr) }
106 QT_MOVE_ASSIGNMENT_OPERATOR_IMPL_VIA_MOVE_AND_SWAP(AVFScopedPointer)
111 dispatch_release(m_queue);
114 void swap(AVFScopedPointer &other)
116 std::swap(m_queue, other.m_queue);
119 operator dispatch_queue_t()
const
125 dispatch_queue_t data()
const
130 void reset(dispatch_queue_t q =
nullptr)
133 dispatch_release(m_queue);
138 dispatch_queue_t m_queue;
140 Q_DISABLE_COPY(AVFScopedPointer)
144Q_MULTIMEDIA_EXPORT AVFPSRange qt_connection_framerates(AVCaptureConnection *videoConnection);
146Q_MULTIMEDIA_EXPORT AVCaptureDeviceFormat *qt_convert_to_capture_device_format(
147 AVCaptureDevice *captureDevice,
const QCameraFormat &format,
148 const std::function<
bool(uint32_t)> &cvFormatValidator =
nullptr);
149Q_MULTIMEDIA_EXPORT QList<AVCaptureDeviceFormat *> qt_unique_device_formats(AVCaptureDevice *captureDevice,
150 FourCharCode preferredFormat);
154Q_MULTIMEDIA_EXPORT QList<AVFPSRange> qt_device_format_framerates(AVCaptureDeviceFormat *format);
155Q_MULTIMEDIA_EXPORT AVCaptureDeviceFormat *qt_find_best_resolution_match(AVCaptureDevice *captureDevice,
const QSize &res,
156 FourCharCode preferredFormat,
bool stillImage =
true);
157Q_MULTIMEDIA_EXPORT AVCaptureDeviceFormat *qt_find_best_framerate_match(AVCaptureDevice *captureDevice,
158 FourCharCode preferredFormat,
160Q_MULTIMEDIA_EXPORT AVFrameRateRange *qt_find_supported_framerate_range(AVCaptureDeviceFormat *format, Float64 fps);
166Q_MULTIMEDIA_EXPORT AVFPSRange qt_current_framerates(AVCaptureDevice *captureDevice, AVCaptureConnection *videoConnection);
168 qreal minFPS, qreal maxFPS);
170Q_MULTIMEDIA_EXPORT QList<AudioValueRange> qt_supported_sample_rates_for_format(
int codecId);
171Q_MULTIMEDIA_EXPORT QList<AudioValueRange> qt_supported_bit_rates_for_format(
int codecId);
172Q_MULTIMEDIA_EXPORT std::optional<QList<UInt32>> qt_supported_channel_counts_for_format(
int codecId);
173Q_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)