summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJames McDonnell <jmcdonnell@blackberry.com>2017-05-30 16:40:05 -0400
committerJames McDonnell <jmcdonnell@blackberry.com>2017-10-23 18:16:00 +0000
commit08db8a408829cb3bbd204e71dd8d5616e7d21d3d (patch)
treea28348cdfcc7a6fff15a1770857da78dd0fc6dd0 /src
parent2ec485482d185f92e4de33f634bc3ef9dd6c9188 (diff)
Switch the metadata code to the event API
The switch is necessary because Multimedia for QNX 7.0.0 removes support for PPS based retrieval. PPS itself is deprecated in QNX 7.0.0. QNX 6.6.0 is also switched to using event notification since Multimedia for QNX 6.6.0 also supports it. There's a slight change in when metadata first becomes available because an event is used instead of file based retrieval. I think it's a necessary change because there isn't actually any guarantee that the metadata is complete at the time that the code used to request it and the code may have missed changes because it never read the information again. [ChangeLog][QNX] Switch to mmr_event_t based metadata retrieval. PPS based retrieval is not supported by Multimedia for QNX 7.0.0. Change-Id: I2b70f05422ee03d25ed2446a0e30b56b03dd82c8 Reviewed-by: Brett Stottlemyer <bstottle@ford.com> Reviewed-by: Michael Brasser <michael.brasser@live.com> Reviewed-by: Christian Stromme <christian.stromme@qt.io>
Diffstat (limited to 'src')
-rw-r--r--src/plugins/qnx/mediaplayer/mediaplayer.pri2
-rw-r--r--src/plugins/qnx/mediaplayer/mmrenderermediaplayercontrol.cpp9
-rw-r--r--src/plugins/qnx/mediaplayer/mmrenderermediaplayercontrol.h3
-rw-r--r--src/plugins/qnx/mediaplayer/mmrenderermetadata.cpp138
-rw-r--r--src/plugins/qnx/mediaplayer/mmrenderermetadata.h4
-rw-r--r--src/plugins/qnx/mediaplayer/mmreventmediaplayercontrol.cpp5
6 files changed, 76 insertions, 85 deletions
diff --git a/src/plugins/qnx/mediaplayer/mediaplayer.pri b/src/plugins/qnx/mediaplayer/mediaplayer.pri
index 0c7ad4d6..4c4363a9 100644
--- a/src/plugins/qnx/mediaplayer/mediaplayer.pri
+++ b/src/plugins/qnx/mediaplayer/mediaplayer.pri
@@ -21,4 +21,4 @@ SOURCES += \
$$PWD/mmreventmediaplayercontrol.cpp \
$$PWD/mmreventthread.cpp
-QMAKE_USE += mmrenderer pps
+QMAKE_USE += mmrenderer
diff --git a/src/plugins/qnx/mediaplayer/mmrenderermediaplayercontrol.cpp b/src/plugins/qnx/mediaplayer/mmrenderermediaplayercontrol.cpp
index c4207af0..d8b0a393 100644
--- a/src/plugins/qnx/mediaplayer/mmrenderermediaplayercontrol.cpp
+++ b/src/plugins/qnx/mediaplayer/mmrenderermediaplayercontrol.cpp
@@ -463,8 +463,8 @@ void MmRendererMediaPlayerControl::setMedia(const QMediaContent &media, QIODevic
void MmRendererMediaPlayerControl::continueLoadMedia()
{
+ updateMetaData(nullptr);
attach();
- updateMetaData();
if (m_playAfterMediaLoaded)
play();
}
@@ -587,12 +587,9 @@ void MmRendererMediaPlayerControl::setMmBufferLevel(const QString &bufferLevel)
}
}
-void MmRendererMediaPlayerControl::updateMetaData()
+void MmRendererMediaPlayerControl::updateMetaData(const strm_dict *dict)
{
- if (m_mediaStatus == QMediaPlayer::LoadedMedia)
- m_metaData.parse(m_contextName);
- else
- m_metaData.clear();
+ m_metaData.update(dict);
if (m_videoWindowControl)
m_videoWindowControl->setMetaData(m_metaData);
diff --git a/src/plugins/qnx/mediaplayer/mmrenderermediaplayercontrol.h b/src/plugins/qnx/mediaplayer/mmrenderermediaplayercontrol.h
index 7216cc7f..2edbd50e 100644
--- a/src/plugins/qnx/mediaplayer/mmrenderermediaplayercontrol.h
+++ b/src/plugins/qnx/mediaplayer/mmrenderermediaplayercontrol.h
@@ -48,6 +48,7 @@
typedef struct mmr_connection mmr_connection_t;
typedef struct mmr_context mmr_context_t;
typedef struct mmrenderer_monitor mmrenderer_monitor_t;
+typedef struct strm_dict strm_dict_t;
QT_BEGIN_NAMESPACE
@@ -115,6 +116,7 @@ protected:
void setMmBufferLevel(const QString &bufferLevel);
void handleMmStopped();
void handleMmStatusUpdate(qint64 position);
+ void updateMetaData(const strm_dict_t *dict);
// must be called from subclass dtors (calls virtual function stopMonitoring())
void destroy();
@@ -131,7 +133,6 @@ private:
void closeConnection();
void attach();
void detach();
- void updateMetaData();
// All these set the specified value to the backend, but neither emit changed signals
// nor change the member value.
diff --git a/src/plugins/qnx/mediaplayer/mmrenderermetadata.cpp b/src/plugins/qnx/mediaplayer/mmrenderermetadata.cpp
index 9f108738..50b45382 100644
--- a/src/plugins/qnx/mediaplayer/mmrenderermetadata.cpp
+++ b/src/plugins/qnx/mediaplayer/mmrenderermetadata.cpp
@@ -42,6 +42,13 @@
#include <QtCore/qfile.h>
#include <QtCore/qstringlist.h>
+#include <sys/strm.h>
+
+static const char *strm_string_getx(const strm_string_t *sstr, const char *defaultValue)
+{
+ return sstr ? strm_string_get(sstr) : defaultValue;
+}
+
QT_BEGIN_NAMESPACE
MmRendererMetaData::MmRendererMetaData()
@@ -69,91 +76,72 @@ static const char * seekableKey = "md_title_seekable";
static const int mediaTypeAudioFlag = 4;
static const int mediaTypeVideoFlag = 2;
-bool MmRendererMetaData::parse(const QString &contextName)
+bool MmRendererMetaData::update(const strm_dict_t *dict)
{
- clear();
- QString fileName =
- QString("/pps/services/multimedia/renderer/context/%1/metadata").arg(contextName);
+ if (!dict) {
+ clear();
+ return true;
+ }
- // In newer OS versions, the filename is "metadata0", not metadata, so try both.
- if (!QFile::exists(fileName))
- fileName += '0';
+ const strm_string_t *value;
- QFile metaDataFile(fileName);
- if (!metaDataFile.open(QFile::ReadOnly)) {
- qWarning() << "Unable to open media metadata file" << fileName << ":"
- << metaDataFile.errorString();
- return false;
- }
+ value = strm_dict_find_rstr(dict, durationKey);
+ m_duration = QByteArray(strm_string_getx(value, "0")).toLongLong();
- const QString separator("::");
- QTextStream stream(&metaDataFile);
- Q_FOREVER {
- const QString line = stream.readLine();
- if (line.isNull())
- break;
-
- const int separatorPos = line.indexOf(separator);
- if (separatorPos != -1) {
- const QStringRef key = line.leftRef(separatorPos);
- const QStringRef value = line.midRef(separatorPos + separator.length());
-
- if (key == durationKey)
- m_duration = value.toLongLong();
- else if (key == widthKey)
- m_width = value.toInt();
- else if (key == heightKey)
- m_height = value.toInt();
- else if (key == mediaTypeKey)
- m_mediaType = value.toInt();
- else if (key == pixelWidthKey)
- m_pixelWidth = value.toFloat();
- else if (key == pixelHeightKey)
- m_pixelHeight = value.toFloat();
- else if (key == titleKey)
- m_title = value.toString();
- else if (key == seekableKey)
- m_seekable = !(value == QLatin1String("0"));
- else if (key == artistKey)
- m_artist = value.toString();
- else if (key == commentKey)
- m_comment = value.toString();
- else if (key == genreKey)
- m_genre = value.toString();
- 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.toString();
- else if (key == trackKey)
- m_track = value.toInt();
- }
- }
+ value = strm_dict_find_rstr(dict, widthKey);
+ m_width = QByteArray(strm_string_getx(value, "0")).toInt();
+
+ value = strm_dict_find_rstr(dict, heightKey);
+ m_height = QByteArray(strm_string_getx(value, "0")).toInt();
+
+ value = strm_dict_find_rstr(dict, mediaTypeKey);
+ m_mediaType = QByteArray(strm_string_getx(value, "-1")).toInt();
+
+ value = strm_dict_find_rstr(dict, pixelWidthKey);
+ m_pixelWidth = QByteArray(strm_string_getx(value, "1")).toFloat();
+
+ value = strm_dict_find_rstr(dict, pixelHeightKey);
+ m_pixelHeight = QByteArray(strm_string_getx(value, "1")).toFloat();
+
+ value = strm_dict_find_rstr(dict, titleKey);
+ m_title = QString::fromLatin1(QByteArray(strm_string_getx(value, nullptr)));
+
+ value = strm_dict_find_rstr(dict, seekableKey);
+ m_seekable = (strcmp(strm_string_getx(value, "1"), "0") != 0);
+
+ value = strm_dict_find_rstr(dict, artistKey);
+ m_artist = QString::fromLatin1(QByteArray(strm_string_getx(value, nullptr)));
+
+ value = strm_dict_find_rstr(dict, commentKey);
+ m_comment = QString::fromLatin1(QByteArray(strm_string_getx(value, nullptr)));
+
+ value = strm_dict_find_rstr(dict, genreKey);
+ m_genre = QString::fromLatin1(QByteArray(strm_string_getx(value, nullptr)));
+
+ value = strm_dict_find_rstr(dict, yearKey);
+ m_year = QByteArray(strm_string_getx(value, "0")).toInt();
+
+ value = strm_dict_find_rstr(dict, bitRateKey);
+ m_audioBitRate = QByteArray(strm_string_getx(value, "0")).toInt();
+
+ value = strm_dict_find_rstr(dict, sampleKey);
+ m_sampleRate = QByteArray(strm_string_getx(value, "0")).toInt();
+
+ value = strm_dict_find_rstr(dict, albumKey);
+ m_album = QString::fromLatin1(QByteArray(strm_string_getx(value, nullptr)));
+
+ value = strm_dict_find_rstr(dict, trackKey);
+ m_track = QByteArray(strm_string_getx(value, "0")).toInt();
return true;
}
void MmRendererMetaData::clear()
{
- m_duration = 0;
- m_height = 0;
- m_width = 0;
- m_mediaType = -1;
- m_pixelWidth = 1;
- m_pixelHeight = 1;
- m_seekable = true;
- 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;
+ strm_dict_t *dict;
+ dict = strm_dict_new();
+ update(dict);
+ strm_dict_destroy(dict);
}
qlonglong MmRendererMetaData::duration() const
diff --git a/src/plugins/qnx/mediaplayer/mmrenderermetadata.h b/src/plugins/qnx/mediaplayer/mmrenderermetadata.h
index 4473e530..ad2193d2 100644
--- a/src/plugins/qnx/mediaplayer/mmrenderermetadata.h
+++ b/src/plugins/qnx/mediaplayer/mmrenderermetadata.h
@@ -43,13 +43,15 @@
#include <QtCore/QSize>
#include <QtCore/QString>
+typedef struct strm_dict strm_dict_t;
+
QT_BEGIN_NAMESPACE
class MmRendererMetaData
{
public:
MmRendererMetaData();
- bool parse(const QString &contextName);
+ bool update(const strm_dict_t *dict);
void clear();
// Duration in milliseconds
diff --git a/src/plugins/qnx/mediaplayer/mmreventmediaplayercontrol.cpp b/src/plugins/qnx/mediaplayer/mmreventmediaplayercontrol.cpp
index 3aac3124..a0bac126 100644
--- a/src/plugins/qnx/mediaplayer/mmreventmediaplayercontrol.cpp
+++ b/src/plugins/qnx/mediaplayer/mmreventmediaplayercontrol.cpp
@@ -122,12 +122,15 @@ void MmrEventMediaPlayerControl::readEvents()
}
break;
}
+ case MMR_EVENT_METADATA: {
+ updateMetaData(event->data);
+ break;
+ }
case MMR_EVENT_ERROR:
case MMR_EVENT_STATE:
case MMR_EVENT_NONE:
case MMR_EVENT_OVERFLOW:
case MMR_EVENT_WARNING:
- case MMR_EVENT_METADATA:
case MMR_EVENT_PLAYLIST:
case MMR_EVENT_INPUT:
case MMR_EVENT_OUTPUT: