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

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

Issue 2685783014: Replace NULL with nullptr in all C++ files. (Closed)
Patch Set: Fixing android. Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright 2012 The WebRTC project authors. All Rights Reserved. 2 * Copyright 2012 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
(...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after
339 protected: 339 protected:
340 ~WebRtcSessionCreateSDPObserverForTest() {} 340 ~WebRtcSessionCreateSDPObserverForTest() {}
341 341
342 private: 342 private:
343 std::unique_ptr<SessionDescriptionInterface> description_; 343 std::unique_ptr<SessionDescriptionInterface> description_;
344 State state_; 344 State state_;
345 }; 345 };
346 346
347 class FakeAudioSource : public cricket::AudioSource { 347 class FakeAudioSource : public cricket::AudioSource {
348 public: 348 public:
349 FakeAudioSource() : sink_(NULL) {} 349 FakeAudioSource() : sink_(nullptr) {}
350 virtual ~FakeAudioSource() { 350 virtual ~FakeAudioSource() {
351 if (sink_) 351 if (sink_)
352 sink_->OnClose(); 352 sink_->OnClose();
353 } 353 }
354 354
355 void SetSink(Sink* sink) override { sink_ = sink; } 355 void SetSink(Sink* sink) override { sink_ = sink; }
356 356
357 const cricket::AudioSource::Sink* sink() const { return sink_; } 357 const cricket::AudioSource::Sink* sink() const { return sink_; }
358 358
359 private: 359 private:
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
412 network_manager_.RemoveInterface(addr); 412 network_manager_.RemoveInterface(addr);
413 } 413 }
414 414
415 // If |cert_generator| != null or |rtc_configuration| contains |certificates| 415 // If |cert_generator| != null or |rtc_configuration| contains |certificates|
416 // then DTLS will be enabled unless explicitly disabled by |rtc_configuration| 416 // then DTLS will be enabled unless explicitly disabled by |rtc_configuration|
417 // options. When DTLS is enabled a certificate will be used if provided, 417 // options. When DTLS is enabled a certificate will be used if provided,
418 // otherwise one will be generated using the |cert_generator|. 418 // otherwise one will be generated using the |cert_generator|.
419 void Init( 419 void Init(
420 std::unique_ptr<rtc::RTCCertificateGeneratorInterface> cert_generator, 420 std::unique_ptr<rtc::RTCCertificateGeneratorInterface> cert_generator,
421 PeerConnectionInterface::RtcpMuxPolicy rtcp_mux_policy) { 421 PeerConnectionInterface::RtcpMuxPolicy rtcp_mux_policy) {
422 ASSERT_TRUE(session_.get() == NULL); 422 ASSERT_TRUE(session_.get() == nullptr);
423 fake_sctp_transport_factory_ = new FakeSctpTransportFactory(); 423 fake_sctp_transport_factory_ = new FakeSctpTransportFactory();
424 session_.reset(new WebRtcSessionForTest( 424 session_.reset(new WebRtcSessionForTest(
425 media_controller_.get(), rtc::Thread::Current(), rtc::Thread::Current(), 425 media_controller_.get(), rtc::Thread::Current(), rtc::Thread::Current(),
426 rtc::Thread::Current(), allocator_.get(), &observer_, 426 rtc::Thread::Current(), allocator_.get(), &observer_,
427 std::unique_ptr<cricket::TransportController>( 427 std::unique_ptr<cricket::TransportController>(
428 new cricket::TransportController(rtc::Thread::Current(), 428 new cricket::TransportController(rtc::Thread::Current(),
429 rtc::Thread::Current(), 429 rtc::Thread::Current(),
430 allocator_.get())), 430 allocator_.get())),
431 std::unique_ptr<FakeSctpTransportFactory>( 431 std::unique_ptr<FakeSctpTransportFactory>(
432 fake_sctp_transport_factory_))); 432 fake_sctp_transport_factory_)));
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after
670 } 670 }
671 671
672 SessionDescriptionInterface* CreateAnswer() { 672 SessionDescriptionInterface* CreateAnswer() {
673 cricket::MediaSessionOptions options; 673 cricket::MediaSessionOptions options;
674 options.recv_video = true; 674 options.recv_video = true;
675 options.recv_audio = true; 675 options.recv_audio = true;
676 return CreateAnswer(options); 676 return CreateAnswer(options);
677 } 677 }
678 678
679 bool ChannelsExist() const { 679 bool ChannelsExist() const {
680 return (session_->voice_channel() != NULL && 680 return (session_->voice_channel() != nullptr &&
681 session_->video_channel() != NULL); 681 session_->video_channel() != nullptr);
682 } 682 }
683 683
684 void VerifyCryptoParams(const cricket::SessionDescription* sdp, 684 void VerifyCryptoParams(const cricket::SessionDescription* sdp,
685 bool gcm_enabled = false) { 685 bool gcm_enabled = false) {
686 ASSERT_TRUE(session_.get() != NULL); 686 ASSERT_TRUE(session_.get() != nullptr);
687 const cricket::ContentInfo* content = cricket::GetFirstAudioContent(sdp); 687 const cricket::ContentInfo* content = cricket::GetFirstAudioContent(sdp);
688 ASSERT_TRUE(content != NULL); 688 ASSERT_TRUE(content != nullptr);
689 const cricket::AudioContentDescription* audio_content = 689 const cricket::AudioContentDescription* audio_content =
690 static_cast<const cricket::AudioContentDescription*>( 690 static_cast<const cricket::AudioContentDescription*>(
691 content->description); 691 content->description);
692 ASSERT_TRUE(audio_content != NULL); 692 ASSERT_TRUE(audio_content != nullptr);
693 if (!gcm_enabled) { 693 if (!gcm_enabled) {
694 ASSERT_EQ(1U, audio_content->cryptos().size()); 694 ASSERT_EQ(1U, audio_content->cryptos().size());
695 ASSERT_EQ(47U, audio_content->cryptos()[0].key_params.size()); 695 ASSERT_EQ(47U, audio_content->cryptos()[0].key_params.size());
696 ASSERT_EQ("AES_CM_128_HMAC_SHA1_80", 696 ASSERT_EQ("AES_CM_128_HMAC_SHA1_80",
697 audio_content->cryptos()[0].cipher_suite); 697 audio_content->cryptos()[0].cipher_suite);
698 EXPECT_EQ(std::string(cricket::kMediaProtocolSavpf), 698 EXPECT_EQ(std::string(cricket::kMediaProtocolSavpf),
699 audio_content->protocol()); 699 audio_content->protocol());
700 } else { 700 } else {
701 // The offer contains 3 possible crypto suites, the answer 1. 701 // The offer contains 3 possible crypto suites, the answer 1.
702 EXPECT_LE(1U, audio_content->cryptos().size()); 702 EXPECT_LE(1U, audio_content->cryptos().size());
703 EXPECT_NE(2U, audio_content->cryptos().size()); 703 EXPECT_NE(2U, audio_content->cryptos().size());
704 EXPECT_GE(3U, audio_content->cryptos().size()); 704 EXPECT_GE(3U, audio_content->cryptos().size());
705 ASSERT_EQ(67U, audio_content->cryptos()[0].key_params.size()); 705 ASSERT_EQ(67U, audio_content->cryptos()[0].key_params.size());
706 ASSERT_EQ("AEAD_AES_256_GCM", 706 ASSERT_EQ("AEAD_AES_256_GCM",
707 audio_content->cryptos()[0].cipher_suite); 707 audio_content->cryptos()[0].cipher_suite);
708 EXPECT_EQ(std::string(cricket::kMediaProtocolSavpf), 708 EXPECT_EQ(std::string(cricket::kMediaProtocolSavpf),
709 audio_content->protocol()); 709 audio_content->protocol());
710 } 710 }
711 711
712 content = cricket::GetFirstVideoContent(sdp); 712 content = cricket::GetFirstVideoContent(sdp);
713 ASSERT_TRUE(content != NULL); 713 ASSERT_TRUE(content != nullptr);
714 const cricket::VideoContentDescription* video_content = 714 const cricket::VideoContentDescription* video_content =
715 static_cast<const cricket::VideoContentDescription*>( 715 static_cast<const cricket::VideoContentDescription*>(
716 content->description); 716 content->description);
717 ASSERT_TRUE(video_content != NULL); 717 ASSERT_TRUE(video_content != nullptr);
718 if (!gcm_enabled) { 718 if (!gcm_enabled) {
719 ASSERT_EQ(1U, video_content->cryptos().size()); 719 ASSERT_EQ(1U, video_content->cryptos().size());
720 ASSERT_EQ("AES_CM_128_HMAC_SHA1_80", 720 ASSERT_EQ("AES_CM_128_HMAC_SHA1_80",
721 video_content->cryptos()[0].cipher_suite); 721 video_content->cryptos()[0].cipher_suite);
722 ASSERT_EQ(47U, video_content->cryptos()[0].key_params.size()); 722 ASSERT_EQ(47U, video_content->cryptos()[0].key_params.size());
723 EXPECT_EQ(std::string(cricket::kMediaProtocolSavpf), 723 EXPECT_EQ(std::string(cricket::kMediaProtocolSavpf),
724 video_content->protocol()); 724 video_content->protocol());
725 } else { 725 } else {
726 // The offer contains 3 possible crypto suites, the answer 1. 726 // The offer contains 3 possible crypto suites, the answer 1.
727 EXPECT_LE(1U, video_content->cryptos().size()); 727 EXPECT_LE(1U, video_content->cryptos().size());
728 EXPECT_NE(2U, video_content->cryptos().size()); 728 EXPECT_NE(2U, video_content->cryptos().size());
729 EXPECT_GE(3U, video_content->cryptos().size()); 729 EXPECT_GE(3U, video_content->cryptos().size());
730 ASSERT_EQ("AEAD_AES_256_GCM", 730 ASSERT_EQ("AEAD_AES_256_GCM",
731 video_content->cryptos()[0].cipher_suite); 731 video_content->cryptos()[0].cipher_suite);
732 ASSERT_EQ(67U, video_content->cryptos()[0].key_params.size()); 732 ASSERT_EQ(67U, video_content->cryptos()[0].key_params.size());
733 EXPECT_EQ(std::string(cricket::kMediaProtocolSavpf), 733 EXPECT_EQ(std::string(cricket::kMediaProtocolSavpf),
734 video_content->protocol()); 734 video_content->protocol());
735 } 735 }
736 } 736 }
737 737
738 void VerifyNoCryptoParams(const cricket::SessionDescription* sdp, bool dtls) { 738 void VerifyNoCryptoParams(const cricket::SessionDescription* sdp, bool dtls) {
739 const cricket::ContentInfo* content = cricket::GetFirstAudioContent(sdp); 739 const cricket::ContentInfo* content = cricket::GetFirstAudioContent(sdp);
740 ASSERT_TRUE(content != NULL); 740 ASSERT_TRUE(content != nullptr);
741 const cricket::AudioContentDescription* audio_content = 741 const cricket::AudioContentDescription* audio_content =
742 static_cast<const cricket::AudioContentDescription*>( 742 static_cast<const cricket::AudioContentDescription*>(
743 content->description); 743 content->description);
744 ASSERT_TRUE(audio_content != NULL); 744 ASSERT_TRUE(audio_content != nullptr);
745 ASSERT_EQ(0U, audio_content->cryptos().size()); 745 ASSERT_EQ(0U, audio_content->cryptos().size());
746 746
747 content = cricket::GetFirstVideoContent(sdp); 747 content = cricket::GetFirstVideoContent(sdp);
748 ASSERT_TRUE(content != NULL); 748 ASSERT_TRUE(content != nullptr);
749 const cricket::VideoContentDescription* video_content = 749 const cricket::VideoContentDescription* video_content =
750 static_cast<const cricket::VideoContentDescription*>( 750 static_cast<const cricket::VideoContentDescription*>(
751 content->description); 751 content->description);
752 ASSERT_TRUE(video_content != NULL); 752 ASSERT_TRUE(video_content != nullptr);
753 ASSERT_EQ(0U, video_content->cryptos().size()); 753 ASSERT_EQ(0U, video_content->cryptos().size());
754 754
755 if (dtls) { 755 if (dtls) {
756 EXPECT_EQ(std::string(cricket::kMediaProtocolDtlsSavpf), 756 EXPECT_EQ(std::string(cricket::kMediaProtocolDtlsSavpf),
757 audio_content->protocol()); 757 audio_content->protocol());
758 EXPECT_EQ(std::string(cricket::kMediaProtocolDtlsSavpf), 758 EXPECT_EQ(std::string(cricket::kMediaProtocolDtlsSavpf),
759 video_content->protocol()); 759 video_content->protocol());
760 } else { 760 } else {
761 EXPECT_EQ(std::string(cricket::kMediaProtocolAvpf), 761 EXPECT_EQ(std::string(cricket::kMediaProtocolAvpf),
762 audio_content->protocol()); 762 audio_content->protocol());
(...skipping 10 matching lines...) Expand all
773 // Confirmed to work with KT_RSA and KT_ECDSA. 773 // Confirmed to work with KT_RSA and KT_ECDSA.
774 tdesc_factory_->set_certificate( 774 tdesc_factory_->set_certificate(
775 rtc::RTCCertificate::Create(std::unique_ptr<rtc::SSLIdentity>( 775 rtc::RTCCertificate::Create(std::unique_ptr<rtc::SSLIdentity>(
776 rtc::SSLIdentity::Generate(identity_name, rtc::KT_DEFAULT)))); 776 rtc::SSLIdentity::Generate(identity_name, rtc::KT_DEFAULT))));
777 tdesc_factory_->set_secure(cricket::SEC_REQUIRED); 777 tdesc_factory_->set_secure(cricket::SEC_REQUIRED);
778 } 778 }
779 779
780 void VerifyFingerprintStatus(const cricket::SessionDescription* sdp, 780 void VerifyFingerprintStatus(const cricket::SessionDescription* sdp,
781 bool expected) { 781 bool expected) {
782 const TransportInfo* audio = sdp->GetTransportInfoByName("audio"); 782 const TransportInfo* audio = sdp->GetTransportInfoByName("audio");
783 ASSERT_TRUE(audio != NULL); 783 ASSERT_TRUE(audio != nullptr);
784 ASSERT_EQ(expected, audio->description.identity_fingerprint.get() != NULL); 784 ASSERT_EQ(expected,
785 audio->description.identity_fingerprint.get() != nullptr);
785 const TransportInfo* video = sdp->GetTransportInfoByName("video"); 786 const TransportInfo* video = sdp->GetTransportInfoByName("video");
786 ASSERT_TRUE(video != NULL); 787 ASSERT_TRUE(video != nullptr);
787 ASSERT_EQ(expected, video->description.identity_fingerprint.get() != NULL); 788 ASSERT_EQ(expected,
789 video->description.identity_fingerprint.get() != nullptr);
788 } 790 }
789 791
790 void VerifyAnswerFromNonCryptoOffer() { 792 void VerifyAnswerFromNonCryptoOffer() {
791 // Create an SDP without Crypto. 793 // Create an SDP without Crypto.
792 cricket::MediaSessionOptions options; 794 cricket::MediaSessionOptions options;
793 options.recv_video = true; 795 options.recv_video = true;
794 JsepSessionDescription* offer( 796 JsepSessionDescription* offer(
795 CreateRemoteOffer(options, cricket::SEC_DISABLED)); 797 CreateRemoteOffer(options, cricket::SEC_DISABLED));
796 ASSERT_TRUE(offer != NULL); 798 ASSERT_TRUE(offer != nullptr);
797 VerifyNoCryptoParams(offer->description(), false); 799 VerifyNoCryptoParams(offer->description(), false);
798 SetRemoteDescriptionOfferExpectError(kSdpWithoutSdesCrypto, 800 SetRemoteDescriptionOfferExpectError(kSdpWithoutSdesCrypto,
799 offer); 801 offer);
800 const webrtc::SessionDescriptionInterface* answer = CreateAnswer(); 802 const webrtc::SessionDescriptionInterface* answer = CreateAnswer();
801 // Answer should be NULL as no crypto params in offer. 803 // Answer should be null as no crypto params in offer.
802 ASSERT_TRUE(answer == NULL); 804 ASSERT_TRUE(answer == nullptr);
803 } 805 }
804 806
805 void VerifyAnswerFromCryptoOffer() { 807 void VerifyAnswerFromCryptoOffer() {
806 cricket::MediaSessionOptions options; 808 cricket::MediaSessionOptions options;
807 options.recv_video = true; 809 options.recv_video = true;
808 options.bundle_enabled = true; 810 options.bundle_enabled = true;
809 std::unique_ptr<JsepSessionDescription> offer( 811 std::unique_ptr<JsepSessionDescription> offer(
810 CreateRemoteOffer(options, cricket::SEC_REQUIRED)); 812 CreateRemoteOffer(options, cricket::SEC_REQUIRED));
811 ASSERT_TRUE(offer.get() != NULL); 813 ASSERT_TRUE(offer.get() != nullptr);
812 VerifyCryptoParams(offer->description()); 814 VerifyCryptoParams(offer->description());
813 SetRemoteDescriptionWithoutError(offer.release()); 815 SetRemoteDescriptionWithoutError(offer.release());
814 std::unique_ptr<SessionDescriptionInterface> answer(CreateAnswer()); 816 std::unique_ptr<SessionDescriptionInterface> answer(CreateAnswer());
815 ASSERT_TRUE(answer.get() != NULL); 817 ASSERT_TRUE(answer.get() != nullptr);
816 VerifyCryptoParams(answer->description()); 818 VerifyCryptoParams(answer->description());
817 } 819 }
818 820
819 bool IceUfragPwdEqual(const cricket::SessionDescription* desc1, 821 bool IceUfragPwdEqual(const cricket::SessionDescription* desc1,
820 const cricket::SessionDescription* desc2) { 822 const cricket::SessionDescription* desc2) {
821 if (desc1->contents().size() != desc2->contents().size()) { 823 if (desc1->contents().size() != desc2->contents().size()) {
822 return false; 824 return false;
823 } 825 }
824 826
825 const cricket::ContentInfos& contents = desc1->contents(); 827 const cricket::ContentInfos& contents = desc1->contents();
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
920 // creates a local answer and applies is as a local description. 922 // creates a local answer and applies is as a local description.
921 // Call SendAudioVideoStreamX() before this function 923 // Call SendAudioVideoStreamX() before this function
922 // to decide which local and remote streams to create. 924 // to decide which local and remote streams to create.
923 void CreateAndSetRemoteOfferAndLocalAnswer() { 925 void CreateAndSetRemoteOfferAndLocalAnswer() {
924 SessionDescriptionInterface* offer = CreateRemoteOffer(); 926 SessionDescriptionInterface* offer = CreateRemoteOffer();
925 SetRemoteDescriptionWithoutError(offer); 927 SetRemoteDescriptionWithoutError(offer);
926 SessionDescriptionInterface* answer = CreateAnswer(); 928 SessionDescriptionInterface* answer = CreateAnswer();
927 SetLocalDescriptionWithoutError(answer); 929 SetLocalDescriptionWithoutError(answer);
928 } 930 }
929 void SetLocalDescriptionWithoutError(SessionDescriptionInterface* desc) { 931 void SetLocalDescriptionWithoutError(SessionDescriptionInterface* desc) {
930 EXPECT_TRUE(session_->SetLocalDescription(desc, NULL)); 932 EXPECT_TRUE(session_->SetLocalDescription(desc, nullptr));
931 session_->MaybeStartGathering(); 933 session_->MaybeStartGathering();
932 } 934 }
933 void SetLocalDescriptionExpectState(SessionDescriptionInterface* desc, 935 void SetLocalDescriptionExpectState(SessionDescriptionInterface* desc,
934 WebRtcSession::State expected_state) { 936 WebRtcSession::State expected_state) {
935 SetLocalDescriptionWithoutError(desc); 937 SetLocalDescriptionWithoutError(desc);
936 EXPECT_EQ(expected_state, session_->state()); 938 EXPECT_EQ(expected_state, session_->state());
937 } 939 }
938 void SetLocalDescriptionExpectError(const std::string& action, 940 void SetLocalDescriptionExpectError(const std::string& action,
939 const std::string& expected_error, 941 const std::string& expected_error,
940 SessionDescriptionInterface* desc) { 942 SessionDescriptionInterface* desc) {
941 std::string error; 943 std::string error;
942 EXPECT_FALSE(session_->SetLocalDescription(desc, &error)); 944 EXPECT_FALSE(session_->SetLocalDescription(desc, &error));
943 std::string sdp_type = "local "; 945 std::string sdp_type = "local ";
944 sdp_type.append(action); 946 sdp_type.append(action);
945 EXPECT_NE(std::string::npos, error.find(sdp_type)); 947 EXPECT_NE(std::string::npos, error.find(sdp_type));
946 EXPECT_NE(std::string::npos, error.find(expected_error)); 948 EXPECT_NE(std::string::npos, error.find(expected_error));
947 } 949 }
948 void SetLocalDescriptionOfferExpectError(const std::string& expected_error, 950 void SetLocalDescriptionOfferExpectError(const std::string& expected_error,
949 SessionDescriptionInterface* desc) { 951 SessionDescriptionInterface* desc) {
950 SetLocalDescriptionExpectError(SessionDescriptionInterface::kOffer, 952 SetLocalDescriptionExpectError(SessionDescriptionInterface::kOffer,
951 expected_error, desc); 953 expected_error, desc);
952 } 954 }
953 void SetLocalDescriptionAnswerExpectError(const std::string& expected_error, 955 void SetLocalDescriptionAnswerExpectError(const std::string& expected_error,
954 SessionDescriptionInterface* desc) { 956 SessionDescriptionInterface* desc) {
955 SetLocalDescriptionExpectError(SessionDescriptionInterface::kAnswer, 957 SetLocalDescriptionExpectError(SessionDescriptionInterface::kAnswer,
956 expected_error, desc); 958 expected_error, desc);
957 } 959 }
958 void SetRemoteDescriptionWithoutError(SessionDescriptionInterface* desc) { 960 void SetRemoteDescriptionWithoutError(SessionDescriptionInterface* desc) {
959 EXPECT_TRUE(session_->SetRemoteDescription(desc, NULL)); 961 EXPECT_TRUE(session_->SetRemoteDescription(desc, nullptr));
960 } 962 }
961 void SetRemoteDescriptionExpectState(SessionDescriptionInterface* desc, 963 void SetRemoteDescriptionExpectState(SessionDescriptionInterface* desc,
962 WebRtcSession::State expected_state) { 964 WebRtcSession::State expected_state) {
963 SetRemoteDescriptionWithoutError(desc); 965 SetRemoteDescriptionWithoutError(desc);
964 EXPECT_EQ(expected_state, session_->state()); 966 EXPECT_EQ(expected_state, session_->state());
965 } 967 }
966 void SetRemoteDescriptionExpectError(const std::string& action, 968 void SetRemoteDescriptionExpectError(const std::string& action,
967 const std::string& expected_error, 969 const std::string& expected_error,
968 SessionDescriptionInterface* desc) { 970 SessionDescriptionInterface* desc) {
969 std::string error; 971 std::string error;
(...skipping 19 matching lines...) Expand all
989 expected_error, desc); 991 expected_error, desc);
990 } 992 }
991 993
992 void CreateCryptoOfferAndNonCryptoAnswer(SessionDescriptionInterface** offer, 994 void CreateCryptoOfferAndNonCryptoAnswer(SessionDescriptionInterface** offer,
993 SessionDescriptionInterface** nocrypto_answer) { 995 SessionDescriptionInterface** nocrypto_answer) {
994 // Create a SDP without Crypto. 996 // Create a SDP without Crypto.
995 cricket::MediaSessionOptions options; 997 cricket::MediaSessionOptions options;
996 options.recv_video = true; 998 options.recv_video = true;
997 options.bundle_enabled = true; 999 options.bundle_enabled = true;
998 *offer = CreateRemoteOffer(options, cricket::SEC_ENABLED); 1000 *offer = CreateRemoteOffer(options, cricket::SEC_ENABLED);
999 ASSERT_TRUE(*offer != NULL); 1001 ASSERT_TRUE(*offer != nullptr);
1000 VerifyCryptoParams((*offer)->description()); 1002 VerifyCryptoParams((*offer)->description());
1001 1003
1002 *nocrypto_answer = CreateRemoteAnswer(*offer, options, 1004 *nocrypto_answer = CreateRemoteAnswer(*offer, options,
1003 cricket::SEC_DISABLED); 1005 cricket::SEC_DISABLED);
1004 EXPECT_TRUE(*nocrypto_answer != NULL); 1006 EXPECT_TRUE(*nocrypto_answer != nullptr);
1005 } 1007 }
1006 1008
1007 void CreateDtlsOfferAndNonDtlsAnswer(SessionDescriptionInterface** offer, 1009 void CreateDtlsOfferAndNonDtlsAnswer(SessionDescriptionInterface** offer,
1008 SessionDescriptionInterface** nodtls_answer) { 1010 SessionDescriptionInterface** nodtls_answer) {
1009 cricket::MediaSessionOptions options; 1011 cricket::MediaSessionOptions options;
1010 options.recv_video = true; 1012 options.recv_video = true;
1011 options.bundle_enabled = true; 1013 options.bundle_enabled = true;
1012 1014
1013 std::unique_ptr<SessionDescriptionInterface> temp_offer( 1015 std::unique_ptr<SessionDescriptionInterface> temp_offer(
1014 CreateRemoteOffer(options, cricket::SEC_ENABLED)); 1016 CreateRemoteOffer(options, cricket::SEC_ENABLED));
1015 1017
1016 *nodtls_answer = 1018 *nodtls_answer =
1017 CreateRemoteAnswer(temp_offer.get(), options, cricket::SEC_ENABLED); 1019 CreateRemoteAnswer(temp_offer.get(), options, cricket::SEC_ENABLED);
1018 EXPECT_TRUE(*nodtls_answer != NULL); 1020 EXPECT_TRUE(*nodtls_answer != nullptr);
1019 VerifyFingerprintStatus((*nodtls_answer)->description(), false); 1021 VerifyFingerprintStatus((*nodtls_answer)->description(), false);
1020 VerifyCryptoParams((*nodtls_answer)->description()); 1022 VerifyCryptoParams((*nodtls_answer)->description());
1021 1023
1022 SetFactoryDtlsSrtp(); 1024 SetFactoryDtlsSrtp();
1023 *offer = CreateRemoteOffer(options, cricket::SEC_ENABLED); 1025 *offer = CreateRemoteOffer(options, cricket::SEC_ENABLED);
1024 ASSERT_TRUE(*offer != NULL); 1026 ASSERT_TRUE(*offer != nullptr);
1025 VerifyFingerprintStatus((*offer)->description(), true); 1027 VerifyFingerprintStatus((*offer)->description(), true);
1026 VerifyCryptoParams((*offer)->description()); 1028 VerifyCryptoParams((*offer)->description());
1027 } 1029 }
1028 1030
1029 JsepSessionDescription* CreateRemoteOfferWithVersion( 1031 JsepSessionDescription* CreateRemoteOfferWithVersion(
1030 cricket::MediaSessionOptions options, 1032 cricket::MediaSessionOptions options,
1031 cricket::SecurePolicy secure_policy, 1033 cricket::SecurePolicy secure_policy,
1032 const std::string& session_version, 1034 const std::string& session_version,
1033 const SessionDescriptionInterface* current_desc) { 1035 const SessionDescriptionInterface* current_desc) {
1034 std::string session_id = rtc::ToString(rtc::CreateRandomId64()); 1036 std::string session_id = rtc::ToString(rtc::CreateRandomId64());
1035 const cricket::SessionDescription* cricket_desc = NULL; 1037 const cricket::SessionDescription* cricket_desc = nullptr;
1036 if (current_desc) { 1038 if (current_desc) {
1037 cricket_desc = current_desc->description(); 1039 cricket_desc = current_desc->description();
1038 session_id = current_desc->session_id(); 1040 session_id = current_desc->session_id();
1039 } 1041 }
1040 1042
1041 desc_factory_->set_secure(secure_policy); 1043 desc_factory_->set_secure(secure_policy);
1042 JsepSessionDescription* offer( 1044 JsepSessionDescription* offer(
1043 new JsepSessionDescription(JsepSessionDescription::kOffer)); 1045 new JsepSessionDescription(JsepSessionDescription::kOffer));
1044 if (!offer->Initialize(desc_factory_->CreateOffer(options, cricket_desc), 1046 if (!offer->Initialize(desc_factory_->CreateOffer(options, cricket_desc),
1045 session_id, session_version)) { 1047 session_id, session_version)) {
1046 delete offer; 1048 delete offer;
1047 offer = NULL; 1049 offer = nullptr;
1048 } 1050 }
1049 return offer; 1051 return offer;
1050 } 1052 }
1051 JsepSessionDescription* CreateRemoteOffer( 1053 JsepSessionDescription* CreateRemoteOffer(
1052 cricket::MediaSessionOptions options) { 1054 cricket::MediaSessionOptions options) {
1053 return CreateRemoteOfferWithVersion(options, cricket::SEC_ENABLED, 1055 return CreateRemoteOfferWithVersion(options, cricket::SEC_ENABLED,
1054 kSessionVersion, NULL); 1056 kSessionVersion, nullptr);
1055 } 1057 }
1056 JsepSessionDescription* CreateRemoteOffer( 1058 JsepSessionDescription* CreateRemoteOffer(
1057 cricket::MediaSessionOptions options, cricket::SecurePolicy sdes_policy) { 1059 cricket::MediaSessionOptions options, cricket::SecurePolicy sdes_policy) {
1058 return CreateRemoteOfferWithVersion( 1060 return CreateRemoteOfferWithVersion(options, sdes_policy, kSessionVersion,
1059 options, sdes_policy, kSessionVersion, NULL); 1061 nullptr);
1060 } 1062 }
1061 JsepSessionDescription* CreateRemoteOffer( 1063 JsepSessionDescription* CreateRemoteOffer(
1062 cricket::MediaSessionOptions options, 1064 cricket::MediaSessionOptions options,
1063 const SessionDescriptionInterface* current_desc) { 1065 const SessionDescriptionInterface* current_desc) {
1064 return CreateRemoteOfferWithVersion(options, cricket::SEC_ENABLED, 1066 return CreateRemoteOfferWithVersion(options, cricket::SEC_ENABLED,
1065 kSessionVersion, current_desc); 1067 kSessionVersion, current_desc);
1066 } 1068 }
1067 1069
1068 JsepSessionDescription* CreateRemoteOfferWithSctpPort( 1070 JsepSessionDescription* CreateRemoteOfferWithSctpPort(
1069 const char* sctp_stream_name, int new_port, 1071 const char* sctp_stream_name, int new_port,
(...skipping 13 matching lines...) Expand all
1083 char new_port_str[16]; 1085 char new_port_str[16];
1084 rtc::sprintfn(new_port_str, sizeof(new_port_str), "%d", new_port); 1086 rtc::sprintfn(new_port_str, sizeof(new_port_str), "%d", new_port);
1085 std::string offer_str; 1087 std::string offer_str;
1086 offer_basis->ToString(&offer_str); 1088 offer_basis->ToString(&offer_str);
1087 rtc::replace_substrs(default_port_str, strlen(default_port_str), 1089 rtc::replace_substrs(default_port_str, strlen(default_port_str),
1088 new_port_str, strlen(new_port_str), 1090 new_port_str, strlen(new_port_str),
1089 &offer_str); 1091 &offer_str);
1090 JsepSessionDescription* offer = new JsepSessionDescription( 1092 JsepSessionDescription* offer = new JsepSessionDescription(
1091 offer_basis->type()); 1093 offer_basis->type());
1092 delete offer_basis; 1094 delete offer_basis;
1093 offer->Initialize(offer_str, NULL); 1095 offer->Initialize(offer_str, nullptr);
1094 return offer; 1096 return offer;
1095 } 1097 }
1096 1098
1097 // Create a remote offer. Call SendAudioVideoStreamX() 1099 // Create a remote offer. Call SendAudioVideoStreamX()
1098 // before this function to decide which streams to create. 1100 // before this function to decide which streams to create.
1099 JsepSessionDescription* CreateRemoteOffer() { 1101 JsepSessionDescription* CreateRemoteOffer() {
1100 cricket::MediaSessionOptions options; 1102 cricket::MediaSessionOptions options;
1101 GetOptionsForAnswer(&options); 1103 GetOptionsForAnswer(&options);
1102 return CreateRemoteOffer(options, session_->remote_description()); 1104 return CreateRemoteOffer(options, session_->remote_description());
1103 } 1105 }
1104 1106
1105 JsepSessionDescription* CreateRemoteAnswer( 1107 JsepSessionDescription* CreateRemoteAnswer(
1106 const SessionDescriptionInterface* offer, 1108 const SessionDescriptionInterface* offer,
1107 cricket::MediaSessionOptions options, 1109 cricket::MediaSessionOptions options,
1108 cricket::SecurePolicy policy) { 1110 cricket::SecurePolicy policy) {
1109 desc_factory_->set_secure(policy); 1111 desc_factory_->set_secure(policy);
1110 const std::string session_id = 1112 const std::string session_id =
1111 rtc::ToString(rtc::CreateRandomId64()); 1113 rtc::ToString(rtc::CreateRandomId64());
1112 JsepSessionDescription* answer( 1114 JsepSessionDescription* answer(
1113 new JsepSessionDescription(JsepSessionDescription::kAnswer)); 1115 new JsepSessionDescription(JsepSessionDescription::kAnswer));
1114 if (!answer->Initialize(desc_factory_->CreateAnswer(offer->description(), 1116 if (!answer->Initialize(
1115 options, NULL), 1117 desc_factory_->CreateAnswer(offer->description(), options, nullptr),
1116 session_id, kSessionVersion)) { 1118 session_id, kSessionVersion)) {
1117 delete answer; 1119 delete answer;
1118 answer = NULL; 1120 answer = nullptr;
1119 } 1121 }
1120 return answer; 1122 return answer;
1121 } 1123 }
1122 1124
1123 JsepSessionDescription* CreateRemoteAnswer( 1125 JsepSessionDescription* CreateRemoteAnswer(
1124 const SessionDescriptionInterface* offer, 1126 const SessionDescriptionInterface* offer,
1125 cricket::MediaSessionOptions options) { 1127 cricket::MediaSessionOptions options) {
1126 return CreateRemoteAnswer(offer, options, cricket::SEC_REQUIRED); 1128 return CreateRemoteAnswer(offer, options, cricket::SEC_REQUIRED);
1127 } 1129 }
1128 1130
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
1160 // for rtp and rtcp. 1162 // for rtp and rtcp.
1161 expected_candidate_num = 4; 1163 expected_candidate_num = 4;
1162 // Disable rtcp-mux from the answer 1164 // Disable rtcp-mux from the answer
1163 const std::string kRtcpMux = "a=rtcp-mux"; 1165 const std::string kRtcpMux = "a=rtcp-mux";
1164 const std::string kXRtcpMux = "a=xrtcp-mux"; 1166 const std::string kXRtcpMux = "a=xrtcp-mux";
1165 rtc::replace_substrs(kRtcpMux.c_str(), kRtcpMux.length(), 1167 rtc::replace_substrs(kRtcpMux.c_str(), kRtcpMux.length(),
1166 kXRtcpMux.c_str(), kXRtcpMux.length(), 1168 kXRtcpMux.c_str(), kXRtcpMux.length(),
1167 &sdp); 1169 &sdp);
1168 } 1170 }
1169 1171
1170 SessionDescriptionInterface* new_answer = CreateSessionDescription( 1172 SessionDescriptionInterface* new_answer =
1171 JsepSessionDescription::kAnswer, sdp, NULL); 1173 CreateSessionDescription(JsepSessionDescription::kAnswer, sdp, nullptr);
1172 1174
1173 // SetRemoteDescription to enable rtcp mux. 1175 // SetRemoteDescription to enable rtcp mux.
1174 SetRemoteDescriptionWithoutError(new_answer); 1176 SetRemoteDescriptionWithoutError(new_answer);
1175 EXPECT_TRUE_WAIT(observer_.oncandidatesready_, kIceCandidatesTimeout); 1177 EXPECT_TRUE_WAIT(observer_.oncandidatesready_, kIceCandidatesTimeout);
1176 EXPECT_EQ(expected_candidate_num, observer_.mline_0_candidates_.size()); 1178 EXPECT_EQ(expected_candidate_num, observer_.mline_0_candidates_.size());
1177 if (bundle) { 1179 if (bundle) {
1178 EXPECT_EQ(0, observer_.mline_1_candidates_.size()); 1180 EXPECT_EQ(0, observer_.mline_1_candidates_.size());
1179 } else { 1181 } else {
1180 EXPECT_EQ(expected_candidate_num, observer_.mline_1_candidates_.size()); 1182 EXPECT_EQ(expected_candidate_num, observer_.mline_1_candidates_.size());
1181 } 1183 }
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
1317 EXPECT_EQ_WAIT(PeerConnectionInterface::kIceGatheringGathering, 1319 EXPECT_EQ_WAIT(PeerConnectionInterface::kIceGatheringGathering,
1318 observer_.ice_gathering_state_, kIceCandidatesTimeout); 1320 observer_.ice_gathering_state_, kIceCandidatesTimeout);
1319 EXPECT_TRUE_WAIT(observer_.oncandidatesready_, kIceCandidatesTimeout); 1321 EXPECT_TRUE_WAIT(observer_.oncandidatesready_, kIceCandidatesTimeout);
1320 EXPECT_EQ_WAIT(PeerConnectionInterface::kIceGatheringComplete, 1322 EXPECT_EQ_WAIT(PeerConnectionInterface::kIceGatheringComplete,
1321 observer_.ice_gathering_state_, kIceCandidatesTimeout); 1323 observer_.ice_gathering_state_, kIceCandidatesTimeout);
1322 1324
1323 std::string sdp; 1325 std::string sdp;
1324 offer->ToString(&sdp); 1326 offer->ToString(&sdp);
1325 SessionDescriptionInterface* desc = webrtc::CreateSessionDescription( 1327 SessionDescriptionInterface* desc = webrtc::CreateSessionDescription(
1326 JsepSessionDescription::kAnswer, sdp, nullptr); 1328 JsepSessionDescription::kAnswer, sdp, nullptr);
1327 ASSERT_TRUE(desc != NULL); 1329 ASSERT_TRUE(desc != nullptr);
1328 SetRemoteDescriptionWithoutError(desc); 1330 SetRemoteDescriptionWithoutError(desc);
1329 1331
1330 EXPECT_EQ_WAIT(PeerConnectionInterface::kIceConnectionChecking, 1332 EXPECT_EQ_WAIT(PeerConnectionInterface::kIceConnectionChecking,
1331 observer_.ice_connection_state_, kIceCandidatesTimeout); 1333 observer_.ice_connection_state_, kIceCandidatesTimeout);
1332 1334
1333 // The ice connection state is "Connected" too briefly to catch in a test. 1335 // The ice connection state is "Connected" too briefly to catch in a test.
1334 EXPECT_EQ_WAIT(PeerConnectionInterface::kIceConnectionCompleted, 1336 EXPECT_EQ_WAIT(PeerConnectionInterface::kIceConnectionCompleted,
1335 observer_.ice_connection_state_, kIceCandidatesTimeout); 1337 observer_.ice_connection_state_, kIceCandidatesTimeout);
1336 } 1338 }
1337 1339
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
1407 std::vector<cricket::AudioCodec> codecs = 1409 std::vector<cricket::AudioCodec> codecs =
1408 media_engine_->audio_send_codecs(); 1410 media_engine_->audio_send_codecs();
1409 codecs.push_back(kCNCodec1); 1411 codecs.push_back(kCNCodec1);
1410 codecs.push_back(kCNCodec2); 1412 codecs.push_back(kCNCodec2);
1411 media_engine_->SetAudioCodecs(codecs); 1413 media_engine_->SetAudioCodecs(codecs);
1412 desc_factory_->set_audio_codecs(codecs, codecs); 1414 desc_factory_->set_audio_codecs(codecs, codecs);
1413 } 1415 }
1414 1416
1415 bool VerifyNoCNCodecs(const cricket::ContentInfo* content) { 1417 bool VerifyNoCNCodecs(const cricket::ContentInfo* content) {
1416 const cricket::ContentDescription* description = content->description; 1418 const cricket::ContentDescription* description = content->description;
1417 RTC_CHECK(description != NULL); 1419 RTC_CHECK(description != nullptr);
1418 const cricket::AudioContentDescription* audio_content_desc = 1420 const cricket::AudioContentDescription* audio_content_desc =
1419 static_cast<const cricket::AudioContentDescription*>(description); 1421 static_cast<const cricket::AudioContentDescription*>(description);
1420 RTC_CHECK(audio_content_desc != NULL); 1422 RTC_CHECK(audio_content_desc != nullptr);
1421 for (size_t i = 0; i < audio_content_desc->codecs().size(); ++i) { 1423 for (size_t i = 0; i < audio_content_desc->codecs().size(); ++i) {
1422 if (audio_content_desc->codecs()[i].name == "CN") 1424 if (audio_content_desc->codecs()[i].name == "CN")
1423 return false; 1425 return false;
1424 } 1426 }
1425 return true; 1427 return true;
1426 } 1428 }
1427 1429
1428 void CreateDataChannel() { 1430 void CreateDataChannel() {
1429 webrtc::InternalDataChannelInit dci; 1431 webrtc::InternalDataChannelInit dci;
1430 RTC_CHECK(session_.get()); 1432 RTC_CHECK(session_.get());
(...skipping 22 matching lines...) Expand all
1453 } 1455 }
1454 1456
1455 void VerifyMultipleAsyncCreateDescriptionAfterInit( 1457 void VerifyMultipleAsyncCreateDescriptionAfterInit(
1456 bool success, CreateSessionDescriptionRequest::Type type) { 1458 bool success, CreateSessionDescriptionRequest::Type type) {
1457 RTC_CHECK(session_); 1459 RTC_CHECK(session_);
1458 SetFactoryDtlsSrtp(); 1460 SetFactoryDtlsSrtp();
1459 if (type == CreateSessionDescriptionRequest::kAnswer) { 1461 if (type == CreateSessionDescriptionRequest::kAnswer) {
1460 cricket::MediaSessionOptions options; 1462 cricket::MediaSessionOptions options;
1461 std::unique_ptr<JsepSessionDescription> offer( 1463 std::unique_ptr<JsepSessionDescription> offer(
1462 CreateRemoteOffer(options, cricket::SEC_DISABLED)); 1464 CreateRemoteOffer(options, cricket::SEC_DISABLED));
1463 ASSERT_TRUE(offer.get() != NULL); 1465 ASSERT_TRUE(offer.get() != nullptr);
1464 SetRemoteDescriptionWithoutError(offer.release()); 1466 SetRemoteDescriptionWithoutError(offer.release());
1465 } 1467 }
1466 1468
1467 PeerConnectionInterface::RTCOfferAnswerOptions options; 1469 PeerConnectionInterface::RTCOfferAnswerOptions options;
1468 cricket::MediaSessionOptions session_options; 1470 cricket::MediaSessionOptions session_options;
1469 const int kNumber = 3; 1471 const int kNumber = 3;
1470 rtc::scoped_refptr<WebRtcSessionCreateSDPObserverForTest> 1472 rtc::scoped_refptr<WebRtcSessionCreateSDPObserverForTest>
1471 observers[kNumber]; 1473 observers[kNumber];
1472 for (int i = 0; i < kNumber; ++i) { 1474 for (int i = 0; i < kNumber; ++i) {
1473 observers[i] = new WebRtcSessionCreateSDPObserverForTest(); 1475 observers[i] = new WebRtcSessionCreateSDPObserverForTest();
1474 if (type == CreateSessionDescriptionRequest::kOffer) { 1476 if (type == CreateSessionDescriptionRequest::kOffer) {
1475 session_->CreateOffer(observers[i], options, session_options); 1477 session_->CreateOffer(observers[i], options, session_options);
1476 } else { 1478 } else {
1477 session_->CreateAnswer(observers[i], session_options); 1479 session_->CreateAnswer(observers[i], session_options);
1478 } 1480 }
1479 } 1481 }
1480 1482
1481 WebRtcSessionCreateSDPObserverForTest::State expected_state = 1483 WebRtcSessionCreateSDPObserverForTest::State expected_state =
1482 success ? WebRtcSessionCreateSDPObserverForTest::kSucceeded : 1484 success ? WebRtcSessionCreateSDPObserverForTest::kSucceeded :
1483 WebRtcSessionCreateSDPObserverForTest::kFailed; 1485 WebRtcSessionCreateSDPObserverForTest::kFailed;
1484 1486
1485 for (int i = 0; i < kNumber; ++i) { 1487 for (int i = 0; i < kNumber; ++i) {
1486 EXPECT_EQ_WAIT(expected_state, observers[i]->state(), 1000); 1488 EXPECT_EQ_WAIT(expected_state, observers[i]->state(), 1000);
1487 if (success) { 1489 if (success) {
1488 EXPECT_TRUE(observers[i]->description() != NULL); 1490 EXPECT_TRUE(observers[i]->description() != nullptr);
1489 } else { 1491 } else {
1490 EXPECT_TRUE(observers[i]->description() == NULL); 1492 EXPECT_TRUE(observers[i]->description() == nullptr);
1491 } 1493 }
1492 } 1494 }
1493 } 1495 }
1494 1496
1495 void ConfigureAllocatorWithTurn() { 1497 void ConfigureAllocatorWithTurn() {
1496 cricket::RelayServerConfig turn_server(cricket::RELAY_TURN); 1498 cricket::RelayServerConfig turn_server(cricket::RELAY_TURN);
1497 cricket::RelayCredentials credentials(kTurnUsername, kTurnPassword); 1499 cricket::RelayCredentials credentials(kTurnUsername, kTurnPassword);
1498 turn_server.credentials = credentials; 1500 turn_server.credentials = credentials;
1499 turn_server.ports.push_back( 1501 turn_server.ports.push_back(
1500 cricket::ProtocolAddress(kTurnUdpIntAddr, cricket::PROTO_UDP)); 1502 cricket::ProtocolAddress(kTurnUdpIntAddr, cricket::PROTO_UDP));
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
1596 EXPECT_EQ(6u, observer_.mline_0_candidates_.size()); 1598 EXPECT_EQ(6u, observer_.mline_0_candidates_.size());
1597 EXPECT_EQ(6u, observer_.mline_1_candidates_.size()); 1599 EXPECT_EQ(6u, observer_.mline_1_candidates_.size());
1598 // Destroy session before scoped fake clock goes out of scope to avoid TSan 1600 // Destroy session before scoped fake clock goes out of scope to avoid TSan
1599 // warning. 1601 // warning.
1600 session_->Close(); 1602 session_->Close();
1601 session_.reset(nullptr); 1603 session_.reset(nullptr);
1602 } 1604 }
1603 1605
1604 TEST_F(WebRtcSessionTest, SetSdpFailedOnInvalidSdp) { 1606 TEST_F(WebRtcSessionTest, SetSdpFailedOnInvalidSdp) {
1605 Init(); 1607 Init();
1606 SessionDescriptionInterface* offer = NULL; 1608 SessionDescriptionInterface* offer = nullptr;
1607 // Since |offer| is NULL, there's no way to tell if it's an offer or answer. 1609 // Since |offer| is null, there's no way to tell if it's an offer or answer.
1608 std::string unknown_action; 1610 std::string unknown_action;
1609 SetLocalDescriptionExpectError(unknown_action, kInvalidSdp, offer); 1611 SetLocalDescriptionExpectError(unknown_action, kInvalidSdp, offer);
1610 SetRemoteDescriptionExpectError(unknown_action, kInvalidSdp, offer); 1612 SetRemoteDescriptionExpectError(unknown_action, kInvalidSdp, offer);
1611 } 1613 }
1612 1614
1613 // Test creating offers and receive answers and make sure the 1615 // Test creating offers and receive answers and make sure the
1614 // media engine creates the expected send and receive streams. 1616 // media engine creates the expected send and receive streams.
1615 TEST_F(WebRtcSessionTest, TestCreateSdesOfferReceiveSdesAnswer) { 1617 TEST_F(WebRtcSessionTest, TestCreateSdesOfferReceiveSdesAnswer) {
1616 Init(); 1618 Init();
1617 SendAudioVideoStream1(); 1619 SendAudioVideoStream1();
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
1722 // Make sure we have no send streams. 1724 // Make sure we have no send streams.
1723 EXPECT_EQ(0u, video_channel_->send_streams().size()); 1725 EXPECT_EQ(0u, video_channel_->send_streams().size());
1724 EXPECT_EQ(0u, voice_channel_->send_streams().size()); 1726 EXPECT_EQ(0u, voice_channel_->send_streams().size());
1725 } 1727 }
1726 1728
1727 TEST_F(WebRtcSessionTest, SetLocalSdpFailedOnCreateChannel) { 1729 TEST_F(WebRtcSessionTest, SetLocalSdpFailedOnCreateChannel) {
1728 Init(); 1730 Init();
1729 media_engine_->set_fail_create_channel(true); 1731 media_engine_->set_fail_create_channel(true);
1730 1732
1731 SessionDescriptionInterface* offer = CreateOffer(); 1733 SessionDescriptionInterface* offer = CreateOffer();
1732 ASSERT_TRUE(offer != NULL); 1734 ASSERT_TRUE(offer != nullptr);
1733 // SetRemoteDescription and SetLocalDescription will take the ownership of 1735 // SetRemoteDescription and SetLocalDescription will take the ownership of
1734 // the offer. 1736 // the offer.
1735 SetRemoteDescriptionOfferExpectError(kCreateChannelFailed, offer); 1737 SetRemoteDescriptionOfferExpectError(kCreateChannelFailed, offer);
1736 offer = CreateOffer(); 1738 offer = CreateOffer();
1737 ASSERT_TRUE(offer != NULL); 1739 ASSERT_TRUE(offer != nullptr);
1738 SetLocalDescriptionOfferExpectError(kCreateChannelFailed, offer); 1740 SetLocalDescriptionOfferExpectError(kCreateChannelFailed, offer);
1739 } 1741 }
1740 1742
1741 // 1743 //
1742 // Tests for creating/setting SDP under different SDES/DTLS polices: 1744 // Tests for creating/setting SDP under different SDES/DTLS polices:
1743 // 1745 //
1744 // --DTLS off and SDES on 1746 // --DTLS off and SDES on
1745 // TestCreateSdesOfferReceiveSdesAnswer/TestReceiveSdesOfferCreateSdesAnswer: 1747 // TestCreateSdesOfferReceiveSdesAnswer/TestReceiveSdesOfferCreateSdesAnswer:
1746 // set local/remote offer/answer with crypto --> success 1748 // set local/remote offer/answer with crypto --> success
1747 // TestSetNonSdesOfferWhenSdesOn: set local/remote offer without crypto ---> 1749 // TestSetNonSdesOfferWhenSdesOn: set local/remote offer without crypto --->
(...skipping 21 matching lines...) Expand all
1769 // 1771 //
1770 1772
1771 // Test that we return a failure when applying a remote/local offer that doesn't 1773 // Test that we return a failure when applying a remote/local offer that doesn't
1772 // have cryptos enabled when DTLS is off. 1774 // have cryptos enabled when DTLS is off.
1773 TEST_F(WebRtcSessionTest, TestSetNonSdesOfferWhenSdesOn) { 1775 TEST_F(WebRtcSessionTest, TestSetNonSdesOfferWhenSdesOn) {
1774 Init(); 1776 Init();
1775 cricket::MediaSessionOptions options; 1777 cricket::MediaSessionOptions options;
1776 options.recv_video = true; 1778 options.recv_video = true;
1777 JsepSessionDescription* offer = CreateRemoteOffer( 1779 JsepSessionDescription* offer = CreateRemoteOffer(
1778 options, cricket::SEC_DISABLED); 1780 options, cricket::SEC_DISABLED);
1779 ASSERT_TRUE(offer != NULL); 1781 ASSERT_TRUE(offer != nullptr);
1780 VerifyNoCryptoParams(offer->description(), false); 1782 VerifyNoCryptoParams(offer->description(), false);
1781 // SetRemoteDescription and SetLocalDescription will take the ownership of 1783 // SetRemoteDescription and SetLocalDescription will take the ownership of
1782 // the offer. 1784 // the offer.
1783 SetRemoteDescriptionOfferExpectError(kSdpWithoutSdesCrypto, offer); 1785 SetRemoteDescriptionOfferExpectError(kSdpWithoutSdesCrypto, offer);
1784 offer = CreateRemoteOffer(options, cricket::SEC_DISABLED); 1786 offer = CreateRemoteOffer(options, cricket::SEC_DISABLED);
1785 ASSERT_TRUE(offer != NULL); 1787 ASSERT_TRUE(offer != nullptr);
1786 SetLocalDescriptionOfferExpectError(kSdpWithoutSdesCrypto, offer); 1788 SetLocalDescriptionOfferExpectError(kSdpWithoutSdesCrypto, offer);
1787 } 1789 }
1788 1790
1789 // Test that we return a failure when applying a local answer that doesn't have 1791 // Test that we return a failure when applying a local answer that doesn't have
1790 // cryptos enabled when DTLS is off. 1792 // cryptos enabled when DTLS is off.
1791 TEST_F(WebRtcSessionTest, TestSetLocalNonSdesAnswerWhenSdesOn) { 1793 TEST_F(WebRtcSessionTest, TestSetLocalNonSdesAnswerWhenSdesOn) {
1792 Init(); 1794 Init();
1793 SessionDescriptionInterface* offer = NULL; 1795 SessionDescriptionInterface* offer = nullptr;
1794 SessionDescriptionInterface* answer = NULL; 1796 SessionDescriptionInterface* answer = nullptr;
1795 CreateCryptoOfferAndNonCryptoAnswer(&offer, &answer); 1797 CreateCryptoOfferAndNonCryptoAnswer(&offer, &answer);
1796 // SetRemoteDescription and SetLocalDescription will take the ownership of 1798 // SetRemoteDescription and SetLocalDescription will take the ownership of
1797 // the offer. 1799 // the offer.
1798 SetRemoteDescriptionWithoutError(offer); 1800 SetRemoteDescriptionWithoutError(offer);
1799 SetLocalDescriptionAnswerExpectError(kSdpWithoutSdesCrypto, answer); 1801 SetLocalDescriptionAnswerExpectError(kSdpWithoutSdesCrypto, answer);
1800 } 1802 }
1801 1803
1802 // Test we will return fail when apply an remote answer that doesn't have 1804 // Test we will return fail when apply an remote answer that doesn't have
1803 // crypto enabled when DTLS is off. 1805 // crypto enabled when DTLS is off.
1804 TEST_F(WebRtcSessionTest, TestSetRemoteNonSdesAnswerWhenSdesOn) { 1806 TEST_F(WebRtcSessionTest, TestSetRemoteNonSdesAnswerWhenSdesOn) {
1805 Init(); 1807 Init();
1806 SessionDescriptionInterface* offer = NULL; 1808 SessionDescriptionInterface* offer = nullptr;
1807 SessionDescriptionInterface* answer = NULL; 1809 SessionDescriptionInterface* answer = nullptr;
1808 CreateCryptoOfferAndNonCryptoAnswer(&offer, &answer); 1810 CreateCryptoOfferAndNonCryptoAnswer(&offer, &answer);
1809 // SetRemoteDescription and SetLocalDescription will take the ownership of 1811 // SetRemoteDescription and SetLocalDescription will take the ownership of
1810 // the offer. 1812 // the offer.
1811 SetLocalDescriptionWithoutError(offer); 1813 SetLocalDescriptionWithoutError(offer);
1812 SetRemoteDescriptionAnswerExpectError(kSdpWithoutSdesCrypto, answer); 1814 SetRemoteDescriptionAnswerExpectError(kSdpWithoutSdesCrypto, answer);
1813 } 1815 }
1814 1816
1815 // Test that we accept an offer with a DTLS fingerprint when DTLS is on 1817 // Test that we accept an offer with a DTLS fingerprint when DTLS is on
1816 // and that we return an answer with a DTLS fingerprint. 1818 // and that we return an answer with a DTLS fingerprint.
1817 TEST_P(WebRtcSessionTest, TestReceiveDtlsOfferCreateDtlsAnswer) { 1819 TEST_P(WebRtcSessionTest, TestReceiveDtlsOfferCreateDtlsAnswer) {
1818 SendAudioVideoStream1(); 1820 SendAudioVideoStream1();
1819 InitWithDtls(GetParam()); 1821 InitWithDtls(GetParam());
1820 SetFactoryDtlsSrtp(); 1822 SetFactoryDtlsSrtp();
1821 cricket::MediaSessionOptions options; 1823 cricket::MediaSessionOptions options;
1822 options.recv_video = true; 1824 options.recv_video = true;
1823 JsepSessionDescription* offer = 1825 JsepSessionDescription* offer =
1824 CreateRemoteOffer(options, cricket::SEC_DISABLED); 1826 CreateRemoteOffer(options, cricket::SEC_DISABLED);
1825 ASSERT_TRUE(offer != NULL); 1827 ASSERT_TRUE(offer != nullptr);
1826 VerifyFingerprintStatus(offer->description(), true); 1828 VerifyFingerprintStatus(offer->description(), true);
1827 VerifyNoCryptoParams(offer->description(), true); 1829 VerifyNoCryptoParams(offer->description(), true);
1828 1830
1829 // SetRemoteDescription will take the ownership of the offer. 1831 // SetRemoteDescription will take the ownership of the offer.
1830 SetRemoteDescriptionWithoutError(offer); 1832 SetRemoteDescriptionWithoutError(offer);
1831 1833
1832 // Verify that we get a crypto fingerprint in the answer. 1834 // Verify that we get a crypto fingerprint in the answer.
1833 SessionDescriptionInterface* answer = CreateAnswer(); 1835 SessionDescriptionInterface* answer = CreateAnswer();
1834 ASSERT_TRUE(answer != NULL); 1836 ASSERT_TRUE(answer != nullptr);
1835 VerifyFingerprintStatus(answer->description(), true); 1837 VerifyFingerprintStatus(answer->description(), true);
1836 // Check that we don't have an a=crypto line in the answer. 1838 // Check that we don't have an a=crypto line in the answer.
1837 VerifyNoCryptoParams(answer->description(), true); 1839 VerifyNoCryptoParams(answer->description(), true);
1838 1840
1839 // Now set the local description, which should work, even without a=crypto. 1841 // Now set the local description, which should work, even without a=crypto.
1840 SetLocalDescriptionWithoutError(answer); 1842 SetLocalDescriptionWithoutError(answer);
1841 } 1843 }
1842 1844
1843 // Test that we set a local offer with a DTLS fingerprint when DTLS is on 1845 // Test that we set a local offer with a DTLS fingerprint when DTLS is on
1844 // and then we accept a remote answer with a DTLS fingerprint successfully. 1846 // and then we accept a remote answer with a DTLS fingerprint successfully.
1845 TEST_P(WebRtcSessionTest, TestCreateDtlsOfferReceiveDtlsAnswer) { 1847 TEST_P(WebRtcSessionTest, TestCreateDtlsOfferReceiveDtlsAnswer) {
1846 SendAudioVideoStream1(); 1848 SendAudioVideoStream1();
1847 InitWithDtls(GetParam()); 1849 InitWithDtls(GetParam());
1848 SetFactoryDtlsSrtp(); 1850 SetFactoryDtlsSrtp();
1849 1851
1850 // Verify that we get a crypto fingerprint in the answer. 1852 // Verify that we get a crypto fingerprint in the answer.
1851 SessionDescriptionInterface* offer = CreateOffer(); 1853 SessionDescriptionInterface* offer = CreateOffer();
1852 ASSERT_TRUE(offer != NULL); 1854 ASSERT_TRUE(offer != nullptr);
1853 VerifyFingerprintStatus(offer->description(), true); 1855 VerifyFingerprintStatus(offer->description(), true);
1854 // Check that we don't have an a=crypto line in the offer. 1856 // Check that we don't have an a=crypto line in the offer.
1855 VerifyNoCryptoParams(offer->description(), true); 1857 VerifyNoCryptoParams(offer->description(), true);
1856 1858
1857 // Now set the local description, which should work, even without a=crypto. 1859 // Now set the local description, which should work, even without a=crypto.
1858 SetLocalDescriptionWithoutError(offer); 1860 SetLocalDescriptionWithoutError(offer);
1859 1861
1860 cricket::MediaSessionOptions options; 1862 cricket::MediaSessionOptions options;
1861 options.recv_video = true; 1863 options.recv_video = true;
1862 JsepSessionDescription* answer = 1864 JsepSessionDescription* answer =
1863 CreateRemoteAnswer(offer, options, cricket::SEC_DISABLED); 1865 CreateRemoteAnswer(offer, options, cricket::SEC_DISABLED);
1864 ASSERT_TRUE(answer != NULL); 1866 ASSERT_TRUE(answer != nullptr);
1865 VerifyFingerprintStatus(answer->description(), true); 1867 VerifyFingerprintStatus(answer->description(), true);
1866 VerifyNoCryptoParams(answer->description(), true); 1868 VerifyNoCryptoParams(answer->description(), true);
1867 1869
1868 // SetRemoteDescription will take the ownership of the answer. 1870 // SetRemoteDescription will take the ownership of the answer.
1869 SetRemoteDescriptionWithoutError(answer); 1871 SetRemoteDescriptionWithoutError(answer);
1870 } 1872 }
1871 1873
1872 // Test that if we support DTLS and the other side didn't offer a fingerprint, 1874 // Test that if we support DTLS and the other side didn't offer a fingerprint,
1873 // we will fail to set the remote description. 1875 // we will fail to set the remote description.
1874 TEST_P(WebRtcSessionTest, TestReceiveNonDtlsOfferWhenDtlsOn) { 1876 TEST_P(WebRtcSessionTest, TestReceiveNonDtlsOfferWhenDtlsOn) {
1875 InitWithDtls(GetParam()); 1877 InitWithDtls(GetParam());
1876 cricket::MediaSessionOptions options; 1878 cricket::MediaSessionOptions options;
1877 options.recv_video = true; 1879 options.recv_video = true;
1878 options.bundle_enabled = true; 1880 options.bundle_enabled = true;
1879 JsepSessionDescription* offer = CreateRemoteOffer( 1881 JsepSessionDescription* offer = CreateRemoteOffer(
1880 options, cricket::SEC_REQUIRED); 1882 options, cricket::SEC_REQUIRED);
1881 ASSERT_TRUE(offer != NULL); 1883 ASSERT_TRUE(offer != nullptr);
1882 VerifyFingerprintStatus(offer->description(), false); 1884 VerifyFingerprintStatus(offer->description(), false);
1883 VerifyCryptoParams(offer->description()); 1885 VerifyCryptoParams(offer->description());
1884 1886
1885 // SetRemoteDescription will take the ownership of the offer. 1887 // SetRemoteDescription will take the ownership of the offer.
1886 SetRemoteDescriptionOfferExpectError( 1888 SetRemoteDescriptionOfferExpectError(
1887 kSdpWithoutDtlsFingerprint, offer); 1889 kSdpWithoutDtlsFingerprint, offer);
1888 1890
1889 offer = CreateRemoteOffer(options, cricket::SEC_REQUIRED); 1891 offer = CreateRemoteOffer(options, cricket::SEC_REQUIRED);
1890 // SetLocalDescription will take the ownership of the offer. 1892 // SetLocalDescription will take the ownership of the offer.
1891 SetLocalDescriptionOfferExpectError( 1893 SetLocalDescriptionOfferExpectError(
1892 kSdpWithoutDtlsFingerprint, offer); 1894 kSdpWithoutDtlsFingerprint, offer);
1893 } 1895 }
1894 1896
1895 // Test that we return a failure when applying a local answer that doesn't have 1897 // Test that we return a failure when applying a local answer that doesn't have
1896 // a DTLS fingerprint when DTLS is required. 1898 // a DTLS fingerprint when DTLS is required.
1897 TEST_P(WebRtcSessionTest, TestSetLocalNonDtlsAnswerWhenDtlsOn) { 1899 TEST_P(WebRtcSessionTest, TestSetLocalNonDtlsAnswerWhenDtlsOn) {
1898 InitWithDtls(GetParam()); 1900 InitWithDtls(GetParam());
1899 SessionDescriptionInterface* offer = NULL; 1901 SessionDescriptionInterface* offer = nullptr;
1900 SessionDescriptionInterface* answer = NULL; 1902 SessionDescriptionInterface* answer = nullptr;
1901 CreateDtlsOfferAndNonDtlsAnswer(&offer, &answer); 1903 CreateDtlsOfferAndNonDtlsAnswer(&offer, &answer);
1902 1904
1903 // SetRemoteDescription and SetLocalDescription will take the ownership of 1905 // SetRemoteDescription and SetLocalDescription will take the ownership of
1904 // the offer and answer. 1906 // the offer and answer.
1905 SetRemoteDescriptionWithoutError(offer); 1907 SetRemoteDescriptionWithoutError(offer);
1906 SetLocalDescriptionAnswerExpectError( 1908 SetLocalDescriptionAnswerExpectError(
1907 kSdpWithoutDtlsFingerprint, answer); 1909 kSdpWithoutDtlsFingerprint, answer);
1908 } 1910 }
1909 1911
1910 // Test that we return a failure when applying a remote answer that doesn't have 1912 // Test that we return a failure when applying a remote answer that doesn't have
(...skipping 17 matching lines...) Expand all
1928 1930
1929 // Test that we create a local offer without SDES or DTLS and accept a remote 1931 // Test that we create a local offer without SDES or DTLS and accept a remote
1930 // answer without SDES or DTLS when encryption is disabled. 1932 // answer without SDES or DTLS when encryption is disabled.
1931 TEST_P(WebRtcSessionTest, TestCreateOfferReceiveAnswerWithoutEncryption) { 1933 TEST_P(WebRtcSessionTest, TestCreateOfferReceiveAnswerWithoutEncryption) {
1932 SendAudioVideoStream1(); 1934 SendAudioVideoStream1();
1933 options_.disable_encryption = true; 1935 options_.disable_encryption = true;
1934 InitWithDtls(GetParam()); 1936 InitWithDtls(GetParam());
1935 1937
1936 // Verify that we get a crypto fingerprint in the answer. 1938 // Verify that we get a crypto fingerprint in the answer.
1937 SessionDescriptionInterface* offer = CreateOffer(); 1939 SessionDescriptionInterface* offer = CreateOffer();
1938 ASSERT_TRUE(offer != NULL); 1940 ASSERT_TRUE(offer != nullptr);
1939 VerifyFingerprintStatus(offer->description(), false); 1941 VerifyFingerprintStatus(offer->description(), false);
1940 // Check that we don't have an a=crypto line in the offer. 1942 // Check that we don't have an a=crypto line in the offer.
1941 VerifyNoCryptoParams(offer->description(), false); 1943 VerifyNoCryptoParams(offer->description(), false);
1942 1944
1943 // Now set the local description, which should work, even without a=crypto. 1945 // Now set the local description, which should work, even without a=crypto.
1944 SetLocalDescriptionWithoutError(offer); 1946 SetLocalDescriptionWithoutError(offer);
1945 1947
1946 cricket::MediaSessionOptions options; 1948 cricket::MediaSessionOptions options;
1947 options.recv_video = true; 1949 options.recv_video = true;
1948 JsepSessionDescription* answer = 1950 JsepSessionDescription* answer =
1949 CreateRemoteAnswer(offer, options, cricket::SEC_DISABLED); 1951 CreateRemoteAnswer(offer, options, cricket::SEC_DISABLED);
1950 ASSERT_TRUE(answer != NULL); 1952 ASSERT_TRUE(answer != nullptr);
1951 VerifyFingerprintStatus(answer->description(), false); 1953 VerifyFingerprintStatus(answer->description(), false);
1952 VerifyNoCryptoParams(answer->description(), false); 1954 VerifyNoCryptoParams(answer->description(), false);
1953 1955
1954 // SetRemoteDescription will take the ownership of the answer. 1956 // SetRemoteDescription will take the ownership of the answer.
1955 SetRemoteDescriptionWithoutError(answer); 1957 SetRemoteDescriptionWithoutError(answer);
1956 } 1958 }
1957 1959
1958 // Test that we create a local answer without SDES or DTLS and accept a remote 1960 // Test that we create a local answer without SDES or DTLS and accept a remote
1959 // offer without SDES or DTLS when encryption is disabled. 1961 // offer without SDES or DTLS when encryption is disabled.
1960 TEST_P(WebRtcSessionTest, TestCreateAnswerReceiveOfferWithoutEncryption) { 1962 TEST_P(WebRtcSessionTest, TestCreateAnswerReceiveOfferWithoutEncryption) {
1961 options_.disable_encryption = true; 1963 options_.disable_encryption = true;
1962 InitWithDtls(GetParam()); 1964 InitWithDtls(GetParam());
1963 1965
1964 cricket::MediaSessionOptions options; 1966 cricket::MediaSessionOptions options;
1965 options.recv_video = true; 1967 options.recv_video = true;
1966 JsepSessionDescription* offer = 1968 JsepSessionDescription* offer =
1967 CreateRemoteOffer(options, cricket::SEC_DISABLED); 1969 CreateRemoteOffer(options, cricket::SEC_DISABLED);
1968 ASSERT_TRUE(offer != NULL); 1970 ASSERT_TRUE(offer != nullptr);
1969 VerifyFingerprintStatus(offer->description(), false); 1971 VerifyFingerprintStatus(offer->description(), false);
1970 VerifyNoCryptoParams(offer->description(), false); 1972 VerifyNoCryptoParams(offer->description(), false);
1971 1973
1972 // SetRemoteDescription will take the ownership of the offer. 1974 // SetRemoteDescription will take the ownership of the offer.
1973 SetRemoteDescriptionWithoutError(offer); 1975 SetRemoteDescriptionWithoutError(offer);
1974 1976
1975 // Verify that we get a crypto fingerprint in the answer. 1977 // Verify that we get a crypto fingerprint in the answer.
1976 SessionDescriptionInterface* answer = CreateAnswer(); 1978 SessionDescriptionInterface* answer = CreateAnswer();
1977 ASSERT_TRUE(answer != NULL); 1979 ASSERT_TRUE(answer != nullptr);
1978 VerifyFingerprintStatus(answer->description(), false); 1980 VerifyFingerprintStatus(answer->description(), false);
1979 // Check that we don't have an a=crypto line in the answer. 1981 // Check that we don't have an a=crypto line in the answer.
1980 VerifyNoCryptoParams(answer->description(), false); 1982 VerifyNoCryptoParams(answer->description(), false);
1981 1983
1982 // Now set the local description, which should work, even without a=crypto. 1984 // Now set the local description, which should work, even without a=crypto.
1983 SetLocalDescriptionWithoutError(answer); 1985 SetLocalDescriptionWithoutError(answer);
1984 } 1986 }
1985 1987
1986 // Test that we can create and set an answer correctly when different 1988 // Test that we can create and set an answer correctly when different
1987 // SSL roles have been negotiated for different transports. 1989 // SSL roles have been negotiated for different transports.
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
2184 2186
2185 EXPECT_TRUE(session_->ProcessIceMessage(&ice_candidate1)); 2187 EXPECT_TRUE(session_->ProcessIceMessage(&ice_candidate1));
2186 candidate.set_component(2); 2188 candidate.set_component(2);
2187 candidate.set_address(rtc::SocketAddress("2.2.2.2", 6000)); 2189 candidate.set_address(rtc::SocketAddress("2.2.2.2", 6000));
2188 JsepIceCandidate ice_candidate2(kMediaContentName0, 0, candidate); 2190 JsepIceCandidate ice_candidate2(kMediaContentName0, 0, candidate);
2189 EXPECT_TRUE(session_->ProcessIceMessage(&ice_candidate2)); 2191 EXPECT_TRUE(session_->ProcessIceMessage(&ice_candidate2));
2190 2192
2191 // Verifying the candidates are copied properly from internal vector. 2193 // Verifying the candidates are copied properly from internal vector.
2192 const SessionDescriptionInterface* remote_desc = 2194 const SessionDescriptionInterface* remote_desc =
2193 session_->remote_description(); 2195 session_->remote_description();
2194 ASSERT_TRUE(remote_desc != NULL); 2196 ASSERT_TRUE(remote_desc != nullptr);
2195 ASSERT_EQ(2u, remote_desc->number_of_mediasections()); 2197 ASSERT_EQ(2u, remote_desc->number_of_mediasections());
2196 const IceCandidateCollection* candidates = 2198 const IceCandidateCollection* candidates =
2197 remote_desc->candidates(kMediaContentIndex0); 2199 remote_desc->candidates(kMediaContentIndex0);
2198 ASSERT_EQ(2u, candidates->count()); 2200 ASSERT_EQ(2u, candidates->count());
2199 EXPECT_EQ(kMediaContentIndex0, candidates->at(0)->sdp_mline_index()); 2201 EXPECT_EQ(kMediaContentIndex0, candidates->at(0)->sdp_mline_index());
2200 EXPECT_EQ(kMediaContentName0, candidates->at(0)->sdp_mid()); 2202 EXPECT_EQ(kMediaContentName0, candidates->at(0)->sdp_mid());
2201 EXPECT_EQ(1, candidates->at(0)->candidate().component()); 2203 EXPECT_EQ(1, candidates->at(0)->candidate().component());
2202 EXPECT_EQ(2, candidates->at(1)->candidate().component()); 2204 EXPECT_EQ(2, candidates->at(1)->candidate().component());
2203 2205
2204 // |ice_candidate3| is identical to |ice_candidate2|. It can be added 2206 // |ice_candidate3| is identical to |ice_candidate2|. It can be added
(...skipping 21 matching lines...) Expand all
2226 cricket::Candidate candidate1; 2228 cricket::Candidate candidate1;
2227 candidate1.set_component(1); 2229 candidate1.set_component(1);
2228 JsepIceCandidate ice_candidate1(kMediaContentName0, kMediaContentIndex0, 2230 JsepIceCandidate ice_candidate1(kMediaContentName0, kMediaContentIndex0,
2229 candidate1); 2231 candidate1);
2230 SendAudioVideoStream1(); 2232 SendAudioVideoStream1();
2231 CreateAndSetRemoteOfferAndLocalAnswer(); 2233 CreateAndSetRemoteOfferAndLocalAnswer();
2232 2234
2233 EXPECT_TRUE(session_->ProcessIceMessage(&ice_candidate1)); 2235 EXPECT_TRUE(session_->ProcessIceMessage(&ice_candidate1));
2234 const SessionDescriptionInterface* remote_desc = 2236 const SessionDescriptionInterface* remote_desc =
2235 session_->remote_description(); 2237 session_->remote_description();
2236 ASSERT_TRUE(remote_desc != NULL); 2238 ASSERT_TRUE(remote_desc != nullptr);
2237 ASSERT_EQ(2u, remote_desc->number_of_mediasections()); 2239 ASSERT_EQ(2u, remote_desc->number_of_mediasections());
2238 const IceCandidateCollection* candidates = 2240 const IceCandidateCollection* candidates =
2239 remote_desc->candidates(kMediaContentIndex0); 2241 remote_desc->candidates(kMediaContentIndex0);
2240 ASSERT_EQ(1u, candidates->count()); 2242 ASSERT_EQ(1u, candidates->count());
2241 EXPECT_EQ(kMediaContentIndex0, candidates->at(0)->sdp_mline_index()); 2243 EXPECT_EQ(kMediaContentIndex0, candidates->at(0)->sdp_mline_index());
2242 2244
2243 // Update the RemoteSessionDescription with a new session description and 2245 // Update the RemoteSessionDescription with a new session description and
2244 // a candidate and check that the new remote session description contains both 2246 // a candidate and check that the new remote session description contains both
2245 // candidates. 2247 // candidates.
2246 SessionDescriptionInterface* offer = CreateRemoteOffer(); 2248 SessionDescriptionInterface* offer = CreateRemoteOffer();
2247 cricket::Candidate candidate2; 2249 cricket::Candidate candidate2;
2248 JsepIceCandidate ice_candidate2(kMediaContentName0, kMediaContentIndex0, 2250 JsepIceCandidate ice_candidate2(kMediaContentName0, kMediaContentIndex0,
2249 candidate2); 2251 candidate2);
2250 EXPECT_TRUE(offer->AddCandidate(&ice_candidate2)); 2252 EXPECT_TRUE(offer->AddCandidate(&ice_candidate2));
2251 SetRemoteDescriptionWithoutError(offer); 2253 SetRemoteDescriptionWithoutError(offer);
2252 2254
2253 remote_desc = session_->remote_description(); 2255 remote_desc = session_->remote_description();
2254 ASSERT_TRUE(remote_desc != NULL); 2256 ASSERT_TRUE(remote_desc != nullptr);
2255 ASSERT_EQ(2u, remote_desc->number_of_mediasections()); 2257 ASSERT_EQ(2u, remote_desc->number_of_mediasections());
2256 candidates = remote_desc->candidates(kMediaContentIndex0); 2258 candidates = remote_desc->candidates(kMediaContentIndex0);
2257 ASSERT_EQ(2u, candidates->count()); 2259 ASSERT_EQ(2u, candidates->count());
2258 EXPECT_EQ(kMediaContentIndex0, candidates->at(0)->sdp_mline_index()); 2260 EXPECT_EQ(kMediaContentIndex0, candidates->at(0)->sdp_mline_index());
2259 // Username and password have be updated with the TransportInfo of the 2261 // Username and password have be updated with the TransportInfo of the
2260 // SessionDescription, won't be equal to the original one. 2262 // SessionDescription, won't be equal to the original one.
2261 candidate2.set_username(candidates->at(0)->candidate().username()); 2263 candidate2.set_username(candidates->at(0)->candidate().username());
2262 candidate2.set_password(candidates->at(0)->candidate().password()); 2264 candidate2.set_password(candidates->at(0)->candidate().password());
2263 EXPECT_TRUE(candidate2.IsEquivalent(candidates->at(0)->candidate())); 2265 EXPECT_TRUE(candidate2.IsEquivalent(candidates->at(0)->candidate()));
2264 EXPECT_EQ(kMediaContentIndex0, candidates->at(1)->sdp_mline_index()); 2266 EXPECT_EQ(kMediaContentIndex0, candidates->at(1)->sdp_mline_index());
(...skipping 17 matching lines...) Expand all
2282 // Enable Continual Gathering. 2284 // Enable Continual Gathering.
2283 cricket::IceConfig config; 2285 cricket::IceConfig config;
2284 config.continual_gathering_policy = cricket::GATHER_CONTINUALLY; 2286 config.continual_gathering_policy = cricket::GATHER_CONTINUALLY;
2285 session_->SetIceConfig(config); 2287 session_->SetIceConfig(config);
2286 SendAudioVideoStream1(); 2288 SendAudioVideoStream1();
2287 CreateAndSetRemoteOfferAndLocalAnswer(); 2289 CreateAndSetRemoteOfferAndLocalAnswer();
2288 2290
2289 const SessionDescriptionInterface* local_desc = session_->local_description(); 2291 const SessionDescriptionInterface* local_desc = session_->local_description();
2290 const IceCandidateCollection* candidates = 2292 const IceCandidateCollection* candidates =
2291 local_desc->candidates(kMediaContentIndex0); 2293 local_desc->candidates(kMediaContentIndex0);
2292 ASSERT_TRUE(candidates != NULL); 2294 ASSERT_TRUE(candidates != nullptr);
2293 EXPECT_EQ(0u, candidates->count()); 2295 EXPECT_EQ(0u, candidates->count());
2294 2296
2295 // Since we're using continual gathering, we won't get "gathering done". 2297 // Since we're using continual gathering, we won't get "gathering done".
2296 EXPECT_EQ_WAIT(2u, candidates->count(), kIceCandidatesTimeout); 2298 EXPECT_EQ_WAIT(2u, candidates->count(), kIceCandidatesTimeout);
2297 2299
2298 local_desc = session_->local_description(); 2300 local_desc = session_->local_description();
2299 candidates = local_desc->candidates(kMediaContentIndex0); 2301 candidates = local_desc->candidates(kMediaContentIndex0);
2300 ASSERT_TRUE(candidates != NULL); 2302 ASSERT_TRUE(candidates != nullptr);
2301 EXPECT_LT(0u, candidates->count()); 2303 EXPECT_LT(0u, candidates->count());
2302 candidates = local_desc->candidates(1); 2304 candidates = local_desc->candidates(1);
2303 ASSERT_TRUE(candidates != NULL); 2305 ASSERT_TRUE(candidates != nullptr);
2304 EXPECT_EQ(0u, candidates->count()); 2306 EXPECT_EQ(0u, candidates->count());
2305 2307
2306 // Update the session descriptions. 2308 // Update the session descriptions.
2307 SendAudioVideoStream1(); 2309 SendAudioVideoStream1();
2308 CreateAndSetRemoteOfferAndLocalAnswer(); 2310 CreateAndSetRemoteOfferAndLocalAnswer();
2309 2311
2310 local_desc = session_->local_description(); 2312 local_desc = session_->local_description();
2311 candidates = local_desc->candidates(kMediaContentIndex0); 2313 candidates = local_desc->candidates(kMediaContentIndex0);
2312 ASSERT_TRUE(candidates != NULL); 2314 ASSERT_TRUE(candidates != nullptr);
2313 EXPECT_LT(0u, candidates->count()); 2315 EXPECT_LT(0u, candidates->count());
2314 candidates = local_desc->candidates(1); 2316 candidates = local_desc->candidates(1);
2315 ASSERT_TRUE(candidates != NULL); 2317 ASSERT_TRUE(candidates != nullptr);
2316 EXPECT_EQ(0u, candidates->count()); 2318 EXPECT_EQ(0u, candidates->count());
2317 2319
2318 candidates = local_desc->candidates(kMediaContentIndex0); 2320 candidates = local_desc->candidates(kMediaContentIndex0);
2319 size_t num_local_candidates = candidates->count(); 2321 size_t num_local_candidates = candidates->count();
2320 // Bring down the network interface to trigger candidate removals. 2322 // Bring down the network interface to trigger candidate removals.
2321 RemoveInterface(rtc::SocketAddress(kClientAddrHost1, kClientAddrPort)); 2323 RemoveInterface(rtc::SocketAddress(kClientAddrHost1, kClientAddrPort));
2322 // Verify that all local candidates are removed. 2324 // Verify that all local candidates are removed.
2323 EXPECT_EQ(0, observer_.num_candidates_removed_); 2325 EXPECT_EQ(0, observer_.num_candidates_removed_);
2324 EXPECT_EQ_WAIT(num_local_candidates, observer_.num_candidates_removed_, 2326 EXPECT_EQ_WAIT(num_local_candidates, observer_.num_candidates_removed_,
2325 kIceCandidatesTimeout); 2327 kIceCandidatesTimeout);
2326 EXPECT_EQ_WAIT(0u, candidates->count(), kIceCandidatesTimeout); 2328 EXPECT_EQ_WAIT(0u, candidates->count(), kIceCandidatesTimeout);
2327 } 2329 }
2328 2330
2329 // Tests that if continual gathering is disabled, local candidates won't be 2331 // Tests that if continual gathering is disabled, local candidates won't be
2330 // removed when the interface is turned down. 2332 // removed when the interface is turned down.
2331 TEST_F(WebRtcSessionTest, TestLocalCandidatesNotRemovedIfNotGatherContinually) { 2333 TEST_F(WebRtcSessionTest, TestLocalCandidatesNotRemovedIfNotGatherContinually) {
2332 AddInterface(rtc::SocketAddress(kClientAddrHost1, kClientAddrPort)); 2334 AddInterface(rtc::SocketAddress(kClientAddrHost1, kClientAddrPort));
2333 Init(); 2335 Init();
2334 SendAudioVideoStream1(); 2336 SendAudioVideoStream1();
2335 CreateAndSetRemoteOfferAndLocalAnswer(); 2337 CreateAndSetRemoteOfferAndLocalAnswer();
2336 2338
2337 const SessionDescriptionInterface* local_desc = session_->local_description(); 2339 const SessionDescriptionInterface* local_desc = session_->local_description();
2338 const IceCandidateCollection* candidates = 2340 const IceCandidateCollection* candidates =
2339 local_desc->candidates(kMediaContentIndex0); 2341 local_desc->candidates(kMediaContentIndex0);
2340 ASSERT_TRUE(candidates != NULL); 2342 ASSERT_TRUE(candidates != nullptr);
2341 EXPECT_TRUE_WAIT(observer_.oncandidatesready_, kIceCandidatesTimeout); 2343 EXPECT_TRUE_WAIT(observer_.oncandidatesready_, kIceCandidatesTimeout);
2342 2344
2343 size_t num_local_candidates = candidates->count(); 2345 size_t num_local_candidates = candidates->count();
2344 EXPECT_LT(0u, num_local_candidates); 2346 EXPECT_LT(0u, num_local_candidates);
2345 // By default, Continual Gathering is disabled. 2347 // By default, Continual Gathering is disabled.
2346 // Bring down the network interface. 2348 // Bring down the network interface.
2347 RemoveInterface(rtc::SocketAddress(kClientAddrHost1, kClientAddrPort)); 2349 RemoveInterface(rtc::SocketAddress(kClientAddrHost1, kClientAddrPort));
2348 // Verify that the local candidates are not removed. 2350 // Verify that the local candidates are not removed.
2349 rtc::Thread::Current()->ProcessMessages(1000); 2351 rtc::Thread::Current()->ProcessMessages(1000);
2350 EXPECT_EQ(0, observer_.num_candidates_removed_); 2352 EXPECT_EQ(0, observer_.num_candidates_removed_);
2351 EXPECT_EQ(num_local_candidates, candidates->count()); 2353 EXPECT_EQ(num_local_candidates, candidates->count());
2352 } 2354 }
2353 2355
2354 // Test that we can set a remote session description with remote candidates. 2356 // Test that we can set a remote session description with remote candidates.
2355 TEST_F(WebRtcSessionTest, TestSetRemoteSessionDescriptionWithCandidates) { 2357 TEST_F(WebRtcSessionTest, TestSetRemoteSessionDescriptionWithCandidates) {
2356 Init(); 2358 Init();
2357 2359
2358 cricket::Candidate candidate1; 2360 cricket::Candidate candidate1;
2359 candidate1.set_component(1); 2361 candidate1.set_component(1);
2360 JsepIceCandidate ice_candidate(kMediaContentName0, kMediaContentIndex0, 2362 JsepIceCandidate ice_candidate(kMediaContentName0, kMediaContentIndex0,
2361 candidate1); 2363 candidate1);
2362 SendAudioVideoStream1(); 2364 SendAudioVideoStream1();
2363 SessionDescriptionInterface* offer = CreateOffer(); 2365 SessionDescriptionInterface* offer = CreateOffer();
2364 2366
2365 EXPECT_TRUE(offer->AddCandidate(&ice_candidate)); 2367 EXPECT_TRUE(offer->AddCandidate(&ice_candidate));
2366 SetRemoteDescriptionWithoutError(offer); 2368 SetRemoteDescriptionWithoutError(offer);
2367 2369
2368 const SessionDescriptionInterface* remote_desc = 2370 const SessionDescriptionInterface* remote_desc =
2369 session_->remote_description(); 2371 session_->remote_description();
2370 ASSERT_TRUE(remote_desc != NULL); 2372 ASSERT_TRUE(remote_desc != nullptr);
2371 ASSERT_EQ(2u, remote_desc->number_of_mediasections()); 2373 ASSERT_EQ(2u, remote_desc->number_of_mediasections());
2372 const IceCandidateCollection* candidates = 2374 const IceCandidateCollection* candidates =
2373 remote_desc->candidates(kMediaContentIndex0); 2375 remote_desc->candidates(kMediaContentIndex0);
2374 ASSERT_EQ(1u, candidates->count()); 2376 ASSERT_EQ(1u, candidates->count());
2375 EXPECT_EQ(kMediaContentIndex0, candidates->at(0)->sdp_mline_index()); 2377 EXPECT_EQ(kMediaContentIndex0, candidates->at(0)->sdp_mline_index());
2376 2378
2377 SessionDescriptionInterface* answer = CreateAnswer(); 2379 SessionDescriptionInterface* answer = CreateAnswer();
2378 SetLocalDescriptionWithoutError(answer); 2380 SetLocalDescriptionWithoutError(answer);
2379 } 2381 }
2380 2382
2381 // Test that offers and answers contains ice candidates when Ice candidates have 2383 // Test that offers and answers contains ice candidates when Ice candidates have
2382 // been gathered. 2384 // been gathered.
2383 TEST_F(WebRtcSessionTest, TestSetLocalAndRemoteDescriptionWithCandidates) { 2385 TEST_F(WebRtcSessionTest, TestSetLocalAndRemoteDescriptionWithCandidates) {
2384 AddInterface(rtc::SocketAddress(kClientAddrHost1, kClientAddrPort)); 2386 AddInterface(rtc::SocketAddress(kClientAddrHost1, kClientAddrPort));
2385 Init(); 2387 Init();
2386 SendAudioVideoStream1(); 2388 SendAudioVideoStream1();
2387 // Ice is started but candidates are not provided until SetLocalDescription 2389 // Ice is started but candidates are not provided until SetLocalDescription
2388 // is called. 2390 // is called.
2389 EXPECT_EQ(0u, observer_.mline_0_candidates_.size()); 2391 EXPECT_EQ(0u, observer_.mline_0_candidates_.size());
2390 EXPECT_EQ(0u, observer_.mline_1_candidates_.size()); 2392 EXPECT_EQ(0u, observer_.mline_1_candidates_.size());
2391 CreateAndSetRemoteOfferAndLocalAnswer(); 2393 CreateAndSetRemoteOfferAndLocalAnswer();
2392 // Wait until at least one local candidate has been collected. 2394 // Wait until at least one local candidate has been collected.
2393 EXPECT_TRUE_WAIT(0u < observer_.mline_0_candidates_.size(), 2395 EXPECT_TRUE_WAIT(0u < observer_.mline_0_candidates_.size(),
2394 kIceCandidatesTimeout); 2396 kIceCandidatesTimeout);
2395 2397
2396 std::unique_ptr<SessionDescriptionInterface> local_offer(CreateOffer()); 2398 std::unique_ptr<SessionDescriptionInterface> local_offer(CreateOffer());
2397 2399
2398 ASSERT_TRUE(local_offer->candidates(kMediaContentIndex0) != NULL); 2400 ASSERT_TRUE(local_offer->candidates(kMediaContentIndex0) != nullptr);
2399 EXPECT_LT(0u, local_offer->candidates(kMediaContentIndex0)->count()); 2401 EXPECT_LT(0u, local_offer->candidates(kMediaContentIndex0)->count());
2400 2402
2401 SessionDescriptionInterface* remote_offer(CreateRemoteOffer()); 2403 SessionDescriptionInterface* remote_offer(CreateRemoteOffer());
2402 SetRemoteDescriptionWithoutError(remote_offer); 2404 SetRemoteDescriptionWithoutError(remote_offer);
2403 SessionDescriptionInterface* answer = CreateAnswer(); 2405 SessionDescriptionInterface* answer = CreateAnswer();
2404 ASSERT_TRUE(answer->candidates(kMediaContentIndex0) != NULL); 2406 ASSERT_TRUE(answer->candidates(kMediaContentIndex0) != nullptr);
2405 EXPECT_LT(0u, answer->candidates(kMediaContentIndex0)->count()); 2407 EXPECT_LT(0u, answer->candidates(kMediaContentIndex0)->count());
2406 SetLocalDescriptionWithoutError(answer); 2408 SetLocalDescriptionWithoutError(answer);
2407 } 2409 }
2408 2410
2409 // Verifies TransportProxy and media channels are created with content names 2411 // Verifies TransportProxy and media channels are created with content names
2410 // present in the SessionDescription. 2412 // present in the SessionDescription.
2411 TEST_F(WebRtcSessionTest, TestChannelCreationsWithContentNames) { 2413 TEST_F(WebRtcSessionTest, TestChannelCreationsWithContentNames) {
2412 Init(); 2414 Init();
2413 SendAudioVideoStream1(); 2415 SendAudioVideoStream1();
2414 std::unique_ptr<SessionDescriptionInterface> offer(CreateOffer()); 2416 std::unique_ptr<SessionDescriptionInterface> offer(CreateOffer());
(...skipping 15 matching lines...) Expand all
2430 kAudioMidReplaceStr.c_str(), 2432 kAudioMidReplaceStr.c_str(),
2431 kAudioMidReplaceStr.length(), 2433 kAudioMidReplaceStr.length(),
2432 &sdp); 2434 &sdp);
2433 // Replacing |video| with |video_content_name|. 2435 // Replacing |video| with |video_content_name|.
2434 rtc::replace_substrs(kVideoMid.c_str(), kVideoMid.length(), 2436 rtc::replace_substrs(kVideoMid.c_str(), kVideoMid.length(),
2435 kVideoMidReplaceStr.c_str(), 2437 kVideoMidReplaceStr.c_str(),
2436 kVideoMidReplaceStr.length(), 2438 kVideoMidReplaceStr.length(),
2437 &sdp); 2439 &sdp);
2438 2440
2439 SessionDescriptionInterface* modified_offer = 2441 SessionDescriptionInterface* modified_offer =
2440 CreateSessionDescription(JsepSessionDescription::kOffer, sdp, NULL); 2442 CreateSessionDescription(JsepSessionDescription::kOffer, sdp, nullptr);
2441 2443
2442 SetRemoteDescriptionWithoutError(modified_offer); 2444 SetRemoteDescriptionWithoutError(modified_offer);
2443 2445
2444 SessionDescriptionInterface* answer = CreateAnswer(); 2446 SessionDescriptionInterface* answer = CreateAnswer();
2445 SetLocalDescriptionWithoutError(answer); 2447 SetLocalDescriptionWithoutError(answer);
2446 2448
2447 rtc::PacketTransportInternal* voice_transport_channel = 2449 rtc::PacketTransportInternal* voice_transport_channel =
2448 session_->voice_rtp_transport_channel(); 2450 session_->voice_rtp_transport_channel();
2449 EXPECT_TRUE(voice_transport_channel != NULL); 2451 EXPECT_TRUE(voice_transport_channel != nullptr);
2450 EXPECT_EQ(voice_transport_channel->debug_name(), 2452 EXPECT_EQ(voice_transport_channel->debug_name(),
2451 "audio_content_name " + 2453 "audio_content_name " +
2452 std::to_string(cricket::ICE_CANDIDATE_COMPONENT_RTP)); 2454 std::to_string(cricket::ICE_CANDIDATE_COMPONENT_RTP));
2453 rtc::PacketTransportInternal* video_transport_channel = 2455 rtc::PacketTransportInternal* video_transport_channel =
2454 session_->video_rtp_transport_channel(); 2456 session_->video_rtp_transport_channel();
2455 ASSERT_TRUE(video_transport_channel != NULL); 2457 ASSERT_TRUE(video_transport_channel != nullptr);
2456 EXPECT_EQ(video_transport_channel->debug_name(), 2458 EXPECT_EQ(video_transport_channel->debug_name(),
2457 "video_content_name " + 2459 "video_content_name " +
2458 std::to_string(cricket::ICE_CANDIDATE_COMPONENT_RTP)); 2460 std::to_string(cricket::ICE_CANDIDATE_COMPONENT_RTP));
2459 EXPECT_TRUE((video_channel_ = media_engine_->GetVideoChannel(0)) != NULL); 2461 EXPECT_TRUE((video_channel_ = media_engine_->GetVideoChannel(0)) != nullptr);
2460 EXPECT_TRUE((voice_channel_ = media_engine_->GetVoiceChannel(0)) != NULL); 2462 EXPECT_TRUE((voice_channel_ = media_engine_->GetVoiceChannel(0)) != nullptr);
2461 } 2463 }
2462 2464
2463 // Test that an offer contains the correct media content descriptions based on 2465 // Test that an offer contains the correct media content descriptions based on
2464 // the send streams when no constraints have been set. 2466 // the send streams when no constraints have been set.
2465 TEST_F(WebRtcSessionTest, CreateOfferWithoutConstraintsOrStreams) { 2467 TEST_F(WebRtcSessionTest, CreateOfferWithoutConstraintsOrStreams) {
2466 Init(); 2468 Init();
2467 std::unique_ptr<SessionDescriptionInterface> offer(CreateOffer()); 2469 std::unique_ptr<SessionDescriptionInterface> offer(CreateOffer());
2468 2470
2469 ASSERT_TRUE(offer != NULL); 2471 ASSERT_TRUE(offer != nullptr);
2470 const cricket::ContentInfo* content = 2472 const cricket::ContentInfo* content =
2471 cricket::GetFirstAudioContent(offer->description()); 2473 cricket::GetFirstAudioContent(offer->description());
2472 EXPECT_TRUE(content != NULL); 2474 EXPECT_TRUE(content != nullptr);
2473 content = cricket::GetFirstVideoContent(offer->description()); 2475 content = cricket::GetFirstVideoContent(offer->description());
2474 EXPECT_TRUE(content == NULL); 2476 EXPECT_TRUE(content == nullptr);
2475 } 2477 }
2476 2478
2477 // Test that an offer contains the correct media content descriptions based on 2479 // Test that an offer contains the correct media content descriptions based on
2478 // the send streams when no constraints have been set. 2480 // the send streams when no constraints have been set.
2479 TEST_F(WebRtcSessionTest, CreateOfferWithoutConstraints) { 2481 TEST_F(WebRtcSessionTest, CreateOfferWithoutConstraints) {
2480 Init(); 2482 Init();
2481 // Test Audio only offer. 2483 // Test Audio only offer.
2482 SendAudioOnlyStream2(); 2484 SendAudioOnlyStream2();
2483 std::unique_ptr<SessionDescriptionInterface> offer(CreateOffer()); 2485 std::unique_ptr<SessionDescriptionInterface> offer(CreateOffer());
2484 2486
2485 const cricket::ContentInfo* content = 2487 const cricket::ContentInfo* content =
2486 cricket::GetFirstAudioContent(offer->description()); 2488 cricket::GetFirstAudioContent(offer->description());
2487 EXPECT_TRUE(content != NULL); 2489 EXPECT_TRUE(content != nullptr);
2488 content = cricket::GetFirstVideoContent(offer->description()); 2490 content = cricket::GetFirstVideoContent(offer->description());
2489 EXPECT_TRUE(content == NULL); 2491 EXPECT_TRUE(content == nullptr);
2490 2492
2491 // Test Audio / Video offer. 2493 // Test Audio / Video offer.
2492 SendAudioVideoStream1(); 2494 SendAudioVideoStream1();
2493 offer.reset(CreateOffer()); 2495 offer.reset(CreateOffer());
2494 content = cricket::GetFirstAudioContent(offer->description()); 2496 content = cricket::GetFirstAudioContent(offer->description());
2495 EXPECT_TRUE(content != NULL); 2497 EXPECT_TRUE(content != nullptr);
2496 content = cricket::GetFirstVideoContent(offer->description()); 2498 content = cricket::GetFirstVideoContent(offer->description());
2497 EXPECT_TRUE(content != NULL); 2499 EXPECT_TRUE(content != nullptr);
2498 } 2500 }
2499 2501
2500 // Test that an offer contains no media content descriptions if 2502 // Test that an offer contains no media content descriptions if
2501 // kOfferToReceiveVideo and kOfferToReceiveAudio constraints are set to false. 2503 // kOfferToReceiveVideo and kOfferToReceiveAudio constraints are set to false.
2502 TEST_F(WebRtcSessionTest, CreateOfferWithConstraintsWithoutStreams) { 2504 TEST_F(WebRtcSessionTest, CreateOfferWithConstraintsWithoutStreams) {
2503 Init(); 2505 Init();
2504 PeerConnectionInterface::RTCOfferAnswerOptions options; 2506 PeerConnectionInterface::RTCOfferAnswerOptions options;
2505 options.offer_to_receive_audio = 0; 2507 options.offer_to_receive_audio = 0;
2506 options.offer_to_receive_video = 0; 2508 options.offer_to_receive_video = 0;
2507 2509
2508 std::unique_ptr<SessionDescriptionInterface> offer(CreateOffer(options)); 2510 std::unique_ptr<SessionDescriptionInterface> offer(CreateOffer(options));
2509 2511
2510 ASSERT_TRUE(offer != NULL); 2512 ASSERT_TRUE(offer != nullptr);
2511 const cricket::ContentInfo* content = 2513 const cricket::ContentInfo* content =
2512 cricket::GetFirstAudioContent(offer->description()); 2514 cricket::GetFirstAudioContent(offer->description());
2513 EXPECT_TRUE(content == NULL); 2515 EXPECT_TRUE(content == nullptr);
2514 content = cricket::GetFirstVideoContent(offer->description()); 2516 content = cricket::GetFirstVideoContent(offer->description());
2515 EXPECT_TRUE(content == NULL); 2517 EXPECT_TRUE(content == nullptr);
2516 } 2518 }
2517 2519
2518 // Test that an offer contains only audio media content descriptions if 2520 // Test that an offer contains only audio media content descriptions if
2519 // kOfferToReceiveAudio constraints are set to true. 2521 // kOfferToReceiveAudio constraints are set to true.
2520 TEST_F(WebRtcSessionTest, CreateAudioOnlyOfferWithConstraints) { 2522 TEST_F(WebRtcSessionTest, CreateAudioOnlyOfferWithConstraints) {
2521 Init(); 2523 Init();
2522 PeerConnectionInterface::RTCOfferAnswerOptions options; 2524 PeerConnectionInterface::RTCOfferAnswerOptions options;
2523 options.offer_to_receive_audio = 2525 options.offer_to_receive_audio =
2524 RTCOfferAnswerOptions::kOfferToReceiveMediaTrue; 2526 RTCOfferAnswerOptions::kOfferToReceiveMediaTrue;
2525 2527
2526 std::unique_ptr<SessionDescriptionInterface> offer(CreateOffer(options)); 2528 std::unique_ptr<SessionDescriptionInterface> offer(CreateOffer(options));
2527 2529
2528 const cricket::ContentInfo* content = 2530 const cricket::ContentInfo* content =
2529 cricket::GetFirstAudioContent(offer->description()); 2531 cricket::GetFirstAudioContent(offer->description());
2530 EXPECT_TRUE(content != NULL); 2532 EXPECT_TRUE(content != nullptr);
2531 content = cricket::GetFirstVideoContent(offer->description()); 2533 content = cricket::GetFirstVideoContent(offer->description());
2532 EXPECT_TRUE(content == NULL); 2534 EXPECT_TRUE(content == nullptr);
2533 } 2535 }
2534 2536
2535 // Test that an offer contains audio and video media content descriptions if 2537 // Test that an offer contains audio and video media content descriptions if
2536 // kOfferToReceiveAudio and kOfferToReceiveVideo constraints are set to true. 2538 // kOfferToReceiveAudio and kOfferToReceiveVideo constraints are set to true.
2537 TEST_F(WebRtcSessionTest, CreateOfferWithConstraints) { 2539 TEST_F(WebRtcSessionTest, CreateOfferWithConstraints) {
2538 Init(); 2540 Init();
2539 // Test Audio / Video offer. 2541 // Test Audio / Video offer.
2540 PeerConnectionInterface::RTCOfferAnswerOptions options; 2542 PeerConnectionInterface::RTCOfferAnswerOptions options;
2541 options.offer_to_receive_audio = 2543 options.offer_to_receive_audio =
2542 RTCOfferAnswerOptions::kOfferToReceiveMediaTrue; 2544 RTCOfferAnswerOptions::kOfferToReceiveMediaTrue;
2543 options.offer_to_receive_video = 2545 options.offer_to_receive_video =
2544 RTCOfferAnswerOptions::kOfferToReceiveMediaTrue; 2546 RTCOfferAnswerOptions::kOfferToReceiveMediaTrue;
2545 2547
2546 std::unique_ptr<SessionDescriptionInterface> offer(CreateOffer(options)); 2548 std::unique_ptr<SessionDescriptionInterface> offer(CreateOffer(options));
2547 2549
2548 const cricket::ContentInfo* content = 2550 const cricket::ContentInfo* content =
2549 cricket::GetFirstAudioContent(offer->description()); 2551 cricket::GetFirstAudioContent(offer->description());
2550 EXPECT_TRUE(content != NULL); 2552 EXPECT_TRUE(content != nullptr);
2551 2553
2552 content = cricket::GetFirstVideoContent(offer->description()); 2554 content = cricket::GetFirstVideoContent(offer->description());
2553 EXPECT_TRUE(content != NULL); 2555 EXPECT_TRUE(content != nullptr);
2554 2556
2555 // Sets constraints to false and verifies that audio/video contents are 2557 // Sets constraints to false and verifies that audio/video contents are
2556 // removed. 2558 // removed.
2557 options.offer_to_receive_audio = 0; 2559 options.offer_to_receive_audio = 0;
2558 options.offer_to_receive_video = 0; 2560 options.offer_to_receive_video = 0;
2559 offer.reset(CreateOffer(options)); 2561 offer.reset(CreateOffer(options));
2560 2562
2561 content = cricket::GetFirstAudioContent(offer->description()); 2563 content = cricket::GetFirstAudioContent(offer->description());
2562 EXPECT_TRUE(content == NULL); 2564 EXPECT_TRUE(content == nullptr);
2563 content = cricket::GetFirstVideoContent(offer->description()); 2565 content = cricket::GetFirstVideoContent(offer->description());
2564 EXPECT_TRUE(content == NULL); 2566 EXPECT_TRUE(content == nullptr);
2565 } 2567 }
2566 2568
2567 // Test that an answer can not be created if the last remote description is not 2569 // Test that an answer can not be created if the last remote description is not
2568 // an offer. 2570 // an offer.
2569 TEST_F(WebRtcSessionTest, CreateAnswerWithoutAnOffer) { 2571 TEST_F(WebRtcSessionTest, CreateAnswerWithoutAnOffer) {
2570 Init(); 2572 Init();
2571 SessionDescriptionInterface* offer = CreateOffer(); 2573 SessionDescriptionInterface* offer = CreateOffer();
2572 SetLocalDescriptionWithoutError(offer); 2574 SetLocalDescriptionWithoutError(offer);
2573 SessionDescriptionInterface* answer = CreateRemoteAnswer(offer); 2575 SessionDescriptionInterface* answer = CreateRemoteAnswer(offer);
2574 SetRemoteDescriptionWithoutError(answer); 2576 SetRemoteDescriptionWithoutError(answer);
2575 EXPECT_TRUE(CreateAnswer() == NULL); 2577 EXPECT_TRUE(CreateAnswer() == nullptr);
2576 } 2578 }
2577 2579
2578 // Test that an answer contains the correct media content descriptions when no 2580 // Test that an answer contains the correct media content descriptions when no
2579 // constraints have been set. 2581 // constraints have been set.
2580 TEST_F(WebRtcSessionTest, CreateAnswerWithoutConstraintsOrStreams) { 2582 TEST_F(WebRtcSessionTest, CreateAnswerWithoutConstraintsOrStreams) {
2581 Init(); 2583 Init();
2582 // Create a remote offer with audio and video content. 2584 // Create a remote offer with audio and video content.
2583 std::unique_ptr<JsepSessionDescription> offer(CreateRemoteOffer()); 2585 std::unique_ptr<JsepSessionDescription> offer(CreateRemoteOffer());
2584 SetRemoteDescriptionWithoutError(offer.release()); 2586 SetRemoteDescriptionWithoutError(offer.release());
2585 std::unique_ptr<SessionDescriptionInterface> answer(CreateAnswer()); 2587 std::unique_ptr<SessionDescriptionInterface> answer(CreateAnswer());
2586 const cricket::ContentInfo* content = 2588 const cricket::ContentInfo* content =
2587 cricket::GetFirstAudioContent(answer->description()); 2589 cricket::GetFirstAudioContent(answer->description());
2588 ASSERT_TRUE(content != NULL); 2590 ASSERT_TRUE(content != nullptr);
2589 EXPECT_FALSE(content->rejected); 2591 EXPECT_FALSE(content->rejected);
2590 2592
2591 content = cricket::GetFirstVideoContent(answer->description()); 2593 content = cricket::GetFirstVideoContent(answer->description());
2592 ASSERT_TRUE(content != NULL); 2594 ASSERT_TRUE(content != nullptr);
2593 EXPECT_FALSE(content->rejected); 2595 EXPECT_FALSE(content->rejected);
2594 } 2596 }
2595 2597
2596 // Test that an answer contains the correct media content descriptions when no 2598 // Test that an answer contains the correct media content descriptions when no
2597 // constraints have been set and the offer only contain audio. 2599 // constraints have been set and the offer only contain audio.
2598 TEST_F(WebRtcSessionTest, CreateAudioAnswerWithoutConstraintsOrStreams) { 2600 TEST_F(WebRtcSessionTest, CreateAudioAnswerWithoutConstraintsOrStreams) {
2599 Init(); 2601 Init();
2600 // Create a remote offer with audio only. 2602 // Create a remote offer with audio only.
2601 cricket::MediaSessionOptions options; 2603 cricket::MediaSessionOptions options;
2602 2604
2603 std::unique_ptr<JsepSessionDescription> offer(CreateRemoteOffer(options)); 2605 std::unique_ptr<JsepSessionDescription> offer(CreateRemoteOffer(options));
2604 ASSERT_TRUE(cricket::GetFirstVideoContent(offer->description()) == NULL); 2606 ASSERT_TRUE(cricket::GetFirstVideoContent(offer->description()) == nullptr);
2605 ASSERT_TRUE(cricket::GetFirstAudioContent(offer->description()) != NULL); 2607 ASSERT_TRUE(cricket::GetFirstAudioContent(offer->description()) != nullptr);
2606 2608
2607 SetRemoteDescriptionWithoutError(offer.release()); 2609 SetRemoteDescriptionWithoutError(offer.release());
2608 std::unique_ptr<SessionDescriptionInterface> answer(CreateAnswer()); 2610 std::unique_ptr<SessionDescriptionInterface> answer(CreateAnswer());
2609 const cricket::ContentInfo* content = 2611 const cricket::ContentInfo* content =
2610 cricket::GetFirstAudioContent(answer->description()); 2612 cricket::GetFirstAudioContent(answer->description());
2611 ASSERT_TRUE(content != NULL); 2613 ASSERT_TRUE(content != nullptr);
2612 EXPECT_FALSE(content->rejected); 2614 EXPECT_FALSE(content->rejected);
2613 2615
2614 EXPECT_TRUE(cricket::GetFirstVideoContent(answer->description()) == NULL); 2616 EXPECT_TRUE(cricket::GetFirstVideoContent(answer->description()) == nullptr);
2615 } 2617 }
2616 2618
2617 // Test that an answer contains the correct media content descriptions when no 2619 // Test that an answer contains the correct media content descriptions when no
2618 // constraints have been set. 2620 // constraints have been set.
2619 TEST_F(WebRtcSessionTest, CreateAnswerWithoutConstraints) { 2621 TEST_F(WebRtcSessionTest, CreateAnswerWithoutConstraints) {
2620 Init(); 2622 Init();
2621 // Create a remote offer with audio and video content. 2623 // Create a remote offer with audio and video content.
2622 std::unique_ptr<JsepSessionDescription> offer(CreateRemoteOffer()); 2624 std::unique_ptr<JsepSessionDescription> offer(CreateRemoteOffer());
2623 SetRemoteDescriptionWithoutError(offer.release()); 2625 SetRemoteDescriptionWithoutError(offer.release());
2624 // Test with a stream with tracks. 2626 // Test with a stream with tracks.
2625 SendAudioVideoStream1(); 2627 SendAudioVideoStream1();
2626 std::unique_ptr<SessionDescriptionInterface> answer(CreateAnswer()); 2628 std::unique_ptr<SessionDescriptionInterface> answer(CreateAnswer());
2627 const cricket::ContentInfo* content = 2629 const cricket::ContentInfo* content =
2628 cricket::GetFirstAudioContent(answer->description()); 2630 cricket::GetFirstAudioContent(answer->description());
2629 ASSERT_TRUE(content != NULL); 2631 ASSERT_TRUE(content != nullptr);
2630 EXPECT_FALSE(content->rejected); 2632 EXPECT_FALSE(content->rejected);
2631 2633
2632 content = cricket::GetFirstVideoContent(answer->description()); 2634 content = cricket::GetFirstVideoContent(answer->description());
2633 ASSERT_TRUE(content != NULL); 2635 ASSERT_TRUE(content != nullptr);
2634 EXPECT_FALSE(content->rejected); 2636 EXPECT_FALSE(content->rejected);
2635 } 2637 }
2636 2638
2637 // Test that an answer contains the correct media content descriptions when 2639 // Test that an answer contains the correct media content descriptions when
2638 // constraints have been set but no stream is sent. 2640 // constraints have been set but no stream is sent.
2639 TEST_F(WebRtcSessionTest, CreateAnswerWithConstraintsWithoutStreams) { 2641 TEST_F(WebRtcSessionTest, CreateAnswerWithConstraintsWithoutStreams) {
2640 Init(); 2642 Init();
2641 // Create a remote offer with audio and video content. 2643 // Create a remote offer with audio and video content.
2642 std::unique_ptr<JsepSessionDescription> offer(CreateRemoteOffer()); 2644 std::unique_ptr<JsepSessionDescription> offer(CreateRemoteOffer());
2643 SetRemoteDescriptionWithoutError(offer.release()); 2645 SetRemoteDescriptionWithoutError(offer.release());
2644 2646
2645 cricket::MediaSessionOptions session_options; 2647 cricket::MediaSessionOptions session_options;
2646 session_options.recv_audio = false; 2648 session_options.recv_audio = false;
2647 session_options.recv_video = false; 2649 session_options.recv_video = false;
2648 std::unique_ptr<SessionDescriptionInterface> answer( 2650 std::unique_ptr<SessionDescriptionInterface> answer(
2649 CreateAnswer(session_options)); 2651 CreateAnswer(session_options));
2650 2652
2651 const cricket::ContentInfo* content = 2653 const cricket::ContentInfo* content =
2652 cricket::GetFirstAudioContent(answer->description()); 2654 cricket::GetFirstAudioContent(answer->description());
2653 ASSERT_TRUE(content != NULL); 2655 ASSERT_TRUE(content != nullptr);
2654 EXPECT_TRUE(content->rejected); 2656 EXPECT_TRUE(content->rejected);
2655 2657
2656 content = cricket::GetFirstVideoContent(answer->description()); 2658 content = cricket::GetFirstVideoContent(answer->description());
2657 ASSERT_TRUE(content != NULL); 2659 ASSERT_TRUE(content != nullptr);
2658 EXPECT_TRUE(content->rejected); 2660 EXPECT_TRUE(content->rejected);
2659 } 2661 }
2660 2662
2661 // Test that an answer contains the correct media content descriptions when 2663 // Test that an answer contains the correct media content descriptions when
2662 // constraints have been set and streams are sent. 2664 // constraints have been set and streams are sent.
2663 TEST_F(WebRtcSessionTest, CreateAnswerWithConstraints) { 2665 TEST_F(WebRtcSessionTest, CreateAnswerWithConstraints) {
2664 Init(); 2666 Init();
2665 // Create a remote offer with audio and video content. 2667 // Create a remote offer with audio and video content.
2666 std::unique_ptr<JsepSessionDescription> offer(CreateRemoteOffer()); 2668 std::unique_ptr<JsepSessionDescription> offer(CreateRemoteOffer());
2667 SetRemoteDescriptionWithoutError(offer.release()); 2669 SetRemoteDescriptionWithoutError(offer.release());
2668 2670
2669 cricket::MediaSessionOptions options; 2671 cricket::MediaSessionOptions options;
2670 options.recv_audio = false; 2672 options.recv_audio = false;
2671 options.recv_video = false; 2673 options.recv_video = false;
2672 2674
2673 // Test with a stream with tracks. 2675 // Test with a stream with tracks.
2674 SendAudioVideoStream1(); 2676 SendAudioVideoStream1();
2675 std::unique_ptr<SessionDescriptionInterface> answer(CreateAnswer(options)); 2677 std::unique_ptr<SessionDescriptionInterface> answer(CreateAnswer(options));
2676 2678
2677 // TODO(perkj): Should the direction be set to SEND_ONLY? 2679 // TODO(perkj): Should the direction be set to SEND_ONLY?
2678 const cricket::ContentInfo* content = 2680 const cricket::ContentInfo* content =
2679 cricket::GetFirstAudioContent(answer->description()); 2681 cricket::GetFirstAudioContent(answer->description());
2680 ASSERT_TRUE(content != NULL); 2682 ASSERT_TRUE(content != nullptr);
2681 EXPECT_FALSE(content->rejected); 2683 EXPECT_FALSE(content->rejected);
2682 2684
2683 // TODO(perkj): Should the direction be set to SEND_ONLY? 2685 // TODO(perkj): Should the direction be set to SEND_ONLY?
2684 content = cricket::GetFirstVideoContent(answer->description()); 2686 content = cricket::GetFirstVideoContent(answer->description());
2685 ASSERT_TRUE(content != NULL); 2687 ASSERT_TRUE(content != nullptr);
2686 EXPECT_FALSE(content->rejected); 2688 EXPECT_FALSE(content->rejected);
2687 } 2689 }
2688 2690
2689 TEST_F(WebRtcSessionTest, CreateOfferWithoutCNCodecs) { 2691 TEST_F(WebRtcSessionTest, CreateOfferWithoutCNCodecs) {
2690 AddCNCodecs(); 2692 AddCNCodecs();
2691 Init(); 2693 Init();
2692 PeerConnectionInterface::RTCOfferAnswerOptions options; 2694 PeerConnectionInterface::RTCOfferAnswerOptions options;
2693 options.offer_to_receive_audio = 2695 options.offer_to_receive_audio =
2694 RTCOfferAnswerOptions::kOfferToReceiveMediaTrue; 2696 RTCOfferAnswerOptions::kOfferToReceiveMediaTrue;
2695 options.voice_activity_detection = false; 2697 options.voice_activity_detection = false;
2696 2698
2697 std::unique_ptr<SessionDescriptionInterface> offer(CreateOffer(options)); 2699 std::unique_ptr<SessionDescriptionInterface> offer(CreateOffer(options));
2698 2700
2699 const cricket::ContentInfo* content = 2701 const cricket::ContentInfo* content =
2700 cricket::GetFirstAudioContent(offer->description()); 2702 cricket::GetFirstAudioContent(offer->description());
2701 EXPECT_TRUE(content != NULL); 2703 EXPECT_TRUE(content != nullptr);
2702 EXPECT_TRUE(VerifyNoCNCodecs(content)); 2704 EXPECT_TRUE(VerifyNoCNCodecs(content));
2703 } 2705 }
2704 2706
2705 TEST_F(WebRtcSessionTest, CreateAnswerWithoutCNCodecs) { 2707 TEST_F(WebRtcSessionTest, CreateAnswerWithoutCNCodecs) {
2706 AddCNCodecs(); 2708 AddCNCodecs();
2707 Init(); 2709 Init();
2708 // Create a remote offer with audio and video content. 2710 // Create a remote offer with audio and video content.
2709 std::unique_ptr<JsepSessionDescription> offer(CreateRemoteOffer()); 2711 std::unique_ptr<JsepSessionDescription> offer(CreateRemoteOffer());
2710 SetRemoteDescriptionWithoutError(offer.release()); 2712 SetRemoteDescriptionWithoutError(offer.release());
2711 2713
2712 cricket::MediaSessionOptions options; 2714 cricket::MediaSessionOptions options;
2713 options.vad_enabled = false; 2715 options.vad_enabled = false;
2714 std::unique_ptr<SessionDescriptionInterface> answer(CreateAnswer(options)); 2716 std::unique_ptr<SessionDescriptionInterface> answer(CreateAnswer(options));
2715 const cricket::ContentInfo* content = 2717 const cricket::ContentInfo* content =
2716 cricket::GetFirstAudioContent(answer->description()); 2718 cricket::GetFirstAudioContent(answer->description());
2717 ASSERT_TRUE(content != NULL); 2719 ASSERT_TRUE(content != nullptr);
2718 EXPECT_TRUE(VerifyNoCNCodecs(content)); 2720 EXPECT_TRUE(VerifyNoCNCodecs(content));
2719 } 2721 }
2720 2722
2721 // This test verifies the call setup when remote answer with audio only and 2723 // This test verifies the call setup when remote answer with audio only and
2722 // later updates with video. 2724 // later updates with video.
2723 TEST_F(WebRtcSessionTest, TestAVOfferWithAudioOnlyAnswer) { 2725 TEST_F(WebRtcSessionTest, TestAVOfferWithAudioOnlyAnswer) {
2724 Init(); 2726 Init();
2725 EXPECT_TRUE(media_engine_->GetVideoChannel(0) == NULL); 2727 EXPECT_TRUE(media_engine_->GetVideoChannel(0) == nullptr);
2726 EXPECT_TRUE(media_engine_->GetVoiceChannel(0) == NULL); 2728 EXPECT_TRUE(media_engine_->GetVoiceChannel(0) == nullptr);
2727 2729
2728 SendAudioVideoStream1(); 2730 SendAudioVideoStream1();
2729 SessionDescriptionInterface* offer = CreateOffer(); 2731 SessionDescriptionInterface* offer = CreateOffer();
2730 2732
2731 cricket::MediaSessionOptions options; 2733 cricket::MediaSessionOptions options;
2732 SessionDescriptionInterface* answer = CreateRemoteAnswer(offer, options); 2734 SessionDescriptionInterface* answer = CreateRemoteAnswer(offer, options);
2733 2735
2734 // SetLocalDescription and SetRemoteDescriptions takes ownership of offer 2736 // SetLocalDescription and SetRemoteDescriptions takes ownership of offer
2735 // and answer; 2737 // and answer;
2736 SetLocalDescriptionWithoutError(offer); 2738 SetLocalDescriptionWithoutError(offer);
2737 SetRemoteDescriptionWithoutError(answer); 2739 SetRemoteDescriptionWithoutError(answer);
2738 2740
2739 video_channel_ = media_engine_->GetVideoChannel(0); 2741 video_channel_ = media_engine_->GetVideoChannel(0);
2740 voice_channel_ = media_engine_->GetVoiceChannel(0); 2742 voice_channel_ = media_engine_->GetVoiceChannel(0);
2741 2743
2742 ASSERT_TRUE(video_channel_ == NULL); 2744 ASSERT_TRUE(video_channel_ == nullptr);
2743 2745
2744 ASSERT_EQ(0u, voice_channel_->recv_streams().size()); 2746 ASSERT_EQ(0u, voice_channel_->recv_streams().size());
2745 ASSERT_EQ(1u, voice_channel_->send_streams().size()); 2747 ASSERT_EQ(1u, voice_channel_->send_streams().size());
2746 EXPECT_EQ(kAudioTrack1, voice_channel_->send_streams()[0].id); 2748 EXPECT_EQ(kAudioTrack1, voice_channel_->send_streams()[0].id);
2747 2749
2748 // Let the remote end update the session descriptions, with Audio and Video. 2750 // Let the remote end update the session descriptions, with Audio and Video.
2749 SendAudioVideoStream2(); 2751 SendAudioVideoStream2();
2750 CreateAndSetRemoteOfferAndLocalAnswer(); 2752 CreateAndSetRemoteOfferAndLocalAnswer();
2751 2753
2752 video_channel_ = media_engine_->GetVideoChannel(0); 2754 video_channel_ = media_engine_->GetVideoChannel(0);
2753 voice_channel_ = media_engine_->GetVoiceChannel(0); 2755 voice_channel_ = media_engine_->GetVoiceChannel(0);
2754 2756
2755 ASSERT_TRUE(video_channel_ != NULL); 2757 ASSERT_TRUE(video_channel_ != nullptr);
2756 ASSERT_TRUE(voice_channel_ != NULL); 2758 ASSERT_TRUE(voice_channel_ != nullptr);
2757 2759
2758 ASSERT_EQ(1u, video_channel_->recv_streams().size()); 2760 ASSERT_EQ(1u, video_channel_->recv_streams().size());
2759 ASSERT_EQ(1u, video_channel_->send_streams().size()); 2761 ASSERT_EQ(1u, video_channel_->send_streams().size());
2760 EXPECT_EQ(kVideoTrack2, video_channel_->recv_streams()[0].id); 2762 EXPECT_EQ(kVideoTrack2, video_channel_->recv_streams()[0].id);
2761 EXPECT_EQ(kVideoTrack2, video_channel_->send_streams()[0].id); 2763 EXPECT_EQ(kVideoTrack2, video_channel_->send_streams()[0].id);
2762 ASSERT_EQ(1u, voice_channel_->recv_streams().size()); 2764 ASSERT_EQ(1u, voice_channel_->recv_streams().size());
2763 ASSERT_EQ(1u, voice_channel_->send_streams().size()); 2765 ASSERT_EQ(1u, voice_channel_->send_streams().size());
2764 EXPECT_EQ(kAudioTrack2, voice_channel_->recv_streams()[0].id); 2766 EXPECT_EQ(kAudioTrack2, voice_channel_->recv_streams()[0].id);
2765 EXPECT_EQ(kAudioTrack2, voice_channel_->send_streams()[0].id); 2767 EXPECT_EQ(kAudioTrack2, voice_channel_->send_streams()[0].id);
2766 2768
2767 // Change session back to audio only. 2769 // Change session back to audio only.
2768 SendAudioOnlyStream2(); 2770 SendAudioOnlyStream2();
2769 CreateAndSetRemoteOfferAndLocalAnswer(); 2771 CreateAndSetRemoteOfferAndLocalAnswer();
2770 2772
2771 EXPECT_EQ(0u, video_channel_->recv_streams().size()); 2773 EXPECT_EQ(0u, video_channel_->recv_streams().size());
2772 ASSERT_EQ(1u, voice_channel_->recv_streams().size()); 2774 ASSERT_EQ(1u, voice_channel_->recv_streams().size());
2773 EXPECT_EQ(kAudioTrack2, voice_channel_->recv_streams()[0].id); 2775 EXPECT_EQ(kAudioTrack2, voice_channel_->recv_streams()[0].id);
2774 ASSERT_EQ(1u, voice_channel_->send_streams().size()); 2776 ASSERT_EQ(1u, voice_channel_->send_streams().size());
2775 EXPECT_EQ(kAudioTrack2, voice_channel_->send_streams()[0].id); 2777 EXPECT_EQ(kAudioTrack2, voice_channel_->send_streams()[0].id);
2776 } 2778 }
2777 2779
2778 // This test verifies the call setup when remote answer with video only and 2780 // This test verifies the call setup when remote answer with video only and
2779 // later updates with audio. 2781 // later updates with audio.
2780 TEST_F(WebRtcSessionTest, TestAVOfferWithVideoOnlyAnswer) { 2782 TEST_F(WebRtcSessionTest, TestAVOfferWithVideoOnlyAnswer) {
2781 Init(); 2783 Init();
2782 EXPECT_TRUE(media_engine_->GetVideoChannel(0) == NULL); 2784 EXPECT_TRUE(media_engine_->GetVideoChannel(0) == nullptr);
2783 EXPECT_TRUE(media_engine_->GetVoiceChannel(0) == NULL); 2785 EXPECT_TRUE(media_engine_->GetVoiceChannel(0) == nullptr);
2784 SendAudioVideoStream1(); 2786 SendAudioVideoStream1();
2785 SessionDescriptionInterface* offer = CreateOffer(); 2787 SessionDescriptionInterface* offer = CreateOffer();
2786 2788
2787 cricket::MediaSessionOptions options; 2789 cricket::MediaSessionOptions options;
2788 options.recv_audio = false; 2790 options.recv_audio = false;
2789 options.recv_video = true; 2791 options.recv_video = true;
2790 SessionDescriptionInterface* answer = CreateRemoteAnswer( 2792 SessionDescriptionInterface* answer = CreateRemoteAnswer(
2791 offer, options, cricket::SEC_ENABLED); 2793 offer, options, cricket::SEC_ENABLED);
2792 2794
2793 // SetLocalDescription and SetRemoteDescriptions takes ownership of offer 2795 // SetLocalDescription and SetRemoteDescriptions takes ownership of offer
2794 // and answer. 2796 // and answer.
2795 SetLocalDescriptionWithoutError(offer); 2797 SetLocalDescriptionWithoutError(offer);
2796 SetRemoteDescriptionWithoutError(answer); 2798 SetRemoteDescriptionWithoutError(answer);
2797 2799
2798 video_channel_ = media_engine_->GetVideoChannel(0); 2800 video_channel_ = media_engine_->GetVideoChannel(0);
2799 voice_channel_ = media_engine_->GetVoiceChannel(0); 2801 voice_channel_ = media_engine_->GetVoiceChannel(0);
2800 2802
2801 ASSERT_TRUE(voice_channel_ == NULL); 2803 ASSERT_TRUE(voice_channel_ == nullptr);
2802 ASSERT_TRUE(video_channel_ != NULL); 2804 ASSERT_TRUE(video_channel_ != nullptr);
2803 2805
2804 EXPECT_EQ(0u, video_channel_->recv_streams().size()); 2806 EXPECT_EQ(0u, video_channel_->recv_streams().size());
2805 ASSERT_EQ(1u, video_channel_->send_streams().size()); 2807 ASSERT_EQ(1u, video_channel_->send_streams().size());
2806 EXPECT_EQ(kVideoTrack1, video_channel_->send_streams()[0].id); 2808 EXPECT_EQ(kVideoTrack1, video_channel_->send_streams()[0].id);
2807 2809
2808 // Update the session descriptions, with Audio and Video. 2810 // Update the session descriptions, with Audio and Video.
2809 SendAudioVideoStream2(); 2811 SendAudioVideoStream2();
2810 CreateAndSetRemoteOfferAndLocalAnswer(); 2812 CreateAndSetRemoteOfferAndLocalAnswer();
2811 2813
2812 voice_channel_ = media_engine_->GetVoiceChannel(0); 2814 voice_channel_ = media_engine_->GetVoiceChannel(0);
2813 ASSERT_TRUE(voice_channel_ != NULL); 2815 ASSERT_TRUE(voice_channel_ != nullptr);
2814 2816
2815 ASSERT_EQ(1u, voice_channel_->recv_streams().size()); 2817 ASSERT_EQ(1u, voice_channel_->recv_streams().size());
2816 ASSERT_EQ(1u, voice_channel_->send_streams().size()); 2818 ASSERT_EQ(1u, voice_channel_->send_streams().size());
2817 EXPECT_EQ(kAudioTrack2, voice_channel_->recv_streams()[0].id); 2819 EXPECT_EQ(kAudioTrack2, voice_channel_->recv_streams()[0].id);
2818 EXPECT_EQ(kAudioTrack2, voice_channel_->send_streams()[0].id); 2820 EXPECT_EQ(kAudioTrack2, voice_channel_->send_streams()[0].id);
2819 2821
2820 // Change session back to video only. 2822 // Change session back to video only.
2821 SendVideoOnlyStream2(); 2823 SendVideoOnlyStream2();
2822 CreateAndSetRemoteOfferAndLocalAnswer(); 2824 CreateAndSetRemoteOfferAndLocalAnswer();
2823 2825
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
2871 // This test verifies that setLocalDescription fails if 2873 // This test verifies that setLocalDescription fails if
2872 // no a=ice-ufrag and a=ice-pwd lines are present in the SDP. 2874 // no a=ice-ufrag and a=ice-pwd lines are present in the SDP.
2873 TEST_F(WebRtcSessionTest, TestSetLocalDescriptionWithoutIce) { 2875 TEST_F(WebRtcSessionTest, TestSetLocalDescriptionWithoutIce) {
2874 Init(); 2876 Init();
2875 SendAudioVideoStream1(); 2877 SendAudioVideoStream1();
2876 std::unique_ptr<SessionDescriptionInterface> offer(CreateOffer()); 2878 std::unique_ptr<SessionDescriptionInterface> offer(CreateOffer());
2877 2879
2878 std::string sdp; 2880 std::string sdp;
2879 RemoveIceUfragPwdLines(offer.get(), &sdp); 2881 RemoveIceUfragPwdLines(offer.get(), &sdp);
2880 SessionDescriptionInterface* modified_offer = 2882 SessionDescriptionInterface* modified_offer =
2881 CreateSessionDescription(JsepSessionDescription::kOffer, sdp, NULL); 2883 CreateSessionDescription(JsepSessionDescription::kOffer, sdp, nullptr);
2882 SetLocalDescriptionOfferExpectError(kSdpWithoutIceUfragPwd, modified_offer); 2884 SetLocalDescriptionOfferExpectError(kSdpWithoutIceUfragPwd, modified_offer);
2883 } 2885 }
2884 2886
2885 // This test verifies that setRemoteDescription fails if 2887 // This test verifies that setRemoteDescription fails if
2886 // no a=ice-ufrag and a=ice-pwd lines are present in the SDP. 2888 // no a=ice-ufrag and a=ice-pwd lines are present in the SDP.
2887 TEST_F(WebRtcSessionTest, TestSetRemoteDescriptionWithoutIce) { 2889 TEST_F(WebRtcSessionTest, TestSetRemoteDescriptionWithoutIce) {
2888 Init(); 2890 Init();
2889 std::unique_ptr<SessionDescriptionInterface> offer(CreateRemoteOffer()); 2891 std::unique_ptr<SessionDescriptionInterface> offer(CreateRemoteOffer());
2890 std::string sdp; 2892 std::string sdp;
2891 RemoveIceUfragPwdLines(offer.get(), &sdp); 2893 RemoveIceUfragPwdLines(offer.get(), &sdp);
2892 SessionDescriptionInterface* modified_offer = 2894 SessionDescriptionInterface* modified_offer =
2893 CreateSessionDescription(JsepSessionDescription::kOffer, sdp, NULL); 2895 CreateSessionDescription(JsepSessionDescription::kOffer, sdp, nullptr);
2894 SetRemoteDescriptionOfferExpectError(kSdpWithoutIceUfragPwd, modified_offer); 2896 SetRemoteDescriptionOfferExpectError(kSdpWithoutIceUfragPwd, modified_offer);
2895 } 2897 }
2896 2898
2897 // This test verifies that setLocalDescription fails if local offer has 2899 // This test verifies that setLocalDescription fails if local offer has
2898 // too short ice ufrag and pwd strings. 2900 // too short ice ufrag and pwd strings.
2899 TEST_F(WebRtcSessionTest, TestSetLocalDescriptionInvalidIceCredentials) { 2901 TEST_F(WebRtcSessionTest, TestSetLocalDescriptionInvalidIceCredentials) {
2900 Init(); 2902 Init();
2901 SendAudioVideoStream1(); 2903 SendAudioVideoStream1();
2902 std::unique_ptr<SessionDescriptionInterface> offer(CreateOffer()); 2904 std::unique_ptr<SessionDescriptionInterface> offer(CreateOffer());
2903 // Modifying ice ufrag and pwd in local offer with strings smaller than the 2905 // Modifying ice ufrag and pwd in local offer with strings smaller than the
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
3034 SessionDescriptionInterface* offer = CreateRemoteOffer(); 3036 SessionDescriptionInterface* offer = CreateRemoteOffer();
3035 SetRemoteDescriptionWithoutError(offer); 3037 SetRemoteDescriptionWithoutError(offer);
3036 3038
3037 SessionDescriptionInterface* answer = CreateAnswer(); 3039 SessionDescriptionInterface* answer = CreateAnswer();
3038 SetLocalDescriptionWithoutError(answer); 3040 SetLocalDescriptionWithoutError(answer);
3039 3041
3040 EXPECT_EQ(session_->voice_rtp_transport_channel(), 3042 EXPECT_EQ(session_->voice_rtp_transport_channel(),
3041 session_->video_rtp_transport_channel()); 3043 session_->video_rtp_transport_channel());
3042 3044
3043 cricket::BaseChannel* voice_channel = session_->voice_channel(); 3045 cricket::BaseChannel* voice_channel = session_->voice_channel();
3044 ASSERT_TRUE(voice_channel != NULL); 3046 ASSERT_TRUE(voice_channel != nullptr);
3045 3047
3046 // Checks if one of the transport channels contains a connection using a given 3048 // Checks if one of the transport channels contains a connection using a given
3047 // port. 3049 // port.
3048 auto connection_with_remote_port = [this, voice_channel](int port) { 3050 auto connection_with_remote_port = [this, voice_channel](int port) {
3049 std::unique_ptr<webrtc::SessionStats> stats = session_->GetStats_s(); 3051 std::unique_ptr<webrtc::SessionStats> stats = session_->GetStats_s();
3050 for (auto& kv : stats->transport_stats) { 3052 for (auto& kv : stats->transport_stats) {
3051 for (auto& chan_stat : kv.second.channel_stats) { 3053 for (auto& chan_stat : kv.second.channel_stats) {
3052 for (auto& conn_info : chan_stat.connection_infos) { 3054 for (auto& conn_info : chan_stat.connection_infos) {
3053 if (conn_info.remote_candidate.address().port() == port) { 3055 if (conn_info.remote_candidate.address().port() == port) {
3054 return true; 3056 return true;
(...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after
3368 // Negotiate an audio channel with MAX_BUNDLE enabled. 3370 // Negotiate an audio channel with MAX_BUNDLE enabled.
3369 SendAudioOnlyStream2(); 3371 SendAudioOnlyStream2();
3370 SessionDescriptionInterface* offer = CreateOffer(); 3372 SessionDescriptionInterface* offer = CreateOffer();
3371 SetLocalDescriptionWithoutError(offer); 3373 SetLocalDescriptionWithoutError(offer);
3372 EXPECT_EQ_WAIT(PeerConnectionInterface::kIceGatheringComplete, 3374 EXPECT_EQ_WAIT(PeerConnectionInterface::kIceGatheringComplete,
3373 observer_.ice_gathering_state_, kIceCandidatesTimeout); 3375 observer_.ice_gathering_state_, kIceCandidatesTimeout);
3374 std::string sdp; 3376 std::string sdp;
3375 offer->ToString(&sdp); 3377 offer->ToString(&sdp);
3376 SessionDescriptionInterface* answer = webrtc::CreateSessionDescription( 3378 SessionDescriptionInterface* answer = webrtc::CreateSessionDescription(
3377 JsepSessionDescription::kAnswer, sdp, nullptr); 3379 JsepSessionDescription::kAnswer, sdp, nullptr);
3378 ASSERT_TRUE(answer != NULL); 3380 ASSERT_TRUE(answer != nullptr);
3379 SetRemoteDescriptionWithoutError(answer); 3381 SetRemoteDescriptionWithoutError(answer);
3380 3382
3381 // Wait for the ICE state to stabilize. 3383 // Wait for the ICE state to stabilize.
3382 EXPECT_EQ_WAIT(PeerConnectionInterface::kIceConnectionCompleted, 3384 EXPECT_EQ_WAIT(PeerConnectionInterface::kIceConnectionCompleted,
3383 observer_.ice_connection_state_, kIceCandidatesTimeout); 3385 observer_.ice_connection_state_, kIceCandidatesTimeout);
3384 observer_.ice_connection_state_history_.clear(); 3386 observer_.ice_connection_state_history_.clear();
3385 3387
3386 // Now add a video channel which should be using the same bundle transport. 3388 // Now add a video channel which should be using the same bundle transport.
3387 SendAudioVideoStream2(); 3389 SendAudioVideoStream2();
3388 offer = CreateOffer(); 3390 offer = CreateOffer();
3389 offer->ToString(&sdp); 3391 offer->ToString(&sdp);
3390 SetLocalDescriptionWithoutError(offer); 3392 SetLocalDescriptionWithoutError(offer);
3391 answer = webrtc::CreateSessionDescription(JsepSessionDescription::kAnswer, 3393 answer = webrtc::CreateSessionDescription(JsepSessionDescription::kAnswer,
3392 sdp, nullptr); 3394 sdp, nullptr);
3393 ASSERT_TRUE(answer != NULL); 3395 ASSERT_TRUE(answer != nullptr);
3394 SetRemoteDescriptionWithoutError(answer); 3396 SetRemoteDescriptionWithoutError(answer);
3395 3397
3396 // Wait for ICE state to stabilize 3398 // Wait for ICE state to stabilize
3397 rtc::Thread::Current()->ProcessMessages(0); 3399 rtc::Thread::Current()->ProcessMessages(0);
3398 EXPECT_EQ_WAIT(PeerConnectionInterface::kIceConnectionCompleted, 3400 EXPECT_EQ_WAIT(PeerConnectionInterface::kIceConnectionCompleted,
3399 observer_.ice_connection_state_, kIceCandidatesTimeout); 3401 observer_.ice_connection_state_, kIceCandidatesTimeout);
3400 3402
3401 // No ICE state changes are expected to happen. 3403 // No ICE state changes are expected to happen.
3402 EXPECT_EQ(0, observer_.ice_connection_state_history_.size()); 3404 EXPECT_EQ(0, observer_.ice_connection_state_history_.size());
3403 } 3405 }
3404 3406
3405 TEST_F(WebRtcSessionTest, TestRequireRtcpMux) { 3407 TEST_F(WebRtcSessionTest, TestRequireRtcpMux) {
3406 InitWithRtcpMuxPolicy(PeerConnectionInterface::kRtcpMuxPolicyRequire); 3408 InitWithRtcpMuxPolicy(PeerConnectionInterface::kRtcpMuxPolicyRequire);
3407 SendAudioVideoStream1(); 3409 SendAudioVideoStream1();
3408 3410
3409 PeerConnectionInterface::RTCOfferAnswerOptions options; 3411 PeerConnectionInterface::RTCOfferAnswerOptions options;
3410 SessionDescriptionInterface* offer = CreateOffer(options); 3412 SessionDescriptionInterface* offer = CreateOffer(options);
3411 SetLocalDescriptionWithoutError(offer); 3413 SetLocalDescriptionWithoutError(offer);
3412 3414
3413 EXPECT_TRUE(session_->voice_rtcp_transport_channel() == NULL); 3415 EXPECT_TRUE(session_->voice_rtcp_transport_channel() == nullptr);
3414 EXPECT_TRUE(session_->video_rtcp_transport_channel() == NULL); 3416 EXPECT_TRUE(session_->video_rtcp_transport_channel() == nullptr);
3415 3417
3416 SendAudioVideoStream2(); 3418 SendAudioVideoStream2();
3417 SessionDescriptionInterface* answer = 3419 SessionDescriptionInterface* answer =
3418 CreateRemoteAnswer(session_->local_description()); 3420 CreateRemoteAnswer(session_->local_description());
3419 SetRemoteDescriptionWithoutError(answer); 3421 SetRemoteDescriptionWithoutError(answer);
3420 3422
3421 EXPECT_TRUE(session_->voice_rtcp_transport_channel() == NULL); 3423 EXPECT_TRUE(session_->voice_rtcp_transport_channel() == nullptr);
3422 EXPECT_TRUE(session_->video_rtcp_transport_channel() == NULL); 3424 EXPECT_TRUE(session_->video_rtcp_transport_channel() == nullptr);
3423 } 3425 }
3424 3426
3425 TEST_F(WebRtcSessionTest, TestNegotiateRtcpMux) { 3427 TEST_F(WebRtcSessionTest, TestNegotiateRtcpMux) {
3426 InitWithRtcpMuxPolicy(PeerConnectionInterface::kRtcpMuxPolicyNegotiate); 3428 InitWithRtcpMuxPolicy(PeerConnectionInterface::kRtcpMuxPolicyNegotiate);
3427 SendAudioVideoStream1(); 3429 SendAudioVideoStream1();
3428 3430
3429 PeerConnectionInterface::RTCOfferAnswerOptions options; 3431 PeerConnectionInterface::RTCOfferAnswerOptions options;
3430 SessionDescriptionInterface* offer = CreateOffer(options); 3432 SessionDescriptionInterface* offer = CreateOffer(options);
3431 SetLocalDescriptionWithoutError(offer); 3433 SetLocalDescriptionWithoutError(offer);
3432 3434
3433 EXPECT_TRUE(session_->voice_rtcp_transport_channel() != NULL); 3435 EXPECT_TRUE(session_->voice_rtcp_transport_channel() != nullptr);
3434 EXPECT_TRUE(session_->video_rtcp_transport_channel() != NULL); 3436 EXPECT_TRUE(session_->video_rtcp_transport_channel() != nullptr);
3435 3437
3436 SendAudioVideoStream2(); 3438 SendAudioVideoStream2();
3437 SessionDescriptionInterface* answer = 3439 SessionDescriptionInterface* answer =
3438 CreateRemoteAnswer(session_->local_description()); 3440 CreateRemoteAnswer(session_->local_description());
3439 SetRemoteDescriptionWithoutError(answer); 3441 SetRemoteDescriptionWithoutError(answer);
3440 3442
3441 EXPECT_TRUE(session_->voice_rtcp_transport_channel() == NULL); 3443 EXPECT_TRUE(session_->voice_rtcp_transport_channel() == nullptr);
3442 EXPECT_TRUE(session_->video_rtcp_transport_channel() == NULL); 3444 EXPECT_TRUE(session_->video_rtcp_transport_channel() == nullptr);
3443 } 3445 }
3444 3446
3445 // This test verifies that SetLocalDescription and SetRemoteDescription fails 3447 // This test verifies that SetLocalDescription and SetRemoteDescription fails
3446 // if BUNDLE is enabled but rtcp-mux is disabled in m-lines. 3448 // if BUNDLE is enabled but rtcp-mux is disabled in m-lines.
3447 TEST_F(WebRtcSessionTest, TestDisabledRtcpMuxWithBundleEnabled) { 3449 TEST_F(WebRtcSessionTest, TestDisabledRtcpMuxWithBundleEnabled) {
3448 Init(); 3450 Init();
3449 SendAudioVideoStream1(); 3451 SendAudioVideoStream1();
3450 3452
3451 PeerConnectionInterface::RTCOfferAnswerOptions options; 3453 PeerConnectionInterface::RTCOfferAnswerOptions options;
3452 options.use_rtp_mux = true; 3454 options.use_rtp_mux = true;
3453 3455
3454 SessionDescriptionInterface* offer = CreateOffer(options); 3456 SessionDescriptionInterface* offer = CreateOffer(options);
3455 std::string offer_str; 3457 std::string offer_str;
3456 offer->ToString(&offer_str); 3458 offer->ToString(&offer_str);
3457 // Disable rtcp-mux 3459 // Disable rtcp-mux
3458 const std::string rtcp_mux = "rtcp-mux"; 3460 const std::string rtcp_mux = "rtcp-mux";
3459 const std::string xrtcp_mux = "xrtcp-mux"; 3461 const std::string xrtcp_mux = "xrtcp-mux";
3460 rtc::replace_substrs(rtcp_mux.c_str(), rtcp_mux.length(), 3462 rtc::replace_substrs(rtcp_mux.c_str(), rtcp_mux.length(),
3461 xrtcp_mux.c_str(), xrtcp_mux.length(), 3463 xrtcp_mux.c_str(), xrtcp_mux.length(),
3462 &offer_str); 3464 &offer_str);
3463 JsepSessionDescription* local_offer = 3465 JsepSessionDescription* local_offer =
3464 new JsepSessionDescription(JsepSessionDescription::kOffer); 3466 new JsepSessionDescription(JsepSessionDescription::kOffer);
3465 EXPECT_TRUE((local_offer)->Initialize(offer_str, NULL)); 3467 EXPECT_TRUE((local_offer)->Initialize(offer_str, nullptr));
3466 SetLocalDescriptionOfferExpectError(kBundleWithoutRtcpMux, local_offer); 3468 SetLocalDescriptionOfferExpectError(kBundleWithoutRtcpMux, local_offer);
3467 JsepSessionDescription* remote_offer = 3469 JsepSessionDescription* remote_offer =
3468 new JsepSessionDescription(JsepSessionDescription::kOffer); 3470 new JsepSessionDescription(JsepSessionDescription::kOffer);
3469 EXPECT_TRUE((remote_offer)->Initialize(offer_str, NULL)); 3471 EXPECT_TRUE((remote_offer)->Initialize(offer_str, nullptr));
3470 SetRemoteDescriptionOfferExpectError(kBundleWithoutRtcpMux, remote_offer); 3472 SetRemoteDescriptionOfferExpectError(kBundleWithoutRtcpMux, remote_offer);
3471 // Trying unmodified SDP. 3473 // Trying unmodified SDP.
3472 SetLocalDescriptionWithoutError(offer); 3474 SetLocalDescriptionWithoutError(offer);
3473 } 3475 }
3474 3476
3475 TEST_F(WebRtcSessionTest, SetSetupGcm) { 3477 TEST_F(WebRtcSessionTest, SetSetupGcm) {
3476 InitWithGcm(); 3478 InitWithGcm();
3477 SendAudioVideoStream1(); 3479 SendAudioVideoStream1();
3478 CreateAndSetRemoteOfferAndLocalAnswer(); 3480 CreateAndSetRemoteOfferAndLocalAnswer();
3479 } 3481 }
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
3526 // Different content names. 3528 // Different content names.
3527 std::string sdp; 3529 std::string sdp;
3528 EXPECT_TRUE(answer->ToString(&sdp)); 3530 EXPECT_TRUE(answer->ToString(&sdp));
3529 const std::string kAudioMid = "a=mid:audio"; 3531 const std::string kAudioMid = "a=mid:audio";
3530 const std::string kAudioMidReplaceStr = "a=mid:audio_content_name"; 3532 const std::string kAudioMidReplaceStr = "a=mid:audio_content_name";
3531 rtc::replace_substrs(kAudioMid.c_str(), kAudioMid.length(), 3533 rtc::replace_substrs(kAudioMid.c_str(), kAudioMid.length(),
3532 kAudioMidReplaceStr.c_str(), 3534 kAudioMidReplaceStr.c_str(),
3533 kAudioMidReplaceStr.length(), 3535 kAudioMidReplaceStr.length(),
3534 &sdp); 3536 &sdp);
3535 SessionDescriptionInterface* modified_answer1 = 3537 SessionDescriptionInterface* modified_answer1 =
3536 CreateSessionDescription(JsepSessionDescription::kAnswer, sdp, NULL); 3538 CreateSessionDescription(JsepSessionDescription::kAnswer, sdp, nullptr);
3537 SetRemoteDescriptionAnswerExpectError(kMlineMismatch, modified_answer1); 3539 SetRemoteDescriptionAnswerExpectError(kMlineMismatch, modified_answer1);
3538 3540
3539 // Different media types. 3541 // Different media types.
3540 EXPECT_TRUE(answer->ToString(&sdp)); 3542 EXPECT_TRUE(answer->ToString(&sdp));
3541 const std::string kAudioMline = "m=audio"; 3543 const std::string kAudioMline = "m=audio";
3542 const std::string kAudioMlineReplaceStr = "m=video"; 3544 const std::string kAudioMlineReplaceStr = "m=video";
3543 rtc::replace_substrs(kAudioMline.c_str(), kAudioMline.length(), 3545 rtc::replace_substrs(kAudioMline.c_str(), kAudioMline.length(),
3544 kAudioMlineReplaceStr.c_str(), 3546 kAudioMlineReplaceStr.c_str(),
3545 kAudioMlineReplaceStr.length(), 3547 kAudioMlineReplaceStr.length(),
3546 &sdp); 3548 &sdp);
3547 SessionDescriptionInterface* modified_answer2 = 3549 SessionDescriptionInterface* modified_answer2 =
3548 CreateSessionDescription(JsepSessionDescription::kAnswer, sdp, NULL); 3550 CreateSessionDescription(JsepSessionDescription::kAnswer, sdp, nullptr);
3549 SetRemoteDescriptionAnswerExpectError(kMlineMismatch, modified_answer2); 3551 SetRemoteDescriptionAnswerExpectError(kMlineMismatch, modified_answer2);
3550 3552
3551 SetRemoteDescriptionWithoutError(answer.release()); 3553 SetRemoteDescriptionWithoutError(answer.release());
3552 } 3554 }
3553 3555
3554 // Verifying remote offer and local answer have matching m-lines as per 3556 // Verifying remote offer and local answer have matching m-lines as per
3555 // RFC 3264. 3557 // RFC 3264.
3556 TEST_F(WebRtcSessionTest, TestIncorrectMLinesInLocalAnswer) { 3558 TEST_F(WebRtcSessionTest, TestIncorrectMLinesInLocalAnswer) {
3557 Init(); 3559 Init();
3558 SendAudioVideoStream1(); 3560 SendAudioVideoStream1();
(...skipping 23 matching lines...) Expand all
3582 candidate.set_component(1); 3584 candidate.set_component(1);
3583 JsepIceCandidate ice_candidate(kMediaContentName0, kMediaContentIndex0, 3585 JsepIceCandidate ice_candidate(kMediaContentName0, kMediaContentIndex0,
3584 candidate); 3586 candidate);
3585 EXPECT_TRUE(offer->AddCandidate(&ice_candidate)); 3587 EXPECT_TRUE(offer->AddCandidate(&ice_candidate));
3586 cricket::Candidate candidate1; 3588 cricket::Candidate candidate1;
3587 candidate1.set_component(1); 3589 candidate1.set_component(1);
3588 JsepIceCandidate ice_candidate1(kMediaContentName1, kMediaContentIndex1, 3590 JsepIceCandidate ice_candidate1(kMediaContentName1, kMediaContentIndex1,
3589 candidate1); 3591 candidate1);
3590 EXPECT_TRUE(offer->AddCandidate(&ice_candidate1)); 3592 EXPECT_TRUE(offer->AddCandidate(&ice_candidate1));
3591 SetRemoteDescriptionWithoutError(offer); 3593 SetRemoteDescriptionWithoutError(offer);
3592 ASSERT_TRUE(session_->voice_rtp_transport_channel() != NULL); 3594 ASSERT_TRUE(session_->voice_rtp_transport_channel() != nullptr);
3593 ASSERT_TRUE(session_->video_rtp_transport_channel() != NULL); 3595 ASSERT_TRUE(session_->video_rtp_transport_channel() != nullptr);
3594 3596
3595 // Pump for 1 second and verify that no candidates are generated. 3597 // Pump for 1 second and verify that no candidates are generated.
3596 rtc::Thread::Current()->ProcessMessages(1000); 3598 rtc::Thread::Current()->ProcessMessages(1000);
3597 EXPECT_TRUE(observer_.mline_0_candidates_.empty()); 3599 EXPECT_TRUE(observer_.mline_0_candidates_.empty());
3598 EXPECT_TRUE(observer_.mline_1_candidates_.empty()); 3600 EXPECT_TRUE(observer_.mline_1_candidates_.empty());
3599 3601
3600 SessionDescriptionInterface* answer = CreateAnswer(); 3602 SessionDescriptionInterface* answer = CreateAnswer();
3601 SetLocalDescriptionWithoutError(answer); 3603 SetLocalDescriptionWithoutError(answer);
3602 EXPECT_TRUE_WAIT(observer_.oncandidatesready_, kIceCandidatesTimeout); 3604 EXPECT_TRUE_WAIT(observer_.oncandidatesready_, kIceCandidatesTimeout);
3603 } 3605 }
3604 3606
3605 // This test verifies that crypto parameter is updated in local session 3607 // This test verifies that crypto parameter is updated in local session
3606 // description as per security policy set in MediaSessionDescriptionFactory. 3608 // description as per security policy set in MediaSessionDescriptionFactory.
3607 TEST_F(WebRtcSessionTest, TestCryptoAfterSetLocalDescription) { 3609 TEST_F(WebRtcSessionTest, TestCryptoAfterSetLocalDescription) {
3608 Init(); 3610 Init();
3609 SendAudioVideoStream1(); 3611 SendAudioVideoStream1();
3610 std::unique_ptr<SessionDescriptionInterface> offer(CreateOffer()); 3612 std::unique_ptr<SessionDescriptionInterface> offer(CreateOffer());
3611 3613
3612 // Making sure SetLocalDescription correctly sets crypto value in 3614 // Making sure SetLocalDescription correctly sets crypto value in
3613 // SessionDescription object after de-serialization of sdp string. The value 3615 // SessionDescription object after de-serialization of sdp string. The value
3614 // will be set as per MediaSessionDescriptionFactory. 3616 // will be set as per MediaSessionDescriptionFactory.
3615 std::string offer_str; 3617 std::string offer_str;
3616 offer->ToString(&offer_str); 3618 offer->ToString(&offer_str);
3617 SessionDescriptionInterface* jsep_offer_str = 3619 SessionDescriptionInterface* jsep_offer_str = CreateSessionDescription(
3618 CreateSessionDescription(JsepSessionDescription::kOffer, offer_str, NULL); 3620 JsepSessionDescription::kOffer, offer_str, nullptr);
3619 SetLocalDescriptionWithoutError(jsep_offer_str); 3621 SetLocalDescriptionWithoutError(jsep_offer_str);
3620 EXPECT_TRUE(session_->voice_channel()->srtp_required_for_testing()); 3622 EXPECT_TRUE(session_->voice_channel()->srtp_required_for_testing());
3621 EXPECT_TRUE(session_->video_channel()->srtp_required_for_testing()); 3623 EXPECT_TRUE(session_->video_channel()->srtp_required_for_testing());
3622 } 3624 }
3623 3625
3624 // This test verifies the crypto parameter when security is disabled. 3626 // This test verifies the crypto parameter when security is disabled.
3625 TEST_F(WebRtcSessionTest, TestCryptoAfterSetLocalDescriptionWithDisabled) { 3627 TEST_F(WebRtcSessionTest, TestCryptoAfterSetLocalDescriptionWithDisabled) {
3626 options_.disable_encryption = true; 3628 options_.disable_encryption = true;
3627 Init(); 3629 Init();
3628 SendAudioVideoStream1(); 3630 SendAudioVideoStream1();
3629 std::unique_ptr<SessionDescriptionInterface> offer(CreateOffer()); 3631 std::unique_ptr<SessionDescriptionInterface> offer(CreateOffer());
3630 3632
3631 // Making sure SetLocalDescription correctly sets crypto value in 3633 // Making sure SetLocalDescription correctly sets crypto value in
3632 // SessionDescription object after de-serialization of sdp string. The value 3634 // SessionDescription object after de-serialization of sdp string. The value
3633 // will be set as per MediaSessionDescriptionFactory. 3635 // will be set as per MediaSessionDescriptionFactory.
3634 std::string offer_str; 3636 std::string offer_str;
3635 offer->ToString(&offer_str); 3637 offer->ToString(&offer_str);
3636 SessionDescriptionInterface* jsep_offer_str = 3638 SessionDescriptionInterface* jsep_offer_str = CreateSessionDescription(
3637 CreateSessionDescription(JsepSessionDescription::kOffer, offer_str, NULL); 3639 JsepSessionDescription::kOffer, offer_str, nullptr);
3638 SetLocalDescriptionWithoutError(jsep_offer_str); 3640 SetLocalDescriptionWithoutError(jsep_offer_str);
3639 EXPECT_FALSE(session_->voice_channel()->srtp_required_for_testing()); 3641 EXPECT_FALSE(session_->voice_channel()->srtp_required_for_testing());
3640 EXPECT_FALSE(session_->video_channel()->srtp_required_for_testing()); 3642 EXPECT_FALSE(session_->video_channel()->srtp_required_for_testing());
3641 } 3643 }
3642 3644
3643 // This test verifies that an answer contains new ufrag and password if an offer 3645 // This test verifies that an answer contains new ufrag and password if an offer
3644 // with new ufrag and password is received. 3646 // with new ufrag and password is received.
3645 TEST_F(WebRtcSessionTest, TestCreateAnswerWithNewUfragAndPassword) { 3647 TEST_F(WebRtcSessionTest, TestCreateAnswerWithNewUfragAndPassword) {
3646 Init(); 3648 Init();
3647 cricket::MediaSessionOptions options; 3649 cricket::MediaSessionOptions options;
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after
3894 ASSERT_TRUE(session_->sctp_content_name()); 3896 ASSERT_TRUE(session_->sctp_content_name());
3895 ASSERT_TRUE(session_->sctp_transport_name()); 3897 ASSERT_TRUE(session_->sctp_transport_name());
3896 EXPECT_EQ("data", *session_->sctp_content_name()); 3898 EXPECT_EQ("data", *session_->sctp_content_name());
3897 EXPECT_EQ("audio", *session_->sctp_transport_name()); 3899 EXPECT_EQ("audio", *session_->sctp_transport_name());
3898 } 3900 }
3899 3901
3900 TEST_P(WebRtcSessionTest, TestCreateOfferWithSctpEnabledWithoutStreams) { 3902 TEST_P(WebRtcSessionTest, TestCreateOfferWithSctpEnabledWithoutStreams) {
3901 InitWithDtls(GetParam()); 3903 InitWithDtls(GetParam());
3902 3904
3903 std::unique_ptr<SessionDescriptionInterface> offer(CreateOffer()); 3905 std::unique_ptr<SessionDescriptionInterface> offer(CreateOffer());
3904 EXPECT_TRUE(offer->description()->GetContentByName("data") == NULL); 3906 EXPECT_TRUE(offer->description()->GetContentByName("data") == nullptr);
3905 EXPECT_TRUE(offer->description()->GetTransportInfoByName("data") == NULL); 3907 EXPECT_TRUE(offer->description()->GetTransportInfoByName("data") == nullptr);
3906 } 3908 }
3907 3909
3908 TEST_P(WebRtcSessionTest, TestCreateAnswerWithSctpInOfferAndNoStreams) { 3910 TEST_P(WebRtcSessionTest, TestCreateAnswerWithSctpInOfferAndNoStreams) {
3909 SetFactoryDtlsSrtp(); 3911 SetFactoryDtlsSrtp();
3910 InitWithDtls(GetParam()); 3912 InitWithDtls(GetParam());
3911 3913
3912 // Create remote offer with SCTP. 3914 // Create remote offer with SCTP.
3913 cricket::MediaSessionOptions options; 3915 cricket::MediaSessionOptions options;
3914 options.data_channel_type = cricket::DCT_SCTP; 3916 options.data_channel_type = cricket::DCT_SCTP;
3915 JsepSessionDescription* offer = 3917 JsepSessionDescription* offer =
3916 CreateRemoteOffer(options, cricket::SEC_DISABLED); 3918 CreateRemoteOffer(options, cricket::SEC_DISABLED);
3917 SetRemoteDescriptionWithoutError(offer); 3919 SetRemoteDescriptionWithoutError(offer);
3918 3920
3919 // Verifies the answer contains SCTP. 3921 // Verifies the answer contains SCTP.
3920 std::unique_ptr<SessionDescriptionInterface> answer(CreateAnswer()); 3922 std::unique_ptr<SessionDescriptionInterface> answer(CreateAnswer());
3921 EXPECT_TRUE(answer != NULL); 3923 EXPECT_TRUE(answer != nullptr);
3922 EXPECT_TRUE(answer->description()->GetContentByName("data") != NULL); 3924 EXPECT_TRUE(answer->description()->GetContentByName("data") != nullptr);
3923 EXPECT_TRUE(answer->description()->GetTransportInfoByName("data") != NULL); 3925 EXPECT_TRUE(answer->description()->GetTransportInfoByName("data") != nullptr);
3924 } 3926 }
3925 3927
3926 // Test that if DTLS is disabled, we don't end up with an SctpTransport 3928 // Test that if DTLS is disabled, we don't end up with an SctpTransport
3927 // created (or an RtpDataChannel). 3929 // created (or an RtpDataChannel).
3928 TEST_P(WebRtcSessionTest, TestSctpDataChannelWithoutDtls) { 3930 TEST_P(WebRtcSessionTest, TestSctpDataChannelWithoutDtls) {
3929 configuration_.enable_dtls_srtp = rtc::Optional<bool>(false); 3931 configuration_.enable_dtls_srtp = rtc::Optional<bool>(false);
3930 InitWithDtls(GetParam()); 3932 InitWithDtls(GetParam());
3931 3933
3932 SetLocalDescriptionWithDataChannel(); 3934 SetLocalDescriptionWithDataChannel();
3933 EXPECT_EQ(nullptr, data_engine_->GetChannel(0)); 3935 EXPECT_EQ(nullptr, data_engine_->GetChannel(0));
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
3968 // into the stream. 3970 // into the stream.
3969 cricket::MediaSessionOptions options; 3971 cricket::MediaSessionOptions options;
3970 JsepSessionDescription* offer = CreateRemoteOfferWithSctpPort( 3972 JsepSessionDescription* offer = CreateRemoteOfferWithSctpPort(
3971 "stream1", new_send_port, options); 3973 "stream1", new_send_port, options);
3972 3974
3973 // SetRemoteDescription will take the ownership of the offer. 3975 // SetRemoteDescription will take the ownership of the offer.
3974 SetRemoteDescriptionWithoutError(offer); 3976 SetRemoteDescriptionWithoutError(offer);
3975 3977
3976 SessionDescriptionInterface* answer = 3978 SessionDescriptionInterface* answer =
3977 ChangeSDPSctpPort(new_recv_port, CreateAnswer()); 3979 ChangeSDPSctpPort(new_recv_port, CreateAnswer());
3978 ASSERT_TRUE(answer != NULL); 3980 ASSERT_TRUE(answer != nullptr);
3979 3981
3980 // Now set the local description, which'll take ownership of the answer. 3982 // Now set the local description, which'll take ownership of the answer.
3981 SetLocalDescriptionWithoutError(answer); 3983 SetLocalDescriptionWithoutError(answer);
3982 3984
3983 // TEST PLAN: Set the port number to something new, set it in the SDP, 3985 // TEST PLAN: Set the port number to something new, set it in the SDP,
3984 // and pass it all the way down. 3986 // and pass it all the way down.
3985 EXPECT_EQ(nullptr, data_engine_->GetChannel(0)); 3987 EXPECT_EQ(nullptr, data_engine_->GetChannel(0));
3986 CreateDataChannel(); 3988 CreateDataChannel();
3987 ASSERT_NE(nullptr, fake_sctp_transport_factory_->last_fake_sctp_transport()); 3989 ASSERT_NE(nullptr, fake_sctp_transport_factory_->last_fake_sctp_transport());
3988 EXPECT_EQ( 3990 EXPECT_EQ(
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
4035 // Verifies that CreateOffer succeeds when CreateOffer is called before async 4037 // Verifies that CreateOffer succeeds when CreateOffer is called before async
4036 // identity generation is finished (even if a certificate is provided this is 4038 // identity generation is finished (even if a certificate is provided this is
4037 // an async op). 4039 // an async op).
4038 TEST_P(WebRtcSessionTest, TestCreateOfferBeforeIdentityRequestReturnSuccess) { 4040 TEST_P(WebRtcSessionTest, TestCreateOfferBeforeIdentityRequestReturnSuccess) {
4039 InitWithDtls(GetParam()); 4041 InitWithDtls(GetParam());
4040 4042
4041 EXPECT_TRUE(session_->waiting_for_certificate_for_testing()); 4043 EXPECT_TRUE(session_->waiting_for_certificate_for_testing());
4042 SendAudioVideoStream1(); 4044 SendAudioVideoStream1();
4043 std::unique_ptr<SessionDescriptionInterface> offer(CreateOffer()); 4045 std::unique_ptr<SessionDescriptionInterface> offer(CreateOffer());
4044 4046
4045 EXPECT_TRUE(offer != NULL); 4047 EXPECT_TRUE(offer != nullptr);
4046 VerifyNoCryptoParams(offer->description(), true); 4048 VerifyNoCryptoParams(offer->description(), true);
4047 VerifyFingerprintStatus(offer->description(), true); 4049 VerifyFingerprintStatus(offer->description(), true);
4048 } 4050 }
4049 4051
4050 // Verifies that CreateAnswer succeeds when CreateOffer is called before async 4052 // Verifies that CreateAnswer succeeds when CreateOffer is called before async
4051 // identity generation is finished (even if a certificate is provided this is 4053 // identity generation is finished (even if a certificate is provided this is
4052 // an async op). 4054 // an async op).
4053 TEST_P(WebRtcSessionTest, TestCreateAnswerBeforeIdentityRequestReturnSuccess) { 4055 TEST_P(WebRtcSessionTest, TestCreateAnswerBeforeIdentityRequestReturnSuccess) {
4054 InitWithDtls(GetParam()); 4056 InitWithDtls(GetParam());
4055 SetFactoryDtlsSrtp(); 4057 SetFactoryDtlsSrtp();
4056 4058
4057 cricket::MediaSessionOptions options; 4059 cricket::MediaSessionOptions options;
4058 options.recv_video = true; 4060 options.recv_video = true;
4059 std::unique_ptr<JsepSessionDescription> offer( 4061 std::unique_ptr<JsepSessionDescription> offer(
4060 CreateRemoteOffer(options, cricket::SEC_DISABLED)); 4062 CreateRemoteOffer(options, cricket::SEC_DISABLED));
4061 ASSERT_TRUE(offer.get() != NULL); 4063 ASSERT_TRUE(offer.get() != nullptr);
4062 SetRemoteDescriptionWithoutError(offer.release()); 4064 SetRemoteDescriptionWithoutError(offer.release());
4063 4065
4064 std::unique_ptr<SessionDescriptionInterface> answer(CreateAnswer()); 4066 std::unique_ptr<SessionDescriptionInterface> answer(CreateAnswer());
4065 EXPECT_TRUE(answer != NULL); 4067 EXPECT_TRUE(answer != nullptr);
4066 VerifyNoCryptoParams(answer->description(), true); 4068 VerifyNoCryptoParams(answer->description(), true);
4067 VerifyFingerprintStatus(answer->description(), true); 4069 VerifyFingerprintStatus(answer->description(), true);
4068 } 4070 }
4069 4071
4070 // Verifies that CreateOffer succeeds when CreateOffer is called after async 4072 // Verifies that CreateOffer succeeds when CreateOffer is called after async
4071 // identity generation is finished (even if a certificate is provided this is 4073 // identity generation is finished (even if a certificate is provided this is
4072 // an async op). 4074 // an async op).
4073 TEST_P(WebRtcSessionTest, TestCreateOfferAfterIdentityRequestReturnSuccess) { 4075 TEST_P(WebRtcSessionTest, TestCreateOfferAfterIdentityRequestReturnSuccess) {
4074 InitWithDtls(GetParam()); 4076 InitWithDtls(GetParam());
4075 4077
4076 EXPECT_TRUE_WAIT(!session_->waiting_for_certificate_for_testing(), 1000); 4078 EXPECT_TRUE_WAIT(!session_->waiting_for_certificate_for_testing(), 1000);
4077 4079
4078 std::unique_ptr<SessionDescriptionInterface> offer(CreateOffer()); 4080 std::unique_ptr<SessionDescriptionInterface> offer(CreateOffer());
4079 EXPECT_TRUE(offer != NULL); 4081 EXPECT_TRUE(offer != nullptr);
4080 } 4082 }
4081 4083
4082 // Verifies that CreateOffer fails when CreateOffer is called after async 4084 // Verifies that CreateOffer fails when CreateOffer is called after async
4083 // identity generation fails. 4085 // identity generation fails.
4084 TEST_F(WebRtcSessionTest, TestCreateOfferAfterIdentityRequestReturnFailure) { 4086 TEST_F(WebRtcSessionTest, TestCreateOfferAfterIdentityRequestReturnFailure) {
4085 InitWithDtlsIdentityGenFail(); 4087 InitWithDtlsIdentityGenFail();
4086 4088
4087 EXPECT_TRUE_WAIT(!session_->waiting_for_certificate_for_testing(), 1000); 4089 EXPECT_TRUE_WAIT(!session_->waiting_for_certificate_for_testing(), 1000);
4088 4090
4089 std::unique_ptr<SessionDescriptionInterface> offer(CreateOffer()); 4091 std::unique_ptr<SessionDescriptionInterface> offer(CreateOffer());
4090 EXPECT_TRUE(offer == NULL); 4092 EXPECT_TRUE(offer == nullptr);
4091 } 4093 }
4092 4094
4093 // Verifies that CreateOffer succeeds when Multiple CreateOffer calls are made 4095 // Verifies that CreateOffer succeeds when Multiple CreateOffer calls are made
4094 // before async identity generation is finished. 4096 // before async identity generation is finished.
4095 TEST_P(WebRtcSessionTest, 4097 TEST_P(WebRtcSessionTest,
4096 TestMultipleCreateOfferBeforeIdentityRequestReturnSuccess) { 4098 TestMultipleCreateOfferBeforeIdentityRequestReturnSuccess) {
4097 VerifyMultipleAsyncCreateDescription(GetParam(), 4099 VerifyMultipleAsyncCreateDescription(GetParam(),
4098 CreateSessionDescriptionRequest::kOffer); 4100 CreateSessionDescriptionRequest::kOffer);
4099 } 4101 }
4100 4102
(...skipping 26 matching lines...) Expand all
4127 TEST_F(WebRtcSessionTest, TestSetRemoteOfferFailIfDtlsDisabledAndNoCrypto) { 4129 TEST_F(WebRtcSessionTest, TestSetRemoteOfferFailIfDtlsDisabledAndNoCrypto) {
4128 // Init without DTLS. 4130 // Init without DTLS.
4129 Init(); 4131 Init();
4130 // Create a remote offer with secured transport disabled. 4132 // Create a remote offer with secured transport disabled.
4131 cricket::MediaSessionOptions options; 4133 cricket::MediaSessionOptions options;
4132 JsepSessionDescription* offer(CreateRemoteOffer( 4134 JsepSessionDescription* offer(CreateRemoteOffer(
4133 options, cricket::SEC_DISABLED)); 4135 options, cricket::SEC_DISABLED));
4134 // Adds a DTLS fingerprint to the remote offer. 4136 // Adds a DTLS fingerprint to the remote offer.
4135 cricket::SessionDescription* sdp = offer->description(); 4137 cricket::SessionDescription* sdp = offer->description();
4136 TransportInfo* audio = sdp->GetTransportInfoByName("audio"); 4138 TransportInfo* audio = sdp->GetTransportInfoByName("audio");
4137 ASSERT_TRUE(audio != NULL); 4139 ASSERT_TRUE(audio != nullptr);
4138 ASSERT_TRUE(audio->description.identity_fingerprint.get() == NULL); 4140 ASSERT_TRUE(audio->description.identity_fingerprint.get() == nullptr);
4139 audio->description.identity_fingerprint.reset( 4141 audio->description.identity_fingerprint.reset(
4140 rtc::SSLFingerprint::CreateFromRfc4572( 4142 rtc::SSLFingerprint::CreateFromRfc4572(
4141 rtc::DIGEST_SHA_256, kFakeDtlsFingerprint)); 4143 rtc::DIGEST_SHA_256, kFakeDtlsFingerprint));
4142 SetRemoteDescriptionOfferExpectError(kSdpWithoutSdesCrypto, 4144 SetRemoteDescriptionOfferExpectError(kSdpWithoutSdesCrypto,
4143 offer); 4145 offer);
4144 } 4146 }
4145 4147
4146 TEST_F(WebRtcSessionTest, TestCombinedAudioVideoBweConstraint) { 4148 TEST_F(WebRtcSessionTest, TestCombinedAudioVideoBweConstraint) {
4147 configuration_.combined_audio_video_bwe = rtc::Optional<bool>(true); 4149 configuration_.combined_audio_video_bwe = rtc::Optional<bool>(true);
4148 Init(); 4150 Init();
4149 SendAudioVideoStream1(); 4151 SendAudioVideoStream1();
4150 SessionDescriptionInterface* offer = CreateOffer(); 4152 SessionDescriptionInterface* offer = CreateOffer();
4151 4153
4152 SetLocalDescriptionWithoutError(offer); 4154 SetLocalDescriptionWithoutError(offer);
4153 4155
4154 voice_channel_ = media_engine_->GetVoiceChannel(0); 4156 voice_channel_ = media_engine_->GetVoiceChannel(0);
4155 4157
4156 ASSERT_TRUE(voice_channel_ != NULL); 4158 ASSERT_TRUE(voice_channel_ != nullptr);
4157 const cricket::AudioOptions& audio_options = voice_channel_->options(); 4159 const cricket::AudioOptions& audio_options = voice_channel_->options();
4158 EXPECT_EQ(rtc::Optional<bool>(true), audio_options.combined_audio_video_bwe); 4160 EXPECT_EQ(rtc::Optional<bool>(true), audio_options.combined_audio_video_bwe);
4159 } 4161 }
4160 4162
4161 // Tests that we can renegotiate new media content with ICE candidates in the 4163 // Tests that we can renegotiate new media content with ICE candidates in the
4162 // new remote SDP. 4164 // new remote SDP.
4163 TEST_P(WebRtcSessionTest, TestRenegotiateNewMediaWithCandidatesInSdp) { 4165 TEST_P(WebRtcSessionTest, TestRenegotiateNewMediaWithCandidatesInSdp) {
4164 InitWithDtls(GetParam()); 4166 InitWithDtls(GetParam());
4165 SetFactoryDtlsSrtp(); 4167 SetFactoryDtlsSrtp();
4166 4168
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
4236 } 4238 }
4237 #endif // HAVE_QUIC 4239 #endif // HAVE_QUIC
4238 4240
4239 // Tests that RTX codec is removed from the answer when it isn't supported 4241 // Tests that RTX codec is removed from the answer when it isn't supported
4240 // by local side. 4242 // by local side.
4241 TEST_F(WebRtcSessionTest, TestRtxRemovedByCreateAnswer) { 4243 TEST_F(WebRtcSessionTest, TestRtxRemovedByCreateAnswer) {
4242 Init(); 4244 Init();
4243 SendAudioVideoStream1(); 4245 SendAudioVideoStream1();
4244 std::string offer_sdp(kSdpWithRtx); 4246 std::string offer_sdp(kSdpWithRtx);
4245 4247
4246 SessionDescriptionInterface* offer = 4248 SessionDescriptionInterface* offer = CreateSessionDescription(
4247 CreateSessionDescription(JsepSessionDescription::kOffer, offer_sdp, NULL); 4249 JsepSessionDescription::kOffer, offer_sdp, nullptr);
4248 EXPECT_TRUE(offer->ToString(&offer_sdp)); 4250 EXPECT_TRUE(offer->ToString(&offer_sdp));
4249 4251
4250 // Offer SDP contains the RTX codec. 4252 // Offer SDP contains the RTX codec.
4251 EXPECT_TRUE(ContainsVideoCodecWithName(offer, "rtx")); 4253 EXPECT_TRUE(ContainsVideoCodecWithName(offer, "rtx"));
4252 SetRemoteDescriptionWithoutError(offer); 4254 SetRemoteDescriptionWithoutError(offer);
4253 4255
4254 SessionDescriptionInterface* answer = CreateAnswer(); 4256 SessionDescriptionInterface* answer = CreateAnswer();
4255 // Answer SDP does not contain the RTX codec. 4257 // Answer SDP does not contain the RTX codec.
4256 EXPECT_FALSE(ContainsVideoCodecWithName(answer, "rtx")); 4258 EXPECT_FALSE(ContainsVideoCodecWithName(answer, "rtx"));
4257 SetLocalDescriptionWithoutError(answer); 4259 SetLocalDescriptionWithoutError(answer);
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
4339 } 4341 }
4340 4342
4341 // TODO(bemasc): Add a TestIceStatesBundle with BUNDLE enabled. That test 4343 // TODO(bemasc): Add a TestIceStatesBundle with BUNDLE enabled. That test
4342 // currently fails because upon disconnection and reconnection OnIceComplete is 4344 // currently fails because upon disconnection and reconnection OnIceComplete is
4343 // called more than once without returning to IceGatheringGathering. 4345 // called more than once without returning to IceGatheringGathering.
4344 4346
4345 INSTANTIATE_TEST_CASE_P(WebRtcSessionTests, 4347 INSTANTIATE_TEST_CASE_P(WebRtcSessionTests,
4346 WebRtcSessionTest, 4348 WebRtcSessionTest,
4347 testing::Values(ALREADY_GENERATED, 4349 testing::Values(ALREADY_GENERATED,
4348 DTLS_IDENTITY_STORE)); 4350 DTLS_IDENTITY_STORE));
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698