LCOV - code coverage report
Current view: top level - media/webrtc/trunk/webrtc/modules/rtp_rtcp/source - ulpfec_generator.h (source / functions) Hit Total Coverage
Test: output.info Lines: 0 2 0.0 %
Date: 2017-07-14 16:53:18 Functions: 0 2 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /*
       2             :  *  Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
       3             :  *
       4             :  *  Use of this source code is governed by a BSD-style license
       5             :  *  that can be found in the LICENSE file in the root of the source
       6             :  *  tree. An additional intellectual property rights grant can be found
       7             :  *  in the file PATENTS.  All contributing project authors may
       8             :  *  be found in the AUTHORS file in the root of the source tree.
       9             :  */
      10             : 
      11             : #ifndef WEBRTC_MODULES_RTP_RTCP_SOURCE_ULPFEC_GENERATOR_H_
      12             : #define WEBRTC_MODULES_RTP_RTCP_SOURCE_ULPFEC_GENERATOR_H_
      13             : 
      14             : #include <list>
      15             : #include <memory>
      16             : #include <vector>
      17             : 
      18             : #include "webrtc/modules/rtp_rtcp/source/forward_error_correction.h"
      19             : 
      20             : namespace webrtc {
      21             : 
      22             : class FlexfecSender;
      23             : 
      24           0 : class RedPacket {
      25             :  public:
      26             :   explicit RedPacket(size_t length);
      27             : 
      28             :   void CreateHeader(const uint8_t* rtp_header,
      29             :                     size_t header_length,
      30             :                     int red_payload_type,
      31             :                     int payload_type);
      32             :   void SetSeqNum(int seq_num);
      33             :   void AssignPayload(const uint8_t* payload, size_t length);
      34             :   void ClearMarkerBit();
      35             :   uint8_t* data() const;
      36             :   size_t length() const;
      37             : 
      38             :  private:
      39             :   std::unique_ptr<uint8_t[]> data_;
      40             :   size_t length_;
      41             :   size_t header_length_;
      42             : };
      43             : 
      44           0 : class UlpfecGenerator {
      45             :   friend class FlexfecSender;
      46             : 
      47             :  public:
      48             :   UlpfecGenerator();
      49             :   ~UlpfecGenerator();
      50             : 
      51             :   static std::unique_ptr<RedPacket> BuildRedPacket(const uint8_t* data_buffer,
      52             :                                                    size_t payload_length,
      53             :                                                    size_t rtp_header_length,
      54             :                                                    int red_payload_type);
      55             : 
      56             :   void SetFecParameters(const FecProtectionParams& params);
      57             : 
      58             :   // Adds a media packet to the internal buffer. When enough media packets
      59             :   // have been added, the FEC packets are generated and stored internally.
      60             :   // These FEC packets are then obtained by calling GetFecPacketsAsRed().
      61             :   int AddRtpPacketAndGenerateFec(const uint8_t* data_buffer,
      62             :                                  size_t payload_length,
      63             :                                  size_t rtp_header_length);
      64             : 
      65             :   // Returns true if there are generated FEC packets available.
      66             :   bool FecAvailable() const;
      67             : 
      68             :   size_t NumAvailableFecPackets() const;
      69             : 
      70             :   // Returns the overhead, per packet, for FEC (and possibly RED).
      71             :   size_t MaxPacketOverhead() const;
      72             : 
      73             :   // Returns generated FEC packets with RED headers added.
      74             :   std::vector<std::unique_ptr<RedPacket>> GetUlpfecPacketsAsRed(
      75             :       int red_payload_type,
      76             :       int ulpfec_payload_type,
      77             :       uint16_t first_seq_num,
      78             :       size_t rtp_header_length);
      79             : 
      80             :  private:
      81             :   explicit UlpfecGenerator(std::unique_ptr<ForwardErrorCorrection> fec);
      82             : 
      83             :   // Overhead is defined as relative to the number of media packets, and not
      84             :   // relative to total number of packets. This definition is inherited from the
      85             :   // protection factor produced by video_coding module and how the FEC
      86             :   // generation is implemented.
      87             :   int Overhead() const;
      88             : 
      89             :   // Returns true if the excess overhead (actual - target) for the FEC is below
      90             :   // the amount |kMaxExcessOverhead|. This effects the lower protection level
      91             :   // cases and low number of media packets/frame. The target overhead is given
      92             :   // by |params_.fec_rate|, and is only achievable in the limit of large number
      93             :   // of media packets.
      94             :   bool ExcessOverheadBelowMax() const;
      95             : 
      96             :   // Returns true if the number of added media packets is at least
      97             :   // |min_num_media_packets_|. This condition tries to capture the effect
      98             :   // that, for the same amount of protection/overhead, longer codes
      99             :   // (e.g. (2k,2m) vs (k,m)) are generally more effective at recovering losses.
     100             :   bool MinimumMediaPacketsReached() const;
     101             : 
     102             :   void ResetState();
     103             : 
     104             :   std::unique_ptr<ForwardErrorCorrection> fec_;
     105             :   ForwardErrorCorrection::PacketList media_packets_;
     106             :   std::list<ForwardErrorCorrection::Packet*> generated_fec_packets_;
     107             :   int num_protected_frames_;
     108             :   int min_num_media_packets_;
     109             :   FecProtectionParams params_;
     110             :   FecProtectionParams new_params_;
     111             : };
     112             : 
     113             : }  // namespace webrtc
     114             : 
     115             : #endif  // WEBRTC_MODULES_RTP_RTCP_SOURCE_ULPFEC_GENERATOR_H_

Generated by: LCOV version 1.13