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>
This commit is contained in:
Jonas Rabbe
2012-03-22 11:04:03 +10:00
committed by Qt by Nokia
parent e44bcf0a38
commit a3b6eabd45
58 changed files with 923 additions and 322 deletions

View File

@@ -23,7 +23,6 @@ PKGCONFIG += \
gstreamer-pbutils-0.10
maemo*:PKGCONFIG +=gstreamer-plugins-bad-0.10
contains(config_test_gstreamer_appsrc, yes): PKGCONFIG += gstreamer-app-0.10
contains(config_test_resourcepolicy, yes) {
DEFINES += HAVE_RESOURCE_POLICY
@@ -42,6 +41,14 @@ PRIVATE_HEADERS += \
qgstutils_p.h \
qgstvideobuffer_p.h \
qvideosurfacegstsink_p.h \
qgstreamervideorendererinterface_p.h \
qgstreameraudioinputendpointselector_p.h \
qgstreamervideorenderer_p.h \
qgstreamervideoinputdevicecontrol_p.h \
gstvideoconnector_p.h \
qgstcodecsinfo_p.h \
qgstreamervideoprobecontrol_p.h \
qgstreameraudioprobecontrol_p.h \
SOURCES += \
qgstbufferpoolinterface.cpp \
@@ -50,6 +57,14 @@ SOURCES += \
qgstutils.cpp \
qgstvideobuffer.cpp \
qvideosurfacegstsink.cpp \
qgstreamervideorendererinterface.cpp \
qgstreameraudioinputendpointselector.cpp \
qgstreamervideorenderer.cpp \
qgstreamervideoinputdevicecontrol.cpp \
qgstcodecsinfo.cpp \
gstvideoconnector.c \
qgstreamervideoprobecontrol.cpp \
qgstreameraudioprobecontrol.cpp \
contains(config_test_xvideo, yes) {
DEFINES += HAVE_XVIDEO
@@ -61,6 +76,43 @@ contains(config_test_xvideo, yes) {
SOURCES += \
qgstxvimagebuffer.cpp \
!isEmpty(QT.widgets.name) {
QT += multimediawidgets
PRIVATE_HEADERS += \
qgstreamervideooverlay_p.h \
qgstreamervideowindow_p.h \
qgstreamervideowidget_p.h \
qx11videosurface_p.h \
SOURCES += \
qgstreamervideooverlay.cpp \
qgstreamervideowindow.cpp \
qgstreamervideowidget.cpp \
qx11videosurface.cpp \
}
}
maemo6 {
PKGCONFIG += qmsystem2
contains(QT_CONFIG, opengles2):!isEmpty(QT.widgets.name) {
PRIVATE_HEADERS += qgstreamergltexturerenderer_p.h
SOURCES += qgstreamergltexturerenderer.cpp
QT += opengl
LIBS += -lEGL -lgstmeegointerfaces-0.10
}
}
contains(config_test_gstreamer_appsrc, yes) {
PKGCONFIG += gstreamer-app-0.10
PRIVATE_HEADERS += qgstappsrc_p.h
SOURCES += qgstappsrc.cpp
DEFINES += HAVE_GST_APPSRC
LIBS += -lgstapp-0.10
}
HEADERS += $$PRIVATE_HEADERS

View File

@@ -39,7 +39,7 @@
**
****************************************************************************/
#include "gstvideoconnector.h"
#include "gstvideoconnector_p.h"
#include <unistd.h>
/* signals */

View File

@@ -41,7 +41,7 @@
#include <QDebug>
#include "qgstappsrc.h"
#include "qgstappsrc_p.h"
#include <QtNetwork>
QGstAppSrc::QGstAppSrc(QObject *parent)

View File

@@ -39,7 +39,7 @@
**
****************************************************************************/
#include "qgstcodecsinfo.h"
#include "qgstcodecsinfo_p.h"
#include <QtCore/qset.h>

View File

@@ -39,7 +39,7 @@
**
****************************************************************************/
#include "qgstreameraudioinputendpointselector.h"
#include "qgstreameraudioinputendpointselector_p.h"
#include <QtCore/QDir>
#include <QtCore/QDebug>

View File

@@ -39,7 +39,7 @@
**
****************************************************************************/
#include "qgstreameraudioprobecontrol.h"
#include "qgstreameraudioprobecontrol_p.h"
#include <private/qgstutils_p.h>
QGstreamerAudioProbeControl::QGstreamerAudioProbeControl(QObject *parent)

View File

@@ -61,7 +61,7 @@
#include <EGL/egl.h>
#include <EGL/eglext.h>
#include "qgstreamergltexturerenderer.h"
#include "qgstreamergltexturerenderer_p.h"
//#define GL_TEXTURE_SINK_DEBUG 1

View File

@@ -39,7 +39,7 @@
**
****************************************************************************/
#include "qgstreamervideoinputdevicecontrol.h"
#include "qgstreamervideoinputdevicecontrol_p.h"
#include <QtCore/QDir>
#include <QtCore/QDebug>

View File

@@ -39,12 +39,12 @@
**
****************************************************************************/
#include "qgstreamervideooverlay.h"
#include "qgstreamervideooverlay_p.h"
#include <private/qvideosurfacegstsink_p.h>
#include <qvideosurfaceformat.h>
#include <qx11videosurface.h>
#include <qx11videosurface_p.h>
QGstreamerVideoOverlay::QGstreamerVideoOverlay(QObject *parent)
: QVideoWindowControl(parent)

View File

@@ -39,7 +39,7 @@
**
****************************************************************************/
#include "qgstreamervideoprobecontrol.h"
#include "qgstreamervideoprobecontrol_p.h"
#include <private/qvideosurfacegstsink_p.h>
#include <private/qgstvideobuffer_p.h>

View File

@@ -39,7 +39,7 @@
**
****************************************************************************/
#include "qgstreamervideorenderer.h"
#include "qgstreamervideorenderer_p.h"
#include <private/qvideosurfacegstsink_p.h>
#include <qabstractvideosurface.h>

View File

@@ -39,7 +39,7 @@
**
****************************************************************************/
#include "qgstreamervideorendererinterface.h"
#include "qgstreamervideorendererinterface_p.h"
QGstreamerVideoRendererInterface::~QGstreamerVideoRendererInterface()
{

View File

@@ -39,7 +39,7 @@
**
****************************************************************************/
#include "qgstreamervideowidget.h"
#include "qgstreamervideowidget_p.h"
#include <private/qgstutils_p.h>
#include <QtCore/qcoreevent.h>

View File

@@ -39,7 +39,7 @@
**
****************************************************************************/
#include "qgstreamervideowindow.h"
#include "qgstreamervideowindow_p.h"
#include <private/qgstutils_p.h>
#include <QtCore/qdebug.h>

View File

@@ -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

View File

@@ -45,7 +45,7 @@
#include <QtGui/qplatformnativeinterface_qpa.h>
#include <qvideosurfaceformat.h>
#include "qx11videosurface.h"
#include "qx11videosurface_p.h"
Q_DECLARE_METATYPE(XvImage*);

View File

@@ -45,7 +45,7 @@
#include <gst/gst.h>
#include <qmediaaudioprobecontrol.h>
#include <QtCore/qmutex.h>
#include "qaudiobuffer.h"
#include <qaudiobuffer.h>
QT_BEGIN_NAMESPACE

View File

@@ -46,7 +46,7 @@
#include <private/qvideosurfacegstsink_p.h>
#include <private/qgstreamerbushelper_p.h>
#include "qgstreamervideorendererinterface.h"
#include "qgstreamervideorendererinterface_p.h"
#include <QtGui/qcolor.h>
#include <X11/extensions/Xv.h>

View File

@@ -44,7 +44,7 @@
#include <qvideowindowcontrol.h>
#include "qgstreamervideorendererinterface.h"
#include "qgstreamervideorendererinterface_p.h"
QT_BEGIN_NAMESPACE
class QAbstractVideoSurface;

View File

@@ -45,7 +45,7 @@
#include <gst/gst.h>
#include <qmediavideoprobecontrol.h>
#include <QtCore/qmutex.h>
#include "qvideoframe.h"
#include <qvideoframe.h>
QT_BEGIN_NAMESPACE

View File

@@ -45,7 +45,7 @@
#include <qvideorenderercontrol.h>
#include <private/qvideosurfacegstsink_p.h>
#include "qgstreamervideorendererinterface.h"
#include "qgstreamervideorendererinterface_p.h"
QT_BEGIN_NAMESPACE

View File

@@ -44,7 +44,7 @@
#include <qvideowidgetcontrol.h>
#include "qgstreamervideorendererinterface.h"
#include "qgstreamervideorendererinterface_p.h"
#include <private/qgstreamerbushelper_p.h>
QT_BEGIN_NAMESPACE

View File

@@ -44,7 +44,7 @@
#include <qvideowindowcontrol.h>
#include "qgstreamervideorendererinterface.h"
#include "qgstreamervideorendererinterface_p.h"
#include <private/qgstreamerbushelper_p.h>
#include <QtGui/qcolor.h>

View File

@@ -54,6 +54,7 @@
//
#include <QtCore/qmap.h>
#include <QtCore/qset.h>
#include <gst/gst.h>
#include <qaudioformat.h>
@@ -71,6 +72,10 @@ namespace QGstUtils {
QAudioFormat audioFormatForCaps(const GstCaps *caps);
QAudioFormat audioFormatForBuffer(GstBuffer *buffer);
GstCaps *capsForAudioFormat(QAudioFormat format);
void initializeGst();
QtMultimedia::SupportEstimate hasSupport(const QString &mimeType,
const QStringList &codecs,
const QSet<QString> &supportedMimeTypeSet);
}
QT_END_NAMESPACE

View File

@@ -0,0 +1,3 @@
{
"Keys": ["org.qt-project.qt.audiodecode"]
}

View File

@@ -1,15 +0,0 @@
INCLUDEPATH += $$PWD
DEFINES += QMEDIA_GSTREAMER_AUDIO_DECODER
HEADERS += \
$$PWD/qgstreameraudiodecodercontrol.h \
$$PWD/qgstreameraudiodecoderservice.h \
$$PWD/qgstreameraudiodecodersession.h
SOURCES += \
$$PWD/qgstreameraudiodecodercontrol.cpp \
$$PWD/qgstreameraudiodecoderservice.cpp \
$$PWD/qgstreameraudiodecodersession.cpp

View File

@@ -0,0 +1,30 @@
load(qt_module)
TARGET = gstaudiodecoder
PLUGIN_TYPE = mediaservice
load(qt_plugin)
DESTDIR = $$QT.multimedia.plugins/$${PLUGIN_TYPE}
include(../common.pri)
INCLUDEPATH += $$PWD
HEADERS += \
$$PWD/qgstreameraudiodecodercontrol.h \
$$PWD/qgstreameraudiodecoderservice.h \
$$PWD/qgstreameraudiodecodersession.h \
$$PWD/qgstreameraudiodecoderserviceplugin.h
SOURCES += \
$$PWD/qgstreameraudiodecodercontrol.cpp \
$$PWD/qgstreameraudiodecoderservice.cpp \
$$PWD/qgstreameraudiodecodersession.cpp \
$$PWD/qgstreameraudiodecoderserviceplugin.cpp
target.path += $$[QT_INSTALL_PLUGINS]/$${PLUGIN_TYPE}
INSTALLS += target
OTHER_FILES += \
audiodecoder.json

View File

@@ -0,0 +1,180 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
** This file is part of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
** This file may be used under the terms of the GNU Lesser General Public
** License version 2.1 as published by the Free Software Foundation and
** appearing in the file LICENSE.LGPL included in the packaging of this
** file. Please review the following information to ensure the GNU Lesser
** General Public License version 2.1 requirements will be met:
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Nokia gives you certain additional
** rights. These rights are described in the Nokia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU General
** Public License version 3.0 as published by the Free Software Foundation
** and appearing in the file LICENSE.GPL included in the packaging of this
** file. Please review the following information to ensure the GNU General
** Public License version 3.0 requirements will be met:
** http://www.gnu.org/copyleft/gpl.html.
**
** Other Usage
** Alternatively, this file may be used in accordance with the terms and
** conditions contained in a signed written agreement between you and Nokia.
**
**
**
**
**
**
** $QT_END_LICENSE$
**
****************************************************************************/
#include "qgstreameraudiodecoderserviceplugin.h"
#include "qgstreameraudiodecoderservice.h"
#include <private/qgstutils_p.h>
#include <QtCore/qstring.h>
#include <QtCore/qdebug.h>
#include <QtCore/QDir>
#include <QtCore/QDebug>
#include <linux/types.h>
#include <sys/time.h>
#include <sys/ioctl.h>
#include <sys/poll.h>
#include <unistd.h>
#include <fcntl.h>
#include <errno.h>
#include <string.h>
#include <stdlib.h>
#include <sys/mman.h>
#include <linux/videodev2.h>
#include <gst/gst.h>
// #define QT_SUPPORTEDMIMETYPES_DEBUG
QMediaService* QGstreamerAudioDecoderServicePlugin::create(const QString &key)
{
QGstUtils::initializeGst();
if (key == QLatin1String(Q_MEDIASERVICE_AUDIODECODER))
return new QGstreamerAudioDecoderService;
qWarning() << "Gstreamer audio decoder service plugin: unsupported key:" << key;
return 0;
}
void QGstreamerAudioDecoderServicePlugin::release(QMediaService *service)
{
delete service;
}
QtMultimedia::SupportEstimate QGstreamerAudioDecoderServicePlugin::hasSupport(const QString &mimeType,
const QStringList &codecs) const
{
if (m_supportedMimeTypeSet.isEmpty())
updateSupportedMimeTypes();
return QGstUtils::hasSupport(mimeType, codecs, m_supportedMimeTypeSet);
}
void QGstreamerAudioDecoderServicePlugin::updateSupportedMimeTypes() const
{
//enumerate supported mime types
gst_init(NULL, NULL);
GList *plugins, *orig_plugins;
orig_plugins = plugins = gst_default_registry_get_plugin_list ();
while (plugins) {
GList *features, *orig_features;
GstPlugin *plugin = (GstPlugin *) (plugins->data);
plugins = g_list_next (plugins);
if (plugin->flags & (1<<1)) //GST_PLUGIN_FLAG_BLACKLISTED
continue;
orig_features = features = gst_registry_get_feature_list_by_plugin(gst_registry_get_default (),
plugin->desc.name);
while (features) {
if (!G_UNLIKELY(features->data == NULL)) {
GstPluginFeature *feature = GST_PLUGIN_FEATURE(features->data);
if (GST_IS_ELEMENT_FACTORY (feature)) {
GstElementFactory *factory = GST_ELEMENT_FACTORY(gst_plugin_feature_load(feature));
if (factory
&& factory->numpadtemplates > 0
&& (qstrcmp(factory->details.klass, "Codec/Decoder/Audio") == 0
|| qstrcmp(factory->details.klass, "Codec/Demux") == 0 )) {
const GList *pads = factory->staticpadtemplates;
while (pads) {
GstStaticPadTemplate *padtemplate = (GstStaticPadTemplate*)(pads->data);
pads = g_list_next (pads);
if (padtemplate->direction != GST_PAD_SINK)
continue;
if (padtemplate->static_caps.string) {
GstCaps *caps = gst_static_caps_get(&padtemplate->static_caps);
if (!gst_caps_is_any (caps) && ! gst_caps_is_empty (caps)) {
for (guint i = 0; i < gst_caps_get_size(caps); i++) {
GstStructure *structure = gst_caps_get_structure(caps, i);
QString nameLowcase = QString(gst_structure_get_name (structure)).toLower();
m_supportedMimeTypeSet.insert(nameLowcase);
if (nameLowcase.contains("mpeg")) {
//Because mpeg version number is only included in the detail
//description, it is necessary to manually extract this information
//in order to match the mime type of mpeg4.
const GValue *value = gst_structure_get_value(structure, "mpegversion");
if (value) {
gchar *str = gst_value_serialize (value);
QString versions(str);
QStringList elements = versions.split(QRegExp("\\D+"), QString::SkipEmptyParts);
foreach (const QString &e, elements)
m_supportedMimeTypeSet.insert(nameLowcase + e);
g_free (str);
}
}
}
}
}
}
gst_object_unref (factory);
}
} else if (GST_IS_TYPE_FIND_FACTORY(feature)) {
QString name(gst_plugin_feature_get_name(feature));
if (name.contains('/')) //filter out any string without '/' which is obviously not a mime type
m_supportedMimeTypeSet.insert(name.toLower());
}
}
features = g_list_next (features);
}
gst_plugin_feature_list_free (orig_features);
}
gst_plugin_list_free (orig_plugins);
#if defined QT_SUPPORTEDMIMETYPES_DEBUG
QStringList list = m_supportedMimeTypeSet.toList();
list.sort();
if (qgetenv("QT_DEBUG_PLUGINS").toInt() > 0) {
foreach (const QString &type, list)
qDebug() << type;
}
#endif
}
QStringList QGstreamerAudioDecoderServicePlugin::supportedMimeTypes() const
{
return QStringList();
}

View File

@@ -0,0 +1,74 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
** This file is part of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
** This file may be used under the terms of the GNU Lesser General Public
** License version 2.1 as published by the Free Software Foundation and
** appearing in the file LICENSE.LGPL included in the packaging of this
** file. Please review the following information to ensure the GNU Lesser
** General Public License version 2.1 requirements will be met:
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Nokia gives you certain additional
** rights. These rights are described in the Nokia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU General
** Public License version 3.0 as published by the Free Software Foundation
** and appearing in the file LICENSE.GPL included in the packaging of this
** file. Please review the following information to ensure the GNU General
** Public License version 3.0 requirements will be met:
** http://www.gnu.org/copyleft/gpl.html.
**
** Other Usage
** Alternatively, this file may be used in accordance with the terms and
** conditions contained in a signed written agreement between you and Nokia.
**
**
**
**
**
**
** $QT_END_LICENSE$
**
****************************************************************************/
#ifndef QGSTREAMERAUDIODECODERSERVICEPLUGIN_H
#define QGSTREAMERAUDIODECODERSERVICEPLUGIN_H
#include <qmediaserviceproviderplugin.h>
#include <QtCore/qset.h>
#include <QtCore/QObject>
QT_BEGIN_NAMESPACE
class QGstreamerAudioDecoderServicePlugin
: public QMediaServiceProviderPlugin
, public QMediaServiceSupportedFormatsInterface
{
Q_OBJECT
Q_INTERFACES(QMediaServiceSupportedFormatsInterface)
Q_PLUGIN_METADATA(IID "org.qt-project.qt.mediaserviceproviderfactory/5.0" FILE "audiodecoder.json")
public:
QMediaService* create(QString const& key);
void release(QMediaService *service);
QtMultimedia::SupportEstimate hasSupport(const QString &mimeType, const QStringList& codecs) const;
QStringList supportedMimeTypes() const;
private:
void updateSupportedMimeTypes() const;
mutable QSet<QString> m_supportedMimeTypeSet;
};
QT_END_NAMESPACE
#endif // QGSTREAMERAUDIODECODERSERVICEPLUGIN_H

View File

@@ -49,7 +49,7 @@
#include "qaudiodecoder.h"
#if defined(HAVE_GST_APPSRC)
#include "qgstappsrc.h"
#include <private/qgstappsrc_p.h>
#endif
#include <gst/gst.h>

View File

@@ -1,10 +1,18 @@
load(qt_module)
TARGET = gstcamerabin
PLUGIN_TYPE = mediaservice
load(qt_plugin)
DESTDIR = $$QT.multimedia.plugins/$${PLUGIN_TYPE}
include(../common.pri)
INCLUDEPATH += $$PWD \
$${SOURCE_DIR}/src/multimedia
INCLUDEPATH += camerabin
DEFINES += QMEDIA_GSTREAMER_CAMERABIN
LIBS += -lgstphotography-0.10
DEFINES += GST_USE_UNSTABLE_API #prevents warnings because of unstable photography API
@@ -48,3 +56,15 @@ SOURCES += \
$$PWD/camerabinresourcepolicy.cpp \
$$PWD/camerabincapturedestination.cpp \
$$PWD/camerabincapturebufferformat.cpp
maemo6 {
HEADERS += \
$$PWD/camerabuttonlistener_meego.h
SOURCES += \
$$PWD/camerabuttonlistener_meego.cpp
}
target.path += $$[QT_INSTALL_PLUGINS]/$${PLUGIN_TYPE}
INSTALLS += target

View File

@@ -0,0 +1,39 @@
QT += multimedia-private network
CONFIG += no_private_qt_headers_warning
!isEmpty(QT.widgets.name) {
QT += widgets multimediawidgets-private
DEFINES += HAVE_WIDGETS
}
LIBS += -lqgsttools_p
CONFIG += link_pkgconfig
PKGCONFIG += \
gstreamer-0.10 \
gstreamer-base-0.10 \
gstreamer-interfaces-0.10 \
gstreamer-audio-0.10 \
gstreamer-video-0.10 \
gstreamer-pbutils-0.10
maemo*:PKGCONFIG +=gstreamer-plugins-bad-0.10
contains(config_test_resourcepolicy, yes) {
DEFINES += HAVE_RESOURCE_POLICY
PKGCONFIG += libresourceqt1
}
contains(config_test_xvideo, yes):!isEmpty(QT.widgets.name): {
DEFINES += HAVE_XVIDEO
LIBS += -lXv -lX11 -lXext
}
contains(config_test_gstreamer_appsrc, yes) {
PKGCONFIG += gstreamer-app-0.10
DEFINES += HAVE_GST_APPSRC
LIBS += -lgstapp-0.10
}

View File

@@ -1,119 +1,14 @@
TEMPLATE = subdirs
load(qt_module)
SUBDIRS += \
audiodecoder \
mediacapture \
mediaplayer
TARGET = qgstengine
QT += multimedia-private network
CONFIG += no_private_qt_headers_warning
!isEmpty(QT.widgets.name) {
QT += widgets multimediawidgets-private
DEFINES += HAVE_WIDGETS
}
PLUGIN_TYPE=mediaservice
load(qt_plugin)
DESTDIR = $$QT.multimedia.plugins/$${PLUGIN_TYPE}
LIBS += -lqgsttools_p
unix:!maemo*:contains(QT_CONFIG, alsa) {
DEFINES += HAVE_ALSA
LIBS += -lasound
}
CONFIG += link_pkgconfig
PKGCONFIG += \
gstreamer-0.10 \
gstreamer-base-0.10 \
gstreamer-interfaces-0.10 \
gstreamer-audio-0.10 \
gstreamer-video-0.10 \
gstreamer-pbutils-0.10
maemo*:PKGCONFIG +=gstreamer-plugins-bad-0.10
contains(config_test_resourcepolicy, yes) {
DEFINES += HAVE_RESOURCE_POLICY
PKGCONFIG += libresourceqt1
}
maemo6 {
HEADERS += camerabuttonlistener_meego.h
SOURCES += camerabuttonlistener_meego.cpp
PKGCONFIG += qmsystem2
contains(QT_CONFIG, opengles2):!isEmpty(QT.widgets.name) {
HEADERS += qgstreamergltexturerenderer.h
SOURCES += qgstreamergltexturerenderer.cpp
QT += opengl
LIBS += -lEGL -lgstmeegointerfaces-0.10
# Camerabin2 based camera backend is untested and currently disabled
disabled {
contains(config_test_gstreamer_photography, yes) {
SUBDIRS += camerabin
}
}
HEADERS += \
qgstreamervideorendererinterface.h \
qgstreamerserviceplugin.h \
qgstreameraudioinputendpointselector.h \
qgstreamervideorenderer.h \
qgstreamervideoinputdevicecontrol.h \
gstvideoconnector.h \
qgstcodecsinfo.h \
qgstreamervideoprobecontrol.h \
qgstreameraudioprobecontrol.h \
SOURCES += \
qgstreamervideorendererinterface.cpp \
qgstreamerserviceplugin.cpp \
qgstreameraudioinputendpointselector.cpp \
qgstreamervideorenderer.cpp \
qgstreamervideoinputdevicecontrol.cpp \
qgstcodecsinfo.cpp \
gstvideoconnector.c \
qgstreamervideoprobecontrol.cpp \
qgstreameraudioprobecontrol.cpp \
contains(config_test_xvideo, yes):!isEmpty(QT.widgets.name): {
DEFINES += HAVE_XVIDEO
LIBS += -lXv -lX11 -lXext
HEADERS += \
qgstreamervideooverlay.h \
qgstreamervideowindow.h \
qgstreamervideowidget.h \
qx11videosurface.h \
SOURCES += \
qgstreamervideooverlay.cpp \
qgstreamervideowindow.cpp \
qgstreamervideowidget.cpp \
qx11videosurface.cpp \
}
include(mediaplayer/mediaplayer.pri)
include(mediacapture/mediacapture.pri)
include(audiodecoder/audiodecoder.pri)
contains(config_test_gstreamer_appsrc, yes) {
PKGCONFIG += gstreamer-app-0.10
HEADERS += $$PWD/qgstappsrc.h
SOURCES += $$PWD/qgstappsrc.cpp
DEFINES += HAVE_GST_APPSRC
LIBS += -lgstapp-0.10
}
OTHER_FILES += gstreamer.json
#Camerabin2 based camera backend is untested and currently disabled
#contains(config_test_gstreamer_photography, yes) {
# include(camerabin/camerabin.pri)
#}
target.path += $$[QT_INSTALL_PLUGINS]/$${PLUGIN_TYPE}
INSTALLS += target

View File

@@ -0,0 +1,3 @@
{
"Keys": ["org.qt-project.qt.audiosource"]
}

View File

@@ -1,6 +1,14 @@
INCLUDEPATH += $$PWD
load(qt_module)
DEFINES += QMEDIA_GSTREAMER_CAPTURE
TARGET = gstmediacapture
PLUGIN_TYPE = mediaservice
load(qt_plugin)
DESTDIR = $$QT.multimedia.plugins/$${PLUGIN_TYPE}
include(../common.pri)
INCLUDEPATH += $$PWD
HEADERS += $$PWD/qgstreamercaptureservice.h \
$$PWD/qgstreamercapturesession.h \
@@ -12,7 +20,8 @@ HEADERS += $$PWD/qgstreamercaptureservice.h \
$$PWD/qgstreamerv4l2input.h \
$$PWD/qgstreamercapturemetadatacontrol.h \
$$PWD/qgstreamerimagecapturecontrol.h \
$$PWD/qgstreamerimageencode.h
$$PWD/qgstreamerimageencode.h \
$$PWD/qgstreamercaptureserviceplugin.h
SOURCES += $$PWD/qgstreamercaptureservice.cpp \
$$PWD/qgstreamercapturesession.cpp \
@@ -24,4 +33,22 @@ SOURCES += $$PWD/qgstreamercaptureservice.cpp \
$$PWD/qgstreamerv4l2input.cpp \
$$PWD/qgstreamercapturemetadatacontrol.cpp \
$$PWD/qgstreamerimagecapturecontrol.cpp \
$$PWD/qgstreamerimageencode.cpp
$$PWD/qgstreamerimageencode.cpp \
$$PWD/qgstreamercaptureserviceplugin.cpp
target.path += $$[QT_INSTALL_PLUGINS]/$${PLUGIN_TYPE}
INSTALLS += target
# Camera usage with gstreamer needs to have
#CONFIG += use_gstreamer_camera
use_gstreamer_camera {
DEFINES += USE_GSTREAMER_CAMERA
OTHER_FILES += \
mediacapturecamera.json
} else {
OTHER_FILES += \
mediacapture.json
}

View File

@@ -0,0 +1,3 @@
{
"Keys": ["org.qt-project.qt.audiosource", "org.qt-project.qt.camera"]
}

View File

@@ -51,16 +51,16 @@
#include "qgstreamerv4l2input.h"
#include "qgstreamercapturemetadatacontrol.h"
#include "qgstreameraudioinputendpointselector.h"
#include "qgstreamervideoinputdevicecontrol.h"
#include "qgstreamerimagecapturecontrol.h"
#include "qgstreameraudioprobecontrol.h"
#include <private/qgstreameraudioinputendpointselector_p.h>
#include <private/qgstreamervideoinputdevicecontrol_p.h>
#include <private/qgstreameraudioprobecontrol_p.h>
#include "qgstreamervideorenderer.h"
#include <private/qgstreamervideorenderer_p.h>
#if defined(HAVE_WIDGETS)
#include "qgstreamervideooverlay.h"
#include "qgstreamervideowidget.h"
#include <private/qgstreamervideooverlay_p.h>
#include <private/qgstreamervideowidget_p.h>
#endif
#include <qmediaserviceproviderplugin.h>

View File

@@ -46,6 +46,7 @@
#include <qmediacontrol.h>
#include <gst/gst.h>
QT_BEGIN_NAMESPACE
class QAudioEndpointSelector;
class QVideoDeviceControl;
@@ -74,7 +75,7 @@ public:
void releaseControl(QMediaControl *);
private:
void setAudioPreview(GstElement*);
void setAudioPreview(GstElement *);
QGstreamerCaptureSession *m_captureSession;
QGstreamerCameraControl *m_cameraControl;

View File

@@ -44,27 +44,12 @@
#include <QtCore/QDir>
#include <QtCore/QDebug>
#include "qgstreamerserviceplugin.h"
#include "qgstreamercaptureserviceplugin.h"
//#define QT_SUPPORTEDMIMETYPES_DEBUG
#ifdef QMEDIA_GSTREAMER_PLAYER
#include "qgstreamerplayerservice.h"
#endif
#if defined(QMEDIA_GSTREAMER_CAPTURE)
#include "qgstreamercaptureservice.h"
#endif
#ifdef QMEDIA_GSTREAMER_CAMERABIN
#include "camerabinservice.h"
#endif
#ifdef QMEDIA_GSTREAMER_AUDIO_DECODER
#include "qgstreameraudiodecoderservice.h"
#endif
#include <qmediaserviceproviderplugin.h>
#include <private/qgstutils_p.h>
#include <linux/types.h>
#include <sys/time.h>
@@ -77,60 +62,40 @@
#include <stdlib.h>
#include <sys/mman.h>
#include <linux/videodev2.h>
#include <gst/gst.h>
QMediaService* QGstreamerServicePlugin::create(const QString &key)
QMediaService* QGstreamerCaptureServicePlugin::create(const QString &key)
{
static bool initialized = false;
if (!initialized) {
initialized = true;
gst_init(NULL, NULL);
}
QGstUtils::initializeGst();
#ifdef QMEDIA_GSTREAMER_PLAYER
if (key == QLatin1String(Q_MEDIASERVICE_MEDIAPLAYER))
return new QGstreamerPlayerService;
#endif
#ifdef QMEDIA_GSTREAMER_CAMERABIN
if (key == QLatin1String(Q_MEDIASERVICE_CAMERA) && CameraBinService::isCameraBinAvailable())
return new CameraBinService(key);
#endif
#ifdef QMEDIA_GSTREAMER_AUDIO_DECODER
if (key == QLatin1String(Q_MEDIASERVICE_AUDIODECODER))
return new QGstreamerAudioDecoderService;
#endif
#ifdef QMEDIA_GSTREAMER_CAPTURE
if (key == QLatin1String(Q_MEDIASERVICE_AUDIOSOURCE))
return new QGstreamerCaptureService(key);
#if defined(USE_GSTREAMER_CAMERA)
if (key == QLatin1String(Q_MEDIASERVICE_CAMERA))
return new QGstreamerCaptureService(key);
#endif
qWarning() << "Gstreamer service plugin: unsupported key:" << key;
qWarning() << "Gstreamer capture service plugin: unsupported key:" << key;
return 0;
}
void QGstreamerServicePlugin::release(QMediaService *service)
void QGstreamerCaptureServicePlugin::release(QMediaService *service)
{
delete service;
}
QMediaServiceProviderHint::Features QGstreamerServicePlugin::supportedFeatures(
#if defined(USE_GSTREAMER_CAMERA)
QMediaServiceProviderHint::Features QGstreamerCaptureServicePlugin::supportedFeatures(
const QByteArray &service) const
{
if (service == Q_MEDIASERVICE_MEDIAPLAYER)
return QMediaServiceProviderHint::StreamPlayback | QMediaServiceProviderHint::VideoSurface;
else if (service == Q_MEDIASERVICE_CAMERA)
if (service == Q_MEDIASERVICE_CAMERA)
return QMediaServiceProviderHint::VideoSurface;
else
return QMediaServiceProviderHint::Features();
}
QList<QByteArray> QGstreamerServicePlugin::devices(const QByteArray &service) const
QList<QByteArray> QGstreamerCaptureServicePlugin::devices(const QByteArray &service) const
{
if (service == Q_MEDIASERVICE_CAMERA) {
if (m_cameraDevices.isEmpty())
@@ -142,7 +107,7 @@ QList<QByteArray> QGstreamerServicePlugin::devices(const QByteArray &service) co
return QList<QByteArray>();
}
QString QGstreamerServicePlugin::deviceDescription(const QByteArray &service, const QByteArray &device)
QString QGstreamerCaptureServicePlugin::deviceDescription(const QByteArray &service, const QByteArray &device)
{
if (service == Q_MEDIASERVICE_CAMERA) {
if (m_cameraDevices.isEmpty())
@@ -156,7 +121,7 @@ QString QGstreamerServicePlugin::deviceDescription(const QByteArray &service, co
return QString();
}
QVariant QGstreamerServicePlugin::deviceProperty(const QByteArray &service, const QByteArray &device, const QByteArray &property)
QVariant QGstreamerCaptureServicePlugin::deviceProperty(const QByteArray &service, const QByteArray &device, const QByteArray &property)
{
Q_UNUSED(service);
Q_UNUSED(device);
@@ -164,17 +129,11 @@ QVariant QGstreamerServicePlugin::deviceProperty(const QByteArray &service, cons
return QVariant();
}
void QGstreamerServicePlugin::updateDevices() const
void QGstreamerCaptureServicePlugin::updateDevices() const
{
m_cameraDevices.clear();
m_cameraDescriptions.clear();
#ifdef Q_WS_MAEMO_6
m_cameraDevices << "primary" << "secondary";
m_cameraDescriptions << tr("Main camera") << tr("Front camera");
return;
#endif
QDir devDir("/dev");
devDir.setFilter(QDir::System);
@@ -216,84 +175,18 @@ void QGstreamerServicePlugin::updateDevices() const
::close(fd);
}
}
#endif
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 QGstreamerServicePlugin::hasSupport(const QString &mimeType,
QtMultimedia::SupportEstimate QGstreamerCaptureServicePlugin::hasSupport(const QString &mimeType,
const QStringList& codecs) const
{
if (m_supportedMimeTypeSet.isEmpty())
updateSupportedMimeTypes();
QString mimeTypeLowcase = mimeType.toLower();
bool containsMimeType = m_supportedMimeTypeSet.contains(mimeTypeLowcase);
if (!containsMimeType) {
const char* mimeTypeAlias = getMimeTypeAlias(mimeTypeLowcase);
containsMimeType = m_supportedMimeTypeSet.contains(mimeTypeAlias);
if (!containsMimeType) {
containsMimeType = m_supportedMimeTypeSet.contains("video/" + mimeTypeLowcase)
|| m_supportedMimeTypeSet.contains("video/x-" + mimeTypeLowcase)
|| m_supportedMimeTypeSet.contains("audio/" + mimeTypeLowcase)
|| m_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 (m_supportedMimeTypeSet.contains(codecAlias))
supportedCodecCount++;
} else if (m_supportedMimeTypeSet.contains("video/" + codecLowcase)
|| m_supportedMimeTypeSet.contains("video/x-" + codecLowcase)
|| m_supportedMimeTypeSet.contains("audio/" + codecLowcase)
|| m_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;
return QGstUtils::hasSupport(mimeType, codecs, m_supportedMimeTypeSet);
}
void QGstreamerServicePlugin::updateSupportedMimeTypes() const
void QGstreamerCaptureServicePlugin::updateSupportedMimeTypes() const
{
//enumerate supported mime types
gst_init(NULL, NULL);
@@ -345,7 +238,7 @@ void QGstreamerServicePlugin::updateSupportedMimeTypes() const
gchar *str = gst_value_serialize (value);
QString versions(str);
QStringList elements = versions.split(QRegExp("\\D+"), QString::SkipEmptyParts);
foreach(const QString &e, elements)
foreach (const QString &e, elements)
m_supportedMimeTypeSet.insert(nameLowcase + e);
g_free (str);
}
@@ -372,13 +265,13 @@ void QGstreamerServicePlugin::updateSupportedMimeTypes() const
QStringList list = m_supportedMimeTypeSet.toList();
list.sort();
if (qgetenv("QT_DEBUG_PLUGINS").toInt() > 0) {
foreach(const QString &type, list)
foreach (const QString &type, list)
qDebug() << type;
}
#endif
}
QStringList QGstreamerServicePlugin::supportedMimeTypes() const
QStringList QGstreamerCaptureServicePlugin::supportedMimeTypes() const
{
return QStringList();
}

View File

@@ -40,8 +40,8 @@
****************************************************************************/
#ifndef QGSTREAMERSERVICEPLUGIN_H
#define QGSTREAMERSERVICEPLUGIN_H
#ifndef QGSTREAMERCAPTURESERVICEPLUGIN_H
#define QGSTREAMERCAPTURESERVICEPLUGIN_H
#include <qmediaserviceproviderplugin.h>
#include <QtCore/qset.h>
@@ -49,41 +49,52 @@
QT_BEGIN_NAMESPACE
class QGstreamerServicePlugin
class QGstreamerCaptureServicePlugin
: public QMediaServiceProviderPlugin
#if defined(USE_GSTREAMER_CAMERA)
, public QMediaServiceSupportedDevicesInterface
, public QMediaServiceFeaturesInterface
#endif
, public QMediaServiceSupportedFormatsInterface
{
Q_OBJECT
#if defined(USE_GSTREAMER_CAMERA)
Q_INTERFACES(QMediaServiceSupportedDevicesInterface)
Q_INTERFACES(QMediaServiceFeaturesInterface)
#endif
Q_INTERFACES(QMediaServiceSupportedFormatsInterface)
Q_PLUGIN_METADATA(IID "org.qt-project.qt.mediaserviceproviderfactory/5.0" FILE "gstreamer.json")
#if defined(USE_GSTREAMER_CAMERA)
Q_PLUGIN_METADATA(IID "org.qt-project.qt.mediaserviceproviderfactory/5.0" FILE "mediacapturecamera.json")
#else
Q_PLUGIN_METADATA(IID "org.qt-project.qt.mediaserviceproviderfactory/5.0" FILE "mediacapture.json")
#endif
public:
QMediaService* create(QString const& key);
void release(QMediaService *service);
#if defined(USE_GSTREAMER_CAMERA)
QMediaServiceProviderHint::Features supportedFeatures(const QByteArray &service) const;
QList<QByteArray> devices(const QByteArray &service) const;
QString deviceDescription(const QByteArray &service, const QByteArray &device);
QVariant deviceProperty(const QByteArray &service, const QByteArray &device, const QByteArray &property);
#endif
QtMultimedia::SupportEstimate hasSupport(const QString &mimeType, const QStringList& codecs) const;
QStringList supportedMimeTypes() const;
private:
#if defined(USE_GSTREAMER_CAMERA)
void updateDevices() const;
mutable QList<QByteArray> m_cameraDevices;
mutable QStringList m_cameraDescriptions;
mutable QSet<QString> m_supportedMimeTypeSet; //for fast access
#endif
void updateSupportedMimeTypes() const;
mutable QSet<QString> m_supportedMimeTypeSet; //for fast access
};
QT_END_NAMESPACE
#endif // QGSTREAMERSERVICEPLUGIN_H
#endif // QGSTREAMERCAPTURESERVICEPLUGIN_H

View File

@@ -42,12 +42,12 @@
#include "qgstreamercapturesession.h"
#include "qgstreamerrecordercontrol.h"
#include "qgstreamermediacontainercontrol.h"
#include "qgstreamervideorendererinterface.h"
#include "qgstreameraudioencode.h"
#include "qgstreamervideoencode.h"
#include "qgstreamerimageencode.h"
#include "qgstreameraudioprobecontrol.h"
#include <qmediarecorder.h>
#include <private/qgstreamervideorendererinterface_p.h>
#include <private/qgstreameraudioprobecontrol_p.h>
#include <private/qgstreamerbushelper_p.h>
#include <gst/gsttagsetter.h>

View File

@@ -0,0 +1,3 @@
{
"Keys": ["org.qt-project.qt.mediaplayer"]
}

View File

@@ -1,6 +1,14 @@
INCLUDEPATH += $$PWD
load(qt_module)
DEFINES += QMEDIA_GSTREAMER_PLAYER
TARGET = gstmediaplayer
PLUGIN_TYPE = mediaservice
load(qt_plugin)
DESTDIR = $$QT.multimedia.plugins/$${PLUGIN_TYPE}
include(../common.pri)
INCLUDEPATH += $$PWD
HEADERS += \
$$PWD/qgstreamerplayercontrol.h \
@@ -8,7 +16,8 @@ HEADERS += \
$$PWD/qgstreamerplayersession.h \
$$PWD/qgstreamerstreamscontrol.h \
$$PWD/qgstreamermetadataprovider.h \
$$PWD/qgstreameravailabilitycontrol.h
$$PWD/qgstreameravailabilitycontrol.h \
$$PWD/qgstreamerplayerserviceplugin.h
SOURCES += \
$$PWD/qgstreamerplayercontrol.cpp \
@@ -16,6 +25,12 @@ SOURCES += \
$$PWD/qgstreamerplayersession.cpp \
$$PWD/qgstreamerstreamscontrol.cpp \
$$PWD/qgstreamermetadataprovider.cpp \
$$PWD/qgstreameravailabilitycontrol.cpp
$$PWD/qgstreameravailabilitycontrol.cpp \
$$PWD/qgstreamerplayerserviceplugin.cpp
target.path += $$[QT_INSTALL_PLUGINS]/$${PLUGIN_TYPE}
INSTALLS += target
OTHER_FILES += \
mediaplayer.json

View File

@@ -53,20 +53,20 @@
#include "qgstreameravailabilitycontrol.h"
#if defined(HAVE_WIDGETS)
#include "qgstreamervideooverlay.h"
#include "qgstreamervideowindow.h"
#include "qgstreamervideowidget.h"
#include <private/qgstreamervideooverlay_p.h>
#include <private/qgstreamervideowindow_p.h>
#include <private/qgstreamervideowidget_p.h>
#endif
#include "qgstreamervideorenderer.h"
#include <private/qgstreamervideorenderer_p.h>
#if defined(Q_WS_MAEMO_6) && defined(__arm__)
#include "qgstreamergltexturerenderer.h"
#endif
#include "qgstreamerstreamscontrol.h"
#include "qgstreameraudioprobecontrol.h"
#include "qgstreamervideoprobecontrol.h"
#include <private/qgstreameraudioprobecontrol_p.h>
#include <private/qgstreamervideoprobecontrol_p.h>
#include <private/qmediaplaylistnavigator_p.h>
#include <qmediaplaylist.h>

View File

@@ -0,0 +1,191 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
** This file is part of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
** This file may be used under the terms of the GNU Lesser General Public
** License version 2.1 as published by the Free Software Foundation and
** appearing in the file LICENSE.LGPL included in the packaging of this
** file. Please review the following information to ensure the GNU Lesser
** General Public License version 2.1 requirements will be met:
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Nokia gives you certain additional
** rights. These rights are described in the Nokia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU General
** Public License version 3.0 as published by the Free Software Foundation
** and appearing in the file LICENSE.GPL included in the packaging of this
** file. Please review the following information to ensure the GNU General
** Public License version 3.0 requirements will be met:
** http://www.gnu.org/copyleft/gpl.html.
**
** Other Usage
** Alternatively, this file may be used in accordance with the terms and
** conditions contained in a signed written agreement between you and Nokia.
**
**
**
**
**
**
** $QT_END_LICENSE$
**
****************************************************************************/
#include <QtCore/qstring.h>
#include <QtCore/qdebug.h>
#include <QtCore/QDir>
#include <QtCore/QDebug>
#include "qgstreamerplayerserviceplugin.h"
//#define QT_SUPPORTEDMIMETYPES_DEBUG
#include "qgstreamerplayerservice.h"
#include <private/qgstutils_p.h>
#include <linux/types.h>
#include <sys/time.h>
#include <sys/ioctl.h>
#include <sys/poll.h>
#include <unistd.h>
#include <fcntl.h>
#include <errno.h>
#include <string.h>
#include <stdlib.h>
#include <sys/mman.h>
#include <linux/videodev2.h>
#include <gst/gst.h>
QMediaService* QGstreamerPlayerServicePlugin::create(const QString &key)
{
QGstUtils::initializeGst();
if (key == QLatin1String(Q_MEDIASERVICE_MEDIAPLAYER))
return new QGstreamerPlayerService;
qWarning() << "Gstreamer service plugin: unsupported key:" << key;
return 0;
}
void QGstreamerPlayerServicePlugin::release(QMediaService *service)
{
delete service;
}
QMediaServiceProviderHint::Features QGstreamerPlayerServicePlugin::supportedFeatures(
const QByteArray &service) const
{
if (service == Q_MEDIASERVICE_MEDIAPLAYER)
return QMediaServiceProviderHint::StreamPlayback | QMediaServiceProviderHint::VideoSurface;
else
return QMediaServiceProviderHint::Features();
}
QtMultimedia::SupportEstimate QGstreamerPlayerServicePlugin::hasSupport(const QString &mimeType,
const QStringList &codecs) const
{
if (m_supportedMimeTypeSet.isEmpty())
updateSupportedMimeTypes();
return QGstUtils::hasSupport(mimeType, codecs, m_supportedMimeTypeSet);
}
void QGstreamerPlayerServicePlugin::updateSupportedMimeTypes() const
{
//enumerate supported mime types
gst_init(NULL, NULL);
GList *plugins, *orig_plugins;
orig_plugins = plugins = gst_default_registry_get_plugin_list ();
while (plugins) {
GList *features, *orig_features;
GstPlugin *plugin = (GstPlugin *) (plugins->data);
plugins = g_list_next (plugins);
if (plugin->flags & (1<<1)) //GST_PLUGIN_FLAG_BLACKLISTED
continue;
orig_features = features = gst_registry_get_feature_list_by_plugin(gst_registry_get_default (),
plugin->desc.name);
while (features) {
if (!G_UNLIKELY(features->data == NULL)) {
GstPluginFeature *feature = GST_PLUGIN_FEATURE(features->data);
if (GST_IS_ELEMENT_FACTORY (feature)) {
GstElementFactory *factory = GST_ELEMENT_FACTORY(gst_plugin_feature_load(feature));
if (factory
&& factory->numpadtemplates > 0
&& (qstrcmp(factory->details.klass, "Codec/Decoder/Audio") == 0
|| qstrcmp(factory->details.klass, "Codec/Decoder/Video") == 0
|| qstrcmp(factory->details.klass, "Codec/Demux") == 0 )) {
const GList *pads = factory->staticpadtemplates;
while (pads) {
GstStaticPadTemplate *padtemplate = (GstStaticPadTemplate*)(pads->data);
pads = g_list_next (pads);
if (padtemplate->direction != GST_PAD_SINK)
continue;
if (padtemplate->static_caps.string) {
GstCaps *caps = gst_static_caps_get(&padtemplate->static_caps);
if (!gst_caps_is_any (caps) && ! gst_caps_is_empty (caps)) {
for (guint i = 0; i < gst_caps_get_size(caps); i++) {
GstStructure *structure = gst_caps_get_structure(caps, i);
QString nameLowcase = QString(gst_structure_get_name (structure)).toLower();
m_supportedMimeTypeSet.insert(nameLowcase);
if (nameLowcase.contains("mpeg")) {
//Because mpeg version number is only included in the detail
//description, it is necessary to manually extract this information
//in order to match the mime type of mpeg4.
const GValue *value = gst_structure_get_value(structure, "mpegversion");
if (value) {
gchar *str = gst_value_serialize (value);
QString versions(str);
QStringList elements = versions.split(QRegExp("\\D+"), QString::SkipEmptyParts);
foreach (const QString &e, elements)
m_supportedMimeTypeSet.insert(nameLowcase + e);
g_free (str);
}
}
}
}
}
}
gst_object_unref (factory);
}
} else if (GST_IS_TYPE_FIND_FACTORY(feature)) {
QString name(gst_plugin_feature_get_name(feature));
if (name.contains('/')) //filter out any string without '/' which is obviously not a mime type
m_supportedMimeTypeSet.insert(name.toLower());
}
}
features = g_list_next (features);
}
gst_plugin_feature_list_free (orig_features);
}
gst_plugin_list_free (orig_plugins);
#if defined QT_SUPPORTEDMIMETYPES_DEBUG
QStringList list = m_supportedMimeTypeSet.toList();
list.sort();
if (qgetenv("QT_DEBUG_PLUGINS").toInt() > 0) {
foreach (const QString &type, list)
qDebug() << type;
}
#endif
}
QStringList QGstreamerPlayerServicePlugin::supportedMimeTypes() const
{
return QStringList();
}

View File

@@ -0,0 +1,80 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
** This file is part of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
** This file may be used under the terms of the GNU Lesser General Public
** License version 2.1 as published by the Free Software Foundation and
** appearing in the file LICENSE.LGPL included in the packaging of this
** file. Please review the following information to ensure the GNU Lesser
** General Public License version 2.1 requirements will be met:
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Nokia gives you certain additional
** rights. These rights are described in the Nokia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU General
** Public License version 3.0 as published by the Free Software Foundation
** and appearing in the file LICENSE.GPL included in the packaging of this
** file. Please review the following information to ensure the GNU General
** Public License version 3.0 requirements will be met:
** http://www.gnu.org/copyleft/gpl.html.
**
** Other Usage
** Alternatively, this file may be used in accordance with the terms and
** conditions contained in a signed written agreement between you and Nokia.
**
**
**
**
**
**
** $QT_END_LICENSE$
**
****************************************************************************/
#ifndef QGSTREAMERPLAYERSERVICEPLUGIN_H
#define QGSTREAMERPLAYERSERVICEPLUGIN_H
#include <qmediaserviceproviderplugin.h>
#include <QtCore/qset.h>
#include <QtCore/QObject>
QT_BEGIN_NAMESPACE
class QGstreamerPlayerServicePlugin
: public QMediaServiceProviderPlugin
, public QMediaServiceFeaturesInterface
, public QMediaServiceSupportedFormatsInterface
{
Q_OBJECT
Q_INTERFACES(QMediaServiceFeaturesInterface)
Q_INTERFACES(QMediaServiceSupportedFormatsInterface)
Q_PLUGIN_METADATA(IID "org.qt-project.qt.mediaserviceproviderfactory/5.0" FILE "mediaplayer.json")
public:
QMediaService* create(QString const& key);
void release(QMediaService *service);
QMediaServiceProviderHint::Features supportedFeatures(const QByteArray &service) const;
QtMultimedia::SupportEstimate hasSupport(const QString &mimeType, const QStringList& codecs) const;
QStringList supportedMimeTypes() const;
private:
void updateSupportedMimeTypes() const;
mutable QSet<QString> m_supportedMimeTypeSet; //for fast access
};
QT_END_NAMESPACE
#endif // QGSTREAMERPLAYERSERVICEPLUGIN_H

View File

@@ -42,10 +42,10 @@
#include "qgstreamerplayersession.h"
#include <private/qgstreamerbushelper_p.h>
#include "qgstreameraudioprobecontrol.h"
#include "qgstreamervideoprobecontrol.h"
#include "qgstreamervideorendererinterface.h"
#include "gstvideoconnector.h"
#include <private/qgstreameraudioprobecontrol_p.h>
#include <private/qgstreamervideoprobecontrol_p.h>
#include <private/qgstreamervideorendererinterface_p.h>
#include <private/gstvideoconnector_p.h>
#include <private/qgstutils_p.h>
#include <private/playlistfileparser_p.h>

View File

@@ -52,7 +52,7 @@
#include <qaudioformat.h>
#if defined(HAVE_GST_APPSRC)
#include "qgstappsrc.h"
#include <private/qgstappsrc_p.h>
#endif
#include <gst/gst.h>

View File

@@ -35,6 +35,9 @@ contains(config_test_gstreamer, yes) {
# If widgets is around, plugins depends on widgets too (imports does not)
src_plugins.depends += src_qtmmwidgets
# same with qgsttools
src_qgsttools.depends += src_qtmmwidgets
}
SUBDIRS += src_plugins