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

Side by Side Diff: webrtc/pc/channel.cc

Issue 1895813003: Renames TransportController worker_thread to network_thread. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: rebase Created 4 years, 7 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
« no previous file with comments | « webrtc/p2p/base/transportcontroller_unittest.cc ('k') | webrtc/pc/channel_unittest.cc » ('j') | 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 2004 The WebRTC project authors. All Rights Reserved. 2 * Copyright 2004 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 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 dtls_keyed_(false), 166 dtls_keyed_(false),
167 secure_required_(false), 167 secure_required_(false),
168 rtp_abs_sendtime_extn_id_(-1), 168 rtp_abs_sendtime_extn_id_(-1),
169 169
170 media_channel_(media_channel), 170 media_channel_(media_channel),
171 enabled_(false), 171 enabled_(false),
172 local_content_direction_(MD_INACTIVE), 172 local_content_direction_(MD_INACTIVE),
173 remote_content_direction_(MD_INACTIVE) { 173 remote_content_direction_(MD_INACTIVE) {
174 ASSERT(worker_thread_ == rtc::Thread::Current()); 174 ASSERT(worker_thread_ == rtc::Thread::Current());
175 if (transport_controller) { 175 if (transport_controller) {
176 RTC_DCHECK_EQ(network_thread, transport_controller->worker_thread()); 176 RTC_DCHECK_EQ(network_thread, transport_controller->network_thread());
177 } 177 }
178 LOG(LS_INFO) << "Created channel for " << content_name; 178 LOG(LS_INFO) << "Created channel for " << content_name;
179 } 179 }
180 180
181 BaseChannel::~BaseChannel() { 181 BaseChannel::~BaseChannel() {
182 TRACE_EVENT0("webrtc", "BaseChannel::~BaseChannel"); 182 TRACE_EVENT0("webrtc", "BaseChannel::~BaseChannel");
183 ASSERT(worker_thread_ == rtc::Thread::Current()); 183 ASSERT(worker_thread_ == rtc::Thread::Current());
184 Deinit(); 184 Deinit();
185 StopConnectionMonitor(); 185 StopConnectionMonitor();
186 // Send any outstanding RTCP packets. 186 // Send any outstanding RTCP packets.
187 network_thread_->Invoke<void>(Bind(&BaseChannel::FlushRtcpMessages_n, this)); 187 network_thread_->Invoke<void>(Bind(&BaseChannel::FlushRtcpMessages_n, this));
188 // Eats any outstanding messages or packets. 188 // Eats any outstanding messages or packets.
189 worker_thread_->Clear(&invoker_); 189 worker_thread_->Clear(&invoker_);
190 worker_thread_->Clear(this); 190 worker_thread_->Clear(this);
191 // We must destroy the media channel before the transport channel, otherwise 191 // We must destroy the media channel before the transport channel, otherwise
192 // the media channel may try to send on the dead transport channel. NULLing 192 // the media channel may try to send on the dead transport channel. NULLing
193 // is not an effective strategy since the sends will come on another thread. 193 // is not an effective strategy since the sends will come on another thread.
194 delete media_channel_; 194 delete media_channel_;
195 // Note that we don't just call SetTransportChannel_n(nullptr) because that 195 // Note that we don't just call SetTransportChannel_n(nullptr) because that
196 // would call a pure virtual method which we can't do from a destructor. 196 // would call a pure virtual method which we can't do from a destructor.
197 network_thread_->Invoke<void>(Bind(&BaseChannel::DeinitNetwork_n, this)); 197 network_thread_->Invoke<void>(Bind(&BaseChannel::DeinitNetwork_n, this));
198 LOG(LS_INFO) << "Destroyed channel"; 198 LOG(LS_INFO) << "Destroyed channel";
199 } 199 }
200 200
201 void BaseChannel::DeinitNetwork_n() { 201 void BaseChannel::DeinitNetwork_n() {
202 if (transport_channel_) { 202 if (transport_channel_) {
203 DisconnectFromTransportChannel(transport_channel_); 203 DisconnectFromTransportChannel(transport_channel_);
204 transport_controller_->DestroyTransportChannel_w( 204 transport_controller_->DestroyTransportChannel_n(
205 transport_name_, cricket::ICE_CANDIDATE_COMPONENT_RTP); 205 transport_name_, cricket::ICE_CANDIDATE_COMPONENT_RTP);
206 } 206 }
207 if (rtcp_transport_channel_) { 207 if (rtcp_transport_channel_) {
208 DisconnectFromTransportChannel(rtcp_transport_channel_); 208 DisconnectFromTransportChannel(rtcp_transport_channel_);
209 transport_controller_->DestroyTransportChannel_w( 209 transport_controller_->DestroyTransportChannel_n(
210 transport_name_, cricket::ICE_CANDIDATE_COMPONENT_RTCP); 210 transport_name_, cricket::ICE_CANDIDATE_COMPONENT_RTCP);
211 } 211 }
212 network_thread_->Clear(this); 212 network_thread_->Clear(this);
213 } 213 }
214 214
215 bool BaseChannel::Init_w() { 215 bool BaseChannel::Init_w() {
216 if (!network_thread_->Invoke<bool>(Bind(&BaseChannel::InitNetwork_n, this))) { 216 if (!network_thread_->Invoke<bool>(Bind(&BaseChannel::InitNetwork_n, this))) {
217 return false; 217 return false;
218 } 218 }
219 219
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
266 // DTLS-SRTP when the writable_ becomes true again. 266 // DTLS-SRTP when the writable_ becomes true again.
267 writable_ = false; 267 writable_ = false;
268 srtp_filter_.ResetParams(); 268 srtp_filter_.ResetParams();
269 } 269 }
270 270
271 // TODO(guoweis): Remove this grossness when we remove non-muxed RTCP. 271 // TODO(guoweis): Remove this grossness when we remove non-muxed RTCP.
272 if (rtcp_transport_enabled()) { 272 if (rtcp_transport_enabled()) {
273 LOG(LS_INFO) << "Create RTCP TransportChannel for " << content_name() 273 LOG(LS_INFO) << "Create RTCP TransportChannel for " << content_name()
274 << " on " << transport_name << " transport "; 274 << " on " << transport_name << " transport ";
275 SetRtcpTransportChannel_n( 275 SetRtcpTransportChannel_n(
276 transport_controller_->CreateTransportChannel_w( 276 transport_controller_->CreateTransportChannel_n(
277 transport_name, cricket::ICE_CANDIDATE_COMPONENT_RTCP), 277 transport_name, cricket::ICE_CANDIDATE_COMPONENT_RTCP),
278 false /* update_writablity */); 278 false /* update_writablity */);
279 if (!rtcp_transport_channel_) { 279 if (!rtcp_transport_channel_) {
280 return false; 280 return false;
281 } 281 }
282 } 282 }
283 283
284 // We're not updating the writablity during the transition state. 284 // We're not updating the writablity during the transition state.
285 SetTransportChannel_n(transport_controller_->CreateTransportChannel_w( 285 SetTransportChannel_n(transport_controller_->CreateTransportChannel_n(
286 transport_name, cricket::ICE_CANDIDATE_COMPONENT_RTP)); 286 transport_name, cricket::ICE_CANDIDATE_COMPONENT_RTP));
287 if (!transport_channel_) { 287 if (!transport_channel_) {
288 return false; 288 return false;
289 } 289 }
290 290
291 // TODO(guoweis): Remove this grossness when we remove non-muxed RTCP. 291 // TODO(guoweis): Remove this grossness when we remove non-muxed RTCP.
292 if (rtcp_transport_enabled()) { 292 if (rtcp_transport_enabled()) {
293 // We can only update the RTCP ready to send after set_transport_channel has 293 // We can only update the RTCP ready to send after set_transport_channel has
294 // handled channel writability. 294 // handled channel writability.
295 SetReadyToSend( 295 SetReadyToSend(
296 true, rtcp_transport_channel_ && rtcp_transport_channel_->writable()); 296 true, rtcp_transport_channel_ && rtcp_transport_channel_->writable());
297 } 297 }
298 transport_name_ = transport_name; 298 transport_name_ = transport_name;
299 return true; 299 return true;
300 } 300 }
301 301
302 void BaseChannel::SetTransportChannel_n(TransportChannel* new_tc) { 302 void BaseChannel::SetTransportChannel_n(TransportChannel* new_tc) {
303 RTC_DCHECK(network_thread_->IsCurrent()); 303 RTC_DCHECK(network_thread_->IsCurrent());
304 304
305 TransportChannel* old_tc = transport_channel_; 305 TransportChannel* old_tc = transport_channel_;
306 if (!old_tc && !new_tc) { 306 if (!old_tc && !new_tc) {
307 // Nothing to do 307 // Nothing to do
308 return; 308 return;
309 } 309 }
310 ASSERT(old_tc != new_tc); 310 ASSERT(old_tc != new_tc);
311 311
312 if (old_tc) { 312 if (old_tc) {
313 DisconnectFromTransportChannel(old_tc); 313 DisconnectFromTransportChannel(old_tc);
314 transport_controller_->DestroyTransportChannel_w( 314 transport_controller_->DestroyTransportChannel_n(
315 transport_name_, cricket::ICE_CANDIDATE_COMPONENT_RTP); 315 transport_name_, cricket::ICE_CANDIDATE_COMPONENT_RTP);
316 } 316 }
317 317
318 transport_channel_ = new_tc; 318 transport_channel_ = new_tc;
319 319
320 if (new_tc) { 320 if (new_tc) {
321 ConnectToTransportChannel(new_tc); 321 ConnectToTransportChannel(new_tc);
322 for (const auto& pair : socket_options_) { 322 for (const auto& pair : socket_options_) {
323 new_tc->SetOption(pair.first, pair.second); 323 new_tc->SetOption(pair.first, pair.second);
324 } 324 }
(...skipping 11 matching lines...) Expand all
336 336
337 TransportChannel* old_tc = rtcp_transport_channel_; 337 TransportChannel* old_tc = rtcp_transport_channel_;
338 if (!old_tc && !new_tc) { 338 if (!old_tc && !new_tc) {
339 // Nothing to do 339 // Nothing to do
340 return; 340 return;
341 } 341 }
342 ASSERT(old_tc != new_tc); 342 ASSERT(old_tc != new_tc);
343 343
344 if (old_tc) { 344 if (old_tc) {
345 DisconnectFromTransportChannel(old_tc); 345 DisconnectFromTransportChannel(old_tc);
346 transport_controller_->DestroyTransportChannel_w( 346 transport_controller_->DestroyTransportChannel_n(
347 transport_name_, cricket::ICE_CANDIDATE_COMPONENT_RTCP); 347 transport_name_, cricket::ICE_CANDIDATE_COMPONENT_RTCP);
348 } 348 }
349 349
350 rtcp_transport_channel_ = new_tc; 350 rtcp_transport_channel_ = new_tc;
351 351
352 if (new_tc) { 352 if (new_tc) {
353 RTC_CHECK(!(ShouldSetupDtlsSrtp_n() && srtp_filter_.IsActive())) 353 RTC_CHECK(!(ShouldSetupDtlsSrtp_n() && srtp_filter_.IsActive()))
354 << "Setting RTCP for DTLS/SRTP after SrtpFilter is active " 354 << "Setting RTCP for DTLS/SRTP after SrtpFilter is active "
355 << "should never happen."; 355 << "should never happen.";
356 ConnectToTransportChannel(new_tc); 356 ConnectToTransportChannel(new_tc);
(...skipping 1966 matching lines...) Expand 10 before | Expand all | Expand 10 after
2323 return data_channel_type_ == DCT_RTP && BaseChannel::ShouldSetupDtlsSrtp_n(); 2323 return data_channel_type_ == DCT_RTP && BaseChannel::ShouldSetupDtlsSrtp_n();
2324 } 2324 }
2325 2325
2326 void DataChannel::OnStreamClosedRemotely(uint32_t sid) { 2326 void DataChannel::OnStreamClosedRemotely(uint32_t sid) {
2327 rtc::TypedMessageData<uint32_t>* message = 2327 rtc::TypedMessageData<uint32_t>* message =
2328 new rtc::TypedMessageData<uint32_t>(sid); 2328 new rtc::TypedMessageData<uint32_t>(sid);
2329 signaling_thread()->Post(this, MSG_STREAMCLOSEDREMOTELY, message); 2329 signaling_thread()->Post(this, MSG_STREAMCLOSEDREMOTELY, message);
2330 } 2330 }
2331 2331
2332 } // namespace cricket 2332 } // namespace cricket
OLDNEW
« no previous file with comments | « webrtc/p2p/base/transportcontroller_unittest.cc ('k') | webrtc/pc/channel_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698