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

Side by Side Diff: talk/app/webrtc/webrtcsession.cc

Issue 1397973002: Merging BaseSession code into WebRtcSession. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Removing obsolete unit test. Created 5 years, 2 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 * libjingle 2 * libjingle
3 * Copyright 2012 Google Inc. 3 * Copyright 2012 Google Inc.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met: 6 * modification, are permitted provided that the following conditions are met:
7 * 7 *
8 * 1. Redistributions of source code must retain the above copyright notice, 8 * 1. Redistributions of source code must retain the above copyright notice,
9 * this list of conditions and the following disclaimer. 9 * this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright notice, 10 * 2. Redistributions in binary form must reproduce the above copyright notice,
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 using cricket::ContentInfos; 56 using cricket::ContentInfos;
57 using cricket::MediaContentDescription; 57 using cricket::MediaContentDescription;
58 using cricket::SessionDescription; 58 using cricket::SessionDescription;
59 using cricket::TransportInfo; 59 using cricket::TransportInfo;
60 60
61 using cricket::LOCAL_PORT_TYPE; 61 using cricket::LOCAL_PORT_TYPE;
62 using cricket::STUN_PORT_TYPE; 62 using cricket::STUN_PORT_TYPE;
63 using cricket::RELAY_PORT_TYPE; 63 using cricket::RELAY_PORT_TYPE;
64 using cricket::PRFLX_PORT_TYPE; 64 using cricket::PRFLX_PORT_TYPE;
65 65
66 namespace {
67
68 enum {
69 MSG_STATE = 0,
70 };
71
72 } // namespace
73
66 namespace webrtc { 74 namespace webrtc {
67 75
68 // Error messages 76 // Error messages
69 const char kBundleWithoutRtcpMux[] = "RTCP-MUX must be enabled when BUNDLE " 77 const char kBundleWithoutRtcpMux[] = "RTCP-MUX must be enabled when BUNDLE "
70 "is enabled."; 78 "is enabled.";
71 const char kCreateChannelFailed[] = "Failed to create channels."; 79 const char kCreateChannelFailed[] = "Failed to create channels.";
72 const char kInvalidCandidates[] = "Description contains invalid candidates."; 80 const char kInvalidCandidates[] = "Description contains invalid candidates.";
73 const char kInvalidSdp[] = "Invalid session description."; 81 const char kInvalidSdp[] = "Invalid session description.";
74 const char kMlineMismatch[] = 82 const char kMlineMismatch[] =
75 "Offer and answer descriptions m-lines are not matching. Rejecting answer."; 83 "Offer and answer descriptions m-lines are not matching. Rejecting answer.";
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after
323 } 331 }
324 } 332 }
325 return false; 333 return false;
326 } 334 }
327 335
328 static bool BadSdp(const std::string& source, 336 static bool BadSdp(const std::string& source,
329 const std::string& type, 337 const std::string& type,
330 const std::string& reason, 338 const std::string& reason,
331 std::string* err_desc) { 339 std::string* err_desc) {
332 std::ostringstream desc; 340 std::ostringstream desc;
333 desc << "Failed to set " << source << " " << type << " sdp: " << reason; 341 desc << "Failed to set " << source;
342 if (!type.empty()) {
343 desc << " " << type;
344 }
345 desc << " sdp: " << reason;
334 346
335 if (err_desc) { 347 if (err_desc) {
336 *err_desc = desc.str(); 348 *err_desc = desc.str();
337 } 349 }
338 LOG(LS_ERROR) << desc.str(); 350 LOG(LS_ERROR) << desc.str();
339 return false; 351 return false;
340 } 352 }
341 353
342 static bool BadSdp(cricket::ContentSource source, 354 static bool BadSdp(cricket::ContentSource source,
343 const std::string& type, 355 const std::string& type,
(...skipping 30 matching lines...) Expand all
374 return BadSdp(source, SessionDescriptionInterface::kPrAnswer, 386 return BadSdp(source, SessionDescriptionInterface::kPrAnswer,
375 reason, err_desc); 387 reason, err_desc);
376 } 388 }
377 389
378 static bool BadAnswerSdp(cricket::ContentSource source, 390 static bool BadAnswerSdp(cricket::ContentSource source,
379 const std::string& reason, 391 const std::string& reason,
380 std::string* err_desc) { 392 std::string* err_desc) {
381 return BadSdp(source, SessionDescriptionInterface::kAnswer, reason, err_desc); 393 return BadSdp(source, SessionDescriptionInterface::kAnswer, reason, err_desc);
382 } 394 }
383 395
384 #define GET_STRING_OF_STATE(state) \ 396 #define GET_STRING_OF_STATE(state) \
385 case cricket::BaseSession::state: \ 397 case webrtc::WebRtcSession::state: \
386 result = #state; \ 398 result = #state; \
387 break; 399 break;
388 400
389 static std::string GetStateString(cricket::BaseSession::State state) { 401 static std::string GetStateString(webrtc::WebRtcSession::State state) {
390 std::string result; 402 std::string result;
391 switch (state) { 403 switch (state) {
392 GET_STRING_OF_STATE(STATE_INIT) 404 GET_STRING_OF_STATE(STATE_INIT)
393 GET_STRING_OF_STATE(STATE_SENTINITIATE) 405 GET_STRING_OF_STATE(STATE_SENTINITIATE)
394 GET_STRING_OF_STATE(STATE_RECEIVEDINITIATE) 406 GET_STRING_OF_STATE(STATE_RECEIVEDINITIATE)
395 GET_STRING_OF_STATE(STATE_SENTPRACCEPT) 407 GET_STRING_OF_STATE(STATE_SENTPRACCEPT)
396 GET_STRING_OF_STATE(STATE_SENTACCEPT) 408 GET_STRING_OF_STATE(STATE_SENTACCEPT)
397 GET_STRING_OF_STATE(STATE_RECEIVEDPRACCEPT) 409 GET_STRING_OF_STATE(STATE_RECEIVEDPRACCEPT)
398 GET_STRING_OF_STATE(STATE_RECEIVEDACCEPT) 410 GET_STRING_OF_STATE(STATE_RECEIVEDACCEPT)
399 GET_STRING_OF_STATE(STATE_SENTMODIFY) 411 GET_STRING_OF_STATE(STATE_SENTMODIFY)
400 GET_STRING_OF_STATE(STATE_RECEIVEDMODIFY) 412 GET_STRING_OF_STATE(STATE_RECEIVEDMODIFY)
401 GET_STRING_OF_STATE(STATE_SENTREJECT) 413 GET_STRING_OF_STATE(STATE_SENTREJECT)
402 GET_STRING_OF_STATE(STATE_RECEIVEDREJECT) 414 GET_STRING_OF_STATE(STATE_RECEIVEDREJECT)
403 GET_STRING_OF_STATE(STATE_SENTREDIRECT) 415 GET_STRING_OF_STATE(STATE_SENTREDIRECT)
404 GET_STRING_OF_STATE(STATE_SENTTERMINATE) 416 GET_STRING_OF_STATE(STATE_SENTTERMINATE)
405 GET_STRING_OF_STATE(STATE_RECEIVEDTERMINATE) 417 GET_STRING_OF_STATE(STATE_RECEIVEDTERMINATE)
406 GET_STRING_OF_STATE(STATE_INPROGRESS) 418 GET_STRING_OF_STATE(STATE_INPROGRESS)
407 GET_STRING_OF_STATE(STATE_DEINIT) 419 GET_STRING_OF_STATE(STATE_DEINIT)
408 default: 420 default:
409 ASSERT(false); 421 ASSERT(false);
410 break; 422 break;
411 } 423 }
412 return result; 424 return result;
413 } 425 }
414 426
415 #define GET_STRING_OF_ERROR_CODE(err) \ 427 #define GET_STRING_OF_ERROR_CODE(err) \
416 case cricket::BaseSession::err: \ 428 case webrtc::WebRtcSession::err: \
417 result = #err; \ 429 result = #err; \
418 break; 430 break;
419 431
420 static std::string GetErrorCodeString(cricket::BaseSession::Error err) { 432 static std::string GetErrorCodeString(webrtc::WebRtcSession::Error err) {
421 std::string result; 433 std::string result;
422 switch (err) { 434 switch (err) {
423 GET_STRING_OF_ERROR_CODE(ERROR_NONE) 435 GET_STRING_OF_ERROR_CODE(ERROR_NONE)
424 GET_STRING_OF_ERROR_CODE(ERROR_TIME)
425 GET_STRING_OF_ERROR_CODE(ERROR_RESPONSE)
426 GET_STRING_OF_ERROR_CODE(ERROR_NETWORK)
427 GET_STRING_OF_ERROR_CODE(ERROR_CONTENT) 436 GET_STRING_OF_ERROR_CODE(ERROR_CONTENT)
428 GET_STRING_OF_ERROR_CODE(ERROR_TRANSPORT) 437 GET_STRING_OF_ERROR_CODE(ERROR_TRANSPORT)
429 default: 438 default:
430 ASSERT(false); 439 RTC_DCHECK(false);
431 break; 440 break;
432 } 441 }
433 return result; 442 return result;
434 } 443 }
435 444
436 static std::string MakeErrorString(const std::string& error, 445 static std::string MakeErrorString(const std::string& error,
437 const std::string& desc) { 446 const std::string& desc) {
438 std::ostringstream ret; 447 std::ostringstream ret;
439 ret << error << " " << desc; 448 ret << error << " " << desc;
440 return ret.str(); 449 return ret.str();
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
529 return true; 538 return true;
530 } 539 }
531 } 540 }
532 return false; 541 return false;
533 } 542 }
534 543
535 private: 544 private:
536 bool ice_restart_; 545 bool ice_restart_;
537 }; 546 };
538 547
539 WebRtcSession::WebRtcSession( 548 WebRtcSession::WebRtcSession(cricket::ChannelManager* channel_manager,
540 cricket::ChannelManager* channel_manager, 549 rtc::Thread* signaling_thread,
541 rtc::Thread* signaling_thread, 550 rtc::Thread* worker_thread,
542 rtc::Thread* worker_thread, 551 cricket::PortAllocator* port_allocator,
543 cricket::PortAllocator* port_allocator, 552 MediaStreamSignaling* mediastream_signaling)
544 MediaStreamSignaling* mediastream_signaling) 553 : signaling_thread_(signaling_thread),
545 : cricket::BaseSession(signaling_thread, 554 worker_thread_(worker_thread),
546 worker_thread, 555 port_allocator_(port_allocator),
547 port_allocator,
548 rtc::ToString(rtc::CreateRandomId64() & LLONG_MAX),
549 false),
550 // RFC 3264: The numeric value of the session id and version in the 556 // RFC 3264: The numeric value of the session id and version in the
551 // o line MUST be representable with a "64 bit signed integer". 557 // o line MUST be representable with a "64 bit signed integer".
552 // Due to this constraint session id |sid_| is max limited to LLONG_MAX. 558 // Due to this constraint session id |sid_| is max limited to LLONG_MAX.
559 sid_(rtc::ToString(rtc::CreateRandomId64() & LLONG_MAX)),
560 transport_controller_(new cricket::TransportController(signaling_thread,
561 worker_thread,
562 port_allocator)),
553 channel_manager_(channel_manager), 563 channel_manager_(channel_manager),
554 mediastream_signaling_(mediastream_signaling), 564 mediastream_signaling_(mediastream_signaling),
555 ice_observer_(NULL), 565 ice_observer_(NULL),
556 ice_connection_state_(PeerConnectionInterface::kIceConnectionNew), 566 ice_connection_state_(PeerConnectionInterface::kIceConnectionNew),
557 ice_connection_receiving_(true), 567 ice_connection_receiving_(true),
558 older_version_remote_peer_(false), 568 older_version_remote_peer_(false),
559 dtls_enabled_(false), 569 dtls_enabled_(false),
560 data_channel_type_(cricket::DCT_NONE), 570 data_channel_type_(cricket::DCT_NONE),
561 ice_restart_latch_(new IceRestartAnswerLatch), 571 ice_restart_latch_(new IceRestartAnswerLatch),
562 metrics_observer_(NULL) { 572 metrics_observer_(NULL) {
563 transport_controller()->SignalConnectionState.connect( 573 transport_controller_->SetIceRole(cricket::ICEROLE_CONTROLLED);
574 transport_controller_->SignalConnectionState.connect(
564 this, &WebRtcSession::OnTransportControllerConnectionState); 575 this, &WebRtcSession::OnTransportControllerConnectionState);
565 transport_controller()->SignalReceiving.connect( 576 transport_controller_->SignalReceiving.connect(
566 this, &WebRtcSession::OnTransportControllerReceiving); 577 this, &WebRtcSession::OnTransportControllerReceiving);
567 transport_controller()->SignalGatheringState.connect( 578 transport_controller_->SignalGatheringState.connect(
568 this, &WebRtcSession::OnTransportControllerGatheringState); 579 this, &WebRtcSession::OnTransportControllerGatheringState);
569 transport_controller()->SignalCandidatesGathered.connect( 580 transport_controller_->SignalCandidatesGathered.connect(
570 this, &WebRtcSession::OnTransportControllerCandidatesGathered); 581 this, &WebRtcSession::OnTransportControllerCandidatesGathered);
571 } 582 }
572 583
573 WebRtcSession::~WebRtcSession() { 584 WebRtcSession::~WebRtcSession() {
574 ASSERT(signaling_thread()->IsCurrent()); 585 ASSERT(signaling_thread()->IsCurrent());
575 // Destroy video_channel_ first since it may have a pointer to the 586 // Destroy video_channel_ first since it may have a pointer to the
576 // voice_channel_. 587 // voice_channel_.
577 if (video_channel_) { 588 if (video_channel_) {
578 SignalVideoChannelDestroyed(); 589 SignalVideoChannelDestroyed();
579 channel_manager_->DestroyVideoChannel(video_channel_.release()); 590 channel_manager_->DestroyVideoChannel(video_channel_.release());
580 } 591 }
581 if (voice_channel_) { 592 if (voice_channel_) {
582 SignalVoiceChannelDestroyed(); 593 SignalVoiceChannelDestroyed();
583 channel_manager_->DestroyVoiceChannel(voice_channel_.release()); 594 channel_manager_->DestroyVoiceChannel(voice_channel_.release());
584 } 595 }
585 if (data_channel_) { 596 if (data_channel_) {
586 SignalDataChannelDestroyed(); 597 SignalDataChannelDestroyed();
587 channel_manager_->DestroyDataChannel(data_channel_.release()); 598 channel_manager_->DestroyDataChannel(data_channel_.release());
588 } 599 }
589 for (size_t i = 0; i < saved_candidates_.size(); ++i) { 600 for (size_t i = 0; i < saved_candidates_.size(); ++i) {
590 delete saved_candidates_[i]; 601 delete saved_candidates_[i];
591 } 602 }
603
604 RTC_DCHECK(state_ != STATE_DEINIT);
605 LogState(state_, STATE_DEINIT);
606 state_ = STATE_DEINIT;
607 SignalState(this, state_);
592 } 608 }
593 609
594 bool WebRtcSession::Initialize( 610 bool WebRtcSession::Initialize(
595 const PeerConnectionFactoryInterface::Options& options, 611 const PeerConnectionFactoryInterface::Options& options,
596 const MediaConstraintsInterface* constraints, 612 const MediaConstraintsInterface* constraints,
597 rtc::scoped_ptr<DtlsIdentityStoreInterface> dtls_identity_store, 613 rtc::scoped_ptr<DtlsIdentityStoreInterface> dtls_identity_store,
598 const PeerConnectionInterface::RTCConfiguration& rtc_configuration) { 614 const PeerConnectionInterface::RTCConfiguration& rtc_configuration) {
599 bundle_policy_ = rtc_configuration.bundle_policy; 615 bundle_policy_ = rtc_configuration.bundle_policy;
600 rtcp_mux_policy_ = rtc_configuration.rtcp_mux_policy; 616 rtcp_mux_policy_ = rtc_configuration.rtcp_mux_policy;
601 transport_controller()->SetSslMaxProtocolVersion(options.ssl_max_version); 617 transport_controller_->SetSslMaxProtocolVersion(options.ssl_max_version);
602 618
603 // Obtain a certificate from RTCConfiguration if any were provided (optional). 619 // Obtain a certificate from RTCConfiguration if any were provided (optional).
604 rtc::scoped_refptr<rtc::RTCCertificate> certificate; 620 rtc::scoped_refptr<rtc::RTCCertificate> certificate;
605 if (!rtc_configuration.certificates.empty()) { 621 if (!rtc_configuration.certificates.empty()) {
606 // TODO(hbos,torbjorng): Decide on certificate-selection strategy instead of 622 // TODO(hbos,torbjorng): Decide on certificate-selection strategy instead of
607 // just picking the first one. The decision should be made based on the DTLS 623 // just picking the first one. The decision should be made based on the DTLS
608 // handshake. The DTLS negotiations need to know about all certificates. 624 // handshake. The DTLS negotiations need to know about all certificates.
609 certificate = rtc_configuration.certificates[0]; 625 certificate = rtc_configuration.certificates[0];
610 } 626 }
611 627
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
775 port_allocator()->flags() | 791 port_allocator()->flags() |
776 cricket::PORTALLOCATOR_ENABLE_LOCALHOST_CANDIDATE); 792 cricket::PORTALLOCATOR_ENABLE_LOCALHOST_CANDIDATE);
777 } 793 }
778 794
779 media_controller_.reset(MediaControllerInterface::Create( 795 media_controller_.reset(MediaControllerInterface::Create(
780 worker_thread(), channel_manager_->media_engine()->GetVoE())); 796 worker_thread(), channel_manager_->media_engine()->GetVoE()));
781 797
782 return true; 798 return true;
783 } 799 }
784 800
785 cricket::IceConfig WebRtcSession::ParseIceConfig(
786 const PeerConnectionInterface::RTCConfiguration& config) const {
787 cricket::IceConfig ice_config;
788 ice_config.receiving_timeout_ms = config.ice_connection_receiving_timeout;
789 ice_config.gather_continually = (config.continual_gathering_policy ==
790 PeerConnectionInterface::GATHER_CONTINUALLY);
791 return ice_config;
792 }
793
794 void WebRtcSession::Terminate() { 801 void WebRtcSession::Terminate() {
795 SetState(STATE_RECEIVEDTERMINATE); 802 SetState(STATE_RECEIVEDTERMINATE);
796 RemoveUnusedChannels(NULL); 803 RemoveUnusedChannels(NULL);
797 ASSERT(!voice_channel_); 804 ASSERT(!voice_channel_);
798 ASSERT(!video_channel_); 805 ASSERT(!video_channel_);
799 ASSERT(!data_channel_); 806 ASSERT(!data_channel_);
800 } 807 }
801 808
802 void WebRtcSession::SetSdesPolicy(cricket::SecurePolicy secure_policy) { 809 void WebRtcSession::SetSdesPolicy(cricket::SecurePolicy secure_policy) {
803 webrtc_session_desc_factory_->SetSdesPolicy(secure_policy); 810 webrtc_session_desc_factory_->SetSdesPolicy(secure_policy);
804 } 811 }
805 812
806 cricket::SecurePolicy WebRtcSession::SdesPolicy() const { 813 cricket::SecurePolicy WebRtcSession::SdesPolicy() const {
807 return webrtc_session_desc_factory_->SdesPolicy(); 814 return webrtc_session_desc_factory_->SdesPolicy();
808 } 815 }
809 816
810 bool WebRtcSession::GetSslRole(rtc::SSLRole* role) { 817 bool WebRtcSession::GetSslRole(rtc::SSLRole* role) {
811 if (local_description() == NULL || remote_description() == NULL) { 818 if (!local_desc_ || !remote_desc_) {
812 LOG(LS_INFO) << "Local and Remote descriptions must be applied to get " 819 LOG(LS_INFO) << "Local and Remote descriptions must be applied to get "
813 << "SSL Role of the session."; 820 << "SSL Role of the session.";
814 return false; 821 return false;
815 } 822 }
816 823
817 return transport_controller()->GetSslRole(role); 824 return transport_controller_->GetSslRole(role);
818 } 825 }
819 826
820 void WebRtcSession::CreateOffer( 827 void WebRtcSession::CreateOffer(
821 CreateSessionDescriptionObserver* observer, 828 CreateSessionDescriptionObserver* observer,
822 const PeerConnectionInterface::RTCOfferAnswerOptions& options) { 829 const PeerConnectionInterface::RTCOfferAnswerOptions& options) {
823 webrtc_session_desc_factory_->CreateOffer(observer, options); 830 webrtc_session_desc_factory_->CreateOffer(observer, options);
824 } 831 }
825 832
826 void WebRtcSession::CreateAnswer(CreateSessionDescriptionObserver* observer, 833 void WebRtcSession::CreateAnswer(CreateSessionDescriptionObserver* observer,
827 const MediaConstraintsInterface* constraints) { 834 const MediaConstraintsInterface* constraints) {
828 webrtc_session_desc_factory_->CreateAnswer(observer, constraints); 835 webrtc_session_desc_factory_->CreateAnswer(observer, constraints);
829 } 836 }
830 837
831 bool WebRtcSession::SetLocalDescription(SessionDescriptionInterface* desc, 838 bool WebRtcSession::SetLocalDescription(SessionDescriptionInterface* desc,
832 std::string* err_desc) { 839 std::string* err_desc) {
833 ASSERT(signaling_thread()->IsCurrent()); 840 ASSERT(signaling_thread()->IsCurrent());
834 841
835 // Takes the ownership of |desc| regardless of the result. 842 // Takes the ownership of |desc| regardless of the result.
836 rtc::scoped_ptr<SessionDescriptionInterface> desc_temp(desc); 843 rtc::scoped_ptr<SessionDescriptionInterface> desc_temp(desc);
837 844
838 // Validate SDP. 845 // Validate SDP.
839 if (!ValidateSessionDescription(desc, cricket::CS_LOCAL, err_desc)) { 846 if (!ValidateSessionDescription(desc, cricket::CS_LOCAL, err_desc)) {
840 return false; 847 return false;
841 } 848 }
842 849
843 // Update the initiator flag if this session is the initiator. 850 // Update the initiator flag if this session is the initiator.
844 Action action = GetAction(desc->type()); 851 Action action = GetAction(desc->type());
845 if (state() == STATE_INIT && action == kOffer) { 852 if (state() == STATE_INIT && action == kOffer) {
846 set_initiator(true); 853 initiator_ = true;
854 transport_controller_->SetIceRole(cricket::ICEROLE_CONTROLLING);
847 } 855 }
848 856
849 cricket::SecurePolicy sdes_policy = 857 cricket::SecurePolicy sdes_policy =
850 webrtc_session_desc_factory_->SdesPolicy(); 858 webrtc_session_desc_factory_->SdesPolicy();
851 cricket::CryptoType crypto_required = dtls_enabled_ ? 859 cricket::CryptoType crypto_required = dtls_enabled_ ?
852 cricket::CT_DTLS : (sdes_policy == cricket::SEC_REQUIRED ? 860 cricket::CT_DTLS : (sdes_policy == cricket::SEC_REQUIRED ?
853 cricket::CT_SDES : cricket::CT_NONE); 861 cricket::CT_SDES : cricket::CT_NONE);
854 // Update the MediaContentDescription crypto settings as per the policy set. 862 // Update the MediaContentDescription crypto settings as per the policy set.
855 UpdateSessionDescriptionSecurePolicy(crypto_required, desc->description()); 863 UpdateSessionDescriptionSecurePolicy(crypto_required, desc->description());
856 864
857 set_local_description(desc->description()->Copy());
858 local_desc_.reset(desc_temp.release()); 865 local_desc_.reset(desc_temp.release());
859 866
860 // Transport and Media channels will be created only when offer is set. 867 // Transport and Media channels will be created only when offer is set.
861 if (action == kOffer && !CreateChannels(local_desc_->description())) { 868 if (action == kOffer && !CreateChannels(base_local_description())) {
862 // TODO(mallinath) - Handle CreateChannel failure, as new local description 869 // TODO(mallinath) - Handle CreateChannel failure, as new local description
863 // is applied. Restore back to old description. 870 // is applied. Restore back to old description.
864 return BadLocalSdp(desc->type(), kCreateChannelFailed, err_desc); 871 return BadLocalSdp(desc->type(), kCreateChannelFailed, err_desc);
865 } 872 }
866 873
867 // Remove unused channels if MediaContentDescription is rejected. 874 // Remove unused channels if MediaContentDescription is rejected.
868 RemoveUnusedChannels(local_desc_->description()); 875 RemoveUnusedChannels(base_local_description());
869 876
870 if (!UpdateSessionState(action, cricket::CS_LOCAL, err_desc)) { 877 if (!UpdateSessionState(action, cricket::CS_LOCAL, err_desc)) {
871 return false; 878 return false;
872 } 879 }
873 880
874 if (remote_description()) { 881 if (remote_desc_) {
875 // Now that we have a local description, we can push down remote candidates 882 // Now that we have a local description, we can push down remote candidates
876 // that we stored, and those from the remote description. 883 // that we stored, and those from the remote description.
877 if (!saved_candidates_.empty()) { 884 if (!saved_candidates_.empty()) {
878 // If there are saved candidates which arrived before the local 885 // If there are saved candidates which arrived before the local
879 // description was set, copy those to the remote description. 886 // description was set, copy those to the remote description.
880 CopySavedCandidates(remote_desc_.get()); 887 CopySavedCandidates(remote_desc_.get());
881 } 888 }
882 // Push remote candidates in remote description to transport channels. 889 // Push remote candidates in remote description to transport channels.
883 UseCandidatesInSessionDescription(remote_desc_.get()); 890 UseCandidatesInSessionDescription(remote_desc_.get());
884 } 891 }
885 892
886 // Update state and SSRC of local MediaStreams and DataChannels based on the 893 // Update state and SSRC of local MediaStreams and DataChannels based on the
887 // local session description. 894 // local session description.
888 mediastream_signaling_->OnLocalDescriptionChanged(local_desc_.get()); 895 mediastream_signaling_->OnLocalDescriptionChanged(local_desc_.get());
889 896
890 rtc::SSLRole role; 897 rtc::SSLRole role;
891 if (data_channel_type_ == cricket::DCT_SCTP && GetSslRole(&role)) { 898 if (data_channel_type_ == cricket::DCT_SCTP && GetSslRole(&role)) {
892 mediastream_signaling_->OnDtlsRoleReadyForSctp(role); 899 mediastream_signaling_->OnDtlsRoleReadyForSctp(role);
893 } 900 }
894 if (error() != cricket::BaseSession::ERROR_NONE) { 901 if (error() != ERROR_NONE) {
895 return BadLocalSdp(desc->type(), GetSessionErrorMsg(), err_desc); 902 return BadLocalSdp(desc->type(), GetSessionErrorMsg(), err_desc);
896 } 903 }
897 return true; 904 return true;
898 } 905 }
899 906
900 bool WebRtcSession::SetRemoteDescription(SessionDescriptionInterface* desc, 907 bool WebRtcSession::SetRemoteDescription(SessionDescriptionInterface* desc,
901 std::string* err_desc) { 908 std::string* err_desc) {
902 ASSERT(signaling_thread()->IsCurrent()); 909 ASSERT(signaling_thread()->IsCurrent());
903 910
904 // Takes the ownership of |desc| regardless of the result. 911 // Takes the ownership of |desc| regardless of the result.
905 rtc::scoped_ptr<SessionDescriptionInterface> desc_temp(desc); 912 rtc::scoped_ptr<SessionDescriptionInterface> desc_temp(desc);
906 913
907 // Validate SDP. 914 // Validate SDP.
908 if (!ValidateSessionDescription(desc, cricket::CS_REMOTE, err_desc)) { 915 if (!ValidateSessionDescription(desc, cricket::CS_REMOTE, err_desc)) {
909 return false; 916 return false;
910 } 917 }
911 918
919 rtc::scoped_ptr<SessionDescriptionInterface> old_remote_desc(
920 remote_desc_.release());
921 remote_desc_.reset(desc_temp.release());
922
912 // Transport and Media channels will be created only when offer is set. 923 // Transport and Media channels will be created only when offer is set.
913 Action action = GetAction(desc->type()); 924 Action action = GetAction(desc->type());
914 if (action == kOffer && !CreateChannels(desc->description())) { 925 if (action == kOffer && !CreateChannels(desc->description())) {
915 // TODO(mallinath) - Handle CreateChannel failure, as new local description 926 // TODO(mallinath) - Handle CreateChannel failure, as new local description
916 // is applied. Restore back to old description. 927 // is applied. Restore back to old description.
917 return BadRemoteSdp(desc->type(), kCreateChannelFailed, err_desc); 928 return BadRemoteSdp(desc->type(), kCreateChannelFailed, err_desc);
918 } 929 }
919 930
920 // Remove unused channels if MediaContentDescription is rejected. 931 // Remove unused channels if MediaContentDescription is rejected.
921 RemoveUnusedChannels(desc->description()); 932 RemoveUnusedChannels(desc->description());
922 933
923 // NOTE: Candidates allocation will be initiated only when SetLocalDescription 934 // NOTE: Candidates allocation will be initiated only when SetLocalDescription
924 // is called. 935 // is called.
925 set_remote_description(desc->description()->Copy());
926 if (!UpdateSessionState(action, cricket::CS_REMOTE, err_desc)) { 936 if (!UpdateSessionState(action, cricket::CS_REMOTE, err_desc)) {
927 return false; 937 return false;
928 } 938 }
929 939
930 // Update remote MediaStreams. 940 // Update remote MediaStreams.
931 mediastream_signaling_->OnRemoteDescriptionChanged(desc); 941 mediastream_signaling_->OnRemoteDescriptionChanged(desc);
932 if (local_description() && !UseCandidatesInSessionDescription(desc)) {
933 return BadRemoteSdp(desc->type(), kInvalidCandidates, err_desc);
934 }
935 942
936 // Copy all saved candidates. 943 // Copy all saved candidates.
937 CopySavedCandidates(desc); 944 CopySavedCandidates(desc);
938 945
946 if (local_desc_ && !UseCandidatesInSessionDescription(desc)) {
947 return BadRemoteSdp(desc->type(), kInvalidCandidates, err_desc);
948 }
949
939 // Check if this new SessionDescription contains new ice ufrag and password 950 // Check if this new SessionDescription contains new ice ufrag and password
940 // that indicates the remote peer requests ice restart. 951 // that indicates the remote peer requests ice restart.
941 bool ice_restart = 952 bool ice_restart =
942 ice_restart_latch_->CheckForRemoteIceRestart(remote_desc_.get(), desc); 953 ice_restart_latch_->CheckForRemoteIceRestart(old_remote_desc.get(), desc);
943 // We retain all received candidates only if ICE is not restarted. 954 // We retain all received candidates only if ICE is not restarted.
944 // When ICE is restarted, all previous candidates belong to an old generation 955 // When ICE is restarted, all previous candidates belong to an old generation
945 // and should not be kept. 956 // and should not be kept.
946 if (!ice_restart) { 957 if (!ice_restart) {
947 WebRtcSessionDescriptionFactory::CopyCandidatesFromSessionDescription( 958 WebRtcSessionDescriptionFactory::CopyCandidatesFromSessionDescription(
948 remote_desc_.get(), desc); 959 old_remote_desc.get(), desc);
949 } 960 }
950 961
951 remote_desc_.reset(desc_temp.release());
952
953 rtc::SSLRole role; 962 rtc::SSLRole role;
954 if (data_channel_type_ == cricket::DCT_SCTP && GetSslRole(&role)) { 963 if (data_channel_type_ == cricket::DCT_SCTP && GetSslRole(&role)) {
955 mediastream_signaling_->OnDtlsRoleReadyForSctp(role); 964 mediastream_signaling_->OnDtlsRoleReadyForSctp(role);
956 } 965 }
957 966
958 if (error() != cricket::BaseSession::ERROR_NONE) { 967 if (error() != ERROR_NONE) {
959 return BadRemoteSdp(desc->type(), GetSessionErrorMsg(), err_desc); 968 return BadRemoteSdp(desc->type(), GetSessionErrorMsg(), err_desc);
960 } 969 }
961 970
962 // Set the the ICE connection state to connecting since the connection may 971 // Set the the ICE connection state to connecting since the connection may
963 // become writable with peer reflexive candidates before any remote candidate 972 // become writable with peer reflexive candidates before any remote candidate
964 // is signaled. 973 // is signaled.
965 // TODO(pthatcher): This is a short-term solution for crbug/446908. A real fix 974 // TODO(pthatcher): This is a short-term solution for crbug/446908. A real fix
966 // is to have a new signal the indicates a change in checking state from the 975 // is to have a new signal the indicates a change in checking state from the
967 // transport and expose a new checking() member from transport that can be 976 // transport and expose a new checking() member from transport that can be
968 // read to determine the current checking state. The existing SignalConnecting 977 // read to determine the current checking state. The existing SignalConnecting
969 // actually means "gathering candidates", so cannot be be used here. 978 // actually means "gathering candidates", so cannot be be used here.
970 if (desc->type() != SessionDescriptionInterface::kOffer && 979 if (desc->type() != SessionDescriptionInterface::kOffer &&
971 ice_connection_state_ == PeerConnectionInterface::kIceConnectionNew) { 980 ice_connection_state_ == PeerConnectionInterface::kIceConnectionNew) {
972 SetIceConnectionState(PeerConnectionInterface::kIceConnectionChecking); 981 SetIceConnectionState(PeerConnectionInterface::kIceConnectionChecking);
973 } 982 }
974 return true; 983 return true;
975 } 984 }
976 985
986 void WebRtcSession::OnMessage(rtc::Message* pmsg) {
987 switch (pmsg->message_id) {
988 case MSG_STATE:
989 switch (state_) {
990 case STATE_SENTACCEPT:
991 case STATE_RECEIVEDACCEPT:
992 SetState(STATE_INPROGRESS);
993 break;
994
995 default:
996 // Explicitly ignoring some states here.
997 break;
998 }
999 break;
1000 }
1001 }
1002
1003 void WebRtcSession::LogState(State old_state, State new_state) {
1004 LOG(LS_INFO) << "Session:" << id()
1005 << " Old state:" << GetStateString(old_state)
1006 << " New state:" << GetStateString(new_state);
1007 }
1008
1009 void WebRtcSession::SetState(State state) {
1010 ASSERT(signaling_thread_->IsCurrent());
1011 if (state != state_) {
1012 LogState(state_, state);
1013 state_ = state;
1014 SignalState(this, state_);
1015 signaling_thread_->Post(this, MSG_STATE);
pthatcher1 2015/10/09 03:28:57 The whole point of this is to convert STATE_SENTAC
Taylor Brandstetter 2015/10/09 23:02:06 Done.
1016 }
1017 }
1018
1019 void WebRtcSession::SetError(Error error, const std::string& error_desc) {
1020 ASSERT(signaling_thread_->IsCurrent());
1021 if (error != error_) {
1022 error_ = error;
1023 error_desc_ = error_desc;
1024 SignalError(this, error);
1025 }
1026 }
1027
977 bool WebRtcSession::UpdateSessionState( 1028 bool WebRtcSession::UpdateSessionState(
978 Action action, cricket::ContentSource source, 1029 Action action, cricket::ContentSource source,
979 std::string* err_desc) { 1030 std::string* err_desc) {
980 ASSERT(signaling_thread()->IsCurrent()); 1031 ASSERT(signaling_thread()->IsCurrent());
981 1032
982 // If there's already a pending error then no state transition should happen. 1033 // If there's already a pending error then no state transition should happen.
983 // But all call-sites should be verifying this before calling us! 1034 // But all call-sites should be verifying this before calling us!
984 ASSERT(error() == cricket::BaseSession::ERROR_NONE); 1035 ASSERT(error() == ERROR_NONE);
985 std::string td_err; 1036 std::string td_err;
986 if (action == kOffer) { 1037 if (action == kOffer) {
987 if (!PushdownTransportDescription(source, cricket::CA_OFFER, &td_err)) { 1038 if (!PushdownTransportDescription(source, cricket::CA_OFFER, &td_err)) {
988 return BadOfferSdp(source, MakeTdErrorString(td_err), err_desc); 1039 return BadOfferSdp(source, MakeTdErrorString(td_err), err_desc);
989 } 1040 }
990 SetState(source == cricket::CS_LOCAL ? 1041 SetState(source == cricket::CS_LOCAL ?
991 STATE_SENTINITIATE : STATE_RECEIVEDINITIATE); 1042 STATE_SENTINITIATE : STATE_RECEIVEDINITIATE);
992 if (!PushdownMediaDescription(cricket::CA_OFFER, source, err_desc)) { 1043 if (!PushdownMediaDescription(cricket::CA_OFFER, source, err_desc)) {
993 SetError(BaseSession::ERROR_CONTENT, *err_desc); 1044 SetError(ERROR_CONTENT, *err_desc);
994 } 1045 }
995 if (error() != cricket::BaseSession::ERROR_NONE) { 1046 if (error() != ERROR_NONE) {
996 return BadOfferSdp(source, GetSessionErrorMsg(), err_desc); 1047 return BadOfferSdp(source, GetSessionErrorMsg(), err_desc);
997 } 1048 }
998 } else if (action == kPrAnswer) { 1049 } else if (action == kPrAnswer) {
999 if (!PushdownTransportDescription(source, cricket::CA_PRANSWER, &td_err)) { 1050 if (!PushdownTransportDescription(source, cricket::CA_PRANSWER, &td_err)) {
1000 return BadPranswerSdp(source, MakeTdErrorString(td_err), err_desc); 1051 return BadPranswerSdp(source, MakeTdErrorString(td_err), err_desc);
1001 } 1052 }
1002 EnableChannels(); 1053 EnableChannels();
1003 SetState(source == cricket::CS_LOCAL ? 1054 SetState(source == cricket::CS_LOCAL ?
1004 STATE_SENTPRACCEPT : STATE_RECEIVEDPRACCEPT); 1055 STATE_SENTPRACCEPT : STATE_RECEIVEDPRACCEPT);
1005 if (!PushdownMediaDescription(cricket::CA_PRANSWER, source, err_desc)) { 1056 if (!PushdownMediaDescription(cricket::CA_PRANSWER, source, err_desc)) {
1006 SetError(BaseSession::ERROR_CONTENT, *err_desc); 1057 SetError(ERROR_CONTENT, *err_desc);
1007 } 1058 }
1008 if (error() != cricket::BaseSession::ERROR_NONE) { 1059 if (error() != ERROR_NONE) {
1009 return BadPranswerSdp(source, GetSessionErrorMsg(), err_desc); 1060 return BadPranswerSdp(source, GetSessionErrorMsg(), err_desc);
1010 } 1061 }
1011 } else if (action == kAnswer) { 1062 } else if (action == kAnswer) {
1012 if (!PushdownTransportDescription(source, cricket::CA_ANSWER, &td_err)) { 1063 if (!PushdownTransportDescription(source, cricket::CA_ANSWER, &td_err)) {
1013 return BadAnswerSdp(source, MakeTdErrorString(td_err), err_desc); 1064 return BadAnswerSdp(source, MakeTdErrorString(td_err), err_desc);
1014 } 1065 }
1015 const cricket::ContentGroup* local_bundle = 1066 const cricket::ContentGroup* local_bundle =
1016 BaseSession::local_description()->GetGroupByName( 1067 base_local_description()->GetGroupByName(cricket::GROUP_TYPE_BUNDLE);
1017 cricket::GROUP_TYPE_BUNDLE);
1018 const cricket::ContentGroup* remote_bundle = 1068 const cricket::ContentGroup* remote_bundle =
1019 BaseSession::remote_description()->GetGroupByName( 1069 base_remote_description()->GetGroupByName(cricket::GROUP_TYPE_BUNDLE);
1020 cricket::GROUP_TYPE_BUNDLE);
1021 if (local_bundle && remote_bundle) { 1070 if (local_bundle && remote_bundle) {
1022 // The answerer decides the transport to bundle on 1071 // The answerer decides the transport to bundle on
1023 const cricket::ContentGroup* answer_bundle = 1072 const cricket::ContentGroup* answer_bundle =
1024 (source == cricket::CS_LOCAL ? local_bundle : remote_bundle); 1073 (source == cricket::CS_LOCAL ? local_bundle : remote_bundle);
1025 if (!EnableBundle(*answer_bundle)) { 1074 if (!EnableBundle(*answer_bundle)) {
1026 LOG(LS_WARNING) << "Failed to enable BUNDLE."; 1075 LOG(LS_WARNING) << "Failed to enable BUNDLE.";
1027 return BadAnswerSdp(source, kEnableBundleFailed, err_desc); 1076 return BadAnswerSdp(source, kEnableBundleFailed, err_desc);
1028 } 1077 }
1029 } 1078 }
1030 EnableChannels(); 1079 EnableChannels();
1031 SetState(source == cricket::CS_LOCAL ? 1080 SetState(source == cricket::CS_LOCAL ?
1032 STATE_SENTACCEPT : STATE_RECEIVEDACCEPT); 1081 STATE_SENTACCEPT : STATE_RECEIVEDACCEPT);
1033 if (!PushdownMediaDescription(cricket::CA_ANSWER, source, err_desc)) { 1082 if (!PushdownMediaDescription(cricket::CA_ANSWER, source, err_desc)) {
1034 SetError(BaseSession::ERROR_CONTENT, *err_desc); 1083 SetError(ERROR_CONTENT, *err_desc);
1035 } 1084 }
1036 if (error() != cricket::BaseSession::ERROR_NONE) { 1085 if (error() != ERROR_NONE) {
1037 return BadAnswerSdp(source, GetSessionErrorMsg(), err_desc); 1086 return BadAnswerSdp(source, GetSessionErrorMsg(), err_desc);
1038 } 1087 }
1039 } 1088 }
1040 return true; 1089 return true;
1041 } 1090 }
1042 1091
1092 WebRtcSession::Action WebRtcSession::GetAction(const std::string& type) {
1093 if (type == SessionDescriptionInterface::kOffer) {
1094 return WebRtcSession::kOffer;
1095 } else if (type == SessionDescriptionInterface::kPrAnswer) {
1096 return WebRtcSession::kPrAnswer;
1097 } else if (type == SessionDescriptionInterface::kAnswer) {
1098 return WebRtcSession::kAnswer;
1099 }
1100 ASSERT(false && "unknown action type");
1101 return WebRtcSession::kOffer;
1102 }
1103
1043 bool WebRtcSession::PushdownMediaDescription( 1104 bool WebRtcSession::PushdownMediaDescription(
1044 cricket::ContentAction action, 1105 cricket::ContentAction action,
1045 cricket::ContentSource source, 1106 cricket::ContentSource source,
1046 std::string* err) { 1107 std::string* err) {
1047 auto set_content = [this, action, source, err](cricket::BaseChannel* ch) { 1108 auto set_content = [this, action, source, err](cricket::BaseChannel* ch) {
1048 if (!ch) { 1109 if (!ch) {
1049 return true; 1110 return true;
1050 } else if (source == cricket::CS_LOCAL) { 1111 } else if (source == cricket::CS_LOCAL) {
1051 return ch->PushdownLocalDescription( 1112 return ch->PushdownLocalDescription(
1052 base_local_description(), action, err); 1113 base_local_description(), action, err);
1053 } else { 1114 } else {
1054 return ch->PushdownRemoteDescription( 1115 return ch->PushdownRemoteDescription(
1055 base_remote_description(), action, err); 1116 base_remote_description(), action, err);
1056 } 1117 }
1057 }; 1118 };
1058 1119
1059 return (set_content(voice_channel()) && 1120 return (set_content(voice_channel()) &&
1060 set_content(video_channel()) && 1121 set_content(video_channel()) &&
1061 set_content(data_channel())); 1122 set_content(data_channel()));
1062 } 1123 }
1063 1124
1064 WebRtcSession::Action WebRtcSession::GetAction(const std::string& type) { 1125 bool WebRtcSession::PushdownTransportDescription(cricket::ContentSource source,
1065 if (type == SessionDescriptionInterface::kOffer) { 1126 cricket::ContentAction action,
1066 return WebRtcSession::kOffer; 1127 std::string* error_desc) {
1067 } else if (type == SessionDescriptionInterface::kPrAnswer) { 1128 RTC_DCHECK(signaling_thread()->IsCurrent());
1068 return WebRtcSession::kPrAnswer; 1129
1069 } else if (type == SessionDescriptionInterface::kAnswer) { 1130 if (source == cricket::CS_LOCAL) {
1070 return WebRtcSession::kAnswer; 1131 return PushdownLocalTransportDescription(base_local_description(), action,
1132 error_desc);
1071 } 1133 }
1072 ASSERT(false && "unknown action type"); 1134 return PushdownRemoteTransportDescription(base_remote_description(), action,
1073 return WebRtcSession::kOffer; 1135 error_desc);
1074 } 1136 }
1075 1137
1076 bool WebRtcSession::GetTransportStats(cricket::SessionStats* stats) { 1138 bool WebRtcSession::PushdownLocalTransportDescription(
1139 const SessionDescription* sdesc,
1140 cricket::ContentAction action,
1141 std::string* err) {
1142 RTC_DCHECK(signaling_thread()->IsCurrent());
1143
1144 if (!sdesc) {
1145 return false;
1146 }
1147
1148 for (const TransportInfo& tinfo : sdesc->transport_infos()) {
1149 if (!transport_controller_->SetLocalTransportDescription(
1150 tinfo.content_name, tinfo.description, action, err)) {
1151 return false;
1152 }
1153 }
1154
1155 return true;
1156 }
1157
1158 bool WebRtcSession::PushdownRemoteTransportDescription(
1159 const SessionDescription* sdesc,
1160 cricket::ContentAction action,
1161 std::string* err) {
1162 RTC_DCHECK(signaling_thread()->IsCurrent());
1163
1164 if (!sdesc) {
1165 return false;
1166 }
1167
1168 for (const TransportInfo& tinfo : sdesc->transport_infos()) {
1169 if (!transport_controller_->SetRemoteTransportDescription(
1170 tinfo.content_name, tinfo.description, action, err)) {
1171 return false;
1172 }
1173 }
1174
1175 return true;
1176 }
1177
1178 bool WebRtcSession::GetTransportDescription(
1179 const SessionDescription* description,
1180 const std::string& content_name,
1181 cricket::TransportDescription* tdesc) {
1182 if (!description || !tdesc) {
1183 return false;
1184 }
1185 const TransportInfo* transport_info =
1186 description->GetTransportInfoByName(content_name);
1187 if (!transport_info) {
1188 return false;
1189 }
1190 *tdesc = transport_info->description;
1191 return true;
1192 }
1193
1194 bool WebRtcSession::GetTransportStats(SessionStats* stats) {
1077 ASSERT(signaling_thread()->IsCurrent()); 1195 ASSERT(signaling_thread()->IsCurrent());
1078 return (GetChannelTransportStats(voice_channel(), stats) && 1196 return (GetChannelTransportStats(voice_channel(), stats) &&
1079 GetChannelTransportStats(video_channel(), stats) && 1197 GetChannelTransportStats(video_channel(), stats) &&
1080 GetChannelTransportStats(data_channel(), stats)); 1198 GetChannelTransportStats(data_channel(), stats));
1081 } 1199 }
1082 1200
1083 bool WebRtcSession::GetChannelTransportStats(cricket::BaseChannel* ch, 1201 bool WebRtcSession::GetChannelTransportStats(cricket::BaseChannel* ch,
1084 cricket::SessionStats* stats) { 1202 SessionStats* stats) {
1085 ASSERT(signaling_thread()->IsCurrent()); 1203 ASSERT(signaling_thread()->IsCurrent());
1086 if (!ch) { 1204 if (!ch) {
1087 // Not using this channel. 1205 // Not using this channel.
1088 return true; 1206 return true;
1089 } 1207 }
1090 1208
1091 const std::string& content_name = ch->content_name(); 1209 const std::string& content_name = ch->content_name();
1092 const std::string& transport_name = ch->transport_name(); 1210 const std::string& transport_name = ch->transport_name();
1093 stats->proxy_to_transport[content_name] = transport_name; 1211 stats->proxy_to_transport[content_name] = transport_name;
1094 if (stats->transport_stats.find(transport_name) != 1212 if (stats->transport_stats.find(transport_name) !=
1095 stats->transport_stats.end()) { 1213 stats->transport_stats.end()) {
1096 // Transport stats already done for this transport. 1214 // Transport stats already done for this transport.
1097 return true; 1215 return true;
1098 } 1216 }
1099 1217
1100 cricket::TransportStats tstats; 1218 cricket::TransportStats tstats;
1101 if (!transport_controller()->GetStats(transport_name, &tstats)) { 1219 if (!transport_controller_->GetStats(transport_name, &tstats)) {
1102 return false; 1220 return false;
1103 } 1221 }
1104 1222
1105 stats->transport_stats[transport_name] = tstats; 1223 stats->transport_stats[transport_name] = tstats;
1106 return true; 1224 return true;
1107 } 1225 }
1108 1226
1109 bool WebRtcSession::GetLocalCertificate( 1227 bool WebRtcSession::GetLocalCertificate(
1110 const std::string& transport_name, 1228 const std::string& transport_name,
1111 rtc::scoped_refptr<rtc::RTCCertificate>* certificate) { 1229 rtc::scoped_refptr<rtc::RTCCertificate>* certificate) {
1112 ASSERT(signaling_thread()->IsCurrent()); 1230 ASSERT(signaling_thread()->IsCurrent());
1113 return transport_controller()->GetLocalCertificate(transport_name, 1231 return transport_controller_->GetLocalCertificate(transport_name,
1114 certificate); 1232 certificate);
1115 } 1233 }
1116 1234
1117 bool WebRtcSession::GetRemoteSSLCertificate(const std::string& transport_name, 1235 bool WebRtcSession::GetRemoteSSLCertificate(const std::string& transport_name,
1118 rtc::SSLCertificate** cert) { 1236 rtc::SSLCertificate** cert) {
1119 ASSERT(signaling_thread()->IsCurrent()); 1237 ASSERT(signaling_thread()->IsCurrent());
1120 return transport_controller()->GetRemoteSSLCertificate(transport_name, cert); 1238 return transport_controller_->GetRemoteSSLCertificate(transport_name, cert);
1121 } 1239 }
1122 1240
1123 cricket::BaseChannel* WebRtcSession::GetChannel( 1241 cricket::BaseChannel* WebRtcSession::GetChannel(
1124 const std::string& content_name) { 1242 const std::string& content_name) {
1125 if (voice_channel() && voice_channel()->content_name() == content_name) { 1243 if (voice_channel() && voice_channel()->content_name() == content_name) {
1126 return voice_channel(); 1244 return voice_channel();
1127 } 1245 }
1128 if (video_channel() && video_channel()->content_name() == content_name) { 1246 if (video_channel() && video_channel()->content_name() == content_name) {
1129 return video_channel(); 1247 return video_channel();
1130 } 1248 }
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
1206 1324
1207 return UseCandidate(candidate); 1325 return UseCandidate(candidate);
1208 } 1326 }
1209 1327
1210 bool WebRtcSession::SetIceTransports( 1328 bool WebRtcSession::SetIceTransports(
1211 PeerConnectionInterface::IceTransportsType type) { 1329 PeerConnectionInterface::IceTransportsType type) {
1212 return port_allocator()->set_candidate_filter( 1330 return port_allocator()->set_candidate_filter(
1213 ConvertIceTransportTypeToCandidateFilter(type)); 1331 ConvertIceTransportTypeToCandidateFilter(type));
1214 } 1332 }
1215 1333
1334 cricket::IceConfig WebRtcSession::ParseIceConfig(
1335 const PeerConnectionInterface::RTCConfiguration& config) const {
1336 cricket::IceConfig ice_config;
1337 ice_config.receiving_timeout_ms = config.ice_connection_receiving_timeout;
1338 ice_config.gather_continually = (config.continual_gathering_policy ==
1339 PeerConnectionInterface::GATHER_CONTINUALLY);
1340 return ice_config;
1341 }
1342
1343 void WebRtcSession::SetIceConfig(const cricket::IceConfig& config) {
1344 transport_controller_->SetIceConfig(config);
1345 }
1346
1347 void WebRtcSession::MaybeStartGathering() {
1348 transport_controller_->MaybeStartGathering();
1349 }
1350
1216 bool WebRtcSession::GetLocalTrackIdBySsrc(uint32_t ssrc, 1351 bool WebRtcSession::GetLocalTrackIdBySsrc(uint32_t ssrc,
1217 std::string* track_id) { 1352 std::string* track_id) {
1218 if (!base_local_description()) 1353 if (!local_desc_) {
1219 return false; 1354 return false;
1355 }
1220 return webrtc::GetTrackIdBySsrc(base_local_description(), ssrc, track_id); 1356 return webrtc::GetTrackIdBySsrc(base_local_description(), ssrc, track_id);
1221 } 1357 }
1222 1358
1223 bool WebRtcSession::GetRemoteTrackIdBySsrc(uint32_t ssrc, 1359 bool WebRtcSession::GetRemoteTrackIdBySsrc(uint32_t ssrc,
1224 std::string* track_id) { 1360 std::string* track_id) {
1225 if (!base_remote_description()) 1361 if (!remote_desc_) {
1226 return false; 1362 return false;
1363 }
1227 return webrtc::GetTrackIdBySsrc(base_remote_description(), ssrc, track_id); 1364 return webrtc::GetTrackIdBySsrc(base_remote_description(), ssrc, track_id);
1228 } 1365 }
1229 1366
1230 std::string WebRtcSession::BadStateErrMsg(State state) { 1367 std::string WebRtcSession::BadStateErrMsg(State state) {
1231 std::ostringstream desc; 1368 std::ostringstream desc;
1232 desc << "Called in wrong state: " << GetStateString(state); 1369 desc << "Called in wrong state: " << GetStateString(state);
1233 return desc.str(); 1370 return desc.str();
1234 } 1371 }
1235 1372
1236 void WebRtcSession::SetAudioPlayout(uint32_t ssrc, 1373 void WebRtcSession::SetAudioPlayout(uint32_t ssrc,
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after
1473 bool WebRtcSession::IceRestartPending() const { 1610 bool WebRtcSession::IceRestartPending() const {
1474 return ice_restart_latch_->Get(); 1611 return ice_restart_latch_->Get();
1475 } 1612 }
1476 1613
1477 void WebRtcSession::ResetIceRestartLatch() { 1614 void WebRtcSession::ResetIceRestartLatch() {
1478 ice_restart_latch_->Reset(); 1615 ice_restart_latch_->Reset();
1479 } 1616 }
1480 1617
1481 void WebRtcSession::OnCertificateReady( 1618 void WebRtcSession::OnCertificateReady(
1482 const rtc::scoped_refptr<rtc::RTCCertificate>& certificate) { 1619 const rtc::scoped_refptr<rtc::RTCCertificate>& certificate) {
1483 transport_controller()->SetLocalCertificate(certificate); 1620 transport_controller_->SetLocalCertificate(certificate);
1484 } 1621 }
1485 1622
1486 bool WebRtcSession::waiting_for_certificate_for_testing() const { 1623 bool WebRtcSession::waiting_for_certificate_for_testing() const {
1487 return webrtc_session_desc_factory_->waiting_for_certificate_for_testing(); 1624 return webrtc_session_desc_factory_->waiting_for_certificate_for_testing();
1488 } 1625 }
1489 1626
1490 const rtc::scoped_refptr<rtc::RTCCertificate>& 1627 const rtc::scoped_refptr<rtc::RTCCertificate>&
1491 WebRtcSession::certificate_for_testing() { 1628 WebRtcSession::certificate_for_testing() {
1492 return transport_controller()->certificate_for_testing(); 1629 return transport_controller_->certificate_for_testing();
1493 } 1630 }
1494 1631
1495 void WebRtcSession::SetIceConnectionState( 1632 void WebRtcSession::SetIceConnectionState(
1496 PeerConnectionInterface::IceConnectionState state) { 1633 PeerConnectionInterface::IceConnectionState state) {
1497 if (ice_connection_state_ == state) { 1634 if (ice_connection_state_ == state) {
1498 return; 1635 return;
1499 } 1636 }
1500 1637
1501 // ASSERT that the requested transition is allowed. Note that 1638 // ASSERT that the requested transition is allowed. Note that
1502 // WebRtcSession does not implement "kIceConnectionClosed" (that is handled 1639 // WebRtcSession does not implement "kIceConnectionClosed" (that is handled
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
1635 if (video_channel_ && !video_channel_->enabled()) 1772 if (video_channel_ && !video_channel_->enabled())
1636 video_channel_->Enable(true); 1773 video_channel_->Enable(true);
1637 1774
1638 if (data_channel_ && !data_channel_->enabled()) 1775 if (data_channel_ && !data_channel_->enabled())
1639 data_channel_->Enable(true); 1776 data_channel_->Enable(true);
1640 } 1777 }
1641 1778
1642 // Returns the media index for a local ice candidate given the content name. 1779 // Returns the media index for a local ice candidate given the content name.
1643 bool WebRtcSession::GetLocalCandidateMediaIndex(const std::string& content_name, 1780 bool WebRtcSession::GetLocalCandidateMediaIndex(const std::string& content_name,
1644 int* sdp_mline_index) { 1781 int* sdp_mline_index) {
1645 if (!base_local_description() || !sdp_mline_index) 1782 if (!local_desc_ || !sdp_mline_index) {
1646 return false; 1783 return false;
1784 }
1647 1785
1648 bool content_found = false; 1786 bool content_found = false;
1649 const ContentInfos& contents = base_local_description()->contents(); 1787 const ContentInfos& contents = base_local_description()->contents();
1650 for (size_t index = 0; index < contents.size(); ++index) { 1788 for (size_t index = 0; index < contents.size(); ++index) {
1651 if (contents[index].name == content_name) { 1789 if (contents[index].name == content_name) {
1652 *sdp_mline_index = static_cast<int>(index); 1790 *sdp_mline_index = static_cast<int>(index);
1653 content_found = true; 1791 content_found = true;
1654 break; 1792 break;
1655 } 1793 }
1656 } 1794 }
1657 return content_found; 1795 return content_found;
1658 } 1796 }
1659 1797
1660 bool WebRtcSession::UseCandidatesInSessionDescription( 1798 bool WebRtcSession::UseCandidatesInSessionDescription(
1661 const SessionDescriptionInterface* remote_desc) { 1799 const SessionDescriptionInterface* remote_desc) {
1662 if (!remote_desc) 1800 if (!remote_desc) {
1663 return true; 1801 return true;
1802 }
1664 bool ret = true; 1803 bool ret = true;
1665 1804
1666 for (size_t m = 0; m < remote_desc->number_of_mediasections(); ++m) { 1805 for (size_t m = 0; m < remote_desc->number_of_mediasections(); ++m) {
1667 const IceCandidateCollection* candidates = remote_desc->candidates(m); 1806 const IceCandidateCollection* candidates = remote_desc->candidates(m);
1668 for (size_t n = 0; n < candidates->count(); ++n) { 1807 for (size_t n = 0; n < candidates->count(); ++n) {
1669 const IceCandidateInterface* candidate = candidates->at(n); 1808 const IceCandidateInterface* candidate = candidates->at(n);
1670 bool valid = false; 1809 bool valid = false;
1671 if (!ReadyToUseRemoteCandidate(candidate, remote_desc, &valid)) { 1810 if (!ReadyToUseRemoteCandidate(candidate, remote_desc, &valid)) {
1672 if (valid) { 1811 if (valid) {
1673 LOG(LS_INFO) << "UseCandidatesInSessionDescription: Candidate saved."; 1812 LOG(LS_INFO) << "UseCandidatesInSessionDescription: Candidate saved.";
(...skipping 22 matching lines...) Expand all
1696 << "UseRemoteCandidateInSession: Invalid candidate media index."; 1835 << "UseRemoteCandidateInSession: Invalid candidate media index.";
1697 return false; 1836 return false;
1698 } 1837 }
1699 1838
1700 cricket::ContentInfo content = 1839 cricket::ContentInfo content =
1701 base_remote_description()->contents()[mediacontent_index]; 1840 base_remote_description()->contents()[mediacontent_index];
1702 std::vector<cricket::Candidate> candidates; 1841 std::vector<cricket::Candidate> candidates;
1703 candidates.push_back(candidate->candidate()); 1842 candidates.push_back(candidate->candidate());
1704 // Invoking BaseSession method to handle remote candidates. 1843 // Invoking BaseSession method to handle remote candidates.
1705 std::string error; 1844 std::string error;
1706 if (transport_controller()->AddRemoteCandidates(content.name, candidates, 1845 if (transport_controller_->AddRemoteCandidates(content.name, candidates,
1707 &error)) { 1846 &error)) {
1708 // Candidates successfully submitted for checking. 1847 // Candidates successfully submitted for checking.
1709 if (ice_connection_state_ == PeerConnectionInterface::kIceConnectionNew || 1848 if (ice_connection_state_ == PeerConnectionInterface::kIceConnectionNew ||
1710 ice_connection_state_ == 1849 ice_connection_state_ ==
1711 PeerConnectionInterface::kIceConnectionDisconnected) { 1850 PeerConnectionInterface::kIceConnectionDisconnected) {
1712 // If state is New, then the session has just gotten its first remote ICE 1851 // If state is New, then the session has just gotten its first remote ICE
1713 // candidates, so go to Checking. 1852 // candidates, so go to Checking.
1714 // If state is Disconnected, the session is re-using old candidates or 1853 // If state is Disconnected, the session is re-using old candidates or
1715 // receiving additional ones, so go to Checking. 1854 // receiving additional ones, so go to Checking.
1716 // If state is Connected, stay Connected. 1855 // If state is Connected, stay Connected.
1717 // TODO(bemasc): If state is Connected, and the new candidates are for a 1856 // TODO(bemasc): If state is Connected, and the new candidates are for a
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
1812 LOG(LS_WARNING) << "max-bundle failed to enable bundling."; 1951 LOG(LS_WARNING) << "max-bundle failed to enable bundling.";
1813 return false; 1952 return false;
1814 } 1953 }
1815 } 1954 }
1816 1955
1817 return true; 1956 return true;
1818 } 1957 }
1819 1958
1820 bool WebRtcSession::CreateVoiceChannel(const cricket::ContentInfo* content) { 1959 bool WebRtcSession::CreateVoiceChannel(const cricket::ContentInfo* content) {
1821 voice_channel_.reset(channel_manager_->CreateVoiceChannel( 1960 voice_channel_.reset(channel_manager_->CreateVoiceChannel(
1822 media_controller_.get(), transport_controller(), content->name, true, 1961 media_controller_.get(), transport_controller_.get(), content->name, true,
1823 audio_options_)); 1962 audio_options_));
1824 if (!voice_channel_) { 1963 if (!voice_channel_) {
1825 return false; 1964 return false;
1826 } 1965 }
1827 1966
1828 voice_channel_->SignalDtlsSetupFailure.connect( 1967 voice_channel_->SignalDtlsSetupFailure.connect(
1829 this, &WebRtcSession::OnDtlsSetupFailure); 1968 this, &WebRtcSession::OnDtlsSetupFailure);
1830 return true; 1969 return true;
1831 } 1970 }
1832 1971
1833 bool WebRtcSession::CreateVideoChannel(const cricket::ContentInfo* content) { 1972 bool WebRtcSession::CreateVideoChannel(const cricket::ContentInfo* content) {
1834 video_channel_.reset(channel_manager_->CreateVideoChannel( 1973 video_channel_.reset(channel_manager_->CreateVideoChannel(
1835 media_controller_.get(), transport_controller(), content->name, true, 1974 media_controller_.get(), transport_controller_.get(), content->name, true,
1836 video_options_)); 1975 video_options_));
1837 if (!video_channel_) { 1976 if (!video_channel_) {
1838 return false; 1977 return false;
1839 } 1978 }
1840 1979
1841 video_channel_->SignalDtlsSetupFailure.connect( 1980 video_channel_->SignalDtlsSetupFailure.connect(
1842 this, &WebRtcSession::OnDtlsSetupFailure); 1981 this, &WebRtcSession::OnDtlsSetupFailure);
1843 return true; 1982 return true;
1844 } 1983 }
1845 1984
1846 bool WebRtcSession::CreateDataChannel(const cricket::ContentInfo* content) { 1985 bool WebRtcSession::CreateDataChannel(const cricket::ContentInfo* content) {
1847 bool sctp = (data_channel_type_ == cricket::DCT_SCTP); 1986 bool sctp = (data_channel_type_ == cricket::DCT_SCTP);
1848 data_channel_.reset(channel_manager_->CreateDataChannel( 1987 data_channel_.reset(channel_manager_->CreateDataChannel(
1849 transport_controller(), content->name, !sctp, data_channel_type_)); 1988 transport_controller_.get(), content->name, !sctp, data_channel_type_));
1850 if (!data_channel_) { 1989 if (!data_channel_) {
1851 return false; 1990 return false;
1852 } 1991 }
1853 1992
1854 if (sctp) { 1993 if (sctp) {
1855 mediastream_signaling_->OnDataTransportCreatedForSctp(); 1994 mediastream_signaling_->OnDataTransportCreatedForSctp();
1856 data_channel_->SignalDataReceived.connect( 1995 data_channel_->SignalDataReceived.connect(
1857 this, &WebRtcSession::OnDataChannelMessageReceived); 1996 this, &WebRtcSession::OnDataChannelMessageReceived);
1858 data_channel_->SignalStreamClosedRemotely.connect( 1997 data_channel_->SignalStreamClosedRemotely.connect(
1859 mediastream_signaling_, 1998 mediastream_signaling_,
1860 &MediaStreamSignaling::OnRemoteSctpDataChannelClosed); 1999 &MediaStreamSignaling::OnRemoteSctpDataChannelClosed);
1861 } 2000 }
1862 2001
1863 data_channel_->SignalDtlsSetupFailure.connect( 2002 data_channel_->SignalDtlsSetupFailure.connect(
1864 this, &WebRtcSession::OnDtlsSetupFailure); 2003 this, &WebRtcSession::OnDtlsSetupFailure);
1865 return true; 2004 return true;
1866 } 2005 }
1867 2006
1868 void WebRtcSession::OnDtlsSetupFailure(cricket::BaseChannel*, bool rtcp) { 2007 void WebRtcSession::OnDtlsSetupFailure(cricket::BaseChannel*, bool rtcp) {
1869 SetError(BaseSession::ERROR_TRANSPORT, rtcp ? kDtlsSetupFailureRtcp : 2008 SetError(ERROR_TRANSPORT,
1870 kDtlsSetupFailureRtp); 2009 rtcp ? kDtlsSetupFailureRtcp : kDtlsSetupFailureRtp);
1871 } 2010 }
1872 2011
1873 void WebRtcSession::CopySavedCandidates( 2012 void WebRtcSession::CopySavedCandidates(
1874 SessionDescriptionInterface* dest_desc) { 2013 SessionDescriptionInterface* dest_desc) {
1875 if (!dest_desc) { 2014 if (!dest_desc) {
1876 ASSERT(false); 2015 ASSERT(false);
1877 return; 2016 return;
1878 } 2017 }
1879 for (size_t i = 0; i < saved_candidates_.size(); ++i) { 2018 for (size_t i = 0; i < saved_candidates_.size(); ++i) {
1880 dest_desc->AddCandidate(saved_candidates_[i]); 2019 dest_desc->AddCandidate(saved_candidates_[i]);
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
1925 const cricket::ContentInfo* content) { 2064 const cricket::ContentInfo* content) {
1926 const cricket::MediaContentDescription* description = 2065 const cricket::MediaContentDescription* description =
1927 static_cast<cricket::MediaContentDescription*>(content->description); 2066 static_cast<cricket::MediaContentDescription*>(content->description);
1928 return description->rtcp_mux(); 2067 return description->rtcp_mux();
1929 } 2068 }
1930 2069
1931 bool WebRtcSession::ValidateSessionDescription( 2070 bool WebRtcSession::ValidateSessionDescription(
1932 const SessionDescriptionInterface* sdesc, 2071 const SessionDescriptionInterface* sdesc,
1933 cricket::ContentSource source, std::string* err_desc) { 2072 cricket::ContentSource source, std::string* err_desc) {
1934 std::string type; 2073 std::string type;
1935 if (error() != cricket::BaseSession::ERROR_NONE) { 2074 if (error() != ERROR_NONE) {
1936 return BadSdp(source, type, GetSessionErrorMsg(), err_desc); 2075 return BadSdp(source, type, GetSessionErrorMsg(), err_desc);
1937 } 2076 }
1938 2077
1939 if (!sdesc || !sdesc->description()) { 2078 if (!sdesc || !sdesc->description()) {
1940 return BadSdp(source, type, kInvalidSdp, err_desc); 2079 return BadSdp(source, type, kInvalidSdp, err_desc);
1941 } 2080 }
1942 2081
1943 type = sdesc->type(); 2082 type = sdesc->type();
1944 Action action = GetAction(sdesc->type()); 2083 Action action = GetAction(sdesc->type());
1945 if (source == cricket::CS_LOCAL) { 2084 if (source == cricket::CS_LOCAL) {
(...skipping 17 matching lines...) Expand all
1963 return BadSdp(source, type, kSdpWithoutIceUfragPwd, err_desc); 2102 return BadSdp(source, type, kSdpWithoutIceUfragPwd, err_desc);
1964 } 2103 }
1965 2104
1966 if (!ValidateBundleSettings(sdesc->description())) { 2105 if (!ValidateBundleSettings(sdesc->description())) {
1967 return BadSdp(source, type, kBundleWithoutRtcpMux, err_desc); 2106 return BadSdp(source, type, kBundleWithoutRtcpMux, err_desc);
1968 } 2107 }
1969 2108
1970 // Verify m-lines in Answer when compared against Offer. 2109 // Verify m-lines in Answer when compared against Offer.
1971 if (action == kAnswer) { 2110 if (action == kAnswer) {
1972 const cricket::SessionDescription* offer_desc = 2111 const cricket::SessionDescription* offer_desc =
1973 (source == cricket::CS_LOCAL) ? remote_description()->description() : 2112 (source == cricket::CS_LOCAL) ? base_remote_description()
1974 local_description()->description(); 2113 : base_local_description();
1975 if (!VerifyMediaDescriptions(sdesc->description(), offer_desc)) { 2114 if (!VerifyMediaDescriptions(sdesc->description(), offer_desc)) {
1976 return BadAnswerSdp(source, kMlineMismatch, err_desc); 2115 return BadAnswerSdp(source, kMlineMismatch, err_desc);
1977 } 2116 }
1978 } 2117 }
1979 2118
1980 return true; 2119 return true;
1981 } 2120 }
1982 2121
1983 bool WebRtcSession::ExpectSetLocalDescription(Action action) { 2122 bool WebRtcSession::ExpectSetLocalDescription(Action action) {
1984 return ((action == kOffer && state() == STATE_INIT) || 2123 return ((action == kOffer && state() == STATE_INIT) ||
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
2022 // them unset while the session has them set from the previous negotiation. 2161 // them unset while the session has them set from the previous negotiation.
2023 // Not doing so may trigger the auto generation of transport description and 2162 // Not doing so may trigger the auto generation of transport description and
2024 // mess up DTLS identity information, ICE credential, etc. 2163 // mess up DTLS identity information, ICE credential, etc.
2025 bool WebRtcSession::ReadyToUseRemoteCandidate( 2164 bool WebRtcSession::ReadyToUseRemoteCandidate(
2026 const IceCandidateInterface* candidate, 2165 const IceCandidateInterface* candidate,
2027 const SessionDescriptionInterface* remote_desc, 2166 const SessionDescriptionInterface* remote_desc,
2028 bool* valid) { 2167 bool* valid) {
2029 *valid = true;; 2168 *valid = true;;
2030 2169
2031 const SessionDescriptionInterface* current_remote_desc = 2170 const SessionDescriptionInterface* current_remote_desc =
2032 remote_desc ? remote_desc : remote_description(); 2171 remote_desc ? remote_desc : remote_desc_.get();
2033 2172
2034 if (!current_remote_desc) 2173 if (!current_remote_desc) {
2035 return false; 2174 return false;
2175 }
2036 2176
2037 size_t mediacontent_index = 2177 size_t mediacontent_index =
2038 static_cast<size_t>(candidate->sdp_mline_index()); 2178 static_cast<size_t>(candidate->sdp_mline_index());
2039 size_t remote_content_size = 2179 size_t remote_content_size =
2040 current_remote_desc->description()->contents().size(); 2180 current_remote_desc->description()->contents().size();
2041 if (mediacontent_index >= remote_content_size) { 2181 if (mediacontent_index >= remote_content_size) {
2042 LOG(LS_ERROR) 2182 LOG(LS_ERROR)
2043 << "ReadyToUseRemoteCandidate: Invalid candidate media index."; 2183 << "ReadyToUseRemoteCandidate: Invalid candidate media index.";
2044 2184
2045 *valid = false; 2185 *valid = false;
2046 return false; 2186 return false;
2047 } 2187 }
2048 2188
2049 cricket::ContentInfo content = 2189 cricket::ContentInfo content =
2050 current_remote_desc->description()->contents()[mediacontent_index]; 2190 current_remote_desc->description()->contents()[mediacontent_index];
2051 cricket::BaseChannel* channel = GetChannel(content.name); 2191 cricket::BaseChannel* channel = GetChannel(content.name);
2052 if (!channel) { 2192 if (!channel) {
2053 return false; 2193 return false;
2054 } 2194 }
2055 2195
2056 return transport_controller()->ReadyForRemoteCandidates( 2196 return transport_controller_->ReadyForRemoteCandidates(
2057 channel->transport_name()); 2197 channel->transport_name());
2058 } 2198 }
2059 2199
2060 void WebRtcSession::OnTransportControllerGatheringState( 2200 void WebRtcSession::OnTransportControllerGatheringState(
2061 cricket::IceGatheringState state) { 2201 cricket::IceGatheringState state) {
2062 ASSERT(signaling_thread()->IsCurrent()); 2202 ASSERT(signaling_thread()->IsCurrent());
2063 if (state == cricket::kIceGatheringGathering) { 2203 if (state == cricket::kIceGatheringGathering) {
2064 if (ice_observer_) { 2204 if (ice_observer_) {
2065 ice_observer_->OnIceGatheringChange( 2205 ice_observer_->OnIceGatheringChange(
2066 PeerConnectionInterface::kIceGatheringGathering); 2206 PeerConnectionInterface::kIceGatheringGathering);
(...skipping 15 matching lines...) Expand all
2082 transport_names.insert(voice_channel()->transport_name()); 2222 transport_names.insert(voice_channel()->transport_name());
2083 } 2223 }
2084 if (video_channel()) { 2224 if (video_channel()) {
2085 transport_names.insert(video_channel()->transport_name()); 2225 transport_names.insert(video_channel()->transport_name());
2086 } 2226 }
2087 if (data_channel()) { 2227 if (data_channel()) {
2088 transport_names.insert(data_channel()->transport_name()); 2228 transport_names.insert(data_channel()->transport_name());
2089 } 2229 }
2090 for (const auto& name : transport_names) { 2230 for (const auto& name : transport_names) {
2091 cricket::TransportStats stats; 2231 cricket::TransportStats stats;
2092 if (transport_controller()->GetStats(name, &stats)) { 2232 if (transport_controller_->GetStats(name, &stats)) {
2093 ReportBestConnectionState(stats); 2233 ReportBestConnectionState(stats);
2094 ReportNegotiatedCiphers(stats); 2234 ReportNegotiatedCiphers(stats);
2095 } 2235 }
2096 } 2236 }
2097 } 2237 }
2098 // Walk through the ConnectionInfos to gather best connection usage 2238 // Walk through the ConnectionInfos to gather best connection usage
2099 // for IPv4 and IPv6. 2239 // for IPv4 and IPv6.
2100 void WebRtcSession::ReportBestConnectionState( 2240 void WebRtcSession::ReportBestConnectionState(
2101 const cricket::TransportStats& stats) { 2241 const cricket::TransportStats& stats) {
2102 RTC_DCHECK(metrics_observer_ != NULL); 2242 RTC_DCHECK(metrics_observer_ != NULL);
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
2179 if (!srtp_cipher.empty()) { 2319 if (!srtp_cipher.empty()) {
2180 metrics_observer_->IncrementSparseEnumCounter( 2320 metrics_observer_->IncrementSparseEnumCounter(
2181 srtp_counter_type, rtc::GetSrtpCryptoSuiteFromName(srtp_cipher)); 2321 srtp_counter_type, rtc::GetSrtpCryptoSuiteFromName(srtp_cipher));
2182 } 2322 }
2183 if (ssl_cipher) { 2323 if (ssl_cipher) {
2184 metrics_observer_->IncrementSparseEnumCounter(ssl_counter_type, ssl_cipher); 2324 metrics_observer_->IncrementSparseEnumCounter(ssl_counter_type, ssl_cipher);
2185 } 2325 }
2186 } 2326 }
2187 2327
2188 } // namespace webrtc 2328 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698