Advertisement
Guest User

qt gstreamer android

a guest
Mar 17th, 2013
37
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.60 KB | None | 0 0
  1. #include <glib.h>
  2. #include <gst/gst.h>
  3. #include <gst/interfaces/xoverlay.h>
  4.  
  5. #include <QApplication>
  6. #include <QTimer>
  7. #include <QWidget>
  8.  
  9. int main(int argc, char *argv[]) {
  10.   gst_init(&argc, &argv);
  11.   QApplication app(argc, argv);
  12.   app.connect(&app, SIGNAL(lastWindowClosed()), &app, SLOT(quit ()));
  13.  
  14.   QCoreApplication::setAttribute(Qt::AA_NativeWindows);
  15.  
  16.   QWidget window;
  17.   window.resize(320, 240);
  18.   window.setWindowTitle("GstVideoOverlay Qt demo");
  19.   window.show();
  20.  
  21.   GError *error = NULL;
  22.   GstElement *pipeline = gst_parse_launch("playbin2", &error);
  23.   if (error) {
  24.     gchar *message = g_strdup_printf("Unable to build pipeline: %s", error->message);
  25.     g_clear_error (&error);
  26.     g_free (message);
  27.     return NULL;
  28.   }
  29.   g_object_set(pipeline, "uri", "http://docs.gstreamer.com/media/sintel_trailer-368p.ogv", NULL);
  30.   gst_element_set_state(pipeline, GST_STATE_READY);
  31.   gst_x_overlay_expose(GST_X_OVERLAY(pipeline));
  32.   gst_x_overlay_expose(GST_X_OVERLAY(pipeline));
  33.   unsigned long winid = window.winId();
  34.   QApplication::syncX();
  35.   gst_x_overlay_set_window_handle(GST_X_OVERLAY(pipeline), winid);
  36.  
  37.   // run the pipeline
  38.   GstStateChangeReturn sret = gst_element_set_state(pipeline, GST_STATE_PLAYING);
  39.   if(sret == GST_STATE_CHANGE_FAILURE) {
  40.     gst_element_set_state(pipeline, GST_STATE_NULL);
  41.     gst_object_unref(pipeline);
  42.     // Exit application
  43.     QTimer::singleShot(0, QApplication::activeWindow(), SLOT(quit()));
  44.   }
  45.  
  46.   int ret = app.exec();
  47.  
  48.   window.hide();
  49.   gst_element_set_state(pipeline, GST_STATE_NULL);
  50.   gst_object_unref(pipeline);
  51.  
  52.   return ret;
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement