OLD | NEW |
---|---|
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 |
11 #include <utility> | 11 #include <utility> |
12 | 12 |
13 #include "webrtc/pc/channel.h" | 13 #include "webrtc/pc/channel.h" |
14 | 14 |
15 #include "webrtc/audio_sink.h" | 15 #include "webrtc/audio_sink.h" |
16 #include "webrtc/base/bind.h" | 16 #include "webrtc/base/bind.h" |
17 #include "webrtc/base/byteorder.h" | 17 #include "webrtc/base/byteorder.h" |
18 #include "webrtc/base/checks.h" | |
18 #include "webrtc/base/common.h" | 19 #include "webrtc/base/common.h" |
19 #include "webrtc/base/copyonwritebuffer.h" | 20 #include "webrtc/base/copyonwritebuffer.h" |
20 #include "webrtc/base/dscp.h" | 21 #include "webrtc/base/dscp.h" |
21 #include "webrtc/base/logging.h" | 22 #include "webrtc/base/logging.h" |
22 #include "webrtc/base/networkroute.h" | 23 #include "webrtc/base/networkroute.h" |
23 #include "webrtc/base/trace_event.h" | 24 #include "webrtc/base/trace_event.h" |
24 #include "webrtc/media/base/mediaconstants.h" | 25 #include "webrtc/media/base/mediaconstants.h" |
25 #include "webrtc/media/base/rtputils.h" | 26 #include "webrtc/media/base/rtputils.h" |
26 #include "webrtc/p2p/base/transportchannel.h" | 27 #include "webrtc/p2p/base/transportchannel.h" |
27 #include "webrtc/pc/channelmanager.h" | 28 #include "webrtc/pc/channelmanager.h" |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
164 const std::string& content_name, | 165 const std::string& content_name, |
165 bool rtcp) | 166 bool rtcp) |
166 : worker_thread_(worker_thread), | 167 : worker_thread_(worker_thread), |
167 network_thread_(network_thread), | 168 network_thread_(network_thread), |
168 | 169 |
169 content_name_(content_name), | 170 content_name_(content_name), |
170 | 171 |
171 transport_controller_(transport_controller), | 172 transport_controller_(transport_controller), |
172 rtcp_enabled_(rtcp), | 173 rtcp_enabled_(rtcp), |
173 media_channel_(media_channel) { | 174 media_channel_(media_channel) { |
174 ASSERT(worker_thread_ == rtc::Thread::Current()); | 175 RTC_DCHECK(worker_thread_ == rtc::Thread::Current()); |
175 if (transport_controller) { | 176 if (transport_controller) { |
176 RTC_DCHECK_EQ(network_thread, transport_controller->network_thread()); | 177 RTC_DCHECK_EQ(network_thread, transport_controller->network_thread()); |
177 } | 178 } |
178 LOG(LS_INFO) << "Created channel for " << content_name; | 179 LOG(LS_INFO) << "Created channel for " << content_name; |
179 } | 180 } |
180 | 181 |
181 BaseChannel::~BaseChannel() { | 182 BaseChannel::~BaseChannel() { |
182 TRACE_EVENT0("webrtc", "BaseChannel::~BaseChannel"); | 183 TRACE_EVENT0("webrtc", "BaseChannel::~BaseChannel"); |
183 ASSERT(worker_thread_ == rtc::Thread::Current()); | 184 RTC_DCHECK(worker_thread_ == rtc::Thread::Current()); |
184 Deinit(); | 185 Deinit(); |
185 StopConnectionMonitor(); | 186 StopConnectionMonitor(); |
186 // Eats any outstanding messages or packets. | 187 // Eats any outstanding messages or packets. |
187 worker_thread_->Clear(&invoker_); | 188 worker_thread_->Clear(&invoker_); |
188 worker_thread_->Clear(this); | 189 worker_thread_->Clear(this); |
189 // We must destroy the media channel before the transport channel, otherwise | 190 // We must destroy the media channel before the transport channel, otherwise |
190 // the media channel may try to send on the dead transport channel. NULLing | 191 // the media channel may try to send on the dead transport channel. NULLing |
191 // is not an effective strategy since the sends will come on another thread. | 192 // is not an effective strategy since the sends will come on another thread. |
192 delete media_channel_; | 193 delete media_channel_; |
193 // Note that we don't just call SetTransportChannel_n(nullptr) because that | 194 // Note that we don't just call SetTransportChannel_n(nullptr) because that |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
273 | 274 |
274 bool BaseChannel::SetTransport(const std::string& transport_name) { | 275 bool BaseChannel::SetTransport(const std::string& transport_name) { |
275 return network_thread_->Invoke<bool>( | 276 return network_thread_->Invoke<bool>( |
276 RTC_FROM_HERE, Bind(&BaseChannel::SetTransport_n, this, transport_name)); | 277 RTC_FROM_HERE, Bind(&BaseChannel::SetTransport_n, this, transport_name)); |
277 } | 278 } |
278 | 279 |
279 bool BaseChannel::SetTransport_n(const std::string& transport_name) { | 280 bool BaseChannel::SetTransport_n(const std::string& transport_name) { |
280 RTC_DCHECK(network_thread_->IsCurrent()); | 281 RTC_DCHECK(network_thread_->IsCurrent()); |
281 | 282 |
282 if (transport_name == transport_name_) { | 283 if (transport_name == transport_name_) { |
283 // Nothing to do if transport name isn't changing | 284 // Nothing to do if transport name isn't changing. |
284 return true; | 285 return true; |
285 } | 286 } |
286 | 287 |
287 // When using DTLS-SRTP, we must reset the SrtpFilter every time the transport | 288 // When using DTLS-SRTP, we must reset the SrtpFilter every time the transport |
288 // changes and wait until the DTLS handshake is complete to set the newly | 289 // changes and wait until the DTLS handshake is complete to set the newly |
289 // negotiated parameters. | 290 // negotiated parameters. |
290 if (ShouldSetupDtlsSrtp_n()) { | 291 if (ShouldSetupDtlsSrtp_n()) { |
291 // Set |writable_| to false such that UpdateWritableState_w can set up | 292 // Set |writable_| to false such that UpdateWritableState_w can set up |
292 // DTLS-SRTP when the writable_ becomes true again. | 293 // DTLS-SRTP when |writable_| becomes true again. |
293 writable_ = false; | 294 writable_ = false; |
294 srtp_filter_.ResetParams(); | 295 srtp_filter_.ResetParams(); |
295 } | 296 } |
296 | 297 |
297 // If this BaseChannel uses RTCP and we haven't fully negotiated RTCP mux, | 298 // If this BaseChannel uses RTCP and we haven't fully negotiated RTCP mux, |
298 // we need an RTCP channel. | 299 // we need an RTCP channel. |
299 if (rtcp_enabled_ && !rtcp_mux_filter_.IsFullyActive()) { | 300 if (rtcp_enabled_ && !rtcp_mux_filter_.IsFullyActive()) { |
300 LOG(LS_INFO) << "Create RTCP TransportChannel for " << content_name() | 301 LOG(LS_INFO) << "Create RTCP TransportChannel for " << content_name() |
301 << " on " << transport_name << " transport "; | 302 << " on " << transport_name << " transport "; |
302 // TODO(deadbeef): Remove this grossness when we remove non-muxed RTCP. | 303 // TODO(deadbeef): Remove this grossness when we remove non-muxed RTCP. |
(...skipping 10 matching lines...) Expand all Loading... | |
313 SetTransportChannel_n(transport_controller_->CreateTransportChannel_n( | 314 SetTransportChannel_n(transport_controller_->CreateTransportChannel_n( |
314 transport_name, cricket::ICE_CANDIDATE_COMPONENT_RTP)); | 315 transport_name, cricket::ICE_CANDIDATE_COMPONENT_RTP)); |
315 if (!transport_channel_) { | 316 if (!transport_channel_) { |
316 return false; | 317 return false; |
317 } | 318 } |
318 | 319 |
319 // TODO(deadbeef): Remove this grossness when we remove non-muxed RTCP. | 320 // TODO(deadbeef): Remove this grossness when we remove non-muxed RTCP. |
320 if (rtcp_transport_channel_) { | 321 if (rtcp_transport_channel_) { |
321 // We can only update the RTCP ready to send after set_transport_channel has | 322 // We can only update the RTCP ready to send after set_transport_channel has |
322 // handled channel writability. | 323 // handled channel writability. |
323 SetReadyToSend(true, rtcp_transport_channel_->writable()); | 324 SetTransportChannelReadyToSend(true, rtcp_transport_channel_->writable()); |
324 } | 325 } |
325 transport_name_ = transport_name; | 326 transport_name_ = transport_name; |
326 return true; | 327 return true; |
327 } | 328 } |
328 | 329 |
329 void BaseChannel::SetTransportChannel_n(TransportChannel* new_tc) { | 330 void BaseChannel::SetTransportChannel_n(TransportChannel* new_tc) { |
330 RTC_DCHECK(network_thread_->IsCurrent()); | 331 RTC_DCHECK(network_thread_->IsCurrent()); |
331 | 332 |
332 TransportChannel* old_tc = transport_channel_; | 333 TransportChannel* old_tc = transport_channel_; |
333 if (!old_tc && !new_tc) { | 334 if (!old_tc && !new_tc) { |
334 // Nothing to do | 335 // Nothing to do. |
335 return; | 336 return; |
336 } | 337 } |
337 ASSERT(old_tc != new_tc); | 338 RTC_DCHECK(old_tc != new_tc); |
338 | 339 |
339 if (old_tc) { | 340 if (old_tc) { |
340 DisconnectFromTransportChannel(old_tc); | 341 DisconnectFromTransportChannel(old_tc); |
341 transport_controller_->DestroyTransportChannel_n( | 342 transport_controller_->DestroyTransportChannel_n( |
342 transport_name_, cricket::ICE_CANDIDATE_COMPONENT_RTP); | 343 transport_name_, cricket::ICE_CANDIDATE_COMPONENT_RTP); |
343 } | 344 } |
344 | 345 |
345 transport_channel_ = new_tc; | 346 transport_channel_ = new_tc; |
346 | 347 |
347 if (new_tc) { | 348 if (new_tc) { |
348 ConnectToTransportChannel(new_tc); | 349 ConnectToTransportChannel(new_tc); |
349 for (const auto& pair : socket_options_) { | 350 for (const auto& pair : socket_options_) { |
350 new_tc->SetOption(pair.first, pair.second); | 351 new_tc->SetOption(pair.first, pair.second); |
351 } | 352 } |
352 } | 353 } |
353 | 354 |
354 // Update aggregate writable/ready-to-send state between RTP and RTCP upon | 355 // Update aggregate writable/ready-to-send state between RTP and RTCP upon |
355 // setting new channel | 356 // setting new transport channels. |
356 UpdateWritableState_n(); | 357 UpdateWritableState_n(); |
357 SetReadyToSend(false, new_tc && new_tc->writable()); | 358 // On setting a new channel, assume it's ready to send if it's writable, |
359 // because we have no way of knowing otherwise (the channel doesn't give us | |
360 // "was last send successful?"). | |
361 // | |
362 // This won't always be accurate (the last SendPacket call from another | |
363 // BaseChannel could have resulted in an error), but even so, we'll just | |
364 // encounter the error again and update "ready to send" accordingly. | |
365 SetTransportChannelReadyToSend(false, new_tc && new_tc->writable()); | |
358 } | 366 } |
359 | 367 |
360 void BaseChannel::SetRtcpTransportChannel_n(TransportChannel* new_tc, | 368 void BaseChannel::SetRtcpTransportChannel_n(TransportChannel* new_tc, |
361 bool update_writablity) { | 369 bool update_writablity) { |
362 RTC_DCHECK(network_thread_->IsCurrent()); | 370 RTC_DCHECK(network_thread_->IsCurrent()); |
363 | 371 |
364 TransportChannel* old_tc = rtcp_transport_channel_; | 372 TransportChannel* old_tc = rtcp_transport_channel_; |
365 if (!old_tc && !new_tc) { | 373 if (!old_tc && !new_tc) { |
366 // Nothing to do | 374 // Nothing to do. |
367 return; | 375 return; |
368 } | 376 } |
369 ASSERT(old_tc != new_tc); | 377 RTC_DCHECK(old_tc != new_tc); |
370 | 378 |
371 if (old_tc) { | 379 if (old_tc) { |
372 DisconnectFromTransportChannel(old_tc); | 380 DisconnectFromTransportChannel(old_tc); |
373 transport_controller_->DestroyTransportChannel_n( | 381 transport_controller_->DestroyTransportChannel_n( |
374 transport_name_, cricket::ICE_CANDIDATE_COMPONENT_RTCP); | 382 transport_name_, cricket::ICE_CANDIDATE_COMPONENT_RTCP); |
375 } | 383 } |
376 | 384 |
377 rtcp_transport_channel_ = new_tc; | 385 rtcp_transport_channel_ = new_tc; |
378 | 386 |
379 if (new_tc) { | 387 if (new_tc) { |
380 RTC_CHECK(!(ShouldSetupDtlsSrtp_n() && srtp_filter_.IsActive())) | 388 RTC_CHECK(!(ShouldSetupDtlsSrtp_n() && srtp_filter_.IsActive())) |
381 << "Setting RTCP for DTLS/SRTP after SrtpFilter is active " | 389 << "Setting RTCP for DTLS/SRTP after SrtpFilter is active " |
382 << "should never happen."; | 390 << "should never happen."; |
383 ConnectToTransportChannel(new_tc); | 391 ConnectToTransportChannel(new_tc); |
384 for (const auto& pair : rtcp_socket_options_) { | 392 for (const auto& pair : rtcp_socket_options_) { |
385 new_tc->SetOption(pair.first, pair.second); | 393 new_tc->SetOption(pair.first, pair.second); |
386 } | 394 } |
387 } | 395 } |
388 | 396 |
389 if (update_writablity) { | 397 if (update_writablity) { |
390 // Update aggregate writable/ready-to-send state between RTP and RTCP upon | 398 // Update aggregate writable/ready-to-send state between RTP and RTCP upon |
391 // setting new channel | 399 // setting new channel |
392 UpdateWritableState_n(); | 400 UpdateWritableState_n(); |
393 SetReadyToSend(true, new_tc && new_tc->writable()); | 401 // On setting a new channel, assume it's ready to send if it's writable, |
402 // because we have no way of knowing otherwise (the channel doesn't give us | |
403 // "was last send successful?"). | |
404 // | |
405 // This won't always be accurate (the last SendPacket call from another | |
406 // BaseChannel could have resulted in an error), but even so, we'll just | |
Taylor Brandstetter
2016/08/24 23:40:34
I know this comment is duplicated, but so is the r
| |
407 // encounter the error again and update "ready to send" accordingly. | |
408 SetTransportChannelReadyToSend(true, new_tc && new_tc->writable()); | |
394 } | 409 } |
395 } | 410 } |
396 | 411 |
397 void BaseChannel::ConnectToTransportChannel(TransportChannel* tc) { | 412 void BaseChannel::ConnectToTransportChannel(TransportChannel* tc) { |
398 RTC_DCHECK(network_thread_->IsCurrent()); | 413 RTC_DCHECK(network_thread_->IsCurrent()); |
399 | 414 |
400 tc->SignalWritableState.connect(this, &BaseChannel::OnWritableState); | 415 tc->SignalWritableState.connect(this, &BaseChannel::OnWritableState); |
401 tc->SignalReadPacket.connect(this, &BaseChannel::OnChannelRead); | 416 tc->SignalReadPacket.connect(this, &BaseChannel::OnChannelRead); |
402 tc->SignalReadyToSend.connect(this, &BaseChannel::OnReadyToSend); | 417 tc->SignalReadyToSend.connect(this, &BaseChannel::OnReadyToSend); |
403 tc->SignalDtlsState.connect(this, &BaseChannel::OnDtlsState); | 418 tc->SignalDtlsState.connect(this, &BaseChannel::OnDtlsState); |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
480 connection_monitor_->Stop(); | 495 connection_monitor_->Stop(); |
481 connection_monitor_.reset(); | 496 connection_monitor_.reset(); |
482 } | 497 } |
483 } | 498 } |
484 | 499 |
485 bool BaseChannel::GetConnectionStats(ConnectionInfos* infos) { | 500 bool BaseChannel::GetConnectionStats(ConnectionInfos* infos) { |
486 RTC_DCHECK(network_thread_->IsCurrent()); | 501 RTC_DCHECK(network_thread_->IsCurrent()); |
487 return transport_channel_->GetStats(infos); | 502 return transport_channel_->GetStats(infos); |
488 } | 503 } |
489 | 504 |
490 bool BaseChannel::IsReadyToReceive_w() const { | 505 bool BaseChannel::IsReadyToReceiveMedia_w() const { |
491 // Receive data if we are enabled and have local content, | 506 // Receive data if we are enabled and have local content, |
492 return enabled() && IsReceiveContentDirection(local_content_direction_); | 507 return enabled() && IsReceiveContentDirection(local_content_direction_); |
493 } | 508 } |
494 | 509 |
495 bool BaseChannel::IsReadyToSend_w() const { | 510 bool BaseChannel::IsReadyToSendMedia_w() const { |
511 // Need to access some state updated on the network thread. | |
512 return network_thread_->Invoke<bool>( | |
513 RTC_FROM_HERE, Bind(&BaseChannel::IsReadyToSendMedia_n, this)); | |
514 } | |
515 | |
516 bool BaseChannel::IsReadyToSendMedia_n() const { | |
496 // Send outgoing data if we are enabled, have local and remote content, | 517 // Send outgoing data if we are enabled, have local and remote content, |
497 // and we have had some form of connectivity. | 518 // and we have had some form of connectivity. |
498 return enabled() && IsReceiveContentDirection(remote_content_direction_) && | 519 return enabled() && IsReceiveContentDirection(remote_content_direction_) && |
499 IsSendContentDirection(local_content_direction_) && | 520 IsSendContentDirection(local_content_direction_) && |
500 network_thread_->Invoke<bool>( | 521 was_ever_writable() && |
501 RTC_FROM_HERE, Bind(&BaseChannel::IsTransportReadyToSend_n, this)); | |
502 } | |
503 | |
504 bool BaseChannel::IsTransportReadyToSend_n() const { | |
505 return was_ever_writable() && | |
506 (srtp_filter_.IsActive() || !ShouldSetupDtlsSrtp_n()); | 522 (srtp_filter_.IsActive() || !ShouldSetupDtlsSrtp_n()); |
507 } | 523 } |
508 | 524 |
509 bool BaseChannel::SendPacket(rtc::CopyOnWriteBuffer* packet, | 525 bool BaseChannel::SendPacket(rtc::CopyOnWriteBuffer* packet, |
510 const rtc::PacketOptions& options) { | 526 const rtc::PacketOptions& options) { |
511 return SendPacket(false, packet, options); | 527 return SendPacket(false, packet, options); |
512 } | 528 } |
513 | 529 |
514 bool BaseChannel::SendRtcp(rtc::CopyOnWriteBuffer* packet, | 530 bool BaseChannel::SendRtcp(rtc::CopyOnWriteBuffer* packet, |
515 const rtc::PacketOptions& options) { | 531 const rtc::PacketOptions& options) { |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
563 RTC_DCHECK(network_thread_->IsCurrent()); | 579 RTC_DCHECK(network_thread_->IsCurrent()); |
564 | 580 |
565 // When using RTCP multiplexing we might get RTCP packets on the RTP | 581 // When using RTCP multiplexing we might get RTCP packets on the RTP |
566 // transport. We feed RTP traffic into the demuxer to determine if it is RTCP. | 582 // transport. We feed RTP traffic into the demuxer to determine if it is RTCP. |
567 bool rtcp = PacketIsRtcp(channel, data, len); | 583 bool rtcp = PacketIsRtcp(channel, data, len); |
568 rtc::CopyOnWriteBuffer packet(data, len); | 584 rtc::CopyOnWriteBuffer packet(data, len); |
569 HandlePacket(rtcp, &packet, packet_time); | 585 HandlePacket(rtcp, &packet, packet_time); |
570 } | 586 } |
571 | 587 |
572 void BaseChannel::OnReadyToSend(TransportChannel* channel) { | 588 void BaseChannel::OnReadyToSend(TransportChannel* channel) { |
573 ASSERT(channel == transport_channel_ || channel == rtcp_transport_channel_); | 589 RTC_DCHECK(channel == transport_channel_ || |
574 SetReadyToSend(channel == rtcp_transport_channel_, true); | 590 channel == rtcp_transport_channel_); |
591 SetTransportChannelReadyToSend(channel == rtcp_transport_channel_, true); | |
575 } | 592 } |
576 | 593 |
577 void BaseChannel::OnDtlsState(TransportChannel* channel, | 594 void BaseChannel::OnDtlsState(TransportChannel* channel, |
578 DtlsTransportState state) { | 595 DtlsTransportState state) { |
579 if (!ShouldSetupDtlsSrtp_n()) { | 596 if (!ShouldSetupDtlsSrtp_n()) { |
580 return; | 597 return; |
581 } | 598 } |
582 | 599 |
583 // Reset the srtp filter if it's not the CONNECTED state. For the CONNECTED | 600 // Reset the srtp filter if it's not the CONNECTED state. For the CONNECTED |
584 // state, setting up DTLS-SRTP context is deferred to ChannelWritable_w to | 601 // state, setting up DTLS-SRTP context is deferred to ChannelWritable_w to |
585 // cover other scenarios like the whole channel is writable (not just this | 602 // cover other scenarios like the whole channel is writable (not just this |
586 // TransportChannel) or when TransportChannel is attached after DTLS is | 603 // TransportChannel) or when TransportChannel is attached after DTLS is |
587 // negotiated. | 604 // negotiated. |
588 if (state != DTLS_TRANSPORT_CONNECTED) { | 605 if (state != DTLS_TRANSPORT_CONNECTED) { |
589 srtp_filter_.ResetParams(); | 606 srtp_filter_.ResetParams(); |
590 } | 607 } |
591 } | 608 } |
592 | 609 |
593 void BaseChannel::OnSelectedCandidatePairChanged( | 610 void BaseChannel::OnSelectedCandidatePairChanged( |
594 TransportChannel* channel, | 611 TransportChannel* channel, |
595 CandidatePairInterface* selected_candidate_pair, | 612 CandidatePairInterface* selected_candidate_pair, |
596 int last_sent_packet_id, | 613 int last_sent_packet_id, |
597 bool ready_to_send) { | 614 bool ready_to_send) { |
598 ASSERT(channel == transport_channel_ || channel == rtcp_transport_channel_); | 615 RTC_DCHECK(channel == transport_channel_ || |
616 channel == rtcp_transport_channel_); | |
599 RTC_DCHECK(network_thread_->IsCurrent()); | 617 RTC_DCHECK(network_thread_->IsCurrent()); |
600 std::string transport_name = channel->transport_name(); | 618 std::string transport_name = channel->transport_name(); |
601 rtc::NetworkRoute network_route; | 619 rtc::NetworkRoute network_route; |
602 if (selected_candidate_pair) { | 620 if (selected_candidate_pair) { |
603 network_route = rtc::NetworkRoute( | 621 network_route = rtc::NetworkRoute( |
604 ready_to_send, selected_candidate_pair->local_candidate().network_id(), | 622 ready_to_send, selected_candidate_pair->local_candidate().network_id(), |
605 selected_candidate_pair->remote_candidate().network_id(), | 623 selected_candidate_pair->remote_candidate().network_id(), |
606 last_sent_packet_id); | 624 last_sent_packet_id); |
607 } | 625 } |
608 invoker_.AsyncInvoke<void>( | 626 invoker_.AsyncInvoke<void>( |
609 RTC_FROM_HERE, worker_thread_, | 627 RTC_FROM_HERE, worker_thread_, |
610 Bind(&MediaChannel::OnNetworkRouteChanged, media_channel_, transport_name, | 628 Bind(&MediaChannel::OnNetworkRouteChanged, media_channel_, transport_name, |
611 network_route)); | 629 network_route)); |
612 } | 630 } |
613 | 631 |
614 void BaseChannel::SetReadyToSend(bool rtcp, bool ready) { | 632 void BaseChannel::SetTransportChannelReadyToSend(bool rtcp, bool ready) { |
615 RTC_DCHECK(network_thread_->IsCurrent()); | 633 RTC_DCHECK(network_thread_->IsCurrent()); |
616 if (rtcp) { | 634 if (rtcp) { |
617 rtcp_ready_to_send_ = ready; | 635 rtcp_ready_to_send_ = ready; |
618 } else { | 636 } else { |
619 rtp_ready_to_send_ = ready; | 637 rtp_ready_to_send_ = ready; |
620 } | 638 } |
621 | 639 |
622 bool ready_to_send = | 640 bool ready_to_send = |
623 (rtp_ready_to_send_ && | 641 (rtp_ready_to_send_ && |
624 // In the case of rtcp mux |rtcp_transport_channel_| will be null. | 642 // In the case of rtcp mux |rtcp_transport_channel_| will be null. |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
734 } | 752 } |
735 } | 753 } |
736 | 754 |
737 // Update the length of the packet now that we've added the auth tag. | 755 // Update the length of the packet now that we've added the auth tag. |
738 packet->SetSize(len); | 756 packet->SetSize(len); |
739 } else if (secure_required_) { | 757 } else if (secure_required_) { |
740 // This is a double check for something that supposedly can't happen. | 758 // This is a double check for something that supposedly can't happen. |
741 LOG(LS_ERROR) << "Can't send outgoing " << PacketType(rtcp) | 759 LOG(LS_ERROR) << "Can't send outgoing " << PacketType(rtcp) |
742 << " packet when SRTP is inactive and crypto is required"; | 760 << " packet when SRTP is inactive and crypto is required"; |
743 | 761 |
744 ASSERT(false); | 762 RTC_DCHECK(false); |
745 return false; | 763 return false; |
746 } | 764 } |
747 | 765 |
748 // Bon voyage. | 766 // Bon voyage. |
749 int flags = (secure() && secure_dtls()) ? PF_SRTP_BYPASS : PF_NORMAL; | 767 int flags = (secure() && secure_dtls()) ? PF_SRTP_BYPASS : PF_NORMAL; |
750 int ret = channel->SendPacket(packet->data<char>(), packet->size(), | 768 int ret = channel->SendPacket(packet->data<char>(), packet->size(), |
751 updated_options, flags); | 769 updated_options, flags); |
752 if (ret != static_cast<int>(packet->size())) { | 770 if (ret != static_cast<int>(packet->size())) { |
753 if (channel->GetError() == ENOTCONN) { | 771 if (channel->GetError() == ENOTCONN) { |
754 LOG(LS_WARNING) << "Got ENOTCONN from transport."; | 772 LOG(LS_WARNING) << "Got ENOTCONN from transport."; |
755 SetReadyToSend(rtcp, false); | 773 SetTransportChannelReadyToSend(rtcp, false); |
756 } | 774 } |
757 return false; | 775 return false; |
758 } | 776 } |
759 return true; | 777 return true; |
760 } | 778 } |
761 | 779 |
762 bool BaseChannel::WantsPacket(bool rtcp, const rtc::CopyOnWriteBuffer* packet) { | 780 bool BaseChannel::WantsPacket(bool rtcp, const rtc::CopyOnWriteBuffer* packet) { |
763 // Protect ourselves against crazy data. | 781 // Protect ourselves against crazy data. |
764 if (!ValidPacket(rtcp, packet)) { | 782 if (!ValidPacket(rtcp, packet)) { |
765 LOG(LS_ERROR) << "Dropping incoming " << content_name_ << " " | 783 LOG(LS_ERROR) << "Dropping incoming " << content_name_ << " " |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
876 GetContentDescription(content_info); | 894 GetContentDescription(content_info); |
877 if (content_desc && content_info && !content_info->rejected && | 895 if (content_desc && content_info && !content_info->rejected && |
878 !SetRemoteContent(content_desc, action, error_desc)) { | 896 !SetRemoteContent(content_desc, action, error_desc)) { |
879 LOG(LS_ERROR) << "Failure in SetRemoteContent with action " << action; | 897 LOG(LS_ERROR) << "Failure in SetRemoteContent with action " << action; |
880 return false; | 898 return false; |
881 } | 899 } |
882 return true; | 900 return true; |
883 } | 901 } |
884 | 902 |
885 void BaseChannel::EnableMedia_w() { | 903 void BaseChannel::EnableMedia_w() { |
886 ASSERT(worker_thread_ == rtc::Thread::Current()); | 904 RTC_DCHECK(worker_thread_ == rtc::Thread::Current()); |
887 if (enabled_) | 905 if (enabled_) |
888 return; | 906 return; |
889 | 907 |
890 LOG(LS_INFO) << "Channel enabled"; | 908 LOG(LS_INFO) << "Channel enabled"; |
891 enabled_ = true; | 909 enabled_ = true; |
892 ChangeState_w(); | 910 UpdateMediaSendRecvState_w(); |
893 } | 911 } |
894 | 912 |
895 void BaseChannel::DisableMedia_w() { | 913 void BaseChannel::DisableMedia_w() { |
896 ASSERT(worker_thread_ == rtc::Thread::Current()); | 914 RTC_DCHECK(worker_thread_ == rtc::Thread::Current()); |
897 if (!enabled_) | 915 if (!enabled_) |
898 return; | 916 return; |
899 | 917 |
900 LOG(LS_INFO) << "Channel disabled"; | 918 LOG(LS_INFO) << "Channel disabled"; |
901 enabled_ = false; | 919 enabled_ = false; |
902 ChangeState_w(); | 920 UpdateMediaSendRecvState_w(); |
903 } | 921 } |
904 | 922 |
905 void BaseChannel::UpdateWritableState_n() { | 923 void BaseChannel::UpdateWritableState_n() { |
906 if (transport_channel_ && transport_channel_->writable() && | 924 if (transport_channel_ && transport_channel_->writable() && |
907 (!rtcp_transport_channel_ || rtcp_transport_channel_->writable())) { | 925 (!rtcp_transport_channel_ || rtcp_transport_channel_->writable())) { |
908 ChannelWritable_n(); | 926 ChannelWritable_n(); |
909 } else { | 927 } else { |
910 ChannelNotWritable_n(); | 928 ChannelNotWritable_n(); |
911 } | 929 } |
912 } | 930 } |
(...skipping 14 matching lines...) Expand all Loading... | |
927 if (it->best_connection) { | 945 if (it->best_connection) { |
928 LOG(LS_INFO) << "Using " << it->local_candidate.ToSensitiveString() | 946 LOG(LS_INFO) << "Using " << it->local_candidate.ToSensitiveString() |
929 << "->" << it->remote_candidate.ToSensitiveString(); | 947 << "->" << it->remote_candidate.ToSensitiveString(); |
930 break; | 948 break; |
931 } | 949 } |
932 } | 950 } |
933 | 951 |
934 was_ever_writable_ = true; | 952 was_ever_writable_ = true; |
935 MaybeSetupDtlsSrtp_n(); | 953 MaybeSetupDtlsSrtp_n(); |
936 writable_ = true; | 954 writable_ = true; |
937 ChangeState(); | 955 UpdateMediaSendRecvState(); |
938 } | 956 } |
939 | 957 |
940 void BaseChannel::SignalDtlsSetupFailure_n(bool rtcp) { | 958 void BaseChannel::SignalDtlsSetupFailure_n(bool rtcp) { |
941 RTC_DCHECK(network_thread_->IsCurrent()); | 959 RTC_DCHECK(network_thread_->IsCurrent()); |
942 invoker_.AsyncInvoke<void>( | 960 invoker_.AsyncInvoke<void>( |
943 RTC_FROM_HERE, signaling_thread(), | 961 RTC_FROM_HERE, signaling_thread(), |
944 Bind(&BaseChannel::SignalDtlsSetupFailure_s, this, rtcp)); | 962 Bind(&BaseChannel::SignalDtlsSetupFailure_s, this, rtcp)); |
945 } | 963 } |
946 | 964 |
947 void BaseChannel::SignalDtlsSetupFailure_s(bool rtcp) { | 965 void BaseChannel::SignalDtlsSetupFailure_s(bool rtcp) { |
948 ASSERT(signaling_thread() == rtc::Thread::Current()); | 966 RTC_DCHECK(signaling_thread() == rtc::Thread::Current()); |
949 SignalDtlsSetupFailure(this, rtcp); | 967 SignalDtlsSetupFailure(this, rtcp); |
950 } | 968 } |
951 | 969 |
952 bool BaseChannel::SetDtlsSrtpCryptoSuites_n(TransportChannel* tc, bool rtcp) { | 970 bool BaseChannel::SetDtlsSrtpCryptoSuites_n(TransportChannel* tc, bool rtcp) { |
953 std::vector<int> crypto_suites; | 971 std::vector<int> crypto_suites; |
954 // We always use the default SRTP crypto suites for RTCP, but we may use | 972 // We always use the default SRTP crypto suites for RTCP, but we may use |
955 // different crypto suites for RTP depending on the media type. | 973 // different crypto suites for RTP depending on the media type. |
956 if (!rtcp) { | 974 if (!rtcp) { |
957 GetSrtpCryptoSuites_n(&crypto_suites); | 975 GetSrtpCryptoSuites_n(&crypto_suites); |
958 } else { | 976 } else { |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
998 | 1016 |
999 // OK, we're now doing DTLS (RFC 5764) | 1017 // OK, we're now doing DTLS (RFC 5764) |
1000 std::vector<unsigned char> dtls_buffer(key_len * 2 + salt_len * 2); | 1018 std::vector<unsigned char> dtls_buffer(key_len * 2 + salt_len * 2); |
1001 | 1019 |
1002 // RFC 5705 exporter using the RFC 5764 parameters | 1020 // RFC 5705 exporter using the RFC 5764 parameters |
1003 if (!channel->ExportKeyingMaterial( | 1021 if (!channel->ExportKeyingMaterial( |
1004 kDtlsSrtpExporterLabel, | 1022 kDtlsSrtpExporterLabel, |
1005 NULL, 0, false, | 1023 NULL, 0, false, |
1006 &dtls_buffer[0], dtls_buffer.size())) { | 1024 &dtls_buffer[0], dtls_buffer.size())) { |
1007 LOG(LS_WARNING) << "DTLS-SRTP key export failed"; | 1025 LOG(LS_WARNING) << "DTLS-SRTP key export failed"; |
1008 ASSERT(false); // This should never happen | 1026 RTC_DCHECK(false); // This should never happen |
1009 return false; | 1027 return false; |
1010 } | 1028 } |
1011 | 1029 |
1012 // Sync up the keys with the DTLS-SRTP interface | 1030 // Sync up the keys with the DTLS-SRTP interface |
1013 std::vector<unsigned char> client_write_key(key_len + salt_len); | 1031 std::vector<unsigned char> client_write_key(key_len + salt_len); |
1014 std::vector<unsigned char> server_write_key(key_len + salt_len); | 1032 std::vector<unsigned char> server_write_key(key_len + salt_len); |
1015 size_t offset = 0; | 1033 size_t offset = 0; |
1016 memcpy(&client_write_key[0], &dtls_buffer[offset], key_len); | 1034 memcpy(&client_write_key[0], &dtls_buffer[offset], key_len); |
1017 offset += key_len; | 1035 offset += key_len; |
1018 memcpy(&server_write_key[0], &dtls_buffer[offset], key_len); | 1036 memcpy(&server_write_key[0], &dtls_buffer[offset], key_len); |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1078 } | 1096 } |
1079 } | 1097 } |
1080 | 1098 |
1081 void BaseChannel::ChannelNotWritable_n() { | 1099 void BaseChannel::ChannelNotWritable_n() { |
1082 RTC_DCHECK(network_thread_->IsCurrent()); | 1100 RTC_DCHECK(network_thread_->IsCurrent()); |
1083 if (!writable_) | 1101 if (!writable_) |
1084 return; | 1102 return; |
1085 | 1103 |
1086 LOG(LS_INFO) << "Channel not writable (" << content_name_ << ")"; | 1104 LOG(LS_INFO) << "Channel not writable (" << content_name_ << ")"; |
1087 writable_ = false; | 1105 writable_ = false; |
1088 ChangeState(); | 1106 UpdateMediaSendRecvState(); |
1089 } | 1107 } |
1090 | 1108 |
1091 bool BaseChannel::SetRtpTransportParameters( | 1109 bool BaseChannel::SetRtpTransportParameters( |
1092 const MediaContentDescription* content, | 1110 const MediaContentDescription* content, |
1093 ContentAction action, | 1111 ContentAction action, |
1094 ContentSource src, | 1112 ContentSource src, |
1095 std::string* error_desc) { | 1113 std::string* error_desc) { |
1096 if (action == CA_UPDATE) { | 1114 if (action == CA_UPDATE) { |
1097 // These parameters never get changed by a CA_UDPATE. | 1115 // These parameters never get changed by a CA_UDPATE. |
1098 return true; | 1116 return true; |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1201 bool BaseChannel::SetRtcpMux_n(bool enable, | 1219 bool BaseChannel::SetRtcpMux_n(bool enable, |
1202 ContentAction action, | 1220 ContentAction action, |
1203 ContentSource src, | 1221 ContentSource src, |
1204 std::string* error_desc) { | 1222 std::string* error_desc) { |
1205 bool ret = false; | 1223 bool ret = false; |
1206 switch (action) { | 1224 switch (action) { |
1207 case CA_OFFER: | 1225 case CA_OFFER: |
1208 ret = rtcp_mux_filter_.SetOffer(enable, src); | 1226 ret = rtcp_mux_filter_.SetOffer(enable, src); |
1209 break; | 1227 break; |
1210 case CA_PRANSWER: | 1228 case CA_PRANSWER: |
1229 // This may activate RTCP muxing, but we don't yet destroy the channel | |
1230 // because the final answer may deactivate it. | |
1211 ret = rtcp_mux_filter_.SetProvisionalAnswer(enable, src); | 1231 ret = rtcp_mux_filter_.SetProvisionalAnswer(enable, src); |
1212 break; | 1232 break; |
1213 case CA_ANSWER: | 1233 case CA_ANSWER: |
1214 ret = rtcp_mux_filter_.SetAnswer(enable, src); | 1234 ret = rtcp_mux_filter_.SetAnswer(enable, src); |
1215 if (ret && rtcp_mux_filter_.IsActive()) { | 1235 if (ret && rtcp_mux_filter_.IsActive()) { |
1216 // We activated RTCP mux, close down the RTCP transport. | 1236 // We activated RTCP mux, close down the RTCP transport. |
1217 LOG(LS_INFO) << "Enabling rtcp-mux for " << content_name() | 1237 LOG(LS_INFO) << "Enabling rtcp-mux for " << content_name() |
1218 << " by destroying RTCP transport channel for " | 1238 << " by destroying RTCP transport channel for " |
1219 << transport_name(); | 1239 << transport_name(); |
1220 SetRtcpTransportChannel_n(nullptr, true); | 1240 SetRtcpTransportChannel_n(nullptr, true); |
(...skipping 17 matching lines...) Expand all Loading... | |
1238 // If the RTP transport is already writable, then so are we. | 1258 // If the RTP transport is already writable, then so are we. |
1239 if (transport_channel_->writable()) { | 1259 if (transport_channel_->writable()) { |
1240 ChannelWritable_n(); | 1260 ChannelWritable_n(); |
1241 } | 1261 } |
1242 } | 1262 } |
1243 | 1263 |
1244 return true; | 1264 return true; |
1245 } | 1265 } |
1246 | 1266 |
1247 bool BaseChannel::AddRecvStream_w(const StreamParams& sp) { | 1267 bool BaseChannel::AddRecvStream_w(const StreamParams& sp) { |
1248 ASSERT(worker_thread() == rtc::Thread::Current()); | 1268 RTC_DCHECK(worker_thread() == rtc::Thread::Current()); |
1249 return media_channel()->AddRecvStream(sp); | 1269 return media_channel()->AddRecvStream(sp); |
1250 } | 1270 } |
1251 | 1271 |
1252 bool BaseChannel::RemoveRecvStream_w(uint32_t ssrc) { | 1272 bool BaseChannel::RemoveRecvStream_w(uint32_t ssrc) { |
1253 ASSERT(worker_thread() == rtc::Thread::Current()); | 1273 RTC_DCHECK(worker_thread() == rtc::Thread::Current()); |
1254 return media_channel()->RemoveRecvStream(ssrc); | 1274 return media_channel()->RemoveRecvStream(ssrc); |
1255 } | 1275 } |
1256 | 1276 |
1257 bool BaseChannel::UpdateLocalStreams_w(const std::vector<StreamParams>& streams, | 1277 bool BaseChannel::UpdateLocalStreams_w(const std::vector<StreamParams>& streams, |
1258 ContentAction action, | 1278 ContentAction action, |
1259 std::string* error_desc) { | 1279 std::string* error_desc) { |
1260 if (!VERIFY(action == CA_OFFER || action == CA_ANSWER || | 1280 if (!VERIFY(action == CA_OFFER || action == CA_ANSWER || |
1261 action == CA_PRANSWER || action == CA_UPDATE)) | 1281 action == CA_PRANSWER || action == CA_UPDATE)) |
1262 return false; | 1282 return false; |
1263 | 1283 |
(...skipping 393 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1657 int flags) { | 1677 int flags) { |
1658 BaseChannel::OnChannelRead(channel, data, len, packet_time, flags); | 1678 BaseChannel::OnChannelRead(channel, data, len, packet_time, flags); |
1659 | 1679 |
1660 // Set a flag when we've received an RTP packet. If we're waiting for early | 1680 // Set a flag when we've received an RTP packet. If we're waiting for early |
1661 // media, this will disable the timeout. | 1681 // media, this will disable the timeout. |
1662 if (!received_media_ && !PacketIsRtcp(channel, data, len)) { | 1682 if (!received_media_ && !PacketIsRtcp(channel, data, len)) { |
1663 received_media_ = true; | 1683 received_media_ = true; |
1664 } | 1684 } |
1665 } | 1685 } |
1666 | 1686 |
1667 void BaseChannel::ChangeState() { | 1687 void BaseChannel::UpdateMediaSendRecvState() { |
1668 RTC_DCHECK(network_thread_->IsCurrent()); | 1688 RTC_DCHECK(network_thread_->IsCurrent()); |
1669 invoker_.AsyncInvoke<void>(RTC_FROM_HERE, worker_thread_, | 1689 invoker_.AsyncInvoke<void>( |
1670 Bind(&BaseChannel::ChangeState_w, this)); | 1690 RTC_FROM_HERE, worker_thread_, |
1691 Bind(&BaseChannel::UpdateMediaSendRecvState_w, this)); | |
1671 } | 1692 } |
1672 | 1693 |
1673 void VoiceChannel::ChangeState_w() { | 1694 void VoiceChannel::UpdateMediaSendRecvState_w() { |
1674 // Render incoming data if we're the active call, and we have the local | 1695 // Render incoming data if we're the active call, and we have the local |
1675 // content. We receive data on the default channel and multiplexed streams. | 1696 // content. We receive data on the default channel and multiplexed streams. |
1676 bool recv = IsReadyToReceive_w(); | 1697 bool recv = IsReadyToReceiveMedia_w(); |
1677 media_channel()->SetPlayout(recv); | 1698 media_channel()->SetPlayout(recv); |
1678 | 1699 |
1679 // Send outgoing data if we're the active call, we have the remote content, | 1700 // Send outgoing data if we're the active call, we have the remote content, |
1680 // and we have had some form of connectivity. | 1701 // and we have had some form of connectivity. |
1681 bool send = IsReadyToSend_w(); | 1702 bool send = IsReadyToSendMedia_w(); |
1682 media_channel()->SetSend(send); | 1703 media_channel()->SetSend(send); |
1683 | 1704 |
1684 LOG(LS_INFO) << "Changing voice state, recv=" << recv << " send=" << send; | 1705 LOG(LS_INFO) << "Changing voice state, recv=" << recv << " send=" << send; |
1685 } | 1706 } |
1686 | 1707 |
1687 const ContentInfo* VoiceChannel::GetFirstContent( | 1708 const ContentInfo* VoiceChannel::GetFirstContent( |
1688 const SessionDescription* sdesc) { | 1709 const SessionDescription* sdesc) { |
1689 return GetFirstAudioContent(sdesc); | 1710 return GetFirstAudioContent(sdesc); |
1690 } | 1711 } |
1691 | 1712 |
1692 bool VoiceChannel::SetLocalContent_w(const MediaContentDescription* content, | 1713 bool VoiceChannel::SetLocalContent_w(const MediaContentDescription* content, |
1693 ContentAction action, | 1714 ContentAction action, |
1694 std::string* error_desc) { | 1715 std::string* error_desc) { |
1695 TRACE_EVENT0("webrtc", "VoiceChannel::SetLocalContent_w"); | 1716 TRACE_EVENT0("webrtc", "VoiceChannel::SetLocalContent_w"); |
1696 ASSERT(worker_thread() == rtc::Thread::Current()); | 1717 RTC_DCHECK(worker_thread() == rtc::Thread::Current()); |
1697 LOG(LS_INFO) << "Setting local voice description"; | 1718 LOG(LS_INFO) << "Setting local voice description"; |
1698 | 1719 |
1699 const AudioContentDescription* audio = | 1720 const AudioContentDescription* audio = |
1700 static_cast<const AudioContentDescription*>(content); | 1721 static_cast<const AudioContentDescription*>(content); |
1701 ASSERT(audio != NULL); | 1722 RTC_DCHECK(audio != NULL); |
1702 if (!audio) { | 1723 if (!audio) { |
1703 SafeSetError("Can't find audio content in local description.", error_desc); | 1724 SafeSetError("Can't find audio content in local description.", error_desc); |
1704 return false; | 1725 return false; |
1705 } | 1726 } |
1706 | 1727 |
1707 if (!SetRtpTransportParameters(content, action, CS_LOCAL, error_desc)) { | 1728 if (!SetRtpTransportParameters(content, action, CS_LOCAL, error_desc)) { |
1708 return false; | 1729 return false; |
1709 } | 1730 } |
1710 | 1731 |
1711 AudioRecvParameters recv_params = last_recv_params_; | 1732 AudioRecvParameters recv_params = last_recv_params_; |
(...skipping 11 matching lines...) Expand all Loading... | |
1723 // TODO(pthatcher): Move local streams into AudioSendParameters, and | 1744 // TODO(pthatcher): Move local streams into AudioSendParameters, and |
1724 // only give it to the media channel once we have a remote | 1745 // only give it to the media channel once we have a remote |
1725 // description too (without a remote description, we won't be able | 1746 // description too (without a remote description, we won't be able |
1726 // to send them anyway). | 1747 // to send them anyway). |
1727 if (!UpdateLocalStreams_w(audio->streams(), action, error_desc)) { | 1748 if (!UpdateLocalStreams_w(audio->streams(), action, error_desc)) { |
1728 SafeSetError("Failed to set local audio description streams.", error_desc); | 1749 SafeSetError("Failed to set local audio description streams.", error_desc); |
1729 return false; | 1750 return false; |
1730 } | 1751 } |
1731 | 1752 |
1732 set_local_content_direction(content->direction()); | 1753 set_local_content_direction(content->direction()); |
1733 ChangeState_w(); | 1754 UpdateMediaSendRecvState_w(); |
1734 return true; | 1755 return true; |
1735 } | 1756 } |
1736 | 1757 |
1737 bool VoiceChannel::SetRemoteContent_w(const MediaContentDescription* content, | 1758 bool VoiceChannel::SetRemoteContent_w(const MediaContentDescription* content, |
1738 ContentAction action, | 1759 ContentAction action, |
1739 std::string* error_desc) { | 1760 std::string* error_desc) { |
1740 TRACE_EVENT0("webrtc", "VoiceChannel::SetRemoteContent_w"); | 1761 TRACE_EVENT0("webrtc", "VoiceChannel::SetRemoteContent_w"); |
1741 ASSERT(worker_thread() == rtc::Thread::Current()); | 1762 RTC_DCHECK(worker_thread() == rtc::Thread::Current()); |
1742 LOG(LS_INFO) << "Setting remote voice description"; | 1763 LOG(LS_INFO) << "Setting remote voice description"; |
1743 | 1764 |
1744 const AudioContentDescription* audio = | 1765 const AudioContentDescription* audio = |
1745 static_cast<const AudioContentDescription*>(content); | 1766 static_cast<const AudioContentDescription*>(content); |
1746 ASSERT(audio != NULL); | 1767 RTC_DCHECK(audio != NULL); |
1747 if (!audio) { | 1768 if (!audio) { |
1748 SafeSetError("Can't find audio content in remote description.", error_desc); | 1769 SafeSetError("Can't find audio content in remote description.", error_desc); |
1749 return false; | 1770 return false; |
1750 } | 1771 } |
1751 | 1772 |
1752 if (!SetRtpTransportParameters(content, action, CS_REMOTE, error_desc)) { | 1773 if (!SetRtpTransportParameters(content, action, CS_REMOTE, error_desc)) { |
1753 return false; | 1774 return false; |
1754 } | 1775 } |
1755 | 1776 |
1756 AudioSendParameters send_params = last_send_params_; | 1777 AudioSendParameters send_params = last_send_params_; |
(...skipping 17 matching lines...) Expand all Loading... | |
1774 if (!UpdateRemoteStreams_w(audio->streams(), action, error_desc)) { | 1795 if (!UpdateRemoteStreams_w(audio->streams(), action, error_desc)) { |
1775 SafeSetError("Failed to set remote audio description streams.", error_desc); | 1796 SafeSetError("Failed to set remote audio description streams.", error_desc); |
1776 return false; | 1797 return false; |
1777 } | 1798 } |
1778 | 1799 |
1779 if (audio->rtp_header_extensions_set()) { | 1800 if (audio->rtp_header_extensions_set()) { |
1780 MaybeCacheRtpAbsSendTimeHeaderExtension_w(audio->rtp_header_extensions()); | 1801 MaybeCacheRtpAbsSendTimeHeaderExtension_w(audio->rtp_header_extensions()); |
1781 } | 1802 } |
1782 | 1803 |
1783 set_remote_content_direction(content->direction()); | 1804 set_remote_content_direction(content->direction()); |
1784 ChangeState_w(); | 1805 UpdateMediaSendRecvState_w(); |
1785 return true; | 1806 return true; |
1786 } | 1807 } |
1787 | 1808 |
1788 void VoiceChannel::HandleEarlyMediaTimeout() { | 1809 void VoiceChannel::HandleEarlyMediaTimeout() { |
1789 // This occurs on the main thread, not the worker thread. | 1810 // This occurs on the main thread, not the worker thread. |
1790 if (!received_media_) { | 1811 if (!received_media_) { |
1791 LOG(LS_INFO) << "No early media received before timeout"; | 1812 LOG(LS_INFO) << "No early media received before timeout"; |
1792 SignalEarlyMediaTimeout(this); | 1813 SignalEarlyMediaTimeout(this); |
1793 } | 1814 } |
1794 } | 1815 } |
(...skipping 24 matching lines...) Expand all Loading... | |
1819 } | 1840 } |
1820 } | 1841 } |
1821 | 1842 |
1822 void VoiceChannel::OnConnectionMonitorUpdate( | 1843 void VoiceChannel::OnConnectionMonitorUpdate( |
1823 ConnectionMonitor* monitor, const std::vector<ConnectionInfo>& infos) { | 1844 ConnectionMonitor* monitor, const std::vector<ConnectionInfo>& infos) { |
1824 SignalConnectionMonitor(this, infos); | 1845 SignalConnectionMonitor(this, infos); |
1825 } | 1846 } |
1826 | 1847 |
1827 void VoiceChannel::OnMediaMonitorUpdate( | 1848 void VoiceChannel::OnMediaMonitorUpdate( |
1828 VoiceMediaChannel* media_channel, const VoiceMediaInfo& info) { | 1849 VoiceMediaChannel* media_channel, const VoiceMediaInfo& info) { |
1829 ASSERT(media_channel == this->media_channel()); | 1850 RTC_DCHECK(media_channel == this->media_channel()); |
1830 SignalMediaMonitor(this, info); | 1851 SignalMediaMonitor(this, info); |
1831 } | 1852 } |
1832 | 1853 |
1833 void VoiceChannel::OnAudioMonitorUpdate(AudioMonitor* monitor, | 1854 void VoiceChannel::OnAudioMonitorUpdate(AudioMonitor* monitor, |
1834 const AudioInfo& info) { | 1855 const AudioInfo& info) { |
1835 SignalAudioMonitor(this, info); | 1856 SignalAudioMonitor(this, info); |
1836 } | 1857 } |
1837 | 1858 |
1838 void VoiceChannel::GetSrtpCryptoSuites_n( | 1859 void VoiceChannel::GetSrtpCryptoSuites_n( |
1839 std::vector<int>* crypto_suites) const { | 1860 std::vector<int>* crypto_suites) const { |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1928 return InvokeOnWorker( | 1949 return InvokeOnWorker( |
1929 RTC_FROM_HERE, | 1950 RTC_FROM_HERE, |
1930 Bind(&VideoChannel::SetRtpReceiveParameters_w, this, ssrc, parameters)); | 1951 Bind(&VideoChannel::SetRtpReceiveParameters_w, this, ssrc, parameters)); |
1931 } | 1952 } |
1932 | 1953 |
1933 bool VideoChannel::SetRtpReceiveParameters_w(uint32_t ssrc, | 1954 bool VideoChannel::SetRtpReceiveParameters_w(uint32_t ssrc, |
1934 webrtc::RtpParameters parameters) { | 1955 webrtc::RtpParameters parameters) { |
1935 return media_channel()->SetRtpReceiveParameters(ssrc, parameters); | 1956 return media_channel()->SetRtpReceiveParameters(ssrc, parameters); |
1936 } | 1957 } |
1937 | 1958 |
1938 void VideoChannel::ChangeState_w() { | 1959 void VideoChannel::UpdateMediaSendRecvState_w() { |
1939 // Send outgoing data if we're the active call, we have the remote content, | 1960 // Send outgoing data if we're the active call, we have the remote content, |
1940 // and we have had some form of connectivity. | 1961 // and we have had some form of connectivity. |
1941 bool send = IsReadyToSend_w(); | 1962 bool send = IsReadyToSendMedia_w(); |
1942 if (!media_channel()->SetSend(send)) { | 1963 if (!media_channel()->SetSend(send)) { |
1943 LOG(LS_ERROR) << "Failed to SetSend on video channel"; | 1964 LOG(LS_ERROR) << "Failed to SetSend on video channel"; |
1944 // TODO(gangji): Report error back to server. | 1965 // TODO(gangji): Report error back to server. |
1945 } | 1966 } |
1946 | 1967 |
1947 LOG(LS_INFO) << "Changing video state, send=" << send; | 1968 LOG(LS_INFO) << "Changing video state, send=" << send; |
1948 } | 1969 } |
1949 | 1970 |
1950 bool VideoChannel::GetStats(VideoMediaInfo* stats) { | 1971 bool VideoChannel::GetStats(VideoMediaInfo* stats) { |
1951 return InvokeOnWorker(RTC_FROM_HERE, Bind(&VideoMediaChannel::GetStats, | 1972 return InvokeOnWorker(RTC_FROM_HERE, Bind(&VideoMediaChannel::GetStats, |
(...skipping 17 matching lines...) Expand all Loading... | |
1969 | 1990 |
1970 const ContentInfo* VideoChannel::GetFirstContent( | 1991 const ContentInfo* VideoChannel::GetFirstContent( |
1971 const SessionDescription* sdesc) { | 1992 const SessionDescription* sdesc) { |
1972 return GetFirstVideoContent(sdesc); | 1993 return GetFirstVideoContent(sdesc); |
1973 } | 1994 } |
1974 | 1995 |
1975 bool VideoChannel::SetLocalContent_w(const MediaContentDescription* content, | 1996 bool VideoChannel::SetLocalContent_w(const MediaContentDescription* content, |
1976 ContentAction action, | 1997 ContentAction action, |
1977 std::string* error_desc) { | 1998 std::string* error_desc) { |
1978 TRACE_EVENT0("webrtc", "VideoChannel::SetLocalContent_w"); | 1999 TRACE_EVENT0("webrtc", "VideoChannel::SetLocalContent_w"); |
1979 ASSERT(worker_thread() == rtc::Thread::Current()); | 2000 RTC_DCHECK(worker_thread() == rtc::Thread::Current()); |
1980 LOG(LS_INFO) << "Setting local video description"; | 2001 LOG(LS_INFO) << "Setting local video description"; |
1981 | 2002 |
1982 const VideoContentDescription* video = | 2003 const VideoContentDescription* video = |
1983 static_cast<const VideoContentDescription*>(content); | 2004 static_cast<const VideoContentDescription*>(content); |
1984 ASSERT(video != NULL); | 2005 RTC_DCHECK(video != NULL); |
1985 if (!video) { | 2006 if (!video) { |
1986 SafeSetError("Can't find video content in local description.", error_desc); | 2007 SafeSetError("Can't find video content in local description.", error_desc); |
1987 return false; | 2008 return false; |
1988 } | 2009 } |
1989 | 2010 |
1990 if (!SetRtpTransportParameters(content, action, CS_LOCAL, error_desc)) { | 2011 if (!SetRtpTransportParameters(content, action, CS_LOCAL, error_desc)) { |
1991 return false; | 2012 return false; |
1992 } | 2013 } |
1993 | 2014 |
1994 VideoRecvParameters recv_params = last_recv_params_; | 2015 VideoRecvParameters recv_params = last_recv_params_; |
(...skipping 11 matching lines...) Expand all Loading... | |
2006 // TODO(pthatcher): Move local streams into VideoSendParameters, and | 2027 // TODO(pthatcher): Move local streams into VideoSendParameters, and |
2007 // only give it to the media channel once we have a remote | 2028 // only give it to the media channel once we have a remote |
2008 // description too (without a remote description, we won't be able | 2029 // description too (without a remote description, we won't be able |
2009 // to send them anyway). | 2030 // to send them anyway). |
2010 if (!UpdateLocalStreams_w(video->streams(), action, error_desc)) { | 2031 if (!UpdateLocalStreams_w(video->streams(), action, error_desc)) { |
2011 SafeSetError("Failed to set local video description streams.", error_desc); | 2032 SafeSetError("Failed to set local video description streams.", error_desc); |
2012 return false; | 2033 return false; |
2013 } | 2034 } |
2014 | 2035 |
2015 set_local_content_direction(content->direction()); | 2036 set_local_content_direction(content->direction()); |
2016 ChangeState_w(); | 2037 UpdateMediaSendRecvState_w(); |
2017 return true; | 2038 return true; |
2018 } | 2039 } |
2019 | 2040 |
2020 bool VideoChannel::SetRemoteContent_w(const MediaContentDescription* content, | 2041 bool VideoChannel::SetRemoteContent_w(const MediaContentDescription* content, |
2021 ContentAction action, | 2042 ContentAction action, |
2022 std::string* error_desc) { | 2043 std::string* error_desc) { |
2023 TRACE_EVENT0("webrtc", "VideoChannel::SetRemoteContent_w"); | 2044 TRACE_EVENT0("webrtc", "VideoChannel::SetRemoteContent_w"); |
2024 ASSERT(worker_thread() == rtc::Thread::Current()); | 2045 RTC_DCHECK(worker_thread() == rtc::Thread::Current()); |
2025 LOG(LS_INFO) << "Setting remote video description"; | 2046 LOG(LS_INFO) << "Setting remote video description"; |
2026 | 2047 |
2027 const VideoContentDescription* video = | 2048 const VideoContentDescription* video = |
2028 static_cast<const VideoContentDescription*>(content); | 2049 static_cast<const VideoContentDescription*>(content); |
2029 ASSERT(video != NULL); | 2050 RTC_DCHECK(video != NULL); |
2030 if (!video) { | 2051 if (!video) { |
2031 SafeSetError("Can't find video content in remote description.", error_desc); | 2052 SafeSetError("Can't find video content in remote description.", error_desc); |
2032 return false; | 2053 return false; |
2033 } | 2054 } |
2034 | 2055 |
2035 if (!SetRtpTransportParameters(content, action, CS_REMOTE, error_desc)) { | 2056 if (!SetRtpTransportParameters(content, action, CS_REMOTE, error_desc)) { |
2036 return false; | 2057 return false; |
2037 } | 2058 } |
2038 | 2059 |
2039 VideoSendParameters send_params = last_send_params_; | 2060 VideoSendParameters send_params = last_send_params_; |
(...skipping 18 matching lines...) Expand all Loading... | |
2058 if (!UpdateRemoteStreams_w(video->streams(), action, error_desc)) { | 2079 if (!UpdateRemoteStreams_w(video->streams(), action, error_desc)) { |
2059 SafeSetError("Failed to set remote video description streams.", error_desc); | 2080 SafeSetError("Failed to set remote video description streams.", error_desc); |
2060 return false; | 2081 return false; |
2061 } | 2082 } |
2062 | 2083 |
2063 if (video->rtp_header_extensions_set()) { | 2084 if (video->rtp_header_extensions_set()) { |
2064 MaybeCacheRtpAbsSendTimeHeaderExtension_w(video->rtp_header_extensions()); | 2085 MaybeCacheRtpAbsSendTimeHeaderExtension_w(video->rtp_header_extensions()); |
2065 } | 2086 } |
2066 | 2087 |
2067 set_remote_content_direction(content->direction()); | 2088 set_remote_content_direction(content->direction()); |
2068 ChangeState_w(); | 2089 UpdateMediaSendRecvState_w(); |
2069 return true; | 2090 return true; |
2070 } | 2091 } |
2071 | 2092 |
2072 void VideoChannel::OnMessage(rtc::Message *pmsg) { | 2093 void VideoChannel::OnMessage(rtc::Message *pmsg) { |
2073 switch (pmsg->message_id) { | 2094 switch (pmsg->message_id) { |
2074 case MSG_CHANNEL_ERROR: { | 2095 case MSG_CHANNEL_ERROR: { |
2075 const VideoChannelErrorMessageData* data = | 2096 const VideoChannelErrorMessageData* data = |
2076 static_cast<VideoChannelErrorMessageData*>(pmsg->pdata); | 2097 static_cast<VideoChannelErrorMessageData*>(pmsg->pdata); |
2077 delete data; | 2098 delete data; |
2078 break; | 2099 break; |
2079 } | 2100 } |
2080 default: | 2101 default: |
2081 BaseChannel::OnMessage(pmsg); | 2102 BaseChannel::OnMessage(pmsg); |
2082 break; | 2103 break; |
2083 } | 2104 } |
2084 } | 2105 } |
2085 | 2106 |
2086 void VideoChannel::OnConnectionMonitorUpdate( | 2107 void VideoChannel::OnConnectionMonitorUpdate( |
2087 ConnectionMonitor* monitor, const std::vector<ConnectionInfo> &infos) { | 2108 ConnectionMonitor* monitor, const std::vector<ConnectionInfo> &infos) { |
2088 SignalConnectionMonitor(this, infos); | 2109 SignalConnectionMonitor(this, infos); |
2089 } | 2110 } |
2090 | 2111 |
2091 // TODO(pthatcher): Look into removing duplicate code between | 2112 // TODO(pthatcher): Look into removing duplicate code between |
2092 // audio, video, and data, perhaps by using templates. | 2113 // audio, video, and data, perhaps by using templates. |
2093 void VideoChannel::OnMediaMonitorUpdate( | 2114 void VideoChannel::OnMediaMonitorUpdate( |
2094 VideoMediaChannel* media_channel, const VideoMediaInfo &info) { | 2115 VideoMediaChannel* media_channel, const VideoMediaInfo &info) { |
2095 ASSERT(media_channel == this->media_channel()); | 2116 RTC_DCHECK(media_channel == this->media_channel()); |
2096 SignalMediaMonitor(this, info); | 2117 SignalMediaMonitor(this, info); |
2097 } | 2118 } |
2098 | 2119 |
2099 void VideoChannel::GetSrtpCryptoSuites_n( | 2120 void VideoChannel::GetSrtpCryptoSuites_n( |
2100 std::vector<int>* crypto_suites) const { | 2121 std::vector<int>* crypto_suites) const { |
2101 GetSupportedVideoCryptoSuites(crypto_options(), crypto_suites); | 2122 GetSupportedVideoCryptoSuites(crypto_options(), crypto_suites); |
2102 } | 2123 } |
2103 | 2124 |
2104 DataChannel::DataChannel(rtc::Thread* worker_thread, | 2125 DataChannel::DataChannel(rtc::Thread* worker_thread, |
2105 rtc::Thread* network_thread, | 2126 rtc::Thread* network_thread, |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2190 bool is_sctp = ((content->protocol() == kMediaProtocolSctp) || | 2211 bool is_sctp = ((content->protocol() == kMediaProtocolSctp) || |
2191 (content->protocol() == kMediaProtocolDtlsSctp)); | 2212 (content->protocol() == kMediaProtocolDtlsSctp)); |
2192 DataChannelType data_channel_type = is_sctp ? DCT_SCTP : DCT_RTP; | 2213 DataChannelType data_channel_type = is_sctp ? DCT_SCTP : DCT_RTP; |
2193 return SetDataChannelType(data_channel_type, error_desc); | 2214 return SetDataChannelType(data_channel_type, error_desc); |
2194 } | 2215 } |
2195 | 2216 |
2196 bool DataChannel::SetLocalContent_w(const MediaContentDescription* content, | 2217 bool DataChannel::SetLocalContent_w(const MediaContentDescription* content, |
2197 ContentAction action, | 2218 ContentAction action, |
2198 std::string* error_desc) { | 2219 std::string* error_desc) { |
2199 TRACE_EVENT0("webrtc", "DataChannel::SetLocalContent_w"); | 2220 TRACE_EVENT0("webrtc", "DataChannel::SetLocalContent_w"); |
2200 ASSERT(worker_thread() == rtc::Thread::Current()); | 2221 RTC_DCHECK(worker_thread() == rtc::Thread::Current()); |
2201 LOG(LS_INFO) << "Setting local data description"; | 2222 LOG(LS_INFO) << "Setting local data description"; |
2202 | 2223 |
2203 const DataContentDescription* data = | 2224 const DataContentDescription* data = |
2204 static_cast<const DataContentDescription*>(content); | 2225 static_cast<const DataContentDescription*>(content); |
2205 ASSERT(data != NULL); | 2226 RTC_DCHECK(data != NULL); |
2206 if (!data) { | 2227 if (!data) { |
2207 SafeSetError("Can't find data content in local description.", error_desc); | 2228 SafeSetError("Can't find data content in local description.", error_desc); |
2208 return false; | 2229 return false; |
2209 } | 2230 } |
2210 | 2231 |
2211 if (!SetDataChannelTypeFromContent(data, error_desc)) { | 2232 if (!SetDataChannelTypeFromContent(data, error_desc)) { |
2212 return false; | 2233 return false; |
2213 } | 2234 } |
2214 | 2235 |
2215 if (data_channel_type_ == DCT_RTP) { | 2236 if (data_channel_type_ == DCT_RTP) { |
(...skipping 22 matching lines...) Expand all Loading... | |
2238 // TODO(pthatcher): Move local streams into DataSendParameters, and | 2259 // TODO(pthatcher): Move local streams into DataSendParameters, and |
2239 // only give it to the media channel once we have a remote | 2260 // only give it to the media channel once we have a remote |
2240 // description too (without a remote description, we won't be able | 2261 // description too (without a remote description, we won't be able |
2241 // to send them anyway). | 2262 // to send them anyway). |
2242 if (!UpdateLocalStreams_w(data->streams(), action, error_desc)) { | 2263 if (!UpdateLocalStreams_w(data->streams(), action, error_desc)) { |
2243 SafeSetError("Failed to set local data description streams.", error_desc); | 2264 SafeSetError("Failed to set local data description streams.", error_desc); |
2244 return false; | 2265 return false; |
2245 } | 2266 } |
2246 | 2267 |
2247 set_local_content_direction(content->direction()); | 2268 set_local_content_direction(content->direction()); |
2248 ChangeState_w(); | 2269 UpdateMediaSendRecvState_w(); |
2249 return true; | 2270 return true; |
2250 } | 2271 } |
2251 | 2272 |
2252 bool DataChannel::SetRemoteContent_w(const MediaContentDescription* content, | 2273 bool DataChannel::SetRemoteContent_w(const MediaContentDescription* content, |
2253 ContentAction action, | 2274 ContentAction action, |
2254 std::string* error_desc) { | 2275 std::string* error_desc) { |
2255 TRACE_EVENT0("webrtc", "DataChannel::SetRemoteContent_w"); | 2276 TRACE_EVENT0("webrtc", "DataChannel::SetRemoteContent_w"); |
2256 ASSERT(worker_thread() == rtc::Thread::Current()); | 2277 RTC_DCHECK(worker_thread() == rtc::Thread::Current()); |
2257 | 2278 |
2258 const DataContentDescription* data = | 2279 const DataContentDescription* data = |
2259 static_cast<const DataContentDescription*>(content); | 2280 static_cast<const DataContentDescription*>(content); |
2260 ASSERT(data != NULL); | 2281 RTC_DCHECK(data != NULL); |
2261 if (!data) { | 2282 if (!data) { |
2262 SafeSetError("Can't find data content in remote description.", error_desc); | 2283 SafeSetError("Can't find data content in remote description.", error_desc); |
2263 return false; | 2284 return false; |
2264 } | 2285 } |
2265 | 2286 |
2266 // If the remote data doesn't have codecs and isn't an update, it | 2287 // If the remote data doesn't have codecs and isn't an update, it |
2267 // must be empty, so ignore it. | 2288 // must be empty, so ignore it. |
2268 if (!data->has_codecs() && action != CA_UPDATE) { | 2289 if (!data->has_codecs() && action != CA_UPDATE) { |
2269 return true; | 2290 return true; |
2270 } | 2291 } |
(...skipping 22 matching lines...) Expand all Loading... | |
2293 // and only give it to the media channel once we have a local | 2314 // and only give it to the media channel once we have a local |
2294 // description too (without a local description, we won't be able to | 2315 // description too (without a local description, we won't be able to |
2295 // recv them anyway). | 2316 // recv them anyway). |
2296 if (!UpdateRemoteStreams_w(data->streams(), action, error_desc)) { | 2317 if (!UpdateRemoteStreams_w(data->streams(), action, error_desc)) { |
2297 SafeSetError("Failed to set remote data description streams.", | 2318 SafeSetError("Failed to set remote data description streams.", |
2298 error_desc); | 2319 error_desc); |
2299 return false; | 2320 return false; |
2300 } | 2321 } |
2301 | 2322 |
2302 set_remote_content_direction(content->direction()); | 2323 set_remote_content_direction(content->direction()); |
2303 ChangeState_w(); | 2324 UpdateMediaSendRecvState_w(); |
2304 return true; | 2325 return true; |
2305 } | 2326 } |
2306 | 2327 |
2307 void DataChannel::ChangeState_w() { | 2328 void DataChannel::UpdateMediaSendRecvState_w() { |
2308 // Render incoming data if we're the active call, and we have the local | 2329 // Render incoming data if we're the active call, and we have the local |
2309 // content. We receive data on the default channel and multiplexed streams. | 2330 // content. We receive data on the default channel and multiplexed streams. |
2310 bool recv = IsReadyToReceive_w(); | 2331 bool recv = IsReadyToReceiveMedia_w(); |
2311 if (!media_channel()->SetReceive(recv)) { | 2332 if (!media_channel()->SetReceive(recv)) { |
2312 LOG(LS_ERROR) << "Failed to SetReceive on data channel"; | 2333 LOG(LS_ERROR) << "Failed to SetReceive on data channel"; |
2313 } | 2334 } |
2314 | 2335 |
2315 // Send outgoing data if we're the active call, we have the remote content, | 2336 // Send outgoing data if we're the active call, we have the remote content, |
2316 // and we have had some form of connectivity. | 2337 // and we have had some form of connectivity. |
2317 bool send = IsReadyToSend_w(); | 2338 bool send = IsReadyToSendMedia_w(); |
2318 if (!media_channel()->SetSend(send)) { | 2339 if (!media_channel()->SetSend(send)) { |
2319 LOG(LS_ERROR) << "Failed to SetSend on data channel"; | 2340 LOG(LS_ERROR) << "Failed to SetSend on data channel"; |
2320 } | 2341 } |
2321 | 2342 |
2322 // Trigger SignalReadyToSendData asynchronously. | 2343 // Trigger SignalReadyToSendData asynchronously. |
2323 OnDataChannelReadyToSend(send); | 2344 OnDataChannelReadyToSend(send); |
2324 | 2345 |
2325 LOG(LS_INFO) << "Changing data state, recv=" << recv << " send=" << send; | 2346 LOG(LS_INFO) << "Changing data state, recv=" << recv << " send=" << send; |
2326 } | 2347 } |
2327 | 2348 |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2377 void DataChannel::StopMediaMonitor() { | 2398 void DataChannel::StopMediaMonitor() { |
2378 if (media_monitor_) { | 2399 if (media_monitor_) { |
2379 media_monitor_->Stop(); | 2400 media_monitor_->Stop(); |
2380 media_monitor_->SignalUpdate.disconnect(this); | 2401 media_monitor_->SignalUpdate.disconnect(this); |
2381 media_monitor_.reset(); | 2402 media_monitor_.reset(); |
2382 } | 2403 } |
2383 } | 2404 } |
2384 | 2405 |
2385 void DataChannel::OnMediaMonitorUpdate( | 2406 void DataChannel::OnMediaMonitorUpdate( |
2386 DataMediaChannel* media_channel, const DataMediaInfo& info) { | 2407 DataMediaChannel* media_channel, const DataMediaInfo& info) { |
2387 ASSERT(media_channel == this->media_channel()); | 2408 RTC_DCHECK(media_channel == this->media_channel()); |
2388 SignalMediaMonitor(this, info); | 2409 SignalMediaMonitor(this, info); |
2389 } | 2410 } |
2390 | 2411 |
2391 void DataChannel::OnDataReceived( | 2412 void DataChannel::OnDataReceived( |
2392 const ReceiveDataParams& params, const char* data, size_t len) { | 2413 const ReceiveDataParams& params, const char* data, size_t len) { |
2393 DataReceivedMessageData* msg = new DataReceivedMessageData( | 2414 DataReceivedMessageData* msg = new DataReceivedMessageData( |
2394 params, data, len); | 2415 params, data, len); |
2395 signaling_thread()->Post(RTC_FROM_HERE, this, MSG_DATARECEIVED, msg); | 2416 signaling_thread()->Post(RTC_FROM_HERE, this, MSG_DATARECEIVED, msg); |
2396 } | 2417 } |
2397 | 2418 |
(...skipping 21 matching lines...) Expand all Loading... | |
2419 } | 2440 } |
2420 | 2441 |
2421 void DataChannel::OnStreamClosedRemotely(uint32_t sid) { | 2442 void DataChannel::OnStreamClosedRemotely(uint32_t sid) { |
2422 rtc::TypedMessageData<uint32_t>* message = | 2443 rtc::TypedMessageData<uint32_t>* message = |
2423 new rtc::TypedMessageData<uint32_t>(sid); | 2444 new rtc::TypedMessageData<uint32_t>(sid); |
2424 signaling_thread()->Post(RTC_FROM_HERE, this, MSG_STREAMCLOSEDREMOTELY, | 2445 signaling_thread()->Post(RTC_FROM_HERE, this, MSG_STREAMCLOSEDREMOTELY, |
2425 message); | 2446 message); |
2426 } | 2447 } |
2427 | 2448 |
2428 } // namespace cricket | 2449 } // namespace cricket |
OLD | NEW |