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
qdarwinintegration.mm
Go to the documentation of this file.
1// Copyright (C) 2021 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
5#include <avfmediaplayer_p.h>
6#if !defined(Q_OS_VISIONOS)
7#include <avfcameraservice_p.h>
8#include <avfcamera_p.h>
9#include <QtMultimedia/private/qavfvideodevices_p.h>
10#include <avfimagecapture_p.h>
11#include <avfmediaencoder_p.h>
12#endif
13#include <qdarwinformatsinfo_p.h>
14#include <avfvideosink_p.h>
15#include <avfaudiodecoder_p.h>
16#include <VideoToolbox/VideoToolbox.h>
17#include <qdebug.h>
18#include <private/qplatformmediaplugin_p.h>
19
21
23{
24 Q_OBJECT
25 Q_PLUGIN_METADATA(IID QPlatformMediaPlugin_iid FILE "darwin.json")
26
27public:
28 QDarwinMediaPlugin() = default;
29
30 QPlatformMediaIntegration* create(const QString &name) override
31 {
32 if (name == u"darwin")
33 return new QDarwinIntegration;
34 return nullptr;
35 }
36};
37
38QDarwinIntegration::QDarwinIntegration() : QPlatformMediaIntegration(QLatin1String("darwin"))
39{
40#if defined(Q_OS_MACOS) && QT_MACOS_PLATFORM_SDK_EQUAL_OR_ABOVE(__MAC_11_0)
41 if (__builtin_available(macOS 11.0, *))
42 VTRegisterSupplementalVideoDecoderIfAvailable(kCMVideoCodecType_VP9);
43#endif
44}
45
46QPlatformMediaFormatInfo *QDarwinIntegration::createFormatInfo()
47{
48 return new QDarwinFormatInfo();
49}
50
51QPlatformVideoDevices *QDarwinIntegration::createVideoDevices()
52{
53#if defined(Q_OS_VISIONOS)
54 return nullptr;
55#else
56 return new QAVFVideoDevices(this);
57#endif
58}
59
60q23::expected<QPlatformAudioDecoder *, QString> QDarwinIntegration::createAudioDecoder(QAudioDecoder *decoder)
61{
62 return new AVFAudioDecoder(decoder);
63}
64
65q23::expected<QPlatformMediaCaptureSession *, QString> QDarwinIntegration::createCaptureSession()
66{
67#if defined(Q_OS_VISIONOS)
68 return q23::unexpected{ notAvailable };
69#else
70 return new AVFCameraService;
71#endif
72}
73
74q23::expected<QPlatformMediaPlayer *, QString> QDarwinIntegration::createPlayer(QMediaPlayer *player)
75{
76 return new AVFMediaPlayer(player);
77}
78
79q23::expected<QPlatformCamera *, QString> QDarwinIntegration::createCamera(QCamera *camera)
80{
81#if defined(Q_OS_VISIONOS)
82 Q_UNUSED(camera);
83 return q23::unexpected{ notAvailable };
84#else
85 return new AVFCamera(camera);
86#endif
87}
88
89q23::expected<QPlatformMediaRecorder *, QString> QDarwinIntegration::createRecorder(QMediaRecorder *recorder)
90{
91#if defined(Q_OS_VISIONOS)
92 Q_UNUSED(recorder);
93 return q23::unexpected{ notAvailable };
94#else
95 return new AVFMediaEncoder(recorder);
96#endif
97}
98
99q23::expected<QPlatformImageCapture *, QString> QDarwinIntegration::createImageCapture(QImageCapture *imageCapture)
100{
101#if defined(Q_OS_VISIONOS)
102 Q_UNUSED(imageCapture);
103 return q23::unexpected{ notAvailable };
104#else
105 return new AVFImageCapture(imageCapture);
106#endif
107}
108
109q23::expected<QPlatformVideoSink *, QString> QDarwinIntegration::createVideoSink(QVideoSink *sink)
110{
111 return new AVFVideoSink(sink);
112}
113
114QT_END_NAMESPACE
115
116#include "qdarwinintegration.moc"
QPlatformMediaIntegration * create(const QString &name) override