• Flore Harlé's avatar
    FEC: update flexible FEC · e6cb6a0e
    Flore Harlé authored
    Update FecParams for an adaptative FEC.
    Several configurations are possible, for an increasing protection level and an increasing overhead. The FEC parameters can be dynamically changed, and the parity protection can be enabled or disabled. The protection configuration (L, D) can be:
    - (0, 0) when the FEC is disabled
    - (10, 0) row protection (1D)
    - (5, 5) column protection (1D)
    - (5, 5) 2D protection
    - (4, 4) 2D protection
    - (3, 3) 2D protection
    The bandwidth is classified in 3 ranges (low, medium and high). For each range, a maximal overhead is set, and a specific rule between loss rate and FEC level is defined.
    The management of the FEC parameters to optimize the bandwidth used is made by the FecParams. The choice of the level is made given the available bandwidth, the loss rate and the overhead. A heuristic helps to find the best compromise between those parameters. When the loss rate is over 20% the FEC is always disabled as we consider this is a situation of congestion. This is typically a case where the FEC has to be disabled to not consume the bandwidth. The FEC is disabled at start.
    Then the best protection level and a prediction of the bandwidth that will be consumed with that level can be computed, to help the videoqualitycontroller to update the video configuration.
    
    Update the API for the source and the repair packets used for FEC: the constructor of the source packet takes a mblk_t as input, not its copy.
    
    Update the FecEncoder to generate the repair packets from a set of source packets, with a given configuration of parity protection, given the current FEC parameters.
    
    Add a Overhead class to measure the real ratio between the sizes of repair packets and the source packets sent by the fec stream. It is used by fecParams to predict the overhead with any FEC parameters.
    
    Update the ReceiveCluster class to repair the lost source packets on the receiver side. The iterative decoding algorithm is described in RFC 8627. The repaired packets are sent to the FecStreamCxx only when asked.
    
    Add a FecPacketsConnection class to identify the sets of source packets and the sets of repair packets that protects them, from all the packets received. The connections are represented by a bipartite graph between source and repair packets that protect them.
    
    Update the FecStreamCxx.
    It is as a subscriber of FecParams, to manage the stream for FEC: send and receive repair packets, and repair missing source packets. When the FEC is disabled, no repair packets are sent, but the received repair packets are always processed.
    The FecStreamCxx controls the update of the FEC parameters of the FecEncoder, as it is notified for the changes of the FecParams. It resets also the Overhead.
    Add mutex to the FecStreamCxx to manage the audio and the video threads. The source packets received by the audio thread are copied into a queue_t. The video thread transfers these packets to the ReceiveCluster each time that a repair packet is received or that it tries to repair a lost packet. This queue is locked by a mutex. It aims to avoid thread contention on the source packets received by the RTP session.
    Two other recursive mutex are used: mSendMutex for the FecEncoder and the Overhead, and mReceiveMutex for the ReceiveCluster.
    
    Update the FEC in rtpsession: the jitter buffer is continously checked to find discontinuities in the sequence numbers. When a missing packet is detected, the ReceiveCluster tries to repair the related FEC block, identified by the FecPacketsConnection. If the lost packet is recovered, it is injected in the jitter buffer by the FecStreamCxx. The other recovered packets are added to the ReceiveCluster and will be sent to the jitter buffer only when asked. This mechanism works even if repair packets are missing and if source and repair packets arrive out of order.
    
    The old packets out of the repair window are erased in the ReceiveCluster and the FecPacketsConnection, with the related repair packets.
    
    Modify flexfec payload type to set only the repair window. It is the only parameter set at start, as L and D are adaptative and as the FEC is disabled by default.
    
    Add counters for FEC statistics in rtpsession.
    
    All the statistics are displayed for rtp session, fec session and their sum.
    
    Remove ortp event for packet reconstruction.
    
    Upadte the tests in fec_tester.
    
    Video bandwidth estimator: add a reset function. It can be used the clean the old estimates after a congestion, because the network parameters and the video encoder might have changed.
    
    CMakeList : ortp src in C++ 17.
    e6cb6a0e
To find the state of this project's repository at the time of any of these versions, check out the tags.