Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <glib.h>
- #include <gst/gst.h>
- #include <gst/interfaces/xoverlay.h>
- #include <QApplication>
- #include <QTimer>
- #include <QWidget>
- int main(int argc, char *argv[]) {
- gst_init(&argc, &argv);
- QApplication app(argc, argv);
- app.connect(&app, SIGNAL(lastWindowClosed()), &app, SLOT(quit ()));
- QCoreApplication::setAttribute(Qt::AA_NativeWindows);
- QWidget window;
- window.resize(320, 240);
- window.setWindowTitle("GstVideoOverlay Qt demo");
- window.show();
- GError *error = NULL;
- GstElement *pipeline = gst_parse_launch("playbin2", &error);
- if (error) {
- gchar *message = g_strdup_printf("Unable to build pipeline: %s", error->message);
- g_clear_error (&error);
- g_free (message);
- return NULL;
- }
- g_object_set(pipeline, "uri", "http://docs.gstreamer.com/media/sintel_trailer-368p.ogv", NULL);
- gst_element_set_state(pipeline, GST_STATE_READY);
- gst_x_overlay_expose(GST_X_OVERLAY(pipeline));
- gst_x_overlay_expose(GST_X_OVERLAY(pipeline));
- unsigned long winid = window.winId();
- QApplication::syncX();
- gst_x_overlay_set_window_handle(GST_X_OVERLAY(pipeline), winid);
- // 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;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement