Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

QtGstreamer, multiudpsink - how to add clients?



  • Hi!

    I have previously setup a gstreamer pipeline using an udpsink. This has worked fine. Now I want to change this pipeline to instead use a multiudpsink and to that sink I want to dynamically add and remove clients as they show up (I have a tcp session setup in parallel with the stream).

    My pipeline is setup as follows:

    auto spBin = QGst::Bin::fromDescription("autovideosrc ! videoconvert ! capsfilter caps=video/x-raw,width=(int)320,height=(int)240 ! videoconvert ! rtpvrawpay ! multiudpsink name=out_sink");
    ...
    auto spPipeline = QGst::Pipeline::create();
    spPipeline->add(spBin);
    ...
    

    Then I connect some signal notifications:

    ...
    spPipeline->bus()->addSignalWatch();
    QGlib::connect(spPipeline->bus(), "message", this, &VideoControl::onBusMessage);
    
    auto spSink = spPipeline->getElementByName("out_sink");
    QGlib::connect(spSink, "client-added", this, &VideoControl::onClientAdded);
    
    auto spSinkPad = spSink->getStaticPad("sink");
    QGlib::connect(spSinkPad, "notify::caps", this, &VideoControl::onSinkCapsChanged);
    ...
    

    Finally I start the pipeline:

    m_spPipeline->setState(QGst::StatePlaying);
    

    When doing so I get a callback on VideoControl::onBusMessage telling me that the pipeline is now in StatePlaying. That is good, I guess?

    In my previous implemntation (udpsink with single reciever) I got a callback to onSinkCapsChanged as soon as a client showed up, at which point i sent those caps to the client so that it could start playback using the correct format. Now I have not been able to trigger onSinkCapsChanged.

    I have tried setting the clients property. That did give me a callback on onClientAdded but onSinkCapsChanged is never called.

    The gstreamer docs mention some add and remove signals. How do I call them? I'm struggling to find good documentation / examples of QtGstreamer.

    I would be grateful for any advice :-)

    //Björn



  • Well, turns out it was only me being stupid. The caps were there all along, I just failed to pass them on to the client after I changed the interface. That's what happens when you code at 2 am :)


  • Lifetime Qt Champion

    Then please mark the topic as solved. thx



  • I did mark it it as solved the moment I wrote my comment :(


  • Lifetime Qt Champion

    There seems to be some caching issues. Don't worry it will appear as solved :-)


Log in to reply