summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTobias Koenig <tobias.koenig.qnx@kdab.com>2013-02-14 17:19:50 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-02-19 14:51:21 +0100
commit0ce2cb3ebe6289e3db14438560fa186d9e5186b8 (patch)
tree1c94a4fe28203ca10290cb05b2cdb6f0eba4b899
parent01436abd3dd65ddabfe101ac95de29b2fc1ab02c (diff)
downloadqtmultimedia-0ce2cb3ebe6289e3db14438560fa186d9e5186b8.tar.gz
Blackberry: Add support for reading meta data in QMediaPlayer
Provide an implementation of QMetaDataReaderControl for the QMediaPlayer. Change-Id: I58c04e40ae3f07013450997410d0a379273c7bde Reviewed-by: Thomas McGuire <thomas.mcguire@kdab.com>
-rw-r--r--src/plugins/blackberry/mediaplayer/bbmediaplayercontrol.cpp9
-rw-r--r--src/plugins/blackberry/mediaplayer/bbmediaplayercontrol.h3
-rw-r--r--src/plugins/blackberry/mediaplayer/bbmediaplayerservice.cpp16
-rw-r--r--src/plugins/blackberry/mediaplayer/bbmediaplayerservice.h2
-rw-r--r--src/plugins/blackberry/mediaplayer/bbmetadata.cpp97
-rw-r--r--src/plugins/blackberry/mediaplayer/bbmetadata.h24
-rw-r--r--src/plugins/blackberry/mediaplayer/bbmetadatareadercontrol.cpp169
-rw-r--r--src/plugins/blackberry/mediaplayer/bbmetadatareadercontrol.h68
-rw-r--r--src/plugins/blackberry/mediaplayer/mediaplayer.pri2
9 files changed, 389 insertions, 1 deletions
diff --git a/src/plugins/blackberry/mediaplayer/bbmediaplayercontrol.cpp b/src/plugins/blackberry/mediaplayer/bbmediaplayercontrol.cpp
index 41d3bc479..5998603d5 100644
--- a/src/plugins/blackberry/mediaplayer/bbmediaplayercontrol.cpp
+++ b/src/plugins/blackberry/mediaplayer/bbmediaplayercontrol.cpp
@@ -39,6 +39,7 @@
**
****************************************************************************/
#include "bbmediaplayercontrol.h"
+#include "bbmetadatareadercontrol.h"
#include "bbvideowindowcontrol.h"
#include "bbutil.h"
#include <QtCore/qabstracteventdispatcher.h>
@@ -515,6 +516,11 @@ void BbMediaPlayerControl::setVideoControl(BbVideoWindowControl *videoControl)
m_videoControl = videoControl;
}
+void BbMediaPlayerControl::setMetaDataReaderControl(BbMetaDataReaderControl *metaDataReaderControl)
+{
+ m_metaDataReaderControl = metaDataReaderControl;
+}
+
bool BbMediaPlayerControl::nativeEventFilter(const QByteArray &eventType, void *message, long *result)
{
Q_UNUSED(eventType);
@@ -592,6 +598,9 @@ void BbMediaPlayerControl::updateMetaData()
if (m_videoControl)
m_videoControl->setMetaData(m_metaData);
+ if (m_metaDataReaderControl)
+ m_metaDataReaderControl->setMetaData(m_metaData);
+
emit durationChanged(m_metaData.duration());
emit audioAvailableChanged(m_metaData.hasAudio());
emit videoAvailableChanged(m_metaData.hasVideo());
diff --git a/src/plugins/blackberry/mediaplayer/bbmediaplayercontrol.h b/src/plugins/blackberry/mediaplayer/bbmediaplayercontrol.h
index eb87ea872..d825a21c0 100644
--- a/src/plugins/blackberry/mediaplayer/bbmediaplayercontrol.h
+++ b/src/plugins/blackberry/mediaplayer/bbmediaplayercontrol.h
@@ -54,6 +54,7 @@ typedef struct mmrenderer_monitor mmrenderer_monitor_t;
QT_BEGIN_NAMESPACE
+class BbMetaDataReaderControl;
class BbVideoWindowControl;
class BbMediaPlayerControl : public QMediaPlayerControl, public QAbstractNativeEventFilter
@@ -99,6 +100,7 @@ public:
void stop() Q_DECL_OVERRIDE;
void setVideoControl(BbVideoWindowControl *videoControl);
+ void setMetaDataReaderControl(BbMetaDataReaderControl *metaDataReaderControl);
bool nativeEventFilter(const QByteArray &eventType, void *message, long *result) Q_DECL_OVERRIDE;
private Q_SLOTS:
@@ -137,6 +139,7 @@ private:
bool m_muted;
qreal m_rate;
QPointer<BbVideoWindowControl> m_videoControl;
+ QPointer<BbMetaDataReaderControl> m_metaDataReaderControl;
BbMetaData m_metaData;
int m_id;
mmrenderer_monitor_t *m_eventMonitor;
diff --git a/src/plugins/blackberry/mediaplayer/bbmediaplayerservice.cpp b/src/plugins/blackberry/mediaplayer/bbmediaplayerservice.cpp
index 8730d2ddc..8c3e93445 100644
--- a/src/plugins/blackberry/mediaplayer/bbmediaplayerservice.cpp
+++ b/src/plugins/blackberry/mediaplayer/bbmediaplayerservice.cpp
@@ -41,6 +41,7 @@
#include "bbmediaplayerservice.h"
#include "bbmediaplayercontrol.h"
+#include "bbmetadatareadercontrol.h"
#include "bbvideowindowcontrol.h"
QT_BEGIN_NAMESPACE
@@ -48,7 +49,8 @@ QT_BEGIN_NAMESPACE
BbMediaPlayerService::BbMediaPlayerService(QObject *parent)
: QMediaService(parent),
m_videoWindowControl(0),
- m_mediaPlayerControl(0)
+ m_mediaPlayerControl(0),
+ m_metaDataReaderControl(0)
{
}
@@ -68,6 +70,13 @@ QMediaControl *BbMediaPlayerService::requestControl(const char *name)
}
return m_mediaPlayerControl;
}
+ else if (qstrcmp(name, QMetaDataReaderControl_iid) == 0) {
+ if (!m_metaDataReaderControl) {
+ m_metaDataReaderControl = new BbMetaDataReaderControl();
+ updateControls();
+ }
+ return m_metaDataReaderControl;
+ }
else if (qstrcmp(name, QVideoWindowControl_iid) == 0) {
if (!m_videoWindowControl) {
m_videoWindowControl = new BbVideoWindowControl();
@@ -84,6 +93,8 @@ void BbMediaPlayerService::releaseControl(QMediaControl *control)
m_videoWindowControl = 0;
if (control == m_mediaPlayerControl)
m_mediaPlayerControl = 0;
+ if (control == m_metaDataReaderControl)
+ m_metaDataReaderControl = 0;
delete control;
}
@@ -91,6 +102,9 @@ void BbMediaPlayerService::updateControls()
{
if (m_videoWindowControl && m_mediaPlayerControl)
m_mediaPlayerControl->setVideoControl(m_videoWindowControl);
+
+ if (m_metaDataReaderControl && m_mediaPlayerControl)
+ m_mediaPlayerControl->setMetaDataReaderControl(m_metaDataReaderControl);
}
QT_END_NAMESPACE
diff --git a/src/plugins/blackberry/mediaplayer/bbmediaplayerservice.h b/src/plugins/blackberry/mediaplayer/bbmediaplayerservice.h
index 8ff52cd28..7ace8830b 100644
--- a/src/plugins/blackberry/mediaplayer/bbmediaplayerservice.h
+++ b/src/plugins/blackberry/mediaplayer/bbmediaplayerservice.h
@@ -47,6 +47,7 @@
QT_BEGIN_NAMESPACE
class BbMediaPlayerControl;
+class BbMetaDataReaderControl;
class BbVideoWindowControl;
class BbMediaPlayerService : public QMediaService
@@ -64,6 +65,7 @@ private:
QPointer<BbVideoWindowControl> m_videoWindowControl;
QPointer<BbMediaPlayerControl> m_mediaPlayerControl;
+ QPointer<BbMetaDataReaderControl> m_metaDataReaderControl;
};
QT_END_NAMESPACE
diff --git a/src/plugins/blackberry/mediaplayer/bbmetadata.cpp b/src/plugins/blackberry/mediaplayer/bbmetadata.cpp
index b34b63e72..38bb0c80b 100644
--- a/src/plugins/blackberry/mediaplayer/bbmetadata.cpp
+++ b/src/plugins/blackberry/mediaplayer/bbmetadata.cpp
@@ -51,7 +51,16 @@ BbMetaData::BbMetaData()
clear();
}
+static const char * titleKey = "md_title_name";
+static const char * artistKey = "md_title_artist";
+static const char * commentKey = "md_title_comment";
+static const char * genreKey = "md_title_genre";
+static const char * yearKey = "md_title_year";
static const char * durationKey = "md_title_duration";
+static const char * bitRateKey = "md_title_bitrate";
+static const char * sampleKey = "md_title_samplerate";
+static const char * albumKey = "md_title_album";
+static const char * trackKey = "md_title_track";
static const char * widthKey = "md_video_width";
static const char * heightKey = "md_video_height";
static const char * mediaTypeKey = "md_title_mediatype";
@@ -102,6 +111,24 @@ bool BbMetaData::parse(const QString &contextName)
m_pixelWidth = value.toFloat();
else if (key == pixelHeightKey)
m_pixelHeight = value.toFloat();
+ else if (key == titleKey)
+ m_title = value;
+ else if (key == artistKey)
+ m_artist = value;
+ else if (key == commentKey)
+ m_comment = value;
+ else if (key == genreKey)
+ m_genre = value;
+ else if (key == yearKey)
+ m_year = value.toInt();
+ else if (key == bitRateKey)
+ m_audioBitRate = value.toInt();
+ else if (key == sampleKey)
+ m_sampleRate = value.toInt();
+ else if (key == albumKey)
+ m_album = value;
+ else if (key == trackKey)
+ m_track = value.toInt();
}
}
@@ -116,6 +143,16 @@ void BbMetaData::clear()
m_mediaType = -1;
m_pixelWidth = 1;
m_pixelHeight = 1;
+
+ m_title.clear();
+ m_artist.clear();
+ m_comment.clear();
+ m_genre.clear();
+ m_year = 0;
+ m_audioBitRate = 0;
+ m_sampleRate = 0;
+ m_album.clear();
+ m_track = 0;
}
qlonglong BbMetaData::duration() const
@@ -161,4 +198,64 @@ bool BbMetaData::hasAudio() const
return (m_mediaType & mediaTypeAudioFlag);
}
+QString BbMetaData::title() const
+{
+ return m_title;
+}
+
+QString BbMetaData::artist() const
+{
+ return m_artist;
+}
+
+QString BbMetaData::comment() const
+{
+ return m_comment;
+}
+
+QString BbMetaData::genre() const
+{
+ return m_genre;
+}
+
+int BbMetaData::year() const
+{
+ return m_year;
+}
+
+QString BbMetaData::mediaType() const
+{
+ if (hasVideo())
+ return QLatin1String("video");
+ else if (hasAudio())
+ return QLatin1String("audio");
+ else
+ return QString();
+}
+
+int BbMetaData::audioBitRate() const
+{
+ return m_audioBitRate;
+}
+
+int BbMetaData::sampleRate() const
+{
+ return m_sampleRate;
+}
+
+QString BbMetaData::album() const
+{
+ return m_album;
+}
+
+int BbMetaData::track() const
+{
+ return m_track;
+}
+
+QSize BbMetaData::resolution() const
+{
+ return QSize(width(), height());
+}
+
QT_END_NAMESPACE
diff --git a/src/plugins/blackberry/mediaplayer/bbmetadata.h b/src/plugins/blackberry/mediaplayer/bbmetadata.h
index a983a6af1..3bb323a4d 100644
--- a/src/plugins/blackberry/mediaplayer/bbmetadata.h
+++ b/src/plugins/blackberry/mediaplayer/bbmetadata.h
@@ -42,6 +42,8 @@
#define BBMETADATA_H
#include <QtCore/qglobal.h>
+#include <QtCore/QSize>
+#include <QtCore/QString>
QT_BEGIN_NAMESPACE
@@ -60,6 +62,18 @@ public:
bool hasVideo() const;
bool hasAudio() const;
+ QString title() const;
+ QString artist() const;
+ QString comment() const;
+ QString genre() const;
+ int year() const;
+ QString mediaType() const;
+ int audioBitRate() const;
+ int sampleRate() const;
+ QString album() const;
+ int track() const;
+ QSize resolution() const;
+
private:
qlonglong m_duration;
int m_height;
@@ -67,6 +81,16 @@ private:
int m_mediaType;
float m_pixelWidth;
float m_pixelHeight;
+
+ QString m_title;
+ QString m_artist;
+ QString m_comment;
+ QString m_genre;
+ int m_year;
+ int m_audioBitRate;
+ int m_sampleRate;
+ QString m_album;
+ int m_track;
};
QT_END_NAMESPACE
diff --git a/src/plugins/blackberry/mediaplayer/bbmetadatareadercontrol.cpp b/src/plugins/blackberry/mediaplayer/bbmetadatareadercontrol.cpp
new file mode 100644
index 000000000..95f85f5e3
--- /dev/null
+++ b/src/plugins/blackberry/mediaplayer/bbmetadatareadercontrol.cpp
@@ -0,0 +1,169 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Research In Motion
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include "bbmetadatareadercontrol.h"
+
+QT_BEGIN_NAMESPACE
+
+BbMetaDataReaderControl::BbMetaDataReaderControl(QObject *parent)
+ : QMetaDataReaderControl(parent)
+{
+}
+
+bool BbMetaDataReaderControl::isMetaDataAvailable() const
+{
+ return !availableMetaData().isEmpty();
+}
+
+QVariant BbMetaDataReaderControl::metaData(const QString &key) const
+{
+ if (key == QMediaMetaData::Title)
+ return m_metaData.title();
+ else if (key == QMediaMetaData::Author)
+ return m_metaData.artist();
+ else if (key == QMediaMetaData::Comment)
+ return m_metaData.comment();
+ else if (key == QMediaMetaData::Genre)
+ return m_metaData.genre();
+ else if (key == QMediaMetaData::Year)
+ return m_metaData.year();
+ else if (key == QMediaMetaData::MediaType)
+ return m_metaData.mediaType();
+ else if (key == QMediaMetaData::Duration)
+ return m_metaData.duration();
+ else if (key == QMediaMetaData::AudioBitRate)
+ return m_metaData.audioBitRate();
+ else if (key == QMediaMetaData::SampleRate)
+ return m_metaData.sampleRate();
+ else if (key == QMediaMetaData::AlbumTitle)
+ return m_metaData.album();
+ else if (key == QMediaMetaData::TrackNumber)
+ return m_metaData.track();
+ else if (key == QMediaMetaData::Resolution)
+ return m_metaData.resolution();
+
+ return QVariant();
+}
+
+QStringList BbMetaDataReaderControl::availableMetaData() const
+{
+ QStringList metaData;
+
+ if (!m_metaData.title().isEmpty())
+ metaData << QMediaMetaData::Title;
+ if (!m_metaData.artist().isEmpty())
+ metaData << QMediaMetaData::Author;
+ if (!m_metaData.comment().isEmpty())
+ metaData << QMediaMetaData::Comment;
+ if (!m_metaData.genre().isEmpty())
+ metaData << QMediaMetaData::Genre;
+ if (m_metaData.year() != 0)
+ metaData << QMediaMetaData::Year;
+ if (!m_metaData.mediaType().isEmpty())
+ metaData << QMediaMetaData::MediaType;
+ if (m_metaData.duration() != 0)
+ metaData << QMediaMetaData::Duration;
+ if (m_metaData.audioBitRate() != 0)
+ metaData << QMediaMetaData::AudioBitRate;
+ if (m_metaData.sampleRate() != 0)
+ metaData << QMediaMetaData::SampleRate;
+ if (!m_metaData.album().isEmpty())
+ metaData << QMediaMetaData::AlbumTitle;
+ if (m_metaData.track() != 0)
+ metaData << QMediaMetaData::TrackNumber;
+ if (m_metaData.resolution().isValid())
+ metaData << QMediaMetaData::Resolution;
+
+ return metaData;
+}
+
+void BbMetaDataReaderControl::setMetaData(const BbMetaData &data)
+{
+ const BbMetaData oldMetaData = m_metaData;
+ const bool oldMetaDataAvailable = isMetaDataAvailable();
+
+ m_metaData = data;
+
+ bool changed = false;
+ if (m_metaData.title() != oldMetaData.title()) {
+ changed = true;
+ emit metaDataChanged(QMediaMetaData::Title, m_metaData.title());
+ } else if (m_metaData.artist() != oldMetaData.artist()) {
+ changed = true;
+ emit metaDataChanged(QMediaMetaData::Author, m_metaData.artist());
+ } else if (m_metaData.comment() != oldMetaData.comment()) {
+ changed = true;
+ emit metaDataChanged(QMediaMetaData::Comment, m_metaData.comment());
+ } else if (m_metaData.genre() != oldMetaData.genre()) {
+ changed = true;
+ emit metaDataChanged(QMediaMetaData::Genre, m_metaData.genre());
+ } else if (m_metaData.year() != oldMetaData.year()) {
+ changed = true;
+ emit metaDataChanged(QMediaMetaData::Year, m_metaData.year());
+ } else if (m_metaData.mediaType() != oldMetaData.mediaType()) {
+ changed = true;
+ emit metaDataChanged(QMediaMetaData::MediaType, m_metaData.mediaType());
+ } else if (m_metaData.duration() != oldMetaData.duration()) {
+ changed = true;
+ emit metaDataChanged(QMediaMetaData::Duration, m_metaData.duration());
+ } else if (m_metaData.audioBitRate() != oldMetaData.audioBitRate()) {
+ changed = true;
+ emit metaDataChanged(QMediaMetaData::AudioBitRate, m_metaData.audioBitRate());
+ } else if (m_metaData.sampleRate() != oldMetaData.sampleRate()) {
+ changed = true;
+ emit metaDataChanged(QMediaMetaData::SampleRate, m_metaData.sampleRate());
+ } else if (m_metaData.album() != oldMetaData.album()) {
+ changed = true;
+ emit metaDataChanged(QMediaMetaData::AlbumTitle, m_metaData.album());
+ } else if (m_metaData.track() != oldMetaData.track()) {
+ changed = true;
+ emit metaDataChanged(QMediaMetaData::TrackNumber, m_metaData.track());
+ } else if (m_metaData.resolution() != oldMetaData.resolution()) {
+ changed = true;
+ emit metaDataChanged(QMediaMetaData::Resolution, m_metaData.resolution());
+ }
+
+ if (changed)
+ emit metaDataChanged();
+
+ const bool metaDataAvailable = isMetaDataAvailable();
+ if (metaDataAvailable != oldMetaDataAvailable)
+ emit metaDataAvailableChanged(metaDataAvailable);
+}
diff --git a/src/plugins/blackberry/mediaplayer/bbmetadatareadercontrol.h b/src/plugins/blackberry/mediaplayer/bbmetadatareadercontrol.h
new file mode 100644
index 000000000..c825b54f3
--- /dev/null
+++ b/src/plugins/blackberry/mediaplayer/bbmetadatareadercontrol.h
@@ -0,0 +1,68 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Research In Motion
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#ifndef BBMETADATAREADERCONTROL_H
+#define BBMETADATAREADERCONTROL_H
+
+#include "bbmetadata.h"
+#include <qmetadatareadercontrol.h>
+
+QT_BEGIN_NAMESPACE
+
+class BbMetaDataReaderControl : public QMetaDataReaderControl
+{
+ Q_OBJECT
+public:
+ explicit BbMetaDataReaderControl(QObject *parent = 0);
+
+ bool isMetaDataAvailable() const Q_DECL_OVERRIDE;
+
+ QVariant metaData(const QString &key) const Q_DECL_OVERRIDE;
+ QStringList availableMetaData() const Q_DECL_OVERRIDE;
+
+ void setMetaData(const BbMetaData &data);
+
+private:
+ BbMetaData m_metaData;
+};
+
+QT_END_NAMESPACE
+
+#endif
diff --git a/src/plugins/blackberry/mediaplayer/mediaplayer.pri b/src/plugins/blackberry/mediaplayer/mediaplayer.pri
index cf888f655..f8db519f5 100644
--- a/src/plugins/blackberry/mediaplayer/mediaplayer.pri
+++ b/src/plugins/blackberry/mediaplayer/mediaplayer.pri
@@ -4,6 +4,7 @@ HEADERS += \
$$PWD/bbmediaplayercontrol.h \
$$PWD/bbmediaplayerservice.h \
$$PWD/bbmetadata.h \
+ $$PWD/bbmetadatareadercontrol.h \
$$PWD/bbutil.h \
$$PWD/bbvideowindowcontrol.h
@@ -11,6 +12,7 @@ SOURCES += \
$$PWD/bbmediaplayercontrol.cpp \
$$PWD/bbmediaplayerservice.cpp \
$$PWD/bbmetadata.cpp \
+ $$PWD/bbmetadatareadercontrol.cpp \
$$PWD/bbutil.cpp \
$$PWD/bbvideowindowcontrol.cpp