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

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

Issue 2974903003: Make BaseChannel::rtp_transport_ a unique_ptr. (Closed)
Patch Set: Created 3 years, 5 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') | no next file » | 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
11 #include <algorithm> 11 #include <algorithm>
12 #include <iterator> 12 #include <iterator>
13 #include <utility> 13 #include <utility>
14 14
15 #include "webrtc/pc/channel.h" 15 #include "webrtc/pc/channel.h"
16 16
17 #include "webrtc/api/call/audio_sink.h" 17 #include "webrtc/api/call/audio_sink.h"
18 #include "webrtc/media/base/mediaconstants.h" 18 #include "webrtc/media/base/mediaconstants.h"
19 #include "webrtc/media/base/rtputils.h" 19 #include "webrtc/media/base/rtputils.h"
20 #include "webrtc/rtc_base/bind.h" 20 #include "webrtc/rtc_base/bind.h"
21 #include "webrtc/rtc_base/byteorder.h" 21 #include "webrtc/rtc_base/byteorder.h"
22 #include "webrtc/rtc_base/checks.h" 22 #include "webrtc/rtc_base/checks.h"
23 #include "webrtc/rtc_base/copyonwritebuffer.h" 23 #include "webrtc/rtc_base/copyonwritebuffer.h"
24 #include "webrtc/rtc_base/dscp.h" 24 #include "webrtc/rtc_base/dscp.h"
25 #include "webrtc/rtc_base/logging.h" 25 #include "webrtc/rtc_base/logging.h"
26 #include "webrtc/rtc_base/networkroute.h" 26 #include "webrtc/rtc_base/networkroute.h"
27 #include "webrtc/rtc_base/ptr_util.h"
27 #include "webrtc/rtc_base/trace_event.h" 28 #include "webrtc/rtc_base/trace_event.h"
28 // Adding 'nogncheck' to disable the gn include headers check to support modular 29 // Adding 'nogncheck' to disable the gn include headers check to support modular
29 // WebRTC build targets. 30 // WebRTC build targets.
30 #include "webrtc/media/engine/webrtcvoiceengine.h" // nogncheck 31 #include "webrtc/media/engine/webrtcvoiceengine.h" // nogncheck
31 #include "webrtc/p2p/base/packettransportinternal.h" 32 #include "webrtc/p2p/base/packettransportinternal.h"
32 #include "webrtc/pc/channelmanager.h" 33 #include "webrtc/pc/channelmanager.h"
33 34
34 namespace cricket { 35 namespace cricket {
35 using rtc::Bind; 36 using rtc::Bind;
36 37
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 rtc::Thread* signaling_thread, 149 rtc::Thread* signaling_thread,
149 MediaChannel* media_channel, 150 MediaChannel* media_channel,
150 const std::string& content_name, 151 const std::string& content_name,
151 bool rtcp_mux_required, 152 bool rtcp_mux_required,
152 bool srtp_required) 153 bool srtp_required)
153 : worker_thread_(worker_thread), 154 : worker_thread_(worker_thread),
154 network_thread_(network_thread), 155 network_thread_(network_thread),
155 signaling_thread_(signaling_thread), 156 signaling_thread_(signaling_thread),
156 content_name_(content_name), 157 content_name_(content_name),
157 rtcp_mux_required_(rtcp_mux_required), 158 rtcp_mux_required_(rtcp_mux_required),
158 rtp_transport_(rtcp_mux_required), 159 rtp_transport_(rtc::MakeUnique<webrtc::RtpTransport>(rtcp_mux_required)),
159 srtp_required_(srtp_required), 160 srtp_required_(srtp_required),
160 media_channel_(media_channel), 161 media_channel_(media_channel),
161 selected_candidate_pair_(nullptr) { 162 selected_candidate_pair_(nullptr) {
162 RTC_DCHECK(worker_thread_ == rtc::Thread::Current()); 163 RTC_DCHECK(worker_thread_ == rtc::Thread::Current());
163 #if defined(ENABLE_EXTERNAL_AUTH) 164 #if defined(ENABLE_EXTERNAL_AUTH)
164 srtp_filter_.EnableExternalAuth(); 165 srtp_filter_.EnableExternalAuth();
165 #endif 166 #endif
166 rtp_transport_.SignalReadyToSend.connect( 167 rtp_transport_->SignalReadyToSend.connect(
167 this, &BaseChannel::OnTransportReadyToSend); 168 this, &BaseChannel::OnTransportReadyToSend);
168 // TODO(zstein): RtpTransport::SignalPacketReceived will probably be replaced 169 // TODO(zstein): RtpTransport::SignalPacketReceived will probably be replaced
169 // with a callback interface later so that the demuxer can select which 170 // with a callback interface later so that the demuxer can select which
170 // channel to signal. 171 // channel to signal.
171 rtp_transport_.SignalPacketReceived.connect(this, 172 rtp_transport_->SignalPacketReceived.connect(this,
172 &BaseChannel::OnPacketReceived); 173 &BaseChannel::OnPacketReceived);
173 LOG(LS_INFO) << "Created channel for " << content_name; 174 LOG(LS_INFO) << "Created channel for " << content_name;
174 } 175 }
175 176
176 BaseChannel::~BaseChannel() { 177 BaseChannel::~BaseChannel() {
177 TRACE_EVENT0("webrtc", "BaseChannel::~BaseChannel"); 178 TRACE_EVENT0("webrtc", "BaseChannel::~BaseChannel");
178 RTC_DCHECK(worker_thread_ == rtc::Thread::Current()); 179 RTC_DCHECK(worker_thread_ == rtc::Thread::Current());
179 Deinit(); 180 Deinit();
180 StopConnectionMonitor(); 181 StopConnectionMonitor();
181 // Eats any outstanding messages or packets. 182 // Eats any outstanding messages or packets.
182 worker_thread_->Clear(&invoker_); 183 worker_thread_->Clear(&invoker_);
183 worker_thread_->Clear(this); 184 worker_thread_->Clear(this);
184 // We must destroy the media channel before the transport channel, otherwise 185 // We must destroy the media channel before the transport channel, otherwise
185 // the media channel may try to send on the dead transport channel. NULLing 186 // the media channel may try to send on the dead transport channel. NULLing
186 // is not an effective strategy since the sends will come on another thread. 187 // is not an effective strategy since the sends will come on another thread.
187 delete media_channel_; 188 delete media_channel_;
188 LOG(LS_INFO) << "Destroyed channel: " << content_name_; 189 LOG(LS_INFO) << "Destroyed channel: " << content_name_;
189 } 190 }
190 191
191 void BaseChannel::DisconnectTransportChannels_n() { 192 void BaseChannel::DisconnectTransportChannels_n() {
192 // Send any outstanding RTCP packets. 193 // Send any outstanding RTCP packets.
193 FlushRtcpMessages_n(); 194 FlushRtcpMessages_n();
194 195
195 // Stop signals from transport channels, but keep them alive because 196 // Stop signals from transport channels, but keep them alive because
196 // media_channel may use them from a different thread. 197 // media_channel may use them from a different thread.
197 if (rtp_dtls_transport_) { 198 if (rtp_dtls_transport_) {
198 DisconnectFromDtlsTransport(rtp_dtls_transport_); 199 DisconnectFromDtlsTransport(rtp_dtls_transport_);
199 } else if (rtp_transport_.rtp_packet_transport()) { 200 } else if (rtp_transport_->rtp_packet_transport()) {
200 DisconnectFromPacketTransport(rtp_transport_.rtp_packet_transport()); 201 DisconnectFromPacketTransport(rtp_transport_->rtp_packet_transport());
201 } 202 }
202 if (rtcp_dtls_transport_) { 203 if (rtcp_dtls_transport_) {
203 DisconnectFromDtlsTransport(rtcp_dtls_transport_); 204 DisconnectFromDtlsTransport(rtcp_dtls_transport_);
204 } else if (rtp_transport_.rtcp_packet_transport()) { 205 } else if (rtp_transport_->rtcp_packet_transport()) {
205 DisconnectFromPacketTransport(rtp_transport_.rtcp_packet_transport()); 206 DisconnectFromPacketTransport(rtp_transport_->rtcp_packet_transport());
206 } 207 }
207 208
208 rtp_transport_.SetRtpPacketTransport(nullptr); 209 rtp_transport_->SetRtpPacketTransport(nullptr);
209 rtp_transport_.SetRtcpPacketTransport(nullptr); 210 rtp_transport_->SetRtcpPacketTransport(nullptr);
210 211
211 // Clear pending read packets/messages. 212 // Clear pending read packets/messages.
212 network_thread_->Clear(&invoker_); 213 network_thread_->Clear(&invoker_);
213 network_thread_->Clear(this); 214 network_thread_->Clear(this);
214 } 215 }
215 216
216 bool BaseChannel::Init_w(DtlsTransportInternal* rtp_dtls_transport, 217 bool BaseChannel::Init_w(DtlsTransportInternal* rtp_dtls_transport,
217 DtlsTransportInternal* rtcp_dtls_transport, 218 DtlsTransportInternal* rtcp_dtls_transport,
218 rtc::PacketTransportInternal* rtp_packet_transport, 219 rtc::PacketTransportInternal* rtp_packet_transport,
219 rtc::PacketTransportInternal* rtcp_packet_transport) { 220 rtc::PacketTransportInternal* rtcp_packet_transport) {
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
278 rtc::PacketTransportInternal* rtcp_packet_transport) { 279 rtc::PacketTransportInternal* rtcp_packet_transport) {
279 RTC_DCHECK(network_thread_->IsCurrent()); 280 RTC_DCHECK(network_thread_->IsCurrent());
280 // Validate some assertions about the input. 281 // Validate some assertions about the input.
281 RTC_DCHECK(rtp_packet_transport); 282 RTC_DCHECK(rtp_packet_transport);
282 RTC_DCHECK_EQ(NeedsRtcpTransport(), rtcp_packet_transport != nullptr); 283 RTC_DCHECK_EQ(NeedsRtcpTransport(), rtcp_packet_transport != nullptr);
283 if (rtp_dtls_transport || rtcp_dtls_transport) { 284 if (rtp_dtls_transport || rtcp_dtls_transport) {
284 // DTLS/non-DTLS pointers should be to the same object. 285 // DTLS/non-DTLS pointers should be to the same object.
285 RTC_DCHECK(rtp_dtls_transport == rtp_packet_transport); 286 RTC_DCHECK(rtp_dtls_transport == rtp_packet_transport);
286 RTC_DCHECK(rtcp_dtls_transport == rtcp_packet_transport); 287 RTC_DCHECK(rtcp_dtls_transport == rtcp_packet_transport);
287 // Can't go from non-DTLS to DTLS. 288 // Can't go from non-DTLS to DTLS.
288 RTC_DCHECK(!rtp_transport_.rtp_packet_transport() || rtp_dtls_transport_); 289 RTC_DCHECK(!rtp_transport_->rtp_packet_transport() || rtp_dtls_transport_);
289 } else { 290 } else {
290 // Can't go from DTLS to non-DTLS. 291 // Can't go from DTLS to non-DTLS.
291 RTC_DCHECK(!rtp_dtls_transport_); 292 RTC_DCHECK(!rtp_dtls_transport_);
292 } 293 }
293 // Transport names should be the same. 294 // Transport names should be the same.
294 if (rtp_dtls_transport && rtcp_dtls_transport) { 295 if (rtp_dtls_transport && rtcp_dtls_transport) {
295 RTC_DCHECK(rtp_dtls_transport->transport_name() == 296 RTC_DCHECK(rtp_dtls_transport->transport_name() ==
296 rtcp_dtls_transport->transport_name()); 297 rtcp_dtls_transport->transport_name());
297 } 298 }
298 std::string debug_name; 299 std::string debug_name;
299 if (rtp_dtls_transport) { 300 if (rtp_dtls_transport) {
300 transport_name_ = rtp_dtls_transport->transport_name(); 301 transport_name_ = rtp_dtls_transport->transport_name();
301 debug_name = transport_name_; 302 debug_name = transport_name_;
302 } else { 303 } else {
303 debug_name = rtp_packet_transport->debug_name(); 304 debug_name = rtp_packet_transport->debug_name();
304 } 305 }
305 if (rtp_packet_transport == rtp_transport_.rtp_packet_transport()) { 306 if (rtp_packet_transport == rtp_transport_->rtp_packet_transport()) {
306 // Nothing to do if transport isn't changing. 307 // Nothing to do if transport isn't changing.
307 return; 308 return;
308 } 309 }
309 310
310 // When using DTLS-SRTP, we must reset the SrtpFilter every time the transport 311 // When using DTLS-SRTP, we must reset the SrtpFilter every time the transport
311 // changes and wait until the DTLS handshake is complete to set the newly 312 // changes and wait until the DTLS handshake is complete to set the newly
312 // negotiated parameters. 313 // negotiated parameters.
313 if (ShouldSetupDtlsSrtp_n()) { 314 if (ShouldSetupDtlsSrtp_n()) {
314 // Set |writable_| to false such that UpdateWritableState_w can set up 315 // Set |writable_| to false such that UpdateWritableState_w can set up
315 // DTLS-SRTP when |writable_| becomes true again. 316 // DTLS-SRTP when |writable_| becomes true again.
(...skipping 19 matching lines...) Expand all
335 } 336 }
336 337
337 void BaseChannel::SetTransport_n( 338 void BaseChannel::SetTransport_n(
338 bool rtcp, 339 bool rtcp,
339 DtlsTransportInternal* new_dtls_transport, 340 DtlsTransportInternal* new_dtls_transport,
340 rtc::PacketTransportInternal* new_packet_transport) { 341 rtc::PacketTransportInternal* new_packet_transport) {
341 RTC_DCHECK(network_thread_->IsCurrent()); 342 RTC_DCHECK(network_thread_->IsCurrent());
342 DtlsTransportInternal*& old_dtls_transport = 343 DtlsTransportInternal*& old_dtls_transport =
343 rtcp ? rtcp_dtls_transport_ : rtp_dtls_transport_; 344 rtcp ? rtcp_dtls_transport_ : rtp_dtls_transport_;
344 rtc::PacketTransportInternal* old_packet_transport = 345 rtc::PacketTransportInternal* old_packet_transport =
345 rtcp ? rtp_transport_.rtcp_packet_transport() 346 rtcp ? rtp_transport_->rtcp_packet_transport()
346 : rtp_transport_.rtp_packet_transport(); 347 : rtp_transport_->rtp_packet_transport();
347 348
348 if (!old_packet_transport && !new_packet_transport) { 349 if (!old_packet_transport && !new_packet_transport) {
349 // Nothing to do. 350 // Nothing to do.
350 return; 351 return;
351 } 352 }
352 353
353 RTC_DCHECK(old_packet_transport != new_packet_transport); 354 RTC_DCHECK(old_packet_transport != new_packet_transport);
354 if (old_dtls_transport) { 355 if (old_dtls_transport) {
355 DisconnectFromDtlsTransport(old_dtls_transport); 356 DisconnectFromDtlsTransport(old_dtls_transport);
356 } else if (old_packet_transport) { 357 } else if (old_packet_transport) {
357 DisconnectFromPacketTransport(old_packet_transport); 358 DisconnectFromPacketTransport(old_packet_transport);
358 } 359 }
359 360
360 if (rtcp) { 361 if (rtcp) {
361 rtp_transport_.SetRtcpPacketTransport(new_packet_transport); 362 rtp_transport_->SetRtcpPacketTransport(new_packet_transport);
362 } else { 363 } else {
363 rtp_transport_.SetRtpPacketTransport(new_packet_transport); 364 rtp_transport_->SetRtpPacketTransport(new_packet_transport);
364 } 365 }
365 old_dtls_transport = new_dtls_transport; 366 old_dtls_transport = new_dtls_transport;
366 367
367 // If there's no new transport, we're done after disconnecting from old one. 368 // If there's no new transport, we're done after disconnecting from old one.
368 if (!new_packet_transport) { 369 if (!new_packet_transport) {
369 return; 370 return;
370 } 371 }
371 372
372 if (rtcp && new_dtls_transport) { 373 if (rtcp && new_dtls_transport) {
373 RTC_CHECK(!(ShouldSetupDtlsSrtp_n() && srtp_filter_.IsActive())) 374 RTC_CHECK(!(ShouldSetupDtlsSrtp_n() && srtp_filter_.IsActive()))
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
542 RTC_FROM_HERE, Bind(&BaseChannel::SetOption_n, this, type, opt, value)); 543 RTC_FROM_HERE, Bind(&BaseChannel::SetOption_n, this, type, opt, value));
543 } 544 }
544 545
545 int BaseChannel::SetOption_n(SocketType type, 546 int BaseChannel::SetOption_n(SocketType type,
546 rtc::Socket::Option opt, 547 rtc::Socket::Option opt,
547 int value) { 548 int value) {
548 RTC_DCHECK(network_thread_->IsCurrent()); 549 RTC_DCHECK(network_thread_->IsCurrent());
549 rtc::PacketTransportInternal* transport = nullptr; 550 rtc::PacketTransportInternal* transport = nullptr;
550 switch (type) { 551 switch (type) {
551 case ST_RTP: 552 case ST_RTP:
552 transport = rtp_transport_.rtp_packet_transport(); 553 transport = rtp_transport_->rtp_packet_transport();
553 socket_options_.push_back( 554 socket_options_.push_back(
554 std::pair<rtc::Socket::Option, int>(opt, value)); 555 std::pair<rtc::Socket::Option, int>(opt, value));
555 break; 556 break;
556 case ST_RTCP: 557 case ST_RTCP:
557 transport = rtp_transport_.rtcp_packet_transport(); 558 transport = rtp_transport_->rtcp_packet_transport();
558 rtcp_socket_options_.push_back( 559 rtcp_socket_options_.push_back(
559 std::pair<rtc::Socket::Option, int>(opt, value)); 560 std::pair<rtc::Socket::Option, int>(opt, value));
560 break; 561 break;
561 } 562 }
562 return transport ? transport->SetOption(opt, value) : -1; 563 return transport ? transport->SetOption(opt, value) : -1;
563 } 564 }
564 565
565 void BaseChannel::OnWritableState(rtc::PacketTransportInternal* transport) { 566 void BaseChannel::OnWritableState(rtc::PacketTransportInternal* transport) {
566 RTC_DCHECK(transport == rtp_transport_.rtp_packet_transport() || 567 RTC_DCHECK(transport == rtp_transport_->rtp_packet_transport() ||
567 transport == rtp_transport_.rtcp_packet_transport()); 568 transport == rtp_transport_->rtcp_packet_transport());
568 RTC_DCHECK(network_thread_->IsCurrent()); 569 RTC_DCHECK(network_thread_->IsCurrent());
569 UpdateWritableState_n(); 570 UpdateWritableState_n();
570 } 571 }
571 572
572 void BaseChannel::OnDtlsState(DtlsTransportInternal* transport, 573 void BaseChannel::OnDtlsState(DtlsTransportInternal* transport,
573 DtlsTransportState state) { 574 DtlsTransportState state) {
574 if (!ShouldSetupDtlsSrtp_n()) { 575 if (!ShouldSetupDtlsSrtp_n()) {
575 return; 576 return;
576 } 577 }
577 578
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
636 data->options = options; 637 data->options = options;
637 network_thread_->Post(RTC_FROM_HERE, this, message_id, data); 638 network_thread_->Post(RTC_FROM_HERE, this, message_id, data);
638 return true; 639 return true;
639 } 640 }
640 TRACE_EVENT0("webrtc", "BaseChannel::SendPacket"); 641 TRACE_EVENT0("webrtc", "BaseChannel::SendPacket");
641 642
642 // Now that we are on the correct thread, ensure we have a place to send this 643 // Now that we are on the correct thread, ensure we have a place to send this
643 // packet before doing anything. (We might get RTCP packets that we don't 644 // packet before doing anything. (We might get RTCP packets that we don't
644 // intend to send.) If we've negotiated RTCP mux, send RTCP over the RTP 645 // intend to send.) If we've negotiated RTCP mux, send RTCP over the RTP
645 // transport. 646 // transport.
646 if (!rtp_transport_.IsWritable(rtcp)) { 647 if (!rtp_transport_->IsWritable(rtcp)) {
647 return false; 648 return false;
648 } 649 }
649 650
650 // Protect ourselves against crazy data. 651 // Protect ourselves against crazy data.
651 if (!ValidPacket(rtcp, packet)) { 652 if (!ValidPacket(rtcp, packet)) {
652 LOG(LS_ERROR) << "Dropping outgoing " << content_name_ << " " 653 LOG(LS_ERROR) << "Dropping outgoing " << content_name_ << " "
653 << RtpRtcpStringLiteral(rtcp) 654 << RtpRtcpStringLiteral(rtcp)
654 << " packet: wrong size=" << packet->size(); 655 << " packet: wrong size=" << packet->size();
655 return false; 656 return false;
656 } 657 }
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
732 // However, there shouldn't be any RTP packets sent before SRTP is set up 733 // However, there shouldn't be any RTP packets sent before SRTP is set up
733 // (and SetSend(true) is called). 734 // (and SetSend(true) is called).
734 LOG(LS_ERROR) << "Can't send outgoing RTP packet when SRTP is inactive" 735 LOG(LS_ERROR) << "Can't send outgoing RTP packet when SRTP is inactive"
735 << " and crypto is required"; 736 << " and crypto is required";
736 RTC_NOTREACHED(); 737 RTC_NOTREACHED();
737 return false; 738 return false;
738 } 739 }
739 740
740 // Bon voyage. 741 // Bon voyage.
741 int flags = (secure() && secure_dtls()) ? PF_SRTP_BYPASS : PF_NORMAL; 742 int flags = (secure() && secure_dtls()) ? PF_SRTP_BYPASS : PF_NORMAL;
742 return rtp_transport_.SendPacket(rtcp, packet, updated_options, flags); 743 return rtp_transport_->SendPacket(rtcp, packet, updated_options, flags);
743 } 744 }
744 745
745 bool BaseChannel::HandlesPayloadType(int packet_type) const { 746 bool BaseChannel::HandlesPayloadType(int packet_type) const {
746 return rtp_transport_.HandlesPayloadType(packet_type); 747 return rtp_transport_->HandlesPayloadType(packet_type);
747 } 748 }
748 749
749 void BaseChannel::OnPacketReceived(bool rtcp, 750 void BaseChannel::OnPacketReceived(bool rtcp,
750 rtc::CopyOnWriteBuffer& packet, 751 rtc::CopyOnWriteBuffer& packet,
751 const rtc::PacketTime& packet_time) { 752 const rtc::PacketTime& packet_time) {
752 if (!has_received_packet_ && !rtcp) { 753 if (!has_received_packet_ && !rtcp) {
753 has_received_packet_ = true; 754 has_received_packet_ = true;
754 signaling_thread()->Post(RTC_FROM_HERE, this, MSG_FIRSTPACKETRECEIVED); 755 signaling_thread()->Post(RTC_FROM_HERE, this, MSG_FIRSTPACKETRECEIVED);
755 } 756 }
756 757
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
864 if (!enabled_) 865 if (!enabled_)
865 return; 866 return;
866 867
867 LOG(LS_INFO) << "Channel disabled"; 868 LOG(LS_INFO) << "Channel disabled";
868 enabled_ = false; 869 enabled_ = false;
869 UpdateMediaSendRecvState_w(); 870 UpdateMediaSendRecvState_w();
870 } 871 }
871 872
872 void BaseChannel::UpdateWritableState_n() { 873 void BaseChannel::UpdateWritableState_n() {
873 rtc::PacketTransportInternal* rtp_packet_transport = 874 rtc::PacketTransportInternal* rtp_packet_transport =
874 rtp_transport_.rtp_packet_transport(); 875 rtp_transport_->rtp_packet_transport();
875 rtc::PacketTransportInternal* rtcp_packet_transport = 876 rtc::PacketTransportInternal* rtcp_packet_transport =
876 rtp_transport_.rtcp_packet_transport(); 877 rtp_transport_->rtcp_packet_transport();
877 if (rtp_packet_transport && rtp_packet_transport->writable() && 878 if (rtp_packet_transport && rtp_packet_transport->writable() &&
878 (!rtcp_packet_transport || rtcp_packet_transport->writable())) { 879 (!rtcp_packet_transport || rtcp_packet_transport->writable())) {
879 ChannelWritable_n(); 880 ChannelWritable_n();
880 } else { 881 } else {
881 ChannelNotWritable_n(); 882 ChannelNotWritable_n();
882 } 883 }
883 } 884 }
884 885
885 void BaseChannel::ChannelWritable_n() { 886 void BaseChannel::ChannelWritable_n() {
886 RTC_DCHECK(network_thread_->IsCurrent()); 887 RTC_DCHECK(network_thread_->IsCurrent());
(...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after
1195 // because the final answer may deactivate it. 1196 // because the final answer may deactivate it.
1196 ret = rtcp_mux_filter_.SetProvisionalAnswer(enable, src); 1197 ret = rtcp_mux_filter_.SetProvisionalAnswer(enable, src);
1197 break; 1198 break;
1198 case CA_ANSWER: 1199 case CA_ANSWER:
1199 ret = rtcp_mux_filter_.SetAnswer(enable, src); 1200 ret = rtcp_mux_filter_.SetAnswer(enable, src);
1200 if (ret && rtcp_mux_filter_.IsActive()) { 1201 if (ret && rtcp_mux_filter_.IsActive()) {
1201 // We permanently activated RTCP muxing; signal that we no longer need 1202 // We permanently activated RTCP muxing; signal that we no longer need
1202 // the RTCP transport. 1203 // the RTCP transport.
1203 std::string debug_name = 1204 std::string debug_name =
1204 transport_name_.empty() 1205 transport_name_.empty()
1205 ? rtp_transport_.rtp_packet_transport()->debug_name() 1206 ? rtp_transport_->rtp_packet_transport()->debug_name()
1206 : transport_name_; 1207 : transport_name_;
1207 ; 1208 ;
1208 LOG(LS_INFO) << "Enabling rtcp-mux for " << content_name() 1209 LOG(LS_INFO) << "Enabling rtcp-mux for " << content_name()
1209 << "; no longer need RTCP transport for " << debug_name; 1210 << "; no longer need RTCP transport for " << debug_name;
1210 if (rtp_transport_.rtcp_packet_transport()) { 1211 if (rtp_transport_->rtcp_packet_transport()) {
1211 SetTransport_n(true, nullptr, nullptr); 1212 SetTransport_n(true, nullptr, nullptr);
1212 SignalRtcpMuxFullyActive(transport_name_); 1213 SignalRtcpMuxFullyActive(transport_name_);
1213 } 1214 }
1214 UpdateWritableState_n(); 1215 UpdateWritableState_n();
1215 } 1216 }
1216 break; 1217 break;
1217 case CA_UPDATE: 1218 case CA_UPDATE:
1218 // No RTCP mux info. 1219 // No RTCP mux info.
1219 ret = true; 1220 ret = true;
1220 break; 1221 break;
1221 default: 1222 default:
1222 break; 1223 break;
1223 } 1224 }
1224 if (!ret) { 1225 if (!ret) {
1225 SafeSetError("Failed to setup RTCP mux filter.", error_desc); 1226 SafeSetError("Failed to setup RTCP mux filter.", error_desc);
1226 return false; 1227 return false;
1227 } 1228 }
1228 rtp_transport_.SetRtcpMuxEnabled(rtcp_mux_filter_.IsActive()); 1229 rtp_transport_->SetRtcpMuxEnabled(rtcp_mux_filter_.IsActive());
1229 // |rtcp_mux_filter_| can be active if |action| is CA_PRANSWER or 1230 // |rtcp_mux_filter_| can be active if |action| is CA_PRANSWER or
1230 // CA_ANSWER, but we only want to tear down the RTCP transport if we received 1231 // CA_ANSWER, but we only want to tear down the RTCP transport if we received
1231 // a final answer. 1232 // a final answer.
1232 if (rtcp_mux_filter_.IsActive()) { 1233 if (rtcp_mux_filter_.IsActive()) {
1233 // If the RTP transport is already writable, then so are we. 1234 // If the RTP transport is already writable, then so are we.
1234 if (rtp_transport_.rtp_packet_transport()->writable()) { 1235 if (rtp_transport_->rtp_packet_transport()->writable()) {
1235 ChannelWritable_n(); 1236 ChannelWritable_n();
1236 } 1237 }
1237 } 1238 }
1238 1239
1239 return true; 1240 return true;
1240 } 1241 }
1241 1242
1242 bool BaseChannel::AddRecvStream_w(const StreamParams& sp) { 1243 bool BaseChannel::AddRecvStream_w(const StreamParams& sp) {
1243 RTC_DCHECK(worker_thread() == rtc::Thread::Current()); 1244 RTC_DCHECK(worker_thread() == rtc::Thread::Current());
1244 return media_channel()->AddRecvStream(sp); 1245 return media_channel()->AddRecvStream(sp);
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after
1450 break; 1451 break;
1451 } 1452 }
1452 case MSG_FIRSTPACKETRECEIVED: { 1453 case MSG_FIRSTPACKETRECEIVED: {
1453 SignalFirstPacketReceived(this); 1454 SignalFirstPacketReceived(this);
1454 break; 1455 break;
1455 } 1456 }
1456 } 1457 }
1457 } 1458 }
1458 1459
1459 void BaseChannel::AddHandledPayloadType(int payload_type) { 1460 void BaseChannel::AddHandledPayloadType(int payload_type) {
1460 rtp_transport_.AddHandledPayloadType(payload_type); 1461 rtp_transport_->AddHandledPayloadType(payload_type);
1461 } 1462 }
1462 1463
1463 void BaseChannel::FlushRtcpMessages_n() { 1464 void BaseChannel::FlushRtcpMessages_n() {
1464 // Flush all remaining RTCP messages. This should only be called in 1465 // Flush all remaining RTCP messages. This should only be called in
1465 // destructor. 1466 // destructor.
1466 RTC_DCHECK(network_thread_->IsCurrent()); 1467 RTC_DCHECK(network_thread_->IsCurrent());
1467 rtc::MessageList rtcp_messages; 1468 rtc::MessageList rtcp_messages;
1468 network_thread_->Clear(this, MSG_SEND_RTCP_PACKET, &rtcp_messages); 1469 network_thread_->Clear(this, MSG_SEND_RTCP_PACKET, &rtcp_messages);
1469 for (const auto& message : rtcp_messages) { 1470 for (const auto& message : rtcp_messages) {
1470 network_thread_->Send(RTC_FROM_HERE, this, MSG_SEND_RTCP_PACKET, 1471 network_thread_->Send(RTC_FROM_HERE, this, MSG_SEND_RTCP_PACKET,
(...skipping 976 matching lines...) Expand 10 before | Expand all | Expand 10 after
2447 2448
2448 void RtpDataChannel::OnDataChannelReadyToSend(bool writable) { 2449 void RtpDataChannel::OnDataChannelReadyToSend(bool writable) {
2449 // This is usded for congestion control to indicate that the stream is ready 2450 // This is usded for congestion control to indicate that the stream is ready
2450 // to send by the MediaChannel, as opposed to OnReadyToSend, which indicates 2451 // to send by the MediaChannel, as opposed to OnReadyToSend, which indicates
2451 // that the transport channel is ready. 2452 // that the transport channel is ready.
2452 signaling_thread()->Post(RTC_FROM_HERE, this, MSG_READYTOSENDDATA, 2453 signaling_thread()->Post(RTC_FROM_HERE, this, MSG_READYTOSENDDATA,
2453 new DataChannelReadyToSendMessageData(writable)); 2454 new DataChannelReadyToSendMessageData(writable));
2454 } 2455 }
2455 2456
2456 } // namespace cricket 2457 } // namespace cricket
OLDNEW
« no previous file with comments | « webrtc/pc/channel.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698