From 5d04ed2a0a02e483196bd88ca059b7cfcb52a6ac Mon Sep 17 00:00:00 2001
From: Andrew Knight <andrew.knight@digia.com>
Date: Wed, 20 Aug 2014 22:14:04 +0300
Subject: [PATCH] Introducing Windows Runtime backend

This lays the foundation for using supported APIs in Media Foundation
for the Windows Runtime family of devies. Due to the narrowing of
supported MF classes, as well as classes that are only available on
Windows 8 and newer, this backend is built as a new plugin rather than
a modification to the existing wmf plugin.

[ChangeLog] Added a new backend plugin, winrt, to support multimedia
within Windows Runtime OSes.

Change-Id: If64ac417127b7400baa5e56fe02b65f909a4dece
Reviewed-by: Maurice Kalinowski <maurice.kalinowski@digia.com>
Reviewed-by: Yoann Lopes <yoann.lopes@digia.com>
---
 src/plugins/plugins.pro                   |  4 ++
 src/plugins/winrt/qwinrtserviceplugin.cpp | 61 ++++++++++++++++++++++
 src/plugins/winrt/qwinrtserviceplugin.h   | 62 +++++++++++++++++++++++
 src/plugins/winrt/winrt.json              |  4 ++
 src/plugins/winrt/winrt.pro               | 17 +++++++
 5 files changed, 148 insertions(+)
 create mode 100644 src/plugins/winrt/qwinrtserviceplugin.cpp
 create mode 100644 src/plugins/winrt/qwinrtserviceplugin.h
 create mode 100644 src/plugins/winrt/winrt.json
 create mode 100644 src/plugins/winrt/winrt.pro

diff --git a/src/plugins/plugins.pro b/src/plugins/plugins.pro
index 45aa95ec7..0020203c3 100644
--- a/src/plugins/plugins.pro
+++ b/src/plugins/plugins.pro
@@ -29,6 +29,10 @@ win32:!winrt {
     config_wmf: SUBDIRS += wmf
 }
 
+winrt {
+    SUBDIRS += winrt
+}
+
 unix:!mac:!android {
     config_gstreamer {
        SUBDIRS += gstreamer
diff --git a/src/plugins/winrt/qwinrtserviceplugin.cpp b/src/plugins/winrt/qwinrtserviceplugin.cpp
new file mode 100644
index 000000000..143b93547
--- /dev/null
+++ b/src/plugins/winrt/qwinrtserviceplugin.cpp
@@ -0,0 +1,61 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia.  For licensing terms and
+** conditions see http://qt.digia.com/licensing.  For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file.  Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights.  These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file.  Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtCore/QString>
+#include <QtCore/QFile>
+
+#include "qwinrtserviceplugin.h"
+
+QMediaService *QWinRTServicePlugin::create(QString const &key)
+{
+    return Q_NULLPTR;
+}
+
+void QWinRTServicePlugin::release(QMediaService *service)
+{
+    delete service;
+}
+
+QMediaServiceProviderHint::Features QWinRTServicePlugin::supportedFeatures(
+        const QByteArray &service) const
+{
+    return QMediaServiceProviderHint::Features();
+}
diff --git a/src/plugins/winrt/qwinrtserviceplugin.h b/src/plugins/winrt/qwinrtserviceplugin.h
new file mode 100644
index 000000000..aaac79c7b
--- /dev/null
+++ b/src/plugins/winrt/qwinrtserviceplugin.h
@@ -0,0 +1,62 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia.  For licensing terms and
+** conditions see http://qt.digia.com/licensing.  For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file.  Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights.  These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file.  Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QWINRTSERVICEPLUGIN_H
+#define QWINRTSERVICEPLUGIN_H
+
+#include <QtMultimedia/QMediaServiceProviderPlugin>
+
+QT_USE_NAMESPACE
+
+class QWinRTServicePlugin : public QMediaServiceProviderPlugin
+        , public QMediaServiceFeaturesInterface
+{
+    Q_OBJECT
+    Q_INTERFACES(QMediaServiceFeaturesInterface)
+    Q_PLUGIN_METADATA(IID "org.qt-project.qt.mediaserviceproviderfactory/5.0" FILE "winrt.json")
+public:
+    QMediaService *create(QString const &key);
+    void release(QMediaService *service);
+
+    QMediaServiceProviderHint::Features supportedFeatures(const QByteArray &service) const;
+};
+
+#endif // QWINRTSERVICEPLUGIN_H
diff --git a/src/plugins/winrt/winrt.json b/src/plugins/winrt/winrt.json
new file mode 100644
index 000000000..f4a1ceb47
--- /dev/null
+++ b/src/plugins/winrt/winrt.json
@@ -0,0 +1,4 @@
+{
+    "Keys": ["winrt"],
+    "Services": []
+}
diff --git a/src/plugins/winrt/winrt.pro b/src/plugins/winrt/winrt.pro
new file mode 100644
index 000000000..82f97e489
--- /dev/null
+++ b/src/plugins/winrt/winrt.pro
@@ -0,0 +1,17 @@
+TARGET = winrtengine
+QT += multimedia-private
+
+PLUGIN_TYPE=mediaservice
+PLUGIN_CLASS_NAME = WinRTServicePlugin
+load(qt_plugin)
+
+LIBS += -lmfplat -lmfuuid -loleaut32 -ld3d11
+
+HEADERS += \
+    qwinrtserviceplugin.h
+
+SOURCES += \
+    qwinrtserviceplugin.cpp
+
+OTHER_FILES += \
+    winrt.json
-- 
GitLab