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

Side by Side Diff: webrtc/voice_engine/test/auto_test/fakes/conference_transport.cc

Issue 1607353002: Swap use of CriticalSectionWrapper with rtc::CriticalSection in voice_engine/ (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 4 years, 11 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) 2015 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2015 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 19 matching lines...) Expand all
30 if (len >= (ssrc_pos + sizeof(ssrc))) { 30 if (len >= (ssrc_pos + sizeof(ssrc))) {
31 ssrc = rtc::GetBE32(static_cast<const char*>(data) + ssrc_pos); 31 ssrc = rtc::GetBE32(static_cast<const char*>(data) + ssrc_pos);
32 } 32 }
33 return ssrc; 33 return ssrc;
34 } 34 }
35 } // namespace 35 } // namespace
36 36
37 namespace voetest { 37 namespace voetest {
38 38
39 ConferenceTransport::ConferenceTransport() 39 ConferenceTransport::ConferenceTransport()
40 : pq_crit_(webrtc::CriticalSectionWrapper::CreateCriticalSection()), 40 : packet_event_(webrtc::EventWrapper::Create()),
41 stream_crit_(webrtc::CriticalSectionWrapper::CreateCriticalSection()),
42 packet_event_(webrtc::EventWrapper::Create()),
43 thread_(Run, this, "ConferenceTransport"), 41 thread_(Run, this, "ConferenceTransport"),
44 rtt_ms_(0), 42 rtt_ms_(0),
45 stream_count_(0), 43 stream_count_(0),
46 rtp_header_parser_(webrtc::RtpHeaderParser::Create()) { 44 rtp_header_parser_(webrtc::RtpHeaderParser::Create()) {
47 rtp_header_parser_-> 45 rtp_header_parser_->
48 RegisterRtpHeaderExtension(webrtc::kRtpExtensionAudioLevel, 46 RegisterRtpHeaderExtension(webrtc::kRtpExtensionAudioLevel,
49 kAudioLevelHeaderId); 47 kAudioLevelHeaderId);
50 48
51 local_voe_ = webrtc::VoiceEngine::Create(); 49 local_voe_ = webrtc::VoiceEngine::Create();
52 local_base_ = webrtc::VoEBase::GetInterface(local_voe_); 50 local_base_ = webrtc::VoEBase::GetInterface(local_voe_);
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 return true; 111 return true;
114 } 112 }
115 113
116 bool ConferenceTransport::SendRtcp(const uint8_t* data, size_t len) { 114 bool ConferenceTransport::SendRtcp(const uint8_t* data, size_t len) {
117 StorePacket(Packet::Rtcp, data, len); 115 StorePacket(Packet::Rtcp, data, len);
118 return true; 116 return true;
119 } 117 }
120 118
121 int ConferenceTransport::GetReceiverChannelForSsrc(unsigned int sender_ssrc) 119 int ConferenceTransport::GetReceiverChannelForSsrc(unsigned int sender_ssrc)
122 const { 120 const {
123 webrtc::CriticalSectionScoped lock(stream_crit_.get()); 121 rtc::CritScope lock(&stream_crit_);
124 auto it = streams_.find(sender_ssrc); 122 auto it = streams_.find(sender_ssrc);
125 if (it != streams_.end()) { 123 if (it != streams_.end()) {
126 return it->second.second; 124 return it->second.second;
127 } 125 }
128 return -1; 126 return -1;
129 } 127 }
130 128
131 void ConferenceTransport::StorePacket(Packet::Type type, 129 void ConferenceTransport::StorePacket(Packet::Type type,
132 const void* data, 130 const void* data,
133 size_t len) { 131 size_t len) {
134 { 132 {
135 webrtc::CriticalSectionScoped lock(pq_crit_.get()); 133 rtc::CritScope lock(&pq_crit_);
136 packet_queue_.push_back(Packet(type, data, len, rtc::Time())); 134 packet_queue_.push_back(Packet(type, data, len, rtc::Time()));
137 } 135 }
138 packet_event_->Set(); 136 packet_event_->Set();
139 } 137 }
140 138
141 // This simulates the flow of RTP and RTCP packets. Complications like that 139 // This simulates the flow of RTP and RTCP packets. Complications like that
142 // a packet is first sent to the reflector, and then forwarded to the receiver 140 // a packet is first sent to the reflector, and then forwarded to the receiver
143 // are simplified, in this particular case, to a direct link between the sender 141 // are simplified, in this particular case, to a direct link between the sender
144 // and the receiver. 142 // and the receiver.
145 void ConferenceTransport::SendPacket(const Packet& packet) { 143 void ConferenceTransport::SendPacket(const Packet& packet) {
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
191 case webrtc::kEventTimeout: 189 case webrtc::kEventTimeout:
192 return true; 190 return true;
193 case webrtc::kEventError: 191 case webrtc::kEventError:
194 ADD_FAILURE() << "kEventError encountered."; 192 ADD_FAILURE() << "kEventError encountered.";
195 return true; 193 return true;
196 } 194 }
197 195
198 while (true) { 196 while (true) {
199 Packet packet; 197 Packet packet;
200 { 198 {
201 webrtc::CriticalSectionScoped lock(pq_crit_.get()); 199 rtc::CritScope lock(&pq_crit_);
202 if (packet_queue_.empty()) 200 if (packet_queue_.empty())
203 break; 201 break;
204 packet = packet_queue_.front(); 202 packet = packet_queue_.front();
205 packet_queue_.pop_front(); 203 packet_queue_.pop_front();
206 } 204 }
207 205
208 int32_t elapsed_time_ms = rtc::TimeSince(packet.send_time_ms_); 206 int32_t elapsed_time_ms = rtc::TimeSince(packet.send_time_ms_);
209 int32_t sleep_ms = rtt_ms_ / 2 - elapsed_time_ms; 207 int32_t sleep_ms = rtt_ms_ / 2 - elapsed_time_ms;
210 if (sleep_ms > 0) { 208 if (sleep_ms > 0) {
211 // Every packet should be delayed by half of RTT. 209 // Every packet should be delayed by half of RTT.
(...skipping 26 matching lines...) Expand all
238 236
239 const int new_receiver = local_base_->CreateChannel(); 237 const int new_receiver = local_base_->CreateChannel();
240 EXPECT_EQ(0, local_base_->AssociateSendChannel(new_receiver, local_sender_)); 238 EXPECT_EQ(0, local_base_->AssociateSendChannel(new_receiver, local_sender_));
241 239
242 EXPECT_EQ(0, local_network_->RegisterExternalTransport(new_receiver, *this)); 240 EXPECT_EQ(0, local_network_->RegisterExternalTransport(new_receiver, *this));
243 // Receive channels have to have the same SSRC in order to send receiver 241 // Receive channels have to have the same SSRC in order to send receiver
244 // reports with this SSRC. 242 // reports with this SSRC.
245 EXPECT_EQ(0, local_rtp_rtcp_->SetLocalSSRC(new_receiver, kLocalSsrc)); 243 EXPECT_EQ(0, local_rtp_rtcp_->SetLocalSSRC(new_receiver, kLocalSsrc));
246 244
247 { 245 {
248 webrtc::CriticalSectionScoped lock(stream_crit_.get()); 246 rtc::CritScope lock(&stream_crit_);
249 streams_[remote_ssrc] = std::make_pair(new_sender, new_receiver); 247 streams_[remote_ssrc] = std::make_pair(new_sender, new_receiver);
250 } 248 }
251 return remote_ssrc; // remote ssrc used as stream id. 249 return remote_ssrc; // remote ssrc used as stream id.
252 } 250 }
253 251
254 bool ConferenceTransport::RemoveStream(unsigned int id) { 252 bool ConferenceTransport::RemoveStream(unsigned int id) {
255 webrtc::CriticalSectionScoped lock(stream_crit_.get()); 253 rtc::CritScope lock(&stream_crit_);
256 auto it = streams_.find(id); 254 auto it = streams_.find(id);
257 if (it == streams_.end()) { 255 if (it == streams_.end()) {
258 return false; 256 return false;
259 } 257 }
260 EXPECT_EQ(0, remote_network_-> 258 EXPECT_EQ(0, remote_network_->
261 DeRegisterExternalTransport(it->second.second)); 259 DeRegisterExternalTransport(it->second.second));
262 EXPECT_EQ(0, local_network_-> 260 EXPECT_EQ(0, local_network_->
263 DeRegisterExternalTransport(it->second.first)); 261 DeRegisterExternalTransport(it->second.first));
264 EXPECT_EQ(0, remote_base_->DeleteChannel(it->second.second)); 262 EXPECT_EQ(0, remote_base_->DeleteChannel(it->second.second));
265 EXPECT_EQ(0, local_base_->DeleteChannel(it->second.first)); 263 EXPECT_EQ(0, local_base_->DeleteChannel(it->second.first));
(...skipping 13 matching lines...) Expand all
279 bool ConferenceTransport::GetReceiverStatistics(unsigned int id, 277 bool ConferenceTransport::GetReceiverStatistics(unsigned int id,
280 webrtc::CallStatistics* stats) { 278 webrtc::CallStatistics* stats) {
281 int dst = GetReceiverChannelForSsrc(id); 279 int dst = GetReceiverChannelForSsrc(id);
282 if (dst == -1) { 280 if (dst == -1) {
283 return false; 281 return false;
284 } 282 }
285 EXPECT_EQ(0, local_rtp_rtcp_->GetRTCPStatistics(dst, *stats)); 283 EXPECT_EQ(0, local_rtp_rtcp_->GetRTCPStatistics(dst, *stats));
286 return true; 284 return true;
287 } 285 }
288 } // namespace voetest 286 } // namespace voetest
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698