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

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: 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
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 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 } 177 }
178 LOG(LS_INFO) << "Created channel for " << content_name; 178 LOG(LS_INFO) << "Created channel for " << content_name;
179 } 179 }
180 180
181 BaseChannel::~BaseChannel() { 181 BaseChannel::~BaseChannel() {
182 TRACE_EVENT0("webrtc", "BaseChannel::~BaseChannel"); 182 TRACE_EVENT0("webrtc", "BaseChannel::~BaseChannel");
183 ASSERT(worker_thread_ == rtc::Thread::Current()); 183 ASSERT(worker_thread_ == rtc::Thread::Current());
184 Deinit(); 184 Deinit();
185 StopConnectionMonitor(); 185 StopConnectionMonitor();
186 // Send any outstanding RTCP packets. 186 // Send any outstanding RTCP packets.
187 network_thread_->Invoke<void>(Bind(&BaseChannel::FlushRtcpMessages_n, this)); 187 network_thread_->Invoke<void>(FROM_HERE,
188 Bind(&BaseChannel::FlushRtcpMessages_n, this));
188 // Eats any outstanding messages or packets. 189 // Eats any outstanding messages or packets.
189 worker_thread_->Clear(&invoker_); 190 worker_thread_->Clear(&invoker_);
190 worker_thread_->Clear(this); 191 worker_thread_->Clear(this);
191 // We must destroy the media channel before the transport channel, otherwise 192 // We must destroy the media channel before the transport channel, otherwise
192 // the media channel may try to send on the dead transport channel. NULLing 193 // the media channel may try to send on the dead transport channel. NULLing
193 // is not an effective strategy since the sends will come on another thread. 194 // is not an effective strategy since the sends will come on another thread.
194 delete media_channel_; 195 delete media_channel_;
195 // Note that we don't just call SetTransportChannel_n(nullptr) because that 196 // Note that we don't just call SetTransportChannel_n(nullptr) because that
196 // would call a pure virtual method which we can't do from a destructor. 197 // would call a pure virtual method which we can't do from a destructor.
197 network_thread_->Invoke<void>(Bind(&BaseChannel::DeinitNetwork_n, this)); 198 network_thread_->Invoke<void>(FROM_HERE,
199 Bind(&BaseChannel::DeinitNetwork_n, this));
198 LOG(LS_INFO) << "Destroyed channel"; 200 LOG(LS_INFO) << "Destroyed channel";
199 } 201 }
200 202
201 void BaseChannel::DeinitNetwork_n() { 203 void BaseChannel::DeinitNetwork_n() {
202 if (transport_channel_) { 204 if (transport_channel_) {
203 DisconnectFromTransportChannel(transport_channel_); 205 DisconnectFromTransportChannel(transport_channel_);
204 transport_controller_->DestroyTransportChannel_n( 206 transport_controller_->DestroyTransportChannel_n(
205 transport_name_, cricket::ICE_CANDIDATE_COMPONENT_RTP); 207 transport_name_, cricket::ICE_CANDIDATE_COMPONENT_RTP);
206 } 208 }
207 if (rtcp_transport_channel_) { 209 if (rtcp_transport_channel_) {
208 DisconnectFromTransportChannel(rtcp_transport_channel_); 210 DisconnectFromTransportChannel(rtcp_transport_channel_);
209 transport_controller_->DestroyTransportChannel_n( 211 transport_controller_->DestroyTransportChannel_n(
210 transport_name_, cricket::ICE_CANDIDATE_COMPONENT_RTCP); 212 transport_name_, cricket::ICE_CANDIDATE_COMPONENT_RTCP);
211 } 213 }
212 network_thread_->Clear(this); 214 network_thread_->Clear(this);
213 } 215 }
214 216
215 bool BaseChannel::Init_w() { 217 bool BaseChannel::Init_w() {
216 if (!network_thread_->Invoke<bool>(Bind(&BaseChannel::InitNetwork_n, this))) { 218 if (!network_thread_->Invoke<bool>(FROM_HERE,
219 Bind(&BaseChannel::InitNetwork_n, this))) {
217 return false; 220 return false;
218 } 221 }
219 222
220 // Both RTP and RTCP channels are set, we can call SetInterface on 223 // Both RTP and RTCP channels are set, we can call SetInterface on
221 // media channel and it can set network options. 224 // media channel and it can set network options.
222 RTC_DCHECK(worker_thread_->IsCurrent()); 225 RTC_DCHECK(worker_thread_->IsCurrent());
223 media_channel_->SetInterface(this); 226 media_channel_->SetInterface(this);
224 return true; 227 return true;
225 } 228 }
226 229
(...skipping 13 matching lines...) Expand all
240 return true; 243 return true;
241 } 244 }
242 245
243 void BaseChannel::Deinit() { 246 void BaseChannel::Deinit() {
244 RTC_DCHECK(worker_thread_->IsCurrent()); 247 RTC_DCHECK(worker_thread_->IsCurrent());
245 media_channel_->SetInterface(NULL); 248 media_channel_->SetInterface(NULL);
246 } 249 }
247 250
248 bool BaseChannel::SetTransport(const std::string& transport_name) { 251 bool BaseChannel::SetTransport(const std::string& transport_name) {
249 return network_thread_->Invoke<bool>( 252 return network_thread_->Invoke<bool>(
250 Bind(&BaseChannel::SetTransport_n, this, transport_name)); 253 FROM_HERE, Bind(&BaseChannel::SetTransport_n, this, transport_name));
251 } 254 }
252 255
253 bool BaseChannel::SetTransport_n(const std::string& transport_name) { 256 bool BaseChannel::SetTransport_n(const std::string& transport_name) {
254 RTC_DCHECK(network_thread_->IsCurrent()); 257 RTC_DCHECK(network_thread_->IsCurrent());
255 258
256 if (transport_name == transport_name_) { 259 if (transport_name == transport_name_) {
257 // Nothing to do if transport name isn't changing 260 // Nothing to do if transport name isn't changing
258 return true; 261 return true;
259 } 262 }
260 263
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
384 387
385 tc->SignalWritableState.disconnect(this); 388 tc->SignalWritableState.disconnect(this);
386 tc->SignalReadPacket.disconnect(this); 389 tc->SignalReadPacket.disconnect(this);
387 tc->SignalReadyToSend.disconnect(this); 390 tc->SignalReadyToSend.disconnect(this);
388 tc->SignalDtlsState.disconnect(this); 391 tc->SignalDtlsState.disconnect(this);
389 tc->SignalSelectedCandidatePairChanged.disconnect(this); 392 tc->SignalSelectedCandidatePairChanged.disconnect(this);
390 tc->SignalSentPacket.disconnect(this); 393 tc->SignalSentPacket.disconnect(this);
391 } 394 }
392 395
393 bool BaseChannel::Enable(bool enable) { 396 bool BaseChannel::Enable(bool enable) {
394 worker_thread_->Invoke<void>(Bind( 397 worker_thread_->Invoke<void>(
395 enable ? &BaseChannel::EnableMedia_w : &BaseChannel::DisableMedia_w, 398 FROM_HERE,
396 this)); 399 Bind(enable ? &BaseChannel::EnableMedia_w : &BaseChannel::DisableMedia_w,
400 this));
397 return true; 401 return true;
398 } 402 }
399 403
400 bool BaseChannel::AddRecvStream(const StreamParams& sp) { 404 bool BaseChannel::AddRecvStream(const StreamParams& sp) {
401 return InvokeOnWorker(Bind(&BaseChannel::AddRecvStream_w, this, sp)); 405 return InvokeOnWorker(Bind(&BaseChannel::AddRecvStream_w, this, sp));
402 } 406 }
403 407
404 bool BaseChannel::RemoveRecvStream(uint32_t ssrc) { 408 bool BaseChannel::RemoveRecvStream(uint32_t ssrc) {
405 return InvokeOnWorker(Bind(&BaseChannel::RemoveRecvStream_w, this, ssrc)); 409 return InvokeOnWorker(Bind(&BaseChannel::RemoveRecvStream_w, this, ssrc));
406 } 410 }
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
461 // Receive data if we are enabled and have local content, 465 // Receive data if we are enabled and have local content,
462 return enabled() && IsReceiveContentDirection(local_content_direction_); 466 return enabled() && IsReceiveContentDirection(local_content_direction_);
463 } 467 }
464 468
465 bool BaseChannel::IsReadyToSend_w() const { 469 bool BaseChannel::IsReadyToSend_w() const {
466 // Send outgoing data if we are enabled, have local and remote content, 470 // Send outgoing data if we are enabled, have local and remote content,
467 // and we have had some form of connectivity. 471 // and we have had some form of connectivity.
468 return enabled() && IsReceiveContentDirection(remote_content_direction_) && 472 return enabled() && IsReceiveContentDirection(remote_content_direction_) &&
469 IsSendContentDirection(local_content_direction_) && 473 IsSendContentDirection(local_content_direction_) &&
470 network_thread_->Invoke<bool>( 474 network_thread_->Invoke<bool>(
471 Bind(&BaseChannel::IsTransportReadyToSend_n, this)); 475 FROM_HERE, Bind(&BaseChannel::IsTransportReadyToSend_n, this));
472 } 476 }
473 477
474 bool BaseChannel::IsTransportReadyToSend_n() const { 478 bool BaseChannel::IsTransportReadyToSend_n() const {
475 return was_ever_writable() && 479 return was_ever_writable() &&
476 (srtp_filter_.IsActive() || !ShouldSetupDtlsSrtp_n()); 480 (srtp_filter_.IsActive() || !ShouldSetupDtlsSrtp_n());
477 } 481 }
478 482
479 bool BaseChannel::SendPacket(rtc::CopyOnWriteBuffer* packet, 483 bool BaseChannel::SendPacket(rtc::CopyOnWriteBuffer* packet,
480 const rtc::PacketOptions& options) { 484 const rtc::PacketOptions& options) {
481 return SendPacket(false, packet, options); 485 return SendPacket(false, packet, options);
482 } 486 }
483 487
484 bool BaseChannel::SendRtcp(rtc::CopyOnWriteBuffer* packet, 488 bool BaseChannel::SendRtcp(rtc::CopyOnWriteBuffer* packet,
485 const rtc::PacketOptions& options) { 489 const rtc::PacketOptions& options) {
486 return SendPacket(true, packet, options); 490 return SendPacket(true, packet, options);
487 } 491 }
488 492
489 int BaseChannel::SetOption(SocketType type, rtc::Socket::Option opt, 493 int BaseChannel::SetOption(SocketType type, rtc::Socket::Option opt,
490 int value) { 494 int value) {
491 return network_thread_->Invoke<int>( 495 return network_thread_->Invoke<int>(
492 Bind(&BaseChannel::SetOption_n, this, type, opt, value)); 496 FROM_HERE, Bind(&BaseChannel::SetOption_n, this, type, opt, value));
493 } 497 }
494 498
495 int BaseChannel::SetOption_n(SocketType type, 499 int BaseChannel::SetOption_n(SocketType type,
496 rtc::Socket::Option opt, 500 rtc::Socket::Option opt,
497 int value) { 501 int value) {
498 RTC_DCHECK(network_thread_->IsCurrent()); 502 RTC_DCHECK(network_thread_->IsCurrent());
499 TransportChannel* channel = nullptr; 503 TransportChannel* channel = nullptr;
500 switch (type) { 504 switch (type) {
501 case ST_RTP: 505 case ST_RTP:
502 channel = transport_channel_; 506 channel = transport_channel_;
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
563 RTC_DCHECK(network_thread_->IsCurrent()); 567 RTC_DCHECK(network_thread_->IsCurrent());
564 std::string transport_name = channel->transport_name(); 568 std::string transport_name = channel->transport_name();
565 rtc::NetworkRoute network_route; 569 rtc::NetworkRoute network_route;
566 if (selected_candidate_pair) { 570 if (selected_candidate_pair) {
567 network_route = rtc::NetworkRoute( 571 network_route = rtc::NetworkRoute(
568 selected_candidate_pair->local_candidate().network_id(), 572 selected_candidate_pair->local_candidate().network_id(),
569 selected_candidate_pair->remote_candidate().network_id(), 573 selected_candidate_pair->remote_candidate().network_id(),
570 last_sent_packet_id); 574 last_sent_packet_id);
571 } 575 }
572 invoker_.AsyncInvoke<void>( 576 invoker_.AsyncInvoke<void>(
573 worker_thread_, Bind(&MediaChannel::OnNetworkRouteChanged, media_channel_, 577 FROM_HERE, worker_thread_,
574 transport_name, network_route)); 578 Bind(&MediaChannel::OnNetworkRouteChanged, media_channel_, transport_name,
579 network_route));
575 } 580 }
576 581
577 void BaseChannel::SetReadyToSend(bool rtcp, bool ready) { 582 void BaseChannel::SetReadyToSend(bool rtcp, bool ready) {
578 RTC_DCHECK(network_thread_->IsCurrent()); 583 RTC_DCHECK(network_thread_->IsCurrent());
579 if (rtcp) { 584 if (rtcp) {
580 rtcp_ready_to_send_ = ready; 585 rtcp_ready_to_send_ = ready;
581 } else { 586 } else {
582 rtp_ready_to_send_ = ready; 587 rtp_ready_to_send_ = ready;
583 } 588 }
584 589
585 bool ready_to_send = 590 bool ready_to_send =
586 (rtp_ready_to_send_ && 591 (rtp_ready_to_send_ &&
587 // In the case of rtcp mux |rtcp_transport_channel_| will be null. 592 // In the case of rtcp mux |rtcp_transport_channel_| will be null.
588 (rtcp_ready_to_send_ || !rtcp_transport_channel_)); 593 (rtcp_ready_to_send_ || !rtcp_transport_channel_));
589 594
590 invoker_.AsyncInvoke<void>( 595 invoker_.AsyncInvoke<void>(
591 worker_thread_, 596 FROM_HERE, worker_thread_,
592 Bind(&MediaChannel::OnReadyToSend, media_channel_, ready_to_send)); 597 Bind(&MediaChannel::OnReadyToSend, media_channel_, ready_to_send));
593 } 598 }
594 599
595 bool BaseChannel::PacketIsRtcp(const TransportChannel* channel, 600 bool BaseChannel::PacketIsRtcp(const TransportChannel* channel,
596 const char* data, size_t len) { 601 const char* data, size_t len) {
597 return (channel == rtcp_transport_channel_ || 602 return (channel == rtcp_transport_channel_ ||
598 rtcp_mux_filter_.DemuxRtcp(data, static_cast<int>(len))); 603 rtcp_mux_filter_.DemuxRtcp(data, static_cast<int>(len)));
599 } 604 }
600 605
601 bool BaseChannel::SendPacket(bool rtcp, 606 bool BaseChannel::SendPacket(bool rtcp,
602 rtc::CopyOnWriteBuffer* packet, 607 rtc::CopyOnWriteBuffer* packet,
603 const rtc::PacketOptions& options) { 608 const rtc::PacketOptions& options) {
604 // SendPacket gets called from MediaEngine, on a pacer or an encoder thread. 609 // SendPacket gets called from MediaEngine, on a pacer or an encoder thread.
605 // If the thread is not our network thread, we will post to our network 610 // If the thread is not our network thread, we will post to our network
606 // so that the real work happens on our network. This avoids us having to 611 // so that the real work happens on our network. This avoids us having to
607 // synchronize access to all the pieces of the send path, including 612 // synchronize access to all the pieces of the send path, including
608 // SRTP and the inner workings of the transport channels. 613 // SRTP and the inner workings of the transport channels.
609 // The only downside is that we can't return a proper failure code if 614 // The only downside is that we can't return a proper failure code if
610 // needed. Since UDP is unreliable anyway, this should be a non-issue. 615 // needed. Since UDP is unreliable anyway, this should be a non-issue.
611 if (!network_thread_->IsCurrent()) { 616 if (!network_thread_->IsCurrent()) {
612 // Avoid a copy by transferring the ownership of the packet data. 617 // Avoid a copy by transferring the ownership of the packet data.
613 int message_id = rtcp ? MSG_SEND_RTCP_PACKET : MSG_SEND_RTP_PACKET; 618 int message_id = rtcp ? MSG_SEND_RTCP_PACKET : MSG_SEND_RTP_PACKET;
614 SendPacketMessageData* data = new SendPacketMessageData; 619 SendPacketMessageData* data = new SendPacketMessageData;
615 data->packet = std::move(*packet); 620 data->packet = std::move(*packet);
616 data->options = options; 621 data->options = options;
617 network_thread_->Post(this, message_id, data); 622 network_thread_->Post(FROM_HERE, this, message_id, data);
618 return true; 623 return true;
619 } 624 }
620 TRACE_EVENT0("webrtc", "BaseChannel::SendPacket"); 625 TRACE_EVENT0("webrtc", "BaseChannel::SendPacket");
621 626
622 // Now that we are on the correct thread, ensure we have a place to send this 627 // Now that we are on the correct thread, ensure we have a place to send this
623 // packet before doing anything. (We might get RTCP packets that we don't 628 // packet before doing anything. (We might get RTCP packets that we don't
624 // intend to send.) If we've negotiated RTCP mux, send RTCP over the RTP 629 // intend to send.) If we've negotiated RTCP mux, send RTCP over the RTP
625 // transport. 630 // transport.
626 TransportChannel* channel = (!rtcp || rtcp_mux_filter_.IsActive()) ? 631 TransportChannel* channel = (!rtcp || rtcp_mux_filter_.IsActive()) ?
627 transport_channel_ : rtcp_transport_channel_; 632 transport_channel_ : rtcp_transport_channel_;
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
742 const rtc::PacketTime& packet_time) { 747 const rtc::PacketTime& packet_time) {
743 RTC_DCHECK(network_thread_->IsCurrent()); 748 RTC_DCHECK(network_thread_->IsCurrent());
744 if (!WantsPacket(rtcp, packet)) { 749 if (!WantsPacket(rtcp, packet)) {
745 return; 750 return;
746 } 751 }
747 752
748 // We are only interested in the first rtp packet because that 753 // We are only interested in the first rtp packet because that
749 // indicates the media has started flowing. 754 // indicates the media has started flowing.
750 if (!has_received_packet_ && !rtcp) { 755 if (!has_received_packet_ && !rtcp) {
751 has_received_packet_ = true; 756 has_received_packet_ = true;
752 signaling_thread()->Post(this, MSG_FIRSTPACKETRECEIVED); 757 signaling_thread()->Post(FROM_HERE, this, MSG_FIRSTPACKETRECEIVED);
753 } 758 }
754 759
755 // Unprotect the packet, if needed. 760 // Unprotect the packet, if needed.
756 if (srtp_filter_.IsActive()) { 761 if (srtp_filter_.IsActive()) {
757 TRACE_EVENT0("webrtc", "SRTP Decode"); 762 TRACE_EVENT0("webrtc", "SRTP Decode");
758 char* data = packet->data<char>(); 763 char* data = packet->data<char>();
759 int len = static_cast<int>(packet->size()); 764 int len = static_cast<int>(packet->size());
760 bool res; 765 bool res;
761 if (!rtcp) { 766 if (!rtcp) {
762 res = srtp_filter_.UnprotectRtp(data, len, &len); 767 res = srtp_filter_.UnprotectRtp(data, len, &len);
(...skipping 29 matching lines...) Expand all
792 // on the channel that the packets are being sent on. It's really good 797 // on the channel that the packets are being sent on. It's really good
793 // practice to wait for both RTP and RTCP to be good to go before sending 798 // practice to wait for both RTP and RTCP to be good to go before sending
794 // media, to prevent weird failure modes, so it's fine for us to just eat 799 // media, to prevent weird failure modes, so it's fine for us to just eat
795 // packets here. This is all sidestepped if RTCP mux is used anyway. 800 // packets here. This is all sidestepped if RTCP mux is used anyway.
796 LOG(LS_WARNING) << "Can't process incoming " << PacketType(rtcp) 801 LOG(LS_WARNING) << "Can't process incoming " << PacketType(rtcp)
797 << " packet when SRTP is inactive and crypto is required"; 802 << " packet when SRTP is inactive and crypto is required";
798 return; 803 return;
799 } 804 }
800 805
801 invoker_.AsyncInvoke<void>( 806 invoker_.AsyncInvoke<void>(
802 worker_thread_, 807 FROM_HERE, worker_thread_,
803 Bind(&BaseChannel::OnPacketReceived, this, rtcp, *packet, packet_time)); 808 Bind(&BaseChannel::OnPacketReceived, this, rtcp, *packet, packet_time));
804 } 809 }
805 810
806 void BaseChannel::OnPacketReceived(bool rtcp, 811 void BaseChannel::OnPacketReceived(bool rtcp,
807 const rtc::CopyOnWriteBuffer& packet, 812 const rtc::CopyOnWriteBuffer& packet,
808 const rtc::PacketTime& packet_time) { 813 const rtc::PacketTime& packet_time) {
809 RTC_DCHECK(worker_thread_->IsCurrent()); 814 RTC_DCHECK(worker_thread_->IsCurrent());
810 // Need to copy variable because OnRtcpReceived/OnPacketReceived 815 // Need to copy variable because OnRtcpReceived/OnPacketReceived
811 // requires non-const pointer to buffer. This doesn't memcpy the actual data. 816 // requires non-const pointer to buffer. This doesn't memcpy the actual data.
812 rtc::CopyOnWriteBuffer data(packet); 817 rtc::CopyOnWriteBuffer data(packet);
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
896 901
897 was_ever_writable_ = true; 902 was_ever_writable_ = true;
898 MaybeSetupDtlsSrtp_n(); 903 MaybeSetupDtlsSrtp_n();
899 writable_ = true; 904 writable_ = true;
900 ChangeState(); 905 ChangeState();
901 } 906 }
902 907
903 void BaseChannel::SignalDtlsSetupFailure_n(bool rtcp) { 908 void BaseChannel::SignalDtlsSetupFailure_n(bool rtcp) {
904 RTC_DCHECK(network_thread_->IsCurrent()); 909 RTC_DCHECK(network_thread_->IsCurrent());
905 invoker_.AsyncInvoke<void>( 910 invoker_.AsyncInvoke<void>(
906 signaling_thread(), 911 FROM_HERE, signaling_thread(),
907 Bind(&BaseChannel::SignalDtlsSetupFailure_s, this, rtcp)); 912 Bind(&BaseChannel::SignalDtlsSetupFailure_s, this, rtcp));
908 } 913 }
909 914
910 void BaseChannel::SignalDtlsSetupFailure_s(bool rtcp) { 915 void BaseChannel::SignalDtlsSetupFailure_s(bool rtcp) {
911 ASSERT(signaling_thread() == rtc::Thread::Current()); 916 ASSERT(signaling_thread() == rtc::Thread::Current());
912 SignalDtlsSetupFailure(this, rtcp); 917 SignalDtlsSetupFailure(this, rtcp);
913 } 918 }
914 919
915 bool BaseChannel::SetDtlsSrtpCryptoSuites_n(TransportChannel* tc, bool rtcp) { 920 bool BaseChannel::SetDtlsSrtpCryptoSuites_n(TransportChannel* tc, bool rtcp) {
916 std::vector<int> crypto_suites; 921 std::vector<int> crypto_suites;
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
1055 ContentAction action, 1060 ContentAction action,
1056 ContentSource src, 1061 ContentSource src,
1057 std::string* error_desc) { 1062 std::string* error_desc) {
1058 if (action == CA_UPDATE) { 1063 if (action == CA_UPDATE) {
1059 // These parameters never get changed by a CA_UDPATE. 1064 // These parameters never get changed by a CA_UDPATE.
1060 return true; 1065 return true;
1061 } 1066 }
1062 1067
1063 // Cache secure_required_ for belt and suspenders check on SendPacket 1068 // Cache secure_required_ for belt and suspenders check on SendPacket
1064 return network_thread_->Invoke<bool>( 1069 return network_thread_->Invoke<bool>(
1065 Bind(&BaseChannel::SetRtpTransportParameters_n, this, content, action, 1070 FROM_HERE, Bind(&BaseChannel::SetRtpTransportParameters_n, this, content,
1066 src, error_desc)); 1071 action, src, error_desc));
1067 } 1072 }
1068 1073
1069 bool BaseChannel::SetRtpTransportParameters_n( 1074 bool BaseChannel::SetRtpTransportParameters_n(
1070 const MediaContentDescription* content, 1075 const MediaContentDescription* content,
1071 ContentAction action, 1076 ContentAction action,
1072 ContentSource src, 1077 ContentSource src,
1073 std::string* error_desc) { 1078 std::string* error_desc) {
1074 RTC_DCHECK(network_thread_->IsCurrent()); 1079 RTC_DCHECK(network_thread_->IsCurrent());
1075 1080
1076 if (src == CS_LOCAL) { 1081 if (src == CS_LOCAL) {
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
1142 break; 1147 break;
1143 } 1148 }
1144 if (!ret) { 1149 if (!ret) {
1145 SafeSetError("Failed to setup SRTP filter.", error_desc); 1150 SafeSetError("Failed to setup SRTP filter.", error_desc);
1146 return false; 1151 return false;
1147 } 1152 }
1148 return true; 1153 return true;
1149 } 1154 }
1150 1155
1151 void BaseChannel::ActivateRtcpMux() { 1156 void BaseChannel::ActivateRtcpMux() {
1152 network_thread_->Invoke<void>(Bind(&BaseChannel::ActivateRtcpMux_n, this)); 1157 network_thread_->Invoke<void>(FROM_HERE,
1158 Bind(&BaseChannel::ActivateRtcpMux_n, this));
1153 } 1159 }
1154 1160
1155 void BaseChannel::ActivateRtcpMux_n() { 1161 void BaseChannel::ActivateRtcpMux_n() {
1156 if (!rtcp_mux_filter_.IsActive()) { 1162 if (!rtcp_mux_filter_.IsActive()) {
1157 rtcp_mux_filter_.SetActive(); 1163 rtcp_mux_filter_.SetActive();
1158 SetRtcpTransportChannel_n(nullptr, true); 1164 SetRtcpTransportChannel_n(nullptr, true);
1159 rtcp_transport_enabled_ = false; 1165 rtcp_transport_enabled_ = false;
1160 } 1166 }
1161 } 1167 }
1162 1168
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after
1368 const std::vector<RtpHeaderExtension>& extensions) { 1374 const std::vector<RtpHeaderExtension>& extensions) {
1369 // Absolute Send Time extension id is used only with external auth, 1375 // Absolute Send Time extension id is used only with external auth,
1370 // so do not bother searching for it and making asyncronious call to set 1376 // so do not bother searching for it and making asyncronious call to set
1371 // something that is not used. 1377 // something that is not used.
1372 #if defined(ENABLE_EXTERNAL_AUTH) 1378 #if defined(ENABLE_EXTERNAL_AUTH)
1373 const RtpHeaderExtension* send_time_extension = 1379 const RtpHeaderExtension* send_time_extension =
1374 FindHeaderExtension(extensions, kRtpAbsoluteSenderTimeHeaderExtension); 1380 FindHeaderExtension(extensions, kRtpAbsoluteSenderTimeHeaderExtension);
1375 int rtp_abs_sendtime_extn_id = 1381 int rtp_abs_sendtime_extn_id =
1376 send_time_extension ? send_time_extension->id : -1; 1382 send_time_extension ? send_time_extension->id : -1;
1377 invoker_.AsyncInvoke<void>( 1383 invoker_.AsyncInvoke<void>(
1378 network_thread_, Bind(&BaseChannel::CacheRtpAbsSendTimeHeaderExtension_n, 1384 FROM_HERE, network_thread_,
1379 this, rtp_abs_sendtime_extn_id)); 1385 Bind(&BaseChannel::CacheRtpAbsSendTimeHeaderExtension_n, this,
1386 rtp_abs_sendtime_extn_id));
1380 #endif 1387 #endif
1381 } 1388 }
1382 1389
1383 void BaseChannel::CacheRtpAbsSendTimeHeaderExtension_n( 1390 void BaseChannel::CacheRtpAbsSendTimeHeaderExtension_n(
1384 int rtp_abs_sendtime_extn_id) { 1391 int rtp_abs_sendtime_extn_id) {
1385 rtp_abs_sendtime_extn_id_ = rtp_abs_sendtime_extn_id; 1392 rtp_abs_sendtime_extn_id_ = rtp_abs_sendtime_extn_id;
1386 } 1393 }
1387 1394
1388 void BaseChannel::OnMessage(rtc::Message *pmsg) { 1395 void BaseChannel::OnMessage(rtc::Message *pmsg) {
1389 TRACE_EVENT0("webrtc", "BaseChannel::OnMessage"); 1396 TRACE_EVENT0("webrtc", "BaseChannel::OnMessage");
(...skipping 15 matching lines...) Expand all
1405 } 1412 }
1406 } 1413 }
1407 1414
1408 void BaseChannel::FlushRtcpMessages_n() { 1415 void BaseChannel::FlushRtcpMessages_n() {
1409 // Flush all remaining RTCP messages. This should only be called in 1416 // Flush all remaining RTCP messages. This should only be called in
1410 // destructor. 1417 // destructor.
1411 RTC_DCHECK(network_thread_->IsCurrent()); 1418 RTC_DCHECK(network_thread_->IsCurrent());
1412 rtc::MessageList rtcp_messages; 1419 rtc::MessageList rtcp_messages;
1413 network_thread_->Clear(this, MSG_SEND_RTCP_PACKET, &rtcp_messages); 1420 network_thread_->Clear(this, MSG_SEND_RTCP_PACKET, &rtcp_messages);
1414 for (const auto& message : rtcp_messages) { 1421 for (const auto& message : rtcp_messages) {
1415 network_thread_->Send(this, MSG_SEND_RTCP_PACKET, message.pdata); 1422 network_thread_->Send(FROM_HERE, this, MSG_SEND_RTCP_PACKET, message.pdata);
1416 } 1423 }
1417 } 1424 }
1418 1425
1419 void BaseChannel::SignalSentPacket_n(TransportChannel* /* channel */, 1426 void BaseChannel::SignalSentPacket_n(TransportChannel* /* channel */,
1420 const rtc::SentPacket& sent_packet) { 1427 const rtc::SentPacket& sent_packet) {
1421 RTC_DCHECK(network_thread_->IsCurrent()); 1428 RTC_DCHECK(network_thread_->IsCurrent());
1422 invoker_.AsyncInvoke<void>( 1429 invoker_.AsyncInvoke<void>(
1423 worker_thread_, 1430 FROM_HERE, worker_thread_,
1424 rtc::Bind(&BaseChannel::SignalSentPacket_w, this, sent_packet)); 1431 rtc::Bind(&BaseChannel::SignalSentPacket_w, this, sent_packet));
1425 } 1432 }
1426 1433
1427 void BaseChannel::SignalSentPacket_w(const rtc::SentPacket& sent_packet) { 1434 void BaseChannel::SignalSentPacket_w(const rtc::SentPacket& sent_packet) {
1428 RTC_DCHECK(worker_thread_->IsCurrent()); 1435 RTC_DCHECK(worker_thread_->IsCurrent());
1429 SignalSentPacket(sent_packet); 1436 SignalSentPacket(sent_packet);
1430 } 1437 }
1431 1438
1432 VoiceChannel::VoiceChannel(rtc::Thread* worker_thread, 1439 VoiceChannel::VoiceChannel(rtc::Thread* worker_thread,
1433 rtc::Thread* network_thread, 1440 rtc::Thread* network_thread,
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
1470 } 1477 }
1471 1478
1472 // TODO(juberti): Handle early media the right way. We should get an explicit 1479 // TODO(juberti): Handle early media the right way. We should get an explicit
1473 // ringing message telling us to start playing local ringback, which we cancel 1480 // ringing message telling us to start playing local ringback, which we cancel
1474 // if any early media actually arrives. For now, we do the opposite, which is 1481 // if any early media actually arrives. For now, we do the opposite, which is
1475 // to wait 1 second for early media, and start playing local ringback if none 1482 // to wait 1 second for early media, and start playing local ringback if none
1476 // arrives. 1483 // arrives.
1477 void VoiceChannel::SetEarlyMedia(bool enable) { 1484 void VoiceChannel::SetEarlyMedia(bool enable) {
1478 if (enable) { 1485 if (enable) {
1479 // Start the early media timeout 1486 // Start the early media timeout
1480 worker_thread()->PostDelayed(kEarlyMediaTimeout, this, 1487 worker_thread()->PostDelayed(FROM_HERE, kEarlyMediaTimeout, this,
1481 MSG_EARLYMEDIATIMEOUT); 1488 MSG_EARLYMEDIATIMEOUT);
1482 } else { 1489 } else {
1483 // Stop the timeout if currently going. 1490 // Stop the timeout if currently going.
1484 worker_thread()->Clear(this, MSG_EARLYMEDIATIMEOUT); 1491 worker_thread()->Clear(this, MSG_EARLYMEDIATIMEOUT);
1485 } 1492 }
1486 } 1493 }
1487 1494
1488 bool VoiceChannel::CanInsertDtmf() { 1495 bool VoiceChannel::CanInsertDtmf() {
1489 return InvokeOnWorker(Bind(&VoiceMediaChannel::CanInsertDtmf, 1496 return InvokeOnWorker(Bind(&VoiceMediaChannel::CanInsertDtmf,
1490 media_channel())); 1497 media_channel()));
1491 } 1498 }
(...skipping 14 matching lines...) Expand all
1506 uint32_t ssrc, 1513 uint32_t ssrc,
1507 std::unique_ptr<webrtc::AudioSinkInterface> sink) { 1514 std::unique_ptr<webrtc::AudioSinkInterface> sink) {
1508 // We need to work around Bind's lack of support for unique_ptr and ownership 1515 // We need to work around Bind's lack of support for unique_ptr and ownership
1509 // passing. So we invoke to our own little routine that gets a pointer to 1516 // passing. So we invoke to our own little routine that gets a pointer to
1510 // our local variable. This is OK since we're synchronously invoking. 1517 // our local variable. This is OK since we're synchronously invoking.
1511 InvokeOnWorker(Bind(&SetRawAudioSink_w, media_channel(), ssrc, &sink)); 1518 InvokeOnWorker(Bind(&SetRawAudioSink_w, media_channel(), ssrc, &sink));
1512 } 1519 }
1513 1520
1514 webrtc::RtpParameters VoiceChannel::GetRtpParameters(uint32_t ssrc) const { 1521 webrtc::RtpParameters VoiceChannel::GetRtpParameters(uint32_t ssrc) const {
1515 return worker_thread()->Invoke<webrtc::RtpParameters>( 1522 return worker_thread()->Invoke<webrtc::RtpParameters>(
1516 Bind(&VoiceChannel::GetRtpParameters_w, this, ssrc)); 1523 FROM_HERE, Bind(&VoiceChannel::GetRtpParameters_w, this, ssrc));
1517 } 1524 }
1518 1525
1519 webrtc::RtpParameters VoiceChannel::GetRtpParameters_w(uint32_t ssrc) const { 1526 webrtc::RtpParameters VoiceChannel::GetRtpParameters_w(uint32_t ssrc) const {
1520 return media_channel()->GetRtpParameters(ssrc); 1527 return media_channel()->GetRtpParameters(ssrc);
1521 } 1528 }
1522 1529
1523 bool VoiceChannel::SetRtpParameters(uint32_t ssrc, 1530 bool VoiceChannel::SetRtpParameters(uint32_t ssrc,
1524 const webrtc::RtpParameters& parameters) { 1531 const webrtc::RtpParameters& parameters) {
1525 return InvokeOnWorker( 1532 return InvokeOnWorker(
1526 Bind(&VoiceChannel::SetRtpParameters_w, this, ssrc, parameters)); 1533 Bind(&VoiceChannel::SetRtpParameters_w, this, ssrc, parameters));
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
1590 1597
1591 // Set a flag when we've received an RTP packet. If we're waiting for early 1598 // Set a flag when we've received an RTP packet. If we're waiting for early
1592 // media, this will disable the timeout. 1599 // media, this will disable the timeout.
1593 if (!received_media_ && !PacketIsRtcp(channel, data, len)) { 1600 if (!received_media_ && !PacketIsRtcp(channel, data, len)) {
1594 received_media_ = true; 1601 received_media_ = true;
1595 } 1602 }
1596 } 1603 }
1597 1604
1598 void BaseChannel::ChangeState() { 1605 void BaseChannel::ChangeState() {
1599 RTC_DCHECK(network_thread_->IsCurrent()); 1606 RTC_DCHECK(network_thread_->IsCurrent());
1600 invoker_.AsyncInvoke<void>(worker_thread_, 1607 invoker_.AsyncInvoke<void>(FROM_HERE, worker_thread_,
1601 Bind(&BaseChannel::ChangeState_w, this)); 1608 Bind(&BaseChannel::ChangeState_w, this));
1602 } 1609 }
1603 1610
1604 void VoiceChannel::ChangeState_w() { 1611 void VoiceChannel::ChangeState_w() {
1605 // Render incoming data if we're the active call, and we have the local 1612 // Render incoming data if we're the active call, and we have the local
1606 // content. We receive data on the default channel and multiplexed streams. 1613 // content. We receive data on the default channel and multiplexed streams.
1607 bool recv = IsReadyToReceive_w(); 1614 bool recv = IsReadyToReceive_w();
1608 media_channel()->SetPlayout(recv); 1615 media_channel()->SetPlayout(recv);
1609 1616
1610 // Send outgoing data if we're the active call, we have the remote content, 1617 // Send outgoing data if we're the active call, we have the remote content,
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
1795 TRACE_EVENT0("webrtc", "VideoChannel::~VideoChannel"); 1802 TRACE_EVENT0("webrtc", "VideoChannel::~VideoChannel");
1796 StopMediaMonitor(); 1803 StopMediaMonitor();
1797 // this can't be done in the base class, since it calls a virtual 1804 // this can't be done in the base class, since it calls a virtual
1798 DisableMedia_w(); 1805 DisableMedia_w();
1799 1806
1800 Deinit(); 1807 Deinit();
1801 } 1808 }
1802 1809
1803 bool VideoChannel::SetSink(uint32_t ssrc, 1810 bool VideoChannel::SetSink(uint32_t ssrc,
1804 rtc::VideoSinkInterface<VideoFrame>* sink) { 1811 rtc::VideoSinkInterface<VideoFrame>* sink) {
1805 worker_thread()->Invoke<void>( 1812 worker_thread()->Invoke<void>(FROM_HERE, Bind(&VideoMediaChannel::SetSink,
1806 Bind(&VideoMediaChannel::SetSink, media_channel(), ssrc, sink)); 1813 media_channel(), ssrc, sink));
1807 return true; 1814 return true;
1808 } 1815 }
1809 1816
1810 void VideoChannel::SetSource( 1817 void VideoChannel::SetSource(
1811 uint32_t ssrc, 1818 uint32_t ssrc,
1812 rtc::VideoSourceInterface<cricket::VideoFrame>* source) { 1819 rtc::VideoSourceInterface<cricket::VideoFrame>* source) {
1813 worker_thread()->Invoke<void>( 1820 worker_thread()->Invoke<void>(FROM_HERE, Bind(&VideoMediaChannel::SetSource,
1814 Bind(&VideoMediaChannel::SetSource, media_channel(), ssrc, source)); 1821 media_channel(), ssrc, source));
1815 } 1822 }
1816 1823
1817 bool VideoChannel::SetVideoSend(uint32_t ssrc, 1824 bool VideoChannel::SetVideoSend(uint32_t ssrc,
1818 bool mute, 1825 bool mute,
1819 const VideoOptions* options) { 1826 const VideoOptions* options) {
1820 return InvokeOnWorker(Bind(&VideoMediaChannel::SetVideoSend, media_channel(), 1827 return InvokeOnWorker(Bind(&VideoMediaChannel::SetVideoSend, media_channel(),
1821 ssrc, mute, options)); 1828 ssrc, mute, options));
1822 } 1829 }
1823 1830
1824 webrtc::RtpParameters VideoChannel::GetRtpParameters(uint32_t ssrc) const { 1831 webrtc::RtpParameters VideoChannel::GetRtpParameters(uint32_t ssrc) const {
1825 return worker_thread()->Invoke<webrtc::RtpParameters>( 1832 return worker_thread()->Invoke<webrtc::RtpParameters>(
1826 Bind(&VideoChannel::GetRtpParameters_w, this, ssrc)); 1833 FROM_HERE, Bind(&VideoChannel::GetRtpParameters_w, this, ssrc));
1827 } 1834 }
1828 1835
1829 webrtc::RtpParameters VideoChannel::GetRtpParameters_w(uint32_t ssrc) const { 1836 webrtc::RtpParameters VideoChannel::GetRtpParameters_w(uint32_t ssrc) const {
1830 return media_channel()->GetRtpParameters(ssrc); 1837 return media_channel()->GetRtpParameters(ssrc);
1831 } 1838 }
1832 1839
1833 bool VideoChannel::SetRtpParameters(uint32_t ssrc, 1840 bool VideoChannel::SetRtpParameters(uint32_t ssrc,
1834 const webrtc::RtpParameters& parameters) { 1841 const webrtc::RtpParameters& parameters) {
1835 return InvokeOnWorker( 1842 return InvokeOnWorker(
1836 Bind(&VideoChannel::SetRtpParameters_w, this, ssrc, parameters)); 1843 Bind(&VideoChannel::SetRtpParameters_w, this, ssrc, parameters));
(...skipping 453 matching lines...) Expand 10 before | Expand all | Expand 10 after
2290 void DataChannel::OnMediaMonitorUpdate( 2297 void DataChannel::OnMediaMonitorUpdate(
2291 DataMediaChannel* media_channel, const DataMediaInfo& info) { 2298 DataMediaChannel* media_channel, const DataMediaInfo& info) {
2292 ASSERT(media_channel == this->media_channel()); 2299 ASSERT(media_channel == this->media_channel());
2293 SignalMediaMonitor(this, info); 2300 SignalMediaMonitor(this, info);
2294 } 2301 }
2295 2302
2296 void DataChannel::OnDataReceived( 2303 void DataChannel::OnDataReceived(
2297 const ReceiveDataParams& params, const char* data, size_t len) { 2304 const ReceiveDataParams& params, const char* data, size_t len) {
2298 DataReceivedMessageData* msg = new DataReceivedMessageData( 2305 DataReceivedMessageData* msg = new DataReceivedMessageData(
2299 params, data, len); 2306 params, data, len);
2300 signaling_thread()->Post(this, MSG_DATARECEIVED, msg); 2307 signaling_thread()->Post(FROM_HERE, this, MSG_DATARECEIVED, msg);
2301 } 2308 }
2302 2309
2303 void DataChannel::OnDataChannelError(uint32_t ssrc, 2310 void DataChannel::OnDataChannelError(uint32_t ssrc,
2304 DataMediaChannel::Error err) { 2311 DataMediaChannel::Error err) {
2305 DataChannelErrorMessageData* data = new DataChannelErrorMessageData( 2312 DataChannelErrorMessageData* data = new DataChannelErrorMessageData(
2306 ssrc, err); 2313 ssrc, err);
2307 signaling_thread()->Post(this, MSG_CHANNEL_ERROR, data); 2314 signaling_thread()->Post(FROM_HERE, this, MSG_CHANNEL_ERROR, data);
2308 } 2315 }
2309 2316
2310 void DataChannel::OnDataChannelReadyToSend(bool writable) { 2317 void DataChannel::OnDataChannelReadyToSend(bool writable) {
2311 // This is usded for congestion control to indicate that the stream is ready 2318 // This is usded for congestion control to indicate that the stream is ready
2312 // to send by the MediaChannel, as opposed to OnReadyToSend, which indicates 2319 // to send by the MediaChannel, as opposed to OnReadyToSend, which indicates
2313 // that the transport channel is ready. 2320 // that the transport channel is ready.
2314 signaling_thread()->Post(this, MSG_READYTOSENDDATA, 2321 signaling_thread()->Post(FROM_HERE, this, MSG_READYTOSENDDATA,
2315 new DataChannelReadyToSendMessageData(writable)); 2322 new DataChannelReadyToSendMessageData(writable));
2316 } 2323 }
2317 2324
2318 void DataChannel::GetSrtpCryptoSuites_n(std::vector<int>* crypto_suites) const { 2325 void DataChannel::GetSrtpCryptoSuites_n(std::vector<int>* crypto_suites) const {
2319 GetSupportedDataCryptoSuites(crypto_suites); 2326 GetSupportedDataCryptoSuites(crypto_suites);
2320 } 2327 }
2321 2328
2322 bool DataChannel::ShouldSetupDtlsSrtp_n() const { 2329 bool DataChannel::ShouldSetupDtlsSrtp_n() const {
2323 return data_channel_type_ == DCT_RTP && BaseChannel::ShouldSetupDtlsSrtp_n(); 2330 return data_channel_type_ == DCT_RTP && BaseChannel::ShouldSetupDtlsSrtp_n();
2324 } 2331 }
2325 2332
2326 void DataChannel::OnStreamClosedRemotely(uint32_t sid) { 2333 void DataChannel::OnStreamClosedRemotely(uint32_t sid) {
2327 rtc::TypedMessageData<uint32_t>* message = 2334 rtc::TypedMessageData<uint32_t>* message =
2328 new rtc::TypedMessageData<uint32_t>(sid); 2335 new rtc::TypedMessageData<uint32_t>(sid);
2329 signaling_thread()->Post(this, MSG_STREAMCLOSEDREMOTELY, message); 2336 signaling_thread()->Post(FROM_HERE, this, MSG_STREAMCLOSEDREMOTELY, message);
2330 } 2337 }
2331 2338
2332 } // namespace cricket 2339 } // namespace cricket
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698