'Bandwidth estimation : adding RTCP header extension - Gstreamer C

I am writing an application that uses Gstreamer to stream video between two clients. To do that, I wrote two codes in C that implement a sending pipeline and a receiving pipeline that both use an rtpbin to send/receive the RTP stream. Along the RTP stream, two RTCP streams are also exchanged. The situation at the sender can be represented as shown here :

                .-------.    .---------.    .----------.     .-------.
                |x264enc|    |rtp264pay|    | rtpbin   |     |udpsink|  RTP
             ->sink    src->sink    src->send_rtp send_rtp->sink     | port=3000
                '-------'    '---------'    |          |     '-------'
                                            |          |      
                                            |          |     .-------.
                                            |          |     |udpsink|  RTCP
                                            |    send_rtcp->sink     | port=3001
                             .-------.      |          |     '-------' sync=false
                  RTCP       |udpsrc |      |          |               async=false
                port=3005    |     src->recv_rtcp      |                       
                             '-------'      '----------'              

I want to implement a way to estimate the bandwidth that is available between the sender and the receiver, so that I can communicate it back to the x264enc to adapt the encoding bitrate.

I searched quite a lot, but most of the questions about this topic concern webrtc and webrtcbins, which I don't use here. These webrtcbins use REMB packets, an RTCP header extension that estimates the bandwidth.

Does anyone know how I can estimate the bandwidth in my case, using rtpbins ? Can anyone help on how I can add/implement an REMB RTCP header extension in C ?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source