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

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

Issue 1877253002: Replaced CriticalSectionWrapper with rtc::CriticalSection in rtp_rtcp module (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: git cl format dtmf_queue.cc Created 4 years, 8 months 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
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
11 #include "webrtc/modules/rtp_rtcp/source/fec_receiver_impl.h" 11 #include "webrtc/modules/rtp_rtcp/source/fec_receiver_impl.h"
12 12
13 #include <assert.h> 13 #include <assert.h>
14 14
15 #include "webrtc/base/logging.h" 15 #include "webrtc/base/logging.h"
16 #include "webrtc/base/scoped_ptr.h" 16 #include "webrtc/base/scoped_ptr.h"
17 #include "webrtc/modules/rtp_rtcp/source/byte_io.h" 17 #include "webrtc/modules/rtp_rtcp/source/byte_io.h"
18 #include "webrtc/modules/rtp_rtcp/source/rtp_receiver_video.h" 18 #include "webrtc/modules/rtp_rtcp/source/rtp_receiver_video.h"
19 #include "webrtc/system_wrappers/include/critical_section_wrapper.h"
20 19
21 // RFC 5109 20 // RFC 5109
22 namespace webrtc { 21 namespace webrtc {
23 22
24 FecReceiver* FecReceiver::Create(RtpData* callback) { 23 FecReceiver* FecReceiver::Create(RtpData* callback) {
25 return new FecReceiverImpl(callback); 24 return new FecReceiverImpl(callback);
26 } 25 }
27 26
28 FecReceiverImpl::FecReceiverImpl(RtpData* callback) 27 FecReceiverImpl::FecReceiverImpl(RtpData* callback)
29 : crit_sect_(CriticalSectionWrapper::CreateCriticalSection()), 28 : recovered_packet_callback_(callback),
30 recovered_packet_callback_(callback),
31 fec_(new ForwardErrorCorrection()) {} 29 fec_(new ForwardErrorCorrection()) {}
32 30
33 FecReceiverImpl::~FecReceiverImpl() { 31 FecReceiverImpl::~FecReceiverImpl() {
34 while (!received_packet_list_.empty()) { 32 while (!received_packet_list_.empty()) {
35 delete received_packet_list_.front(); 33 delete received_packet_list_.front();
36 received_packet_list_.pop_front(); 34 received_packet_list_.pop_front();
37 } 35 }
38 if (fec_ != NULL) { 36 if (fec_ != NULL) {
39 fec_->ResetState(&recovered_packet_list_); 37 fec_->ResetState(&recovered_packet_list_);
40 delete fec_; 38 delete fec_;
41 } 39 }
42 } 40 }
43 41
44 FecPacketCounter FecReceiverImpl::GetPacketCounter() const { 42 FecPacketCounter FecReceiverImpl::GetPacketCounter() const {
45 CriticalSectionScoped cs(crit_sect_.get()); 43 rtc::CritScope cs(&crit_sect_);
46 return packet_counter_; 44 return packet_counter_;
47 } 45 }
48 46
49 // 0 1 2 3 47 // 0 1 2 3
50 // 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 48 // 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
51 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 49 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
52 // |F| block PT | timestamp offset | block length | 50 // |F| block PT | timestamp offset | block length |
53 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 51 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
54 // 52 //
55 // 53 //
(...skipping 14 matching lines...) Expand all
70 // data, and is hence a time to be subtracted from the current 68 // data, and is hence a time to be subtracted from the current
71 // timestamp to determine the timestamp of the data for which this 69 // timestamp to determine the timestamp of the data for which this
72 // block is the redundancy. 70 // block is the redundancy.
73 // 71 //
74 // block length: 10 bits Length in bytes of the corresponding data 72 // block length: 10 bits Length in bytes of the corresponding data
75 // block excluding header. 73 // block excluding header.
76 74
77 int32_t FecReceiverImpl::AddReceivedRedPacket( 75 int32_t FecReceiverImpl::AddReceivedRedPacket(
78 const RTPHeader& header, const uint8_t* incoming_rtp_packet, 76 const RTPHeader& header, const uint8_t* incoming_rtp_packet,
79 size_t packet_length, uint8_t ulpfec_payload_type) { 77 size_t packet_length, uint8_t ulpfec_payload_type) {
80 CriticalSectionScoped cs(crit_sect_.get()); 78 rtc::CritScope cs(&crit_sect_);
81 uint8_t REDHeaderLength = 1; 79 uint8_t REDHeaderLength = 1;
82 size_t payload_data_length = packet_length - header.headerLength; 80 size_t payload_data_length = packet_length - header.headerLength;
83 81
84 if (payload_data_length == 0) { 82 if (payload_data_length == 0) {
85 LOG(LS_WARNING) << "Corrupt/truncated FEC packet."; 83 LOG(LS_WARNING) << "Corrupt/truncated FEC packet.";
86 return -1; 84 return -1;
87 } 85 }
88 86
89 // Add to list without RED header, aka a virtual RTP packet 87 // Add to list without RED header, aka a virtual RTP packet
90 // we remove the RED header 88 // we remove the RED header
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 } 210 }
213 211
214 received_packet_list_.push_back(received_packet.release()); 212 received_packet_list_.push_back(received_packet.release());
215 if (second_received_packet) { 213 if (second_received_packet) {
216 received_packet_list_.push_back(second_received_packet.release()); 214 received_packet_list_.push_back(second_received_packet.release());
217 } 215 }
218 return 0; 216 return 0;
219 } 217 }
220 218
221 int32_t FecReceiverImpl::ProcessReceivedFec() { 219 int32_t FecReceiverImpl::ProcessReceivedFec() {
222 crit_sect_->Enter(); 220 crit_sect_.Enter();
223 if (!received_packet_list_.empty()) { 221 if (!received_packet_list_.empty()) {
224 // Send received media packet to VCM. 222 // Send received media packet to VCM.
225 if (!received_packet_list_.front()->is_fec) { 223 if (!received_packet_list_.front()->is_fec) {
226 ForwardErrorCorrection::Packet* packet = 224 ForwardErrorCorrection::Packet* packet =
227 received_packet_list_.front()->pkt; 225 received_packet_list_.front()->pkt;
228 crit_sect_->Leave(); 226 crit_sect_.Leave();
229 if (!recovered_packet_callback_->OnRecoveredPacket(packet->data, 227 if (!recovered_packet_callback_->OnRecoveredPacket(packet->data,
230 packet->length)) { 228 packet->length)) {
231 return -1; 229 return -1;
232 } 230 }
233 crit_sect_->Enter(); 231 crit_sect_.Enter();
234 } 232 }
235 if (fec_->DecodeFEC(&received_packet_list_, &recovered_packet_list_) != 0) { 233 if (fec_->DecodeFEC(&received_packet_list_, &recovered_packet_list_) != 0) {
236 crit_sect_->Leave(); 234 crit_sect_.Leave();
237 return -1; 235 return -1;
238 } 236 }
239 assert(received_packet_list_.empty()); 237 assert(received_packet_list_.empty());
240 } 238 }
241 // Send any recovered media packets to VCM. 239 // Send any recovered media packets to VCM.
242 ForwardErrorCorrection::RecoveredPacketList::iterator it = 240 ForwardErrorCorrection::RecoveredPacketList::iterator it =
243 recovered_packet_list_.begin(); 241 recovered_packet_list_.begin();
244 for (; it != recovered_packet_list_.end(); ++it) { 242 for (; it != recovered_packet_list_.end(); ++it) {
245 if ((*it)->returned) // Already sent to the VCM and the jitter buffer. 243 if ((*it)->returned) // Already sent to the VCM and the jitter buffer.
246 continue; 244 continue;
247 ForwardErrorCorrection::Packet* packet = (*it)->pkt; 245 ForwardErrorCorrection::Packet* packet = (*it)->pkt;
248 ++packet_counter_.num_recovered_packets; 246 ++packet_counter_.num_recovered_packets;
249 crit_sect_->Leave(); 247 crit_sect_.Leave();
250 if (!recovered_packet_callback_->OnRecoveredPacket(packet->data, 248 if (!recovered_packet_callback_->OnRecoveredPacket(packet->data,
251 packet->length)) { 249 packet->length)) {
252 return -1; 250 return -1;
253 } 251 }
254 crit_sect_->Enter(); 252 crit_sect_.Enter();
255 (*it)->returned = true; 253 (*it)->returned = true;
256 } 254 }
257 crit_sect_->Leave(); 255 crit_sect_.Leave();
258 return 0; 256 return 0;
259 } 257 }
260 258
261 } // namespace webrtc 259 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/modules/rtp_rtcp/source/fec_receiver_impl.h ('k') | webrtc/modules/rtp_rtcp/source/receive_statistics_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698