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