• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_PRODUCER_FEC_H_
12 #define WEBRTC_MODULES_RTP_RTCP_SOURCE_PRODUCER_FEC_H_
13 
14 #include <list>
15 
16 #include "webrtc/modules/rtp_rtcp/source/forward_error_correction.h"
17 
18 namespace webrtc {
19 
20 struct RtpPacket;
21 
22 class RedPacket {
23  public:
24   explicit RedPacket(int length);
25   ~RedPacket();
26   void CreateHeader(const uint8_t* rtp_header, int header_length,
27                     int red_pl_type, int pl_type);
28   void SetSeqNum(int seq_num);
29   void AssignPayload(const uint8_t* payload, int length);
30   void ClearMarkerBit();
31   uint8_t* data() const;
32   int length() const;
33 
34  private:
35   uint8_t* data_;
36   int length_;
37   int header_length_;
38 };
39 
40 class ProducerFec {
41  public:
42   explicit ProducerFec(ForwardErrorCorrection* fec);
43   ~ProducerFec();
44 
45   void SetFecParameters(const FecProtectionParams* params,
46                         int max_fec_frames);
47 
48   RedPacket* BuildRedPacket(const uint8_t* data_buffer,
49                             int payload_length,
50                             int rtp_header_length,
51                             int red_pl_type);
52 
53   int AddRtpPacketAndGenerateFec(const uint8_t* data_buffer,
54                                  int payload_length,
55                                  int rtp_header_length);
56 
57   bool ExcessOverheadBelowMax();
58 
59   bool MinimumMediaPacketsReached();
60 
61   bool FecAvailable() const;
62 
63   RedPacket* GetFecPacket(int red_pl_type,
64                           int fec_pl_type,
65                           uint16_t seq_num,
66                           int rtp_header_length);
67 
68  private:
69   void DeletePackets();
70   int Overhead() const;
71   ForwardErrorCorrection* fec_;
72   std::list<ForwardErrorCorrection::Packet*> media_packets_fec_;
73   std::list<ForwardErrorCorrection::Packet*> fec_packets_;
74   int num_frames_;
75   bool incomplete_frame_;
76   int num_first_partition_;
77   int minimum_media_packets_fec_;
78   FecProtectionParams params_;
79   FecProtectionParams new_params_;
80 };
81 
82 }  // namespace webrtc
83 
84 #endif  // WEBRTC_MODULES_RTP_RTCP_SOURCE_PRODUCER_FEC_H_
85