GStreamer - How to interrupt a video stream programmaticaly?



  • Hi.

    I have a RTSP server (implemented with GStreamer) that works as a video stream server for a client implemented with Qt5GStreamer.
    This rtsp server accepts up to 3 client sessions simultaneously. So, 3 clients can receive a video stream simultaneously. In this case, if a 4th client tries to see the video, the stream will not be available, wich is obvious.

    However, even if one running client stops the video (ex: close the windows that shows the video), the 4th client remains incapable of seeing the video, because the stream continue unavailable, wich is an error. The problem here is the client that maybe has some error that prevent it to interrupt the video and free the session in a correct way. The client is using a gstreamer pipeline to receive the stream.

    So, I suspect that my Qt code needs some fix. See the code that I use when the client close the video:

    if( _pipeline ){
        _pipeline->setState(QGst::StateNull);
        _pipeline.clear();
    }
    

    Now, see the code that creates the pipeline, please:

        _pipeline = QGst::Pipeline::create();
    
        rtspsrc = QGst::ElementFactory::make("rtspsrc");
        rtspsrc->setProperty("location",uri);
        rtspsrc->setProperty("do-rtcp",false);
        rtspsrc->setProperty("buffer-mode",1);
        _pipeline->add(rtspsrc);
    
        /* SURFACE */
        videoSink = _surface->videoSink();
        videoSink->setProperty("sync",false);
        _pipeline->add(videoSink);
    
        /* SIGNALS */
    
        // prepare bus to listen
        _pipeline->bus()->addSignalWatch();
        // watch for the receiving side src pads
        QGlib::connect(rtspsrc, "pad-added", this, &CameraControl::onRtpBinPadAdded);
        QGlib::connect(rtspsrc, "select-stream", this, &CameraControl::onSelectStream);
        QGlib::connect(_pipeline->bus(), "message::error", this, &CameraControl::onBusErrorMessage);
    
        /* ALL READY */
    
        /* Play */
        _pipeline->setState(QGst::StatePlaying);
    

    What is wrong in my code? Is there something more I must put in my code to free the client session in the gstreamer?
    If everything is ok with my code, could it be a issue in the GSTreamer version being used?

    Any hint will be very helpful!

    Best regards.

    Rodrigo Pimenta Carvalho.



  • Sorry, the complete code for pipeline creation is:

       _pipeline = QGst::Pipeline::create();
        rtspsrc = QGst::ElementFactory::make("rtspsrc");
        /* Configuring */
    
        /* RTSPSRC */
        rtspsrc->setProperty("location",uri);
        rtspsrc->setProperty("do-rtcp",false);
        rtspsrc->setProperty("buffer-mode",1);
        _pipeline->add(rtspsrc);
    
        /* SURFACE */
        videoSink = _surface->videoSink();
        videoSink->setProperty("sync",false);
        _pipeline->add(videoSink);
    
        /* SIGNALS */
    
        // prepare bus to listen
        _pipeline->bus()->addSignalWatch();
        // watch for the receiving side src pads
        QGlib::connect(rtspsrc, "pad-added", this, &CameraControl::onRtpBinPadAdded);
        QGlib::connect(rtspsrc, "select-stream", this, &CameraControl::onSelectStream);
        QGlib::connect(_pipeline->bus(), "message::error", this, &CameraControl::onBusErrorMessage);
    
        /* ALL READY */
    
        /* Play */
        _pipeline->setState(QGst::StatePlaying);

  • Lifetime Qt Champion

    Hi,

    The QtGStreamer module is not part of the Qt project, you should as the author of the module.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.