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

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

Issue 2019423006: Adding more detail to MessageQueue::Dispatch logging. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Fixing one more place where RTC_FROM_HERE wasn't used. Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « webrtc/pc/channel.h ('k') | webrtc/pc/channel_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2004 The WebRTC project authors. All Rights Reserved. 2 * Copyright 2004 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 // Eats any outstanding messages or packets. 200 // Eats any outstanding messages or packets.
201 worker_thread_->Clear(&invoker_); 201 worker_thread_->Clear(&invoker_);
202 worker_thread_->Clear(this); 202 worker_thread_->Clear(this);
203 // We must destroy the media channel before the transport channel, otherwise 203 // We must destroy the media channel before the transport channel, otherwise
204 // the media channel may try to send on the dead transport channel. NULLing 204 // the media channel may try to send on the dead transport channel. NULLing
205 // is not an effective strategy since the sends will come on another thread. 205 // is not an effective strategy since the sends will come on another thread.
206 delete media_channel_; 206 delete media_channel_;
207 // Note that we don't just call SetTransportChannel_n(nullptr) because that 207 // Note that we don't just call SetTransportChannel_n(nullptr) because that
208 // would call a pure virtual method which we can't do from a destructor. 208 // would call a pure virtual method which we can't do from a destructor.
209 network_thread_->Invoke<void>( 209 network_thread_->Invoke<void>(
210 Bind(&BaseChannel::DestroyTransportChannels_n, this)); 210 RTC_FROM_HERE, Bind(&BaseChannel::DestroyTransportChannels_n, this));
211 LOG(LS_INFO) << "Destroyed channel"; 211 LOG(LS_INFO) << "Destroyed channel";
212 } 212 }
213 213
214 void BaseChannel::DisconnectTransportChannels_n() { 214 void BaseChannel::DisconnectTransportChannels_n() {
215 // Send any outstanding RTCP packets. 215 // Send any outstanding RTCP packets.
216 FlushRtcpMessages_n(); 216 FlushRtcpMessages_n();
217 217
218 // Stop signals from transport channels, but keep them alive because 218 // Stop signals from transport channels, but keep them alive because
219 // media_channel may use them from a different thread. 219 // media_channel may use them from a different thread.
220 if (transport_channel_) { 220 if (transport_channel_) {
(...skipping 17 matching lines...) Expand all
238 transport_controller_->DestroyTransportChannel_n( 238 transport_controller_->DestroyTransportChannel_n(
239 transport_name_, cricket::ICE_CANDIDATE_COMPONENT_RTCP); 239 transport_name_, cricket::ICE_CANDIDATE_COMPONENT_RTCP);
240 } 240 }
241 // Clear pending send packets/messages. 241 // Clear pending send packets/messages.
242 network_thread_->Clear(&invoker_); 242 network_thread_->Clear(&invoker_);
243 network_thread_->Clear(this); 243 network_thread_->Clear(this);
244 } 244 }
245 245
246 bool BaseChannel::Init_w(const std::string* bundle_transport_name) { 246 bool BaseChannel::Init_w(const std::string* bundle_transport_name) {
247 if (!network_thread_->Invoke<bool>( 247 if (!network_thread_->Invoke<bool>(
248 RTC_FROM_HERE,
248 Bind(&BaseChannel::InitNetwork_n, this, bundle_transport_name))) { 249 Bind(&BaseChannel::InitNetwork_n, this, bundle_transport_name))) {
249 return false; 250 return false;
250 } 251 }
251 252
252 // Both RTP and RTCP channels are set, we can call SetInterface on 253 // Both RTP and RTCP channels are set, we can call SetInterface on
253 // media channel and it can set network options. 254 // media channel and it can set network options.
254 RTC_DCHECK(worker_thread_->IsCurrent()); 255 RTC_DCHECK(worker_thread_->IsCurrent());
255 media_channel_->SetInterface(this); 256 media_channel_->SetInterface(this);
256 return true; 257 return true;
257 } 258 }
(...skipping 16 matching lines...) Expand all
274 return true; 275 return true;
275 } 276 }
276 277
277 void BaseChannel::Deinit() { 278 void BaseChannel::Deinit() {
278 RTC_DCHECK(worker_thread_->IsCurrent()); 279 RTC_DCHECK(worker_thread_->IsCurrent());
279 media_channel_->SetInterface(NULL); 280 media_channel_->SetInterface(NULL);
280 // Packets arrive on the network thread, processing packets calls virtual 281 // Packets arrive on the network thread, processing packets calls virtual
281 // functions, so need to stop this process in Deinit that is called in 282 // functions, so need to stop this process in Deinit that is called in
282 // derived classes destructor. 283 // derived classes destructor.
283 network_thread_->Invoke<void>( 284 network_thread_->Invoke<void>(
284 Bind(&BaseChannel::DisconnectTransportChannels_n, this)); 285 RTC_FROM_HERE, Bind(&BaseChannel::DisconnectTransportChannels_n, this));
285 } 286 }
286 287
287 bool BaseChannel::SetTransport(const std::string& transport_name) { 288 bool BaseChannel::SetTransport(const std::string& transport_name) {
288 return network_thread_->Invoke<bool>( 289 return network_thread_->Invoke<bool>(
289 Bind(&BaseChannel::SetTransport_n, this, transport_name)); 290 RTC_FROM_HERE, Bind(&BaseChannel::SetTransport_n, this, transport_name));
290 } 291 }
291 292
292 bool BaseChannel::SetTransport_n(const std::string& transport_name) { 293 bool BaseChannel::SetTransport_n(const std::string& transport_name) {
293 RTC_DCHECK(network_thread_->IsCurrent()); 294 RTC_DCHECK(network_thread_->IsCurrent());
294 295
295 if (transport_name == transport_name_) { 296 if (transport_name == transport_name_) {
296 // Nothing to do if transport name isn't changing 297 // Nothing to do if transport name isn't changing
297 return true; 298 return true;
298 } 299 }
299 300
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
423 424
424 tc->SignalWritableState.disconnect(this); 425 tc->SignalWritableState.disconnect(this);
425 tc->SignalReadPacket.disconnect(this); 426 tc->SignalReadPacket.disconnect(this);
426 tc->SignalReadyToSend.disconnect(this); 427 tc->SignalReadyToSend.disconnect(this);
427 tc->SignalDtlsState.disconnect(this); 428 tc->SignalDtlsState.disconnect(this);
428 tc->SignalSelectedCandidatePairChanged.disconnect(this); 429 tc->SignalSelectedCandidatePairChanged.disconnect(this);
429 tc->SignalSentPacket.disconnect(this); 430 tc->SignalSentPacket.disconnect(this);
430 } 431 }
431 432
432 bool BaseChannel::Enable(bool enable) { 433 bool BaseChannel::Enable(bool enable) {
433 worker_thread_->Invoke<void>(Bind( 434 worker_thread_->Invoke<void>(
434 enable ? &BaseChannel::EnableMedia_w : &BaseChannel::DisableMedia_w, 435 RTC_FROM_HERE,
435 this)); 436 Bind(enable ? &BaseChannel::EnableMedia_w : &BaseChannel::DisableMedia_w,
437 this));
436 return true; 438 return true;
437 } 439 }
438 440
439 bool BaseChannel::AddRecvStream(const StreamParams& sp) { 441 bool BaseChannel::AddRecvStream(const StreamParams& sp) {
440 return InvokeOnWorker(Bind(&BaseChannel::AddRecvStream_w, this, sp)); 442 return InvokeOnWorker(RTC_FROM_HERE,
443 Bind(&BaseChannel::AddRecvStream_w, this, sp));
441 } 444 }
442 445
443 bool BaseChannel::RemoveRecvStream(uint32_t ssrc) { 446 bool BaseChannel::RemoveRecvStream(uint32_t ssrc) {
444 return InvokeOnWorker(Bind(&BaseChannel::RemoveRecvStream_w, this, ssrc)); 447 return InvokeOnWorker(RTC_FROM_HERE,
448 Bind(&BaseChannel::RemoveRecvStream_w, this, ssrc));
445 } 449 }
446 450
447 bool BaseChannel::AddSendStream(const StreamParams& sp) { 451 bool BaseChannel::AddSendStream(const StreamParams& sp) {
448 return InvokeOnWorker( 452 return InvokeOnWorker(
449 Bind(&MediaChannel::AddSendStream, media_channel(), sp)); 453 RTC_FROM_HERE, Bind(&MediaChannel::AddSendStream, media_channel(), sp));
450 } 454 }
451 455
452 bool BaseChannel::RemoveSendStream(uint32_t ssrc) { 456 bool BaseChannel::RemoveSendStream(uint32_t ssrc) {
453 return InvokeOnWorker( 457 return InvokeOnWorker(RTC_FROM_HERE, Bind(&MediaChannel::RemoveSendStream,
454 Bind(&MediaChannel::RemoveSendStream, media_channel(), ssrc)); 458 media_channel(), ssrc));
455 } 459 }
456 460
457 bool BaseChannel::SetLocalContent(const MediaContentDescription* content, 461 bool BaseChannel::SetLocalContent(const MediaContentDescription* content,
458 ContentAction action, 462 ContentAction action,
459 std::string* error_desc) { 463 std::string* error_desc) {
460 TRACE_EVENT0("webrtc", "BaseChannel::SetLocalContent"); 464 TRACE_EVENT0("webrtc", "BaseChannel::SetLocalContent");
461 return InvokeOnWorker(Bind(&BaseChannel::SetLocalContent_w, 465 return InvokeOnWorker(RTC_FROM_HERE, Bind(&BaseChannel::SetLocalContent_w,
462 this, content, action, error_desc)); 466 this, content, action, error_desc));
463 } 467 }
464 468
465 bool BaseChannel::SetRemoteContent(const MediaContentDescription* content, 469 bool BaseChannel::SetRemoteContent(const MediaContentDescription* content,
466 ContentAction action, 470 ContentAction action,
467 std::string* error_desc) { 471 std::string* error_desc) {
468 TRACE_EVENT0("webrtc", "BaseChannel::SetRemoteContent"); 472 TRACE_EVENT0("webrtc", "BaseChannel::SetRemoteContent");
469 return InvokeOnWorker(Bind(&BaseChannel::SetRemoteContent_w, 473 return InvokeOnWorker(RTC_FROM_HERE, Bind(&BaseChannel::SetRemoteContent_w,
470 this, content, action, error_desc)); 474 this, content, action, error_desc));
471 } 475 }
472 476
473 void BaseChannel::StartConnectionMonitor(int cms) { 477 void BaseChannel::StartConnectionMonitor(int cms) {
474 // We pass in the BaseChannel instead of the transport_channel_ 478 // We pass in the BaseChannel instead of the transport_channel_
475 // because if the transport_channel_ changes, the ConnectionMonitor 479 // because if the transport_channel_ changes, the ConnectionMonitor
476 // would be pointing to the wrong TransportChannel. 480 // would be pointing to the wrong TransportChannel.
477 // We pass in the network thread because on that thread connection monitor 481 // We pass in the network thread because on that thread connection monitor
478 // will call BaseChannel::GetConnectionStats which must be called on the 482 // will call BaseChannel::GetConnectionStats which must be called on the
479 // network thread. 483 // network thread.
480 connection_monitor_.reset( 484 connection_monitor_.reset(
(...skipping 19 matching lines...) Expand all
500 // Receive data if we are enabled and have local content, 504 // Receive data if we are enabled and have local content,
501 return enabled() && IsReceiveContentDirection(local_content_direction_); 505 return enabled() && IsReceiveContentDirection(local_content_direction_);
502 } 506 }
503 507
504 bool BaseChannel::IsReadyToSend_w() const { 508 bool BaseChannel::IsReadyToSend_w() const {
505 // Send outgoing data if we are enabled, have local and remote content, 509 // Send outgoing data if we are enabled, have local and remote content,
506 // and we have had some form of connectivity. 510 // and we have had some form of connectivity.
507 return enabled() && IsReceiveContentDirection(remote_content_direction_) && 511 return enabled() && IsReceiveContentDirection(remote_content_direction_) &&
508 IsSendContentDirection(local_content_direction_) && 512 IsSendContentDirection(local_content_direction_) &&
509 network_thread_->Invoke<bool>( 513 network_thread_->Invoke<bool>(
510 Bind(&BaseChannel::IsTransportReadyToSend_n, this)); 514 RTC_FROM_HERE, Bind(&BaseChannel::IsTransportReadyToSend_n, this));
511 } 515 }
512 516
513 bool BaseChannel::IsTransportReadyToSend_n() const { 517 bool BaseChannel::IsTransportReadyToSend_n() const {
514 return was_ever_writable() && 518 return was_ever_writable() &&
515 (srtp_filter_.IsActive() || !ShouldSetupDtlsSrtp_n()); 519 (srtp_filter_.IsActive() || !ShouldSetupDtlsSrtp_n());
516 } 520 }
517 521
518 bool BaseChannel::SendPacket(rtc::CopyOnWriteBuffer* packet, 522 bool BaseChannel::SendPacket(rtc::CopyOnWriteBuffer* packet,
519 const rtc::PacketOptions& options) { 523 const rtc::PacketOptions& options) {
520 return SendPacket(false, packet, options); 524 return SendPacket(false, packet, options);
521 } 525 }
522 526
523 bool BaseChannel::SendRtcp(rtc::CopyOnWriteBuffer* packet, 527 bool BaseChannel::SendRtcp(rtc::CopyOnWriteBuffer* packet,
524 const rtc::PacketOptions& options) { 528 const rtc::PacketOptions& options) {
525 return SendPacket(true, packet, options); 529 return SendPacket(true, packet, options);
526 } 530 }
527 531
528 int BaseChannel::SetOption(SocketType type, rtc::Socket::Option opt, 532 int BaseChannel::SetOption(SocketType type, rtc::Socket::Option opt,
529 int value) { 533 int value) {
530 return network_thread_->Invoke<int>( 534 return network_thread_->Invoke<int>(
531 Bind(&BaseChannel::SetOption_n, this, type, opt, value)); 535 RTC_FROM_HERE, Bind(&BaseChannel::SetOption_n, this, type, opt, value));
532 } 536 }
533 537
534 int BaseChannel::SetOption_n(SocketType type, 538 int BaseChannel::SetOption_n(SocketType type,
535 rtc::Socket::Option opt, 539 rtc::Socket::Option opt,
536 int value) { 540 int value) {
537 RTC_DCHECK(network_thread_->IsCurrent()); 541 RTC_DCHECK(network_thread_->IsCurrent());
538 TransportChannel* channel = nullptr; 542 TransportChannel* channel = nullptr;
539 switch (type) { 543 switch (type) {
540 case ST_RTP: 544 case ST_RTP:
541 channel = transport_channel_; 545 channel = transport_channel_;
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
602 RTC_DCHECK(network_thread_->IsCurrent()); 606 RTC_DCHECK(network_thread_->IsCurrent());
603 std::string transport_name = channel->transport_name(); 607 std::string transport_name = channel->transport_name();
604 rtc::NetworkRoute network_route; 608 rtc::NetworkRoute network_route;
605 if (selected_candidate_pair) { 609 if (selected_candidate_pair) {
606 network_route = rtc::NetworkRoute( 610 network_route = rtc::NetworkRoute(
607 selected_candidate_pair->local_candidate().network_id(), 611 selected_candidate_pair->local_candidate().network_id(),
608 selected_candidate_pair->remote_candidate().network_id(), 612 selected_candidate_pair->remote_candidate().network_id(),
609 last_sent_packet_id); 613 last_sent_packet_id);
610 } 614 }
611 invoker_.AsyncInvoke<void>( 615 invoker_.AsyncInvoke<void>(
612 worker_thread_, Bind(&MediaChannel::OnNetworkRouteChanged, media_channel_, 616 RTC_FROM_HERE, worker_thread_,
613 transport_name, network_route)); 617 Bind(&MediaChannel::OnNetworkRouteChanged, media_channel_, transport_name,
618 network_route));
614 } 619 }
615 620
616 void BaseChannel::SetReadyToSend(bool rtcp, bool ready) { 621 void BaseChannel::SetReadyToSend(bool rtcp, bool ready) {
617 RTC_DCHECK(network_thread_->IsCurrent()); 622 RTC_DCHECK(network_thread_->IsCurrent());
618 if (rtcp) { 623 if (rtcp) {
619 rtcp_ready_to_send_ = ready; 624 rtcp_ready_to_send_ = ready;
620 } else { 625 } else {
621 rtp_ready_to_send_ = ready; 626 rtp_ready_to_send_ = ready;
622 } 627 }
623 628
624 bool ready_to_send = 629 bool ready_to_send =
625 (rtp_ready_to_send_ && 630 (rtp_ready_to_send_ &&
626 // In the case of rtcp mux |rtcp_transport_channel_| will be null. 631 // In the case of rtcp mux |rtcp_transport_channel_| will be null.
627 (rtcp_ready_to_send_ || !rtcp_transport_channel_)); 632 (rtcp_ready_to_send_ || !rtcp_transport_channel_));
628 633
629 invoker_.AsyncInvoke<void>( 634 invoker_.AsyncInvoke<void>(
630 worker_thread_, 635 RTC_FROM_HERE, worker_thread_,
631 Bind(&MediaChannel::OnReadyToSend, media_channel_, ready_to_send)); 636 Bind(&MediaChannel::OnReadyToSend, media_channel_, ready_to_send));
632 } 637 }
633 638
634 bool BaseChannel::PacketIsRtcp(const TransportChannel* channel, 639 bool BaseChannel::PacketIsRtcp(const TransportChannel* channel,
635 const char* data, size_t len) { 640 const char* data, size_t len) {
636 return (channel == rtcp_transport_channel_ || 641 return (channel == rtcp_transport_channel_ ||
637 rtcp_mux_filter_.DemuxRtcp(data, static_cast<int>(len))); 642 rtcp_mux_filter_.DemuxRtcp(data, static_cast<int>(len)));
638 } 643 }
639 644
640 bool BaseChannel::SendPacket(bool rtcp, 645 bool BaseChannel::SendPacket(bool rtcp,
641 rtc::CopyOnWriteBuffer* packet, 646 rtc::CopyOnWriteBuffer* packet,
642 const rtc::PacketOptions& options) { 647 const rtc::PacketOptions& options) {
643 // SendPacket gets called from MediaEngine, on a pacer or an encoder thread. 648 // SendPacket gets called from MediaEngine, on a pacer or an encoder thread.
644 // If the thread is not our network thread, we will post to our network 649 // If the thread is not our network thread, we will post to our network
645 // so that the real work happens on our network. This avoids us having to 650 // so that the real work happens on our network. This avoids us having to
646 // synchronize access to all the pieces of the send path, including 651 // synchronize access to all the pieces of the send path, including
647 // SRTP and the inner workings of the transport channels. 652 // SRTP and the inner workings of the transport channels.
648 // The only downside is that we can't return a proper failure code if 653 // The only downside is that we can't return a proper failure code if
649 // needed. Since UDP is unreliable anyway, this should be a non-issue. 654 // needed. Since UDP is unreliable anyway, this should be a non-issue.
650 if (!network_thread_->IsCurrent()) { 655 if (!network_thread_->IsCurrent()) {
651 // Avoid a copy by transferring the ownership of the packet data. 656 // Avoid a copy by transferring the ownership of the packet data.
652 int message_id = rtcp ? MSG_SEND_RTCP_PACKET : MSG_SEND_RTP_PACKET; 657 int message_id = rtcp ? MSG_SEND_RTCP_PACKET : MSG_SEND_RTP_PACKET;
653 SendPacketMessageData* data = new SendPacketMessageData; 658 SendPacketMessageData* data = new SendPacketMessageData;
654 data->packet = std::move(*packet); 659 data->packet = std::move(*packet);
655 data->options = options; 660 data->options = options;
656 network_thread_->Post(this, message_id, data); 661 network_thread_->Post(RTC_FROM_HERE, this, message_id, data);
657 return true; 662 return true;
658 } 663 }
659 TRACE_EVENT0("webrtc", "BaseChannel::SendPacket"); 664 TRACE_EVENT0("webrtc", "BaseChannel::SendPacket");
660 665
661 // Now that we are on the correct thread, ensure we have a place to send this 666 // Now that we are on the correct thread, ensure we have a place to send this
662 // packet before doing anything. (We might get RTCP packets that we don't 667 // packet before doing anything. (We might get RTCP packets that we don't
663 // intend to send.) If we've negotiated RTCP mux, send RTCP over the RTP 668 // intend to send.) If we've negotiated RTCP mux, send RTCP over the RTP
664 // transport. 669 // transport.
665 TransportChannel* channel = (!rtcp || rtcp_mux_filter_.IsActive()) ? 670 TransportChannel* channel = (!rtcp || rtcp_mux_filter_.IsActive()) ?
666 transport_channel_ : rtcp_transport_channel_; 671 transport_channel_ : rtcp_transport_channel_;
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
781 const rtc::PacketTime& packet_time) { 786 const rtc::PacketTime& packet_time) {
782 RTC_DCHECK(network_thread_->IsCurrent()); 787 RTC_DCHECK(network_thread_->IsCurrent());
783 if (!WantsPacket(rtcp, packet)) { 788 if (!WantsPacket(rtcp, packet)) {
784 return; 789 return;
785 } 790 }
786 791
787 // We are only interested in the first rtp packet because that 792 // We are only interested in the first rtp packet because that
788 // indicates the media has started flowing. 793 // indicates the media has started flowing.
789 if (!has_received_packet_ && !rtcp) { 794 if (!has_received_packet_ && !rtcp) {
790 has_received_packet_ = true; 795 has_received_packet_ = true;
791 signaling_thread()->Post(this, MSG_FIRSTPACKETRECEIVED); 796 signaling_thread()->Post(RTC_FROM_HERE, this, MSG_FIRSTPACKETRECEIVED);
792 } 797 }
793 798
794 // Unprotect the packet, if needed. 799 // Unprotect the packet, if needed.
795 if (srtp_filter_.IsActive()) { 800 if (srtp_filter_.IsActive()) {
796 TRACE_EVENT0("webrtc", "SRTP Decode"); 801 TRACE_EVENT0("webrtc", "SRTP Decode");
797 char* data = packet->data<char>(); 802 char* data = packet->data<char>();
798 int len = static_cast<int>(packet->size()); 803 int len = static_cast<int>(packet->size());
799 bool res; 804 bool res;
800 if (!rtcp) { 805 if (!rtcp) {
801 res = srtp_filter_.UnprotectRtp(data, len, &len); 806 res = srtp_filter_.UnprotectRtp(data, len, &len);
(...skipping 29 matching lines...) Expand all
831 // on the channel that the packets are being sent on. It's really good 836 // on the channel that the packets are being sent on. It's really good
832 // practice to wait for both RTP and RTCP to be good to go before sending 837 // practice to wait for both RTP and RTCP to be good to go before sending
833 // media, to prevent weird failure modes, so it's fine for us to just eat 838 // media, to prevent weird failure modes, so it's fine for us to just eat
834 // packets here. This is all sidestepped if RTCP mux is used anyway. 839 // packets here. This is all sidestepped if RTCP mux is used anyway.
835 LOG(LS_WARNING) << "Can't process incoming " << PacketType(rtcp) 840 LOG(LS_WARNING) << "Can't process incoming " << PacketType(rtcp)
836 << " packet when SRTP is inactive and crypto is required"; 841 << " packet when SRTP is inactive and crypto is required";
837 return; 842 return;
838 } 843 }
839 844
840 invoker_.AsyncInvoke<void>( 845 invoker_.AsyncInvoke<void>(
841 worker_thread_, 846 RTC_FROM_HERE, worker_thread_,
842 Bind(&BaseChannel::OnPacketReceived, this, rtcp, *packet, packet_time)); 847 Bind(&BaseChannel::OnPacketReceived, this, rtcp, *packet, packet_time));
843 } 848 }
844 849
845 void BaseChannel::OnPacketReceived(bool rtcp, 850 void BaseChannel::OnPacketReceived(bool rtcp,
846 const rtc::CopyOnWriteBuffer& packet, 851 const rtc::CopyOnWriteBuffer& packet,
847 const rtc::PacketTime& packet_time) { 852 const rtc::PacketTime& packet_time) {
848 RTC_DCHECK(worker_thread_->IsCurrent()); 853 RTC_DCHECK(worker_thread_->IsCurrent());
849 // Need to copy variable because OnRtcpReceived/OnPacketReceived 854 // Need to copy variable because OnRtcpReceived/OnPacketReceived
850 // requires non-const pointer to buffer. This doesn't memcpy the actual data. 855 // requires non-const pointer to buffer. This doesn't memcpy the actual data.
851 rtc::CopyOnWriteBuffer data(packet); 856 rtc::CopyOnWriteBuffer data(packet);
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
935 940
936 was_ever_writable_ = true; 941 was_ever_writable_ = true;
937 MaybeSetupDtlsSrtp_n(); 942 MaybeSetupDtlsSrtp_n();
938 writable_ = true; 943 writable_ = true;
939 ChangeState(); 944 ChangeState();
940 } 945 }
941 946
942 void BaseChannel::SignalDtlsSetupFailure_n(bool rtcp) { 947 void BaseChannel::SignalDtlsSetupFailure_n(bool rtcp) {
943 RTC_DCHECK(network_thread_->IsCurrent()); 948 RTC_DCHECK(network_thread_->IsCurrent());
944 invoker_.AsyncInvoke<void>( 949 invoker_.AsyncInvoke<void>(
945 signaling_thread(), 950 RTC_FROM_HERE, signaling_thread(),
946 Bind(&BaseChannel::SignalDtlsSetupFailure_s, this, rtcp)); 951 Bind(&BaseChannel::SignalDtlsSetupFailure_s, this, rtcp));
947 } 952 }
948 953
949 void BaseChannel::SignalDtlsSetupFailure_s(bool rtcp) { 954 void BaseChannel::SignalDtlsSetupFailure_s(bool rtcp) {
950 ASSERT(signaling_thread() == rtc::Thread::Current()); 955 ASSERT(signaling_thread() == rtc::Thread::Current());
951 SignalDtlsSetupFailure(this, rtcp); 956 SignalDtlsSetupFailure(this, rtcp);
952 } 957 }
953 958
954 bool BaseChannel::SetDtlsSrtpCryptoSuites_n(TransportChannel* tc, bool rtcp) { 959 bool BaseChannel::SetDtlsSrtpCryptoSuites_n(TransportChannel* tc, bool rtcp) {
955 std::vector<int> crypto_suites; 960 std::vector<int> crypto_suites;
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
1094 ContentAction action, 1099 ContentAction action,
1095 ContentSource src, 1100 ContentSource src,
1096 std::string* error_desc) { 1101 std::string* error_desc) {
1097 if (action == CA_UPDATE) { 1102 if (action == CA_UPDATE) {
1098 // These parameters never get changed by a CA_UDPATE. 1103 // These parameters never get changed by a CA_UDPATE.
1099 return true; 1104 return true;
1100 } 1105 }
1101 1106
1102 // Cache secure_required_ for belt and suspenders check on SendPacket 1107 // Cache secure_required_ for belt and suspenders check on SendPacket
1103 return network_thread_->Invoke<bool>( 1108 return network_thread_->Invoke<bool>(
1104 Bind(&BaseChannel::SetRtpTransportParameters_n, this, content, action, 1109 RTC_FROM_HERE, Bind(&BaseChannel::SetRtpTransportParameters_n, this,
1105 src, error_desc)); 1110 content, action, src, error_desc));
1106 } 1111 }
1107 1112
1108 bool BaseChannel::SetRtpTransportParameters_n( 1113 bool BaseChannel::SetRtpTransportParameters_n(
1109 const MediaContentDescription* content, 1114 const MediaContentDescription* content,
1110 ContentAction action, 1115 ContentAction action,
1111 ContentSource src, 1116 ContentSource src,
1112 std::string* error_desc) { 1117 std::string* error_desc) {
1113 RTC_DCHECK(network_thread_->IsCurrent()); 1118 RTC_DCHECK(network_thread_->IsCurrent());
1114 1119
1115 if (src == CS_LOCAL) { 1120 if (src == CS_LOCAL) {
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
1181 break; 1186 break;
1182 } 1187 }
1183 if (!ret) { 1188 if (!ret) {
1184 SafeSetError("Failed to setup SRTP filter.", error_desc); 1189 SafeSetError("Failed to setup SRTP filter.", error_desc);
1185 return false; 1190 return false;
1186 } 1191 }
1187 return true; 1192 return true;
1188 } 1193 }
1189 1194
1190 void BaseChannel::ActivateRtcpMux() { 1195 void BaseChannel::ActivateRtcpMux() {
1191 network_thread_->Invoke<void>(Bind(&BaseChannel::ActivateRtcpMux_n, this)); 1196 network_thread_->Invoke<void>(RTC_FROM_HERE,
1197 Bind(&BaseChannel::ActivateRtcpMux_n, this));
1192 } 1198 }
1193 1199
1194 void BaseChannel::ActivateRtcpMux_n() { 1200 void BaseChannel::ActivateRtcpMux_n() {
1195 if (!rtcp_mux_filter_.IsActive()) { 1201 if (!rtcp_mux_filter_.IsActive()) {
1196 rtcp_mux_filter_.SetActive(); 1202 rtcp_mux_filter_.SetActive();
1197 SetRtcpTransportChannel_n(nullptr, true); 1203 SetRtcpTransportChannel_n(nullptr, true);
1198 rtcp_transport_enabled_ = false; 1204 rtcp_transport_enabled_ = false;
1199 } 1205 }
1200 } 1206 }
1201 1207
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after
1407 const std::vector<webrtc::RtpExtension>& extensions) { 1413 const std::vector<webrtc::RtpExtension>& extensions) {
1408 // Absolute Send Time extension id is used only with external auth, 1414 // Absolute Send Time extension id is used only with external auth,
1409 // so do not bother searching for it and making asyncronious call to set 1415 // so do not bother searching for it and making asyncronious call to set
1410 // something that is not used. 1416 // something that is not used.
1411 #if defined(ENABLE_EXTERNAL_AUTH) 1417 #if defined(ENABLE_EXTERNAL_AUTH)
1412 const webrtc::RtpExtension* send_time_extension = 1418 const webrtc::RtpExtension* send_time_extension =
1413 FindHeaderExtension(extensions, webrtc::RtpExtension::kAbsSendTimeUri); 1419 FindHeaderExtension(extensions, webrtc::RtpExtension::kAbsSendTimeUri);
1414 int rtp_abs_sendtime_extn_id = 1420 int rtp_abs_sendtime_extn_id =
1415 send_time_extension ? send_time_extension->id : -1; 1421 send_time_extension ? send_time_extension->id : -1;
1416 invoker_.AsyncInvoke<void>( 1422 invoker_.AsyncInvoke<void>(
1417 network_thread_, Bind(&BaseChannel::CacheRtpAbsSendTimeHeaderExtension_n, 1423 RTC_FROM_HERE, network_thread_,
1418 this, rtp_abs_sendtime_extn_id)); 1424 Bind(&BaseChannel::CacheRtpAbsSendTimeHeaderExtension_n, this,
1425 rtp_abs_sendtime_extn_id));
1419 #endif 1426 #endif
1420 } 1427 }
1421 1428
1422 void BaseChannel::CacheRtpAbsSendTimeHeaderExtension_n( 1429 void BaseChannel::CacheRtpAbsSendTimeHeaderExtension_n(
1423 int rtp_abs_sendtime_extn_id) { 1430 int rtp_abs_sendtime_extn_id) {
1424 rtp_abs_sendtime_extn_id_ = rtp_abs_sendtime_extn_id; 1431 rtp_abs_sendtime_extn_id_ = rtp_abs_sendtime_extn_id;
1425 } 1432 }
1426 1433
1427 void BaseChannel::OnMessage(rtc::Message *pmsg) { 1434 void BaseChannel::OnMessage(rtc::Message *pmsg) {
1428 TRACE_EVENT0("webrtc", "BaseChannel::OnMessage"); 1435 TRACE_EVENT0("webrtc", "BaseChannel::OnMessage");
(...skipping 15 matching lines...) Expand all
1444 } 1451 }
1445 } 1452 }
1446 1453
1447 void BaseChannel::FlushRtcpMessages_n() { 1454 void BaseChannel::FlushRtcpMessages_n() {
1448 // Flush all remaining RTCP messages. This should only be called in 1455 // Flush all remaining RTCP messages. This should only be called in
1449 // destructor. 1456 // destructor.
1450 RTC_DCHECK(network_thread_->IsCurrent()); 1457 RTC_DCHECK(network_thread_->IsCurrent());
1451 rtc::MessageList rtcp_messages; 1458 rtc::MessageList rtcp_messages;
1452 network_thread_->Clear(this, MSG_SEND_RTCP_PACKET, &rtcp_messages); 1459 network_thread_->Clear(this, MSG_SEND_RTCP_PACKET, &rtcp_messages);
1453 for (const auto& message : rtcp_messages) { 1460 for (const auto& message : rtcp_messages) {
1454 network_thread_->Send(this, MSG_SEND_RTCP_PACKET, message.pdata); 1461 network_thread_->Send(RTC_FROM_HERE, this, MSG_SEND_RTCP_PACKET,
1462 message.pdata);
1455 } 1463 }
1456 } 1464 }
1457 1465
1458 void BaseChannel::SignalSentPacket_n(TransportChannel* /* channel */, 1466 void BaseChannel::SignalSentPacket_n(TransportChannel* /* channel */,
1459 const rtc::SentPacket& sent_packet) { 1467 const rtc::SentPacket& sent_packet) {
1460 RTC_DCHECK(network_thread_->IsCurrent()); 1468 RTC_DCHECK(network_thread_->IsCurrent());
1461 invoker_.AsyncInvoke<void>( 1469 invoker_.AsyncInvoke<void>(
1462 worker_thread_, 1470 RTC_FROM_HERE, worker_thread_,
1463 rtc::Bind(&BaseChannel::SignalSentPacket_w, this, sent_packet)); 1471 rtc::Bind(&BaseChannel::SignalSentPacket_w, this, sent_packet));
1464 } 1472 }
1465 1473
1466 void BaseChannel::SignalSentPacket_w(const rtc::SentPacket& sent_packet) { 1474 void BaseChannel::SignalSentPacket_w(const rtc::SentPacket& sent_packet) {
1467 RTC_DCHECK(worker_thread_->IsCurrent()); 1475 RTC_DCHECK(worker_thread_->IsCurrent());
1468 SignalSentPacket(sent_packet); 1476 SignalSentPacket(sent_packet);
1469 } 1477 }
1470 1478
1471 VoiceChannel::VoiceChannel(rtc::Thread* worker_thread, 1479 VoiceChannel::VoiceChannel(rtc::Thread* worker_thread,
1472 rtc::Thread* network_thread, 1480 rtc::Thread* network_thread,
(...skipping 24 matching lines...) Expand all
1497 if (!BaseChannel::Init_w(bundle_transport_name)) { 1505 if (!BaseChannel::Init_w(bundle_transport_name)) {
1498 return false; 1506 return false;
1499 } 1507 }
1500 return true; 1508 return true;
1501 } 1509 }
1502 1510
1503 bool VoiceChannel::SetAudioSend(uint32_t ssrc, 1511 bool VoiceChannel::SetAudioSend(uint32_t ssrc,
1504 bool enable, 1512 bool enable,
1505 const AudioOptions* options, 1513 const AudioOptions* options,
1506 AudioSource* source) { 1514 AudioSource* source) {
1507 return InvokeOnWorker(Bind(&VoiceMediaChannel::SetAudioSend, media_channel(), 1515 return InvokeOnWorker(RTC_FROM_HERE,
1516 Bind(&VoiceMediaChannel::SetAudioSend, media_channel(),
1508 ssrc, enable, options, source)); 1517 ssrc, enable, options, source));
1509 } 1518 }
1510 1519
1511 // TODO(juberti): Handle early media the right way. We should get an explicit 1520 // TODO(juberti): Handle early media the right way. We should get an explicit
1512 // ringing message telling us to start playing local ringback, which we cancel 1521 // ringing message telling us to start playing local ringback, which we cancel
1513 // if any early media actually arrives. For now, we do the opposite, which is 1522 // if any early media actually arrives. For now, we do the opposite, which is
1514 // to wait 1 second for early media, and start playing local ringback if none 1523 // to wait 1 second for early media, and start playing local ringback if none
1515 // arrives. 1524 // arrives.
1516 void VoiceChannel::SetEarlyMedia(bool enable) { 1525 void VoiceChannel::SetEarlyMedia(bool enable) {
1517 if (enable) { 1526 if (enable) {
1518 // Start the early media timeout 1527 // Start the early media timeout
1519 worker_thread()->PostDelayed(kEarlyMediaTimeout, this, 1528 worker_thread()->PostDelayed(RTC_FROM_HERE, kEarlyMediaTimeout, this,
1520 MSG_EARLYMEDIATIMEOUT); 1529 MSG_EARLYMEDIATIMEOUT);
1521 } else { 1530 } else {
1522 // Stop the timeout if currently going. 1531 // Stop the timeout if currently going.
1523 worker_thread()->Clear(this, MSG_EARLYMEDIATIMEOUT); 1532 worker_thread()->Clear(this, MSG_EARLYMEDIATIMEOUT);
1524 } 1533 }
1525 } 1534 }
1526 1535
1527 bool VoiceChannel::CanInsertDtmf() { 1536 bool VoiceChannel::CanInsertDtmf() {
1528 return InvokeOnWorker(Bind(&VoiceMediaChannel::CanInsertDtmf, 1537 return InvokeOnWorker(
1529 media_channel())); 1538 RTC_FROM_HERE, Bind(&VoiceMediaChannel::CanInsertDtmf, media_channel()));
1530 } 1539 }
1531 1540
1532 bool VoiceChannel::InsertDtmf(uint32_t ssrc, 1541 bool VoiceChannel::InsertDtmf(uint32_t ssrc,
1533 int event_code, 1542 int event_code,
1534 int duration) { 1543 int duration) {
1535 return InvokeOnWorker(Bind(&VoiceChannel::InsertDtmf_w, this, 1544 return InvokeOnWorker(RTC_FROM_HERE, Bind(&VoiceChannel::InsertDtmf_w, this,
1536 ssrc, event_code, duration)); 1545 ssrc, event_code, duration));
1537 } 1546 }
1538 1547
1539 bool VoiceChannel::SetOutputVolume(uint32_t ssrc, double volume) { 1548 bool VoiceChannel::SetOutputVolume(uint32_t ssrc, double volume) {
1540 return InvokeOnWorker(Bind(&VoiceMediaChannel::SetOutputVolume, 1549 return InvokeOnWorker(RTC_FROM_HERE, Bind(&VoiceMediaChannel::SetOutputVolume,
1541 media_channel(), ssrc, volume)); 1550 media_channel(), ssrc, volume));
1542 } 1551 }
1543 1552
1544 void VoiceChannel::SetRawAudioSink( 1553 void VoiceChannel::SetRawAudioSink(
1545 uint32_t ssrc, 1554 uint32_t ssrc,
1546 std::unique_ptr<webrtc::AudioSinkInterface> sink) { 1555 std::unique_ptr<webrtc::AudioSinkInterface> sink) {
1547 // We need to work around Bind's lack of support for unique_ptr and ownership 1556 // We need to work around Bind's lack of support for unique_ptr and ownership
1548 // passing. So we invoke to our own little routine that gets a pointer to 1557 // passing. So we invoke to our own little routine that gets a pointer to
1549 // our local variable. This is OK since we're synchronously invoking. 1558 // our local variable. This is OK since we're synchronously invoking.
1550 InvokeOnWorker(Bind(&SetRawAudioSink_w, media_channel(), ssrc, &sink)); 1559 InvokeOnWorker(RTC_FROM_HERE,
1560 Bind(&SetRawAudioSink_w, media_channel(), ssrc, &sink));
1551 } 1561 }
1552 1562
1553 webrtc::RtpParameters VoiceChannel::GetRtpSendParameters(uint32_t ssrc) const { 1563 webrtc::RtpParameters VoiceChannel::GetRtpSendParameters(uint32_t ssrc) const {
1554 return worker_thread()->Invoke<webrtc::RtpParameters>( 1564 return worker_thread()->Invoke<webrtc::RtpParameters>(
1555 Bind(&VoiceChannel::GetRtpSendParameters_w, this, ssrc)); 1565 RTC_FROM_HERE, Bind(&VoiceChannel::GetRtpSendParameters_w, this, ssrc));
1556 } 1566 }
1557 1567
1558 webrtc::RtpParameters VoiceChannel::GetRtpSendParameters_w( 1568 webrtc::RtpParameters VoiceChannel::GetRtpSendParameters_w(
1559 uint32_t ssrc) const { 1569 uint32_t ssrc) const {
1560 return media_channel()->GetRtpSendParameters(ssrc); 1570 return media_channel()->GetRtpSendParameters(ssrc);
1561 } 1571 }
1562 1572
1563 bool VoiceChannel::SetRtpSendParameters( 1573 bool VoiceChannel::SetRtpSendParameters(
1564 uint32_t ssrc, 1574 uint32_t ssrc,
1565 const webrtc::RtpParameters& parameters) { 1575 const webrtc::RtpParameters& parameters) {
1566 return InvokeOnWorker( 1576 return InvokeOnWorker(
1577 RTC_FROM_HERE,
1567 Bind(&VoiceChannel::SetRtpSendParameters_w, this, ssrc, parameters)); 1578 Bind(&VoiceChannel::SetRtpSendParameters_w, this, ssrc, parameters));
1568 } 1579 }
1569 1580
1570 bool VoiceChannel::SetRtpSendParameters_w(uint32_t ssrc, 1581 bool VoiceChannel::SetRtpSendParameters_w(uint32_t ssrc,
1571 webrtc::RtpParameters parameters) { 1582 webrtc::RtpParameters parameters) {
1572 return media_channel()->SetRtpSendParameters(ssrc, parameters); 1583 return media_channel()->SetRtpSendParameters(ssrc, parameters);
1573 } 1584 }
1574 1585
1575 webrtc::RtpParameters VoiceChannel::GetRtpReceiveParameters( 1586 webrtc::RtpParameters VoiceChannel::GetRtpReceiveParameters(
1576 uint32_t ssrc) const { 1587 uint32_t ssrc) const {
1577 return worker_thread()->Invoke<webrtc::RtpParameters>( 1588 return worker_thread()->Invoke<webrtc::RtpParameters>(
1589 RTC_FROM_HERE,
1578 Bind(&VoiceChannel::GetRtpReceiveParameters_w, this, ssrc)); 1590 Bind(&VoiceChannel::GetRtpReceiveParameters_w, this, ssrc));
1579 } 1591 }
1580 1592
1581 webrtc::RtpParameters VoiceChannel::GetRtpReceiveParameters_w( 1593 webrtc::RtpParameters VoiceChannel::GetRtpReceiveParameters_w(
1582 uint32_t ssrc) const { 1594 uint32_t ssrc) const {
1583 return media_channel()->GetRtpReceiveParameters(ssrc); 1595 return media_channel()->GetRtpReceiveParameters(ssrc);
1584 } 1596 }
1585 1597
1586 bool VoiceChannel::SetRtpReceiveParameters( 1598 bool VoiceChannel::SetRtpReceiveParameters(
1587 uint32_t ssrc, 1599 uint32_t ssrc,
1588 const webrtc::RtpParameters& parameters) { 1600 const webrtc::RtpParameters& parameters) {
1589 return InvokeOnWorker( 1601 return InvokeOnWorker(
1602 RTC_FROM_HERE,
1590 Bind(&VoiceChannel::SetRtpReceiveParameters_w, this, ssrc, parameters)); 1603 Bind(&VoiceChannel::SetRtpReceiveParameters_w, this, ssrc, parameters));
1591 } 1604 }
1592 1605
1593 bool VoiceChannel::SetRtpReceiveParameters_w(uint32_t ssrc, 1606 bool VoiceChannel::SetRtpReceiveParameters_w(uint32_t ssrc,
1594 webrtc::RtpParameters parameters) { 1607 webrtc::RtpParameters parameters) {
1595 return media_channel()->SetRtpReceiveParameters(ssrc, parameters); 1608 return media_channel()->SetRtpReceiveParameters(ssrc, parameters);
1596 } 1609 }
1597 1610
1598 bool VoiceChannel::GetStats(VoiceMediaInfo* stats) { 1611 bool VoiceChannel::GetStats(VoiceMediaInfo* stats) {
1599 return InvokeOnWorker(Bind(&VoiceMediaChannel::GetStats, 1612 return InvokeOnWorker(RTC_FROM_HERE, Bind(&VoiceMediaChannel::GetStats,
1600 media_channel(), stats)); 1613 media_channel(), stats));
1601 } 1614 }
1602 1615
1603 void VoiceChannel::StartMediaMonitor(int cms) { 1616 void VoiceChannel::StartMediaMonitor(int cms) {
1604 media_monitor_.reset(new VoiceMediaMonitor(media_channel(), worker_thread(), 1617 media_monitor_.reset(new VoiceMediaMonitor(media_channel(), worker_thread(),
1605 rtc::Thread::Current())); 1618 rtc::Thread::Current()));
1606 media_monitor_->SignalUpdate.connect( 1619 media_monitor_->SignalUpdate.connect(
1607 this, &VoiceChannel::OnMediaMonitorUpdate); 1620 this, &VoiceChannel::OnMediaMonitorUpdate);
1608 media_monitor_->Start(cms); 1621 media_monitor_->Start(cms);
1609 } 1622 }
1610 1623
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
1654 1667
1655 // Set a flag when we've received an RTP packet. If we're waiting for early 1668 // Set a flag when we've received an RTP packet. If we're waiting for early
1656 // media, this will disable the timeout. 1669 // media, this will disable the timeout.
1657 if (!received_media_ && !PacketIsRtcp(channel, data, len)) { 1670 if (!received_media_ && !PacketIsRtcp(channel, data, len)) {
1658 received_media_ = true; 1671 received_media_ = true;
1659 } 1672 }
1660 } 1673 }
1661 1674
1662 void BaseChannel::ChangeState() { 1675 void BaseChannel::ChangeState() {
1663 RTC_DCHECK(network_thread_->IsCurrent()); 1676 RTC_DCHECK(network_thread_->IsCurrent());
1664 invoker_.AsyncInvoke<void>(worker_thread_, 1677 invoker_.AsyncInvoke<void>(RTC_FROM_HERE, worker_thread_,
1665 Bind(&BaseChannel::ChangeState_w, this)); 1678 Bind(&BaseChannel::ChangeState_w, this));
1666 } 1679 }
1667 1680
1668 void VoiceChannel::ChangeState_w() { 1681 void VoiceChannel::ChangeState_w() {
1669 // Render incoming data if we're the active call, and we have the local 1682 // Render incoming data if we're the active call, and we have the local
1670 // content. We receive data on the default channel and multiplexed streams. 1683 // content. We receive data on the default channel and multiplexed streams.
1671 bool recv = IsReadyToReceive_w(); 1684 bool recv = IsReadyToReceive_w();
1672 media_channel()->SetPlayout(recv); 1685 media_channel()->SetPlayout(recv);
1673 1686
1674 // Send outgoing data if we're the active call, we have the remote content, 1687 // Send outgoing data if we're the active call, we have the remote content,
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
1860 StopMediaMonitor(); 1873 StopMediaMonitor();
1861 // this can't be done in the base class, since it calls a virtual 1874 // this can't be done in the base class, since it calls a virtual
1862 DisableMedia_w(); 1875 DisableMedia_w();
1863 1876
1864 Deinit(); 1877 Deinit();
1865 } 1878 }
1866 1879
1867 bool VideoChannel::SetSink(uint32_t ssrc, 1880 bool VideoChannel::SetSink(uint32_t ssrc,
1868 rtc::VideoSinkInterface<VideoFrame>* sink) { 1881 rtc::VideoSinkInterface<VideoFrame>* sink) {
1869 worker_thread()->Invoke<void>( 1882 worker_thread()->Invoke<void>(
1883 RTC_FROM_HERE,
1870 Bind(&VideoMediaChannel::SetSink, media_channel(), ssrc, sink)); 1884 Bind(&VideoMediaChannel::SetSink, media_channel(), ssrc, sink));
1871 return true; 1885 return true;
1872 } 1886 }
1873 1887
1874 bool VideoChannel::SetVideoSend( 1888 bool VideoChannel::SetVideoSend(
1875 uint32_t ssrc, 1889 uint32_t ssrc,
1876 bool mute, 1890 bool mute,
1877 const VideoOptions* options, 1891 const VideoOptions* options,
1878 rtc::VideoSourceInterface<cricket::VideoFrame>* source) { 1892 rtc::VideoSourceInterface<cricket::VideoFrame>* source) {
1879 return InvokeOnWorker(Bind(&VideoMediaChannel::SetVideoSend, media_channel(), 1893 return InvokeOnWorker(RTC_FROM_HERE,
1894 Bind(&VideoMediaChannel::SetVideoSend, media_channel(),
1880 ssrc, mute, options, source)); 1895 ssrc, mute, options, source));
1881 } 1896 }
1882 1897
1883 webrtc::RtpParameters VideoChannel::GetRtpSendParameters(uint32_t ssrc) const { 1898 webrtc::RtpParameters VideoChannel::GetRtpSendParameters(uint32_t ssrc) const {
1884 return worker_thread()->Invoke<webrtc::RtpParameters>( 1899 return worker_thread()->Invoke<webrtc::RtpParameters>(
1885 Bind(&VideoChannel::GetRtpSendParameters_w, this, ssrc)); 1900 RTC_FROM_HERE, Bind(&VideoChannel::GetRtpSendParameters_w, this, ssrc));
1886 } 1901 }
1887 1902
1888 webrtc::RtpParameters VideoChannel::GetRtpSendParameters_w( 1903 webrtc::RtpParameters VideoChannel::GetRtpSendParameters_w(
1889 uint32_t ssrc) const { 1904 uint32_t ssrc) const {
1890 return media_channel()->GetRtpSendParameters(ssrc); 1905 return media_channel()->GetRtpSendParameters(ssrc);
1891 } 1906 }
1892 1907
1893 bool VideoChannel::SetRtpSendParameters( 1908 bool VideoChannel::SetRtpSendParameters(
1894 uint32_t ssrc, 1909 uint32_t ssrc,
1895 const webrtc::RtpParameters& parameters) { 1910 const webrtc::RtpParameters& parameters) {
1896 return InvokeOnWorker( 1911 return InvokeOnWorker(
1912 RTC_FROM_HERE,
1897 Bind(&VideoChannel::SetRtpSendParameters_w, this, ssrc, parameters)); 1913 Bind(&VideoChannel::SetRtpSendParameters_w, this, ssrc, parameters));
1898 } 1914 }
1899 1915
1900 bool VideoChannel::SetRtpSendParameters_w(uint32_t ssrc, 1916 bool VideoChannel::SetRtpSendParameters_w(uint32_t ssrc,
1901 webrtc::RtpParameters parameters) { 1917 webrtc::RtpParameters parameters) {
1902 return media_channel()->SetRtpSendParameters(ssrc, parameters); 1918 return media_channel()->SetRtpSendParameters(ssrc, parameters);
1903 } 1919 }
1904 1920
1905 webrtc::RtpParameters VideoChannel::GetRtpReceiveParameters( 1921 webrtc::RtpParameters VideoChannel::GetRtpReceiveParameters(
1906 uint32_t ssrc) const { 1922 uint32_t ssrc) const {
1907 return worker_thread()->Invoke<webrtc::RtpParameters>( 1923 return worker_thread()->Invoke<webrtc::RtpParameters>(
1924 RTC_FROM_HERE,
1908 Bind(&VideoChannel::GetRtpReceiveParameters_w, this, ssrc)); 1925 Bind(&VideoChannel::GetRtpReceiveParameters_w, this, ssrc));
1909 } 1926 }
1910 1927
1911 webrtc::RtpParameters VideoChannel::GetRtpReceiveParameters_w( 1928 webrtc::RtpParameters VideoChannel::GetRtpReceiveParameters_w(
1912 uint32_t ssrc) const { 1929 uint32_t ssrc) const {
1913 return media_channel()->GetRtpReceiveParameters(ssrc); 1930 return media_channel()->GetRtpReceiveParameters(ssrc);
1914 } 1931 }
1915 1932
1916 bool VideoChannel::SetRtpReceiveParameters( 1933 bool VideoChannel::SetRtpReceiveParameters(
1917 uint32_t ssrc, 1934 uint32_t ssrc,
1918 const webrtc::RtpParameters& parameters) { 1935 const webrtc::RtpParameters& parameters) {
1919 return InvokeOnWorker( 1936 return InvokeOnWorker(
1937 RTC_FROM_HERE,
1920 Bind(&VideoChannel::SetRtpReceiveParameters_w, this, ssrc, parameters)); 1938 Bind(&VideoChannel::SetRtpReceiveParameters_w, this, ssrc, parameters));
1921 } 1939 }
1922 1940
1923 bool VideoChannel::SetRtpReceiveParameters_w(uint32_t ssrc, 1941 bool VideoChannel::SetRtpReceiveParameters_w(uint32_t ssrc,
1924 webrtc::RtpParameters parameters) { 1942 webrtc::RtpParameters parameters) {
1925 return media_channel()->SetRtpReceiveParameters(ssrc, parameters); 1943 return media_channel()->SetRtpReceiveParameters(ssrc, parameters);
1926 } 1944 }
1927 1945
1928 void VideoChannel::ChangeState_w() { 1946 void VideoChannel::ChangeState_w() {
1929 // Send outgoing data if we're the active call, we have the remote content, 1947 // Send outgoing data if we're the active call, we have the remote content,
1930 // and we have had some form of connectivity. 1948 // and we have had some form of connectivity.
1931 bool send = IsReadyToSend_w(); 1949 bool send = IsReadyToSend_w();
1932 if (!media_channel()->SetSend(send)) { 1950 if (!media_channel()->SetSend(send)) {
1933 LOG(LS_ERROR) << "Failed to SetSend on video channel"; 1951 LOG(LS_ERROR) << "Failed to SetSend on video channel";
1934 // TODO(gangji): Report error back to server. 1952 // TODO(gangji): Report error back to server.
1935 } 1953 }
1936 1954
1937 LOG(LS_INFO) << "Changing video state, send=" << send; 1955 LOG(LS_INFO) << "Changing video state, send=" << send;
1938 } 1956 }
1939 1957
1940 bool VideoChannel::GetStats(VideoMediaInfo* stats) { 1958 bool VideoChannel::GetStats(VideoMediaInfo* stats) {
1941 return InvokeOnWorker( 1959 return InvokeOnWorker(RTC_FROM_HERE, Bind(&VideoMediaChannel::GetStats,
1942 Bind(&VideoMediaChannel::GetStats, media_channel(), stats)); 1960 media_channel(), stats));
1943 } 1961 }
1944 1962
1945 void VideoChannel::StartMediaMonitor(int cms) { 1963 void VideoChannel::StartMediaMonitor(int cms) {
1946 media_monitor_.reset(new VideoMediaMonitor(media_channel(), worker_thread(), 1964 media_monitor_.reset(new VideoMediaMonitor(media_channel(), worker_thread(),
1947 rtc::Thread::Current())); 1965 rtc::Thread::Current()));
1948 media_monitor_->SignalUpdate.connect( 1966 media_monitor_->SignalUpdate.connect(
1949 this, &VideoChannel::OnMediaMonitorUpdate); 1967 this, &VideoChannel::OnMediaMonitorUpdate);
1950 media_monitor_->Start(cms); 1968 media_monitor_->Start(cms);
1951 } 1969 }
1952 1970
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
2124 media_channel()->SignalReadyToSend.connect( 2142 media_channel()->SignalReadyToSend.connect(
2125 this, &DataChannel::OnDataChannelReadyToSend); 2143 this, &DataChannel::OnDataChannelReadyToSend);
2126 media_channel()->SignalStreamClosedRemotely.connect( 2144 media_channel()->SignalStreamClosedRemotely.connect(
2127 this, &DataChannel::OnStreamClosedRemotely); 2145 this, &DataChannel::OnStreamClosedRemotely);
2128 return true; 2146 return true;
2129 } 2147 }
2130 2148
2131 bool DataChannel::SendData(const SendDataParams& params, 2149 bool DataChannel::SendData(const SendDataParams& params,
2132 const rtc::CopyOnWriteBuffer& payload, 2150 const rtc::CopyOnWriteBuffer& payload,
2133 SendDataResult* result) { 2151 SendDataResult* result) {
2134 return InvokeOnWorker(Bind(&DataMediaChannel::SendData, 2152 return InvokeOnWorker(
2135 media_channel(), params, payload, result)); 2153 RTC_FROM_HERE, Bind(&DataMediaChannel::SendData, media_channel(), params,
2154 payload, result));
2136 } 2155 }
2137 2156
2138 const ContentInfo* DataChannel::GetFirstContent( 2157 const ContentInfo* DataChannel::GetFirstContent(
2139 const SessionDescription* sdesc) { 2158 const SessionDescription* sdesc) {
2140 return GetFirstDataContent(sdesc); 2159 return GetFirstDataContent(sdesc);
2141 } 2160 }
2142 2161
2143 bool DataChannel::WantsPacket(bool rtcp, const rtc::CopyOnWriteBuffer* packet) { 2162 bool DataChannel::WantsPacket(bool rtcp, const rtc::CopyOnWriteBuffer* packet) {
2144 if (data_channel_type_ == DCT_SCTP) { 2163 if (data_channel_type_ == DCT_SCTP) {
2145 // TODO(pthatcher): Do this in a more robust way by checking for 2164 // TODO(pthatcher): Do this in a more robust way by checking for
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
2374 void DataChannel::OnMediaMonitorUpdate( 2393 void DataChannel::OnMediaMonitorUpdate(
2375 DataMediaChannel* media_channel, const DataMediaInfo& info) { 2394 DataMediaChannel* media_channel, const DataMediaInfo& info) {
2376 ASSERT(media_channel == this->media_channel()); 2395 ASSERT(media_channel == this->media_channel());
2377 SignalMediaMonitor(this, info); 2396 SignalMediaMonitor(this, info);
2378 } 2397 }
2379 2398
2380 void DataChannel::OnDataReceived( 2399 void DataChannel::OnDataReceived(
2381 const ReceiveDataParams& params, const char* data, size_t len) { 2400 const ReceiveDataParams& params, const char* data, size_t len) {
2382 DataReceivedMessageData* msg = new DataReceivedMessageData( 2401 DataReceivedMessageData* msg = new DataReceivedMessageData(
2383 params, data, len); 2402 params, data, len);
2384 signaling_thread()->Post(this, MSG_DATARECEIVED, msg); 2403 signaling_thread()->Post(RTC_FROM_HERE, this, MSG_DATARECEIVED, msg);
2385 } 2404 }
2386 2405
2387 void DataChannel::OnDataChannelError(uint32_t ssrc, 2406 void DataChannel::OnDataChannelError(uint32_t ssrc,
2388 DataMediaChannel::Error err) { 2407 DataMediaChannel::Error err) {
2389 DataChannelErrorMessageData* data = new DataChannelErrorMessageData( 2408 DataChannelErrorMessageData* data = new DataChannelErrorMessageData(
2390 ssrc, err); 2409 ssrc, err);
2391 signaling_thread()->Post(this, MSG_CHANNEL_ERROR, data); 2410 signaling_thread()->Post(RTC_FROM_HERE, this, MSG_CHANNEL_ERROR, data);
2392 } 2411 }
2393 2412
2394 void DataChannel::OnDataChannelReadyToSend(bool writable) { 2413 void DataChannel::OnDataChannelReadyToSend(bool writable) {
2395 // This is usded for congestion control to indicate that the stream is ready 2414 // This is usded for congestion control to indicate that the stream is ready
2396 // to send by the MediaChannel, as opposed to OnReadyToSend, which indicates 2415 // to send by the MediaChannel, as opposed to OnReadyToSend, which indicates
2397 // that the transport channel is ready. 2416 // that the transport channel is ready.
2398 signaling_thread()->Post(this, MSG_READYTOSENDDATA, 2417 signaling_thread()->Post(RTC_FROM_HERE, this, MSG_READYTOSENDDATA,
2399 new DataChannelReadyToSendMessageData(writable)); 2418 new DataChannelReadyToSendMessageData(writable));
2400 } 2419 }
2401 2420
2402 void DataChannel::GetSrtpCryptoSuites_n(std::vector<int>* crypto_suites) const { 2421 void DataChannel::GetSrtpCryptoSuites_n(std::vector<int>* crypto_suites) const {
2403 GetSupportedDataCryptoSuites(crypto_suites); 2422 GetSupportedDataCryptoSuites(crypto_suites);
2404 } 2423 }
2405 2424
2406 bool DataChannel::ShouldSetupDtlsSrtp_n() const { 2425 bool DataChannel::ShouldSetupDtlsSrtp_n() const {
2407 return data_channel_type_ == DCT_RTP && BaseChannel::ShouldSetupDtlsSrtp_n(); 2426 return data_channel_type_ == DCT_RTP && BaseChannel::ShouldSetupDtlsSrtp_n();
2408 } 2427 }
2409 2428
2410 void DataChannel::OnStreamClosedRemotely(uint32_t sid) { 2429 void DataChannel::OnStreamClosedRemotely(uint32_t sid) {
2411 rtc::TypedMessageData<uint32_t>* message = 2430 rtc::TypedMessageData<uint32_t>* message =
2412 new rtc::TypedMessageData<uint32_t>(sid); 2431 new rtc::TypedMessageData<uint32_t>(sid);
2413 signaling_thread()->Post(this, MSG_STREAMCLOSEDREMOTELY, message); 2432 signaling_thread()->Post(RTC_FROM_HERE, this, MSG_STREAMCLOSEDREMOTELY,
2433 message);
2414 } 2434 }
2415 2435
2416 } // namespace cricket 2436 } // namespace cricket
OLDNEW
« no previous file with comments | « webrtc/pc/channel.h ('k') | webrtc/pc/channel_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698