diff options
Diffstat (limited to 'src/plugins/directshow')
43 files changed, 735 insertions, 224 deletions
diff --git a/src/plugins/directshow/camera/dscamerasession.cpp b/src/plugins/directshow/camera/dscamerasession.cpp index 40e54a94d..3f1187baa 100644 --- a/src/plugins/directshow/camera/dscamerasession.cpp +++ b/src/plugins/directshow/camera/dscamerasession.cpp @@ -334,6 +334,26 @@ void DSCameraSession::setImageProcessingParameter( } } +bool DSCameraSession::getCameraControlInterface(IAMCameraControl **cameraControl) const +{ + if (!m_sourceFilter) { + qCDebug(qtDirectShowPlugin, "getCameraControlInterface failed: No capture filter!"); + return false; + } + + if (!cameraControl) { + qCDebug(qtDirectShowPlugin, "getCameraControlInterface failed: Invalid out argument!"); + return false; + } + + if (FAILED(m_sourceFilter->QueryInterface(IID_IAMCameraControl, reinterpret_cast<void **>(cameraControl)))) { + qCDebug(qtDirectShowPlugin, "getCameraControlInterface failed: Querying camera control failed!"); + return false; + } + + return true; +} + bool DSCameraSession::load() { unload(); diff --git a/src/plugins/directshow/camera/dscamerasession.h b/src/plugins/directshow/camera/dscamerasession.h index 37730736f..6b6cb49b2 100644 --- a/src/plugins/directshow/camera/dscamerasession.h +++ b/src/plugins/directshow/camera/dscamerasession.h @@ -118,6 +118,8 @@ public: QCameraImageProcessingControl::ProcessingParameter, const QVariant &); + bool getCameraControlInterface(IAMCameraControl **cameraControl) const; + Q_SIGNALS: void statusChanged(QCamera::Status); void imageExposed(int id); diff --git a/src/plugins/directshow/common/common.pri b/src/plugins/directshow/common/common.pri index 9b7c1e3f4..06f8582ac 100644 --- a/src/plugins/directshow/common/common.pri +++ b/src/plugins/directshow/common/common.pri @@ -1,11 +1,30 @@ INCLUDEPATH += $$PWD HEADERS += \ + $$PWD/directshowbasefilter.h \ + $$PWD/directshoweventloop.h \ + $$PWD/directshowglobal.h \ + $$PWD/directshowmediatype.h \ + $$PWD/directshowmediatypeenum.h \ + $$PWD/directshowobject.h \ + $$PWD/directshowpin.h \ + $$PWD/directshowpinenum.h \ + $$PWD/directshowvideobuffer.h \ + $$PWD/directshowutils.h \ $$PWD/directshowvideoprobecontrol.h \ $$PWD/directshowaudioprobecontrol.h \ $$PWD/directshowsamplegrabber.h SOURCES += \ + $$PWD/directshowbasefilter.cpp \ + $$PWD/directshoweventloop.cpp \ + $$PWD/directshowmediatype.cpp \ + $$PWD/directshowmediatypeenum.cpp \ + $$PWD/directshowobject.cpp \ + $$PWD/directshowpin.cpp \ + $$PWD/directshowpinenum.cpp \ + $$PWD/directshowvideobuffer.cpp \ + $$PWD/directshowutils.cpp \ $$PWD/directshowvideoprobecontrol.cpp \ $$PWD/directshowaudioprobecontrol.cpp \ $$PWD/directshowsamplegrabber.cpp diff --git a/src/plugins/directshow/helpers/directshowbasefilter.cpp b/src/plugins/directshow/common/directshowbasefilter.cpp index fbf0f6204..342f0c271 100644 --- a/src/plugins/directshow/helpers/directshowbasefilter.cpp +++ b/src/plugins/directshow/common/directshowbasefilter.cpp @@ -1,31 +1,37 @@ /**************************************************************************** ** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ ** ** This file is part of the Qt Toolkit. ** -** $QT_BEGIN_LICENSE:LGPL21$ +** $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 The Qt Company. For licensing terms -** and conditions see http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/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 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. ** -** As a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company 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 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. ** ** $QT_END_LICENSE$ ** @@ -35,6 +41,8 @@ #include "directshowpinenum.h" +QT_BEGIN_NAMESPACE + DirectShowBaseFilter::DirectShowBaseFilter() : m_mutex(QMutex::Recursive) , m_state(State_Stopped) @@ -265,3 +273,5 @@ HRESULT DirectShowBaseFilter::QueryVendorInfo(LPWSTR *pVendorInfo) Q_UNUSED(pVendorInfo); return E_NOTIMPL; } + +QT_END_NAMESPACE diff --git a/src/plugins/directshow/helpers/directshowbasefilter.h b/src/plugins/directshow/common/directshowbasefilter.h index cc8588044..9a2f44567 100644 --- a/src/plugins/directshow/helpers/directshowbasefilter.h +++ b/src/plugins/directshow/common/directshowbasefilter.h @@ -1,31 +1,37 @@ /**************************************************************************** ** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ ** ** This file is part of the Qt Toolkit. ** -** $QT_BEGIN_LICENSE:LGPL21$ +** $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 The Qt Company. For licensing terms -** and conditions see http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/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 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. ** -** As a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company 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 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. ** ** $QT_END_LICENSE$ ** @@ -36,7 +42,7 @@ #include "directshowpin.h" -QT_USE_NAMESPACE +QT_BEGIN_NAMESPACE class DirectShowBaseFilter : public DirectShowObject , public IBaseFilter @@ -90,4 +96,6 @@ private: Q_DISABLE_COPY(DirectShowBaseFilter) }; +QT_END_NAMESPACE + #endif // DIRECTSHOWBASEFILTER_H diff --git a/src/plugins/directshow/helpers/directshoweventloop.cpp b/src/plugins/directshow/common/directshoweventloop.cpp index 87f969e42..ef85c0429 100644 --- a/src/plugins/directshow/helpers/directshoweventloop.cpp +++ b/src/plugins/directshow/common/directshoweventloop.cpp @@ -42,6 +42,8 @@ #include <QtCore/qcoreapplication.h> #include <QtCore/qcoreevent.h> +QT_BEGIN_NAMESPACE + class DirectShowPostedEvent { public: @@ -146,3 +148,5 @@ void DirectShowEventLoop::processEvents() locker.relock(); } } + +QT_END_NAMESPACE diff --git a/src/plugins/directshow/helpers/directshoweventloop.h b/src/plugins/directshow/common/directshoweventloop.h index 09d986de7..609e53134 100644 --- a/src/plugins/directshow/helpers/directshoweventloop.h +++ b/src/plugins/directshow/common/directshoweventloop.h @@ -46,6 +46,8 @@ #include <qt_windows.h> +QT_BEGIN_NAMESPACE + class DirectShowPostedEvent; class DirectShowEventLoop : public QObject @@ -73,4 +75,6 @@ private: QMutex m_mutex; }; +QT_END_NAMESPACE + #endif diff --git a/src/plugins/directshow/helpers/directshowglobal.h b/src/plugins/directshow/common/directshowglobal.h index 5f391710e..5f391710e 100644 --- a/src/plugins/directshow/helpers/directshowglobal.h +++ b/src/plugins/directshow/common/directshowglobal.h diff --git a/src/plugins/directshow/helpers/directshowmediatype.cpp b/src/plugins/directshow/common/directshowmediatype.cpp index d9ddf8248..65882806c 100644 --- a/src/plugins/directshow/helpers/directshowmediatype.cpp +++ b/src/plugins/directshow/common/directshowmediatype.cpp @@ -134,6 +134,11 @@ void DirectShowMediaType::copy(AM_MEDIA_TYPE *target, const AM_MEDIA_TYPE *sourc clear(*target); + copyToUninitialized(target, source); +} + +void DirectShowMediaType::copyToUninitialized(AM_MEDIA_TYPE *target, const AM_MEDIA_TYPE *source) +{ *target = *source; if (source->cbFormat > 0) { diff --git a/src/plugins/directshow/helpers/directshowmediatype.h b/src/plugins/directshow/common/directshowmediatype.h index 7849ca9b0..7f495f3b2 100644 --- a/src/plugins/directshow/helpers/directshowmediatype.h +++ b/src/plugins/directshow/common/directshowmediatype.h @@ -47,7 +47,7 @@ #include <dvdmedia.h> #include <QtCore/qglobal.h> -QT_USE_NAMESPACE +QT_BEGIN_NAMESPACE class DirectShowMediaType { @@ -72,6 +72,7 @@ public: static void init(AM_MEDIA_TYPE *type); static void copy(AM_MEDIA_TYPE *target, const AM_MEDIA_TYPE *source); + static void copyToUninitialized(AM_MEDIA_TYPE *target, const AM_MEDIA_TYPE *source); static void move(AM_MEDIA_TYPE *target, AM_MEDIA_TYPE **source); static void move(AM_MEDIA_TYPE *target, AM_MEDIA_TYPE &source); static void clear(AM_MEDIA_TYPE &type); @@ -91,4 +92,6 @@ private: Q_DECLARE_TYPEINFO(DirectShowMediaType, Q_MOVABLE_TYPE); +QT_END_NAMESPACE + #endif diff --git a/src/plugins/directshow/helpers/directshowmediatypeenum.cpp b/src/plugins/directshow/common/directshowmediatypeenum.cpp index a58993f7f..8fbdf7dea 100644 --- a/src/plugins/directshow/helpers/directshowmediatypeenum.cpp +++ b/src/plugins/directshow/common/directshowmediatypeenum.cpp @@ -1,31 +1,37 @@ /**************************************************************************** ** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ ** ** This file is part of the Qt Toolkit. ** -** $QT_BEGIN_LICENSE:LGPL21$ +** $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 The Qt Company. For licensing terms -** and conditions see http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/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 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. ** -** As a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company 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 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. ** ** $QT_END_LICENSE$ ** @@ -72,7 +78,7 @@ HRESULT DirectShowMediaTypeEnum::Next(ULONG cMediaTypes, AM_MEDIA_TYPE **ppMedia for (ULONG i = 0; i < count; ++i, ++m_index) { ppMediaTypes[i] = reinterpret_cast<AM_MEDIA_TYPE *>(CoTaskMemAlloc(sizeof(AM_MEDIA_TYPE))); - DirectShowMediaType::copy(ppMediaTypes[i], &m_mediaTypes.at(m_index)); + DirectShowMediaType::copyToUninitialized(ppMediaTypes[i], &m_mediaTypes.at(m_index)); } if (pcFetched) diff --git a/src/plugins/directshow/common/directshowmediatypeenum.h b/src/plugins/directshow/common/directshowmediatypeenum.h new file mode 100644 index 000000000..9b058fc5b --- /dev/null +++ b/src/plugins/directshow/common/directshowmediatypeenum.h @@ -0,0 +1,80 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** 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 The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/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 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef DIRECTSHOWMEDIATYPEENUM_H +#define DIRECTSHOWMEDIATYPEENUM_H + +#include "directshowobject.h" +#include <qlist.h> + +QT_BEGIN_NAMESPACE + +class DirectShowPin; +class DirectShowMediaType; + +class DirectShowMediaTypeEnum : public DirectShowObject + , public IEnumMediaTypes +{ + DIRECTSHOW_OBJECT + +public: + DirectShowMediaTypeEnum(DirectShowPin *pin); + DirectShowMediaTypeEnum(const QList<DirectShowMediaType> &types); + ~DirectShowMediaTypeEnum(); + + // DirectShowObject + HRESULT getInterface(REFIID riid, void **ppvObject); + + // IEnumMediaTypes + STDMETHODIMP Next(ULONG cMediaTypes, AM_MEDIA_TYPE **ppMediaTypes, ULONG *pcFetched); + STDMETHODIMP Skip(ULONG cMediaTypes); + STDMETHODIMP Reset(); + STDMETHODIMP Clone(IEnumMediaTypes **ppEnum); + +private: + Q_DISABLE_COPY(DirectShowMediaTypeEnum) + + DirectShowPin *m_pin; + QList<DirectShowMediaType> m_mediaTypes; + int m_index; +}; + +QT_END_NAMESPACE + +#endif // DIRECTSHOWMEDIATYPEENUM_H diff --git a/src/plugins/directshow/helpers/directshowobject.cpp b/src/plugins/directshow/common/directshowobject.cpp index b9d989f6e..db1817a8d 100644 --- a/src/plugins/directshow/helpers/directshowobject.cpp +++ b/src/plugins/directshow/common/directshowobject.cpp @@ -39,6 +39,8 @@ #include "directshowobject.h" +QT_BEGIN_NAMESPACE + DirectShowObject::DirectShowObject() : m_ref(1) { @@ -81,3 +83,4 @@ HRESULT GetInterface(IUnknown *pUnk, void **ppv) return S_OK; } +QT_END_NAMESPACE diff --git a/src/plugins/directshow/helpers/directshowobject.h b/src/plugins/directshow/common/directshowobject.h index 3aba06f46..cfac16f61 100644 --- a/src/plugins/directshow/helpers/directshowobject.h +++ b/src/plugins/directshow/common/directshowobject.h @@ -1,31 +1,37 @@ /**************************************************************************** ** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ ** ** This file is part of the Qt Toolkit. ** -** $QT_BEGIN_LICENSE:LGPL21$ +** $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 The Qt Company. For licensing terms -** and conditions see http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/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 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. ** -** As a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company 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 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. ** ** $QT_END_LICENSE$ ** @@ -36,7 +42,7 @@ #include "directshowglobal.h" -QT_USE_NAMESPACE +QT_BEGIN_NAMESPACE class DirectShowObject { @@ -71,4 +77,6 @@ public: \ return unref(); \ }; +QT_END_NAMESPACE + #endif // DIRECTSHOWOBJECT_H diff --git a/src/plugins/directshow/helpers/directshowpin.cpp b/src/plugins/directshow/common/directshowpin.cpp index f501747f9..b49c3f8a4 100644 --- a/src/plugins/directshow/helpers/directshowpin.cpp +++ b/src/plugins/directshow/common/directshowpin.cpp @@ -1,31 +1,37 @@ /**************************************************************************** ** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ ** ** This file is part of the Qt Toolkit. ** -** $QT_BEGIN_LICENSE:LGPL21$ +** $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 The Qt Company. For licensing terms -** and conditions see http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/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 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. ** -** As a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company 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 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. ** ** $QT_END_LICENSE$ ** @@ -39,6 +45,8 @@ #include <qdebug.h> +QT_BEGIN_NAMESPACE + DirectShowPin::DirectShowPin(DirectShowBaseFilter *filter, const QString &name, PIN_DIRECTION direction) : m_mutex(QMutex::Recursive) , m_filter(filter) @@ -728,3 +736,5 @@ HRESULT DirectShowInputPin::ReceiveCanBlock() return outputPins == 0 ? S_OK : S_FALSE; } + +QT_END_NAMESPACE diff --git a/src/plugins/directshow/helpers/directshowpin.h b/src/plugins/directshow/common/directshowpin.h index b8207abae..97e808384 100644 --- a/src/plugins/directshow/helpers/directshowpin.h +++ b/src/plugins/directshow/common/directshowpin.h @@ -1,31 +1,37 @@ /**************************************************************************** ** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ ** ** This file is part of the Qt Toolkit. ** -** $QT_BEGIN_LICENSE:LGPL21$ +** $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 The Qt Company. For licensing terms -** and conditions see http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/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 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. ** -** As a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company 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 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. ** ** $QT_END_LICENSE$ ** @@ -40,7 +46,7 @@ #include <qstring.h> #include <qmutex.h> -QT_USE_NAMESPACE +QT_BEGIN_NAMESPACE class DirectShowBaseFilter; @@ -181,4 +187,6 @@ private: Q_DISABLE_COPY(DirectShowInputPin) }; +QT_END_NAMESPACE + #endif // DIRECTSHOWPIN_H diff --git a/src/plugins/directshow/helpers/directshowpinenum.cpp b/src/plugins/directshow/common/directshowpinenum.cpp index 61aca8b9c..910bba77d 100644 --- a/src/plugins/directshow/helpers/directshowpinenum.cpp +++ b/src/plugins/directshow/common/directshowpinenum.cpp @@ -40,6 +40,8 @@ #include "directshowpinenum.h" #include "directshowbasefilter.h" +QT_BEGIN_NAMESPACE + DirectShowPinEnum::DirectShowPinEnum(DirectShowBaseFilter *filter) : m_filter(filter) , m_index(0) @@ -124,3 +126,5 @@ HRESULT DirectShowPinEnum::Clone(IEnumPins **ppEnum) return E_POINTER; } } + +QT_END_NAMESPACE diff --git a/src/plugins/directshow/helpers/directshowpinenum.h b/src/plugins/directshow/common/directshowpinenum.h index 84c2a7579..77214e376 100644 --- a/src/plugins/directshow/helpers/directshowpinenum.h +++ b/src/plugins/directshow/common/directshowpinenum.h @@ -45,7 +45,7 @@ #include <QtCore/qlist.h> #include "directshowpin.h" -QT_USE_NAMESPACE +QT_BEGIN_NAMESPACE class DirectShowBaseFilter; @@ -76,4 +76,6 @@ private: int m_index; }; +QT_END_NAMESPACE + #endif diff --git a/src/plugins/directshow/helpers/directshowutils.cpp b/src/plugins/directshow/common/directshowutils.cpp index d9701fd99..96fabd6da 100644 --- a/src/plugins/directshow/helpers/directshowutils.cpp +++ b/src/plugins/directshow/common/directshowutils.cpp @@ -39,6 +39,8 @@ #include "directshowutils.h" +QT_BEGIN_NAMESPACE + /** * @brief DirectShowUtils::isPinConnected * @param pin @@ -307,3 +309,5 @@ bool DirectShowUtils::connectFilters(IGraphBuilder *graph, return SUCCEEDED(*hrOut); } + +QT_END_NAMESPACE diff --git a/src/plugins/directshow/helpers/directshowutils.h b/src/plugins/directshow/common/directshowutils.h index 09c81c257..09c81c257 100644 --- a/src/plugins/directshow/helpers/directshowutils.h +++ b/src/plugins/directshow/common/directshowutils.h diff --git a/src/plugins/directshow/helpers/directshowvideobuffer.cpp b/src/plugins/directshow/common/directshowvideobuffer.cpp index 3204e9f7e..7f94da97e 100644 --- a/src/plugins/directshow/helpers/directshowvideobuffer.cpp +++ b/src/plugins/directshow/common/directshowvideobuffer.cpp @@ -39,6 +39,8 @@ #include "directshowvideobuffer.h" +QT_BEGIN_NAMESPACE + DirectShowVideoBuffer::DirectShowVideoBuffer(IMediaSample *sample, int bytesPerLine) : QAbstractVideoBuffer(NoHandle) , m_sample(sample) @@ -82,3 +84,5 @@ QAbstractVideoBuffer::MapMode DirectShowVideoBuffer::mapMode() const { return m_mapMode; } + +QT_END_NAMESPACE diff --git a/src/plugins/directshow/helpers/directshowvideobuffer.h b/src/plugins/directshow/common/directshowvideobuffer.h index 10089c75a..85e02b53d 100644 --- a/src/plugins/directshow/helpers/directshowvideobuffer.h +++ b/src/plugins/directshow/common/directshowvideobuffer.h @@ -44,6 +44,8 @@ #include <qabstractvideobuffer.h> +QT_BEGIN_NAMESPACE + class DirectShowVideoBuffer : public QAbstractVideoBuffer { public: @@ -63,5 +65,6 @@ private: MapMode m_mapMode; }; +QT_END_NAMESPACE #endif diff --git a/src/plugins/directshow/directshow.pro b/src/plugins/directshow/directshow.pro index 35301474f..2857f87d9 100644 --- a/src/plugins/directshow/directshow.pro +++ b/src/plugins/directshow/directshow.pro @@ -11,7 +11,6 @@ SOURCES += dsserviceplugin.cpp mingw: DEFINES += NO_DSHOW_STRSAFE include(common/common.pri) -include(helpers/helpers.pri) qtConfig(directshow-player): include(player/player.pri) include(camera/camera.pri) diff --git a/src/plugins/directshow/dsserviceplugin.cpp b/src/plugins/directshow/dsserviceplugin.cpp index 9060bac7c..51be7e500 100644 --- a/src/plugins/directshow/dsserviceplugin.cpp +++ b/src/plugins/directshow/dsserviceplugin.cpp @@ -75,9 +75,6 @@ extern const CLSID CLSID_VideoInputDeviceCategory; QT_BEGIN_NAMESPACE Q_LOGGING_CATEGORY(qtDirectShowPlugin, "qt.multimedia.plugins.directshow") -QT_END_NAMESPACE - -QT_USE_NAMESPACE static int g_refCount = 0; void addRefCount() @@ -157,3 +154,5 @@ QString DSServicePlugin::deviceDescription(const QByteArray &service, const QByt } return QString(); } + +QT_END_NAMESPACE diff --git a/src/plugins/directshow/dsserviceplugin.h b/src/plugins/directshow/dsserviceplugin.h index b7ac6a86e..f57262e37 100644 --- a/src/plugins/directshow/dsserviceplugin.h +++ b/src/plugins/directshow/dsserviceplugin.h @@ -43,7 +43,7 @@ #include <QtMultimedia/private/qtmultimediaglobal_p.h> #include "qmediaserviceproviderplugin.h" -QT_USE_NAMESPACE +QT_BEGIN_NAMESPACE class DSServicePlugin : public QMediaServiceProviderPlugin @@ -74,4 +74,6 @@ public: QString deviceDescription(const QByteArray &service, const QByteArray &device); }; +QT_END_NAMESPACE + #endif // DSSERVICEPLUGIN_H diff --git a/src/plugins/directshow/helpers/directshowmediatypeenum.h b/src/plugins/directshow/helpers/directshowmediatypeenum.h deleted file mode 100644 index 050df0881..000000000 --- a/src/plugins/directshow/helpers/directshowmediatypeenum.h +++ /dev/null @@ -1,72 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL21$ -** 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 The Qt Company. For licensing terms -** and conditions see http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/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 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** As a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef DIRECTSHOWMEDIATYPEENUM_H -#define DIRECTSHOWMEDIATYPEENUM_H - -#include "directshowobject.h" -#include <qlist.h> - -QT_USE_NAMESPACE - -class DirectShowPin; -class DirectShowMediaType; - -class DirectShowMediaTypeEnum : public DirectShowObject - , public IEnumMediaTypes -{ - DIRECTSHOW_OBJECT - -public: - DirectShowMediaTypeEnum(DirectShowPin *pin); - DirectShowMediaTypeEnum(const QList<DirectShowMediaType> &types); - ~DirectShowMediaTypeEnum(); - - // DirectShowObject - HRESULT getInterface(REFIID riid, void **ppvObject); - - // IEnumMediaTypes - STDMETHODIMP Next(ULONG cMediaTypes, AM_MEDIA_TYPE **ppMediaTypes, ULONG *pcFetched); - STDMETHODIMP Skip(ULONG cMediaTypes); - STDMETHODIMP Reset(); - STDMETHODIMP Clone(IEnumMediaTypes **ppEnum); - -private: - Q_DISABLE_COPY(DirectShowMediaTypeEnum) - - DirectShowPin *m_pin; - QList<DirectShowMediaType> m_mediaTypes; - int m_index; -}; - -#endif // DIRECTSHOWMEDIATYPEENUM_H diff --git a/src/plugins/directshow/helpers/helpers.pri b/src/plugins/directshow/helpers/helpers.pri deleted file mode 100644 index ca883eeb8..000000000 --- a/src/plugins/directshow/helpers/helpers.pri +++ /dev/null @@ -1,24 +0,0 @@ -INCLUDEPATH += $$PWD - -HEADERS += \ - $$PWD/directshowbasefilter.h \ - $$PWD/directshoweventloop.h \ - $$PWD/directshowglobal.h \ - $$PWD/directshowmediatype.h \ - $$PWD/directshowmediatypeenum.h \ - $$PWD/directshowobject.h \ - $$PWD/directshowpin.h \ - $$PWD/directshowpinenum.h \ - $$PWD/directshowvideobuffer.h \ - $$PWD/directshowutils.h - -SOURCES += \ - $$PWD/directshowbasefilter.cpp \ - $$PWD/directshoweventloop.cpp \ - $$PWD/directshowmediatype.cpp \ - $$PWD/directshowmediatypeenum.cpp \ - $$PWD/directshowobject.cpp \ - $$PWD/directshowpin.cpp \ - $$PWD/directshowpinenum.cpp \ - $$PWD/directshowvideobuffer.cpp \ - $$PWD/directshowutils.cpp diff --git a/src/plugins/directshow/player/directshowaudioendpointcontrol.cpp b/src/plugins/directshow/player/directshowaudioendpointcontrol.cpp index f4e75f4e2..78733972a 100644 --- a/src/plugins/directshow/player/directshowaudioendpointcontrol.cpp +++ b/src/plugins/directshow/player/directshowaudioendpointcontrol.cpp @@ -42,6 +42,8 @@ #include "directshowglobal.h" #include "directshowplayerservice.h" +QT_BEGIN_NAMESPACE + DirectShowAudioEndpointControl::DirectShowAudioEndpointControl( DirectShowPlayerService *service, QObject *parent) : QAudioOutputSelectorControl(parent) @@ -157,3 +159,5 @@ void DirectShowAudioEndpointControl::updateEndpoints() oleMalloc->Release(); } } + +QT_END_NAMESPACE diff --git a/src/plugins/directshow/player/directshowaudioendpointcontrol.h b/src/plugins/directshow/player/directshowaudioendpointcontrol.h index 2d1763ea3..e0e6a1545 100644 --- a/src/plugins/directshow/player/directshowaudioendpointcontrol.h +++ b/src/plugins/directshow/player/directshowaudioendpointcontrol.h @@ -44,9 +44,9 @@ #include <dshow.h> -class DirectShowPlayerService; +QT_BEGIN_NAMESPACE -QT_USE_NAMESPACE +class DirectShowPlayerService; class DirectShowAudioEndpointControl : public QAudioOutputSelectorControl { @@ -76,5 +76,7 @@ private: QString m_activeEndpoint; }; +QT_END_NAMESPACE + #endif diff --git a/src/plugins/directshow/player/directshowevrvideowindowcontrol.h b/src/plugins/directshow/player/directshowevrvideowindowcontrol.h index 5aa304bca..fb661780f 100644 --- a/src/plugins/directshow/player/directshowevrvideowindowcontrol.h +++ b/src/plugins/directshow/player/directshowevrvideowindowcontrol.h @@ -44,7 +44,7 @@ struct IBaseFilter; -QT_USE_NAMESPACE +QT_BEGIN_NAMESPACE class DirectShowEvrVideoWindowControl : public EvrVideoWindowControl { @@ -58,4 +58,6 @@ private: IBaseFilter *m_evrFilter; }; +QT_END_NAMESPACE + #endif // DIRECTSHOWEVRVIDEOWINDOWCONTROL_H diff --git a/src/plugins/directshow/player/directshowioreader.cpp b/src/plugins/directshow/player/directshowioreader.cpp index a35124b1e..7f3303633 100644 --- a/src/plugins/directshow/player/directshowioreader.cpp +++ b/src/plugins/directshow/player/directshowioreader.cpp @@ -48,6 +48,8 @@ #include <QtCore/qiodevice.h> #include <QtCore/qthread.h> +QT_BEGIN_NAMESPACE + class DirectShowSampleRequest { public: @@ -492,3 +494,5 @@ void DirectShowIOReader::flushRequests() m_readyHead = m_readyTail; } } + +QT_END_NAMESPACE diff --git a/src/plugins/directshow/player/directshowioreader.h b/src/plugins/directshow/player/directshowioreader.h index deb5d5327..2d62c0b95 100644 --- a/src/plugins/directshow/player/directshowioreader.h +++ b/src/plugins/directshow/player/directshowioreader.h @@ -48,7 +48,6 @@ QT_BEGIN_NAMESPACE class QIODevice; -QT_END_NAMESPACE class DirectShowEventLoop; class DirectShowIOSource; @@ -115,4 +114,6 @@ private: QWaitCondition m_wait; }; +QT_END_NAMESPACE + #endif diff --git a/src/plugins/directshow/player/directshowiosource.cpp b/src/plugins/directshow/player/directshowiosource.cpp index 96b4b14bf..b3aa3fab9 100644 --- a/src/plugins/directshow/player/directshowiosource.cpp +++ b/src/plugins/directshow/player/directshowiosource.cpp @@ -47,6 +47,8 @@ #include <QtCore/qcoreapplication.h> #include <QtCore/qurl.h> +QT_BEGIN_NAMESPACE + static const GUID directshow_subtypes[] = { MEDIASUBTYPE_NULL, @@ -581,3 +583,5 @@ HRESULT DirectShowIOSource::QueryDirection(PIN_DIRECTION *pPinDir) return S_OK; } } + +QT_END_NAMESPACE diff --git a/src/plugins/directshow/player/directshowiosource.h b/src/plugins/directshow/player/directshowiosource.h index 702bfed61..43df6c34f 100644 --- a/src/plugins/directshow/player/directshowiosource.h +++ b/src/plugins/directshow/player/directshowiosource.h @@ -46,6 +46,8 @@ #include <QtCore/qfile.h> +QT_BEGIN_NAMESPACE + class DirectShowIOSource : public IBaseFilter , public IAMFilterMiscFlags @@ -131,4 +133,6 @@ private: QMutex m_mutex; }; +QT_END_NAMESPACE + #endif diff --git a/src/plugins/directshow/player/directshowmetadatacontrol.h b/src/plugins/directshow/player/directshowmetadatacontrol.h index b42b48c67..3d2fa5e8e 100644 --- a/src/plugins/directshow/player/directshowmetadatacontrol.h +++ b/src/plugins/directshow/player/directshowmetadatacontrol.h @@ -48,9 +48,7 @@ #include <QtCore/qcoreevent.h> -class DirectShowPlayerService; - -QT_USE_NAMESPACE +QT_BEGIN_NAMESPACE class DirectShowMetaDataControl : public QMetaDataReaderControl { @@ -83,4 +81,6 @@ private: bool m_available; }; +QT_END_NAMESPACE + #endif diff --git a/src/plugins/directshow/player/directshowplayercontrol.h b/src/plugins/directshow/player/directshowplayercontrol.h index 184951544..fd2c21c38 100644 --- a/src/plugins/directshow/player/directshowplayercontrol.h +++ b/src/plugins/directshow/player/directshowplayercontrol.h @@ -49,7 +49,7 @@ #include "directshowplayerservice.h" -QT_USE_NAMESPACE +QT_BEGIN_NAMESPACE class DirectShowPlayerControl : public QMediaPlayerControl { @@ -148,4 +148,6 @@ private: }; +QT_END_NAMESPACE + #endif diff --git a/src/plugins/directshow/player/directshowplayerservice.cpp b/src/plugins/directshow/player/directshowplayerservice.cpp index 5fbb6ef05..de427f781 100644 --- a/src/plugins/directshow/player/directshowplayerservice.cpp +++ b/src/plugins/directshow/player/directshowplayerservice.cpp @@ -53,7 +53,11 @@ #include "directshowiosource.h" #include "directshowplayercontrol.h" #include "directshowvideorenderercontrol.h" - +#include "directshowutils.h" +#include "directshowglobal.h" +#include "directshowaudioprobecontrol.h" +#include "directshowvideoprobecontrol.h" +#include "directshowsamplegrabber.h" #if QT_CONFIG(evr) #include "directshowevrvideowindowcontrol.h" @@ -68,6 +72,11 @@ #include <QtCore/qdir.h> #include <QtCore/qthread.h> #include <QtCore/qvarlengtharray.h> +#include <QtCore/qsize.h> + +#include <QtMultimedia/qaudiobuffer.h> +#include <QtMultimedia/qvideoframe.h> +#include <QtMultimedia/private/qmemoryvideobuffer_p.h> #if QT_CONFIG(wmsdk) # include <wmsdk.h> @@ -77,6 +86,8 @@ # include <comdef.h> #endif +QT_BEGIN_NAMESPACE + Q_GLOBAL_STATIC(DirectShowEventLoop, qt_directShowEventLoop) static QString comError(HRESULT hr) @@ -115,6 +126,10 @@ DirectShowPlayerService::DirectShowPlayerService(QObject *parent) , m_videoRendererControl(0) , m_videoWindowControl(0) , m_audioEndpointControl(0) + , m_audioProbeControl(nullptr) + , m_videoProbeControl(nullptr) + , m_audioSampleGrabber(nullptr) + , m_videoSampleGrabber(nullptr) , m_taskThread(0) , m_loop(qt_directShowEventLoop()) , m_pendingTasks(0) @@ -174,6 +189,8 @@ DirectShowPlayerService::~DirectShowPlayerService() delete m_metaDataControl; delete m_videoRendererControl; delete m_videoWindowControl; + delete m_audioProbeControl; + delete m_videoProbeControl; ::CloseHandle(m_taskHandle); } @@ -217,6 +234,18 @@ QMediaControl *DirectShowPlayerService::requestControl(const char *name) return m_videoWindowControl; } + } else if (qstrcmp(name, QMediaAudioProbeControl_iid) == 0) { + if (!m_audioProbeControl) + m_audioProbeControl = new DirectShowAudioProbeControl(); + m_audioProbeControl->ref(); + updateAudioProbe(); + return m_audioProbeControl; + } else if (qstrcmp(name, QMediaVideoProbeControl_iid) == 0) { + if (!m_videoProbeControl) + m_videoProbeControl = new DirectShowVideoProbeControl(); + m_videoProbeControl->ref(); + updateVideoProbe(); + return m_videoProbeControl; } return 0; } @@ -238,6 +267,20 @@ void DirectShowPlayerService::releaseControl(QMediaControl *control) delete m_videoWindowControl; m_videoWindowControl = 0; + } else if (control == m_audioProbeControl) { + if (!m_audioProbeControl->deref()) { + DirectShowAudioProbeControl *old = m_audioProbeControl; + m_audioProbeControl = nullptr; + updateAudioProbe(); + delete old; + } + } else if (control == m_videoProbeControl) { + if (!m_videoProbeControl->deref()) { + DirectShowVideoProbeControl *old = m_videoProbeControl; + m_videoProbeControl = nullptr; + updateVideoProbe(); + delete old; + } } } @@ -347,6 +390,10 @@ void DirectShowPlayerService::doSetUrlSource(QMutexLocker *locker) m_pendingTasks |= SetAudioOutput; if (m_videoOutput) m_pendingTasks |= SetVideoOutput; + if (m_audioProbeControl) + m_pendingTasks |= SetAudioProbe; + if (m_videoProbeControl) + m_pendingTasks |= SetVideoProbe; if (m_rate != 1.0) m_pendingTasks |= SetRate; @@ -432,6 +479,18 @@ void DirectShowPlayerService::doRender(QMutexLocker *locker) m_executedTasks |= SetVideoOutput; } + if (m_pendingTasks & SetAudioProbe) { + doSetAudioProbe(locker); + m_pendingTasks ^= SetAudioProbe; + m_executedTasks |= SetAudioProbe; + } + + if (m_pendingTasks & SetVideoProbe) { + doSetVideoProbe(locker); + m_pendingTasks ^= SetVideoProbe; + m_executedTasks |= SetVideoProbe; + } + IFilterGraph2 *graph = m_graph; graph->AddRef(); @@ -599,6 +658,9 @@ void DirectShowPlayerService::doReleaseGraph(QMutexLocker *locker) control->Release(); } + doReleaseAudioProbe(locker); + doReleaseVideoProbe(locker); + if (m_source) { m_source->Release(); m_source = 0; @@ -612,6 +674,139 @@ void DirectShowPlayerService::doReleaseGraph(QMutexLocker *locker) m_loop->wake(); } +void DirectShowPlayerService::doSetVideoProbe(QMutexLocker *locker) +{ + Q_UNUSED(locker); + + if (!m_graph) { + qCWarning(qtDirectShowPlugin, "Attempting to set a video probe without a valid graph!"); + return; + } + + // Create the sample grabber, if necessary. + if (!m_videoSampleGrabber) { + m_videoSampleGrabber = new DirectShowSampleGrabber; + connect(m_videoSampleGrabber, &DirectShowSampleGrabber::bufferAvailable, this, &DirectShowPlayerService::onVideoBufferAvailable); + } + + if (FAILED(m_graph->AddFilter(m_videoSampleGrabber->filter(), L"Video Sample Grabber"))) { + qCWarning(qtDirectShowPlugin, "Failed to add the video sample grabber into the graph!"); + return; + } + + // TODO: Make util function for getting this, so it's easy to keep it in sync. + static const GUID subtypes[] = { MEDIASUBTYPE_ARGB32, + MEDIASUBTYPE_RGB32, + MEDIASUBTYPE_RGB24, + MEDIASUBTYPE_RGB565, + MEDIASUBTYPE_RGB555, + MEDIASUBTYPE_AYUV, + MEDIASUBTYPE_I420, + MEDIASUBTYPE_IYUV, + MEDIASUBTYPE_YV12, + MEDIASUBTYPE_UYVY, + MEDIASUBTYPE_YUYV, + MEDIASUBTYPE_YUY2, + MEDIASUBTYPE_NV12, + MEDIASUBTYPE_MJPG, + MEDIASUBTYPE_IMC1, + MEDIASUBTYPE_IMC2, + MEDIASUBTYPE_IMC3, + MEDIASUBTYPE_IMC4 }; + + // Negotiate the subtype + DirectShowMediaType mediaType(AM_MEDIA_TYPE { MEDIATYPE_Video }); + const int items = (sizeof subtypes / sizeof(GUID)); + bool connected = false; + for (int i = 0; i != items; ++i) { + mediaType->subtype = subtypes[i]; + m_videoSampleGrabber->setMediaType(&mediaType); + if (SUCCEEDED(DirectShowUtils::connectFilters(m_graph, m_source, m_videoSampleGrabber->filter(), true))) + connected = true; + break; + } + + if (!connected) { + qCWarning(qtDirectShowPlugin, "Unable to connect the video probe!"); + return; + } + + m_videoSampleGrabber->start(DirectShowSampleGrabber::CallbackMethod::BufferCB); +} + +void DirectShowPlayerService::doSetAudioProbe(QMutexLocker *locker) +{ + Q_UNUSED(locker); + + if (!m_graph) { + qCWarning(qtDirectShowPlugin, "Attempting to set an audio probe without a valid graph!"); + return; + } + + // Create the sample grabber, if necessary. + if (!m_audioSampleGrabber) { + m_audioSampleGrabber = new DirectShowSampleGrabber; + connect(m_audioSampleGrabber, &DirectShowSampleGrabber::bufferAvailable, this, &DirectShowPlayerService::onAudioBufferAvailable); + } + + static const AM_MEDIA_TYPE mediaType { MEDIATYPE_Audio, MEDIASUBTYPE_PCM }; + m_audioSampleGrabber->setMediaType(&mediaType); + + if (FAILED(m_graph->AddFilter(m_audioSampleGrabber->filter(), L"Audio Sample Grabber"))) { + qCWarning(qtDirectShowPlugin, "Failed to add the audio sample grabber into the graph!"); + return; + } + + if (FAILED(DirectShowUtils::connectFilters(m_graph, m_source, m_audioSampleGrabber->filter(), true))) { + qCWarning(qtDirectShowPlugin, "Failed to connect the audio sample grabber"); + return; + } + + m_audioSampleGrabber->start(DirectShowSampleGrabber::CallbackMethod::BufferCB); +} + +void DirectShowPlayerService::doReleaseVideoProbe(QMutexLocker *locker) +{ + Q_UNUSED(locker); + + if (!m_graph) + return; + + if (!m_videoSampleGrabber) + return; + + m_videoSampleGrabber->stop(); + HRESULT hr = m_graph->RemoveFilter(m_videoSampleGrabber->filter()); + if (FAILED(hr)) { + qCWarning(qtDirectShowPlugin, "Failed to remove the video sample grabber!"); + return; + } + + m_videoSampleGrabber->deleteLater(); + m_videoSampleGrabber = nullptr; +} + +void DirectShowPlayerService::doReleaseAudioProbe(QMutexLocker *locker) +{ + Q_UNUSED(locker); + + if (!m_graph) + return; + + if (!m_audioSampleGrabber) + return; + + m_audioSampleGrabber->stop(); + HRESULT hr = m_graph->RemoveFilter(m_audioSampleGrabber->filter()); + if (FAILED(hr)) { + qCWarning(qtDirectShowPlugin, "Failed to remove the audio sample grabber!"); + return; + } + + m_audioSampleGrabber->deleteLater(); + m_audioSampleGrabber = nullptr; +} + int DirectShowPlayerService::findStreamTypes(IBaseFilter *source) const { QVarLengthArray<IBaseFilter *, 16> filters; @@ -1119,6 +1314,40 @@ void DirectShowPlayerService::setVideoOutput(IBaseFilter *filter) } } +void DirectShowPlayerService::updateAudioProbe() +{ + QMutexLocker locker(&m_mutex); + + // Set/Activate the audio probe. + if (m_graph) { + // If we don't have a audio probe, then stop and release the audio sample grabber + if (!m_audioProbeControl && (m_executedTasks & SetAudioProbe)) { + m_pendingTasks |= ReleaseAudioProbe; + ::SetEvent(m_taskHandle); + m_loop->wait(&m_mutex); + } else if (m_audioProbeControl) { + m_pendingTasks |= SetAudioProbe; + } + } +} + +void DirectShowPlayerService::updateVideoProbe() +{ + QMutexLocker locker(&m_mutex); + + // Set/Activate the video probe. + if (m_graph) { + // If we don't have a video probe, then stop and release the video sample grabber + if (!m_videoProbeControl && (m_executedTasks & SetVideoProbe)) { + m_pendingTasks |= ReleaseVideoProbe; + ::SetEvent(m_taskHandle); + m_loop->wait(&m_mutex); + } else if (m_videoProbeControl){ + m_pendingTasks |= SetVideoProbe; + } + } +} + void DirectShowPlayerService::doReleaseVideoOutput(QMutexLocker *locker) { Q_UNUSED(locker) @@ -1215,6 +1444,97 @@ void DirectShowPlayerService::videoOutputChanged() setVideoOutput(m_videoRendererControl->filter()); } +void DirectShowPlayerService::onAudioBufferAvailable(double time, quint8 *buffer, long len) +{ + QMutexLocker locker(&m_mutex); + if (!m_audioProbeControl || !m_audioSampleGrabber) + return; + + DirectShowMediaType mt(AM_MEDIA_TYPE { GUID_NULL }); + const bool ok = m_audioSampleGrabber->getConnectedMediaType(&mt); + if (!ok) + return; + + if (mt->majortype != MEDIATYPE_Audio) + return; + + if (mt->subtype != MEDIASUBTYPE_PCM) + return; + + const bool isWfx = ((mt->formattype == FORMAT_WaveFormatEx) && (mt->cbFormat >= sizeof(WAVEFORMATEX))); + WAVEFORMATEX *wfx = isWfx ? reinterpret_cast<WAVEFORMATEX *>(mt->pbFormat) : nullptr; + + if (!wfx) + return; + + if (wfx->wFormatTag != WAVE_FORMAT_PCM && wfx->wFormatTag != WAVE_FORMAT_EXTENSIBLE) + return; + + if ((wfx->wFormatTag == WAVE_FORMAT_EXTENSIBLE) && (wfx->cbSize >= sizeof(WAVEFORMATEXTENSIBLE))) { + WAVEFORMATEXTENSIBLE *wfxe = reinterpret_cast<WAVEFORMATEXTENSIBLE *>(wfx); + if (wfxe->SubFormat != KSDATAFORMAT_SUBTYPE_PCM) + return; + } + + QAudioFormat format; + format.setSampleRate(wfx->nSamplesPerSec); + format.setChannelCount(wfx->nChannels); + format.setSampleSize(wfx->wBitsPerSample); + format.setCodec("audio/pcm"); + format.setByteOrder(QAudioFormat::LittleEndian); + if (format.sampleSize() == 8) + format.setSampleType(QAudioFormat::UnSignedInt); + else + format.setSampleType(QAudioFormat::SignedInt); + + const quint64 startTime = quint64(time * 1000.); + QAudioBuffer audioBuffer(QByteArray(reinterpret_cast<const char *>(buffer), len), + format, + startTime); + + Q_EMIT m_audioProbeControl->audioBufferProbed(audioBuffer); +} + +void DirectShowPlayerService::onVideoBufferAvailable(double time, quint8 *buffer, long len) +{ + Q_UNUSED(time); + Q_UNUSED(buffer); + Q_UNUSED(len); + + QMutexLocker locker(&m_mutex); + if (!m_videoProbeControl || !m_videoSampleGrabber) + return; + + DirectShowMediaType mt(AM_MEDIA_TYPE { GUID_NULL }); + const bool ok = m_videoSampleGrabber->getConnectedMediaType(&mt); + if (!ok) + return; + + if (mt->majortype != MEDIATYPE_Video) + return; + + QVideoFrame::PixelFormat format = DirectShowMediaType::pixelFormatFromType(&mt); + if (format == QVideoFrame::Format_Invalid) { + qCWarning(qtDirectShowPlugin, "Invalid format, stopping video probes!"); + m_videoSampleGrabber->stop(); + return; + } + + const QVideoSurfaceFormat &videoFormat = DirectShowMediaType::videoFormatFromType(&mt); + if (!videoFormat.isValid()) + return; + + const QSize &size = videoFormat.frameSize(); + + const int bytesPerLine = DirectShowMediaType::bytesPerLine(videoFormat); + QByteArray data(reinterpret_cast<const char *>(buffer), len); + QVideoFrame frame(new QMemoryVideoBuffer(data, bytesPerLine), + size, + format); + + Q_EMIT m_videoProbeControl->videoFrameProbed(frame); +} + void DirectShowPlayerService::graphEvent(QMutexLocker *locker) { Q_UNUSED(locker) @@ -1403,6 +1723,16 @@ void DirectShowPlayerService::run() m_executingTask = ReleaseVideoOutput; doReleaseVideoOutput(&locker); + } else if (m_pendingTasks & ReleaseAudioProbe) { + m_pendingTasks ^= ReleaseAudioProbe; + m_executingTask = ReleaseAudioProbe; + + doReleaseAudioProbe(&locker); + } else if (m_pendingTasks & ReleaseVideoProbe) { + m_pendingTasks ^= ReleaseVideoProbe; + m_executingTask = ReleaseVideoProbe; + + doReleaseVideoProbe(&locker); } else if (m_pendingTasks & SetUrlSource) { m_pendingTasks ^= SetUrlSource; m_executingTask = SetUrlSource; @@ -1413,6 +1743,16 @@ void DirectShowPlayerService::run() m_executingTask = SetStreamSource; doSetStreamSource(&locker); + } else if (m_pendingTasks & SetAudioProbe) { + m_pendingTasks ^= SetAudioProbe; + m_executingTask = SetAudioProbe; + + doSetAudioProbe(&locker); + } else if (m_pendingTasks & SetVideoProbe) { + m_pendingTasks ^= SetVideoProbe; + m_executingTask = SetVideoProbe; + + doSetVideoProbe(&locker); } else if (m_pendingTasks & Render) { m_pendingTasks ^= Render; m_executingTask = Render; @@ -1454,3 +1794,5 @@ void DirectShowPlayerService::run() m_executingTask = 0; } } + +QT_END_NAMESPACE diff --git a/src/plugins/directshow/player/directshowplayerservice.h b/src/plugins/directshow/player/directshowplayerservice.h index d933bd660..676d88fb5 100644 --- a/src/plugins/directshow/player/directshowplayerservice.h +++ b/src/plugins/directshow/player/directshowplayerservice.h @@ -55,17 +55,18 @@ #include <QtCore/qurl.h> #include <QtCore/qwaitcondition.h> +QT_BEGIN_NAMESPACE + class DirectShowAudioEndpointControl; class DirectShowMetaDataControl; class DirectShowPlayerControl; class DirectShowVideoRendererControl; +class DirectShowAudioProbeControl; +class DirectShowVideoProbeControl; +class DirectShowSampleGrabber; -QT_BEGIN_NAMESPACE class QMediaContent; class QVideoWindowControl; -QT_END_NAMESPACE - -QT_USE_NAMESPACE class DirectShowPlayerService : public QMediaService { @@ -105,10 +106,16 @@ protected: private Q_SLOTS: void videoOutputChanged(); + void onAudioBufferAvailable(double time, quint8 *buffer, long len); + void onVideoBufferAvailable(double time, quint8 *buffer, long len); + private: void releaseGraph(); void updateStatus(); + void updateAudioProbe(); + void updateVideoProbe(); + int findStreamTypes(IBaseFilter *source) const; int findStreamType(IPin *pin) const; @@ -129,29 +136,40 @@ private: void doReleaseAudioOutput(QMutexLocker *locker); void doReleaseVideoOutput(QMutexLocker *locker); void doReleaseGraph(QMutexLocker *locker); + void doSetVideoProbe(QMutexLocker *locker); + void doSetAudioProbe(QMutexLocker *locker); + void doReleaseVideoProbe(QMutexLocker *locker); + void doReleaseAudioProbe(QMutexLocker *locker); void graphEvent(QMutexLocker *locker); enum Task { - Shutdown = 0x0001, - SetUrlSource = 0x0002, - SetStreamSource = 0x0004, + Shutdown = 0x00001, + SetUrlSource = 0x00002, + SetStreamSource = 0x00004, SetSource = SetUrlSource | SetStreamSource, - SetAudioOutput = 0x0008, - SetVideoOutput = 0x0010, + SetAudioOutput = 0x00008, + SetVideoOutput = 0x00010, SetOutputs = SetAudioOutput | SetVideoOutput, - Render = 0x0020, - FinalizeLoad = 0x0040, - SetRate = 0x0080, - Seek = 0x0100, - Play = 0x0200, - Pause = 0x0400, - Stop = 0x0800, - ReleaseGraph = 0x1000, - ReleaseAudioOutput = 0x2000, - ReleaseVideoOutput = 0x4000, - ReleaseFilters = ReleaseGraph | ReleaseAudioOutput | ReleaseVideoOutput + SetAudioProbe = 0x00020, + SetVideoProbe = 0x00040, + SetProbes = SetAudioProbe | SetVideoProbe, + Render = 0x00080, + FinalizeLoad = 0x00100, + SetRate = 0x00200, + Seek = 0x00400, + Play = 0x00800, + Pause = 0x01000, + Stop = 0x02000, + ReleaseGraph = 0x04000, + ReleaseAudioOutput = 0x08000, + ReleaseVideoOutput = 0x10000, + ReleaseAudioProbe = 0x20000, + ReleaseVideoProbe = 0x40000, + ReleaseFilters = ReleaseGraph | ReleaseAudioOutput + | ReleaseVideoOutput | ReleaseAudioProbe + | ReleaseVideoProbe }; enum Event @@ -180,6 +198,10 @@ private: DirectShowVideoRendererControl *m_videoRendererControl; QVideoWindowControl *m_videoWindowControl; DirectShowAudioEndpointControl *m_audioEndpointControl; + DirectShowAudioProbeControl *m_audioProbeControl; + DirectShowVideoProbeControl *m_videoProbeControl; + DirectShowSampleGrabber *m_audioSampleGrabber; + DirectShowSampleGrabber *m_videoSampleGrabber; QThread *m_taskThread; DirectShowEventLoop *m_loop; @@ -213,5 +235,6 @@ private: friend class DirectShowPlayerServiceThread; }; +QT_END_NAMESPACE #endif diff --git a/src/plugins/directshow/player/directshowvideorenderercontrol.h b/src/plugins/directshow/player/directshowvideorenderercontrol.h index 36c5b2248..ce515a329 100644 --- a/src/plugins/directshow/player/directshowvideorenderercontrol.h +++ b/src/plugins/directshow/player/directshowvideorenderercontrol.h @@ -47,13 +47,13 @@ #include <QtMultimedia/private/qtmultimedia-config_p.h> +QT_BEGIN_NAMESPACE + class DirectShowEventLoop; #if QT_CONFIG(evr) class EVRCustomPresenter; #endif -QT_USE_NAMESPACE - class DirectShowVideoRendererControl : public QVideoRendererControl { Q_OBJECT @@ -78,4 +78,6 @@ private: #endif }; +QT_END_NAMESPACE + #endif diff --git a/src/plugins/directshow/player/player.pri b/src/plugins/directshow/player/player.pri index 59ac5a330..9111cc545 100644 --- a/src/plugins/directshow/player/player.pri +++ b/src/plugins/directshow/player/player.pri @@ -3,6 +3,8 @@ INCLUDEPATH += $$PWD QMAKE_USE += directshow LIBS += -lgdi32 +mingw: LIBS_PRIVATE += -lksuser + qtHaveModule(widgets): QT += widgets HEADERS += \ diff --git a/src/plugins/directshow/player/videosurfacefilter.cpp b/src/plugins/directshow/player/videosurfacefilter.cpp index 13f767a85..656cd5a7c 100644 --- a/src/plugins/directshow/player/videosurfacefilter.cpp +++ b/src/plugins/directshow/player/videosurfacefilter.cpp @@ -49,6 +49,8 @@ #include <initguid.h> +QT_BEGIN_NAMESPACE + Q_LOGGING_CATEGORY(qLcRenderFilter, "qt.multimedia.plugins.directshow.renderfilter") // { e23cad72-153d-406c-bf3f-4c4b523d96f2 } @@ -786,3 +788,5 @@ bool VideoSurfaceFilter::event(QEvent *e) return QObject::event(e); } + +QT_END_NAMESPACE diff --git a/src/plugins/directshow/player/videosurfacefilter.h b/src/plugins/directshow/player/videosurfacefilter.h index 6d6cc7593..ad253d564 100644 --- a/src/plugins/directshow/player/videosurfacefilter.h +++ b/src/plugins/directshow/player/videosurfacefilter.h @@ -49,8 +49,8 @@ #include <qwaitcondition.h> QT_BEGIN_NAMESPACE + class QAbstractVideoSurface; -QT_END_NAMESPACE class DirectShowEventLoop; class VideoSurfaceInputPin; @@ -157,4 +157,6 @@ private: friend class VideoSurfaceInputPin; }; +QT_END_NAMESPACE + #endif diff --git a/src/plugins/directshow/player/vmr9videowindowcontrol.h b/src/plugins/directshow/player/vmr9videowindowcontrol.h index 6f6e55362..ed3b53233 100644 --- a/src/plugins/directshow/player/vmr9videowindowcontrol.h +++ b/src/plugins/directshow/player/vmr9videowindowcontrol.h @@ -46,7 +46,7 @@ #include <d3d9.h> #include <vmr9.h> -QT_USE_NAMESPACE +QT_BEGIN_NAMESPACE class Vmr9VideoWindowControl : public QVideoWindowControl { @@ -103,4 +103,6 @@ private: bool m_fullScreen; }; +QT_END_NAMESPACE + #endif |