summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorGareth Stockwell <gareth.stockwell@sosco.com>2009-08-17 15:02:58 (GMT)
committerGareth Stockwell <gareth.stockwell@sosco.com>2009-08-17 15:02:58 (GMT)
commit427c415d876d57042a55e8b66730888512ac0ed1 (patch)
tree0bc694626ccd2229941ee73a31f7e048b714ed1e /src
parentc82bcc8a3bf2ab64db9ccbe7b8ec7ca1208e2edc (diff)
downloadQt-427c415d876d57042a55e8b66730888512ac0ed1.zip
Qt-427c415d876d57042a55e8b66730888512ac0ed1.tar.gz
Qt-427c415d876d57042a55e8b66730888512ac0ed1.tar.bz2
Added recognizer code to determine if file is audio or video
Diffstat (limited to 'src')
-rw-r--r--src/3rdparty/phonon/mmf/mediaobject.cpp58
-rw-r--r--src/3rdparty/phonon/mmf/mediaobject.h10
-rw-r--r--src/plugins/phonon/mmf/mmf.pro3
3 files changed, 71 insertions, 0 deletions
diff --git a/src/3rdparty/phonon/mmf/mediaobject.cpp b/src/3rdparty/phonon/mmf/mediaobject.cpp
index 8a4b76e..6bf15e6 100644
--- a/src/3rdparty/phonon/mmf/mediaobject.cpp
+++ b/src/3rdparty/phonon/mmf/mediaobject.cpp
@@ -53,6 +53,10 @@ MMF::MediaObject::MediaObject(QObject *parent) : m_player(NULL)
Q_UNUSED(parent);
+ TInt err = m_recognizer.Connect();
+ err = m_fileServer.Connect();
+ // TODO: handle this error
+
// TODO: should leaves be trapped in the constructor?
m_player = CPlayerType::NewL(*this, 0, EMdaPriorityPreferenceNone);
@@ -70,9 +74,63 @@ MMF::MediaObject::~MediaObject()
delete m_tickTimer;
delete m_player;
+ m_fileServer.Close();
+ m_recognizer.Close();
+
TRACE_EXIT_0();
}
+
+//-----------------------------------------------------------------------------
+// Recognizer
+//-----------------------------------------------------------------------------
+
+const TInt KMimePrefixLength = 6; // either "audio/" or "video/"
+_LIT(KMimePrefixAudio, "audio/");
+_LIT(KMimePrefixVideo, "video/");
+
+MMF::MediaObject::MediaType MMF::MediaObject::mimeTypeToMediaType(const TDesC& mimeType)
+{
+ MediaType result = MediaTypeUnknown;
+
+ if(mimeType.Left(KMimePrefixLength).Compare(KMimePrefixAudio) == 0)
+ {
+ result = MediaTypeAudio;
+ }
+ else if(mimeType.Left(KMimePrefixLength).Compare(KMimePrefixVideo) == 0)
+ {
+ result = MediaTypeVideo;
+ }
+
+ return result;
+}
+
+
+MMF::MediaObject::MediaType MMF::MediaObject::fileMediaType
+ (const QString& fileName)
+{
+ MediaType result = MediaTypeUnknown;
+
+ QHBufC fileNameSymbian = Utils::symbianFilename(m_mediaSource.fileName());
+ RFile file;
+ TInt err = file.Open(m_fileServer, *fileNameSymbian, EFileRead);
+
+ if(KErrNone == err)
+ {
+ TDataRecognitionResult recognizerResult;
+ err = m_recognizer.RecognizeData(file, recognizerResult);
+ if(KErrNone == err)
+ {
+ const TPtrC mimeType = recognizerResult.iDataType.Des();
+ result = mimeTypeToMediaType(mimeType);
+ }
+
+ file.Close();
+ }
+ return result;
+}
+
+
//-----------------------------------------------------------------------------
// MediaObjectInterface
//-----------------------------------------------------------------------------
diff --git a/src/3rdparty/phonon/mmf/mediaobject.h b/src/3rdparty/phonon/mmf/mediaobject.h
index f17580e..af9bae2 100644
--- a/src/3rdparty/phonon/mmf/mediaobject.h
+++ b/src/3rdparty/phonon/mmf/mediaobject.h
@@ -40,6 +40,9 @@ typedef CMdaAudioPlayerUtility CPlayerType;
typedef MMdaAudioPlayerCallback MPlayerObserverType;
#endif
+// For recognizer
+#include <apgcli.h>
+
namespace Phonon
{
namespace MMF
@@ -149,6 +152,13 @@ namespace Phonon
*/
void changeState(PrivateState newState);
+ RApaLsSession m_recognizer;
+ RFs m_fileServer;
+ enum MediaType { MediaTypeUnknown, MediaTypeAudio, MediaTypeVideo };
+ MediaType mimeTypeToMediaType(const TDesC& mimeType);
+ MediaType fileMediaType(const QString& fileName);
+ // TODO: urlMediaType function
+
/**
* Using CPlayerType typedef in order to be able to easily switch between
* CMdaAudioPlayerUtility and CDrmPlayerUtility
diff --git a/src/plugins/phonon/mmf/mmf.pro b/src/plugins/phonon/mmf/mmf.pro
index ee2d3f9..3c8a721 100644
--- a/src/plugins/phonon/mmf/mmf.pro
+++ b/src/plugins/phonon/mmf/mmf.pro
@@ -33,6 +33,9 @@ SOURCES += \
$$PHONON_MMF_DIR/mediaobject.cpp \
$$PHONON_MMF_DIR/utils.cpp
+LIBS += -lefsrv # For file server
+LIBS += -lapgrfx.lib # For recognizer
+
# This is needed for having the .qtplugin file properly created on Symbian.
QTDIR_build:DESTDIR = $$QT_BUILD_TREE/plugins/phonon_backend