]> git.sesse.net Git - mlt/commitdiff
Add qglsl multi consumer (opengl branch).
authorDan Dennedy <dan@dennedy.org>
Thu, 21 Feb 2013 04:29:28 +0000 (20:29 -0800)
committerDan Dennedy <dan@dennedy.org>
Thu, 21 Feb 2013 04:29:28 +0000 (20:29 -0800)
src/modules/qimage/Makefile
src/modules/qimage/configure
src/modules/qimage/consumer_qglsl.cpp [new file with mode: 0644]
src/modules/qimage/factory.c

index be5e1cc64b27c3a7b46948726311ec3c04ff17b2..eedfc6159c7bfce809369ed915595391a7b688cb 100644 (file)
@@ -1,6 +1,6 @@
 CFLAGS += -I../..
 
-LDFLAGS += -L../../framework -lmlt -lpthread -lm
+LDFLAGS += -L../../framework -lmlt -lpthread -lm -L../../mlt++ -lmlt++
 
 include ../../../config.mak
 include config.mak
@@ -9,7 +9,8 @@ TARGET = ../libmltqimage$(LIBSUF)
 
 OBJS = factory.o producer_qimage.o producer_kdenlivetitle.o
 CPPOBJS = qimage_wrapper.o \
-       kdenlivetitle_wrapper.o
+       kdenlivetitle_wrapper.o \
+       consumer_qglsl.o
 
 ifdef GPL3
        CPPOBJS += transition_vqm.o
index 04a93d58fa0a364d6fe1380020d5048ebcf7c233..a9ec7f8170b59d779a50f4dbe1b70ed3a3492c58 100755 (executable)
@@ -104,15 +104,15 @@ else
                        echo "USE_QT4=1" >> config.mak
                        if [ -d "$qimage_libdir/QtGui.framework" ]
                        then
-                               echo QTCXXFLAGS=$(pkg-config --cflags QtCore QtGui QtXml QtSvg ) >> config.mak
-                               echo QTLIBS=$(pkg-config --libs QtCore QtGui QtXml QtSvg) >> config.mak
+                               echo QTCXXFLAGS=$(pkg-config --cflags QtCore QtGui QtXml QtSvg QtOpenGL) >> config.mak
+                               echo QTLIBS=$(pkg-config --libs QtCore QtGui QtXml QtSvg QtOpenGL) >> config.mak
                        elif [ -f "$qimage_libdir/libQtCore4.a" ]
                        then
                                echo QTCXXFLAGS=-I$qimage_includedir >> config.mak
-                               echo QTLIBS=-Wl,-enable-auto-import -L$qimage_libdir -lQtCore4 -lQtGui4 -lQtXml4 -lQtSvg4 >> config.mak
+                               echo QTLIBS=-Wl,-enable-auto-import -L$qimage_libdir -lQtCore4 -lQtGui4 -lQtXml4 -lQtSvg4 -lQtOpenGL4 >> config.mak
                        else
                                echo QTCXXFLAGS=-I$qimage_includedir >> config.mak
-                               echo QTLIBS=-L$qimage_libdir -lQtCore -lQtGui -lQtXml -lQtSvg >> config.mak
+                               echo QTLIBS=-L$qimage_libdir -lQtCore -lQtGui -lQtXml -lQtSvg -lQtOpenGL >> config.mak
                        fi
                else
                    if [ "$without_kde" = "" ] && [ -d "$kde_includedir" ]
@@ -139,8 +139,8 @@ else
                        qt4_found=true
                        echo "#define USE_QT4" >> config.h
                        echo "USE_QT4=1" >> config.mak
-                       echo QTCXXFLAGS=$(pkg-config --cflags QtCore QtGui QtXml QtSvg ) >> config.mak
-                       echo QTLIBS=$(pkg-config --libs QtCore QtGui QtXml QtSvg) >> config.mak
+                       echo QTCXXFLAGS=$(pkg-config --cflags QtCore QtGui QtXml QtSvg QtOpenGL) >> config.mak
+                       echo QTLIBS=$(pkg-config --libs QtCore QtGui QtXml QtSvg QtOpenGL) >> config.mak
                else
                        echo "qimage: QT environment not found - disabling"
                        touch ../disable-qimage
diff --git a/src/modules/qimage/consumer_qglsl.cpp b/src/modules/qimage/consumer_qglsl.cpp
new file mode 100644 (file)
index 0000000..0e62c7d
--- /dev/null
@@ -0,0 +1,77 @@
+/*
+ * consumer_qglsl.cpp
+ * Copyright (C) 2012 Dan Dennedy <dan@dennedy.org>
+ *
+ * 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 library 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 library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+#include <framework/mlt.h>
+#include <QtGui/QApplication>
+#include <QtCore/QLocale>
+#include <QtOpenGL/QGLWidget>
+
+static void onThreadStarted(mlt_properties owner, mlt_consumer consumer)
+{
+       mlt_service service = MLT_CONSUMER_SERVICE(consumer);
+       mlt_properties properties = MLT_CONSUMER_PROPERTIES(consumer);
+       mlt_filter filter = (mlt_filter) mlt_properties_get_data(properties, "glslManager", NULL);
+       mlt_properties filter_properties = MLT_FILTER_PROPERTIES(filter);
+       QApplication* app = qApp;
+
+       mlt_log_verbose(service, "%s\n", __FUNCTION__);
+#ifdef linux
+       if ( getenv("DISPLAY") == 0 ) {
+               mlt_log_error(service, "The qglsl consumer requires a X11 environment.\nPlease either run melt from an X session or use a fake X server like xvfb:\nxvfb-run -a melt (...)\n" );
+       } else
+#endif
+       if (!app) {
+               int argc = 1;
+               char* argv[1];
+               argv[0] = (char*) "MLT qglsl consumer";
+               app = new QApplication(argc, argv);
+               const char *localename = mlt_properties_get_lcnumeric(properties);
+               QLocale::setDefault(QLocale(localename));
+       }
+       QGLWidget* renderContext = new QGLWidget;
+       renderContext->resize(0, 0);
+       renderContext->show();
+       app->processEvents();
+       mlt_events_fire(filter_properties, "init glsl", NULL);
+       if (!mlt_properties_get_int(filter_properties, "glsl_supported")) {
+               mlt_log_fatal(service,
+                       "OpenGL Shading Language rendering is not supported on this machine.\n" );
+               mlt_events_fire(properties, "consumer-fatal-error", NULL);
+       }
+}
+
+extern "C" {
+
+mlt_consumer consumer_qglsl_init( mlt_profile profile, mlt_service_type type, const char *id, char *arg )
+{
+       mlt_consumer consumer = mlt_factory_consumer(profile, "multi", arg);
+       if (consumer) {
+               mlt_filter filter = mlt_factory_filter(profile, "glsl.manager", 0);
+               if (filter) {
+                       mlt_properties properties = MLT_CONSUMER_PROPERTIES(consumer);
+                       mlt_properties_set_data(properties, "glslManager", filter, 0, (mlt_destructor) mlt_filter_close, NULL);
+                       mlt_events_listen(properties, consumer, "consumer-thread-started", (mlt_listener) onThreadStarted);
+                       return consumer;
+               }
+               mlt_consumer_close(consumer);
+       }
+       return NULL;
+}
+
+}
index 6823ae45d83dcebabcfb9ab89f59ce5bfa64b3cf..e11c8b2eee6aae2fdfc8746b87ea4e983922e2eb 100644 (file)
@@ -22,6 +22,7 @@
 #include <limits.h>
 #include <framework/mlt.h>
 
+extern mlt_consumer consumer_qglsl_init( mlt_profile profile, mlt_service_type type, const char *id, char *arg );
 extern mlt_producer producer_qimage_init( mlt_profile profile, mlt_service_type type, const char *id, char *arg );
 extern mlt_producer producer_kdenlivetitle_init( mlt_profile profile, mlt_service_type type, const char *id, char *arg );
 extern mlt_transition transition_vqm_init( mlt_profile profile, mlt_service_type type, const char *id, void *arg );
@@ -35,6 +36,7 @@ static mlt_properties metadata( mlt_service_type type, const char *id, void *dat
 
 MLT_REPOSITORY
 {
+       MLT_REGISTER( consumer_type, "qglsl", consumer_qglsl_init );
        MLT_REGISTER( producer_type, "qimage", producer_qimage_init );
        MLT_REGISTER( producer_type, "kdenlivetitle", producer_kdenlivetitle_init );
        MLT_REGISTER_METADATA( producer_type, "qimage", metadata, "producer_qimage.yml" );