summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorGareth Stockwell <gareth.stockwell@sosco.com>2009-08-25 07:46:08 (GMT)
committerGareth Stockwell <gareth.stockwell@sosco.com>2009-08-25 07:46:08 (GMT)
commitca8f0c669142d27091873c108ffe21b4285e3087 (patch)
tree74bee27be06d17007b9e589c6bc3aaf668aab69a /src
parentd4efe766d35aa8150f67f67cd16cfc00ba4f9723 (diff)
downloadQt-ca8f0c669142d27091873c108ffe21b4285e3087.zip
Qt-ca8f0c669142d27091873c108ffe21b4285e3087.tar.gz
Qt-ca8f0c669142d27091873c108ffe21b4285e3087.tar.bz2
Implemented Backend::availableMimeTypes
Diffstat (limited to 'src')
-rw-r--r--src/3rdparty/phonon/mmf/TODO.txt2
-rw-r--r--src/3rdparty/phonon/mmf/backend.cpp39
-rw-r--r--src/3rdparty/phonon/mmf/defs.h8
-rw-r--r--src/3rdparty/phonon/mmf/mediaobject.cpp26
-rw-r--r--src/3rdparty/phonon/mmf/mediaobject.h5
-rw-r--r--src/3rdparty/phonon/mmf/utils.cpp21
-rw-r--r--src/3rdparty/phonon/mmf/utils.h14
7 files changed, 81 insertions, 34 deletions
diff --git a/src/3rdparty/phonon/mmf/TODO.txt b/src/3rdparty/phonon/mmf/TODO.txt
index d866aea..4b140dd 100644
--- a/src/3rdparty/phonon/mmf/TODO.txt
+++ b/src/3rdparty/phonon/mmf/TODO.txt
@@ -30,8 +30,6 @@ The main question here is how best to implement the MIME type detection for stre
* Performance analysis
Compare video frame rate obtained using default S60 media player and Qt demo apps
-* Implement MMF::Backend::availableMimeTypes
-
* Implement MMF::Backend::disconnectNodes
This should probably be left for now, particularly until audio effects have been implemented. This is because the node connection mechanism may need to be refactored slightly once we start building up longer graphs (e.g. MediaObject -> Effect -> Effect -> AudioOutput).
diff --git a/src/3rdparty/phonon/mmf/backend.cpp b/src/3rdparty/phonon/mmf/backend.cpp
index 5b360f2..010562e 100644
--- a/src/3rdparty/phonon/mmf/backend.cpp
+++ b/src/3rdparty/phonon/mmf/backend.cpp
@@ -19,6 +19,10 @@ along with this library. If not, see <http://www.gnu.org/licenses/>.
#include <QStringList>
#include <QtPlugin>
+#include <apgcli.h> // for RApaLsSession
+#include <apmrec.h> // for CDataTypeArray
+#include <apmstd.h> // for TDataType
+
#include "backend.h"
#include "audiooutput.h"
#include "mediaobject.h"
@@ -140,11 +144,42 @@ bool Backend::endConnectionChange(QSet<QObject *>)
return true;
}
+void getAvailableMimeTypesL(QStringList& result)
+{
+ RApaLsSession apaSession;
+ User::LeaveIfError(apaSession.Connect());
+ CleanupClosePushL(apaSession);
+
+ static const TInt DataTypeArrayGranularity = 8;
+ CDataTypeArray* array = new (ELeave) CDataTypeArray(DataTypeArrayGranularity);
+ CleanupStack::PushL(array);
+
+ apaSession.GetSupportedDataTypesL(*array);
+
+ for(TInt i=0; i<array->Count(); ++i)
+ {
+ const TPtrC mimeType = array->At(i).Des();
+ const MediaType mediaType = Utils::mimeTypeToMediaType(mimeType);
+ if(MediaTypeAudio == mediaType or MediaTypeVideo == mediaType)
+ {
+ result.append(qt_TDesC2QString(mimeType));
+ }
+ }
+
+ CleanupStack::PopAndDestroy(2); // apaSession, array
+}
+
QStringList Backend::availableMimeTypes() const
{
- // TODO: query MMF for available MIME types
+ QStringList result;
+
+ // There is no way to return an error from this function, so we just
+ // have to trap and ignore exceptions...
+ TRAP_IGNORE(getAvailableMimeTypesL(result));
- return QStringList();
+ result.sort();
+
+ return result;
}
Q_EXPORT_PLUGIN2(phonon_mmf, Phonon::MMF::Backend);
diff --git a/src/3rdparty/phonon/mmf/defs.h b/src/3rdparty/phonon/mmf/defs.h
index d31cabb..0f2f31f 100644
--- a/src/3rdparty/phonon/mmf/defs.h
+++ b/src/3rdparty/phonon/mmf/defs.h
@@ -27,7 +27,13 @@ namespace Phonon
{
static const qint32 DefaultTickInterval = 20;
static const qreal InitialVolume = 0.5;
-
+
+ enum MediaType
+ {
+ MediaTypeUnknown,
+ MediaTypeAudio,
+ MediaTypeVideo
+ };
}
}
diff --git a/src/3rdparty/phonon/mmf/mediaobject.cpp b/src/3rdparty/phonon/mmf/mediaobject.cpp
index 82c671c..fec5441 100644
--- a/src/3rdparty/phonon/mmf/mediaobject.cpp
+++ b/src/3rdparty/phonon/mmf/mediaobject.cpp
@@ -17,6 +17,7 @@ along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
#include "audioplayer.h"
+#include "defs.h"
#include "dummyplayer.h"
#include "mediaobject.h"
#include "utils.h"
@@ -95,28 +96,7 @@ bool MMF::MediaObject::openRecognizer()
return true;
}
-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
+MMF::MediaType MMF::MediaObject::fileMediaType
(const QString& fileName)
{
TRACE_CONTEXT(MediaObject::fileMediaType, EAudioInternal);
@@ -137,7 +117,7 @@ MMF::MediaObject::MediaType MMF::MediaObject::fileMediaType
if(KErrNone == err)
{
const TPtrC mimeType = recognizerResult.iDataType.Des();
- result = mimeTypeToMediaType(mimeType);
+ result = Utils::mimeTypeToMediaType(mimeType);
}
else
{
diff --git a/src/3rdparty/phonon/mmf/mediaobject.h b/src/3rdparty/phonon/mmf/mediaobject.h
index 130b7e1..99223c3 100644
--- a/src/3rdparty/phonon/mmf/mediaobject.h
+++ b/src/3rdparty/phonon/mmf/mediaobject.h
@@ -27,6 +27,7 @@ along with this library. If not, see <http://www.gnu.org/licenses/>.
// For recognizer
#include <apgcli.h>
+#include "defs.h"
#include "volumeobserver.h"
namespace Phonon
@@ -88,9 +89,7 @@ namespace Phonon
void createPlayer(const MediaSource &source);
bool openRecognizer();
- // Audio / video media type recognition
- enum MediaType { MediaTypeUnknown, MediaTypeAudio, MediaTypeVideo };
- MediaType mimeTypeToMediaType(const TDesC& mimeType);
+ // Audio / video media type recognition
MediaType fileMediaType(const QString& fileName);
// TODO: urlMediaType function
diff --git a/src/3rdparty/phonon/mmf/utils.cpp b/src/3rdparty/phonon/mmf/utils.cpp
index ada4800..2655962 100644
--- a/src/3rdparty/phonon/mmf/utils.cpp
+++ b/src/3rdparty/phonon/mmf/utils.cpp
@@ -44,3 +44,24 @@ QHBufC MMF::Utils::symbianFilename(const QString& qtFilename)
return result;
}
+
+
+static const TInt KMimePrefixLength = 6; // either "audio/" or "video/"
+_LIT(KMimePrefixAudio, "audio/");
+_LIT(KMimePrefixVideo, "video/");
+
+MMF::MediaType MMF::Utils::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;
+}
diff --git a/src/3rdparty/phonon/mmf/utils.h b/src/3rdparty/phonon/mmf/utils.h
index 8895a93..2df7e48 100644
--- a/src/3rdparty/phonon/mmf/utils.h
+++ b/src/3rdparty/phonon/mmf/utils.h
@@ -22,6 +22,8 @@ along with this library. If not, see <http://www.gnu.org/licenses/>.
#include <private/qcore_symbian_p.h>
#include <e32debug.h> // for RDebug
+#include "defs.h"
+
namespace Phonon
{
namespace MMF
@@ -30,12 +32,12 @@ namespace Phonon
* Panic codes for fatal errors
*/
enum PanicCode
- {
+ {
InvalidStatePanic = 1,
InvalidMediaTypePanic = 2,
InvalidBackendInterfaceClass = 3
- };
-
+ };
+
namespace Utils
{
/**
@@ -51,6 +53,12 @@ namespace Phonon
* determined.
*/
QHBufC symbianFilename(const QString& qtFilename);
+
+ /**
+ * Determines whether the provided MIME type is an audio or video
+ * type. If it is neither, the function returns MediaTypeUnknown.
+ */
+ MediaType mimeTypeToMediaType(const TDesC& mimeType);
}
/**