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

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

Issue 2606123002: Remove the dependency of TransportChannel and TransportChannelImpl. (Closed)
Patch Set: Merge Created 3 years, 11 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
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/common.h" 19 #include "webrtc/base/common.h"
20 #include "webrtc/base/copyonwritebuffer.h" 20 #include "webrtc/base/copyonwritebuffer.h"
21 #include "webrtc/base/dscp.h" 21 #include "webrtc/base/dscp.h"
22 #include "webrtc/base/logging.h" 22 #include "webrtc/base/logging.h"
23 #include "webrtc/base/networkroute.h" 23 #include "webrtc/base/networkroute.h"
24 #include "webrtc/base/trace_event.h" 24 #include "webrtc/base/trace_event.h"
25 #include "webrtc/media/base/mediaconstants.h" 25 #include "webrtc/media/base/mediaconstants.h"
26 #include "webrtc/media/base/rtputils.h" 26 #include "webrtc/media/base/rtputils.h"
27 #include "webrtc/p2p/base/packettransportinterface.h" 27 #include "webrtc/p2p/base/packettransportinterface.h"
28 #include "webrtc/p2p/base/transportchannel.h"
29 #include "webrtc/pc/channelmanager.h" 28 #include "webrtc/pc/channelmanager.h"
30 29
31 namespace cricket { 30 namespace cricket {
32 using rtc::Bind; 31 using rtc::Bind;
33 32
34 namespace { 33 namespace {
35 // See comment below for why we need to use a pointer to a unique_ptr. 34 // See comment below for why we need to use a pointer to a unique_ptr.
36 bool SetRawAudioSink_w(VoiceMediaChannel* channel, 35 bool SetRawAudioSink_w(VoiceMediaChannel* channel,
37 uint32_t ssrc, 36 uint32_t ssrc,
38 std::unique_ptr<webrtc::AudioSinkInterface>* sink) { 37 std::unique_ptr<webrtc::AudioSinkInterface>* sink) {
(...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after
335 // BaseChannel could have resulted in an error), but even so, we'll just 334 // BaseChannel could have resulted in an error), but even so, we'll just
336 // encounter the error again and update "ready to send" accordingly. 335 // encounter the error again and update "ready to send" accordingly.
337 SetTransportChannelReadyToSend( 336 SetTransportChannelReadyToSend(
338 false, transport_channel_ && transport_channel_->writable()); 337 false, transport_channel_ && transport_channel_->writable());
339 SetTransportChannelReadyToSend( 338 SetTransportChannelReadyToSend(
340 true, rtcp_transport_channel_ && rtcp_transport_channel_->writable()); 339 true, rtcp_transport_channel_ && rtcp_transport_channel_->writable());
341 return true; 340 return true;
342 } 341 }
343 342
344 void BaseChannel::SetTransportChannel_n(bool rtcp, 343 void BaseChannel::SetTransportChannel_n(bool rtcp,
345 TransportChannel* new_channel) { 344 DtlsTransportInternal* new_channel) {
346 RTC_DCHECK(network_thread_->IsCurrent()); 345 RTC_DCHECK(network_thread_->IsCurrent());
347 TransportChannel*& old_channel = 346 DtlsTransportInternal*& old_channel =
348 rtcp ? rtcp_transport_channel_ : transport_channel_; 347 rtcp ? rtcp_transport_channel_ : transport_channel_;
349 348
350 if (!old_channel && !new_channel) { 349 if (!old_channel && !new_channel) {
351 // Nothing to do. 350 // Nothing to do.
352 return; 351 return;
353 } 352 }
354 RTC_DCHECK(old_channel != new_channel); 353 RTC_DCHECK(old_channel != new_channel);
355 354
356 if (old_channel) { 355 if (old_channel) {
357 DisconnectFromTransportChannel(old_channel); 356 DisconnectFromTransportChannel(old_channel);
(...skipping 11 matching lines...) Expand all
369 << "should never happen."; 368 << "should never happen.";
370 } 369 }
371 ConnectToTransportChannel(new_channel); 370 ConnectToTransportChannel(new_channel);
372 auto& socket_options = rtcp ? rtcp_socket_options_ : socket_options_; 371 auto& socket_options = rtcp ? rtcp_socket_options_ : socket_options_;
373 for (const auto& pair : socket_options) { 372 for (const auto& pair : socket_options) {
374 new_channel->SetOption(pair.first, pair.second); 373 new_channel->SetOption(pair.first, pair.second);
375 } 374 }
376 } 375 }
377 } 376 }
378 377
379 void BaseChannel::ConnectToTransportChannel(TransportChannel* tc) { 378 void BaseChannel::ConnectToTransportChannel(DtlsTransportInternal* tc) {
380 RTC_DCHECK(network_thread_->IsCurrent()); 379 RTC_DCHECK(network_thread_->IsCurrent());
381 380
382 tc->SignalWritableState.connect(this, &BaseChannel::OnWritableState); 381 tc->SignalWritableState.connect(this, &BaseChannel::OnWritableState);
383 tc->SignalReadPacket.connect(this, &BaseChannel::OnPacketRead); 382 tc->SignalReadPacket.connect(this, &BaseChannel::OnPacketRead);
384 tc->SignalReadyToSend.connect(this, &BaseChannel::OnReadyToSend); 383 tc->SignalReadyToSend.connect(this, &BaseChannel::OnReadyToSend);
385 tc->SignalDtlsState.connect(this, &BaseChannel::OnDtlsState); 384 tc->SignalDtlsState.connect(this, &BaseChannel::OnDtlsState);
386 tc->SignalSelectedCandidatePairChanged.connect( 385 tc->SignalSentPacket.connect(this, &BaseChannel::SignalSentPacket_n);
386 tc->ice_transport()->SignalSelectedCandidatePairChanged.connect(
387 this, &BaseChannel::OnSelectedCandidatePairChanged); 387 this, &BaseChannel::OnSelectedCandidatePairChanged);
388 tc->SignalSentPacket.connect(this, &BaseChannel::SignalSentPacket_n);
389 } 388 }
390 389
391 void BaseChannel::DisconnectFromTransportChannel(TransportChannel* tc) { 390 void BaseChannel::DisconnectFromTransportChannel(DtlsTransportInternal* tc) {
392 RTC_DCHECK(network_thread_->IsCurrent()); 391 RTC_DCHECK(network_thread_->IsCurrent());
393 OnSelectedCandidatePairChanged(tc, nullptr, -1, false); 392 OnSelectedCandidatePairChanged(tc->ice_transport(), nullptr, -1, false);
394 393
395 tc->SignalWritableState.disconnect(this); 394 tc->SignalWritableState.disconnect(this);
396 tc->SignalReadPacket.disconnect(this); 395 tc->SignalReadPacket.disconnect(this);
397 tc->SignalReadyToSend.disconnect(this); 396 tc->SignalReadyToSend.disconnect(this);
398 tc->SignalDtlsState.disconnect(this); 397 tc->SignalDtlsState.disconnect(this);
399 tc->SignalSelectedCandidatePairChanged.disconnect(this);
400 tc->SignalSentPacket.disconnect(this); 398 tc->SignalSentPacket.disconnect(this);
399 tc->ice_transport()->SignalSelectedCandidatePairChanged.disconnect(this);
401 } 400 }
402 401
403 bool BaseChannel::Enable(bool enable) { 402 bool BaseChannel::Enable(bool enable) {
404 worker_thread_->Invoke<void>( 403 worker_thread_->Invoke<void>(
405 RTC_FROM_HERE, 404 RTC_FROM_HERE,
406 Bind(enable ? &BaseChannel::EnableMedia_w : &BaseChannel::DisableMedia_w, 405 Bind(enable ? &BaseChannel::EnableMedia_w : &BaseChannel::DisableMedia_w,
407 this)); 406 this));
408 return true; 407 return true;
409 } 408 }
410 409
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
460 459
461 void BaseChannel::StopConnectionMonitor() { 460 void BaseChannel::StopConnectionMonitor() {
462 if (connection_monitor_) { 461 if (connection_monitor_) {
463 connection_monitor_->Stop(); 462 connection_monitor_->Stop();
464 connection_monitor_.reset(); 463 connection_monitor_.reset();
465 } 464 }
466 } 465 }
467 466
468 bool BaseChannel::GetConnectionStats(ConnectionInfos* infos) { 467 bool BaseChannel::GetConnectionStats(ConnectionInfos* infos) {
469 RTC_DCHECK(network_thread_->IsCurrent()); 468 RTC_DCHECK(network_thread_->IsCurrent());
470 return transport_channel_->GetStats(infos); 469 return transport_channel_->ice_transport()->GetStats(infos);
471 } 470 }
472 471
473 bool BaseChannel::IsReadyToReceiveMedia_w() const { 472 bool BaseChannel::IsReadyToReceiveMedia_w() const {
474 // Receive data if we are enabled and have local content, 473 // Receive data if we are enabled and have local content,
475 return enabled() && IsReceiveContentDirection(local_content_direction_); 474 return enabled() && IsReceiveContentDirection(local_content_direction_);
476 } 475 }
477 476
478 bool BaseChannel::IsReadyToSendMedia_w() const { 477 bool BaseChannel::IsReadyToSendMedia_w() const {
479 // Need to access some state updated on the network thread. 478 // Need to access some state updated on the network thread.
480 return network_thread_->Invoke<bool>( 479 return network_thread_->Invoke<bool>(
(...skipping 22 matching lines...) Expand all
503 int BaseChannel::SetOption(SocketType type, rtc::Socket::Option opt, 502 int BaseChannel::SetOption(SocketType type, rtc::Socket::Option opt,
504 int value) { 503 int value) {
505 return network_thread_->Invoke<int>( 504 return network_thread_->Invoke<int>(
506 RTC_FROM_HERE, Bind(&BaseChannel::SetOption_n, this, type, opt, value)); 505 RTC_FROM_HERE, Bind(&BaseChannel::SetOption_n, this, type, opt, value));
507 } 506 }
508 507
509 int BaseChannel::SetOption_n(SocketType type, 508 int BaseChannel::SetOption_n(SocketType type,
510 rtc::Socket::Option opt, 509 rtc::Socket::Option opt,
511 int value) { 510 int value) {
512 RTC_DCHECK(network_thread_->IsCurrent()); 511 RTC_DCHECK(network_thread_->IsCurrent());
513 TransportChannel* channel = nullptr; 512 DtlsTransportInternal* channel = nullptr;
514 switch (type) { 513 switch (type) {
515 case ST_RTP: 514 case ST_RTP:
516 channel = transport_channel_; 515 channel = transport_channel_;
517 socket_options_.push_back( 516 socket_options_.push_back(
518 std::pair<rtc::Socket::Option, int>(opt, value)); 517 std::pair<rtc::Socket::Option, int>(opt, value));
519 break; 518 break;
520 case ST_RTCP: 519 case ST_RTCP:
521 channel = rtcp_transport_channel_; 520 channel = rtcp_transport_channel_;
522 rtcp_socket_options_.push_back( 521 rtcp_socket_options_.push_back(
523 std::pair<rtc::Socket::Option, int>(opt, value)); 522 std::pair<rtc::Socket::Option, int>(opt, value));
524 break; 523 break;
525 } 524 }
526 return channel ? channel->SetOption(opt, value) : -1; 525 return channel ? channel->ice_transport()->SetOption(opt, value) : -1;
527 } 526 }
528 527
529 bool BaseChannel::SetCryptoOptions(const rtc::CryptoOptions& crypto_options) { 528 bool BaseChannel::SetCryptoOptions(const rtc::CryptoOptions& crypto_options) {
530 crypto_options_ = crypto_options; 529 crypto_options_ = crypto_options;
531 return true; 530 return true;
532 } 531 }
533 532
534 void BaseChannel::OnWritableState(rtc::PacketTransportInterface* transport) { 533 void BaseChannel::OnWritableState(rtc::PacketTransportInterface* transport) {
535 RTC_DCHECK(transport == transport_channel_ || 534 RTC_DCHECK(transport == transport_channel_ ||
536 transport == rtcp_transport_channel_); 535 transport == rtcp_transport_channel_);
537 RTC_DCHECK(network_thread_->IsCurrent()); 536 RTC_DCHECK(network_thread_->IsCurrent());
538 UpdateWritableState_n(); 537 UpdateWritableState_n();
539 } 538 }
540 539
541 void BaseChannel::OnPacketRead(rtc::PacketTransportInterface* transport, 540 void BaseChannel::OnPacketRead(rtc::PacketTransportInterface* transport,
542 const char* data, 541 const char* data,
543 size_t len, 542 size_t len,
544 const rtc::PacketTime& packet_time, 543 const rtc::PacketTime& packet_time,
545 int flags) { 544 int flags) {
546 TRACE_EVENT0("webrtc", "BaseChannel::OnPacketRead"); 545 TRACE_EVENT0("webrtc", "BaseChannel::OnPacketRead");
547 // OnPacketRead gets called from P2PSocket; now pass data to MediaEngine 546 // OnPacketRead gets called from P2PSocket; now pass data to MediaEngine
548 RTC_DCHECK(network_thread_->IsCurrent()); 547 RTC_DCHECK(network_thread_->IsCurrent());
549 548
549 LOG(INFO) << "data: " << (long)data << " len " << len << " from "
550 << transport;
Taylor Brandstetter 2017/01/10 19:43:47 Leftover debug message
Zhi Huang 2017/01/12 20:04:12 Done.
550 // When using RTCP multiplexing we might get RTCP packets on the RTP 551 // When using RTCP multiplexing we might get RTCP packets on the RTP
551 // transport. We feed RTP traffic into the demuxer to determine if it is RTCP. 552 // transport. We feed RTP traffic into the demuxer to determine if it is RTCP.
552 bool rtcp = PacketIsRtcp(transport, data, len); 553 bool rtcp = PacketIsRtcp(transport, data, len);
553 rtc::CopyOnWriteBuffer packet(data, len); 554 rtc::CopyOnWriteBuffer packet(data, len);
554 HandlePacket(rtcp, &packet, packet_time); 555 HandlePacket(rtcp, &packet, packet_time);
555 } 556 }
556 557
557 void BaseChannel::OnReadyToSend(rtc::PacketTransportInterface* transport) { 558 void BaseChannel::OnReadyToSend(rtc::PacketTransportInterface* transport) {
558 RTC_DCHECK(transport == transport_channel_ || 559 RTC_DCHECK(transport == transport_channel_ ||
559 transport == rtcp_transport_channel_); 560 transport == rtcp_transport_channel_);
560 SetTransportChannelReadyToSend(transport == rtcp_transport_channel_, true); 561 SetTransportChannelReadyToSend(transport == rtcp_transport_channel_, true);
561 } 562 }
562 563
563 void BaseChannel::OnDtlsState(TransportChannel* channel, 564 void BaseChannel::OnDtlsState(DtlsTransportInternal* channel,
564 DtlsTransportState state) { 565 DtlsTransportState state) {
565 if (!ShouldSetupDtlsSrtp_n()) { 566 if (!ShouldSetupDtlsSrtp_n()) {
566 return; 567 return;
567 } 568 }
568 569
569 // Reset the srtp filter if it's not the CONNECTED state. For the CONNECTED 570 // Reset the srtp filter if it's not the CONNECTED state. For the CONNECTED
570 // state, setting up DTLS-SRTP context is deferred to ChannelWritable_w to 571 // state, setting up DTLS-SRTP context is deferred to ChannelWritable_w to
571 // cover other scenarios like the whole channel is writable (not just this 572 // cover other scenarios like the whole channel is writable (not just this
572 // TransportChannel) or when TransportChannel is attached after DTLS is 573 // TransportChannel) or when TransportChannel is attached after DTLS is
573 // negotiated. 574 // negotiated.
574 if (state != DTLS_TRANSPORT_CONNECTED) { 575 if (state != DTLS_TRANSPORT_CONNECTED) {
575 srtp_filter_.ResetParams(); 576 srtp_filter_.ResetParams();
576 } 577 }
577 } 578 }
578 579
579 void BaseChannel::OnSelectedCandidatePairChanged( 580 void BaseChannel::OnSelectedCandidatePairChanged(
580 TransportChannel* channel, 581 IceTransportInternal* channel,
581 CandidatePairInterface* selected_candidate_pair, 582 CandidatePairInterface* selected_candidate_pair,
582 int last_sent_packet_id, 583 int last_sent_packet_id,
583 bool ready_to_send) { 584 bool ready_to_send) {
584 RTC_DCHECK(channel == transport_channel_ || 585 RTC_DCHECK(channel == transport_channel_->ice_transport() ||
585 channel == rtcp_transport_channel_); 586 channel == rtcp_transport_channel_->ice_transport());
586 RTC_DCHECK(network_thread_->IsCurrent()); 587 RTC_DCHECK(network_thread_->IsCurrent());
587 selected_candidate_pair_ = selected_candidate_pair; 588 selected_candidate_pair_ = selected_candidate_pair;
588 std::string transport_name = channel->transport_name(); 589 std::string transport_name = channel->transport_name();
589 rtc::NetworkRoute network_route; 590 rtc::NetworkRoute network_route;
590 if (selected_candidate_pair) { 591 if (selected_candidate_pair) {
591 network_route = rtc::NetworkRoute( 592 network_route = rtc::NetworkRoute(
592 ready_to_send, selected_candidate_pair->local_candidate().network_id(), 593 ready_to_send, selected_candidate_pair->local_candidate().network_id(),
593 selected_candidate_pair->remote_candidate().network_id(), 594 selected_candidate_pair->remote_candidate().network_id(),
594 last_sent_packet_id); 595 last_sent_packet_id);
595 596
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
644 data->options = options; 645 data->options = options;
645 network_thread_->Post(RTC_FROM_HERE, this, message_id, data); 646 network_thread_->Post(RTC_FROM_HERE, this, message_id, data);
646 return true; 647 return true;
647 } 648 }
648 TRACE_EVENT0("webrtc", "BaseChannel::SendPacket"); 649 TRACE_EVENT0("webrtc", "BaseChannel::SendPacket");
649 650
650 // Now that we are on the correct thread, ensure we have a place to send this 651 // Now that we are on the correct thread, ensure we have a place to send this
651 // packet before doing anything. (We might get RTCP packets that we don't 652 // packet before doing anything. (We might get RTCP packets that we don't
652 // intend to send.) If we've negotiated RTCP mux, send RTCP over the RTP 653 // intend to send.) If we've negotiated RTCP mux, send RTCP over the RTP
653 // transport. 654 // transport.
654 TransportChannel* channel = (!rtcp || rtcp_mux_filter_.IsActive()) ? 655 DtlsTransportInternal* channel = (!rtcp || rtcp_mux_filter_.IsActive())
655 transport_channel_ : rtcp_transport_channel_; 656 ? transport_channel_
657 : rtcp_transport_channel_;
656 if (!channel || !channel->writable()) { 658 if (!channel || !channel->writable()) {
657 return false; 659 return false;
658 } 660 }
659 661
660 // Protect ourselves against crazy data. 662 // Protect ourselves against crazy data.
661 if (!ValidPacket(rtcp, packet)) { 663 if (!ValidPacket(rtcp, packet)) {
662 LOG(LS_ERROR) << "Dropping outgoing " << content_name_ << " " 664 LOG(LS_ERROR) << "Dropping outgoing " << content_name_ << " "
663 << PacketType(rtcp) 665 << PacketType(rtcp)
664 << " packet: wrong size=" << packet->size(); 666 << " packet: wrong size=" << packet->size();
665 return false; 667 return false;
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
786 signaling_thread()->Post(RTC_FROM_HERE, this, MSG_FIRSTPACKETRECEIVED); 788 signaling_thread()->Post(RTC_FROM_HERE, this, MSG_FIRSTPACKETRECEIVED);
787 } 789 }
788 790
789 // Unprotect the packet, if needed. 791 // Unprotect the packet, if needed.
790 if (srtp_filter_.IsActive()) { 792 if (srtp_filter_.IsActive()) {
791 TRACE_EVENT0("webrtc", "SRTP Decode"); 793 TRACE_EVENT0("webrtc", "SRTP Decode");
792 char* data = packet->data<char>(); 794 char* data = packet->data<char>();
793 int len = static_cast<int>(packet->size()); 795 int len = static_cast<int>(packet->size());
794 bool res; 796 bool res;
795 if (!rtcp) { 797 if (!rtcp) {
798 LOG(INFO) << __FUNCTION__ << " " << (long)data;
Taylor Brandstetter 2017/01/10 19:43:47 Also here
Zhi Huang 2017/01/12 20:04:12 Done.
796 res = srtp_filter_.UnprotectRtp(data, len, &len); 799 res = srtp_filter_.UnprotectRtp(data, len, &len);
797 if (!res) { 800 if (!res) {
798 int seq_num = -1; 801 int seq_num = -1;
799 uint32_t ssrc = 0; 802 uint32_t ssrc = 0;
800 GetRtpSeqNum(data, len, &seq_num); 803 GetRtpSeqNum(data, len, &seq_num);
801 GetRtpSsrc(data, len, &ssrc); 804 GetRtpSsrc(data, len, &ssrc);
802 LOG(LS_ERROR) << "Failed to unprotect " << content_name_ 805 LOG(LS_ERROR) << "Failed to unprotect " << content_name_
803 << " RTP packet: size=" << len 806 << " RTP packet: size=" << len
804 << ", seqnum=" << seq_num << ", SSRC=" << ssrc; 807 << ", seqnum=" << seq_num << ", SSRC=" << ssrc;
805 return; 808 return;
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
935 invoker_.AsyncInvoke<void>( 938 invoker_.AsyncInvoke<void>(
936 RTC_FROM_HERE, signaling_thread(), 939 RTC_FROM_HERE, signaling_thread(),
937 Bind(&BaseChannel::SignalDtlsSrtpSetupFailure_s, this, rtcp)); 940 Bind(&BaseChannel::SignalDtlsSrtpSetupFailure_s, this, rtcp));
938 } 941 }
939 942
940 void BaseChannel::SignalDtlsSrtpSetupFailure_s(bool rtcp) { 943 void BaseChannel::SignalDtlsSrtpSetupFailure_s(bool rtcp) {
941 RTC_DCHECK(signaling_thread() == rtc::Thread::Current()); 944 RTC_DCHECK(signaling_thread() == rtc::Thread::Current());
942 SignalDtlsSrtpSetupFailure(this, rtcp); 945 SignalDtlsSrtpSetupFailure(this, rtcp);
943 } 946 }
944 947
945 bool BaseChannel::SetDtlsSrtpCryptoSuites_n(TransportChannel* tc, bool rtcp) { 948 bool BaseChannel::SetDtlsSrtpCryptoSuites_n(DtlsTransportInternal* tc,
949 bool rtcp) {
946 std::vector<int> crypto_suites; 950 std::vector<int> crypto_suites;
947 // We always use the default SRTP crypto suites for RTCP, but we may use 951 // We always use the default SRTP crypto suites for RTCP, but we may use
948 // different crypto suites for RTP depending on the media type. 952 // different crypto suites for RTP depending on the media type.
949 if (!rtcp) { 953 if (!rtcp) {
950 GetSrtpCryptoSuites_n(&crypto_suites); 954 GetSrtpCryptoSuites_n(&crypto_suites);
951 } else { 955 } else {
952 GetDefaultSrtpCryptoSuites(crypto_options(), &crypto_suites); 956 GetDefaultSrtpCryptoSuites(crypto_options(), &crypto_suites);
953 } 957 }
954 return tc->SetSrtpCryptoSuites(crypto_suites); 958 return tc->SetSrtpCryptoSuites(crypto_suites);
955 } 959 }
956 960
957 bool BaseChannel::ShouldSetupDtlsSrtp_n() const { 961 bool BaseChannel::ShouldSetupDtlsSrtp_n() const {
958 // Since DTLS is applied to all channels, checking RTP should be enough. 962 // Since DTLS is applied to all channels, checking RTP should be enough.
959 return transport_channel_ && transport_channel_->IsDtlsActive(); 963 return transport_channel_ && transport_channel_->IsDtlsActive();
960 } 964 }
961 965
962 // This function returns true if either DTLS-SRTP is not in use 966 // This function returns true if either DTLS-SRTP is not in use
963 // *or* DTLS-SRTP is successfully set up. 967 // *or* DTLS-SRTP is successfully set up.
964 bool BaseChannel::SetupDtlsSrtp_n(bool rtcp_channel) { 968 bool BaseChannel::SetupDtlsSrtp_n(bool rtcp_channel) {
965 RTC_DCHECK(network_thread_->IsCurrent()); 969 RTC_DCHECK(network_thread_->IsCurrent());
966 bool ret = false; 970 bool ret = false;
967 971
968 TransportChannel* channel = 972 DtlsTransportInternal* channel =
969 rtcp_channel ? rtcp_transport_channel_ : transport_channel_; 973 rtcp_channel ? rtcp_transport_channel_ : transport_channel_;
970 974
971 RTC_DCHECK(channel->IsDtlsActive()); 975 RTC_DCHECK(channel->IsDtlsActive());
972 976
973 int selected_crypto_suite; 977 int selected_crypto_suite;
974 978
975 if (!channel->GetSrtpCryptoSuite(&selected_crypto_suite)) { 979 if (!channel->GetSrtpCryptoSuite(&selected_crypto_suite)) {
976 LOG(LS_ERROR) << "No DTLS-SRTP selected crypto suite"; 980 LOG(LS_ERROR) << "No DTLS-SRTP selected crypto suite";
977 return false; 981 return false;
978 } 982 }
(...skipping 1431 matching lines...) Expand 10 before | Expand all | Expand 10 after
2410 signaling_thread()->Post(RTC_FROM_HERE, this, MSG_READYTOSENDDATA, 2414 signaling_thread()->Post(RTC_FROM_HERE, this, MSG_READYTOSENDDATA,
2411 new DataChannelReadyToSendMessageData(writable)); 2415 new DataChannelReadyToSendMessageData(writable));
2412 } 2416 }
2413 2417
2414 void RtpDataChannel::GetSrtpCryptoSuites_n( 2418 void RtpDataChannel::GetSrtpCryptoSuites_n(
2415 std::vector<int>* crypto_suites) const { 2419 std::vector<int>* crypto_suites) const {
2416 GetSupportedDataCryptoSuites(crypto_options(), crypto_suites); 2420 GetSupportedDataCryptoSuites(crypto_options(), crypto_suites);
2417 } 2421 }
2418 2422
2419 } // namespace cricket 2423 } // namespace cricket
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698