summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorge Kiagiadakis <george.kiagiadakis@collabora.com>2013-10-21 15:17:13 +0200
committerGeorge Kiagiadakis <george.kiagiadakis@collabora.com>2013-10-28 13:17:27 +0100
commitd272518ef8999970a242d22f225f1f9d016d08d5 (patch)
treee3d428e2b8b38d5c5d48e0be8bc65d7898a03e9d
parentb459cd8d32d70da017cef13528864e77bbf80c72 (diff)
Add a qtquick2 plugin and library with integration API
-rw-r--r--CMakeLists.txt12
-rw-r--r--cmake/modules/QtGStreamerConfigCommon.cmake1
-rw-r--r--src/CMakeLists.txt6
-rw-r--r--src/QGst/CMakeLists.txt29
-rw-r--r--src/QGst/Quick/VideoItem1
-rw-r--r--src/QGst/Quick/VideoSurface1
-rw-r--r--src/QGst/Quick/global.h42
-rw-r--r--src/QGst/Quick/videoitem.cpp118
-rw-r--r--src/QGst/Quick/videoitem.h65
-rw-r--r--src/QGst/Quick/videosurface.cpp70
-rw-r--r--src/QGst/Quick/videosurface.h84
-rw-r--r--src/QGst/Quick/videosurface_p.h37
-rw-r--r--src/qml/CMakeLists.txt30
-rw-r--r--src/qml/quick1/CMakeLists.txt27
-rw-r--r--src/qml/quick1/plugin.cpp (renamed from src/qml/plugin.cpp)0
-rw-r--r--src/qml/quick1/videoitem.cpp (renamed from src/qml/videoitem.cpp)2
-rw-r--r--src/qml/quick1/videoitem.h (renamed from src/qml/videoitem.h)2
-rw-r--r--src/qml/quick2/CMakeLists.txt26
-rw-r--r--src/qml/quick2/QtGStreamerQuick2.json2
-rw-r--r--src/qml/quick2/plugin.cpp40
20 files changed, 561 insertions, 34 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 3cc1b9e..4e64104 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -21,7 +21,7 @@ include(MacroLogFeature)
set(Qt4_MIN_VERSION 4.7)
set(Qt5_MIN_VERSION 5.0.0)
-find_package(Qt4or5 COMPONENTS Core Gui Widgets OPTIONAL_COMPONENTS OpenGL Quick1 Quick2 Test)
+find_package(Qt4or5 COMPONENTS Core Gui Widgets OPTIONAL_COMPONENTS OpenGL Quick1 Quick2 Qml Test)
macro_log_feature(Qt4or5_FOUND "Qt" "Required for building everything"
"http://qt-project.org/" TRUE "${Qt4or5_MIN_VERSION}")
macro_log_feature(Qt4or5_OpenGL_FOUND "QtOpenGL"
@@ -30,9 +30,14 @@ macro_log_feature(Qt4or5_OpenGL_FOUND "QtOpenGL"
macro_log_feature(Qt4or5_Quick1_FOUND "QtQuick1 (QtDeclarative)"
"Required for building QtQuick1 support"
"http://qt-project.org/" FALSE "${Qt4or5_MIN_VERSION}")
-macro_log_feature(Qt4or5_Quick2_FOUND "QtQuick2 (QtQuick)"
+if (${QT_VERSION} STREQUAL "5")
+ macro_log_feature(Qt4or5_Quick2_FOUND "QtQuick2 (QtQuick)"
"Required for building QtQuick2 support"
- "http://qt-project.org/" FALSE "${Qt4or5_MIN_VERSION}")
+ "http://qt-project.org/" TRUE "${Qt4or5_MIN_VERSION}")
+ macro_log_feature(Qt4or5_Qml_FOUND "QtQml"
+ "Required for building QtQuick2 support"
+ "http://qt-project.org/" TRUE "${Qt4or5_MIN_VERSION}")
+endif()
if (QTGSTREAMER_TESTS)
macro_log_feature(Qt4or5_Test_FOUND "QtTest" "Required for building unit tests"
@@ -51,6 +56,7 @@ if (${QT_VERSION} STREQUAL "5")
set(USE_QT5 TRUE)
set(QTGLIB_LIBRARY Qt5GLib)
set(QTGSTREAMER_LIBRARY Qt5GStreamer)
+ set(QTGSTREAMER_QUICK_LIBRARY Qt5GStreamerQuick)
set(QTGSTREAMER_UI_LIBRARY Qt5GStreamerUi)
set(QTGSTREAMER_UTILS_LIBRARY Qt5GStreamerUtils)
set(QTGSTREAMER_PACKAGE_NAME Qt5GStreamer)
diff --git a/cmake/modules/QtGStreamerConfigCommon.cmake b/cmake/modules/QtGStreamerConfigCommon.cmake
index 554dce3..b0dba33 100644
--- a/cmake/modules/QtGStreamerConfigCommon.cmake
+++ b/cmake/modules/QtGStreamerConfigCommon.cmake
@@ -6,6 +6,7 @@ set(QTGSTREAMER_INCLUDES ${QTGSTREAMER_INCLUDE_DIR} ${Boost_INCLUDE_DIRS})
set(QTGSTREAMER_DEFINITIONS "-DQT_NO_KEYWORDS")
if (${QTGSTREAMER_LIBRARY} MATCHES ".*Qt5GStreamer.*")
+ set(QTGSTREAMER_QUICK_LIBRARIES ${QTGSTREAMER_QUICK_LIBRARY})
set(QTGSTREAMER_INCLUDES ${QTGSTREAMER_INCLUDES} ${Qt5Core_INCLUDE_DIRS})
else()
set(QTGSTREAMER_INCLUDES ${QTGSTREAMER_INCLUDES} ${QT_INCLUDE_DIR})
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 6a107e8..1d5f516 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -56,10 +56,8 @@ add_definitions(
add_subdirectory(QGlib)
add_subdirectory(QGst)
-# Build the QtQuick1 plugin
-if (Qt4or5_Quick1_FOUND)
- add_subdirectory(qml)
-endif()
+# Build the qml plugins
+add_subdirectory(qml)
# Install the cmake scripts that are used to find the installed library from external projects
include(CMakePackageConfigHelpers)
diff --git a/src/QGst/CMakeLists.txt b/src/QGst/CMakeLists.txt
index 186b256..00cc20b 100644
--- a/src/QGst/CMakeLists.txt
+++ b/src/QGst/CMakeLists.txt
@@ -34,6 +34,11 @@ set(QtGStreamer_SRCS
${CMAKE_CURRENT_BINARY_DIR}/gen.cpp
)
+set(QtGStreamerQuick_SRCS
+ Quick/videosurface.cpp
+ Quick/videoitem.cpp
+)
+
set(QtGStreamerUi_SRCS
Ui/videowidget.cpp
Ui/graphicsvideosurface.cpp
@@ -95,6 +100,15 @@ set(QtGStreamer_INSTALLED_HEADERS
Utils/applicationsource.h Utils/ApplicationSource
)
+if (Qt4or5_Quick2_FOUND)
+ set(QtGStreamer_INSTALLED_HEADERS
+ ${QtGStreamer_INSTALLED_HEADERS}
+ Quick/global.h
+ Quick/videosurface.h Quick/VideoSurface
+ Quick/videoitem.h Quick/VideoItem
+ )
+endif()
+
file(GLOB QtGStreamer_CODEGEN_HEADERS RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}" "*.h")
list(REMOVE_ITEM QtGStreamer_CODEGEN_HEADERS "global.h")
@@ -116,6 +130,7 @@ set(QtGStreamer_CODEGEN_INCLUDES
# Setup the environment
set(QTGSTREAMER_API_VERSION 0.10)
set(QTGSTREAMER_SOVERSION 0)
+set(QTGSTREAMER_QUICK_SOVERSION 0)
set(QTGSTREAMER_UI_SOVERSION 0)
set(QTGSTREAMER_UTILS_SOVERSION 0)
include_directories(
@@ -152,6 +167,17 @@ target_link_libraries(${QTGSTREAMER_LIBRARY} LINK_PRIVATE ${GOBJECT_LIBRARIES}
${GSTREAMER_PBUTILS_LIBRARY})
qt4or5_use_modules(${QTGSTREAMER_LIBRARY} LINK_PUBLIC Core)
+# Build and link QtGStreamerQuick
+if (Qt4or5_Quick2_FOUND)
+ add_library(${QTGSTREAMER_QUICK_LIBRARY} ${SHARED_OR_STATIC} ${QtGStreamerQuick_SRCS})
+ set_target_properties(${QTGSTREAMER_QUICK_LIBRARY} PROPERTIES OUTPUT_NAME ${QTGSTREAMER_QUICK_LIBRARY}-${QTGSTREAMER_API_VERSION}
+ SOVERSION ${QTGSTREAMER_QUICK_SOVERSION}
+ VERSION ${QTGSTREAMER_VERSION})
+ target_link_libraries(${QTGSTREAMER_QUICK_LIBRARY} LINK_PUBLIC ${QTGSTREAMER_LIBRARY})
+ qt4or5_use_modules(${QTGSTREAMER_QUICK_LIBRARY} LINK_PUBLIC Quick2)
+ qt4or5_use_modules(${QTGSTREAMER_QUICK_LIBRARY} LINK_PRIVATE Core)
+endif()
+
# Build and link QtGStreamerUi
add_library(${QTGSTREAMER_UI_LIBRARY} ${SHARED_OR_STATIC} ${QtGStreamerUi_SRCS})
set_target_properties(${QTGSTREAMER_UI_LIBRARY} PROPERTIES OUTPUT_NAME ${QTGSTREAMER_UI_LIBRARY}-${QTGSTREAMER_API_VERSION}
@@ -175,6 +201,9 @@ qt4or5_use_modules(${QTGSTREAMER_UTILS_LIBRARY} LINK_PRIVATE Core)
# Install
install(TARGETS ${QTGSTREAMER_LIBRARY} EXPORT ${EXPORT_TARGET_SET} ${QTGSTREAMER_INSTALL_TARGET_DEFAULT_ARGS})
+if (Qt4or5_Quick2_FOUND)
+ install(TARGETS ${QTGSTREAMER_QUICK_LIBRARY} EXPORT ${EXPORT_TARGET_SET} ${QTGSTREAMER_INSTALL_TARGET_DEFAULT_ARGS})
+endif()
install(TARGETS ${QTGSTREAMER_UI_LIBRARY} EXPORT ${EXPORT_TARGET_SET} ${QTGSTREAMER_INSTALL_TARGET_DEFAULT_ARGS})
install(TARGETS ${QTGSTREAMER_UTILS_LIBRARY} EXPORT ${EXPORT_TARGET_SET} ${QTGSTREAMER_INSTALL_TARGET_DEFAULT_ARGS})
install_headers("QGst" ${QtGStreamer_INSTALLED_HEADERS})
diff --git a/src/QGst/Quick/VideoItem b/src/QGst/Quick/VideoItem
new file mode 100644
index 0000000..8082d8d
--- /dev/null
+++ b/src/QGst/Quick/VideoItem
@@ -0,0 +1 @@
+#include "videoitem.h" \ No newline at end of file
diff --git a/src/QGst/Quick/VideoSurface b/src/QGst/Quick/VideoSurface
new file mode 100644
index 0000000..ebfe51f
--- /dev/null
+++ b/src/QGst/Quick/VideoSurface
@@ -0,0 +1 @@
+#include "videosurface.h"
diff --git a/src/QGst/Quick/global.h b/src/QGst/Quick/global.h
new file mode 100644
index 0000000..132804e
--- /dev/null
+++ b/src/QGst/Quick/global.h
@@ -0,0 +1,42 @@
+/*
+ Copyright (C) 2011-2013 Collabora Ltd.
+ @author George Kiagiadakis <george.kiagiadakis@collabora.co.uk>
+
+ This library is free software; you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as published
+ by the Free Software Foundation; either version 2.1 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+#ifndef QTGSTREAMERQUICK_EXPORT_H
+#define QTGSTREAMERQUICK_EXPORT_H
+
+// workaround for https://bugreports.qt-project.org/browse/QTBUG-22829
+#if defined(Q_MOC_RUN) && !defined(BOOST_TT_HAS_OPERATOR_HPP_INCLUDED)
+#define BOOST_TT_HAS_OPERATOR_HPP_INCLUDED
+#endif
+
+#include <QtCore/QtGlobal>
+
+/* defined by cmake when building this library */
+#if defined(QtGStreamerQuick_EXPORTS) || defined(Qt5GStreamerQuick_EXPORTS)
+# define QTGSTREAMERQUICK_EXPORT Q_DECL_EXPORT
+#else
+# define QTGSTREAMERQUICK_EXPORT Q_DECL_IMPORT
+#endif
+
+#if !defined(Q_OS_WIN) && !defined(Q_CC_NOKIAX86) && \
+ !defined(Q_CC_RVCT) && defined(QT_VISIBILITY_AVAILABLE)
+# define QTGSTREAMERQUICK_NO_EXPORT __attribute__((visibility("hidden")))
+#else
+# define QTGSTREAMERQUICK_NO_EXPORT
+#endif
+
+#endif
diff --git a/src/QGst/Quick/videoitem.cpp b/src/QGst/Quick/videoitem.cpp
new file mode 100644
index 0000000..f03de4f
--- /dev/null
+++ b/src/QGst/Quick/videoitem.cpp
@@ -0,0 +1,118 @@
+/*
+ Copyright (C) 2012-2013 Collabora Ltd. <info@collabora.com>
+ @author George Kiagiadakis <george.kiagiadakis@collabora.com>
+
+ This library is free software; you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as published
+ by the Free Software Foundation; either version 2.1 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#include "videoitem.h"
+#include "videosurface_p.h"
+#include <QtQuick/QSGNode>
+#include <QtQuick/QSGFlatColorMaterial>
+#include "../../QGlib/Signal"
+
+namespace QGst {
+namespace Quick {
+
+struct VideoItem::Private
+{
+ QPointer<VideoSurface> surface;
+ bool surfaceDirty;
+ QRectF targetArea;
+};
+
+VideoItem::VideoItem(QQuickItem *parent)
+ : QQuickItem(parent), d(new Private)
+{
+ d->surfaceDirty = true;
+ setFlag(QQuickItem::ItemHasContents, true);
+}
+
+VideoItem::~VideoItem()
+{
+ setSurface(0);
+ delete d;
+}
+
+VideoSurface *VideoItem::surface() const
+{
+ return d->surface.data();
+}
+
+void VideoItem::setSurface(VideoSurface *surface)
+{
+ if (d->surface) {
+ d->surface.data()->d->items.remove(this);
+ }
+
+ d->surface = surface;
+ d->surfaceDirty = true;
+
+ if (d->surface) {
+ d->surface.data()->d->items.insert(this);
+ }
+}
+
+QSGNode* VideoItem::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *data)
+{
+ Q_UNUSED(data)
+
+ QRectF r = boundingRect();
+ QSGNode *newNode = 0;
+
+ if (d->surfaceDirty) {
+ delete oldNode;
+ oldNode = 0;
+ d->surfaceDirty = false;
+ }
+
+ if (!d->surface || d->surface.data()->d->videoSink.isNull()) {
+ if (!oldNode) {
+ QSGFlatColorMaterial *material = new QSGFlatColorMaterial;
+ material->setColor(Qt::black);
+
+ QSGGeometryNode *node = new QSGGeometryNode;
+ node->setMaterial(material);
+ node->setFlag(QSGNode::OwnsMaterial);
+ node->setFlag(QSGNode::OwnsGeometry);
+
+ newNode = node;
+ d->targetArea = QRectF(); //force geometry to be set
+ } else {
+ newNode = oldNode;
+ }
+
+ if (r != d->targetArea) {
+ QSGGeometry *geometry = new QSGGeometry(QSGGeometry::defaultAttributes_Point2D(), 4);
+ geometry->vertexDataAsPoint2D()[0].set(r.x(), r.y());
+ geometry->vertexDataAsPoint2D()[1].set(r.x(), r.height());
+ geometry->vertexDataAsPoint2D()[2].set(r.width(), r.y());
+ geometry->vertexDataAsPoint2D()[3].set(r.width(), r.height());
+
+ QSGGeometryNode *node = static_cast<QSGGeometryNode*>(newNode);
+ node->setGeometry(geometry);
+
+ d->targetArea = r;
+ }
+ } else {
+ newNode = (QSGNode*) QGlib::emit<void*>(d->surface.data()->d->videoSink,
+ "update-node", (void*)oldNode,
+ r.x(), r.y(), r.width(), r.height());
+ }
+
+ return newNode;
+}
+
+} // namespace Quick
+} // namespace QGst
diff --git a/src/QGst/Quick/videoitem.h b/src/QGst/Quick/videoitem.h
new file mode 100644
index 0000000..be408d2
--- /dev/null
+++ b/src/QGst/Quick/videoitem.h
@@ -0,0 +1,65 @@
+/*
+ Copyright (C) 2012-2013 Collabora Ltd. <info@collabora.com>
+ @author George Kiagiadakis <george.kiagiadakis@collabora.com>
+
+ This library is free software; you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as published
+ by the Free Software Foundation; either version 2.1 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#ifndef QGST_QUICK_VIDEOITEM_H
+#define QGST_QUICK_VIDEOITEM_H
+
+#include "videosurface.h"
+#include <QtQuick/QQuickItem>
+#include <QtCore/QPointer>
+
+namespace QGst {
+namespace Quick {
+
+/*! \headerfile videoitem.h <QGst/Quick/VideoItem>
+ * \brief A QQuickItem for displaying video
+ *
+ * This is a QQuickItem subclass that can display video. To use it,
+ * you have to create a VideoSurface and connect it with this
+ * item using the setSurface() method or the surface property.
+ * See the VideoSurface documentation for details and examples.
+ *
+ * \sa VideoSurface
+ */
+class QTGSTREAMERQUICK_EXPORT VideoItem : public QQuickItem
+{
+ Q_OBJECT
+ Q_DISABLE_COPY(VideoItem)
+ Q_PROPERTY(QGst::Quick::VideoSurface* surface READ surface WRITE setSurface)
+
+public:
+ explicit VideoItem(QQuickItem *parent = 0);
+ virtual ~VideoItem();
+
+ VideoSurface *surface() const;
+ void setSurface(VideoSurface *surface);
+
+protected:
+ /*! Reimplemented from QQuickItem. */
+ virtual QSGNode* updatePaintNode(QSGNode *oldNode,
+ UpdatePaintNodeData *updatePaintNodeData);
+
+private:
+ struct Private;
+ Private *const d;
+};
+
+} // namespace Quick
+} // namespace QGst
+
+#endif // QGST_QUICK_VIDEOITEM_H
diff --git a/src/QGst/Quick/videosurface.cpp b/src/QGst/Quick/videosurface.cpp
new file mode 100644
index 0000000..c99e578
--- /dev/null
+++ b/src/QGst/Quick/videosurface.cpp
@@ -0,0 +1,70 @@
+/*
+ Copyright (C) 2012-2013 Collabora Ltd. <info@collabora.com>
+ @author George Kiagiadakis <george.kiagiadakis@collabora.com>
+
+ This library is free software; you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as published
+ by the Free Software Foundation; either version 2.1 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+#include "videosurface_p.h"
+
+#include "../elementfactory.h"
+#include "../../QGlib/connect.h"
+
+#include <QtCore/QDebug>
+#include <QtQuick/QQuickItem>
+
+namespace QGst {
+namespace Quick {
+
+VideoSurface::VideoSurface(QObject *parent)
+ : QObject(parent), d(new VideoSurfacePrivate)
+{
+}
+
+VideoSurface::~VideoSurface()
+{
+ if (!d->videoSink.isNull()) {
+ d->videoSink->setState(QGst::StateNull);
+ }
+
+ delete d;
+}
+
+ElementPtr VideoSurface::videoSink() const
+{
+ if (d->videoSink.isNull()) {
+ d->videoSink = QGst::ElementFactory::make("qtquick2videosink");
+
+ if (d->videoSink.isNull()) {
+ qCritical("Failed to create qtquick2videosink. Make sure it is installed correctly");
+ return ElementPtr();
+ }
+
+ QGlib::connect(d->videoSink, "update",
+ const_cast<VideoSurface*>(this),
+ &VideoSurface::onUpdate);
+
+ }
+
+ return d->videoSink;
+}
+
+void VideoSurface::onUpdate()
+{
+ Q_FOREACH(QQuickItem *item, d->items) {
+ item->update();
+ }
+}
+
+} // namespace Quick
+} // namespace QGst
diff --git a/src/QGst/Quick/videosurface.h b/src/QGst/Quick/videosurface.h
new file mode 100644
index 0000000..8048e65
--- /dev/null
+++ b/src/QGst/Quick/videosurface.h
@@ -0,0 +1,84 @@
+/*
+ Copyright (C) 2012-2013 Collabora Ltd. <info@collabora.com>
+ @author George Kiagiadakis <george.kiagiadakis@collabora.com>
+
+ This library is free software; you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as published
+ by the Free Software Foundation; either version 2.1 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+#ifndef QGST_QUICK_VIDEOSURFACE_H
+#define QGST_QUICK_VIDEOSURFACE_H
+
+#include "global.h"
+#include "../element.h"
+#include <QtCore/QObject>
+
+namespace QGst {
+namespace Quick {
+
+class VideoSurfacePrivate;
+
+/*! \headerfile videosurface.h <QGst/Quick/VideoSurface>
+ * \brief Helper class for painting video on a QtQuick2 VideoItem
+ *
+ * This is a helper class that represents a video surface on a QQuickView.
+ * To use it, create a VideoItem from QML and connect it with this surface.
+ *
+ * Example:
+ * \code
+ * // in your C++ code
+ * QQuickView *view = new QQuickView;
+ * ...
+ * QGst::Quick::VideoSurface *surface = new QGst::Quick::VideoSurface;
+ * view->rootContext()->setContextProperty(QLatin1String("videoSurface"), surface);
+ * ...
+ * // and in your qml file:
+ * import QtGStreamer 0.10
+ * ...
+ * VideoItem {
+ * id: video
+ * width: 320
+ * height: 240
+ * surface: videoSurface
+ * }
+ * \endcode
+ *
+ * \sa VideoItem
+ */
+class QTGSTREAMERQUICK_EXPORT VideoSurface : public QObject
+{
+ Q_OBJECT
+ Q_DISABLE_COPY(VideoSurface)
+public:
+ explicit VideoSurface(QObject *parent = 0);
+ virtual ~VideoSurface();
+
+ /*! Returns the video sink element that provides this surface's image.
+ * The element will be constructed the first time that this function
+ * is called. The surface will always keep a reference to this element.
+ */
+ ElementPtr videoSink() const;
+
+protected:
+ QTGSTREAMERQUICK_NO_EXPORT void onUpdate();
+
+private:
+ friend class VideoItem;
+ VideoSurfacePrivate * const d;
+};
+
+} // namespace Quick
+} // namespace QGst
+
+Q_DECLARE_METATYPE(QGst::Quick::VideoSurface*)
+
+#endif // QGST_QUICK_VIDEOSURFACE_H
diff --git a/src/QGst/Quick/videosurface_p.h b/src/QGst/Quick/videosurface_p.h
new file mode 100644
index 0000000..6f74bce
--- /dev/null
+++ b/src/QGst/Quick/videosurface_p.h
@@ -0,0 +1,37 @@
+/*
+ Copyright (C) 2012-2013 Collabora Ltd. <info@collabora.com>
+ @author George Kiagiadakis <george.kiagiadakis@collabora.com>
+
+ This library is free software; you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as published
+ by the Free Software Foundation; either version 2.1 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+#ifndef QGST_QUICK_VIDEOSURFACE_P_H
+#define QGST_QUICK_VIDEOSURFACE_P_H
+
+#include "videosurface.h"
+#include "videoitem.h"
+
+namespace QGst {
+namespace Quick {
+
+class QTGSTREAMERQUICK_NO_EXPORT VideoSurfacePrivate
+{
+public:
+ QSet<VideoItem*> items;
+ ElementPtr videoSink;
+};
+
+} // namespace Quick
+} // namespace QGst
+
+#endif // QGST_QUICK_VIDEOSURFACE_P_H
diff --git a/src/qml/CMakeLists.txt b/src/qml/CMakeLists.txt
index 53ded96..179abba 100644
--- a/src/qml/CMakeLists.txt
+++ b/src/qml/CMakeLists.txt
@@ -1,27 +1,7 @@
-set(QtGStreamerQuick1_SRCS
- plugin.cpp
- videoitem.cpp
-)
-
-add_library(QtGStreamerQuick1 MODULE ${QtGStreamerQuick1_SRCS})
-target_link_libraries(QtGStreamerQuick1 ${QTGSTREAMER_UI_LIBRARIES})
-qt4or5_use_modules(QtGStreamerQuick1 Quick1)
-
-if (WIN32 AND CMAKE_COMPILER_IS_GNUCXX)
- # On windows with gcc, cmake calls the binary libFOO.dll, but the Qt plugin loader
- # does not remove the lib prefix when searching for .dlls, unlike what happens on unix
- file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/qmldir "plugin libQtGStreamerQuick1")
-else()
- file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/qmldir "plugin QtGStreamerQuick1")
+if (Qt4or5_Quick1_FOUND)
+ add_subdirectory(quick1)
endif()
-install(TARGETS QtGStreamerQuick1 DESTINATION ${QTGSTREAMER_QTQUICK1_INSTALL_DIR}/QtGStreamer)
-install(FILES ${CMAKE_CURRENT_BINARY_DIR}/qmldir DESTINATION ${QTGSTREAMER_QTQUICK1_INSTALL_DIR}/QtGStreamer)
-
-# create a layout similar to the one in ${QTGSTREAMER_QTQUICK1_INSTALL_DIR} for testing
-add_custom_command(TARGET QtGStreamerQuick1 POST_BUILD
- COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_CURRENT_BINARY_DIR}/QtGStreamer
- COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:QtGStreamerQuick1> ${CMAKE_CURRENT_BINARY_DIR}/QtGStreamer/
- COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_BINARY_DIR}/qmldir ${CMAKE_CURRENT_BINARY_DIR}/QtGStreamer/
- WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
-)
+if (Qt4or5_Quick2_FOUND)
+ add_subdirectory(quick2)
+endif()
diff --git a/src/qml/quick1/CMakeLists.txt b/src/qml/quick1/CMakeLists.txt
new file mode 100644
index 0000000..53ded96
--- /dev/null
+++ b/src/qml/quick1/CMakeLists.txt
@@ -0,0 +1,27 @@
+set(QtGStreamerQuick1_SRCS
+ plugin.cpp
+ videoitem.cpp
+)
+
+add_library(QtGStreamerQuick1 MODULE ${QtGStreamerQuick1_SRCS})
+target_link_libraries(QtGStreamerQuick1 ${QTGSTREAMER_UI_LIBRARIES})
+qt4or5_use_modules(QtGStreamerQuick1 Quick1)
+
+if (WIN32 AND CMAKE_COMPILER_IS_GNUCXX)
+ # On windows with gcc, cmake calls the binary libFOO.dll, but the Qt plugin loader
+ # does not remove the lib prefix when searching for .dlls, unlike what happens on unix
+ file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/qmldir "plugin libQtGStreamerQuick1")
+else()
+ file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/qmldir "plugin QtGStreamerQuick1")
+endif()
+
+install(TARGETS QtGStreamerQuick1 DESTINATION ${QTGSTREAMER_QTQUICK1_INSTALL_DIR}/QtGStreamer)
+install(FILES ${CMAKE_CURRENT_BINARY_DIR}/qmldir DESTINATION ${QTGSTREAMER_QTQUICK1_INSTALL_DIR}/QtGStreamer)
+
+# create a layout similar to the one in ${QTGSTREAMER_QTQUICK1_INSTALL_DIR} for testing
+add_custom_command(TARGET QtGStreamerQuick1 POST_BUILD
+ COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_CURRENT_BINARY_DIR}/QtGStreamer
+ COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:QtGStreamerQuick1> ${CMAKE_CURRENT_BINARY_DIR}/QtGStreamer/
+ COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_BINARY_DIR}/qmldir ${CMAKE_CURRENT_BINARY_DIR}/QtGStreamer/
+ WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
+)
diff --git a/src/qml/plugin.cpp b/src/qml/quick1/plugin.cpp
index abb01bd..abb01bd 100644
--- a/src/qml/plugin.cpp
+++ b/src/qml/quick1/plugin.cpp
diff --git a/src/qml/videoitem.cpp b/src/qml/quick1/videoitem.cpp
index ce12c02..3a20d2f 100644
--- a/src/qml/videoitem.cpp
+++ b/src/qml/quick1/videoitem.cpp
@@ -16,7 +16,7 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "videoitem.h"
-#include "../QGst/Ui/graphicsvideowidget.h"
+#include "../../QGst/Ui/graphicsvideowidget.h"
VideoItem::VideoItem(QDeclarativeItem *parent)
: QDeclarativeItem(parent)
diff --git a/src/qml/videoitem.h b/src/qml/quick1/videoitem.h
index 32c7ee7..b5bb84b 100644
--- a/src/qml/videoitem.h
+++ b/src/qml/quick1/videoitem.h
@@ -18,7 +18,7 @@
#ifndef VIDEOITEM_H
#define VIDEOITEM_H
-#include "../QGst/Ui/graphicsvideosurface.h"
+#include "../../QGst/Ui/graphicsvideosurface.h"
#include <QtDeclarative/QDeclarativeItem>
class VideoItem : public QDeclarativeItem
diff --git a/src/qml/quick2/CMakeLists.txt b/src/qml/quick2/CMakeLists.txt
new file mode 100644
index 0000000..9ab4b70
--- /dev/null
+++ b/src/qml/quick2/CMakeLists.txt
@@ -0,0 +1,26 @@
+set(QtGStreamerQuick2_SRCS
+ plugin.cpp
+)
+
+add_library(QtGStreamerQuick2 MODULE ${QtGStreamerQuick2_SRCS})
+target_link_libraries(QtGStreamerQuick2 ${QTGSTREAMER_QUICK_LIBRARIES})
+qt4or5_use_modules(QtGStreamerQuick2 Qml)
+
+if (WIN32 AND CMAKE_COMPILER_IS_GNUCXX)
+ # On windows with gcc, cmake calls the binary libFOO.dll, but the Qt plugin loader
+ # does not remove the lib prefix when searching for .dlls, unlike what happens on unix
+ file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/qmldir "module QtGStreamer\nplugin libQtGStreamerQuick2")
+else()
+ file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/qmldir "module QtGStreamer\nplugin QtGStreamerQuick2")
+endif()
+
+install(TARGETS QtGStreamerQuick2 DESTINATION ${QTGSTREAMER_QTQUICK2_INSTALL_DIR}/QtGStreamer/)
+install(FILES ${CMAKE_CURRENT_BINARY_DIR}/qmldir DESTINATION ${QTGSTREAMER_QTQUICK2_INSTALL_DIR}/QtGStreamer/)
+
+# create a layout similar to the one in ${QTGSTREAMER_QTQUICK2_INSTALL_DIR} for testing
+add_custom_command(TARGET QtGStreamerQuick2 POST_BUILD
+ COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_CURRENT_BINARY_DIR}/QtGStreamer
+ COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:QtGStreamerQuick2> ${CMAKE_CURRENT_BINARY_DIR}/QtGStreamer/
+ COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_BINARY_DIR}/qmldir ${CMAKE_CURRENT_BINARY_DIR}/QtGStreamer/
+ WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
+)
diff --git a/src/qml/quick2/QtGStreamerQuick2.json b/src/qml/quick2/QtGStreamerQuick2.json
new file mode 100644
index 0000000..311847d
--- /dev/null
+++ b/src/qml/quick2/QtGStreamerQuick2.json
@@ -0,0 +1,2 @@
+{}
+
diff --git a/src/qml/quick2/plugin.cpp b/src/qml/quick2/plugin.cpp
new file mode 100644
index 0000000..59fc0d9
--- /dev/null
+++ b/src/qml/quick2/plugin.cpp
@@ -0,0 +1,40 @@
+/*
+ Copyright (C) 2013 basysKom GmbH <info@basyskom.com>
+ @author Benjamin Federau <benjamin.federau@basyskom.com>
+
+ This library is free software; you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as published
+ by the Free Software Foundation; either version 2.1 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#include "../../QGst/Quick/videoitem.h"
+#include "../../QGst/Quick/videosurface.h"
+#include <QtQml/QQmlExtensionPlugin>
+
+class QtGStreamerPlugin : public QQmlExtensionPlugin
+{
+ Q_OBJECT
+ Q_PLUGIN_METADATA(IID "org.freedesktop.gstreamer.QtGStreamerQuick2-0.10"
+ FILE "QtGStreamerQuick2.json")
+public:
+ virtual void registerTypes(const char *uri);
+};
+
+void QtGStreamerPlugin::registerTypes(const char *uri)
+{
+ // @uri org.freedesktop.gstreamer.QtGStreamerQuick2-0.10
+ qmlRegisterType<QGst::Quick::VideoItem>(uri, 0, 10, "VideoItem");
+ qmlRegisterUncreatableType<QGst::Quick::VideoSurface>(uri, 0, 10, "VideoSurface",
+ QLatin1String("Creating a QGst::Quick::VideoSurface from QML is not supported"));
+}
+
+#include "plugin.moc"