Qt Gstreamer : get RTP timestamp



  • Hi all,

    I am developping a Qt program to play rtp video stream.

    I use gstreamer (QGst) to play the video. The video plays well but I would like to extract the RTP timestamp from the RTP header from the stream.

    Does anybody know a way to do it ?

    Maybe getting a "QGstBuffer":http://gstreamer.freedesktop.org/data/doc/gstreamer/head/qt-gstreamer/html/classQGst_1_1Buffer.html could be a solution ? It has a timeStamp() method...

    Thank you

    Here is the pipeline configuration :

    @
    /*
    .----------.
    | rtpbin |
    .-------. | | .---------. .-------. .-------------.
    RTP RECV |udpsrc | | | |h264depay| |h264dec| |autovideosink|
    | src->recv_rtp recv_rtp->sink src->sink src->sink |
    '-------' | | '---------' '-------' '-------------'
    | |
    '----------'
    */

    void VideoControler::playRTP(int port)
    {
    m_pipeline = QGst::Pipeline::create();

    QGst::ElementPtr rtpbin = QGst::ElementFactory::make("gstrtpbin");
    if (!rtpbin) {
        qFatal("Failed to create gstrtpbin");
    }
    m_pipeline->add(rtpbin);
    
    // video content
    // receiving the vidéo
    QGst::ElementPtr rtpudpsrc = QGst::ElementFactory::make("udpsrc");
    if (!rtpudpsrc) {
        qFatal("Failed to create udpsrc. Aborting...");
    }
    rtpudpsrc->setProperty("port", port);
    rtpudpsrc->setProperty("caps", QGst::Caps::fromString("application/x-rtp,"
                                                          "media=(string)video,"
                                                          "clock-rate=(int)90000,"
                                                          "encoding-name=(string)H264"));
    rtpudpsrc->setProperty("sync", false);
    m_pipeline->add(rtpudpsrc);
    rtpudpsrc->link(rtpbin, "recv_rtp_sink_1");
    
    // watch for the receiving side src pads
    QGlib::connect(rtpbin, "pad-added", this, &VideoControler::onRtpBinPadAdded);
    
    // watch the bus
    m_pipeline->bus()->addSignalWatch();
    QGlib::connect(m_pipeline->bus(), "message::error", this, &VideoControler::onBusErrorMessage);
    
    // switch to the video view and connect the video widget
    m_player->watchPipeline(m_pipeline);
    
    // go!
    m_pipeline->setState(QGst::StatePlaying);
    

    }

    void VideoControler::onRtpBinPadAdded(const QGst::PadPtr & pad)
    {
    QGst::ElementPtr bin;

    try {
        bin = QGst::Bin::fromDescription(
            "rtph264depay ! ffdec_h264 ! ffmpegcolorspace ! autovideosink"
        );
    } catch (const QGlib::Error & error) {
        qCritical() << error;
        qFatal("One ore more required elements are missing. Aborting...");
    }
    
    m_pipeline->add(bin);
    bin->syncStateWithParent();
    pad->link(bin->getStaticPad("sink"));
    

    }
    @



  • Hi !

    I found how to extract RTP timestamp (and more).

    Here is my new pipeline : http://www.asciiflow.com/#5094128708993859588

    @

    /*
    +-------+ +--------+
    |udpsrc | |appsink |
    RTP RECV | | | |
    | src->sink |
    +-------+ +--------+
    +
    |
    | queue
    pushBuffer(pullBuffer())|
    | +----------+ +---------+ +-------+ +-------------+
    v +----------+ | | |h264depay| |h264dec| |autovideosink|
    +-------+ | rtpbin | | | | | | | | |
    |appsrc | | | +----+ src->sink src->sink src->sink |
    | | | | | +------+ +---------+ +-------+ +-------------+
    | src->recv_rtp recv_rtp->sink tee |
    +-------+ | | | +------+ +---------+ +-------+ +---------+ +------+ +--------+
    | | +----+ | |h264depay| |h264dec| |theoraenc| |oggmux| |filesink|
    +----------+ | | | | | | | | | | | |
    | src->sink src->sink src->sink src->sink src->sink |
    +----------+ +---------+ +-------+ +---------+ +------+ +--------+

                                                                                 queue
    

    */
    @

    And follow this example to create a personal sink :
    http://gstreamer.freedesktop.org/data/doc/gstreamer/head/qt-gstreamer/html/examples_2appsink-src_2main_8cpp-example.html

    This way you can access to a raw RTP packet.



  • Could you put the headers of your code.


Log in to reply
 

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