summaryrefslogtreecommitdiff
path: root/tests/examples/overlay/qt-xoverlay.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/examples/overlay/qt-xoverlay.cpp')
-rw-r--r--tests/examples/overlay/qt-xoverlay.cpp78
1 files changed, 78 insertions, 0 deletions
diff --git a/tests/examples/overlay/qt-xoverlay.cpp b/tests/examples/overlay/qt-xoverlay.cpp
new file mode 100644
index 00000000..a1ba7c37
--- /dev/null
+++ b/tests/examples/overlay/qt-xoverlay.cpp
@@ -0,0 +1,78 @@
+/* GStreamer
+ * Copyright (C) <2010> Stefan Kost <ensonic@users.sf.net>
+ *
+ * qt-xoverlay: demonstrate overlay handling using qt
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 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
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library 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.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <glib.h>
+#include <gst/gst.h>
+#include <gst/interfaces/xoverlay.h>
+
+#include <QApplication>
+#include <QTimer>
+#include <QWidget>
+
+int main(int argc, char *argv[])
+{
+ if (!g_thread_supported ())
+ g_thread_init (NULL);
+
+ gst_init (&argc, &argv);
+ QApplication app(argc, argv);
+ app.connect(&app, SIGNAL(lastWindowClosed()), &app, SLOT(quit ()));
+
+ /* prepare the pipeline */
+
+ GstElement *pipeline = gst_pipeline_new ("xvoverlay");
+ GstElement *src = gst_element_factory_make ("videotestsrc", NULL);
+ GstElement *sink = gst_element_factory_make ("xvimagesink", NULL);
+ gst_bin_add_many (GST_BIN (pipeline), src, sink, NULL);
+ gst_element_link (src, sink);
+
+ /* prepare the ui */
+
+ QWidget window;
+ window.resize(320, 240);
+ window.show();
+
+ WId xwinid = window.winId();
+ gst_x_overlay_set_xwindow_id (GST_X_OVERLAY (sink), xwinid);
+
+ /* run the pipeline */
+
+ GstStateChangeReturn sret = gst_element_set_state (pipeline,
+ GST_STATE_PLAYING);
+ if (sret == GST_STATE_CHANGE_FAILURE) {
+ gst_element_set_state (pipeline, GST_STATE_NULL);
+ gst_object_unref (pipeline);
+ /* Exit application */
+ QTimer::singleShot(0, QApplication::activeWindow(), SLOT(quit()));
+ }
+
+ int ret = app.exec();
+
+ window.hide();
+ gst_element_set_state (pipeline, GST_STATE_NULL);
+ gst_object_unref (pipeline);
+
+ return ret;
+}