summaryrefslogtreecommitdiffstats
path: root/src/plugins/multimedia/windows/decoder
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins/multimedia/windows/decoder')
-rw-r--r--src/plugins/multimedia/windows/decoder/mfaudiodecodercontrol.cpp90
-rw-r--r--src/plugins/multimedia/windows/decoder/mfaudiodecodercontrol_p.h50
-rw-r--r--src/plugins/multimedia/windows/decoder/mfdecodersourcereader.cpp71
-rw-r--r--src/plugins/multimedia/windows/decoder/mfdecodersourcereader_p.h55
4 files changed, 69 insertions, 197 deletions
diff --git a/src/plugins/multimedia/windows/decoder/mfaudiodecodercontrol.cpp b/src/plugins/multimedia/windows/decoder/mfaudiodecodercontrol.cpp
index 7cc162204..912ab5e94 100644
--- a/src/plugins/multimedia/windows/decoder/mfaudiodecodercontrol.cpp
+++ b/src/plugins/multimedia/windows/decoder/mfaudiodecodercontrol.cpp
@@ -1,55 +1,21 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 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$
-**
-****************************************************************************/
+// Copyright (C) 2016 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 <system_error>
#include <mferror.h>
#include <qglobal.h>
-#include "Wmcodecdsp.h"
+#include "wmcodecdsp.h"
#include "mfaudiodecodercontrol_p.h"
#include <private/qwindowsaudioutils_p.h>
+QT_BEGIN_NAMESPACE
+
MFAudioDecoderControl::MFAudioDecoderControl(QAudioDecoder *parent)
: QPlatformAudioDecoder(parent)
, m_sourceResolver(new SourceResolver)
{
- connect(m_sourceResolver, SIGNAL(mediaSourceReady()), this, SLOT(handleMediaSourceReady()));
- connect(m_sourceResolver, SIGNAL(error(long)), this, SLOT(handleMediaSourceError(long)));
+ connect(m_sourceResolver, &SourceResolver::mediaSourceReady, this, &MFAudioDecoderControl::handleMediaSourceReady);
+ connect(m_sourceResolver, &SourceResolver::error, this, &MFAudioDecoderControl::handleMediaSourceError);
}
MFAudioDecoderControl::~MFAudioDecoderControl()
@@ -121,22 +87,22 @@ void MFAudioDecoderControl::startReadingSource(IMFMediaSource *source)
{
Q_ASSERT(source);
- m_decoderSourceReader.reset(new MFDecoderSourceReader());
+ m_decoderSourceReader = makeComObject<MFDecoderSourceReader>();
if (!m_decoderSourceReader) {
error(QAudioDecoder::ResourceError, tr("Could not instantiate MFDecoderSourceReader"));
return;
}
auto mediaType = m_decoderSourceReader->setSource(source, m_outputFormat.sampleFormat());
- QAudioFormat mediaFormat = QWindowsAudioUtils::mediaTypeToFormat(mediaType.get());
+ QAudioFormat mediaFormat = QWindowsAudioUtils::mediaTypeToFormat(mediaType.Get());
if (!mediaFormat.isValid()) {
error(QAudioDecoder::FormatError, tr("Invalid media format"));
- m_decoderSourceReader.reset();
+ m_decoderSourceReader.Reset();
return;
}
- QWindowsIUPointer<IMFPresentationDescriptor> pd;
- if (SUCCEEDED(source->CreatePresentationDescriptor(pd.address()))) {
+ ComPtr<IMFPresentationDescriptor> pd;
+ if (SUCCEEDED(source->CreatePresentationDescriptor(pd.GetAddressOf()))) {
UINT64 duration = 0;
pd->GetUINT64(MF_PD_DURATION, &duration);
duration /= 10000;
@@ -145,12 +111,12 @@ void MFAudioDecoderControl::startReadingSource(IMFMediaSource *source)
}
if (!m_resampler.setup(mediaFormat, m_outputFormat.isValid() ? m_outputFormat : mediaFormat)) {
- qWarning() << "Failed to setup resampler";
+ qWarning() << "Failed to set up resampler";
return;
}
- connect(m_decoderSourceReader.get(), SIGNAL(finished()), this, SLOT(handleSourceFinished()));
- connect(m_decoderSourceReader.get(), SIGNAL(newSample(QWindowsIUPointer<IMFSample>)), this, SLOT(handleNewSample(QWindowsIUPointer<IMFSample>)));
+ connect(m_decoderSourceReader.Get(), &MFDecoderSourceReader::finished, this, &MFAudioDecoderControl::handleSourceFinished);
+ connect(m_decoderSourceReader.Get(), &MFDecoderSourceReader::newSample, this, &MFAudioDecoderControl::handleNewSample);
setIsDecoding(true);
@@ -186,14 +152,14 @@ void MFAudioDecoderControl::stop()
if (!isDecoding())
return;
- disconnect(m_decoderSourceReader.get());
+ disconnect(m_decoderSourceReader.Get());
m_decoderSourceReader->clearSource();
- m_decoderSourceReader.reset();
+ m_decoderSourceReader.Reset();
if (bufferAvailable()) {
QAudioBuffer buffer;
m_audioBuffer.swap(buffer);
- emit bufferAvailableChanged(false);
+ bufferAvailableChanged(false);
}
setIsDecoding(false);
@@ -207,12 +173,12 @@ void MFAudioDecoderControl::stop()
}
}
-void MFAudioDecoderControl::handleNewSample(QWindowsIUPointer<IMFSample> sample)
+void MFAudioDecoderControl::handleNewSample(ComPtr<IMFSample> sample)
{
Q_ASSERT(sample);
qint64 sampleStartTimeUs = m_resampler.outputFormat().durationForBytes(m_resampler.totalOutputBytes());
- QByteArray out = m_resampler.resample(sample.get());
+ QByteArray out = m_resampler.resample(sample.Get());
if (out.isEmpty()) {
error(QAudioDecoder::Error::ResourceError, tr("Failed processing a sample"));
@@ -220,15 +186,15 @@ void MFAudioDecoderControl::handleNewSample(QWindowsIUPointer<IMFSample> sample)
} else {
m_audioBuffer = QAudioBuffer(out, m_resampler.outputFormat(), sampleStartTimeUs);
- emit bufferAvailableChanged(true);
- emit bufferReady();
+ bufferAvailableChanged(true);
+ bufferReady();
}
}
void MFAudioDecoderControl::handleSourceFinished()
{
stop();
- emit finished();
+ finished();
}
void MFAudioDecoderControl::setAudioFormat(const QAudioFormat &format)
@@ -236,7 +202,7 @@ void MFAudioDecoderControl::setAudioFormat(const QAudioFormat &format)
if (m_outputFormat == format)
return;
m_outputFormat = format;
- emit formatChanged(m_outputFormat);
+ formatChanged(m_outputFormat);
}
QAudioBuffer MFAudioDecoderControl::read()
@@ -246,10 +212,14 @@ QAudioBuffer MFAudioDecoderControl::read()
if (bufferAvailable()) {
buffer.swap(m_audioBuffer);
m_position = buffer.startTime() / 1000;
- emit positionChanged(m_position);
- emit bufferAvailableChanged(false);
+ positionChanged(m_position);
+ bufferAvailableChanged(false);
m_decoderSourceReader->readNextSample();
}
return buffer;
}
+
+QT_END_NAMESPACE
+
+#include "moc_mfaudiodecodercontrol_p.cpp"
diff --git a/src/plugins/multimedia/windows/decoder/mfaudiodecodercontrol_p.h b/src/plugins/multimedia/windows/decoder/mfaudiodecodercontrol_p.h
index 0b1b42198..9bb2371ec 100644
--- a/src/plugins/multimedia/windows/decoder/mfaudiodecodercontrol_p.h
+++ b/src/plugins/multimedia/windows/decoder/mfaudiodecodercontrol_p.h
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 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$
-**
-****************************************************************************/
+// Copyright (C) 2016 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
#ifndef MFAUDIODECODERCONTROL_H
#define MFAUDIODECODERCONTROL_H
@@ -54,10 +18,10 @@
#include "mfdecodersourcereader_p.h"
#include <private/qplatformaudiodecoder_p.h>
#include <sourceresolver_p.h>
-#include <private/qwindowsiupointer_p.h>
+#include <private/qcomptr_p.h>
#include <private/qwindowsresampler_p.h>
-QT_USE_NAMESPACE
+QT_BEGIN_NAMESPACE
class MFAudioDecoderControl : public QPlatformAudioDecoder
{
@@ -87,13 +51,13 @@ public:
private Q_SLOTS:
void handleMediaSourceReady();
void handleMediaSourceError(long hr);
- void handleNewSample(QWindowsIUPointer<IMFSample>);
+ void handleNewSample(ComPtr<IMFSample>);
void handleSourceFinished();
private:
void startReadingSource(IMFMediaSource *source);
- QWindowsIUPointer<MFDecoderSourceReader> m_decoderSourceReader;
+ ComPtr<MFDecoderSourceReader> m_decoderSourceReader;
SourceResolver *m_sourceResolver;
QWindowsResampler m_resampler;
QUrl m_source;
@@ -106,4 +70,6 @@ private:
bool m_deferredStart = false;
};
+QT_END_NAMESPACE
+
#endif//MFAUDIODECODERCONTROL_H
diff --git a/src/plugins/multimedia/windows/decoder/mfdecodersourcereader.cpp b/src/plugins/multimedia/windows/decoder/mfdecodersourcereader.cpp
index e0b54dcde..097f83437 100644
--- a/src/plugins/multimedia/windows/decoder/mfdecodersourcereader.cpp
+++ b/src/plugins/multimedia/windows/decoder/mfdecodersourcereader.cpp
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 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$
-**
-****************************************************************************/
+// Copyright (C) 2016 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 <system_error>
#include <mferror.h>
@@ -43,24 +7,26 @@
#include <qdebug.h>
#include "mfdecodersourcereader_p.h"
-QWindowsIUPointer<IMFMediaType> MFDecoderSourceReader::setSource(IMFMediaSource *source, QAudioFormat::SampleFormat sampleFormat)
+QT_BEGIN_NAMESPACE
+
+ComPtr<IMFMediaType> MFDecoderSourceReader::setSource(IMFMediaSource *source, QAudioFormat::SampleFormat sampleFormat)
{
- QWindowsIUPointer<IMFMediaType> mediaType;
- m_sourceReader.reset();
+ ComPtr<IMFMediaType> mediaType;
+ m_sourceReader.Reset();
if (!source)
return mediaType;
- QWindowsIUPointer<IMFAttributes> attr;
- MFCreateAttributes(attr.address(), 1);
+ ComPtr<IMFAttributes> attr;
+ MFCreateAttributes(attr.GetAddressOf(), 1);
if (FAILED(attr->SetUnknown(MF_SOURCE_READER_ASYNC_CALLBACK, this)))
return mediaType;
if (FAILED(attr->SetUINT32(MF_SOURCE_READER_DISCONNECT_MEDIASOURCE_ON_SHUTDOWN, TRUE)))
return mediaType;
- HRESULT hr = MFCreateSourceReaderFromMediaSource(source, attr.get(), m_sourceReader.address());
+ HRESULT hr = MFCreateSourceReaderFromMediaSource(source, attr.Get(), m_sourceReader.GetAddressOf());
if (FAILED(hr)) {
- qWarning() << "MFDecoderSourceReader: failed to setup source reader: "
+ qWarning() << "MFDecoderSourceReader: failed to set up source reader: "
<< std::system_category().message(hr).c_str();
return mediaType;
}
@@ -68,12 +34,12 @@ QWindowsIUPointer<IMFMediaType> MFDecoderSourceReader::setSource(IMFMediaSource
m_sourceReader->SetStreamSelection(DWORD(MF_SOURCE_READER_ALL_STREAMS), FALSE);
m_sourceReader->SetStreamSelection(DWORD(MF_SOURCE_READER_FIRST_AUDIO_STREAM), TRUE);
- QWindowsIUPointer<IMFMediaType> pPartialType;
- MFCreateMediaType(pPartialType.address());
+ ComPtr<IMFMediaType> pPartialType;
+ MFCreateMediaType(pPartialType.GetAddressOf());
pPartialType->SetGUID(MF_MT_MAJOR_TYPE, MFMediaType_Audio);
pPartialType->SetGUID(MF_MT_SUBTYPE, sampleFormat == QAudioFormat::Float ? MFAudioFormat_Float : MFAudioFormat_PCM);
- m_sourceReader->SetCurrentMediaType(DWORD(MF_SOURCE_READER_FIRST_AUDIO_STREAM), nullptr, pPartialType.get());
- m_sourceReader->GetCurrentMediaType(DWORD(MF_SOURCE_READER_FIRST_AUDIO_STREAM), mediaType.address());
+ m_sourceReader->SetCurrentMediaType(DWORD(MF_SOURCE_READER_FIRST_AUDIO_STREAM), nullptr, pPartialType.Get());
+ m_sourceReader->GetCurrentMediaType(DWORD(MF_SOURCE_READER_FIRST_AUDIO_STREAM), mediaType.GetAddressOf());
// Ensure the stream is selected.
m_sourceReader->SetStreamSelection(DWORD(MF_SOURCE_READER_FIRST_AUDIO_STREAM), TRUE);
@@ -125,10 +91,13 @@ STDMETHODIMP MFDecoderSourceReader::OnReadSample(HRESULT hrStatus, DWORD dwStrea
Q_UNUSED(dwStreamIndex);
Q_UNUSED(llTimestamp);
if (pSample) {
- pSample->AddRef();
- emit newSample(QWindowsIUPointer{pSample});
+ emit newSample(ComPtr<IMFSample>{pSample});
} else if ((dwStreamFlags & MF_SOURCE_READERF_ENDOFSTREAM) == MF_SOURCE_READERF_ENDOFSTREAM) {
emit finished();
}
return S_OK;
}
+
+QT_END_NAMESPACE
+
+#include "moc_mfdecodersourcereader_p.cpp"
diff --git a/src/plugins/multimedia/windows/decoder/mfdecodersourcereader_p.h b/src/plugins/multimedia/windows/decoder/mfdecodersourcereader_p.h
index da35f466e..dee6f8bf5 100644
--- a/src/plugins/multimedia/windows/decoder/mfdecodersourcereader_p.h
+++ b/src/plugins/multimedia/windows/decoder/mfdecodersourcereader_p.h
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt Mobility Components.
-**
-** $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$
-**
-****************************************************************************/
+// Copyright (C) 2016 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
#ifndef MFDECODERSOURCEREADER_H
#define MFDECODERSOURCEREADER_H
@@ -57,9 +21,9 @@
#include <QtCore/qobject.h>
#include "qaudioformat.h"
-#include <private/qwindowsiupointer_p.h>
+#include <private/qcomptr_p.h>
-QT_USE_NAMESPACE
+QT_BEGIN_NAMESPACE
class MFDecoderSourceReader : public QObject, public IMFSourceReaderCallback
{
@@ -68,8 +32,8 @@ public:
MFDecoderSourceReader() {}
~MFDecoderSourceReader() override {}
- void clearSource() { m_sourceReader.reset(); }
- QWindowsIUPointer<IMFMediaType> setSource(IMFMediaSource *source, QAudioFormat::SampleFormat);
+ void clearSource() { m_sourceReader.Reset(); }
+ ComPtr<IMFMediaType> setSource(IMFMediaSource *source, QAudioFormat::SampleFormat);
void readNextSample();
@@ -85,12 +49,15 @@ public:
STDMETHODIMP OnEvent(DWORD, IMFMediaEvent *) override { return S_OK; }
Q_SIGNALS:
- void newSample(QWindowsIUPointer<IMFSample>);
+ void newSample(ComPtr<IMFSample>);
void finished();
private:
long m_cRef = 1;
- QWindowsIUPointer<IMFSourceReader> m_sourceReader;
+ ComPtr<IMFSourceReader> m_sourceReader;
};
+
+QT_END_NAMESPACE
+
#endif//MFDECODERSOURCEREADER_H