summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJames McDonnell <jmcdonnell@blackberry.com>2017-04-03 16:36:46 -0400
committerJames McDonnell <jmcdonnell@blackberry.com>2017-11-14 17:03:28 +0000
commitc16ce50f2b3362c70d9e1cdf6382b9950e552509 (patch)
tree07fcc4965bb2f517642180f2f5052c166a04f3b7
parent1cb4027e0a59e1875db88b72afb5833aafbd87eb (diff)
Implement QCustomAudioRoleControl for QNX
Change-Id: I95202ffabbeae36dbb2f2fa43871e0bceed53cae Reviewed-by: Christian Stromme <christian.stromme@qt.io>
-rw-r--r--examples/multimediawidgets/player/main.cpp9
-rw-r--r--examples/multimediawidgets/player/player.cpp5
-rw-r--r--examples/multimediawidgets/player/player.h1
-rw-r--r--src/plugins/qnx/mediaplayer/mediaplayer.pri6
-rw-r--r--src/plugins/qnx/mediaplayer/mmrenderercustomaudiorolecontrol.cpp67
-rw-r--r--src/plugins/qnx/mediaplayer/mmrenderercustomaudiorolecontrol.h63
-rw-r--r--src/plugins/qnx/mediaplayer/mmrenderermediaplayercontrol.cpp11
-rw-r--r--src/plugins/qnx/mediaplayer/mmrenderermediaplayercontrol.h3
-rw-r--r--src/plugins/qnx/mediaplayer/mmrenderermediaplayerservice.cpp13
-rw-r--r--src/plugins/qnx/mediaplayer/mmrenderermediaplayerservice.h2
10 files changed, 176 insertions, 4 deletions
diff --git a/examples/multimediawidgets/player/main.cpp b/examples/multimediawidgets/player/main.cpp
index 9e6d9358c..a20fb1c4f 100644
--- a/examples/multimediawidgets/player/main.cpp
+++ b/examples/multimediawidgets/player/main.cpp
@@ -63,14 +63,21 @@ int main(int argc, char *argv[])
QCoreApplication::setOrganizationName("QtProject");
QCoreApplication::setApplicationVersion(QT_VERSION_STR);
QCommandLineParser parser;
+ QCommandLineOption customAudioRoleOption("custom-audio-role",
+ "Set a custom audio role for the player.",
+ "role");
parser.setApplicationDescription("Qt MultiMedia Player Example");
parser.addHelpOption();
parser.addVersionOption();
- parser.addPositionalArgument("url", "The URL to open.");
+ parser.addOption(customAudioRoleOption);
+ parser.addPositionalArgument("url", "The URL(s) to open.");
parser.process(app);
Player player;
+ if (parser.isSet(customAudioRoleOption))
+ player.setCustomAudioRole(parser.value(customAudioRoleOption));
+
if (!parser.positionalArguments().isEmpty() && player.isPlayerAvailable()) {
QList<QUrl> urls;
for (auto &a: parser.positionalArguments())
diff --git a/examples/multimediawidgets/player/player.cpp b/examples/multimediawidgets/player/player.cpp
index 8113df70e..4d3340855 100644
--- a/examples/multimediawidgets/player/player.cpp
+++ b/examples/multimediawidgets/player/player.cpp
@@ -234,6 +234,11 @@ void Player::addToPlaylist(const QList<QUrl> &urls)
}
}
+void Player::setCustomAudioRole(const QString &role)
+{
+ m_player->setCustomAudioRole(role);
+}
+
void Player::durationChanged(qint64 duration)
{
m_duration = duration / 1000;
diff --git a/examples/multimediawidgets/player/player.h b/examples/multimediawidgets/player/player.h
index 1b30204f9..a15d27bd7 100644
--- a/examples/multimediawidgets/player/player.h
+++ b/examples/multimediawidgets/player/player.h
@@ -81,6 +81,7 @@ public:
bool isPlayerAvailable() const;
void addToPlaylist(const QList<QUrl> &urls);
+ void setCustomAudioRole(const QString &role);
signals:
void fullScreenChanged(bool fullScreen);
diff --git a/src/plugins/qnx/mediaplayer/mediaplayer.pri b/src/plugins/qnx/mediaplayer/mediaplayer.pri
index 71bb98827..f39b542cc 100644
--- a/src/plugins/qnx/mediaplayer/mediaplayer.pri
+++ b/src/plugins/qnx/mediaplayer/mediaplayer.pri
@@ -10,7 +10,8 @@ HEADERS += \
$$PWD/mmrendererutil.h \
$$PWD/mmrenderervideowindowcontrol.h \
$$PWD/mmreventmediaplayercontrol.h \
- $$PWD/mmreventthread.h
+ $$PWD/mmreventthread.h \
+ $$PWD/mmrenderercustomaudiorolecontrol.h
SOURCES += \
$$PWD/mmrendereraudiorolecontrol.cpp \
$$PWD/mmrenderermediaplayercontrol.cpp \
@@ -21,6 +22,7 @@ SOURCES += \
$$PWD/mmrendererutil.cpp \
$$PWD/mmrenderervideowindowcontrol.cpp \
$$PWD/mmreventmediaplayercontrol.cpp \
- $$PWD/mmreventthread.cpp
+ $$PWD/mmreventthread.cpp \
+ $$PWD/mmrenderercustomaudiorolecontrol.cpp
QMAKE_USE += mmrenderer
diff --git a/src/plugins/qnx/mediaplayer/mmrenderercustomaudiorolecontrol.cpp b/src/plugins/qnx/mediaplayer/mmrenderercustomaudiorolecontrol.cpp
new file mode 100644
index 000000000..c8971d41c
--- /dev/null
+++ b/src/plugins/qnx/mediaplayer/mmrenderercustomaudiorolecontrol.cpp
@@ -0,0 +1,67 @@
+/****************************************************************************
+**
+** Copyright (C) 2017 QNX Software Systems. All rights reserved.
+** 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$
+**
+****************************************************************************/
+#include "mmrenderercustomaudiorolecontrol.h"
+#include "mmrendererutil.h"
+
+QT_BEGIN_NAMESPACE
+
+MmRendererCustomAudioRoleControl::MmRendererCustomAudioRoleControl(QObject *parent)
+ : QCustomAudioRoleControl(parent)
+{
+}
+
+QString MmRendererCustomAudioRoleControl::customAudioRole() const
+{
+ return m_role;
+}
+
+void MmRendererCustomAudioRoleControl::setCustomAudioRole(const QString &role)
+{
+ if (m_role != role) {
+ m_role = role;
+ emit customAudioRoleChanged(m_role);
+ }
+}
+
+QStringList MmRendererCustomAudioRoleControl::supportedCustomAudioRoles() const
+{
+ return QStringList();
+}
+
+QT_END_NAMESPACE
diff --git a/src/plugins/qnx/mediaplayer/mmrenderercustomaudiorolecontrol.h b/src/plugins/qnx/mediaplayer/mmrenderercustomaudiorolecontrol.h
new file mode 100644
index 000000000..ff16f9355
--- /dev/null
+++ b/src/plugins/qnx/mediaplayer/mmrenderercustomaudiorolecontrol.h
@@ -0,0 +1,63 @@
+/****************************************************************************
+**
+** Copyright (C) 2017 QNX Software Systems. All rights reserved.
+** 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 MMRENDERERCUSTOMAUDIOROLECONTROL_H
+#define MMRENDERERCUSTOMAUDIOROLECONTROL_H
+
+#include <qcustomaudiorolecontrol.h>
+
+QT_BEGIN_NAMESPACE
+
+class MmRendererCustomAudioRoleControl : public QCustomAudioRoleControl
+{
+ Q_OBJECT
+public:
+ explicit MmRendererCustomAudioRoleControl(QObject *parent = 0);
+
+ QString customAudioRole() const Q_DECL_OVERRIDE;
+ void setCustomAudioRole(const QString &role) Q_DECL_OVERRIDE;
+
+ QStringList supportedCustomAudioRoles() const Q_DECL_OVERRIDE;
+
+private:
+ QString m_role;
+};
+
+QT_END_NAMESPACE
+
+#endif
diff --git a/src/plugins/qnx/mediaplayer/mmrenderermediaplayercontrol.cpp b/src/plugins/qnx/mediaplayer/mmrenderermediaplayercontrol.cpp
index 55116f642..be2739941 100644
--- a/src/plugins/qnx/mediaplayer/mmrenderermediaplayercontrol.cpp
+++ b/src/plugins/qnx/mediaplayer/mmrenderermediaplayercontrol.cpp
@@ -37,6 +37,7 @@
**
****************************************************************************/
#include "mmrendereraudiorolecontrol.h"
+#include "mmrenderercustomaudiorolecontrol.h"
#include "mmrenderermediaplayercontrol.h"
#include "mmrenderermetadatareadercontrol.h"
#include "mmrendererplayervideorenderercontrol.h"
@@ -180,7 +181,10 @@ void MmRendererMediaPlayerControl::attach()
}
if (m_audioId != -1 && m_audioRoleControl) {
- QString audioType = qnxAudioType(m_audioRoleControl->audioRole());
+ QAudio::Role audioRole = m_audioRoleControl->audioRole();
+ QString audioType = (audioRole == QAudio::CustomRole && m_customAudioRoleControl)
+ ? m_customAudioRoleControl->customAudioRole()
+ : qnxAudioType(audioRole);
QByteArray latin1AudioType = audioType.toLatin1();
if (!audioType.isEmpty() && latin1AudioType == audioType) {
strm_dict_t *dict = strm_dict_new();
@@ -547,6 +551,11 @@ void MmRendererMediaPlayerControl::setAudioRoleControl(MmRendererAudioRoleContro
m_audioRoleControl = audioRoleControl;
}
+void MmRendererMediaPlayerControl::setCustomAudioRoleControl(MmRendererCustomAudioRoleControl *customAudioRoleControl)
+{
+ m_customAudioRoleControl = customAudioRoleControl;
+}
+
void MmRendererMediaPlayerControl::setMmPosition(qint64 newPosition)
{
if (newPosition != 0 && newPosition != m_position) {
diff --git a/src/plugins/qnx/mediaplayer/mmrenderermediaplayercontrol.h b/src/plugins/qnx/mediaplayer/mmrenderermediaplayercontrol.h
index dbac4aeb0..e1530689e 100644
--- a/src/plugins/qnx/mediaplayer/mmrenderermediaplayercontrol.h
+++ b/src/plugins/qnx/mediaplayer/mmrenderermediaplayercontrol.h
@@ -53,6 +53,7 @@ typedef struct strm_dict strm_dict_t;
QT_BEGIN_NAMESPACE
class MmRendererAudioRoleControl;
+class MmRendererCustomAudioRoleControl;
class MmRendererMetaDataReaderControl;
class MmRendererPlayerVideoRendererControl;
class MmRendererVideoWindowControl;
@@ -105,6 +106,7 @@ public:
void setVideoWindowControl(MmRendererVideoWindowControl *videoControl);
void setMetaDataReaderControl(MmRendererMetaDataReaderControl *metaDataReaderControl);
void setAudioRoleControl(MmRendererAudioRoleControl *audioRoleControl);
+ void setCustomAudioRoleControl(MmRendererCustomAudioRoleControl *customAudioRoleControl);
protected:
virtual void startMonitoring() = 0;
@@ -158,6 +160,7 @@ private:
QPointer<MmRendererVideoWindowControl> m_videoWindowControl;
QPointer<MmRendererMetaDataReaderControl> m_metaDataReaderControl;
QPointer<MmRendererAudioRoleControl> m_audioRoleControl;
+ QPointer<MmRendererCustomAudioRoleControl> m_customAudioRoleControl;
MmRendererMetaData m_metaData;
qint64 m_position;
QMediaPlayer::MediaStatus m_mediaStatus;
diff --git a/src/plugins/qnx/mediaplayer/mmrenderermediaplayerservice.cpp b/src/plugins/qnx/mediaplayer/mmrenderermediaplayerservice.cpp
index 257c437ce..190cb8b80 100644
--- a/src/plugins/qnx/mediaplayer/mmrenderermediaplayerservice.cpp
+++ b/src/plugins/qnx/mediaplayer/mmrenderermediaplayerservice.cpp
@@ -39,6 +39,7 @@
#include "mmrenderermediaplayerservice.h"
#include "mmrendereraudiorolecontrol.h"
+#include "mmrenderercustomaudiorolecontrol.h"
#include "mmrenderermediaplayercontrol.h"
#include "mmrenderermetadatareadercontrol.h"
#include "mmrendererplayervideorenderercontrol.h"
@@ -68,6 +69,7 @@ MmRendererMediaPlayerService::~MmRendererMediaPlayerService()
delete m_mediaPlayerControl;
delete m_metaDataReaderControl;
delete m_audioRoleControl;
+ delete m_customAudioRoleControl;
}
QMediaControl *MmRendererMediaPlayerService::requestControl(const char *name)
@@ -90,6 +92,12 @@ QMediaControl *MmRendererMediaPlayerService::requestControl(const char *name)
updateControls();
}
return m_audioRoleControl;
+ } else if (qstrcmp(name, QCustomAudioRoleControl_iid) == 0) {
+ if (!m_customAudioRoleControl) {
+ m_customAudioRoleControl = new MmRendererCustomAudioRoleControl();
+ updateControls();
+ }
+ return m_customAudioRoleControl;
} else if (qstrcmp(name, QVideoRendererControl_iid) == 0) {
if (!m_appHasDrmPermissionChecked) {
m_appHasDrmPermission = checkForDrmPermission();
@@ -130,6 +138,8 @@ void MmRendererMediaPlayerService::releaseControl(QMediaControl *control)
m_metaDataReaderControl = 0;
if (control == m_audioRoleControl)
m_audioRoleControl = 0;
+ if (control == m_customAudioRoleControl)
+ m_customAudioRoleControl = 0;
delete control;
}
@@ -146,6 +156,9 @@ void MmRendererMediaPlayerService::updateControls()
if (m_audioRoleControl && m_mediaPlayerControl)
m_mediaPlayerControl->setAudioRoleControl(m_audioRoleControl);
+
+ if (m_customAudioRoleControl && m_mediaPlayerControl)
+ m_mediaPlayerControl->setCustomAudioRoleControl(m_customAudioRoleControl);
}
QT_END_NAMESPACE
diff --git a/src/plugins/qnx/mediaplayer/mmrenderermediaplayerservice.h b/src/plugins/qnx/mediaplayer/mmrenderermediaplayerservice.h
index b1d26a9b9..ab3054af5 100644
--- a/src/plugins/qnx/mediaplayer/mmrenderermediaplayerservice.h
+++ b/src/plugins/qnx/mediaplayer/mmrenderermediaplayerservice.h
@@ -45,6 +45,7 @@
QT_BEGIN_NAMESPACE
class MmRendererAudioRoleControl;
+class MmRendererCustomAudioRoleControl;
class MmRendererMediaPlayerControl;
class MmRendererMetaDataReaderControl;
class MmRendererPlayerVideoRendererControl;
@@ -68,6 +69,7 @@ private:
QPointer<MmRendererMediaPlayerControl> m_mediaPlayerControl;
QPointer<MmRendererMetaDataReaderControl> m_metaDataReaderControl;
QPointer<MmRendererAudioRoleControl> m_audioRoleControl;
+ QPointer<MmRendererCustomAudioRoleControl> m_customAudioRoleControl;
bool m_appHasDrmPermission : 1;
bool m_appHasDrmPermissionChecked : 1;