diff options
author | Julien Isorce <julien.isorce@gmail.com> | 2008-07-14 12:56:24 +0000 |
---|---|---|
committer | David Schleef <ds@schleef.org> | 2008-07-15 14:21:39 -0700 |
commit | 0d1187fbb68cb4283cfd750fb7065b6be32cc5f4 (patch) | |
tree | a38a8a4f714fc9ab3f55fa7e1494813a46cda6d0 | |
parent | 76e3e146de130b6f4e3f0af6ef80c8cdca7d63e6 (diff) |
try againisorce
git-svn-id: svn://svn.wobow.com/GStreamer_playground/gst-plugins-gl@587 93df14bb-0f41-7a43-8087-d3e2a2f0e464
-rw-r--r-- | tests/examples/videoxoverlay/gstthread.cpp | 9 | ||||
-rw-r--r-- | tests/examples/videoxoverlay/pipeline.cpp | 83 | ||||
-rw-r--r-- | tests/examples/videoxoverlay/pipeline.h | 3 |
3 files changed, 54 insertions, 41 deletions
diff --git a/tests/examples/videoxoverlay/gstthread.cpp b/tests/examples/videoxoverlay/gstthread.cpp index e016dd2..a11a15f 100644 --- a/tests/examples/videoxoverlay/gstthread.cpp +++ b/tests/examples/videoxoverlay/gstthread.cpp @@ -29,10 +29,15 @@ void GstThread::run() {
m_pipeline = new Pipeline(m_winId);
connect(m_pipeline, SIGNAL(resizeRequested(int, int)), this, SLOT(resize(int, int)));
- m_pipeline->start();
+ m_pipeline->start(); //it runs the gmainloop on win32
+
+#ifndef WIN32
//works like the gmainloop on linux (GstEvent are handled)
- //exec();
+ connect(m_pipeline, SIGNAL(stopRequested()), this, SLOT(quit()));
+ exec();
+#endif
+
m_pipeline->unconfigure();
}
diff --git a/tests/examples/videoxoverlay/pipeline.cpp b/tests/examples/videoxoverlay/pipeline.cpp index cc1bacd..d7e0198 100644 --- a/tests/examples/videoxoverlay/pipeline.cpp +++ b/tests/examples/videoxoverlay/pipeline.cpp @@ -19,10 +19,11 @@ void Pipeline::create() {
gst_init (NULL, NULL);
- //m_loop = g_main_loop_new (NULL, FALSE);
+#ifdef WIN32
+ m_loop = g_main_loop_new (NULL, FALSE);
+#endif
m_pipeline = gst_pipeline_new ("pipeline");
- m_loop = g_main_loop_new(NULL, FALSE);
m_bus = gst_pipeline_get_bus (GST_PIPELINE (m_pipeline));
gst_bus_add_watch (m_bus, (GstBusFunc) bus_call, this);
gst_bus_set_sync_handler (m_bus, (GstBusSyncHandler) create_window, this);
@@ -58,44 +59,50 @@ void Pipeline::create() void Pipeline::start()
{
- GstStateChangeReturn ret = gst_element_set_state (m_pipeline, GST_STATE_PLAYING); - if (ret == GST_STATE_CHANGE_FAILURE) - { - qDebug ("Failed to start up pipeline!"); - - /* check if there is an error message with details on the bus */ - GstMessage* msg = gst_bus_poll (m_bus, GST_MESSAGE_ERROR, 0); - if (msg) - { - GError *err = NULL; - gst_message_parse_error (msg, &err, NULL); - qDebug ("ERROR: %s", err->message); - g_error_free (err); - gst_message_unref (msg); - } - return; + GstStateChangeReturn ret = gst_element_set_state (m_pipeline, GST_STATE_PLAYING);
+ if (ret == GST_STATE_CHANGE_FAILURE)
+ {
+ qDebug ("Failed to start up pipeline!");
+
+ /* check if there is an error message with details on the bus */
+ GstMessage* msg = gst_bus_poll (m_bus, GST_MESSAGE_ERROR, 0);
+ if (msg)
+ {
+ GError *err = NULL;
+ gst_message_parse_error (msg, &err, NULL);
+ qDebug ("ERROR: %s", err->message);
+ g_error_free (err);
+ gst_message_unref (msg);
+ }
+ return;
}
+#ifdef WIN32
g_main_loop_run(m_loop);
+#endif
}
//we don't want a thread safe stop in this example
void Pipeline::stop()
-{ +{
+#ifdef WIN32
g_main_loop_quit(m_loop);
-} - - -void Pipeline::unconfigure() const -{ - gst_element_set_state (m_pipeline, GST_STATE_NULL); - gst_object_unref (m_pipeline); +#else
+ emit stopRequested();
+#endif
+}
+
+
+void Pipeline::unconfigure() const
+{
+ gst_element_set_state (m_pipeline, GST_STATE_NULL);
+ gst_object_unref (m_pipeline);
}
//redraw the current frame in the drawable
void Pipeline::doExpose() const
{
- if (m_pipeline && m_glimagesink) + if (m_pipeline && m_glimagesink)
gst_x_overlay_expose (GST_X_OVERLAY (m_glimagesink));
}
@@ -153,9 +160,9 @@ void Pipeline::cb_new_pad (GstElement* avidemux, GstPad* pad, GstElement* ffdec_ }
void Pipeline::cb_video_size (GstPad* pad, GParamSpec* pspec, Pipeline* p)
-{ - GstCaps* caps = gst_pad_get_negotiated_caps(pad); - if (caps) +{
+ GstCaps* caps = gst_pad_get_negotiated_caps(pad);
+ if (caps)
{
qDebug ("negotiated caps : %s", gst_caps_to_string(caps)) ;
const GstStructure* str = gst_caps_get_structure (caps, 0);
@@ -164,15 +171,15 @@ void Pipeline::cb_video_size (GstPad* pad, GParamSpec* pspec, Pipeline* p) if (gst_structure_get_int (str, "width", &width) &&
gst_structure_get_int (str, "height", &height) )
p->resize(width, height);
- gst_caps_unref(caps) ; + gst_caps_unref(caps) ;
}
-} - -gboolean Pipeline::cb_expose (gpointer data) -{ - ((Pipeline*)data)->doExpose(); - return FALSE; -} +}
+
+gboolean Pipeline::cb_expose (gpointer data)
+{
+ ((Pipeline*)data)->doExpose();
+ return FALSE;
+}
GstBusSyncReply Pipeline::create_window (GstBus* bus, GstMessage* message, const Pipeline* p)
diff --git a/tests/examples/videoxoverlay/pipeline.h b/tests/examples/videoxoverlay/pipeline.h index b7a8390..7fd931c 100644 --- a/tests/examples/videoxoverlay/pipeline.h +++ b/tests/examples/videoxoverlay/pipeline.h @@ -3,7 +3,7 @@ #include <QtGui>
#include <gst/gst.h>
-//#include <qeventdispatcher_glib_p.h>
+//#include <QtCore/private/qeventdispatcher_glib_p.h>
class Pipeline : public QObject
{
@@ -20,6 +20,7 @@ public: signals:
void resizeRequested(int width, int height);
+ void stopRequested();
private:
const WId m_winId;
|