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

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

Issue 2614263002: Remove BaseChannel's dependency on TransportController. (Closed)
Patch Set: Fix the channel_unittests Created 3 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 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 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 template <class Codec> 154 template <class Codec>
155 void RtpSendParametersFromMediaDescription( 155 void RtpSendParametersFromMediaDescription(
156 const MediaContentDescriptionImpl<Codec>* desc, 156 const MediaContentDescriptionImpl<Codec>* desc,
157 RtpSendParameters<Codec>* send_params) { 157 RtpSendParameters<Codec>* send_params) {
158 RtpParametersFromMediaDescription(desc, send_params); 158 RtpParametersFromMediaDescription(desc, send_params);
159 send_params->max_bandwidth_bps = desc->bandwidth(); 159 send_params->max_bandwidth_bps = desc->bandwidth();
160 } 160 }
161 161
162 BaseChannel::BaseChannel(rtc::Thread* worker_thread, 162 BaseChannel::BaseChannel(rtc::Thread* worker_thread,
163 rtc::Thread* network_thread, 163 rtc::Thread* network_thread,
164 rtc::Thread* signaling_thread,
164 MediaChannel* media_channel, 165 MediaChannel* media_channel,
165 TransportController* transport_controller,
166 const std::string& content_name, 166 const std::string& content_name,
167 bool rtcp, 167 bool rtcp,
168 bool srtp_required) 168 bool srtp_required)
169 : worker_thread_(worker_thread), 169 : worker_thread_(worker_thread),
170 network_thread_(network_thread), 170 network_thread_(network_thread),
171 171 signaling_thread_(signaling_thread),
172 content_name_(content_name), 172 content_name_(content_name),
173
174 transport_controller_(transport_controller),
175 rtcp_enabled_(rtcp), 173 rtcp_enabled_(rtcp),
176 srtp_required_(srtp_required), 174 srtp_required_(srtp_required),
177 media_channel_(media_channel), 175 media_channel_(media_channel),
178 selected_candidate_pair_(nullptr) { 176 selected_candidate_pair_(nullptr) {
179 RTC_DCHECK(worker_thread_ == rtc::Thread::Current()); 177 RTC_DCHECK(worker_thread_ == rtc::Thread::Current());
180 if (transport_controller) {
181 RTC_DCHECK_EQ(network_thread, transport_controller->network_thread());
182 }
183 LOG(LS_INFO) << "Created channel for " << content_name; 178 LOG(LS_INFO) << "Created channel for " << content_name;
184 } 179 }
185 180
186 BaseChannel::~BaseChannel() { 181 BaseChannel::~BaseChannel() {
187 TRACE_EVENT0("webrtc", "BaseChannel::~BaseChannel"); 182 TRACE_EVENT0("webrtc", "BaseChannel::~BaseChannel");
188 RTC_DCHECK(worker_thread_ == rtc::Thread::Current()); 183 RTC_DCHECK(worker_thread_ == rtc::Thread::Current());
189 Deinit(); 184 Deinit();
190 StopConnectionMonitor(); 185 StopConnectionMonitor();
191 // Eats any outstanding messages or packets. 186 // Eats any outstanding messages or packets.
192 worker_thread_->Clear(&invoker_); 187 worker_thread_->Clear(&invoker_);
193 worker_thread_->Clear(this); 188 worker_thread_->Clear(this);
194 // We must destroy the media channel before the transport channel, otherwise 189 // We must destroy the media channel before the transport channel, otherwise
195 // the media channel may try to send on the dead transport channel. NULLing 190 // the media channel may try to send on the dead transport channel. NULLing
196 // is not an effective strategy since the sends will come on another thread. 191 // is not an effective strategy since the sends will come on another thread.
197 delete media_channel_; 192 delete media_channel_;
198 // Note that we don't just call SetTransportChannel_n(nullptr) because that 193 // Note that we don't just call SetTransportChannel_n(nullptr) because that
199 // would call a pure virtual method which we can't do from a destructor. 194 // would call a pure virtual method which we can't do from a destructor.
200 network_thread_->Invoke<void>( 195 network_thread_->Invoke<void>(
201 RTC_FROM_HERE, Bind(&BaseChannel::DestroyTransportChannels_n, this)); 196 RTC_FROM_HERE, Bind(&BaseChannel::DestroyTransportChannels_n, this));
202 LOG(LS_INFO) << "Destroyed channel"; 197 LOG(LS_INFO) << "Destroyed channel";
203 } 198 }
204 199
205 void BaseChannel::DisconnectTransportChannels_n() { 200 void BaseChannel::DisconnectTransportChannels_n() {
206 // Send any outstanding RTCP packets. 201 // Send any outstanding RTCP packets.
207 FlushRtcpMessages_n(); 202 FlushRtcpMessages_n();
208 203
209 // Stop signals from transport channels, but keep them alive because 204 // Stop signals from transport channels, but keep them alive because
210 // media_channel may use them from a different thread. 205 // media_channel may use them from a different thread.
211 if (transport_channel_) { 206 if (rtp_transport_) {
212 DisconnectFromTransportChannel(transport_channel_); 207 DisconnectFromTransportChannel(rtp_transport_);
213 } 208 }
214 if (rtcp_transport_channel_) { 209 if (rtcp_transport_) {
215 DisconnectFromTransportChannel(rtcp_transport_channel_); 210 DisconnectFromTransportChannel(rtcp_transport_);
216 } 211 }
217 212
218 // Clear pending read packets/messages. 213 // Clear pending read packets/messages.
219 network_thread_->Clear(&invoker_); 214 network_thread_->Clear(&invoker_);
220 network_thread_->Clear(this); 215 network_thread_->Clear(this);
221 } 216 }
222 217
223 void BaseChannel::DestroyTransportChannels_n() { 218 void BaseChannel::DestroyTransportChannels_n() {
224 if (transport_channel_) { 219 if (rtp_transport_) {
225 transport_controller_->DestroyTransportChannel_n( 220 SignalDestroyTransport(transport_name_,
226 transport_name_, cricket::ICE_CANDIDATE_COMPONENT_RTP); 221 cricket::ICE_CANDIDATE_COMPONENT_RTP);
227 } 222 }
228 if (rtcp_transport_channel_) { 223 if (rtcp_transport_) {
229 transport_controller_->DestroyTransportChannel_n( 224 SignalDestroyTransport(transport_name_,
230 transport_name_, cricket::ICE_CANDIDATE_COMPONENT_RTCP); 225 cricket::ICE_CANDIDATE_COMPONENT_RTCP);
231 } 226 }
232 // Clear pending send packets/messages. 227 // Clear pending send packets/messages.
233 network_thread_->Clear(&invoker_); 228 network_thread_->Clear(&invoker_);
234 network_thread_->Clear(this); 229 network_thread_->Clear(this);
235 } 230 }
236 231
237 bool BaseChannel::Init_w(const std::string* bundle_transport_name) { 232 bool BaseChannel::Init_w(TransportChannel* rtp_transport,
233 TransportChannel* rtcp_transport) {
238 if (!network_thread_->Invoke<bool>( 234 if (!network_thread_->Invoke<bool>(
239 RTC_FROM_HERE, 235 RTC_FROM_HERE, Bind(&BaseChannel::InitNetwork_n, this, rtp_transport,
240 Bind(&BaseChannel::InitNetwork_n, this, bundle_transport_name))) { 236 rtcp_transport))) {
241 return false; 237 return false;
242 } 238 }
243 239
244 // Both RTP and RTCP channels are set, we can call SetInterface on 240 // Both RTP and RTCP channels are set, we can call SetInterface on
245 // media channel and it can set network options. 241 // media channel and it can set network options.
246 RTC_DCHECK(worker_thread_->IsCurrent()); 242 RTC_DCHECK(worker_thread_->IsCurrent());
247 media_channel_->SetInterface(this); 243 media_channel_->SetInterface(this);
248 return true; 244 return true;
249 } 245 }
250 246
251 bool BaseChannel::InitNetwork_n(const std::string* bundle_transport_name) { 247 bool BaseChannel::InitNetwork_n(TransportChannel* rtp_transport,
248 TransportChannel* rtcp_transport) {
252 RTC_DCHECK(network_thread_->IsCurrent()); 249 RTC_DCHECK(network_thread_->IsCurrent());
253 const std::string& transport_name = 250 // const std::string& transport_name =
254 (bundle_transport_name ? *bundle_transport_name : content_name()); 251 // (bundle_transport_name ? *bundle_transport_name : content_name());
255 if (!SetTransport_n(transport_name)) { 252 if (!SetTransport_n(rtp_transport, rtcp_transport)) {
256 return false; 253 return false;
257 } 254 }
258 255
259 if (!SetDtlsSrtpCryptoSuites_n(transport_channel_, false)) { 256 if (!SetDtlsSrtpCryptoSuites_n(rtp_transport_, false)) {
260 return false; 257 return false;
261 } 258 }
262 if (rtcp_transport_channel_ && 259 if (rtcp_transport_ && !SetDtlsSrtpCryptoSuites_n(rtcp_transport_, true)) {
263 !SetDtlsSrtpCryptoSuites_n(rtcp_transport_channel_, true)) {
264 return false; 260 return false;
265 } 261 }
266 return true; 262 return true;
267 } 263 }
268 264
269 void BaseChannel::Deinit() { 265 void BaseChannel::Deinit() {
270 RTC_DCHECK(worker_thread_->IsCurrent()); 266 RTC_DCHECK(worker_thread_->IsCurrent());
271 media_channel_->SetInterface(NULL); 267 media_channel_->SetInterface(NULL);
272 // Packets arrive on the network thread, processing packets calls virtual 268 // Packets arrive on the network thread, processing packets calls virtual
273 // functions, so need to stop this process in Deinit that is called in 269 // functions, so need to stop this process in Deinit that is called in
274 // derived classes destructor. 270 // derived classes destructor.
275 network_thread_->Invoke<void>( 271 network_thread_->Invoke<void>(
276 RTC_FROM_HERE, Bind(&BaseChannel::DisconnectTransportChannels_n, this)); 272 RTC_FROM_HERE, Bind(&BaseChannel::DisconnectTransportChannels_n, this));
277 } 273 }
278 274
279 bool BaseChannel::SetTransport(const std::string& transport_name) { 275 bool BaseChannel::SetTransport(TransportChannel* rtp_transport,
276 TransportChannel* rtcp_transport) {
280 return network_thread_->Invoke<bool>( 277 return network_thread_->Invoke<bool>(
281 RTC_FROM_HERE, Bind(&BaseChannel::SetTransport_n, this, transport_name)); 278 RTC_FROM_HERE,
279 Bind(&BaseChannel::SetTransport_n, this, rtp_transport, rtcp_transport));
282 } 280 }
283 281
284 bool BaseChannel::SetTransport_n(const std::string& transport_name) { 282 bool BaseChannel::SetTransport_n(TransportChannel* rtp_transport,
283 TransportChannel* rtcp_transport) {
285 RTC_DCHECK(network_thread_->IsCurrent()); 284 RTC_DCHECK(network_thread_->IsCurrent());
285 if (!rtp_transport && rtcp_transport) {
286 LOG(LS_WARNING) << "Setting nullptr to RTP Transport and RTCP Transport.";
Taylor Brandstetter 2017/01/09 22:50:42 It seems like this should never happen. Change log
Zhi Huang 2017/01/12 03:47:46 Done.
287 return true;
288 }
286 289
287 if (transport_name == transport_name_) { 290 if (rtcp_transport) {
291 RTC_DCHECK(rtp_transport->transport_name() ==
292 rtcp_transport->transport_name());
Taylor Brandstetter 2017/01/09 22:50:42 Could also RTC_DCHECK that ShouldCreateRtcpTranspo
Zhi Huang 2017/01/12 03:47:46 Done.
293 }
294
295 if (rtp_transport->transport_name() == transport_name_) {
288 // Nothing to do if transport name isn't changing. 296 // Nothing to do if transport name isn't changing.
289 return true; 297 return true;
290 } 298 }
291 299
292 // When using DTLS-SRTP, we must reset the SrtpFilter every time the transport 300 // When using DTLS-SRTP, we must reset the SrtpFilter every time the transport
293 // changes and wait until the DTLS handshake is complete to set the newly 301 // changes and wait until the DTLS handshake is complete to set the newly
294 // negotiated parameters. 302 // negotiated parameters.
295 if (ShouldSetupDtlsSrtp_n()) { 303 if (ShouldSetupDtlsSrtp_n()) {
296 // Set |writable_| to false such that UpdateWritableState_w can set up 304 // Set |writable_| to false such that UpdateWritableState_w can set up
297 // DTLS-SRTP when |writable_| becomes true again. 305 // DTLS-SRTP when |writable_| becomes true again.
298 writable_ = false; 306 writable_ = false;
299 srtp_filter_.ResetParams(); 307 srtp_filter_.ResetParams();
300 } 308 }
301 309
302 // If this BaseChannel uses RTCP and we haven't fully negotiated RTCP mux, 310 // If this BaseChannel uses RTCP and we haven't fully negotiated RTCP mux,
303 // we need an RTCP channel. 311 // we need an RTCP channel.
304 if (rtcp_enabled_ && !rtcp_mux_filter_.IsFullyActive()) { 312 if (ShouldCreateRtcpTransport()) {
305 LOG(LS_INFO) << "Create RTCP TransportChannel for " << content_name() 313 LOG(LS_INFO) << "Create RTCP Transport for " << content_name() << " on "
Taylor Brandstetter 2017/01/09 22:50:42 Should update log statements; is now "setting" ins
Zhi Huang 2017/01/12 03:47:46 Done.
306 << " on " << transport_name << " transport "; 314 << transport_name() << " transport ";
307 SetTransportChannel_n( 315 SetTransportChannel_n(true, rtcp_transport);
308 true, transport_controller_->CreateTransportChannel_n( 316 if (!rtcp_transport_) {
309 transport_name, cricket::ICE_CANDIDATE_COMPONENT_RTCP));
310 if (!rtcp_transport_channel_) {
311 return false; 317 return false;
312 } 318 }
313 } 319 }
314 320
315 LOG(LS_INFO) << "Create non-RTCP TransportChannel for " << content_name() 321 LOG(LS_INFO) << "Create non-RTCP TransportChannel for " << content_name()
316 << " on " << transport_name << " transport "; 322 << " on " << transport_name() << " transport ";
317 SetTransportChannel_n( 323 SetTransportChannel_n(false, rtp_transport);
318 false, transport_controller_->CreateTransportChannel_n( 324 if (!rtp_transport_) {
319 transport_name, cricket::ICE_CANDIDATE_COMPONENT_RTP));
320 if (!transport_channel_) {
321 return false; 325 return false;
322 } 326 }
323 327
324 transport_name_ = transport_name; 328 transport_name_ = rtp_transport->transport_name();
325 329
326 // Update aggregate writable/ready-to-send state between RTP and RTCP upon 330 // Update aggregate writable/ready-to-send state between RTP and RTCP upon
327 // setting new transport channels. 331 // setting new transport channels.
328 UpdateWritableState_n(); 332 UpdateWritableState_n();
329 // We can only update ready-to-send after updating writability. 333 // We can only update ready-to-send after updating writability.
330 // 334 //
331 // On setting a new channel, assume it's ready to send if it's writable, 335 // On setting a new channel, assume it's ready to send if it's writable,
332 // because we have no way of knowing otherwise (the channel doesn't give us 336 // because we have no way of knowing otherwise (the channel doesn't give us
333 // "was last send successful?"). 337 // "was last send successful?").
334 // 338 //
335 // This won't always be accurate (the last SendPacket call from another 339 // This won't always be accurate (the last SendPacket call from another
336 // BaseChannel could have resulted in an error), but even so, we'll just 340 // BaseChannel could have resulted in an error), but even so, we'll just
337 // encounter the error again and update "ready to send" accordingly. 341 // encounter the error again and update "ready to send" accordingly.
342 SetTransportChannelReadyToSend(false,
343 rtp_transport_ && rtp_transport_->writable());
338 SetTransportChannelReadyToSend( 344 SetTransportChannelReadyToSend(
339 false, transport_channel_ && transport_channel_->writable()); 345 true, rtcp_transport_ && rtcp_transport_->writable());
340 SetTransportChannelReadyToSend(
341 true, rtcp_transport_channel_ && rtcp_transport_channel_->writable());
342 return true; 346 return true;
343 } 347 }
344 348
345 void BaseChannel::SetTransportChannel_n(bool rtcp, 349 void BaseChannel::SetTransportChannel_n(bool rtcp,
346 TransportChannel* new_channel) { 350 TransportChannel* new_transport) {
347 RTC_DCHECK(network_thread_->IsCurrent()); 351 RTC_DCHECK(network_thread_->IsCurrent());
348 TransportChannel*& old_channel = 352 TransportChannel*& old_transport = rtcp ? rtcp_transport_ : rtp_transport_;
349 rtcp ? rtcp_transport_channel_ : transport_channel_;
350 353
351 if (!old_channel && !new_channel) { 354 if (!old_transport && !new_transport) {
352 // Nothing to do. 355 // Nothing to do.
353 return; 356 return;
354 } 357 }
355 RTC_DCHECK(old_channel != new_channel); 358 RTC_DCHECK(old_transport != new_transport);
356 359
357 if (old_channel) { 360 if (old_transport) {
358 DisconnectFromTransportChannel(old_channel); 361 DisconnectFromTransportChannel(old_transport);
359 transport_controller_->DestroyTransportChannel_n( 362 SignalDestroyTransport(transport_name_,
360 transport_name_, rtcp ? cricket::ICE_CANDIDATE_COMPONENT_RTCP 363 rtcp ? cricket::ICE_CANDIDATE_COMPONENT_RTCP
361 : cricket::ICE_CANDIDATE_COMPONENT_RTP); 364 : cricket::ICE_CANDIDATE_COMPONENT_RTP);
362 } 365 }
363 366
364 old_channel = new_channel; 367 old_transport = new_transport;
365 368
366 if (new_channel) { 369 if (new_transport) {
367 if (rtcp) { 370 if (rtcp) {
368 RTC_CHECK(!(ShouldSetupDtlsSrtp_n() && srtp_filter_.IsActive())) 371 RTC_CHECK(!(ShouldSetupDtlsSrtp_n() && srtp_filter_.IsActive()))
369 << "Setting RTCP for DTLS/SRTP after SrtpFilter is active " 372 << "Setting RTCP for DTLS/SRTP after SrtpFilter is active "
370 << "should never happen."; 373 << "should never happen.";
371 } 374 }
372 ConnectToTransportChannel(new_channel); 375 ConnectToTransportChannel(new_transport);
373 auto& socket_options = rtcp ? rtcp_socket_options_ : socket_options_; 376 auto& socket_options = rtcp ? rtcp_socket_options_ : socket_options_;
374 for (const auto& pair : socket_options) { 377 for (const auto& pair : socket_options) {
375 new_channel->SetOption(pair.first, pair.second); 378 new_transport->SetOption(pair.first, pair.second);
376 } 379 }
377 } 380 }
378 } 381 }
379 382
380 void BaseChannel::ConnectToTransportChannel(TransportChannel* tc) { 383 void BaseChannel::ConnectToTransportChannel(TransportChannel* tc) {
381 RTC_DCHECK(network_thread_->IsCurrent()); 384 RTC_DCHECK(network_thread_->IsCurrent());
382 385
383 tc->SignalWritableState.connect(this, &BaseChannel::OnWritableState); 386 tc->SignalWritableState.connect(this, &BaseChannel::OnWritableState);
384 tc->SignalReadPacket.connect(this, &BaseChannel::OnPacketRead); 387 tc->SignalReadPacket.connect(this, &BaseChannel::OnPacketRead);
385 tc->SignalReadyToSend.connect(this, &BaseChannel::OnReadyToSend); 388 tc->SignalReadyToSend.connect(this, &BaseChannel::OnReadyToSend);
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
439 442
440 bool BaseChannel::SetRemoteContent(const MediaContentDescription* content, 443 bool BaseChannel::SetRemoteContent(const MediaContentDescription* content,
441 ContentAction action, 444 ContentAction action,
442 std::string* error_desc) { 445 std::string* error_desc) {
443 TRACE_EVENT0("webrtc", "BaseChannel::SetRemoteContent"); 446 TRACE_EVENT0("webrtc", "BaseChannel::SetRemoteContent");
444 return InvokeOnWorker(RTC_FROM_HERE, Bind(&BaseChannel::SetRemoteContent_w, 447 return InvokeOnWorker(RTC_FROM_HERE, Bind(&BaseChannel::SetRemoteContent_w,
445 this, content, action, error_desc)); 448 this, content, action, error_desc));
446 } 449 }
447 450
448 void BaseChannel::StartConnectionMonitor(int cms) { 451 void BaseChannel::StartConnectionMonitor(int cms) {
449 // We pass in the BaseChannel instead of the transport_channel_ 452 // We pass in the BaseChannel instead of the rtp_transport_
450 // because if the transport_channel_ changes, the ConnectionMonitor 453 // because if the rtp_transport_ changes, the ConnectionMonitor
451 // would be pointing to the wrong TransportChannel. 454 // would be pointing to the wrong TransportChannel.
452 // We pass in the network thread because on that thread connection monitor 455 // We pass in the network thread because on that thread connection monitor
453 // will call BaseChannel::GetConnectionStats which must be called on the 456 // will call BaseChannel::GetConnectionStats which must be called on the
454 // network thread. 457 // network thread.
455 connection_monitor_.reset( 458 connection_monitor_.reset(
456 new ConnectionMonitor(this, network_thread(), rtc::Thread::Current())); 459 new ConnectionMonitor(this, network_thread(), rtc::Thread::Current()));
457 connection_monitor_->SignalUpdate.connect( 460 connection_monitor_->SignalUpdate.connect(
458 this, &BaseChannel::OnConnectionMonitorUpdate); 461 this, &BaseChannel::OnConnectionMonitorUpdate);
459 connection_monitor_->Start(cms); 462 connection_monitor_->Start(cms);
460 } 463 }
461 464
462 void BaseChannel::StopConnectionMonitor() { 465 void BaseChannel::StopConnectionMonitor() {
463 if (connection_monitor_) { 466 if (connection_monitor_) {
464 connection_monitor_->Stop(); 467 connection_monitor_->Stop();
465 connection_monitor_.reset(); 468 connection_monitor_.reset();
466 } 469 }
467 } 470 }
468 471
469 bool BaseChannel::GetConnectionStats(ConnectionInfos* infos) { 472 bool BaseChannel::GetConnectionStats(ConnectionInfos* infos) {
470 RTC_DCHECK(network_thread_->IsCurrent()); 473 RTC_DCHECK(network_thread_->IsCurrent());
471 return transport_channel_->GetStats(infos); 474 return rtp_transport_->GetStats(infos);
475 }
476
477 bool BaseChannel::ShouldCreateRtcpTransport() {
Taylor Brandstetter 2017/01/09 22:50:42 nit: Would "NeedsRtcpTransport" be a more fitting
Zhi Huang 2017/01/12 03:47:46 Done.
478 return rtcp_enabled_ && !rtcp_mux_filter_.IsFullyActive();
472 } 479 }
473 480
474 bool BaseChannel::IsReadyToReceiveMedia_w() const { 481 bool BaseChannel::IsReadyToReceiveMedia_w() const {
475 // Receive data if we are enabled and have local content, 482 // Receive data if we are enabled and have local content,
476 return enabled() && IsReceiveContentDirection(local_content_direction_); 483 return enabled() && IsReceiveContentDirection(local_content_direction_);
477 } 484 }
478 485
479 bool BaseChannel::IsReadyToSendMedia_w() const { 486 bool BaseChannel::IsReadyToSendMedia_w() const {
480 // Need to access some state updated on the network thread. 487 // Need to access some state updated on the network thread.
481 return network_thread_->Invoke<bool>( 488 return network_thread_->Invoke<bool>(
(...skipping 25 matching lines...) Expand all
507 RTC_FROM_HERE, Bind(&BaseChannel::SetOption_n, this, type, opt, value)); 514 RTC_FROM_HERE, Bind(&BaseChannel::SetOption_n, this, type, opt, value));
508 } 515 }
509 516
510 int BaseChannel::SetOption_n(SocketType type, 517 int BaseChannel::SetOption_n(SocketType type,
511 rtc::Socket::Option opt, 518 rtc::Socket::Option opt,
512 int value) { 519 int value) {
513 RTC_DCHECK(network_thread_->IsCurrent()); 520 RTC_DCHECK(network_thread_->IsCurrent());
514 TransportChannel* channel = nullptr; 521 TransportChannel* channel = nullptr;
515 switch (type) { 522 switch (type) {
516 case ST_RTP: 523 case ST_RTP:
517 channel = transport_channel_; 524 channel = rtp_transport_;
518 socket_options_.push_back( 525 socket_options_.push_back(
519 std::pair<rtc::Socket::Option, int>(opt, value)); 526 std::pair<rtc::Socket::Option, int>(opt, value));
520 break; 527 break;
521 case ST_RTCP: 528 case ST_RTCP:
522 channel = rtcp_transport_channel_; 529 channel = rtcp_transport_;
523 rtcp_socket_options_.push_back( 530 rtcp_socket_options_.push_back(
524 std::pair<rtc::Socket::Option, int>(opt, value)); 531 std::pair<rtc::Socket::Option, int>(opt, value));
525 break; 532 break;
526 } 533 }
527 return channel ? channel->SetOption(opt, value) : -1; 534 return channel ? channel->SetOption(opt, value) : -1;
528 } 535 }
529 536
530 bool BaseChannel::SetCryptoOptions(const rtc::CryptoOptions& crypto_options) { 537 bool BaseChannel::SetCryptoOptions(const rtc::CryptoOptions& crypto_options) {
531 crypto_options_ = crypto_options; 538 crypto_options_ = crypto_options;
532 return true; 539 return true;
533 } 540 }
534 541
535 void BaseChannel::OnWritableState(rtc::PacketTransportInterface* transport) { 542 void BaseChannel::OnWritableState(rtc::PacketTransportInterface* transport) {
536 RTC_DCHECK(transport == transport_channel_ || 543 RTC_DCHECK(transport == rtp_transport_ || transport == rtcp_transport_);
537 transport == rtcp_transport_channel_);
538 RTC_DCHECK(network_thread_->IsCurrent()); 544 RTC_DCHECK(network_thread_->IsCurrent());
539 UpdateWritableState_n(); 545 UpdateWritableState_n();
540 } 546 }
541 547
542 void BaseChannel::OnPacketRead(rtc::PacketTransportInterface* transport, 548 void BaseChannel::OnPacketRead(rtc::PacketTransportInterface* transport,
543 const char* data, 549 const char* data,
544 size_t len, 550 size_t len,
545 const rtc::PacketTime& packet_time, 551 const rtc::PacketTime& packet_time,
546 int flags) { 552 int flags) {
547 TRACE_EVENT0("webrtc", "BaseChannel::OnPacketRead"); 553 TRACE_EVENT0("webrtc", "BaseChannel::OnPacketRead");
548 // OnPacketRead gets called from P2PSocket; now pass data to MediaEngine 554 // OnPacketRead gets called from P2PSocket; now pass data to MediaEngine
549 RTC_DCHECK(network_thread_->IsCurrent()); 555 RTC_DCHECK(network_thread_->IsCurrent());
550 556
551 // When using RTCP multiplexing we might get RTCP packets on the RTP 557 // When using RTCP multiplexing we might get RTCP packets on the RTP
552 // transport. We feed RTP traffic into the demuxer to determine if it is RTCP. 558 // transport. We feed RTP traffic into the demuxer to determine if it is RTCP.
553 bool rtcp = PacketIsRtcp(transport, data, len); 559 bool rtcp = PacketIsRtcp(transport, data, len);
554 rtc::CopyOnWriteBuffer packet(data, len); 560 rtc::CopyOnWriteBuffer packet(data, len);
555 HandlePacket(rtcp, &packet, packet_time); 561 HandlePacket(rtcp, &packet, packet_time);
556 } 562 }
557 563
558 void BaseChannel::OnReadyToSend(rtc::PacketTransportInterface* transport) { 564 void BaseChannel::OnReadyToSend(rtc::PacketTransportInterface* transport) {
559 RTC_DCHECK(transport == transport_channel_ || 565 RTC_DCHECK(transport == rtp_transport_ || transport == rtcp_transport_);
560 transport == rtcp_transport_channel_); 566 SetTransportChannelReadyToSend(transport == rtcp_transport_, true);
561 SetTransportChannelReadyToSend(transport == rtcp_transport_channel_, true);
562 } 567 }
563 568
564 void BaseChannel::OnDtlsState(TransportChannel* channel, 569 void BaseChannel::OnDtlsState(TransportChannel* channel,
565 DtlsTransportState state) { 570 DtlsTransportState state) {
566 if (!ShouldSetupDtlsSrtp_n()) { 571 if (!ShouldSetupDtlsSrtp_n()) {
567 return; 572 return;
568 } 573 }
569 574
570 // Reset the srtp filter if it's not the CONNECTED state. For the CONNECTED 575 // Reset the srtp filter if it's not the CONNECTED state. For the CONNECTED
571 // state, setting up DTLS-SRTP context is deferred to ChannelWritable_w to 576 // state, setting up DTLS-SRTP context is deferred to ChannelWritable_w to
572 // cover other scenarios like the whole channel is writable (not just this 577 // cover other scenarios like the whole channel is writable (not just this
573 // TransportChannel) or when TransportChannel is attached after DTLS is 578 // TransportChannel) or when TransportChannel is attached after DTLS is
574 // negotiated. 579 // negotiated.
575 if (state != DTLS_TRANSPORT_CONNECTED) { 580 if (state != DTLS_TRANSPORT_CONNECTED) {
576 srtp_filter_.ResetParams(); 581 srtp_filter_.ResetParams();
577 } 582 }
578 } 583 }
579 584
580 void BaseChannel::OnSelectedCandidatePairChanged( 585 void BaseChannel::OnSelectedCandidatePairChanged(
581 TransportChannel* channel, 586 TransportChannel* channel,
582 CandidatePairInterface* selected_candidate_pair, 587 CandidatePairInterface* selected_candidate_pair,
583 int last_sent_packet_id, 588 int last_sent_packet_id,
584 bool ready_to_send) { 589 bool ready_to_send) {
585 RTC_DCHECK(channel == transport_channel_ || 590 RTC_DCHECK(channel == rtp_transport_ || channel == rtcp_transport_);
586 channel == rtcp_transport_channel_);
587 RTC_DCHECK(network_thread_->IsCurrent()); 591 RTC_DCHECK(network_thread_->IsCurrent());
588 selected_candidate_pair_ = selected_candidate_pair; 592 selected_candidate_pair_ = selected_candidate_pair;
589 std::string transport_name = channel->transport_name(); 593 std::string transport_name = channel->transport_name();
590 rtc::NetworkRoute network_route; 594 rtc::NetworkRoute network_route;
591 if (selected_candidate_pair) { 595 if (selected_candidate_pair) {
592 network_route = rtc::NetworkRoute( 596 network_route = rtc::NetworkRoute(
593 ready_to_send, selected_candidate_pair->local_candidate().network_id(), 597 ready_to_send, selected_candidate_pair->local_candidate().network_id(),
594 selected_candidate_pair->remote_candidate().network_id(), 598 selected_candidate_pair->remote_candidate().network_id(),
595 last_sent_packet_id); 599 last_sent_packet_id);
596 600
597 UpdateTransportOverhead(); 601 UpdateTransportOverhead();
598 } 602 }
599 invoker_.AsyncInvoke<void>( 603 invoker_.AsyncInvoke<void>(
600 RTC_FROM_HERE, worker_thread_, 604 RTC_FROM_HERE, worker_thread_,
601 Bind(&MediaChannel::OnNetworkRouteChanged, media_channel_, transport_name, 605 Bind(&MediaChannel::OnNetworkRouteChanged, media_channel_, transport_name,
602 network_route)); 606 network_route));
603 } 607 }
604 608
605 void BaseChannel::SetTransportChannelReadyToSend(bool rtcp, bool ready) { 609 void BaseChannel::SetTransportChannelReadyToSend(bool rtcp, bool ready) {
606 RTC_DCHECK(network_thread_->IsCurrent()); 610 RTC_DCHECK(network_thread_->IsCurrent());
607 if (rtcp) { 611 if (rtcp) {
608 rtcp_ready_to_send_ = ready; 612 rtcp_ready_to_send_ = ready;
609 } else { 613 } else {
610 rtp_ready_to_send_ = ready; 614 rtp_ready_to_send_ = ready;
611 } 615 }
612 616
613 bool ready_to_send = 617 bool ready_to_send =
614 (rtp_ready_to_send_ && 618 (rtp_ready_to_send_ &&
615 // In the case of rtcp mux |rtcp_transport_channel_| will be null. 619 // In the case of rtcp mux |rtcp_transport_| will be null.
616 (rtcp_ready_to_send_ || !rtcp_transport_channel_)); 620 (rtcp_ready_to_send_ || !rtcp_transport_));
617 621
618 invoker_.AsyncInvoke<void>( 622 invoker_.AsyncInvoke<void>(
619 RTC_FROM_HERE, worker_thread_, 623 RTC_FROM_HERE, worker_thread_,
620 Bind(&MediaChannel::OnReadyToSend, media_channel_, ready_to_send)); 624 Bind(&MediaChannel::OnReadyToSend, media_channel_, ready_to_send));
621 } 625 }
622 626
623 bool BaseChannel::PacketIsRtcp(const rtc::PacketTransportInterface* transport, 627 bool BaseChannel::PacketIsRtcp(const rtc::PacketTransportInterface* transport,
624 const char* data, 628 const char* data,
625 size_t len) { 629 size_t len) {
626 return (transport == rtcp_transport_channel_ || 630 return (transport == rtcp_transport_ ||
627 rtcp_mux_filter_.DemuxRtcp(data, static_cast<int>(len))); 631 rtcp_mux_filter_.DemuxRtcp(data, static_cast<int>(len)));
628 } 632 }
629 633
630 bool BaseChannel::SendPacket(bool rtcp, 634 bool BaseChannel::SendPacket(bool rtcp,
631 rtc::CopyOnWriteBuffer* packet, 635 rtc::CopyOnWriteBuffer* packet,
632 const rtc::PacketOptions& options) { 636 const rtc::PacketOptions& options) {
633 // SendPacket gets called from MediaEngine, on a pacer or an encoder thread. 637 // SendPacket gets called from MediaEngine, on a pacer or an encoder thread.
634 // If the thread is not our network thread, we will post to our network 638 // If the thread is not our network thread, we will post to our network
635 // so that the real work happens on our network. This avoids us having to 639 // so that the real work happens on our network. This avoids us having to
636 // synchronize access to all the pieces of the send path, including 640 // synchronize access to all the pieces of the send path, including
637 // SRTP and the inner workings of the transport channels. 641 // SRTP and the inner workings of the transport channels.
638 // The only downside is that we can't return a proper failure code if 642 // The only downside is that we can't return a proper failure code if
639 // needed. Since UDP is unreliable anyway, this should be a non-issue. 643 // needed. Since UDP is unreliable anyway, this should be a non-issue.
640 if (!network_thread_->IsCurrent()) { 644 if (!network_thread_->IsCurrent()) {
641 // Avoid a copy by transferring the ownership of the packet data. 645 // Avoid a copy by transferring the ownership of the packet data.
642 int message_id = rtcp ? MSG_SEND_RTCP_PACKET : MSG_SEND_RTP_PACKET; 646 int message_id = rtcp ? MSG_SEND_RTCP_PACKET : MSG_SEND_RTP_PACKET;
643 SendPacketMessageData* data = new SendPacketMessageData; 647 SendPacketMessageData* data = new SendPacketMessageData;
644 data->packet = std::move(*packet); 648 data->packet = std::move(*packet);
645 data->options = options; 649 data->options = options;
646 network_thread_->Post(RTC_FROM_HERE, this, message_id, data); 650 network_thread_->Post(RTC_FROM_HERE, this, message_id, data);
647 return true; 651 return true;
648 } 652 }
649 TRACE_EVENT0("webrtc", "BaseChannel::SendPacket"); 653 TRACE_EVENT0("webrtc", "BaseChannel::SendPacket");
650 654
651 // Now that we are on the correct thread, ensure we have a place to send this 655 // Now that we are on the correct thread, ensure we have a place to send this
652 // packet before doing anything. (We might get RTCP packets that we don't 656 // packet before doing anything. (We might get RTCP packets that we don't
653 // intend to send.) If we've negotiated RTCP mux, send RTCP over the RTP 657 // intend to send.) If we've negotiated RTCP mux, send RTCP over the RTP
654 // transport. 658 // transport.
655 TransportChannel* channel = (!rtcp || rtcp_mux_filter_.IsActive()) ? 659 TransportChannel* channel =
656 transport_channel_ : rtcp_transport_channel_; 660 (!rtcp || rtcp_mux_filter_.IsActive()) ? rtp_transport_ : rtcp_transport_;
657 if (!channel || !channel->writable()) { 661 if (!channel || !channel->writable()) {
658 return false; 662 return false;
659 } 663 }
660 664
661 // Protect ourselves against crazy data. 665 // Protect ourselves against crazy data.
662 if (!ValidPacket(rtcp, packet)) { 666 if (!ValidPacket(rtcp, packet)) {
663 LOG(LS_ERROR) << "Dropping outgoing " << content_name_ << " " 667 LOG(LS_ERROR) << "Dropping outgoing " << content_name_ << " "
664 << PacketType(rtcp) 668 << PacketType(rtcp)
665 << " packet: wrong size=" << packet->size(); 669 << " packet: wrong size=" << packet->size();
666 return false; 670 return false;
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after
894 RTC_DCHECK(worker_thread_ == rtc::Thread::Current()); 898 RTC_DCHECK(worker_thread_ == rtc::Thread::Current());
895 if (!enabled_) 899 if (!enabled_)
896 return; 900 return;
897 901
898 LOG(LS_INFO) << "Channel disabled"; 902 LOG(LS_INFO) << "Channel disabled";
899 enabled_ = false; 903 enabled_ = false;
900 UpdateMediaSendRecvState_w(); 904 UpdateMediaSendRecvState_w();
901 } 905 }
902 906
903 void BaseChannel::UpdateWritableState_n() { 907 void BaseChannel::UpdateWritableState_n() {
904 if (transport_channel_ && transport_channel_->writable() && 908 if (rtp_transport_ && rtp_transport_->writable() &&
905 (!rtcp_transport_channel_ || rtcp_transport_channel_->writable())) { 909 (!rtcp_transport_ || rtcp_transport_->writable())) {
906 ChannelWritable_n(); 910 ChannelWritable_n();
907 } else { 911 } else {
908 ChannelNotWritable_n(); 912 ChannelNotWritable_n();
909 } 913 }
910 } 914 }
911 915
912 void BaseChannel::ChannelWritable_n() { 916 void BaseChannel::ChannelWritable_n() {
913 RTC_DCHECK(network_thread_->IsCurrent()); 917 RTC_DCHECK(network_thread_->IsCurrent());
914 if (writable_) { 918 if (writable_) {
915 return; 919 return;
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
950 if (!rtcp) { 954 if (!rtcp) {
951 GetSrtpCryptoSuites_n(&crypto_suites); 955 GetSrtpCryptoSuites_n(&crypto_suites);
952 } else { 956 } else {
953 GetDefaultSrtpCryptoSuites(crypto_options(), &crypto_suites); 957 GetDefaultSrtpCryptoSuites(crypto_options(), &crypto_suites);
954 } 958 }
955 return tc->SetSrtpCryptoSuites(crypto_suites); 959 return tc->SetSrtpCryptoSuites(crypto_suites);
956 } 960 }
957 961
958 bool BaseChannel::ShouldSetupDtlsSrtp_n() const { 962 bool BaseChannel::ShouldSetupDtlsSrtp_n() const {
959 // Since DTLS is applied to all channels, checking RTP should be enough. 963 // Since DTLS is applied to all channels, checking RTP should be enough.
960 return transport_channel_ && transport_channel_->IsDtlsActive(); 964 return rtp_transport_ && rtp_transport_->IsDtlsActive();
961 } 965 }
962 966
963 // This function returns true if either DTLS-SRTP is not in use 967 // This function returns true if either DTLS-SRTP is not in use
964 // *or* DTLS-SRTP is successfully set up. 968 // *or* DTLS-SRTP is successfully set up.
965 bool BaseChannel::SetupDtlsSrtp_n(bool rtcp_channel) { 969 bool BaseChannel::SetupDtlsSrtp_n(bool rtcp_channel) {
966 RTC_DCHECK(network_thread_->IsCurrent()); 970 RTC_DCHECK(network_thread_->IsCurrent());
967 bool ret = false; 971 bool ret = false;
968 972
969 TransportChannel* channel = 973 TransportChannel* channel = rtcp_channel ? rtcp_transport_ : rtp_transport_;
970 rtcp_channel ? rtcp_transport_channel_ : transport_channel_;
971 974
972 RTC_DCHECK(channel->IsDtlsActive()); 975 RTC_DCHECK(channel->IsDtlsActive());
973 976
974 int selected_crypto_suite; 977 int selected_crypto_suite;
975 978
976 if (!channel->GetSrtpCryptoSuite(&selected_crypto_suite)) { 979 if (!channel->GetSrtpCryptoSuite(&selected_crypto_suite)) {
977 LOG(LS_ERROR) << "No DTLS-SRTP selected crypto suite"; 980 LOG(LS_ERROR) << "No DTLS-SRTP selected crypto suite";
978 return false; 981 return false;
979 } 982 }
980 983
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
1058 1061
1059 if (!ShouldSetupDtlsSrtp_n()) { 1062 if (!ShouldSetupDtlsSrtp_n()) {
1060 return; 1063 return;
1061 } 1064 }
1062 1065
1063 if (!SetupDtlsSrtp_n(false)) { 1066 if (!SetupDtlsSrtp_n(false)) {
1064 SignalDtlsSetupFailure_n(false); 1067 SignalDtlsSetupFailure_n(false);
1065 return; 1068 return;
1066 } 1069 }
1067 1070
1068 if (rtcp_transport_channel_) { 1071 if (rtcp_transport_) {
1069 if (!SetupDtlsSrtp_n(true)) { 1072 if (!SetupDtlsSrtp_n(true)) {
1070 SignalDtlsSetupFailure_n(true); 1073 SignalDtlsSetupFailure_n(true);
1071 return; 1074 return;
1072 } 1075 }
1073 } 1076 }
1074 } 1077 }
1075 1078
1076 void BaseChannel::ChannelNotWritable_n() { 1079 void BaseChannel::ChannelNotWritable_n() {
1077 RTC_DCHECK(network_thread_->IsCurrent()); 1080 RTC_DCHECK(network_thread_->IsCurrent());
1078 if (!writable_) 1081 if (!writable_)
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
1115 } 1118 }
1116 1119
1117 return true; 1120 return true;
1118 } 1121 }
1119 1122
1120 // |dtls| will be set to true if DTLS is active for transport channel and 1123 // |dtls| will be set to true if DTLS is active for transport channel and
1121 // crypto is empty. 1124 // crypto is empty.
1122 bool BaseChannel::CheckSrtpConfig_n(const std::vector<CryptoParams>& cryptos, 1125 bool BaseChannel::CheckSrtpConfig_n(const std::vector<CryptoParams>& cryptos,
1123 bool* dtls, 1126 bool* dtls,
1124 std::string* error_desc) { 1127 std::string* error_desc) {
1125 *dtls = transport_channel_->IsDtlsActive(); 1128 *dtls = rtp_transport_->IsDtlsActive();
1126 if (*dtls && !cryptos.empty()) { 1129 if (*dtls && !cryptos.empty()) {
1127 SafeSetError("Cryptos must be empty when DTLS is active.", error_desc); 1130 SafeSetError("Cryptos must be empty when DTLS is active.", error_desc);
1128 return false; 1131 return false;
1129 } 1132 }
1130 return true; 1133 return true;
1131 } 1134 }
1132 1135
1133 bool BaseChannel::SetSrtp_n(const std::vector<CryptoParams>& cryptos, 1136 bool BaseChannel::SetSrtp_n(const std::vector<CryptoParams>& cryptos,
1134 ContentAction action, 1137 ContentAction action,
1135 ContentSource src, 1138 ContentSource src,
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
1228 } 1231 }
1229 if (!ret) { 1232 if (!ret) {
1230 SafeSetError("Failed to setup RTCP mux filter.", error_desc); 1233 SafeSetError("Failed to setup RTCP mux filter.", error_desc);
1231 return false; 1234 return false;
1232 } 1235 }
1233 // |rtcp_mux_filter_| can be active if |action| is CA_PRANSWER or 1236 // |rtcp_mux_filter_| can be active if |action| is CA_PRANSWER or
1234 // CA_ANSWER, but we only want to tear down the RTCP transport channel if we 1237 // CA_ANSWER, but we only want to tear down the RTCP transport channel if we
1235 // received a final answer. 1238 // received a final answer.
1236 if (rtcp_mux_filter_.IsActive()) { 1239 if (rtcp_mux_filter_.IsActive()) {
1237 // If the RTP transport is already writable, then so are we. 1240 // If the RTP transport is already writable, then so are we.
1238 if (transport_channel_->writable()) { 1241 if (rtp_transport_->writable()) {
1239 ChannelWritable_n(); 1242 ChannelWritable_n();
1240 } 1243 }
1241 } 1244 }
1242 1245
1243 return true; 1246 return true;
1244 } 1247 }
1245 1248
1246 bool BaseChannel::AddRecvStream_w(const StreamParams& sp) { 1249 bool BaseChannel::AddRecvStream_w(const StreamParams& sp) {
1247 RTC_DCHECK(worker_thread() == rtc::Thread::Current()); 1250 RTC_DCHECK(worker_thread() == rtc::Thread::Current());
1248 return media_channel()->AddRecvStream(sp); 1251 return media_channel()->AddRecvStream(sp);
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
1463 rtc::Bind(&BaseChannel::SignalSentPacket_w, this, sent_packet)); 1466 rtc::Bind(&BaseChannel::SignalSentPacket_w, this, sent_packet));
1464 } 1467 }
1465 1468
1466 void BaseChannel::SignalSentPacket_w(const rtc::SentPacket& sent_packet) { 1469 void BaseChannel::SignalSentPacket_w(const rtc::SentPacket& sent_packet) {
1467 RTC_DCHECK(worker_thread_->IsCurrent()); 1470 RTC_DCHECK(worker_thread_->IsCurrent());
1468 SignalSentPacket(sent_packet); 1471 SignalSentPacket(sent_packet);
1469 } 1472 }
1470 1473
1471 VoiceChannel::VoiceChannel(rtc::Thread* worker_thread, 1474 VoiceChannel::VoiceChannel(rtc::Thread* worker_thread,
1472 rtc::Thread* network_thread, 1475 rtc::Thread* network_thread,
1476 rtc::Thread* signaling_thread,
1473 MediaEngineInterface* media_engine, 1477 MediaEngineInterface* media_engine,
1474 VoiceMediaChannel* media_channel, 1478 VoiceMediaChannel* media_channel,
1475 TransportController* transport_controller,
1476 const std::string& content_name, 1479 const std::string& content_name,
1477 bool rtcp, 1480 bool rtcp,
1478 bool srtp_required) 1481 bool srtp_required)
1479 : BaseChannel(worker_thread, 1482 : BaseChannel(worker_thread,
1480 network_thread, 1483 network_thread,
1484 signaling_thread,
1481 media_channel, 1485 media_channel,
1482 transport_controller,
1483 content_name, 1486 content_name,
1484 rtcp, 1487 rtcp,
1485 srtp_required), 1488 srtp_required),
1486 media_engine_(media_engine), 1489 media_engine_(media_engine),
1487 received_media_(false) {} 1490 received_media_(false) {}
1488 1491
1489 VoiceChannel::~VoiceChannel() { 1492 VoiceChannel::~VoiceChannel() {
1490 TRACE_EVENT0("webrtc", "VoiceChannel::~VoiceChannel"); 1493 TRACE_EVENT0("webrtc", "VoiceChannel::~VoiceChannel");
1491 StopAudioMonitor(); 1494 StopAudioMonitor();
1492 StopMediaMonitor(); 1495 StopMediaMonitor();
1493 // this can't be done in the base class, since it calls a virtual 1496 // this can't be done in the base class, since it calls a virtual
1494 DisableMedia_w(); 1497 DisableMedia_w();
1495 Deinit(); 1498 Deinit();
1496 } 1499 }
1497 1500
1498 bool VoiceChannel::Init_w(const std::string* bundle_transport_name) { 1501 bool VoiceChannel::Init_w(TransportChannel* rtp_transport,
1499 if (!BaseChannel::Init_w(bundle_transport_name)) { 1502 TransportChannel* rtcp_transport) {
1500 return false; 1503 return BaseChannel::Init_w(rtp_transport, rtcp_transport);
1501 }
1502 return true;
1503 } 1504 }
1504 1505
1505 bool VoiceChannel::SetAudioSend(uint32_t ssrc, 1506 bool VoiceChannel::SetAudioSend(uint32_t ssrc,
1506 bool enable, 1507 bool enable,
1507 const AudioOptions* options, 1508 const AudioOptions* options,
1508 AudioSource* source) { 1509 AudioSource* source) {
1509 return InvokeOnWorker(RTC_FROM_HERE, 1510 return InvokeOnWorker(RTC_FROM_HERE,
1510 Bind(&VoiceMediaChannel::SetAudioSend, media_channel(), 1511 Bind(&VoiceMediaChannel::SetAudioSend, media_channel(),
1511 ssrc, enable, options, source)); 1512 ssrc, enable, options, source));
1512 } 1513 }
(...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after
1879 SignalAudioMonitor(this, info); 1880 SignalAudioMonitor(this, info);
1880 } 1881 }
1881 1882
1882 void VoiceChannel::GetSrtpCryptoSuites_n( 1883 void VoiceChannel::GetSrtpCryptoSuites_n(
1883 std::vector<int>* crypto_suites) const { 1884 std::vector<int>* crypto_suites) const {
1884 GetSupportedAudioCryptoSuites(crypto_options(), crypto_suites); 1885 GetSupportedAudioCryptoSuites(crypto_options(), crypto_suites);
1885 } 1886 }
1886 1887
1887 VideoChannel::VideoChannel(rtc::Thread* worker_thread, 1888 VideoChannel::VideoChannel(rtc::Thread* worker_thread,
1888 rtc::Thread* network_thread, 1889 rtc::Thread* network_thread,
1890 rtc::Thread* signaling_thread,
1889 VideoMediaChannel* media_channel, 1891 VideoMediaChannel* media_channel,
1890 TransportController* transport_controller,
1891 const std::string& content_name, 1892 const std::string& content_name,
1892 bool rtcp, 1893 bool rtcp,
1893 bool srtp_required) 1894 bool srtp_required)
1894 : BaseChannel(worker_thread, 1895 : BaseChannel(worker_thread,
1895 network_thread, 1896 network_thread,
1897 signaling_thread,
1896 media_channel, 1898 media_channel,
1897 transport_controller,
1898 content_name, 1899 content_name,
1899 rtcp, 1900 rtcp,
1900 srtp_required) {} 1901 srtp_required) {}
1901 1902
1902 bool VideoChannel::Init_w(const std::string* bundle_transport_name) { 1903 bool VideoChannel::Init_w(TransportChannel* rtp_transport,
1903 if (!BaseChannel::Init_w(bundle_transport_name)) { 1904 TransportChannel* rtcp_transport) {
1904 return false; 1905 return BaseChannel::Init_w(rtp_transport, rtcp_transport);
1905 }
1906 return true;
1907 } 1906 }
1908 1907
1909 VideoChannel::~VideoChannel() { 1908 VideoChannel::~VideoChannel() {
1910 TRACE_EVENT0("webrtc", "VideoChannel::~VideoChannel"); 1909 TRACE_EVENT0("webrtc", "VideoChannel::~VideoChannel");
1911 StopMediaMonitor(); 1910 StopMediaMonitor();
1912 // this can't be done in the base class, since it calls a virtual 1911 // this can't be done in the base class, since it calls a virtual
1913 DisableMedia_w(); 1912 DisableMedia_w();
1914 1913
1915 Deinit(); 1914 Deinit();
1916 } 1915 }
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after
2142 SignalMediaMonitor(this, info); 2141 SignalMediaMonitor(this, info);
2143 } 2142 }
2144 2143
2145 void VideoChannel::GetSrtpCryptoSuites_n( 2144 void VideoChannel::GetSrtpCryptoSuites_n(
2146 std::vector<int>* crypto_suites) const { 2145 std::vector<int>* crypto_suites) const {
2147 GetSupportedVideoCryptoSuites(crypto_options(), crypto_suites); 2146 GetSupportedVideoCryptoSuites(crypto_options(), crypto_suites);
2148 } 2147 }
2149 2148
2150 DataChannel::DataChannel(rtc::Thread* worker_thread, 2149 DataChannel::DataChannel(rtc::Thread* worker_thread,
2151 rtc::Thread* network_thread, 2150 rtc::Thread* network_thread,
2151 rtc::Thread* signaling_thread,
2152 DataMediaChannel* media_channel, 2152 DataMediaChannel* media_channel,
2153 TransportController* transport_controller,
2154 const std::string& content_name, 2153 const std::string& content_name,
2155 bool rtcp, 2154 bool rtcp,
2156 bool srtp_required) 2155 bool srtp_required)
2157 : BaseChannel(worker_thread, 2156 : BaseChannel(worker_thread,
2158 network_thread, 2157 network_thread,
2158 signaling_thread,
2159 media_channel, 2159 media_channel,
2160 transport_controller,
2161 content_name, 2160 content_name,
2162 rtcp, 2161 rtcp,
2163 srtp_required), 2162 srtp_required),
2164 data_channel_type_(cricket::DCT_NONE), 2163 data_channel_type_(cricket::DCT_NONE),
2165 ready_to_send_data_(false) {} 2164 ready_to_send_data_(false) {}
2166 2165
2167 DataChannel::~DataChannel() { 2166 DataChannel::~DataChannel() {
2168 TRACE_EVENT0("webrtc", "DataChannel::~DataChannel"); 2167 TRACE_EVENT0("webrtc", "DataChannel::~DataChannel");
2169 StopMediaMonitor(); 2168 StopMediaMonitor();
2170 // this can't be done in the base class, since it calls a virtual 2169 // this can't be done in the base class, since it calls a virtual
2171 DisableMedia_w(); 2170 DisableMedia_w();
2172 2171
2173 Deinit(); 2172 Deinit();
2174 } 2173 }
2175 2174
2176 bool DataChannel::Init_w(const std::string* bundle_transport_name) { 2175 bool DataChannel::Init_w(TransportChannel* rtp_transport,
2177 if (!BaseChannel::Init_w(bundle_transport_name)) { 2176 TransportChannel* rtcp_transport) {
2177 if (!BaseChannel::Init_w(rtp_transport, rtcp_transport)) {
2178 return false; 2178 return false;
2179 } 2179 }
2180 media_channel()->SignalDataReceived.connect( 2180 media_channel()->SignalDataReceived.connect(
2181 this, &DataChannel::OnDataReceived); 2181 this, &DataChannel::OnDataReceived);
2182 media_channel()->SignalReadyToSend.connect( 2182 media_channel()->SignalReadyToSend.connect(
2183 this, &DataChannel::OnDataChannelReadyToSend); 2183 this, &DataChannel::OnDataChannelReadyToSend);
2184 media_channel()->SignalStreamClosedRemotely.connect( 2184 media_channel()->SignalStreamClosedRemotely.connect(
2185 this, &DataChannel::OnStreamClosedRemotely); 2185 this, &DataChannel::OnStreamClosedRemotely);
2186 return true; 2186 return true;
2187 } 2187 }
(...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after
2467 } 2467 }
2468 2468
2469 void DataChannel::OnStreamClosedRemotely(uint32_t sid) { 2469 void DataChannel::OnStreamClosedRemotely(uint32_t sid) {
2470 rtc::TypedMessageData<uint32_t>* message = 2470 rtc::TypedMessageData<uint32_t>* message =
2471 new rtc::TypedMessageData<uint32_t>(sid); 2471 new rtc::TypedMessageData<uint32_t>(sid);
2472 signaling_thread()->Post(RTC_FROM_HERE, this, MSG_STREAMCLOSEDREMOTELY, 2472 signaling_thread()->Post(RTC_FROM_HERE, this, MSG_STREAMCLOSEDREMOTELY,
2473 message); 2473 message);
2474 } 2474 }
2475 2475
2476 } // namespace cricket 2476 } // namespace cricket
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698