Revision control
++ // Copyright (C) 2021 The Qt Company Ltd.
++ // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
++
++ #include "qwindowsintegration_p.h"
++
++ #include <decoder/mfaudiodecodercontrol_p.h>
++ #include <mediacapture/qwindowscamera_p.h>
++ #include <mediacapture/qwindowsimagecapture_p.h>
++ #include <mediacapture/qwindowsmediacapture_p.h>
++ #include <mediacapture/qwindowsmediaencoder_p.h>
++ #include <player/qmediaengineplayer_p.h>
++ #include <qmediaenginevideosink_p.h>
++ #include <qwindowsformatinfo_p.h>
++
++ #include <QtMultimedia/private/qplatformmediaplugin_p.h>
++ #include <QtMultimedia/private/qwindowsaudiodevices_p.h>
++ #include <QtCore/private/qfunctions_win_p.h>
++ #include <QtCore/private/qsystemerror_p.h>
++
++ QT_BEGIN_NAMESPACE
++
++ using namespace Qt::StringLiterals;
++
++ class QWindowsMediaPlugin : public QPlatformMediaPlugin
++ {
++ Q_OBJECT
++ Q_PLUGIN_METADATA(IID QPlatformMediaPlugin_iid FILE "windows.json")
++
++ public:
++ QWindowsMediaPlugin()
++ : QPlatformMediaPlugin()
++ {}
++
++ QPlatformMediaIntegration* create(const QString &name) override
++ {
++ if (name != u"windows")
++ return nullptr;
++
++ qt_win_ensureComInitializedOnThisThread();
++ HRESULT hr = MFStartup(MF_VERSION);
++ if (SUCCEEDED(hr))
++ return new QWindowsMediaIntegration;
++
++ qWarning() << "Failed to initialize Media Foundation:"
++ << QSystemError::windowsComString(hr);
++ return nullptr;
++ }
++ };
++
++ QWindowsMediaIntegration::QWindowsMediaIntegration()
++ : QPlatformMediaIntegration("windows"_L1)
++ {}
++
++ QWindowsMediaIntegration::~QWindowsMediaIntegration()
++ {
++ MFShutdown();
++ }
++
++ QPlatformMediaFormatInfo *QWindowsMediaIntegration::createFormatInfo()
++ {
++ return new QWindowsFormatInfo();
++ }
++
++ QPlatformVideoDevices *QWindowsMediaIntegration::createVideoDevices()
++ {
++ return new QWindowsVideoDevices(this);
++ }
++
++ q23::expected<QPlatformMediaCaptureSession *, QString> QWindowsMediaIntegration::createCaptureSession()
++ {
++ return new QWindowsMediaCaptureService();
++ }
++
++ q23::expected<QPlatformAudioDecoder *, QString> QWindowsMediaIntegration::createAudioDecoder(QAudioDecoder *decoder)
++ {
++ return new MFAudioDecoderControl(decoder);
++ }
++
++ q23::expected<QPlatformMediaPlayer *, QString> QWindowsMediaIntegration::createPlayer(QMediaPlayer *parent)
++ {
++ return new QMediaEnginePlayer(parent);
++ }
++
++ q23::expected<QPlatformCamera *, QString> QWindowsMediaIntegration::createCamera(QCamera *camera)
++ {
++ return new QWindowsCamera(camera);
++ }
++
++ q23::expected<QPlatformMediaRecorder *, QString> QWindowsMediaIntegration::createRecorder(QMediaRecorder *recorder)
++ {
++ return new QWindowsMediaEncoder(recorder);
++ }
++
++ q23::expected<QPlatformImageCapture *, QString> QWindowsMediaIntegration::createImageCapture(QImageCapture *imageCapture)
++ {
++ return new QWindowsImageCapture(imageCapture);
++ }
++
++ q23::expected<QPlatformVideoSink *, QString> QWindowsMediaIntegration::createVideoSink(QVideoSink *sink)
++ {
++ return new QMediaEngineVideoSink(sink);
++ }
++
++ QT_END_NAMESPACE
++
++ #include "qwindowsintegration.moc"