From 7c787f11dd2348e0fd2cecc231f15a0acde7481a Mon Sep 17 00:00:00 2001
From: Friedemann Kleint <Friedemann.Kleint@qt.io>
Date: Tue, 13 Dec 2016 13:56:49 +0100
Subject: [PATCH] DirectShow: Port to new configure system (evr, wmsdk)

Replace old legacy defines by QT_CONFIG. Fixes warnings when using MinGW:
qtmultimedia/src/multimedia/qtmultimedia-config.h:4:0: warning: "QT_NO_WMSDK" redefined

Change-Id: Ifbfc2cea3bf5bfd06d94fd70e6ea4afb6d6fbb4b
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
---
 src/plugins/directshow/camera/camera.pri         |  2 --
 src/plugins/directshow/directshow.pro            |  2 --
 .../player/directshowmetadatacontrol.cpp         |  8 +++++---
 .../player/directshowplayerservice.cpp           | 16 +++++++++-------
 .../player/directshowvideorenderercontrol.cpp    | 10 +++++-----
 .../player/directshowvideorenderercontrol.h      |  6 ++++--
 src/plugins/directshow/player/player.pri         |  2 --
 7 files changed, 23 insertions(+), 23 deletions(-)

diff --git a/src/plugins/directshow/camera/camera.pri b/src/plugins/directshow/camera/camera.pri
index fb7fbd3f5..afe77fc56 100644
--- a/src/plugins/directshow/camera/camera.pri
+++ b/src/plugins/directshow/camera/camera.pri
@@ -2,8 +2,6 @@ INCLUDEPATH += $$PWD
 
 DEFINES += QMEDIA_DIRECTSHOW_CAMERA
 
-mingw: DEFINES += QT_NO_WMSDK
-
 win32: DEFINES += _CRT_SECURE_NO_WARNINGS
 
 HEADERS += \
diff --git a/src/plugins/directshow/directshow.pro b/src/plugins/directshow/directshow.pro
index 7fe02e662..8e31527da 100644
--- a/src/plugins/directshow/directshow.pro
+++ b/src/plugins/directshow/directshow.pro
@@ -8,8 +8,6 @@ win32:!qtHaveModule(opengl)|qtConfig(dynamicgl) {
 HEADERS += dsserviceplugin.h
 SOURCES += dsserviceplugin.cpp
 
-!qtConfig(wmsdk): DEFINES += QT_NO_WMSDK
-
 mingw: DEFINES += NO_DSHOW_STRSAFE
 
 include(helpers/helpers.pri)
diff --git a/src/plugins/directshow/player/directshowmetadatacontrol.cpp b/src/plugins/directshow/player/directshowmetadatacontrol.cpp
index 6a88d76a9..ccd408a8a 100644
--- a/src/plugins/directshow/player/directshowmetadatacontrol.cpp
+++ b/src/plugins/directshow/player/directshowmetadatacontrol.cpp
@@ -57,7 +57,9 @@
 #include "directshowmetadatacontrol.h"
 #include "directshowplayerservice.h"
 
-#ifndef QT_NO_WMSDK
+#include <QtMultimedia/private/qtmultimedia-config_p.h>
+
+#if QT_CONFIG(wmsdk)
 #include <wmsdk.h>
 #endif
 
@@ -108,7 +110,7 @@ typedef HRESULT (WINAPI *q_SHCreateItemFromParsingName)(PCWSTR, IBindCtx *, cons
 static q_SHCreateItemFromParsingName sHCreateItemFromParsingName = 0;
 #endif
 
-#ifndef QT_NO_WMSDK
+#if QT_CONFIG(wmsdk)
 
 namespace
 {
@@ -513,7 +515,7 @@ void DirectShowMetaDataControl::updateMetadata(IFilterGraph2 *graph, IBaseFilter
         goto send_event;
 #endif
 
-#ifndef QT_NO_WMSDK
+#if QT_CONFIG(wmsdk)
     IWMHeaderInfo *info = com_cast<IWMHeaderInfo>(source, IID_IWMHeaderInfo);
 
     if (info) {
diff --git a/src/plugins/directshow/player/directshowplayerservice.cpp b/src/plugins/directshow/player/directshowplayerservice.cpp
index 1502c6df3..1554d194d 100644
--- a/src/plugins/directshow/player/directshowplayerservice.cpp
+++ b/src/plugins/directshow/player/directshowplayerservice.cpp
@@ -55,22 +55,24 @@
 #include "directshowvideorenderercontrol.h"
 
 
-#ifdef HAVE_EVR
+#if QT_CONFIG(evr)
 #include "directshowevrvideowindowcontrol.h"
 #endif
 
-#ifndef QT_NO_WMSDK
-#include <wmsdk.h>
-#endif
-
 #include "qmediacontent.h"
 
+#include <QtMultimedia/private/qtmultimedia-config_p.h>
+
 #include <QtCore/qcoreapplication.h>
 #include <QtCore/qdatetime.h>
 #include <QtCore/qdir.h>
 #include <QtCore/qthread.h>
 #include <QtCore/qvarlengtharray.h>
 
+#if QT_CONFIG(wmsdk)
+#  include <wmsdk.h>
+#endif
+
 #ifndef Q_CC_MINGW
 #  include <comdef.h>
 #endif
@@ -197,7 +199,7 @@ QMediaControl *DirectShowPlayerService::requestControl(const char *name)
         if (!m_videoRendererControl && !m_videoWindowControl) {
             IBaseFilter *filter;
 
-#ifdef HAVE_EVR
+#if QT_CONFIG(evr)
             DirectShowEvrVideoWindowControl *evrControl = new DirectShowEvrVideoWindowControl;
             if ((filter = evrControl->filter()))
                 m_videoWindowControl = evrControl;
@@ -980,7 +982,7 @@ void DirectShowPlayerService::doSeek(QMutexLocker *locker)
 
 int DirectShowPlayerService::bufferStatus() const
 {
-#ifndef QT_NO_WMSDK
+#if QT_CONFIG(wmsdk)
     QMutexLocker locker(const_cast<QMutex *>(&m_mutex));
 
     if (IWMReaderAdvanced2 *reader = com_cast<IWMReaderAdvanced2>(
diff --git a/src/plugins/directshow/player/directshowvideorenderercontrol.cpp b/src/plugins/directshow/player/directshowvideorenderercontrol.cpp
index b86125df9..b726040b3 100644
--- a/src/plugins/directshow/player/directshowvideorenderercontrol.cpp
+++ b/src/plugins/directshow/player/directshowvideorenderercontrol.cpp
@@ -41,7 +41,7 @@
 
 #include "videosurfacefilter.h"
 
-#ifdef HAVE_EVR
+#if QT_CONFIG(evr)
 #include "evrcustompresenter.h"
 #endif
 
@@ -52,7 +52,7 @@ DirectShowVideoRendererControl::DirectShowVideoRendererControl(DirectShowEventLo
     , m_loop(loop)
     , m_surface(0)
     , m_filter(0)
-#ifdef HAVE_EVR
+#if QT_CONFIG(evr)
     , m_evrPresenter(0)
 #endif
 {
@@ -60,7 +60,7 @@ DirectShowVideoRendererControl::DirectShowVideoRendererControl(DirectShowEventLo
 
 DirectShowVideoRendererControl::~DirectShowVideoRendererControl()
 {
-#ifdef HAVE_EVR
+#if QT_CONFIG(evr)
     if (m_evrPresenter) {
         m_evrPresenter->setSurface(Q_NULLPTR);
         m_evrPresenter->Release();
@@ -80,7 +80,7 @@ void DirectShowVideoRendererControl::setSurface(QAbstractVideoSurface *surface)
     if (m_surface == surface)
         return;
 
-#ifdef HAVE_EVR
+#if QT_CONFIG(evr)
     if (m_evrPresenter) {
         m_evrPresenter->setSurface(Q_NULLPTR);
         m_evrPresenter->Release();
@@ -96,7 +96,7 @@ void DirectShowVideoRendererControl::setSurface(QAbstractVideoSurface *surface)
     m_surface = surface;
 
     if (m_surface) {
-#ifdef HAVE_EVR
+#if QT_CONFIG(evr)
         m_filter = com_new<IBaseFilter>(clsid_EnhancedVideoRenderer);
         m_evrPresenter = new EVRCustomPresenter(m_surface);
         if (!m_evrPresenter->isValid() || !qt_evr_setCustomPresenter(m_filter, m_evrPresenter)) {
diff --git a/src/plugins/directshow/player/directshowvideorenderercontrol.h b/src/plugins/directshow/player/directshowvideorenderercontrol.h
index 9d1a23933..1df5d6864 100644
--- a/src/plugins/directshow/player/directshowvideorenderercontrol.h
+++ b/src/plugins/directshow/player/directshowvideorenderercontrol.h
@@ -44,8 +44,10 @@
 
 #include "qvideorenderercontrol.h"
 
+#include <QtMultimedia/private/qtmultimedia-config_p.h>
+
 class DirectShowEventLoop;
-#ifdef HAVE_EVR
+#if QT_CONFIG(evr)
 class EVRCustomPresenter;
 #endif
 
@@ -70,7 +72,7 @@ private:
     DirectShowEventLoop *m_loop;
     QAbstractVideoSurface *m_surface;
     IBaseFilter *m_filter;
-#ifdef HAVE_EVR
+#if QT_CONFIG(evr)
     EVRCustomPresenter *m_evrPresenter;
 #endif
 };
diff --git a/src/plugins/directshow/player/player.pri b/src/plugins/directshow/player/player.pri
index 7391ec7f0..18817b879 100644
--- a/src/plugins/directshow/player/player.pri
+++ b/src/plugins/directshow/player/player.pri
@@ -30,8 +30,6 @@ SOURCES += \
         $$PWD/vmr9videowindowcontrol.cpp
 
 qtConfig(evr) {
-    DEFINES += HAVE_EVR
-
     include($$PWD/../../common/evr.pri)
 
     HEADERS += \
-- 
GitLab