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. Qt Gstreamer : get RTP timestamp
Forum Updated to NodeBB v4.3 + New Features

Qt Gstreamer : get RTP timestamp

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 5.8k Views 1 Watching
  • 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.
  • Q Offline
    Q Offline
    Qt_User
    wrote on 10 Jun 2013, 07:43 last edited by
    #1

    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"));
    

    }
    @

    1 Reply Last reply
    0
    • Q Offline
      Q Offline
      Qt_User
      wrote on 18 Jun 2013, 13:37 last edited by
      #2

      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.

      1 Reply Last reply
      0
      • A Offline
        A Offline
        ali.pro
        wrote on 24 Feb 2014, 15:56 last edited by
        #3

        Could you put the headers of your code.

        1 Reply Last reply
        0

        • Login

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