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

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

Issue 2679103006: Rename "PacketTransportInterface" to "PacketTransportInternal". (Closed)
Patch Set: Created 3 years, 10 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
11 #include <utility> 11 #include <utility>
12 12
13 #include "webrtc/pc/channel.h" 13 #include "webrtc/pc/channel.h"
14 14
15 #include "webrtc/api/call/audio_sink.h" 15 #include "webrtc/api/call/audio_sink.h"
16 #include "webrtc/base/bind.h" 16 #include "webrtc/base/bind.h"
17 #include "webrtc/base/byteorder.h" 17 #include "webrtc/base/byteorder.h"
18 #include "webrtc/base/checks.h" 18 #include "webrtc/base/checks.h"
19 #include "webrtc/base/copyonwritebuffer.h" 19 #include "webrtc/base/copyonwritebuffer.h"
20 #include "webrtc/base/dscp.h" 20 #include "webrtc/base/dscp.h"
21 #include "webrtc/base/logging.h" 21 #include "webrtc/base/logging.h"
22 #include "webrtc/base/networkroute.h" 22 #include "webrtc/base/networkroute.h"
23 #include "webrtc/base/trace_event.h" 23 #include "webrtc/base/trace_event.h"
24 #include "webrtc/media/base/mediaconstants.h" 24 #include "webrtc/media/base/mediaconstants.h"
25 #include "webrtc/media/base/rtputils.h" 25 #include "webrtc/media/base/rtputils.h"
26 #include "webrtc/p2p/base/packettransportinterface.h" 26 #include "webrtc/p2p/base/packettransportinternal.h"
27 #include "webrtc/pc/channelmanager.h" 27 #include "webrtc/pc/channelmanager.h"
28 28
29 namespace cricket { 29 namespace cricket {
30 using rtc::Bind; 30 using rtc::Bind;
31 31
32 namespace { 32 namespace {
33 // See comment below for why we need to use a pointer to a unique_ptr. 33 // See comment below for why we need to use a pointer to a unique_ptr.
34 bool SetRawAudioSink_w(VoiceMediaChannel* channel, 34 bool SetRawAudioSink_w(VoiceMediaChannel* channel,
35 uint32_t ssrc, 35 uint32_t ssrc,
36 std::unique_ptr<webrtc::AudioSinkInterface>* sink) { 36 std::unique_ptr<webrtc::AudioSinkInterface>* sink) {
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 DisconnectFromPacketTransport(rtcp_packet_transport_); 207 DisconnectFromPacketTransport(rtcp_packet_transport_);
208 } 208 }
209 209
210 // Clear pending read packets/messages. 210 // Clear pending read packets/messages.
211 network_thread_->Clear(&invoker_); 211 network_thread_->Clear(&invoker_);
212 network_thread_->Clear(this); 212 network_thread_->Clear(this);
213 } 213 }
214 214
215 bool BaseChannel::Init_w(DtlsTransportInternal* rtp_dtls_transport, 215 bool BaseChannel::Init_w(DtlsTransportInternal* rtp_dtls_transport,
216 DtlsTransportInternal* rtcp_dtls_transport, 216 DtlsTransportInternal* rtcp_dtls_transport,
217 rtc::PacketTransportInterface* rtp_packet_transport, 217 rtc::PacketTransportInternal* rtp_packet_transport,
218 rtc::PacketTransportInterface* rtcp_packet_transport) { 218 rtc::PacketTransportInternal* rtcp_packet_transport) {
219 if (!network_thread_->Invoke<bool>( 219 if (!network_thread_->Invoke<bool>(
220 RTC_FROM_HERE, Bind(&BaseChannel::InitNetwork_n, this, 220 RTC_FROM_HERE, Bind(&BaseChannel::InitNetwork_n, this,
221 rtp_dtls_transport, rtcp_dtls_transport, 221 rtp_dtls_transport, rtcp_dtls_transport,
222 rtp_packet_transport, rtcp_packet_transport))) { 222 rtp_packet_transport, rtcp_packet_transport))) {
223 return false; 223 return false;
224 } 224 }
225 // Both RTP and RTCP channels should be set, we can call SetInterface on 225 // Both RTP and RTCP channels should be set, we can call SetInterface on
226 // the media channel and it can set network options. 226 // the media channel and it can set network options.
227 RTC_DCHECK_RUN_ON(worker_thread_); 227 RTC_DCHECK_RUN_ON(worker_thread_);
228 media_channel_->SetInterface(this); 228 media_channel_->SetInterface(this);
229 return true; 229 return true;
230 } 230 }
231 231
232 bool BaseChannel::InitNetwork_n( 232 bool BaseChannel::InitNetwork_n(
233 DtlsTransportInternal* rtp_dtls_transport, 233 DtlsTransportInternal* rtp_dtls_transport,
234 DtlsTransportInternal* rtcp_dtls_transport, 234 DtlsTransportInternal* rtcp_dtls_transport,
235 rtc::PacketTransportInterface* rtp_packet_transport, 235 rtc::PacketTransportInternal* rtp_packet_transport,
236 rtc::PacketTransportInterface* rtcp_packet_transport) { 236 rtc::PacketTransportInternal* rtcp_packet_transport) {
237 RTC_DCHECK(network_thread_->IsCurrent()); 237 RTC_DCHECK(network_thread_->IsCurrent());
238 SetTransports_n(rtp_dtls_transport, rtcp_dtls_transport, rtp_packet_transport, 238 SetTransports_n(rtp_dtls_transport, rtcp_dtls_transport, rtp_packet_transport,
239 rtcp_packet_transport); 239 rtcp_packet_transport);
240 240
241 if (rtp_dtls_transport_ && 241 if (rtp_dtls_transport_ &&
242 !SetDtlsSrtpCryptoSuites_n(rtp_dtls_transport_, false)) { 242 !SetDtlsSrtpCryptoSuites_n(rtp_dtls_transport_, false)) {
243 return false; 243 return false;
244 } 244 }
245 if (rtcp_dtls_transport_ && 245 if (rtcp_dtls_transport_ &&
246 !SetDtlsSrtpCryptoSuites_n(rtcp_dtls_transport_, true)) { 246 !SetDtlsSrtpCryptoSuites_n(rtcp_dtls_transport_, true)) {
(...skipping 17 matching lines...) Expand all
264 264
265 void BaseChannel::SetTransports(DtlsTransportInternal* rtp_dtls_transport, 265 void BaseChannel::SetTransports(DtlsTransportInternal* rtp_dtls_transport,
266 DtlsTransportInternal* rtcp_dtls_transport) { 266 DtlsTransportInternal* rtcp_dtls_transport) {
267 network_thread_->Invoke<void>( 267 network_thread_->Invoke<void>(
268 RTC_FROM_HERE, 268 RTC_FROM_HERE,
269 Bind(&BaseChannel::SetTransports_n, this, rtp_dtls_transport, 269 Bind(&BaseChannel::SetTransports_n, this, rtp_dtls_transport,
270 rtcp_dtls_transport, rtp_dtls_transport, rtcp_dtls_transport)); 270 rtcp_dtls_transport, rtp_dtls_transport, rtcp_dtls_transport));
271 } 271 }
272 272
273 void BaseChannel::SetTransports( 273 void BaseChannel::SetTransports(
274 rtc::PacketTransportInterface* rtp_packet_transport, 274 rtc::PacketTransportInternal* rtp_packet_transport,
275 rtc::PacketTransportInterface* rtcp_packet_transport) { 275 rtc::PacketTransportInternal* rtcp_packet_transport) {
276 network_thread_->Invoke<void>( 276 network_thread_->Invoke<void>(
277 RTC_FROM_HERE, Bind(&BaseChannel::SetTransports_n, this, nullptr, nullptr, 277 RTC_FROM_HERE, Bind(&BaseChannel::SetTransports_n, this, nullptr, nullptr,
278 rtp_packet_transport, rtcp_packet_transport)); 278 rtp_packet_transport, rtcp_packet_transport));
279 } 279 }
280 280
281 void BaseChannel::SetTransports_n( 281 void BaseChannel::SetTransports_n(
282 DtlsTransportInternal* rtp_dtls_transport, 282 DtlsTransportInternal* rtp_dtls_transport,
283 DtlsTransportInternal* rtcp_dtls_transport, 283 DtlsTransportInternal* rtcp_dtls_transport,
284 rtc::PacketTransportInterface* rtp_packet_transport, 284 rtc::PacketTransportInternal* rtp_packet_transport,
285 rtc::PacketTransportInterface* rtcp_packet_transport) { 285 rtc::PacketTransportInternal* rtcp_packet_transport) {
286 RTC_DCHECK(network_thread_->IsCurrent()); 286 RTC_DCHECK(network_thread_->IsCurrent());
287 // Validate some assertions about the input. 287 // Validate some assertions about the input.
288 RTC_DCHECK(rtp_packet_transport); 288 RTC_DCHECK(rtp_packet_transport);
289 RTC_DCHECK_EQ(NeedsRtcpTransport(), rtcp_packet_transport != nullptr); 289 RTC_DCHECK_EQ(NeedsRtcpTransport(), rtcp_packet_transport != nullptr);
290 if (rtp_dtls_transport || rtcp_dtls_transport) { 290 if (rtp_dtls_transport || rtcp_dtls_transport) {
291 // DTLS/non-DTLS pointers should be to the same object. 291 // DTLS/non-DTLS pointers should be to the same object.
292 RTC_DCHECK(rtp_dtls_transport == rtp_packet_transport); 292 RTC_DCHECK(rtp_dtls_transport == rtp_packet_transport);
293 RTC_DCHECK(rtcp_dtls_transport == rtcp_packet_transport); 293 RTC_DCHECK(rtcp_dtls_transport == rtcp_packet_transport);
294 // Can't go from non-DTLS to DTLS. 294 // Can't go from non-DTLS to DTLS.
295 RTC_DCHECK(!rtp_packet_transport_ || rtp_dtls_transport_); 295 RTC_DCHECK(!rtp_packet_transport_ || rtp_dtls_transport_);
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
350 // encounter the error again and update "ready to send" accordingly. 350 // encounter the error again and update "ready to send" accordingly.
351 SetTransportChannelReadyToSend( 351 SetTransportChannelReadyToSend(
352 false, rtp_packet_transport_ && rtp_packet_transport_->writable()); 352 false, rtp_packet_transport_ && rtp_packet_transport_->writable());
353 SetTransportChannelReadyToSend( 353 SetTransportChannelReadyToSend(
354 true, rtcp_packet_transport_ && rtcp_packet_transport_->writable()); 354 true, rtcp_packet_transport_ && rtcp_packet_transport_->writable());
355 } 355 }
356 356
357 void BaseChannel::SetTransport_n( 357 void BaseChannel::SetTransport_n(
358 bool rtcp, 358 bool rtcp,
359 DtlsTransportInternal* new_dtls_transport, 359 DtlsTransportInternal* new_dtls_transport,
360 rtc::PacketTransportInterface* new_packet_transport) { 360 rtc::PacketTransportInternal* new_packet_transport) {
361 RTC_DCHECK(network_thread_->IsCurrent()); 361 RTC_DCHECK(network_thread_->IsCurrent());
362 DtlsTransportInternal*& old_dtls_transport = 362 DtlsTransportInternal*& old_dtls_transport =
363 rtcp ? rtcp_dtls_transport_ : rtp_dtls_transport_; 363 rtcp ? rtcp_dtls_transport_ : rtp_dtls_transport_;
364 rtc::PacketTransportInterface*& old_packet_transport = 364 rtc::PacketTransportInternal*& old_packet_transport =
365 rtcp ? rtcp_packet_transport_ : rtp_packet_transport_; 365 rtcp ? rtcp_packet_transport_ : rtp_packet_transport_;
366 366
367 if (!old_packet_transport && !new_packet_transport) { 367 if (!old_packet_transport && !new_packet_transport) {
368 // Nothing to do. 368 // Nothing to do.
369 return; 369 return;
370 } 370 }
371 371
372 RTC_DCHECK(old_packet_transport != new_packet_transport); 372 RTC_DCHECK(old_packet_transport != new_packet_transport);
373 if (old_dtls_transport) { 373 if (old_dtls_transport) {
374 DisconnectFromDtlsTransport(old_dtls_transport); 374 DisconnectFromDtlsTransport(old_dtls_transport);
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
421 transport->SignalWritableState.disconnect(this); 421 transport->SignalWritableState.disconnect(this);
422 transport->SignalReadPacket.disconnect(this); 422 transport->SignalReadPacket.disconnect(this);
423 transport->SignalReadyToSend.disconnect(this); 423 transport->SignalReadyToSend.disconnect(this);
424 transport->SignalDtlsState.disconnect(this); 424 transport->SignalDtlsState.disconnect(this);
425 transport->SignalSentPacket.disconnect(this); 425 transport->SignalSentPacket.disconnect(this);
426 transport->ice_transport()->SignalSelectedCandidatePairChanged.disconnect( 426 transport->ice_transport()->SignalSelectedCandidatePairChanged.disconnect(
427 this); 427 this);
428 } 428 }
429 429
430 void BaseChannel::ConnectToPacketTransport( 430 void BaseChannel::ConnectToPacketTransport(
431 rtc::PacketTransportInterface* transport) { 431 rtc::PacketTransportInternal* transport) {
432 RTC_DCHECK_RUN_ON(network_thread_); 432 RTC_DCHECK_RUN_ON(network_thread_);
433 transport->SignalWritableState.connect(this, &BaseChannel::OnWritableState); 433 transport->SignalWritableState.connect(this, &BaseChannel::OnWritableState);
434 transport->SignalReadPacket.connect(this, &BaseChannel::OnPacketRead); 434 transport->SignalReadPacket.connect(this, &BaseChannel::OnPacketRead);
435 transport->SignalReadyToSend.connect(this, &BaseChannel::OnReadyToSend); 435 transport->SignalReadyToSend.connect(this, &BaseChannel::OnReadyToSend);
436 transport->SignalSentPacket.connect(this, &BaseChannel::SignalSentPacket_n); 436 transport->SignalSentPacket.connect(this, &BaseChannel::SignalSentPacket_n);
437 } 437 }
438 438
439 void BaseChannel::DisconnectFromPacketTransport( 439 void BaseChannel::DisconnectFromPacketTransport(
440 rtc::PacketTransportInterface* transport) { 440 rtc::PacketTransportInternal* transport) {
441 RTC_DCHECK_RUN_ON(network_thread_); 441 RTC_DCHECK_RUN_ON(network_thread_);
442 transport->SignalWritableState.disconnect(this); 442 transport->SignalWritableState.disconnect(this);
443 transport->SignalReadPacket.disconnect(this); 443 transport->SignalReadPacket.disconnect(this);
444 transport->SignalReadyToSend.disconnect(this); 444 transport->SignalReadyToSend.disconnect(this);
445 transport->SignalSentPacket.disconnect(this); 445 transport->SignalSentPacket.disconnect(this);
446 } 446 }
447 447
448 bool BaseChannel::Enable(bool enable) { 448 bool BaseChannel::Enable(bool enable) {
449 worker_thread_->Invoke<void>( 449 worker_thread_->Invoke<void>(
450 RTC_FROM_HERE, 450 RTC_FROM_HERE,
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
557 int BaseChannel::SetOption(SocketType type, rtc::Socket::Option opt, 557 int BaseChannel::SetOption(SocketType type, rtc::Socket::Option opt,
558 int value) { 558 int value) {
559 return network_thread_->Invoke<int>( 559 return network_thread_->Invoke<int>(
560 RTC_FROM_HERE, Bind(&BaseChannel::SetOption_n, this, type, opt, value)); 560 RTC_FROM_HERE, Bind(&BaseChannel::SetOption_n, this, type, opt, value));
561 } 561 }
562 562
563 int BaseChannel::SetOption_n(SocketType type, 563 int BaseChannel::SetOption_n(SocketType type,
564 rtc::Socket::Option opt, 564 rtc::Socket::Option opt,
565 int value) { 565 int value) {
566 RTC_DCHECK(network_thread_->IsCurrent()); 566 RTC_DCHECK(network_thread_->IsCurrent());
567 rtc::PacketTransportInterface* transport = nullptr; 567 rtc::PacketTransportInternal* transport = nullptr;
568 switch (type) { 568 switch (type) {
569 case ST_RTP: 569 case ST_RTP:
570 transport = rtp_packet_transport_; 570 transport = rtp_packet_transport_;
571 socket_options_.push_back( 571 socket_options_.push_back(
572 std::pair<rtc::Socket::Option, int>(opt, value)); 572 std::pair<rtc::Socket::Option, int>(opt, value));
573 break; 573 break;
574 case ST_RTCP: 574 case ST_RTCP:
575 transport = rtcp_packet_transport_; 575 transport = rtcp_packet_transport_;
576 rtcp_socket_options_.push_back( 576 rtcp_socket_options_.push_back(
577 std::pair<rtc::Socket::Option, int>(opt, value)); 577 std::pair<rtc::Socket::Option, int>(opt, value));
578 break; 578 break;
579 } 579 }
580 return transport ? transport->SetOption(opt, value) : -1; 580 return transport ? transport->SetOption(opt, value) : -1;
581 } 581 }
582 582
583 bool BaseChannel::SetCryptoOptions(const rtc::CryptoOptions& crypto_options) { 583 bool BaseChannel::SetCryptoOptions(const rtc::CryptoOptions& crypto_options) {
584 crypto_options_ = crypto_options; 584 crypto_options_ = crypto_options;
585 return true; 585 return true;
586 } 586 }
587 587
588 void BaseChannel::OnWritableState(rtc::PacketTransportInterface* transport) { 588 void BaseChannel::OnWritableState(rtc::PacketTransportInternal* transport) {
589 RTC_DCHECK(transport == rtp_packet_transport_ || 589 RTC_DCHECK(transport == rtp_packet_transport_ ||
590 transport == rtcp_packet_transport_); 590 transport == rtcp_packet_transport_);
591 RTC_DCHECK(network_thread_->IsCurrent()); 591 RTC_DCHECK(network_thread_->IsCurrent());
592 UpdateWritableState_n(); 592 UpdateWritableState_n();
593 } 593 }
594 594
595 void BaseChannel::OnPacketRead(rtc::PacketTransportInterface* transport, 595 void BaseChannel::OnPacketRead(rtc::PacketTransportInternal* transport,
596 const char* data, 596 const char* data,
597 size_t len, 597 size_t len,
598 const rtc::PacketTime& packet_time, 598 const rtc::PacketTime& packet_time,
599 int flags) { 599 int flags) {
600 TRACE_EVENT0("webrtc", "BaseChannel::OnPacketRead"); 600 TRACE_EVENT0("webrtc", "BaseChannel::OnPacketRead");
601 // OnPacketRead gets called from P2PSocket; now pass data to MediaEngine 601 // OnPacketRead gets called from P2PSocket; now pass data to MediaEngine
602 RTC_DCHECK(network_thread_->IsCurrent()); 602 RTC_DCHECK(network_thread_->IsCurrent());
603 603
604 // When using RTCP multiplexing we might get RTCP packets on the RTP 604 // When using RTCP multiplexing we might get RTCP packets on the RTP
605 // transport. We feed RTP traffic into the demuxer to determine if it is RTCP. 605 // transport. We feed RTP traffic into the demuxer to determine if it is RTCP.
606 bool rtcp = PacketIsRtcp(transport, data, len); 606 bool rtcp = PacketIsRtcp(transport, data, len);
607 rtc::CopyOnWriteBuffer packet(data, len); 607 rtc::CopyOnWriteBuffer packet(data, len);
608 HandlePacket(rtcp, &packet, packet_time); 608 HandlePacket(rtcp, &packet, packet_time);
609 } 609 }
610 610
611 void BaseChannel::OnReadyToSend(rtc::PacketTransportInterface* transport) { 611 void BaseChannel::OnReadyToSend(rtc::PacketTransportInternal* transport) {
612 RTC_DCHECK(transport == rtp_packet_transport_ || 612 RTC_DCHECK(transport == rtp_packet_transport_ ||
613 transport == rtcp_packet_transport_); 613 transport == rtcp_packet_transport_);
614 SetTransportChannelReadyToSend(transport == rtcp_packet_transport_, true); 614 SetTransportChannelReadyToSend(transport == rtcp_packet_transport_, true);
615 } 615 }
616 616
617 void BaseChannel::OnDtlsState(DtlsTransportInternal* transport, 617 void BaseChannel::OnDtlsState(DtlsTransportInternal* transport,
618 DtlsTransportState state) { 618 DtlsTransportState state) {
619 if (!ShouldSetupDtlsSrtp_n()) { 619 if (!ShouldSetupDtlsSrtp_n()) {
620 return; 620 return;
621 } 621 }
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
668 bool ready_to_send = 668 bool ready_to_send =
669 (rtp_ready_to_send_ && 669 (rtp_ready_to_send_ &&
670 // In the case of rtcp mux |rtcp_packet_transport_| will be null. 670 // In the case of rtcp mux |rtcp_packet_transport_| will be null.
671 (rtcp_ready_to_send_ || !rtcp_packet_transport_)); 671 (rtcp_ready_to_send_ || !rtcp_packet_transport_));
672 672
673 invoker_.AsyncInvoke<void>( 673 invoker_.AsyncInvoke<void>(
674 RTC_FROM_HERE, worker_thread_, 674 RTC_FROM_HERE, worker_thread_,
675 Bind(&MediaChannel::OnReadyToSend, media_channel_, ready_to_send)); 675 Bind(&MediaChannel::OnReadyToSend, media_channel_, ready_to_send));
676 } 676 }
677 677
678 bool BaseChannel::PacketIsRtcp(const rtc::PacketTransportInterface* transport, 678 bool BaseChannel::PacketIsRtcp(const rtc::PacketTransportInternal* transport,
679 const char* data, 679 const char* data,
680 size_t len) { 680 size_t len) {
681 return (transport == rtcp_packet_transport_ || 681 return (transport == rtcp_packet_transport_ ||
682 rtcp_mux_filter_.DemuxRtcp(data, static_cast<int>(len))); 682 rtcp_mux_filter_.DemuxRtcp(data, static_cast<int>(len)));
683 } 683 }
684 684
685 bool BaseChannel::SendPacket(bool rtcp, 685 bool BaseChannel::SendPacket(bool rtcp,
686 rtc::CopyOnWriteBuffer* packet, 686 rtc::CopyOnWriteBuffer* packet,
687 const rtc::PacketOptions& options) { 687 const rtc::PacketOptions& options) {
688 // SendPacket gets called from MediaEngine, on a pacer or an encoder thread. 688 // SendPacket gets called from MediaEngine, on a pacer or an encoder thread.
(...skipping 11 matching lines...) Expand all
700 data->options = options; 700 data->options = options;
701 network_thread_->Post(RTC_FROM_HERE, this, message_id, data); 701 network_thread_->Post(RTC_FROM_HERE, this, message_id, data);
702 return true; 702 return true;
703 } 703 }
704 TRACE_EVENT0("webrtc", "BaseChannel::SendPacket"); 704 TRACE_EVENT0("webrtc", "BaseChannel::SendPacket");
705 705
706 // Now that we are on the correct thread, ensure we have a place to send this 706 // Now that we are on the correct thread, ensure we have a place to send this
707 // packet before doing anything. (We might get RTCP packets that we don't 707 // packet before doing anything. (We might get RTCP packets that we don't
708 // intend to send.) If we've negotiated RTCP mux, send RTCP over the RTP 708 // intend to send.) If we've negotiated RTCP mux, send RTCP over the RTP
709 // transport. 709 // transport.
710 rtc::PacketTransportInterface* transport = 710 rtc::PacketTransportInternal* transport =
711 (!rtcp || rtcp_mux_filter_.IsActive()) ? rtp_packet_transport_ 711 (!rtcp || rtcp_mux_filter_.IsActive()) ? rtp_packet_transport_
712 : rtcp_packet_transport_; 712 : rtcp_packet_transport_;
713 if (!transport || !transport->writable()) { 713 if (!transport || !transport->writable()) {
714 return false; 714 return false;
715 } 715 }
716 716
717 // Protect ourselves against crazy data. 717 // Protect ourselves against crazy data.
718 if (!ValidPacket(rtcp, packet)) { 718 if (!ValidPacket(rtcp, packet)) {
719 LOG(LS_ERROR) << "Dropping outgoing " << content_name_ << " " 719 LOG(LS_ERROR) << "Dropping outgoing " << content_name_ << " "
720 << PacketType(rtcp) 720 << PacketType(rtcp)
(...skipping 778 matching lines...) Expand 10 before | Expand all | Expand 10 after
1499 RTC_DCHECK(network_thread_->IsCurrent()); 1499 RTC_DCHECK(network_thread_->IsCurrent());
1500 rtc::MessageList rtcp_messages; 1500 rtc::MessageList rtcp_messages;
1501 network_thread_->Clear(this, MSG_SEND_RTCP_PACKET, &rtcp_messages); 1501 network_thread_->Clear(this, MSG_SEND_RTCP_PACKET, &rtcp_messages);
1502 for (const auto& message : rtcp_messages) { 1502 for (const auto& message : rtcp_messages) {
1503 network_thread_->Send(RTC_FROM_HERE, this, MSG_SEND_RTCP_PACKET, 1503 network_thread_->Send(RTC_FROM_HERE, this, MSG_SEND_RTCP_PACKET,
1504 message.pdata); 1504 message.pdata);
1505 } 1505 }
1506 } 1506 }
1507 1507
1508 void BaseChannel::SignalSentPacket_n( 1508 void BaseChannel::SignalSentPacket_n(
1509 rtc::PacketTransportInterface* /* transport */, 1509 rtc::PacketTransportInternal* /* transport */,
1510 const rtc::SentPacket& sent_packet) { 1510 const rtc::SentPacket& sent_packet) {
1511 RTC_DCHECK(network_thread_->IsCurrent()); 1511 RTC_DCHECK(network_thread_->IsCurrent());
1512 invoker_.AsyncInvoke<void>( 1512 invoker_.AsyncInvoke<void>(
1513 RTC_FROM_HERE, worker_thread_, 1513 RTC_FROM_HERE, worker_thread_,
1514 rtc::Bind(&BaseChannel::SignalSentPacket_w, this, sent_packet)); 1514 rtc::Bind(&BaseChannel::SignalSentPacket_w, this, sent_packet));
1515 } 1515 }
1516 1516
1517 void BaseChannel::SignalSentPacket_w(const rtc::SentPacket& sent_packet) { 1517 void BaseChannel::SignalSentPacket_w(const rtc::SentPacket& sent_packet) {
1518 RTC_DCHECK(worker_thread_->IsCurrent()); 1518 RTC_DCHECK(worker_thread_->IsCurrent());
1519 SignalSentPacket(sent_packet); 1519 SignalSentPacket(sent_packet);
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
1690 } 1690 }
1691 1691
1692 int VoiceChannel::GetOutputLevel_w() { 1692 int VoiceChannel::GetOutputLevel_w() {
1693 return media_channel()->GetOutputLevel(); 1693 return media_channel()->GetOutputLevel();
1694 } 1694 }
1695 1695
1696 void VoiceChannel::GetActiveStreams_w(AudioInfo::StreamList* actives) { 1696 void VoiceChannel::GetActiveStreams_w(AudioInfo::StreamList* actives) {
1697 media_channel()->GetActiveStreams(actives); 1697 media_channel()->GetActiveStreams(actives);
1698 } 1698 }
1699 1699
1700 void VoiceChannel::OnPacketRead(rtc::PacketTransportInterface* transport, 1700 void VoiceChannel::OnPacketRead(rtc::PacketTransportInternal* transport,
1701 const char* data, 1701 const char* data,
1702 size_t len, 1702 size_t len,
1703 const rtc::PacketTime& packet_time, 1703 const rtc::PacketTime& packet_time,
1704 int flags) { 1704 int flags) {
1705 BaseChannel::OnPacketRead(transport, data, len, packet_time, flags); 1705 BaseChannel::OnPacketRead(transport, data, len, packet_time, flags);
1706 // Set a flag when we've received an RTP packet. If we're waiting for early 1706 // Set a flag when we've received an RTP packet. If we're waiting for early
1707 // media, this will disable the timeout. 1707 // media, this will disable the timeout.
1708 if (!received_media_ && !PacketIsRtcp(transport, data, len)) { 1708 if (!received_media_ && !PacketIsRtcp(transport, data, len)) {
1709 received_media_ = true; 1709 received_media_ = true;
1710 } 1710 }
(...skipping 493 matching lines...) Expand 10 before | Expand all | Expand 10 after
2204 StopMediaMonitor(); 2204 StopMediaMonitor();
2205 // this can't be done in the base class, since it calls a virtual 2205 // this can't be done in the base class, since it calls a virtual
2206 DisableMedia_w(); 2206 DisableMedia_w();
2207 2207
2208 Deinit(); 2208 Deinit();
2209 } 2209 }
2210 2210
2211 bool RtpDataChannel::Init_w( 2211 bool RtpDataChannel::Init_w(
2212 DtlsTransportInternal* rtp_dtls_transport, 2212 DtlsTransportInternal* rtp_dtls_transport,
2213 DtlsTransportInternal* rtcp_dtls_transport, 2213 DtlsTransportInternal* rtcp_dtls_transport,
2214 rtc::PacketTransportInterface* rtp_packet_transport, 2214 rtc::PacketTransportInternal* rtp_packet_transport,
2215 rtc::PacketTransportInterface* rtcp_packet_transport) { 2215 rtc::PacketTransportInternal* rtcp_packet_transport) {
2216 if (!BaseChannel::Init_w(rtp_dtls_transport, rtcp_dtls_transport, 2216 if (!BaseChannel::Init_w(rtp_dtls_transport, rtcp_dtls_transport,
2217 rtp_packet_transport, rtcp_packet_transport)) { 2217 rtp_packet_transport, rtcp_packet_transport)) {
2218 return false; 2218 return false;
2219 } 2219 }
2220 media_channel()->SignalDataReceived.connect(this, 2220 media_channel()->SignalDataReceived.connect(this,
2221 &RtpDataChannel::OnDataReceived); 2221 &RtpDataChannel::OnDataReceived);
2222 media_channel()->SignalReadyToSend.connect( 2222 media_channel()->SignalReadyToSend.connect(
2223 this, &RtpDataChannel::OnDataChannelReadyToSend); 2223 this, &RtpDataChannel::OnDataChannelReadyToSend);
2224 return true; 2224 return true;
2225 } 2225 }
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after
2453 signaling_thread()->Post(RTC_FROM_HERE, this, MSG_READYTOSENDDATA, 2453 signaling_thread()->Post(RTC_FROM_HERE, this, MSG_READYTOSENDDATA,
2454 new DataChannelReadyToSendMessageData(writable)); 2454 new DataChannelReadyToSendMessageData(writable));
2455 } 2455 }
2456 2456
2457 void RtpDataChannel::GetSrtpCryptoSuites_n( 2457 void RtpDataChannel::GetSrtpCryptoSuites_n(
2458 std::vector<int>* crypto_suites) const { 2458 std::vector<int>* crypto_suites) const {
2459 GetSupportedDataCryptoSuites(crypto_options(), crypto_suites); 2459 GetSupportedDataCryptoSuites(crypto_options(), crypto_suites);
2460 } 2460 }
2461 2461
2462 } // namespace cricket 2462 } // 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