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/qdarwinintegrationfactory_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)
41 VTRegisterSupplementalVideoDecoderIfAvailable(kCMVideoCodecType_VP9);
42#endif
43}
44
45QPlatformMediaFormatInfo *QDarwinIntegration::createFormatInfo()
46{
47 return new QDarwinFormatInfo();
48}
49
50QPlatformVideoDevices *QDarwinIntegration::createVideoDevices()
51{
52#if defined(Q_OS_VISIONOS)
53 return nullptr;
54#else
55 return makeQAvfVideoDevices(*this).release();
56#endif
57}
58
59q23::expected<QPlatformAudioDecoder *, QString> QDarwinIntegration::createAudioDecoder(QAudioDecoder *decoder)
60{
61 return new AVFAudioDecoder(decoder);
62}
63
64q23::expected<QPlatformMediaCaptureSession *, QString> QDarwinIntegration::createCaptureSession()
65{
66#if defined(Q_OS_VISIONOS)
67 return q23::unexpected{ notAvailable };
68#else
69 return new AVFCameraService;
70#endif
71}
72
73q23::expected<QPlatformMediaPlayer *, QString> QDarwinIntegration::createPlayer(QMediaPlayer *player)
74{
75 return new AVFMediaPlayer(player);
76}
77
78q23::expected<QPlatformCamera *, QString> QDarwinIntegration::createCamera(QCamera *camera)
79{
80#if defined(Q_OS_VISIONOS)
81 Q_UNUSED(camera);
82 return q23::unexpected{ notAvailable };
83#else
84 return new AVFCamera(camera);
85#endif
86}
87
88q23::expected<QPlatformMediaRecorder *, QString> QDarwinIntegration::createRecorder(QMediaRecorder *recorder)
89{
90#if defined(Q_OS_VISIONOS)
91 Q_UNUSED(recorder);
92 return q23::unexpected{ notAvailable };
93#else
94 return new AVFMediaEncoder(recorder);
95#endif
96}
97
98q23::expected<QPlatformImageCapture *, QString> QDarwinIntegration::createImageCapture(QImageCapture *imageCapture)
99{
100#if defined(Q_OS_VISIONOS)
101 Q_UNUSED(imageCapture);
102 return q23::unexpected{ notAvailable };
103#else
104 return new AVFImageCapture(imageCapture);
105#endif
106}
107
108q23::expected<QPlatformVideoSink *, QString> QDarwinIntegration::createVideoSink(QVideoSink *sink)
109{
110 return new AVFVideoSink(sink);
111}
112
113QT_END_NAMESPACE
114
115#include "qdarwinintegration.moc"
QPlatformMediaIntegration * create(const QString &name) override
Combined button and popup list for selecting options.