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 |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 | 90 |
91 uint8_t* RedPacket::data() const { | 91 uint8_t* RedPacket::data() const { |
92 return data_.get(); | 92 return data_.get(); |
93 } | 93 } |
94 | 94 |
95 size_t RedPacket::length() const { | 95 size_t RedPacket::length() const { |
96 return length_; | 96 return length_; |
97 } | 97 } |
98 | 98 |
99 ProducerFec::ProducerFec() | 99 ProducerFec::ProducerFec() |
100 : fec_(ForwardErrorCorrection::CreateUlpfec()), | 100 : ProducerFec(ForwardErrorCorrection::CreateUlpfec()) {} |
| 101 |
| 102 ProducerFec::ProducerFec(std::unique_ptr<ForwardErrorCorrection> fec) |
| 103 : fec_(std::move(fec)), |
101 num_protected_frames_(0), | 104 num_protected_frames_(0), |
102 min_num_media_packets_(1) { | 105 min_num_media_packets_(1) { |
103 memset(¶ms_, 0, sizeof(params_)); | 106 memset(¶ms_, 0, sizeof(params_)); |
104 memset(&new_params_, 0, sizeof(new_params_)); | 107 memset(&new_params_, 0, sizeof(new_params_)); |
105 } | 108 } |
106 | 109 |
107 ProducerFec::~ProducerFec() = default; | 110 ProducerFec::~ProducerFec() = default; |
108 | 111 |
109 std::unique_ptr<RedPacket> ProducerFec::BuildRedPacket( | 112 std::unique_ptr<RedPacket> ProducerFec::BuildRedPacket( |
110 const uint8_t* data_buffer, | 113 const uint8_t* data_buffer, |
(...skipping 25 matching lines...) Expand all Loading... |
136 int ProducerFec::AddRtpPacketAndGenerateFec(const uint8_t* data_buffer, | 139 int ProducerFec::AddRtpPacketAndGenerateFec(const uint8_t* data_buffer, |
137 size_t payload_length, | 140 size_t payload_length, |
138 size_t rtp_header_length) { | 141 size_t rtp_header_length) { |
139 RTC_DCHECK(generated_fec_packets_.empty()); | 142 RTC_DCHECK(generated_fec_packets_.empty()); |
140 if (media_packets_.empty()) { | 143 if (media_packets_.empty()) { |
141 params_ = new_params_; | 144 params_ = new_params_; |
142 } | 145 } |
143 bool complete_frame = false; | 146 bool complete_frame = false; |
144 const bool marker_bit = (data_buffer[1] & kRtpMarkerBitMask) ? true : false; | 147 const bool marker_bit = (data_buffer[1] & kRtpMarkerBitMask) ? true : false; |
145 if (media_packets_.size() < kUlpfecMaxMediaPackets) { | 148 if (media_packets_.size() < kUlpfecMaxMediaPackets) { |
146 // Generic FEC can only protect up to |kUlpfecMaxMediaPackets| packets. | 149 // Our packet masks can only protect up to |kUlpfecMaxMediaPackets| packets. |
147 std::unique_ptr<ForwardErrorCorrection::Packet> packet( | 150 std::unique_ptr<ForwardErrorCorrection::Packet> packet( |
148 new ForwardErrorCorrection::Packet()); | 151 new ForwardErrorCorrection::Packet()); |
149 packet->length = payload_length + rtp_header_length; | 152 packet->length = payload_length + rtp_header_length; |
150 memcpy(packet->data, data_buffer, packet->length); | 153 memcpy(packet->data, data_buffer, packet->length); |
151 media_packets_.push_back(std::move(packet)); | 154 media_packets_.push_back(std::move(packet)); |
152 } | 155 } |
153 if (marker_bit) { | 156 if (marker_bit) { |
154 ++num_protected_frames_; | 157 ++num_protected_frames_; |
155 complete_frame = true; | 158 complete_frame = true; |
156 } | 159 } |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
242 return (num_fec_packets << 8) / media_packets_.size(); | 245 return (num_fec_packets << 8) / media_packets_.size(); |
243 } | 246 } |
244 | 247 |
245 void ProducerFec::ResetState() { | 248 void ProducerFec::ResetState() { |
246 media_packets_.clear(); | 249 media_packets_.clear(); |
247 generated_fec_packets_.clear(); | 250 generated_fec_packets_.clear(); |
248 num_protected_frames_ = 0; | 251 num_protected_frames_ = 0; |
249 } | 252 } |
250 | 253 |
251 } // namespace webrtc | 254 } // namespace webrtc |
OLD | NEW |