diff options
author | George Kiagiadakis <george.kiagiadakis@collabora.com> | 2013-06-07 18:02:26 +0300 |
---|---|---|
committer | George Kiagiadakis <george.kiagiadakis@collabora.com> | 2013-06-09 19:20:26 +0300 |
commit | 9c1df56f4b2d7ac47371e7d6b44885e9e4ea18eb (patch) | |
tree | 924560ec6e77ffd30d2554e444795030eb4f8aee | |
parent | 0f718aebd7805d291c8afa357cef7748e9813adf (diff) |
elements: Rename qtvideosink and its variants in Qt5 to make it parallel installable
* qtvideosink -> qt5videosink
* qtglvideosink -> qt5glvideosink
* qwidgetvideosink -> qwidget5videosink
-rw-r--r-- | CMakeLists.txt | 14 | ||||
-rw-r--r-- | elements/gstqtvideosink/CMakeLists.txt | 16 | ||||
-rw-r--r-- | elements/gstqtvideosink/autotest.cpp | 4 | ||||
-rw-r--r-- | elements/gstqtvideosink/gstqtglvideosinkbase.cpp | 2 | ||||
-rw-r--r-- | elements/gstqtvideosink/gstqtvideosinkplugin.cpp | 10 | ||||
-rw-r--r-- | elements/gstqtvideosink/gstqtvideosinkplugin.h | 21 | ||||
-rw-r--r-- | src/CMakeLists.txt | 6 | ||||
-rw-r--r-- | src/QGst/Ui/graphicsvideosurface.cpp | 4 | ||||
-rw-r--r-- | src/QGst/Ui/graphicsvideosurface.h | 4 | ||||
-rw-r--r-- | src/QGst/Ui/videowidget.cpp | 18 | ||||
-rw-r--r-- | src/QGst/Ui/videowidget.h | 6 | ||||
-rw-r--r-- | tests/manual/CMakeLists.txt | 6 | ||||
-rw-r--r-- | tests/manual/qwidgetvideosinktest.cpp | 2 |
13 files changed, 81 insertions, 32 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 3b701de..7db3650 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -51,6 +51,9 @@ if (${QT_VERSION} STREQUAL "5") set(QTGSTREAMER_UI_LIBRARY Qt5GStreamerUi) set(QTGSTREAMER_UTILS_LIBRARY Qt5GStreamerUtils) set(QTGSTREAMER_PACKAGE_NAME Qt5GStreamer) + set(QTVIDEOSINK_NAME qt5videosink) + set(QTGLVIDEOSINK_NAME qt5glvideosink) + set(QWIDGETVIDEOSINK_NAME qwidget5videosink) elseif (${QT_VERSION} STREQUAL "4") set(USE_QT4 TRUE) set(QTGLIB_LIBRARY QtGLib) @@ -58,6 +61,9 @@ elseif (${QT_VERSION} STREQUAL "4") set(QTGSTREAMER_UI_LIBRARY QtGStreamerUi) set(QTGSTREAMER_UTILS_LIBRARY QtGStreamerUtils) set(QTGSTREAMER_PACKAGE_NAME QtGStreamer) + set(QTVIDEOSINK_NAME qtvideosink) + set(QTGLVIDEOSINK_NAME qtglvideosink) + set(QWIDGETVIDEOSINK_NAME qwidgetvideosink) endif() set(QTGSTREAMER_INCLUDE_DIR ${CMAKE_SOURCE_DIR}/src) include(QtGStreamerConfigCommon) @@ -66,7 +72,7 @@ find_package(GStreamer 0.10.33 COMPONENTS base) macro_log_feature(GSTREAMER_FOUND "GStreamer" "Required to build QtGStreamer" "http://gstreamer.freedesktop.org/" TRUE "0.10.33") macro_log_feature(GSTREAMER_BASE_LIBRARY_FOUND "GStreamer base library" - "Used for building the qwidgetvideosink element" + "Used for building the ${QTVIDEOSINK_NAME} element" "http://gstreamer.freedesktop.org/" FALSE "0.10.33") find_package(GStreamerPluginsBase 0.10.36 COMPONENTS app interfaces video pbutils) @@ -77,7 +83,7 @@ macro_log_feature(GSTREAMER_INTERFACES_LIBRARY_FOUND "GStreamer interfaces libra "Required to build QtGStreamer" "http://gstreamer.freedesktop.org/" TRUE "0.10.33") macro_log_feature(GSTREAMER_VIDEO_LIBRARY_FOUND "GStreamer video library" - "Used for building the qwidgetvideosink element" + "Used for building the ${QTVIDEOSINK_NAME} element" "http://gstreamer.freedesktop.org/" FALSE "0.10.33") macro_log_feature(GSTREAMER_PBUTILS_LIBRARY_FOUND "GStreamer pbutils library" "Used for building the Discoverer API" @@ -91,12 +97,12 @@ macro_log_feature(GOBJECT_FOUND "GObject" "Required to build QtGLib" "http://www find_package(OpenGL) macro_log_feature(OPENGL_FOUND "OpenGL" - "Required for OpenGL rendering support in qtvideosink (desktop only)" + "Required for OpenGL rendering support in ${QTVIDEOSINK_NAME} (desktop only)" "http://www.opengl.org" FALSE) find_package(OpenGLES2) macro_log_feature(OPENGLES2_FOUND "OpenGLES" - "Required for OpenGLES rendering support in qtvideosink (embedded only)" + "Required for OpenGLES rendering support in ${QTVIDEOSINK_NAME} (embedded only)" "http://www.opengl.org" FALSE "2.0") if (QTGSTREAMER_CODEGEN AND CMAKE_CROSSCOMPILING) diff --git a/elements/gstqtvideosink/CMakeLists.txt b/elements/gstqtvideosink/CMakeLists.txt index 1051fea..86b3884 100644 --- a/elements/gstqtvideosink/CMakeLists.txt +++ b/elements/gstqtvideosink/CMakeLists.txt @@ -40,8 +40,14 @@ else() add_definitions(-DGST_QT_VIDEO_SINK_NO_OPENGL) endif() -add_library(gstqtvideosink MODULE ${GstQtVideoSink_SRCS} ${GstQtVideoSink_GL_SRCS}) -target_link_libraries(gstqtvideosink +add_definitions( + -DQTVIDEOSINK_NAME="${QTVIDEOSINK_NAME}" + -DQTGLVIDEOSINK_NAME="${QTGLVIDEOSINK_NAME}" + -DQWIDGETVIDEOSINK_NAME="${QWIDGETVIDEOSINK_NAME}" +) + +add_library(gst${QTVIDEOSINK_NAME} MODULE ${GstQtVideoSink_SRCS} ${GstQtVideoSink_GL_SRCS}) +target_link_libraries(gst${QTVIDEOSINK_NAME} ${GOBJECT_LIBRARIES} ${GSTREAMER_LIBRARY} ${GSTREAMER_BASE_LIBRARY} @@ -49,11 +55,11 @@ target_link_libraries(gstqtvideosink ${GSTREAMER_INTERFACES_LIBRARY} ${GstQtVideoSink_GL_LIBS} ) -qt4or5_use_modules(gstqtvideosink Core Gui Widgets) +qt4or5_use_modules(gst${QTVIDEOSINK_NAME} Core Gui Widgets) if (Qt4or5_OpenGL_FOUND AND (OPENGL_FOUND OR OPENGLES2_FOUND)) - qt4or5_use_modules(gstqtvideosink OpenGL) + qt4or5_use_modules(gst${QTVIDEOSINK_NAME} OpenGL) endif() -install(TARGETS gstqtvideosink DESTINATION ${QTGSTREAMER_GST_PLUGINS_INSTALL_DIR}) +install(TARGETS gst${QTVIDEOSINK_NAME} DESTINATION ${QTGSTREAMER_GST_PLUGINS_INSTALL_DIR}) if (QTGSTREAMER_TESTS) add_executable(qtvideosink_autotest diff --git a/elements/gstqtvideosink/autotest.cpp b/elements/gstqtvideosink/autotest.cpp index 7c3f75b..439601f 100644 --- a/elements/gstqtvideosink/autotest.cpp +++ b/elements/gstqtvideosink/autotest.cpp @@ -759,7 +759,7 @@ void QtVideoSinkTest::qtVideoSinkTest() QVERIFY(w); w->setVideoSink(GST_ELEMENT(g_object_ref(qtvideosink.data()))); } - widget->setWindowTitle("qtvideosink"); + widget->setWindowTitle(QTVIDEOSINK_NAME); widget->resize(widgetSize); widget->show(); widget->raise(); @@ -892,7 +892,7 @@ GstPipeline *QtVideoSinkTest::constructPipeline(GstCaps *caps, MAKE_ELEMENT(tee, "tee"); MAKE_ELEMENT(queue, "queue"); - MAKE_ELEMENT(qtvideosink, context ? "qtglvideosink" : "qtvideosink"); + MAKE_ELEMENT(qtvideosink, context ? QTGLVIDEOSINK_NAME : QTVIDEOSINK_NAME); MAKE_ELEMENT(queue2, "queue"); MAKE_ELEMENT(colorspace, "ffmpegcolorspace"); diff --git a/elements/gstqtvideosink/gstqtglvideosinkbase.cpp b/elements/gstqtvideosink/gstqtglvideosinkbase.cpp index d269c29..1894105 100644 --- a/elements/gstqtvideosink/gstqtglvideosinkbase.cpp +++ b/elements/gstqtvideosink/gstqtglvideosinkbase.cpp @@ -27,7 +27,7 @@ GstQtVideoSinkBaseClass *GstQtGLVideoSinkBase::s_parent_class = 0; //------------------------------ -DEFINE_TYPE_FULL(GstQtGLVideoSinkBase, GST_TYPE_QT_VIDEO_SINK_BASE, init_interfaces) +DEFINE_TYPE_WITH_CODE(GstQtGLVideoSinkBase, GST_TYPE_QT_VIDEO_SINK_BASE, init_interfaces) void GstQtGLVideoSinkBase::init_interfaces(GType type) { diff --git a/elements/gstqtvideosink/gstqtvideosinkplugin.cpp b/elements/gstqtvideosink/gstqtvideosinkplugin.cpp index ccc6a2a..7a804d3 100644 --- a/elements/gstqtvideosink/gstqtvideosinkplugin.cpp +++ b/elements/gstqtvideosink/gstqtvideosinkplugin.cpp @@ -25,16 +25,16 @@ GST_DEBUG_CATEGORY(gst_qt_video_sink_debug); /* entry point to initialize the plug-in */ static gboolean plugin_init(GstPlugin *plugin) { - GST_DEBUG_CATEGORY_INIT(gst_qt_video_sink_debug, "qtvideosink", 0, + GST_DEBUG_CATEGORY_INIT(gst_qt_video_sink_debug, QTVIDEOSINK_NAME, 0, "Debug category for GstQtVideoSink"); - gst_element_register(plugin, "qtvideosink", + gst_element_register(plugin, QTVIDEOSINK_NAME, GST_RANK_NONE, GST_TYPE_QT_VIDEO_SINK); #ifndef GST_QT_VIDEO_SINK_NO_OPENGL - gst_element_register(plugin, "qtglvideosink", + gst_element_register(plugin, QTGLVIDEOSINK_NAME, GST_RANK_NONE, GST_TYPE_QT_GL_VIDEO_SINK); #endif - gst_element_register(plugin, "qwidgetvideosink", + gst_element_register(plugin, QWIDGETVIDEOSINK_NAME, GST_RANK_NONE, GST_TYPE_QWIDGET_VIDEO_SINK); return TRUE; @@ -43,7 +43,7 @@ static gboolean plugin_init(GstPlugin *plugin) GST_PLUGIN_DEFINE ( GST_VERSION_MAJOR, GST_VERSION_MINOR, - "qtvideosink", + QTVIDEOSINK_NAME, "A video sink that can draw on any Qt surface", plugin_init, PACKAGE_VERSION, diff --git a/elements/gstqtvideosink/gstqtvideosinkplugin.h b/elements/gstqtvideosink/gstqtvideosinkplugin.h index 50703da..0f49037 100644 --- a/elements/gstqtvideosink/gstqtvideosinkplugin.h +++ b/elements/gstqtvideosink/gstqtvideosinkplugin.h @@ -24,7 +24,7 @@ GST_DEBUG_CATEGORY_EXTERN(gst_qt_video_sink_debug); #define GST_CAT_DEFAULT gst_qt_video_sink_debug -#define DEFINE_TYPE_FULL(cpp_type, parent_type, additional_initializations) \ +#define DEFINE_TYPE_FULL(cpp_type, type_name, parent_type, additional_initializations) \ GType cpp_type::get_type() \ { \ static volatile gsize gonce_data = 0; \ @@ -32,7 +32,7 @@ GST_DEBUG_CATEGORY_EXTERN(gst_qt_video_sink_debug); GType type; \ type = gst_type_register_static_full( \ parent_type, \ - g_intern_static_string(#cpp_type), \ + g_intern_static_string(type_name), \ sizeof(cpp_type##Class), \ &cpp_type::base_init, \ NULL, /* base_finalize */ \ @@ -50,9 +50,20 @@ GST_DEBUG_CATEGORY_EXTERN(gst_qt_video_sink_debug); return (GType) gonce_data; \ } -#define DEFINE_TYPE(cpp_type, parent_type) \ - DEFINE_TYPE_FULL(cpp_type, parent_type, Q_UNUSED) - +// To allow qt4 and qt5 versions of the plugin to be installed at the same time, +// use a different name for their GType, so that the glib type system can handle +// both plugins being loaded by the gstreamer registry +#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)) +# define DEFINE_TYPE(cpp_type, parent_type) \ + DEFINE_TYPE_FULL(cpp_type, #cpp_type "_qt5", parent_type, Q_UNUSED) +# define DEFINE_TYPE_WITH_CODE(cpp_type, parent_type, additional_initializations) \ + DEFINE_TYPE_FULL(cpp_type, #cpp_type "_qt5", parent_type, additional_initializations) +#else +# define DEFINE_TYPE(cpp_type, parent_type) \ + DEFINE_TYPE_FULL(cpp_type, #cpp_type, parent_type, Q_UNUSED) +# define DEFINE_TYPE_WITH_CODE(cpp_type, parent_type, additional_initializations) \ + DEFINE_TYPE_FULL(cpp_type, #cpp_type, parent_type, additional_initializations) +#endif inline bool qRealIsDouble() { return sizeof(qreal) == sizeof(double); } #define G_TYPE_QREAL qRealIsDouble() ? G_TYPE_DOUBLE : G_TYPE_FLOAT diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 885e526..6a107e8 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -46,6 +46,12 @@ include_directories(${QTGSTREAMER_INCLUDES}) add_definitions(${QTGSTREAMER_DEFINITIONS}) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${QTGSTREAMER_FLAGS}") +add_definitions( + -DQTVIDEOSINK_NAME="${QTVIDEOSINK_NAME}" + -DQTGLVIDEOSINK_NAME="${QTGLVIDEOSINK_NAME}" + -DQWIDGETVIDEOSINK_NAME="${QWIDGETVIDEOSINK_NAME}" +) + # Build the libraries add_subdirectory(QGlib) add_subdirectory(QGst) diff --git a/src/QGst/Ui/graphicsvideosurface.cpp b/src/QGst/Ui/graphicsvideosurface.cpp index c52575f..74b2d97 100644 --- a/src/QGst/Ui/graphicsvideosurface.cpp +++ b/src/QGst/Ui/graphicsvideosurface.cpp @@ -48,7 +48,7 @@ ElementPtr GraphicsVideoSurface::videoSink() const //if the viewport is a QGLWidget, profit from it QGLWidget *glw = qobject_cast<QGLWidget*>(d->view->viewport()); if (glw) { - d->videoSink = QGst::ElementFactory::make("qtglvideosink"); + d->videoSink = QGst::ElementFactory::make(QTGLVIDEOSINK_NAME); if (!d->videoSink.isNull()) { glw->makeCurrent(); @@ -63,7 +63,7 @@ ElementPtr GraphicsVideoSurface::videoSink() const #endif if (d->videoSink.isNull()) { - d->videoSink = QGst::ElementFactory::make("qtvideosink"); + d->videoSink = QGst::ElementFactory::make(QTVIDEOSINK_NAME); if (d->videoSink.isNull()) { qCritical("Failed to create qtvideosink. Make sure it is installed correctly"); diff --git a/src/QGst/Ui/graphicsvideosurface.h b/src/QGst/Ui/graphicsvideosurface.h index 12134c9..534c667 100644 --- a/src/QGst/Ui/graphicsvideosurface.h +++ b/src/QGst/Ui/graphicsvideosurface.h @@ -54,8 +54,8 @@ class GraphicsVideoSurfacePrivate; * \endcode * * This class internally creates and uses either a "qtglvideosink" or a "qtvideosink" - * element. This element is created the first time it is requested and a reference is - * kept internally. + * element ("qt5glvideosink" / "qt5videosink" in Qt5). This element is created the + * first time it is requested and a reference is kept internally. * * To make use of OpenGL hardware acceleration (using qtglvideosink), you need to set * a QGLWidget as the viewport of the QGraphicsView. Note that you must do this before diff --git a/src/QGst/Ui/videowidget.cpp b/src/QGst/Ui/videowidget.cpp index fcdd2e1..75435b5 100644 --- a/src/QGst/Ui/videowidget.cpp +++ b/src/QGst/Ui/videowidget.cpp @@ -288,17 +288,29 @@ AbstractRenderer *AbstractRenderer::create(const ElementPtr & sink, QWidget *vid return r; } - if (QGlib::Type::fromInstance(sink).name() == QLatin1String("GstQtVideoSink")) { + if (QGlib::Type::fromInstance(sink).name() == QLatin1String("GstQtVideoSink" +#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)) + "_qt5" +#endif + )) { return new QtVideoSinkRenderer(sink, videoWidget); } #ifndef QTGSTREAMER_UI_NO_OPENGL - if (QGlib::Type::fromInstance(sink).name() == QLatin1String("GstQtGLVideoSink")) { + if (QGlib::Type::fromInstance(sink).name() == QLatin1String("GstQtGLVideoSink" +# if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)) + "_qt5" +# endif + )) { return new QtGLVideoSinkRenderer(sink, videoWidget); } #endif - if (QGlib::Type::fromInstance(sink).name() == QLatin1String("GstQWidgetVideoSink")) { + if (QGlib::Type::fromInstance(sink).name() == QLatin1String("GstQWidgetVideoSink" +#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)) + "_qt5" +#endif + )) { return new QWidgetVideoSinkRenderer(sink, videoWidget); } diff --git a/src/QGst/Ui/videowidget.h b/src/QGst/Ui/videowidget.h index 76b3c90..ca05f72 100644 --- a/src/QGst/Ui/videowidget.h +++ b/src/QGst/Ui/videowidget.h @@ -41,7 +41,8 @@ class AbstractRenderer; * There are two ways of using this widget: * \li Create a video sink yourself and set it with the setVideoSink() method. * This will work for all sinks that implement the XOverlay interface, plus - * "qtvideosink", "qtglvideosink" and "qwidgetvideosink", which paint directly + * "qtvideosink", "qtglvideosink" and "qwidgetvideosink" (or "qt5videosink", + * "qt5glvideosink" and "qwidget5videosink" in Qt5), which paint directly * on the widget. * \li Create a pipeline and let the widget watch the pipeline using the * watchPipeline() method. This will cause the widget to watch the bus for @@ -80,7 +81,8 @@ public: /*! Sets the video sink element that is going to be embedded. * Any sink that implements the XOverlay interface will work, as well as - * "qtvideosink", "qtglvideosink" and "qwidgetvideosink". + * "qtvideosink", "qtglvideosink" and "qwidgetvideosink" (or "qt5videosink", + * "qt5glvideosink" and "qwidget5videosink" in Qt5) * \note * \li This method \em must be called from Qt's GUI thread. * \li Passing a null ElementPtr has the same effect as calling releaseVideoSink(). diff --git a/tests/manual/CMakeLists.txt b/tests/manual/CMakeLists.txt index b07ced8..ca33d0f 100644 --- a/tests/manual/CMakeLists.txt +++ b/tests/manual/CMakeLists.txt @@ -2,6 +2,12 @@ include_directories(${QTGSTREAMER_INCLUDES}) add_definitions(${QTGSTREAMER_DEFINITIONS}) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${QTGSTREAMER_FLAGS}") +add_definitions( + -DQTVIDEOSINK_NAME="${QTVIDEOSINK_NAME}" + -DQTGLVIDEOSINK_NAME="${QTGLVIDEOSINK_NAME}" + -DQWIDGETVIDEOSINK_NAME="${QWIDGETVIDEOSINK_NAME}" +) + qt4or5_wrap_ui(QWIDGETVIDEOSINKTEST_UI qwidgetvideosinktest.ui) add_executable(qwidgetvideosinktest qwidgetvideosinktest.cpp ${QWIDGETVIDEOSINKTEST_UI}) target_link_libraries(qwidgetvideosinktest ${QTGSTREAMER_LIBRARIES}) diff --git a/tests/manual/qwidgetvideosinktest.cpp b/tests/manual/qwidgetvideosinktest.cpp index f541348..b6b11bf 100644 --- a/tests/manual/qwidgetvideosinktest.cpp +++ b/tests/manual/qwidgetvideosinktest.cpp @@ -57,7 +57,7 @@ QWidgetVideoSinkTest::QWidgetVideoSinkTest(QWidget *parent, Qt::WindowFlags f) m_pipeline = QGst::Pipeline::create(); QGst::ElementPtr src = QGst::ElementFactory::make("videotestsrc"); - m_sink = QGst::ElementFactory::make("qwidgetvideosink"); + m_sink = QGst::ElementFactory::make(QWIDGETVIDEOSINK_NAME); if (!src || !m_sink) { throw std::runtime_error("Unable to initialize the required elements"); |