Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Use GStreamer with Qt

Use GStreamer with Qt

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 2 Posters 556 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • thamT Offline
    thamT Offline
    tham
    wrote on last edited by
    #1

    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

    Supplement:

    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;
            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?

    1 Reply Last reply
    0
    • K Offline
      K Offline
      kuzulis
      Qt Champions 2020
      wrote on last edited by kuzulis
      #2

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

      1 Reply Last reply
      2

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved