Unsolved 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- sleep periodic in the while loop
- Use QTimer to pop the message out from the main thread
- 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. ThanksSupplement:
1.I init the gstreamer in main function, before QApplication
gst_init (&argc, &argv); QApplication app(argc, argv);
- 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; if(msg){ GError *err; gchar *debug_info; switch (GST_MESSAGE_TYPE (msg.get())) { case GST_MESSAGE_ERROR: emit message_error(.....) default: cout<<"We should not reach here"<<endl; g_printerr ("Unexpected message received.\n"); break; } } } 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.