From f4f6012d181cf60fd04fc5bf69b21786977f0de0 Mon Sep 17 00:00:00 2001 From: Gareth Stockwell Date: Wed, 4 Nov 2009 10:38:41 +0000 Subject: Implemented metadata handling in Phonon MMF backend Task-number: QTBUG-4662 Reviewed-by: Frans Englich --- src/3rdparty/phonon/mmf/abstractmediaplayer.cpp | 21 +++++++++++++++++++++ src/3rdparty/phonon/mmf/abstractmediaplayer.h | 6 ++++++ src/3rdparty/phonon/mmf/abstractplayer.h | 3 ++- src/3rdparty/phonon/mmf/audioplayer.cpp | 21 ++++++++++++++++++++- src/3rdparty/phonon/mmf/audioplayer.h | 4 ++++ src/3rdparty/phonon/mmf/mediaobject.cpp | 1 + src/3rdparty/phonon/mmf/mmf_videoplayer.cpp | 13 +++++++++++++ src/3rdparty/phonon/mmf/mmf_videoplayer.h | 4 ++++ src/plugins/phonon/mmf/plugin/plugin.pro | 11 ++++++----- 9 files changed, 77 insertions(+), 7 deletions(-) diff --git a/src/3rdparty/phonon/mmf/abstractmediaplayer.cpp b/src/3rdparty/phonon/mmf/abstractmediaplayer.cpp index b443194..f2efaa0 100644 --- a/src/3rdparty/phonon/mmf/abstractmediaplayer.cpp +++ b/src/3rdparty/phonon/mmf/abstractmediaplayer.cpp @@ -392,7 +392,28 @@ void MMF::AbstractMediaPlayer::changeState(PrivateState newState) play(); } } +} + +void MMF::AbstractMediaPlayer::updateMetaData() +{ + TRACE_CONTEXT(AbstractMediaPlayer::updateMetaData, EAudioInternal); + TRACE_ENTRY_0(); + + m_metaData.clear(); + + const int numberOfEntries = numberOfMetaDataEntries(); + for(int i=0; i entry = metaDataEntry(i); + // Note that we capitalize the key, as required by the Ogg Vorbis + // metadata standard to which Phonon adheres: + // http://xiph.org/vorbis/doc/v-comment.html + m_metaData.insert(entry.first.toUpper(), entry.second); + } + + emit metaDataChanged(m_metaData); + + TRACE_EXIT_0(); } QT_END_NAMESPACE diff --git a/src/3rdparty/phonon/mmf/abstractmediaplayer.h b/src/3rdparty/phonon/mmf/abstractmediaplayer.h index 1ea236b..cff7bab 100644 --- a/src/3rdparty/phonon/mmf/abstractmediaplayer.h +++ b/src/3rdparty/phonon/mmf/abstractmediaplayer.h @@ -73,6 +73,10 @@ protected: virtual void close() = 0; virtual void changeState(PrivateState newState); + void updateMetaData(); + virtual int numberOfMetaDataEntries() const = 0; + virtual QPair metaDataEntry(int index) const = 0; + protected: bool tickTimerRunning() const; void startTickTimer(); @@ -105,6 +109,8 @@ private: MediaSource m_source; MediaSource m_nextSource; + QMultiMap m_metaData; + }; } } diff --git a/src/3rdparty/phonon/mmf/abstractplayer.h b/src/3rdparty/phonon/mmf/abstractplayer.h index 1c4ea02..66496cc 100644 --- a/src/3rdparty/phonon/mmf/abstractplayer.h +++ b/src/3rdparty/phonon/mmf/abstractplayer.h @@ -97,13 +97,14 @@ public: const QString &errorMessage = QString()); Phonon::State state() const; + Q_SIGNALS: void totalTimeChanged(qint64 length); void finished(); void tick(qint64 time); void stateChanged(Phonon::State oldState, Phonon::State newState); - + void metaDataChanged(const QMultiMap& metaData); protected: /** diff --git a/src/3rdparty/phonon/mmf/audioplayer.cpp b/src/3rdparty/phonon/mmf/audioplayer.cpp index 1d259a8..8fccfe6 100644 --- a/src/3rdparty/phonon/mmf/audioplayer.cpp +++ b/src/3rdparty/phonon/mmf/audioplayer.cpp @@ -182,8 +182,8 @@ void MMF::AudioPlayer::MapcInitComplete(TInt aError, if (KErrNone == aError) { maxVolumeChanged(m_player->MaxVolume()); - emit totalTimeChanged(totalTime()); + updateMetaData(); changeState(StoppedState); } else { // TODO: set different error states according to value of aError? @@ -251,5 +251,24 @@ void MMF::AudioPlayer::MaloLoadingComplete() #endif // QT_PHONON_MMF_AUDIO_DRM +//----------------------------------------------------------------------------- +// Private functions +//----------------------------------------------------------------------------- + +int MMF::AudioPlayer::numberOfMetaDataEntries() const +{ + int numberOfEntries = 0; + m_player->GetNumberOfMetaDataEntries(numberOfEntries); // ignoring return code + return numberOfEntries; +} + +QPair MMF::AudioPlayer::metaDataEntry(int index) const +{ + CMMFMetaDataEntry *entry = 0; + QT_TRAP_THROWING(entry = m_player->GetMetaDataEntryL(index)); + return QPair(qt_TDesC2QString(entry->Name()), qt_TDesC2QString(entry->Value())); +} + + QT_END_NAMESPACE diff --git a/src/3rdparty/phonon/mmf/audioplayer.h b/src/3rdparty/phonon/mmf/audioplayer.h index 60ef436..bc60076 100644 --- a/src/3rdparty/phonon/mmf/audioplayer.h +++ b/src/3rdparty/phonon/mmf/audioplayer.h @@ -94,6 +94,10 @@ public: private: void construct(); + // AbstractMediaPlayer + virtual int numberOfMetaDataEntries() const; + virtual QPair metaDataEntry(int index) const; + private: /** * Using CPlayerType typedef in order to be able to easily switch between diff --git a/src/3rdparty/phonon/mmf/mediaobject.cpp b/src/3rdparty/phonon/mmf/mediaobject.cpp index 74aaa58..f004fd7 100644 --- a/src/3rdparty/phonon/mmf/mediaobject.cpp +++ b/src/3rdparty/phonon/mmf/mediaobject.cpp @@ -322,6 +322,7 @@ void MMF::MediaObject::createPlayer(const MediaSource &source) connect(m_player.data(), SIGNAL(stateChanged(Phonon::State, Phonon::State)), SIGNAL(stateChanged(Phonon::State, Phonon::State))); connect(m_player.data(), SIGNAL(finished()), SIGNAL(finished())); connect(m_player.data(), SIGNAL(tick(qint64)), SIGNAL(tick(qint64))); + connect(m_player.data(), SIGNAL(metaDataChanged(const QMultiMap&)), SIGNAL(metaDataChanged(const QMultiMap&))); // We need to call setError() after doing the connects, otherwise the // error won't be received. diff --git a/src/3rdparty/phonon/mmf/mmf_videoplayer.cpp b/src/3rdparty/phonon/mmf/mmf_videoplayer.cpp index fe469cf..ba7d005 100644 --- a/src/3rdparty/phonon/mmf/mmf_videoplayer.cpp +++ b/src/3rdparty/phonon/mmf/mmf_videoplayer.cpp @@ -490,6 +490,19 @@ bool MMF::VideoPlayer::getNativeWindowSystemHandles() TRACE_RETURN("changed %d", changed); } +int MMF::VideoPlayer::numberOfMetaDataEntries() const +{ + int numberOfEntries = 0; + TRAP_IGNORE(numberOfEntries = m_player->NumberOfMetaDataEntriesL()); + return numberOfEntries; +} + +QPair MMF::VideoPlayer::metaDataEntry(int index) const +{ + CMMFMetaDataEntry *entry = 0; + QT_TRAP_THROWING(entry = m_player->MetaDataEntryL(index)); + return QPair(qt_TDesC2QString(entry->Name()), qt_TDesC2QString(entry->Value())); +} QT_END_NAMESPACE diff --git a/src/3rdparty/phonon/mmf/mmf_videoplayer.h b/src/3rdparty/phonon/mmf/mmf_videoplayer.h index 8072404..fa4e59b 100644 --- a/src/3rdparty/phonon/mmf/mmf_videoplayer.h +++ b/src/3rdparty/phonon/mmf/mmf_videoplayer.h @@ -86,6 +86,10 @@ private: void updateMmfOutput(); + // AbstractMediaPlayer + virtual int numberOfMetaDataEntries() const; + virtual QPair metaDataEntry(int index) const; + private: QScopedPointer m_player; diff --git a/src/plugins/phonon/mmf/plugin/plugin.pro b/src/plugins/phonon/mmf/plugin/plugin.pro index 793c307..8a7de98 100644 --- a/src/plugins/phonon/mmf/plugin/plugin.pro +++ b/src/plugins/phonon/mmf/plugin/plugin.pro @@ -69,11 +69,12 @@ debug { LIBS += -lhal } -LIBS += -lmediaclientvideo # For CVideoPlayerUtility -LIBS += -lcone # For CCoeEnv -LIBS += -lws32 # For RWindow -LIBS += -lefsrv # For file server -LIBS += -lapgrfx -lapmime # For recognizer +LIBS += -lmediaclientvideo # For CVideoPlayerUtility +LIBS += -lcone # For CCoeEnv +LIBS += -lws32 # For RWindow +LIBS += -lefsrv # For file server +LIBS += -lapgrfx -lapmime # For recognizer +LIBS += -lmmfcontrollerframework # For CMMFMetaDataEntry # These are for effects. LIBS += -lAudioEqualizerEffect -lBassBoostEffect -lDistanceAttenuationEffect -lDopplerBase -lEffectBase -lEnvironmentalReverbEffect -lListenerDopplerEffect -lListenerLocationEffect -lListenerOrientationEffect -lLocationBase -lLoudnessEffect -lOrientationBase -lSourceDopplerEffect -lSourceLocationEffect -lSourceOrientationEffect -lStereoWideningEffect -- cgit v0.12