diff options
author | George Kiagiadakis <george.kiagiadakis@collabora.com> | 2012-01-16 01:33:01 +0200 |
---|---|---|
committer | George Kiagiadakis <george.kiagiadakis@collabora.com> | 2012-01-16 01:33:01 +0200 |
commit | 1790311bcf7b53ef2d36f8c72b2875edc66e4b33 (patch) | |
tree | a46b5742018b31821d7306fcebca12236ab44b7f | |
parent | a12aea13b9d4b90ff2f1e84b7f59849cad8c0203 (diff) |
Add a qml plugin that exports GraphicsVideoWidget as a QML item called "VideoItem"
-rw-r--r-- | CMakeLists.txt | 9 | ||||
-rw-r--r-- | src/CMakeLists.txt | 5 | ||||
-rw-r--r-- | src/qml/CMakeLists.txt | 22 | ||||
-rw-r--r-- | src/qml/plugin.cpp | 37 | ||||
-rw-r--r-- | src/qml/qmldir | 1 | ||||
-rw-r--r-- | src/qml/videoitem.cpp | 45 | ||||
-rw-r--r-- | src/qml/videoitem.h | 42 |
7 files changed, 160 insertions, 1 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 8661d39..1ba3d30 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -9,7 +9,8 @@ option(QTGSTREAMER_STATIC "Build QtGStreamer as a static library" OFF) option(QTGSTREAMER_TESTS "Build QtGStreamer's tests" OFF) option(QTGSTREAMER_EXAMPLES "Build QtGStreamer's examples" ON) option(QTGSTREAMER_CODEGEN "Build and use QtGStreamer's codegen" OFF) -option(USE_GST_PLUGIN_DIR "Install plugins together with the other gstreamer plugins" ON) +option(USE_GST_PLUGIN_DIR "Install gstreamer plugins at the system location" ON) +option(USE_QT_PLUGIN_DIR "Install qt plugins at the system location" ON) include(MacroLogFeature) @@ -98,6 +99,12 @@ else() set(PLUGINS_INSTALL_DIR ${LIB_INSTALL_DIR}/gstreamer-0.10) endif() +if (USE_QT_PLUGIN_DIR) + set(IMPORTS_INSTALL_DIR ${QT_IMPORTS_DIR}) +else() + set(IMPORTS_INSTALL_DIR ${LIB_INSTALL_DIR}/qt4/imports) +endif() + if (QTGSTREAMER_CODEGEN AND FLEX_FOUND AND BISON_FOUND) add_subdirectory(codegen) endif() diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index f8d9505..3822449 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -50,6 +50,11 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${QTGSTREAMER_FLAGS}") add_subdirectory(QGlib) add_subdirectory(QGst) +# Build the qml plugin +if (QT_QTDECLARATIVE_FOUND) + add_subdirectory(qml) +endif() + # Install the cmake scripts that are used to find the installed library from external projects install(EXPORT ${EXPORT_TARGET_SET} DESTINATION ${LIB_INSTALL_DIR}/QtGStreamer) install(FILES ${CMAKE_SOURCE_DIR}/cmake/modules/FindQtGStreamer.cmake diff --git a/src/qml/CMakeLists.txt b/src/qml/CMakeLists.txt new file mode 100644 index 0000000..be5ab55 --- /dev/null +++ b/src/qml/CMakeLists.txt @@ -0,0 +1,22 @@ +set(QtGStreamerQML_SRCS + plugin.cpp + videoitem.cpp +) + +include_directories(${CMAKE_CURRENT_BINARY_DIR}) +automoc4_add_library(QtGStreamerQML MODULE ${QtGStreamerQML_SRCS}) +target_link_libraries(QtGStreamerQML + ${QTGSTREAMER_UI_LIBRARIES} + ${QT_QTDECLARATIVE_LIBRARY} +) + +install(TARGETS QtGStreamerQML DESTINATION ${IMPORTS_INSTALL_DIR}/QtGStreamer) +install(FILES qmldir DESTINATION ${IMPORTS_INSTALL_DIR}/QtGStreamer) + +# create a layout similar to the one in ${IMPORTS_INSTALL_DIR} for testing +add_custom_command(TARGET QtGStreamerQML POST_BUILD + COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_CURRENT_BINARY_DIR}/QtGStreamer + COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:QtGStreamerQML> ${CMAKE_CURRENT_BINARY_DIR}/QtGStreamer/ + COMMAND ${CMAKE_COMMAND} -E copy qmldir ${CMAKE_CURRENT_BINARY_DIR}/QtGStreamer/ + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} +) diff --git a/src/qml/plugin.cpp b/src/qml/plugin.cpp new file mode 100644 index 0000000..e6d64e0 --- /dev/null +++ b/src/qml/plugin.cpp @@ -0,0 +1,37 @@ +/* + Copyright (C) 2012 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 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 <QtDeclarative/QDeclarativeExtensionPlugin> + +class QtGStreamerPlugin : public QDeclarativeExtensionPlugin +{ + Q_OBJECT +public: + void registerTypes(const char *uri); +}; + +void QtGStreamerPlugin::registerTypes(const char *uri) +{ + qmlRegisterType<VideoItem>(uri, 0, 10, "VideoItem"); + qmlRegisterUncreatableType<QGst::Ui::GraphicsVideoSurface>(uri, 0, 10, "GraphicsVideoSurface", + QLatin1String("Creating a QGst::Ui::GraphicsVideoSurface from QML is not supported")); +} + +Q_EXPORT_PLUGIN2(qtgstPlugin, QtGStreamerPlugin) + +#include "plugin.moc" diff --git a/src/qml/qmldir b/src/qml/qmldir new file mode 100644 index 0000000..257b19c --- /dev/null +++ b/src/qml/qmldir @@ -0,0 +1 @@ +plugin QtGStreamerQML diff --git a/src/qml/videoitem.cpp b/src/qml/videoitem.cpp new file mode 100644 index 0000000..8e0fd05 --- /dev/null +++ b/src/qml/videoitem.cpp @@ -0,0 +1,45 @@ +/* + Copyright (C) 2012 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 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 "../QGst/Ui/graphicsvideowidget.h" + +VideoItem::VideoItem(QDeclarativeItem *parent) + : QDeclarativeItem(parent) +{ + m_widget = new QGst::Ui::GraphicsVideoWidget(this); +} + +VideoItem::~VideoItem() +{ +} + +QGst::Ui::GraphicsVideoSurface *VideoItem::surface() const +{ + return m_widget->surface(); +} + +void VideoItem::setSurface(QGst::Ui::GraphicsVideoSurface *surface) +{ + m_widget->setSurface(surface); +} + +void VideoItem::geometryChanged(const QRectF& newGeometry, const QRectF& oldGeometry) +{ + m_widget->setGeometry(newGeometry); + QDeclarativeItem::geometryChanged(newGeometry, oldGeometry); +} diff --git a/src/qml/videoitem.h b/src/qml/videoitem.h new file mode 100644 index 0000000..9fb0977 --- /dev/null +++ b/src/qml/videoitem.h @@ -0,0 +1,42 @@ +/* + Copyright (C) 2012 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 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 VIDEOITEM_H +#define VIDEOITEM_H + +#include "../QGst/Ui/graphicsvideosurface.h" +#include <QtDeclarative/QDeclarativeItem> + +class VideoItem : public QDeclarativeItem +{ + Q_OBJECT + Q_PROPERTY(QGst::Ui::GraphicsVideoSurface* surface READ surface WRITE setSurface) +public: + explicit VideoItem(QDeclarativeItem *parent = 0); + virtual ~VideoItem(); + + QGst::Ui::GraphicsVideoSurface *surface() const; + void setSurface(QGst::Ui::GraphicsVideoSurface *surface); + +protected: + virtual void geometryChanged(const QRectF & newGeometry, const QRectF & oldGeometry); + +private: + QGst::Ui::GraphicsVideoWidget *m_widget; +}; + +#endif // VIDEOITEM_H |