Important: Please read the Qt Code of Conduct -

Use GStreamer with Qt

  • Using GStreamer with Qt, so far so good if do not work with gui.
    GStreamer with the event loop by default, that means if I do not want to let the GStreamer block my main thread, the solution I got is

    1. sleep periodic in the while loop
    2. Use QTimer to pop the message out from the main thread
    3. Create a QThread, pass the pointer of bus into the class, execute the while loop in the thread and emit the signal when receive message

    I prefer solution 3
    Qt-GStreamer is not a choice since this project is dead. Thanks


    1.I init the gstreamer in main function, before QApplication

    gst_init (&argc, &argv);
    QApplication app(argc, argv);
    1. Intent to create a class inherit QThread and execute the while loop in the run function
    do {
            unique_gst_msg msg(gst_bus_timed_pop_filtered (bus.get(), GST_CLOCK_TIME_NONE,
                                                           GstMessageType(GST_MESSAGE_STATE_CHANGED | GST_MESSAGE_ERROR | GST_MESSAGE_EOS)));
            //cout<<"Parse message"<<endl;
                GError *err;
                gchar *debug_info;
                switch (GST_MESSAGE_TYPE (msg.get())) {
                case GST_MESSAGE_ERROR:
                    emit message_error(.....)
                    cout<<"We should not reach here"<<endl;
                    g_printerr ("Unexpected message received.\n");
        } while(!terminate);

    ps : Looks like only the bus need to rely on the event loop of glib?

  • You can look how it is implemented e.g. in QtMM module.

Log in to reply