summaryrefslogtreecommitdiff
path: root/src/gsttools/qgstutils.cpp
diff options
context:
space:
mode:
authorJonas Rabbe <jonas.rabbe@nokia.com>2012-03-22 11:04:03 +1000
committerQt by Nokia <qt-info@nokia.com>2012-04-27 09:22:09 +0200
commita3b6eabd45b452b98c5b7c45df8a332ad018b8f1 (patch)
tree9f3a3fd7bfd6c514a472ad0103037476da4c6e0f /src/gsttools/qgstutils.cpp
parente44bcf0a384c15e7df593ec3f3cee30775f3f1ef (diff)
downloadqtmultimedia-a3b6eabd45b452b98c5b7c45df8a332ad018b8f1.tar.gz
Split gstreamer plugin into smaller plugins providing fewer services
The gstreamer blob has been split into four plugins: audiodecoder, camerabin, mediacapture, and mediaplayer. Note: camerabin is still disabled because it is untested camerabin2 implementation. A new qmake configuration use_gstreamer_camera has been introduced and is needed for the mediacapture plugin to expose the camera service. This configuration has been disabled by default. Shared functionality has been moved to the internal gsttools library. Change-Id: Ifb2604f440cfa97513d39f5d7978766c88eaec45 Reviewed-by: Michael Goddard <michael.goddard@nokia.com>
Diffstat (limited to 'src/gsttools/qgstutils.cpp')
-rw-r--r--src/gsttools/qgstutils.cpp88
1 files changed, 88 insertions, 0 deletions
diff --git a/src/gsttools/qgstutils.cpp b/src/gsttools/qgstutils.cpp
index 03c31fbdf..b29ca367c 100644
--- a/src/gsttools/qgstutils.cpp
+++ b/src/gsttools/qgstutils.cpp
@@ -45,6 +45,8 @@
#include <QtCore/qbytearray.h>
#include <QtCore/qvariant.h>
#include <QtCore/qsize.h>
+#include <QtCore/qset.h>
+#include <QtCore/qstringlist.h>
#include <qaudioformat.h>
QT_BEGIN_NAMESPACE
@@ -313,4 +315,90 @@ GstCaps *QGstUtils::capsForAudioFormat(QAudioFormat format)
return caps;
}
+void QGstUtils::initializeGst()
+{
+ static bool initialized = false;
+ if (!initialized) {
+ initialized = true;
+ gst_init(NULL, NULL);
+ }
+}
+
+namespace {
+ const char* getCodecAlias(const QString &codec)
+ {
+ if (codec.startsWith("avc1."))
+ return "video/x-h264";
+
+ if (codec.startsWith("mp4a."))
+ return "audio/mpeg4";
+
+ if (codec.startsWith("mp4v.20."))
+ return "video/mpeg4";
+
+ if (codec == "samr")
+ return "audio/amr";
+
+ return 0;
+ }
+
+ const char* getMimeTypeAlias(const QString &mimeType)
+ {
+ if (mimeType == "video/mp4")
+ return "video/mpeg4";
+
+ if (mimeType == "audio/mp4")
+ return "audio/mpeg4";
+
+ if (mimeType == "video/ogg"
+ || mimeType == "audio/ogg")
+ return "application/ogg";
+
+ return 0;
+ }
+}
+
+QtMultimedia::SupportEstimate QGstUtils::hasSupport(const QString &mimeType,
+ const QStringList &codecs,
+ const QSet<QString> &supportedMimeTypeSet)
+{
+ if (supportedMimeTypeSet.isEmpty())
+ return QtMultimedia::NotSupported;
+
+ QString mimeTypeLowcase = mimeType.toLower();
+ bool containsMimeType = supportedMimeTypeSet.contains(mimeTypeLowcase);
+ if (!containsMimeType) {
+ const char* mimeTypeAlias = getMimeTypeAlias(mimeTypeLowcase);
+ containsMimeType = supportedMimeTypeSet.contains(mimeTypeAlias);
+ if (!containsMimeType) {
+ containsMimeType = supportedMimeTypeSet.contains("video/" + mimeTypeLowcase)
+ || supportedMimeTypeSet.contains("video/x-" + mimeTypeLowcase)
+ || supportedMimeTypeSet.contains("audio/" + mimeTypeLowcase)
+ || supportedMimeTypeSet.contains("audio/x-" + mimeTypeLowcase);
+ }
+ }
+
+ int supportedCodecCount = 0;
+ foreach (const QString &codec, codecs) {
+ QString codecLowcase = codec.toLower();
+ const char* codecAlias = getCodecAlias(codecLowcase);
+ if (codecAlias) {
+ if (supportedMimeTypeSet.contains(codecAlias))
+ supportedCodecCount++;
+ } else if (supportedMimeTypeSet.contains("video/" + codecLowcase)
+ || supportedMimeTypeSet.contains("video/x-" + codecLowcase)
+ || supportedMimeTypeSet.contains("audio/" + codecLowcase)
+ || supportedMimeTypeSet.contains("audio/x-" + codecLowcase)) {
+ supportedCodecCount++;
+ }
+ }
+ if (supportedCodecCount > 0 && supportedCodecCount == codecs.size())
+ return QtMultimedia::ProbablySupported;
+
+ if (supportedCodecCount == 0 && !containsMimeType)
+ return QtMultimedia::NotSupported;
+
+ return QtMultimedia::MaybeSupported;
+}
+
QT_END_NAMESPACE