OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 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 | 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 | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
11 #ifndef WEBRTC_MODULES_RTP_RTCP_SOURCE_PRODUCER_FEC_H_ | 11 #ifndef WEBRTC_MODULES_RTP_RTCP_SOURCE_PRODUCER_FEC_H_ |
12 #define WEBRTC_MODULES_RTP_RTCP_SOURCE_PRODUCER_FEC_H_ | 12 #define WEBRTC_MODULES_RTP_RTCP_SOURCE_PRODUCER_FEC_H_ |
13 | 13 |
14 #include <list> | 14 #include <list> |
15 #include <memory> | 15 #include <memory> |
16 #include <vector> | 16 #include <vector> |
17 | 17 |
18 #include "webrtc/modules/rtp_rtcp/source/forward_error_correction.h" | 18 #include "webrtc/modules/rtp_rtcp/source/forward_error_correction.h" |
19 | 19 |
20 namespace webrtc { | 20 namespace webrtc { |
21 | 21 |
22 class FlexfecSenderImpl; | |
23 | |
22 class RedPacket { | 24 class RedPacket { |
23 public: | 25 public: |
24 explicit RedPacket(size_t length); | 26 explicit RedPacket(size_t length); |
25 | 27 |
26 void CreateHeader(const uint8_t* rtp_header, | 28 void CreateHeader(const uint8_t* rtp_header, |
27 size_t header_length, | 29 size_t header_length, |
28 int red_payload_type, | 30 int red_payload_type, |
29 int payload_type); | 31 int payload_type); |
30 void SetSeqNum(int seq_num); | 32 void SetSeqNum(int seq_num); |
31 void AssignPayload(const uint8_t* payload, size_t length); | 33 void AssignPayload(const uint8_t* payload, size_t length); |
32 void ClearMarkerBit(); | 34 void ClearMarkerBit(); |
33 uint8_t* data() const; | 35 uint8_t* data() const; |
34 size_t length() const; | 36 size_t length() const; |
35 | 37 |
36 private: | 38 private: |
37 std::unique_ptr<uint8_t[]> data_; | 39 std::unique_ptr<uint8_t[]> data_; |
38 size_t length_; | 40 size_t length_; |
39 size_t header_length_; | 41 size_t header_length_; |
40 }; | 42 }; |
41 | 43 |
42 class ProducerFec { | 44 class ProducerFec { |
45 friend class FlexfecSenderImpl; | |
danilchap
2016/10/20 15:12:58
do you plan to remove this friendship later, after
brandtr
2016/10/24 12:52:08
Yes, this friendship will be removed in the future
| |
46 | |
43 public: | 47 public: |
44 ProducerFec(); | 48 ProducerFec(); |
45 ~ProducerFec(); | 49 ~ProducerFec(); |
46 | 50 |
47 static std::unique_ptr<RedPacket> BuildRedPacket(const uint8_t* data_buffer, | 51 static std::unique_ptr<RedPacket> BuildRedPacket(const uint8_t* data_buffer, |
48 size_t payload_length, | 52 size_t payload_length, |
49 size_t rtp_header_length, | 53 size_t rtp_header_length, |
50 int red_payload_type); | 54 int red_payload_type); |
51 | 55 |
52 void SetFecParameters(const FecProtectionParams* params); | 56 void SetFecParameters(const FecProtectionParams* params); |
(...skipping 14 matching lines...) Expand all Loading... | |
67 size_t MaxPacketOverhead() const; | 71 size_t MaxPacketOverhead() const; |
68 | 72 |
69 // Returns generated FEC packets with RED headers added. | 73 // Returns generated FEC packets with RED headers added. |
70 std::vector<std::unique_ptr<RedPacket>> GetUlpfecPacketsAsRed( | 74 std::vector<std::unique_ptr<RedPacket>> GetUlpfecPacketsAsRed( |
71 int red_payload_type, | 75 int red_payload_type, |
72 int ulpfec_payload_type, | 76 int ulpfec_payload_type, |
73 uint16_t first_seq_num, | 77 uint16_t first_seq_num, |
74 size_t rtp_header_length); | 78 size_t rtp_header_length); |
75 | 79 |
76 private: | 80 private: |
81 explicit ProducerFec(std::unique_ptr<ForwardErrorCorrection> fec); | |
82 | |
77 // Overhead is defined as relative to the number of media packets, and not | 83 // Overhead is defined as relative to the number of media packets, and not |
78 // relative to total number of packets. This definition is inherited from the | 84 // relative to total number of packets. This definition is inherited from the |
79 // protection factor produced by video_coding module and how the FEC | 85 // protection factor produced by video_coding module and how the FEC |
80 // generation is implemented. | 86 // generation is implemented. |
81 int Overhead() const; | 87 int Overhead() const; |
82 | 88 |
83 // Returns true if the excess overhead (actual - target) for the FEC is below | 89 // Returns true if the excess overhead (actual - target) for the FEC is below |
84 // the amount |kMaxExcessOverhead|. This effects the lower protection level | 90 // the amount |kMaxExcessOverhead|. This effects the lower protection level |
85 // cases and low number of media packets/frame. The target overhead is given | 91 // cases and low number of media packets/frame. The target overhead is given |
86 // by |params_.fec_rate|, and is only achievable in the limit of large number | 92 // by |params_.fec_rate|, and is only achievable in the limit of large number |
(...skipping 13 matching lines...) Expand all Loading... | |
100 std::list<ForwardErrorCorrection::Packet*> generated_fec_packets_; | 106 std::list<ForwardErrorCorrection::Packet*> generated_fec_packets_; |
101 int num_protected_frames_; | 107 int num_protected_frames_; |
102 int min_num_media_packets_; | 108 int min_num_media_packets_; |
103 FecProtectionParams params_; | 109 FecProtectionParams params_; |
104 FecProtectionParams new_params_; | 110 FecProtectionParams new_params_; |
105 }; | 111 }; |
106 | 112 |
107 } // namespace webrtc | 113 } // namespace webrtc |
108 | 114 |
109 #endif // WEBRTC_MODULES_RTP_RTCP_SOURCE_PRODUCER_FEC_H_ | 115 #endif // WEBRTC_MODULES_RTP_RTCP_SOURCE_PRODUCER_FEC_H_ |
OLD | NEW |