Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(27)

Side by Side Diff: webrtc/modules/rtp_rtcp/source/ulpfec_generator.cc

Issue 2441613002: Add FlexfecSender. (Closed)
Patch Set: Rebase. Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « webrtc/modules/rtp_rtcp/source/ulpfec_generator.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 87
88 uint8_t* RedPacket::data() const { 88 uint8_t* RedPacket::data() const {
89 return data_.get(); 89 return data_.get();
90 } 90 }
91 91
92 size_t RedPacket::length() const { 92 size_t RedPacket::length() const {
93 return length_; 93 return length_;
94 } 94 }
95 95
96 UlpfecGenerator::UlpfecGenerator() 96 UlpfecGenerator::UlpfecGenerator()
97 : fec_(ForwardErrorCorrection::CreateUlpfec()), 97 : UlpfecGenerator(ForwardErrorCorrection::CreateUlpfec()) {}
98
99 UlpfecGenerator::UlpfecGenerator(std::unique_ptr<ForwardErrorCorrection> fec)
100 : fec_(std::move(fec)),
98 num_protected_frames_(0), 101 num_protected_frames_(0),
99 min_num_media_packets_(1) { 102 min_num_media_packets_(1) {
100 memset(&params_, 0, sizeof(params_)); 103 memset(&params_, 0, sizeof(params_));
101 memset(&new_params_, 0, sizeof(new_params_)); 104 memset(&new_params_, 0, sizeof(new_params_));
102 } 105 }
103 106
104 UlpfecGenerator::~UlpfecGenerator() = default; 107 UlpfecGenerator::~UlpfecGenerator() = default;
105 108
106 std::unique_ptr<RedPacket> UlpfecGenerator::BuildRedPacket( 109 std::unique_ptr<RedPacket> UlpfecGenerator::BuildRedPacket(
107 const uint8_t* data_buffer, 110 const uint8_t* data_buffer,
(...skipping 25 matching lines...) Expand all
133 int UlpfecGenerator::AddRtpPacketAndGenerateFec(const uint8_t* data_buffer, 136 int UlpfecGenerator::AddRtpPacketAndGenerateFec(const uint8_t* data_buffer,
134 size_t payload_length, 137 size_t payload_length,
135 size_t rtp_header_length) { 138 size_t rtp_header_length) {
136 RTC_DCHECK(generated_fec_packets_.empty()); 139 RTC_DCHECK(generated_fec_packets_.empty());
137 if (media_packets_.empty()) { 140 if (media_packets_.empty()) {
138 params_ = new_params_; 141 params_ = new_params_;
139 } 142 }
140 bool complete_frame = false; 143 bool complete_frame = false;
141 const bool marker_bit = (data_buffer[1] & kRtpMarkerBitMask) ? true : false; 144 const bool marker_bit = (data_buffer[1] & kRtpMarkerBitMask) ? true : false;
142 if (media_packets_.size() < kUlpfecMaxMediaPackets) { 145 if (media_packets_.size() < kUlpfecMaxMediaPackets) {
143 // Generic FEC can only protect up to |kUlpfecMaxMediaPackets| packets. 146 // Our packet masks can only protect up to |kUlpfecMaxMediaPackets| packets.
144 std::unique_ptr<ForwardErrorCorrection::Packet> packet( 147 std::unique_ptr<ForwardErrorCorrection::Packet> packet(
145 new ForwardErrorCorrection::Packet()); 148 new ForwardErrorCorrection::Packet());
146 packet->length = payload_length + rtp_header_length; 149 packet->length = payload_length + rtp_header_length;
147 memcpy(packet->data, data_buffer, packet->length); 150 memcpy(packet->data, data_buffer, packet->length);
148 media_packets_.push_back(std::move(packet)); 151 media_packets_.push_back(std::move(packet));
149 } 152 }
150 if (marker_bit) { 153 if (marker_bit) {
151 ++num_protected_frames_; 154 ++num_protected_frames_;
152 complete_frame = true; 155 complete_frame = true;
153 } 156 }
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
239 return (num_fec_packets << 8) / media_packets_.size(); 242 return (num_fec_packets << 8) / media_packets_.size();
240 } 243 }
241 244
242 void UlpfecGenerator::ResetState() { 245 void UlpfecGenerator::ResetState() {
243 media_packets_.clear(); 246 media_packets_.clear();
244 generated_fec_packets_.clear(); 247 generated_fec_packets_.clear();
245 num_protected_frames_ = 0; 248 num_protected_frames_ = 0;
246 } 249 }
247 250
248 } // namespace webrtc 251 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/modules/rtp_rtcp/source/ulpfec_generator.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698