• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* GStreamer
2  * Copyright (C) <2010> Stefan Kost <ensonic@users.sf.net>
3  *
4  * qt-xoverlay: demonstrate overlay handling using qt
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Library General Public
8  * License as published by the Free Software Foundation; either
9  * version 2 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * Library General Public License for more details.
15  *
16  * You should have received a copy of the GNU Library General Public
17  * License along with this library; if not, write to the
18  * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
19  * Boston, MA 02110-1301, USA.
20  */
21 
22 #ifdef HAVE_CONFIG_H
23 #include "config.h"
24 #endif
25 
26 #include <glib.h>
27 #include <gst/gst.h>
28 #include <gst/video/videooverlay.h>
29 
30 #include <QApplication>
31 #include <QTimer>
32 #include <QWidget>
33 
main(int argc,char * argv[])34 int main(int argc, char *argv[])
35 {
36   gst_init (&argc, &argv);
37   QApplication app(argc, argv);
38   app.setQuitOnLastWindowClosed(true);
39 
40   /* prepare the pipeline */
41 
42   GstElement *pipeline = gst_pipeline_new ("xvoverlay");
43   GstElement *src = gst_element_factory_make ("videotestsrc", NULL);
44   GstElement *sink = gst_element_factory_make ("glimagesink", NULL);
45 
46   if (sink == NULL)
47     g_error ("Couldn't create glimagesink.");
48 
49   gst_bin_add_many (GST_BIN (pipeline), src, sink, NULL);
50   gst_element_link (src, sink);
51 
52   /* prepare the ui */
53 
54   QWidget window;
55   window.resize(320, 240);
56   window.setWindowTitle("GstVideoOverlay Qt demo");
57   window.show();
58 
59   WId xwinid = window.winId();
60   gst_video_overlay_set_window_handle (GST_VIDEO_OVERLAY (sink), xwinid);
61 
62   /* run the pipeline */
63 
64   GstStateChangeReturn sret = gst_element_set_state (pipeline,
65       GST_STATE_PLAYING);
66   if (sret == GST_STATE_CHANGE_FAILURE) {
67     gst_element_set_state (pipeline, GST_STATE_NULL);
68     gst_object_unref (pipeline);
69     /* Exit application */
70     QTimer::singleShot(0, QApplication::activeWindow(), SLOT(quit()));
71   }
72 
73   int ret = app.exec();
74 
75   window.hide();
76   gst_element_set_state (pipeline, GST_STATE_NULL);
77   gst_object_unref (pipeline);
78 
79   return ret;
80 }
81