diff options
author | Gareth Stockwell <gareth.stockwell@sosco.com> | 2009-08-17 15:02:58 (GMT) |
---|---|---|
committer | Gareth Stockwell <gareth.stockwell@sosco.com> | 2009-08-17 15:02:58 (GMT) |
commit | 427c415d876d57042a55e8b66730888512ac0ed1 (patch) | |
tree | 0bc694626ccd2229941ee73a31f7e048b714ed1e /src/3rdparty/phonon/mmf/mediaobject.cpp | |
parent | c82bcc8a3bf2ab64db9ccbe7b8ec7ca1208e2edc (diff) | |
download | Qt-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/3rdparty/phonon/mmf/mediaobject.cpp')
-rw-r--r-- | src/3rdparty/phonon/mmf/mediaobject.cpp | 58 |
1 files changed, 58 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 //----------------------------------------------------------------------------- |