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

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

Issue 2991693002: Adding support for Unified Plan offer/answer negotiation. (Closed)
Patch Set: address review comments Created 3 years, 4 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 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 "a=fmtp:96 apt=0\r\n"; 136 "a=fmtp:96 apt=0\r\n";
137 137
138 static const char kStream1[] = "stream1"; 138 static const char kStream1[] = "stream1";
139 static const char kVideoTrack1[] = "video1"; 139 static const char kVideoTrack1[] = "video1";
140 static const char kAudioTrack1[] = "audio1"; 140 static const char kAudioTrack1[] = "audio1";
141 141
142 static const char kStream2[] = "stream2"; 142 static const char kStream2[] = "stream2";
143 static const char kVideoTrack2[] = "video2"; 143 static const char kVideoTrack2[] = "video2";
144 static const char kAudioTrack2[] = "audio2"; 144 static const char kAudioTrack2[] = "audio2";
145 145
146 static constexpr bool kStopped = true;
147
146 enum RTCCertificateGenerationMethod { ALREADY_GENERATED, DTLS_IDENTITY_STORE }; 148 enum RTCCertificateGenerationMethod { ALREADY_GENERATED, DTLS_IDENTITY_STORE };
147 149
148 class MockIceObserver : public webrtc::IceObserver { 150 class MockIceObserver : public webrtc::IceObserver {
149 public: 151 public:
150 MockIceObserver() 152 MockIceObserver()
151 : oncandidatesready_(false), 153 : oncandidatesready_(false),
152 ice_connection_state_(PeerConnectionInterface::kIceConnectionNew), 154 ice_connection_state_(PeerConnectionInterface::kIceConnectionNew),
153 ice_gathering_state_(PeerConnectionInterface::kIceGatheringNew) { 155 ice_gathering_state_(PeerConnectionInterface::kIceGatheringNew) {
154 } 156 }
155 157
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after
391 metrics_observer_(new rtc::RefCountedObject<FakeMetricsObserver>()) { 393 metrics_observer_(new rtc::RefCountedObject<FakeMetricsObserver>()) {
392 cricket::ServerAddresses stun_servers; 394 cricket::ServerAddresses stun_servers;
393 stun_servers.insert(stun_socket_addr_); 395 stun_servers.insert(stun_socket_addr_);
394 allocator_.reset(new cricket::BasicPortAllocator( 396 allocator_.reset(new cricket::BasicPortAllocator(
395 &network_manager_, 397 &network_manager_,
396 stun_servers, 398 stun_servers,
397 SocketAddress(), SocketAddress(), SocketAddress())); 399 SocketAddress(), SocketAddress(), SocketAddress()));
398 allocator_->set_flags(cricket::PORTALLOCATOR_DISABLE_TCP | 400 allocator_->set_flags(cricket::PORTALLOCATOR_DISABLE_TCP |
399 cricket::PORTALLOCATOR_DISABLE_RELAY); 401 cricket::PORTALLOCATOR_DISABLE_RELAY);
400 EXPECT_TRUE(channel_manager_->Init()); 402 EXPECT_TRUE(channel_manager_->Init());
401 desc_factory_->set_add_legacy_streams(false);
402 allocator_->set_step_delay(cricket::kMinimumStepDelay); 403 allocator_->set_step_delay(cricket::kMinimumStepDelay);
403 } 404 }
404 405
405 void AddInterface(const SocketAddress& addr) { 406 void AddInterface(const SocketAddress& addr) {
406 network_manager_.AddInterface(addr); 407 network_manager_.AddInterface(addr);
407 } 408 }
408 void RemoveInterface(const SocketAddress& addr) { 409 void RemoveInterface(const SocketAddress& addr) {
409 network_manager_.RemoveInterface(addr); 410 network_manager_.RemoveInterface(addr);
410 } 411 }
411 412
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
542 send_video_ = false; 543 send_video_ = false;
543 } 544 }
544 545
545 void SendVideoOnlyStream2() { 546 void SendVideoOnlyStream2() {
546 send_stream_1_ = false; 547 send_stream_1_ = false;
547 send_stream_2_ = true; 548 send_stream_2_ = true;
548 send_audio_ = false; 549 send_audio_ = false;
549 send_video_ = true; 550 send_video_ = true;
550 } 551 }
551 552
552 void AddStreamsToOptions(cricket::MediaSessionOptions* session_options) { 553 // Helper function used to add a specific media section to the
553 if (send_stream_1_ && send_audio_) { 554 // |session_options|.
554 session_options->AddSendStream(cricket::MEDIA_TYPE_AUDIO, kAudioTrack1, 555 void AddMediaSection(cricket::MediaType type,
555 kStream1); 556 const std::string& mid,
557 cricket::MediaContentDirection direction,
558 bool stopped,
559 cricket::MediaSessionOptions* opts) {
560 opts->media_description_options.push_back(cricket::MediaDescriptionOptions(
561 type, mid,
562 cricket::RtpTransceiverDirection::FromMediaContentDirection(direction),
563 stopped));
564 }
565
566 // Add the media sections to the options from |offered_media_sections_| when
567 // creating an answer or a new offer.
568 // This duplicates a lot of logic from PeerConnection but this can be fix when
569 // PeerConnection and WebRtcSession are merged.
570 void AddExistingMediaSectionsAndSendersToOptions(
571 cricket::MediaSessionOptions* session_options,
572 bool send_audio,
573 bool recv_audio,
574 bool send_video,
575 bool recv_video) {
576 int num_sim_layer = 1;
577 for (auto media_description_options : offered_media_sections_) {
578 if (media_description_options.type == cricket::MEDIA_TYPE_AUDIO) {
579 bool stopped = !send_audio && !recv_audio;
580 auto media_desc_options = cricket::MediaDescriptionOptions(
581 cricket::MEDIA_TYPE_AUDIO, media_description_options.mid,
582 cricket::RtpTransceiverDirection(send_audio, recv_audio), stopped);
583 if (send_stream_1_ && send_audio_) {
584 media_desc_options.AddAudioSender(kAudioTrack1, kStream1);
585 }
586 if (send_stream_2_ && send_audio_) {
587 media_desc_options.AddAudioSender(kAudioTrack2, kStream2);
588 }
589 session_options->media_description_options.push_back(
590 media_desc_options);
591 } else if (media_description_options.type == cricket::MEDIA_TYPE_VIDEO) {
592 bool stopped = !send_video && !recv_video;
593 auto media_desc_options = cricket::MediaDescriptionOptions(
594 cricket::MEDIA_TYPE_VIDEO, media_description_options.mid,
595 cricket::RtpTransceiverDirection(send_video, recv_video), stopped);
596 if (send_stream_1_ && send_video_) {
597 media_desc_options.AddVideoSender(kVideoTrack1, kStream1,
598 num_sim_layer);
599 }
600 if (send_stream_2_ && send_video_) {
601 media_desc_options.AddVideoSender(kVideoTrack2, kStream2,
602 num_sim_layer);
603 }
604 session_options->media_description_options.push_back(
605 media_desc_options);
606 } else if (media_description_options.type == cricket::MEDIA_TYPE_DATA) {
607 session_options->media_description_options.push_back(
608 cricket::MediaDescriptionOptions(
609 cricket::MEDIA_TYPE_DATA, media_description_options.mid,
610 // Direction for data sections is meaningless, but legacy
611 // endpoints might expect sendrecv.
612 cricket::RtpTransceiverDirection(true, true), false));
613 } else {
614 RTC_NOTREACHED();
615 }
556 } 616 }
557 if (send_stream_1_ && send_video_) { 617 }
558 session_options->AddSendStream(cricket::MEDIA_TYPE_VIDEO, kVideoTrack1, 618
559 kStream1); 619 // Add the existing media sections first and then add new media sections if
620 // needed.
621 void AddMediaSectionsAndSendersToOptions(
622 cricket::MediaSessionOptions* session_options,
623 bool recv_audio,
624 bool recv_video) {
625 AddExistingMediaSectionsAndSendersToOptions(
626 session_options, send_audio_, recv_audio, send_video_, recv_video);
627
628 if (!session_options->has_audio() && (send_audio_ || recv_audio)) {
629 cricket::MediaDescriptionOptions media_desc_options =
630 cricket::MediaDescriptionOptions(
631 cricket::MEDIA_TYPE_AUDIO, cricket::CN_AUDIO,
632 cricket::RtpTransceiverDirection(send_audio_, recv_audio), true);
633 if (send_stream_1_ && send_audio_) {
634 media_desc_options.AddAudioSender(kAudioTrack1, kStream1);
635 }
636 if (send_stream_2_ && send_audio_) {
637 media_desc_options.AddAudioSender(kAudioTrack2, kStream2);
638 }
639 session_options->media_description_options.push_back(media_desc_options);
640 offered_media_sections_.push_back(media_desc_options);
560 } 641 }
561 if (send_stream_2_ && send_audio_) { 642
562 session_options->AddSendStream(cricket::MEDIA_TYPE_AUDIO, kAudioTrack2, 643 if (!session_options->has_video() && (send_video_ || recv_video)) {
563 kStream2); 644 cricket::MediaDescriptionOptions media_desc_options =
645 cricket::MediaDescriptionOptions(
646 cricket::MEDIA_TYPE_VIDEO, cricket::CN_VIDEO,
647 cricket::RtpTransceiverDirection(send_video_, recv_video), true);
648 int num_sim_layer = 1;
649 if (send_stream_1_ && send_video_) {
650 media_desc_options.AddVideoSender(kVideoTrack1, kStream1,
651 num_sim_layer);
652 }
653 if (send_stream_2_ && send_video_) {
654 media_desc_options.AddVideoSender(kVideoTrack2, kStream2,
655 num_sim_layer);
656 }
657 session_options->media_description_options.push_back(media_desc_options);
658 offered_media_sections_.push_back(media_desc_options);
564 } 659 }
565 if (send_stream_2_ && send_video_) { 660
566 session_options->AddSendStream(cricket::MEDIA_TYPE_VIDEO, kVideoTrack2, 661 if (!session_options->has_data() &&
567 kStream2); 662 (data_channel_ ||
568 } 663 session_options->data_channel_type != cricket::DCT_NONE)) {
569 if (data_channel_ && session_->data_channel_type() == cricket::DCT_RTP) { 664 cricket::MediaDescriptionOptions media_desc_options =
570 session_options->AddSendStream(cricket::MEDIA_TYPE_DATA, 665 cricket::MediaDescriptionOptions(
571 data_channel_->label(), 666 cricket::MEDIA_TYPE_DATA, cricket::CN_DATA,
572 data_channel_->label()); 667 cricket::RtpTransceiverDirection(true, true), false);
668 if (session_options->data_channel_type == cricket::DCT_RTP) {
669 media_desc_options.AddRtpDataChannel(data_channel_->label(),
670 data_channel_->label());
671 }
672 session_options->media_description_options.push_back(media_desc_options);
673 offered_media_sections_.push_back(media_desc_options);
573 } 674 }
574 } 675 }
575 676
576 void GetOptionsForOffer( 677 void GetOptionsForOffer(
577 const PeerConnectionInterface::RTCOfferAnswerOptions& rtc_options, 678 const PeerConnectionInterface::RTCOfferAnswerOptions& rtc_options,
578 cricket::MediaSessionOptions* session_options) { 679 cricket::MediaSessionOptions* session_options) {
579 ASSERT_TRUE(ExtractMediaSessionOptions(rtc_options, true, session_options)); 680 ExtractSharedMediaSessionOptions(rtc_options, session_options);
580 681
581 AddStreamsToOptions(session_options); 682 // |recv_X| is true by default if |offer_to_receive_X| is undefined.
582 if (rtc_options.offer_to_receive_audio == 683 bool recv_audio = rtc_options.offer_to_receive_audio != 0;
583 RTCOfferAnswerOptions::kUndefined) { 684 bool recv_video = rtc_options.offer_to_receive_video != 0;
584 session_options->recv_audio = 685
585 session_options->HasSendMediaStream(cricket::MEDIA_TYPE_AUDIO); 686 AddMediaSectionsAndSendersToOptions(session_options, recv_audio,
586 } 687 recv_video);
587 if (rtc_options.offer_to_receive_video ==
588 RTCOfferAnswerOptions::kUndefined) {
589 session_options->recv_video =
590 session_options->HasSendMediaStream(cricket::MEDIA_TYPE_VIDEO);
591 }
592 session_options->bundle_enabled = 688 session_options->bundle_enabled =
593 session_options->bundle_enabled && 689 session_options->bundle_enabled &&
594 (session_options->has_audio() || session_options->has_video() || 690 (session_options->has_audio() || session_options->has_video() ||
595 session_options->has_data()); 691 session_options->has_data());
596 692
597 if (session_->data_channel_type() == cricket::DCT_SCTP && data_channel_) {
598 session_options->data_channel_type = cricket::DCT_SCTP;
599 } else if (session_->data_channel_type() == cricket::DCT_QUIC) {
600 session_options->data_channel_type = cricket::DCT_QUIC;
601 }
602
603 session_options->crypto_options = crypto_options_; 693 session_options->crypto_options = crypto_options_;
604 } 694 }
605 695
606 void GetOptionsForAnswer(cricket::MediaSessionOptions* session_options) { 696 void GetOptionsForAnswer(cricket::MediaSessionOptions* session_options) {
607 // ParseConstraintsForAnswer is used to set some defaults. 697 // |recv_X| is true if callee wants to receive or the caller wants to send.
608 ASSERT_TRUE(webrtc::ParseConstraintsForAnswer(nullptr, session_options)); 698 bool recv_audio = recv_audio_ || send_audio_;
699 bool recv_video = recv_video_ || send_video_;
700 bool send_audio = false;
701 bool send_video = false;
609 702
610 AddStreamsToOptions(session_options); 703 AddExistingMediaSectionsAndSendersToOptions(
704 session_options, send_audio, recv_audio, send_video, recv_video);
705
611 session_options->bundle_enabled = 706 session_options->bundle_enabled =
612 session_options->bundle_enabled && 707 session_options->bundle_enabled &&
613 (session_options->has_audio() || session_options->has_video() || 708 (session_options->has_audio() || session_options->has_video() ||
614 session_options->has_data()); 709 session_options->has_data());
615 710
616 if (session_->data_channel_type() != cricket::DCT_RTP) { 711 if (session_->data_channel_type() != cricket::DCT_RTP) {
617 session_options->data_channel_type = session_->data_channel_type(); 712 session_options->data_channel_type = session_->data_channel_type();
618 } 713 }
619 714
620 session_options->crypto_options = crypto_options_; 715 session_options->crypto_options = crypto_options_;
621 } 716 }
622 717
718 void GetOptionsForAudioOnlyRemoteOffer(
719 cricket::MediaSessionOptions* session_options) {
720 recv_audio_ = true;
721 recv_video_ = false;
722 GetOptionsForRemoteOffer(session_options);
723 }
724
725 void GetOptionsForRemoteOffer(cricket::MediaSessionOptions* session_options) {
726 AddMediaSectionsAndSendersToOptions(session_options, recv_audio_,
727 recv_video_);
728 session_options->bundle_enabled =
729 (session_options->has_audio() || session_options->has_video() ||
730 session_options->has_data());
731
732 if (session_->data_channel_type() != cricket::DCT_RTP) {
733 session_options->data_channel_type = session_->data_channel_type();
734 }
735
736 session_options->crypto_options = crypto_options_;
737 }
738
623 // Creates a local offer and applies it. Starts ICE. 739 // Creates a local offer and applies it. Starts ICE.
624 // Call SendAudioVideoStreamX() before this function 740 // Call SendAudioVideoStreamX() before this function
625 // to decide which streams to create. 741 // to decide which streams to create.
626 void InitiateCall() { 742 void InitiateCall() {
627 SessionDescriptionInterface* offer = CreateOffer(); 743 SessionDescriptionInterface* offer = CreateOffer();
628 SetLocalDescriptionWithoutError(offer); 744 SetLocalDescriptionWithoutError(offer);
629 EXPECT_TRUE_WAIT(PeerConnectionInterface::kIceGatheringNew != 745 EXPECT_TRUE_WAIT(PeerConnectionInterface::kIceGatheringNew !=
630 observer_.ice_gathering_state_, 746 observer_.ice_gathering_state_,
631 kIceCandidatesTimeout); 747 kIceCandidatesTimeout);
632 } 748 }
633 749
634 SessionDescriptionInterface* CreateOffer() { 750 SessionDescriptionInterface* CreateOffer() {
635 PeerConnectionInterface::RTCOfferAnswerOptions options; 751 PeerConnectionInterface::RTCOfferAnswerOptions options;
636 options.offer_to_receive_audio = 752 options.offer_to_receive_audio =
637 RTCOfferAnswerOptions::kOfferToReceiveMediaTrue; 753 RTCOfferAnswerOptions::kOfferToReceiveMediaTrue;
638
639 return CreateOffer(options); 754 return CreateOffer(options);
640 } 755 }
641 756
642 SessionDescriptionInterface* CreateOffer( 757 SessionDescriptionInterface* CreateOffer(
643 const PeerConnectionInterface::RTCOfferAnswerOptions options) { 758 const PeerConnectionInterface::RTCOfferAnswerOptions options) {
644 rtc::scoped_refptr<WebRtcSessionCreateSDPObserverForTest> 759 rtc::scoped_refptr<WebRtcSessionCreateSDPObserverForTest>
645 observer = new WebRtcSessionCreateSDPObserverForTest(); 760 observer = new WebRtcSessionCreateSDPObserverForTest();
646 cricket::MediaSessionOptions session_options; 761 cricket::MediaSessionOptions session_options;
647 GetOptionsForOffer(options, &session_options); 762 GetOptionsForOffer(options, &session_options);
648 session_->CreateOffer(observer, options, session_options); 763 session_->CreateOffer(observer, options, session_options);
649 EXPECT_TRUE_WAIT( 764 EXPECT_TRUE_WAIT(
650 observer->state() != WebRtcSessionCreateSDPObserverForTest::kInit, 765 observer->state() != WebRtcSessionCreateSDPObserverForTest::kInit,
651 2000); 766 2000);
652 return observer->ReleaseDescription(); 767 return observer->ReleaseDescription();
653 } 768 }
654 769
655 SessionDescriptionInterface* CreateAnswer( 770 SessionDescriptionInterface* CreateAnswer(
656 const cricket::MediaSessionOptions& options) { 771 const cricket::MediaSessionOptions& options) {
657 rtc::scoped_refptr<WebRtcSessionCreateSDPObserverForTest> observer 772 rtc::scoped_refptr<WebRtcSessionCreateSDPObserverForTest> observer
658 = new WebRtcSessionCreateSDPObserverForTest(); 773 = new WebRtcSessionCreateSDPObserverForTest();
659 cricket::MediaSessionOptions session_options = options; 774 cricket::MediaSessionOptions session_options = options;
660 GetOptionsForAnswer(&session_options); 775 GetOptionsForAnswer(&session_options);
661 // Overwrite recv_audio and recv_video with passed-in values.
662 session_options.recv_video = options.recv_video;
663 session_options.recv_audio = options.recv_audio;
664 session_->CreateAnswer(observer, session_options); 776 session_->CreateAnswer(observer, session_options);
665 EXPECT_TRUE_WAIT( 777 EXPECT_TRUE_WAIT(
666 observer->state() != WebRtcSessionCreateSDPObserverForTest::kInit, 778 observer->state() != WebRtcSessionCreateSDPObserverForTest::kInit,
667 2000); 779 2000);
668 return observer->ReleaseDescription(); 780 return observer->ReleaseDescription();
669 } 781 }
670 782
671 SessionDescriptionInterface* CreateAnswer() { 783 SessionDescriptionInterface* CreateAnswer() {
672 cricket::MediaSessionOptions options; 784 cricket::MediaSessionOptions options;
673 options.recv_video = true; 785 options.bundle_enabled = true;
674 options.recv_audio = true;
675 return CreateAnswer(options); 786 return CreateAnswer(options);
676 } 787 }
677 788
678 bool ChannelsExist() const { 789 bool ChannelsExist() const {
679 return (session_->voice_channel() != NULL && 790 return (session_->voice_channel() != NULL &&
680 session_->video_channel() != NULL); 791 session_->video_channel() != NULL);
681 } 792 }
682 793
683 void VerifyCryptoParams(const cricket::SessionDescription* sdp, 794 void VerifyCryptoParams(const cricket::SessionDescription* sdp,
684 bool gcm_enabled = false) { 795 bool gcm_enabled = false) {
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
782 ASSERT_TRUE(audio != NULL); 893 ASSERT_TRUE(audio != NULL);
783 ASSERT_EQ(expected, audio->description.identity_fingerprint.get() != NULL); 894 ASSERT_EQ(expected, audio->description.identity_fingerprint.get() != NULL);
784 const TransportInfo* video = sdp->GetTransportInfoByName("video"); 895 const TransportInfo* video = sdp->GetTransportInfoByName("video");
785 ASSERT_TRUE(video != NULL); 896 ASSERT_TRUE(video != NULL);
786 ASSERT_EQ(expected, video->description.identity_fingerprint.get() != NULL); 897 ASSERT_EQ(expected, video->description.identity_fingerprint.get() != NULL);
787 } 898 }
788 899
789 void VerifyAnswerFromNonCryptoOffer() { 900 void VerifyAnswerFromNonCryptoOffer() {
790 // Create an SDP without Crypto. 901 // Create an SDP without Crypto.
791 cricket::MediaSessionOptions options; 902 cricket::MediaSessionOptions options;
792 options.recv_video = true; 903 GetOptionsForRemoteOffer(&options);
793 JsepSessionDescription* offer( 904 JsepSessionDescription* offer(
794 CreateRemoteOffer(options, cricket::SEC_DISABLED)); 905 CreateRemoteOffer(options, cricket::SEC_DISABLED));
795 ASSERT_TRUE(offer != NULL); 906 ASSERT_TRUE(offer != NULL);
796 VerifyNoCryptoParams(offer->description(), false); 907 VerifyNoCryptoParams(offer->description(), false);
797 SetRemoteDescriptionOfferExpectError(kSdpWithoutSdesCrypto, 908 SetRemoteDescriptionOfferExpectError(kSdpWithoutSdesCrypto,
798 offer); 909 offer);
799 const webrtc::SessionDescriptionInterface* answer = CreateAnswer(); 910 const webrtc::SessionDescriptionInterface* answer = CreateAnswer();
800 // Answer should be NULL as no crypto params in offer. 911 // Answer should be NULL as no crypto params in offer.
801 ASSERT_TRUE(answer == NULL); 912 ASSERT_TRUE(answer == NULL);
802 } 913 }
803 914
804 void VerifyAnswerFromCryptoOffer() { 915 void VerifyAnswerFromCryptoOffer() {
805 cricket::MediaSessionOptions options; 916 cricket::MediaSessionOptions options;
806 options.recv_video = true; 917 GetOptionsForRemoteOffer(&options);
807 options.bundle_enabled = true; 918 options.bundle_enabled = true;
808 std::unique_ptr<JsepSessionDescription> offer( 919 std::unique_ptr<JsepSessionDescription> offer(
809 CreateRemoteOffer(options, cricket::SEC_REQUIRED)); 920 CreateRemoteOffer(options, cricket::SEC_REQUIRED));
810 ASSERT_TRUE(offer.get() != NULL); 921 ASSERT_TRUE(offer.get() != NULL);
811 VerifyCryptoParams(offer->description()); 922 VerifyCryptoParams(offer->description());
812 SetRemoteDescriptionWithoutError(offer.release()); 923 SetRemoteDescriptionWithoutError(offer.release());
813 std::unique_ptr<SessionDescriptionInterface> answer(CreateAnswer()); 924 std::unique_ptr<SessionDescriptionInterface> answer(CreateAnswer());
814 ASSERT_TRUE(answer.get() != NULL); 925 ASSERT_TRUE(answer.get() != NULL);
815 VerifyCryptoParams(answer->description()); 926 VerifyCryptoParams(answer->description());
816 } 927 }
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
985 void SetRemoteDescriptionAnswerExpectError( 1096 void SetRemoteDescriptionAnswerExpectError(
986 const std::string& expected_error, SessionDescriptionInterface* desc) { 1097 const std::string& expected_error, SessionDescriptionInterface* desc) {
987 SetRemoteDescriptionExpectError(SessionDescriptionInterface::kAnswer, 1098 SetRemoteDescriptionExpectError(SessionDescriptionInterface::kAnswer,
988 expected_error, desc); 1099 expected_error, desc);
989 } 1100 }
990 1101
991 void CreateCryptoOfferAndNonCryptoAnswer(SessionDescriptionInterface** offer, 1102 void CreateCryptoOfferAndNonCryptoAnswer(SessionDescriptionInterface** offer,
992 SessionDescriptionInterface** nocrypto_answer) { 1103 SessionDescriptionInterface** nocrypto_answer) {
993 // Create a SDP without Crypto. 1104 // Create a SDP without Crypto.
994 cricket::MediaSessionOptions options; 1105 cricket::MediaSessionOptions options;
995 options.recv_video = true; 1106 GetOptionsForRemoteOffer(&options);
996 options.bundle_enabled = true; 1107 options.bundle_enabled = true;
997 *offer = CreateRemoteOffer(options, cricket::SEC_ENABLED); 1108 *offer = CreateRemoteOffer(options, cricket::SEC_ENABLED);
998 ASSERT_TRUE(*offer != NULL); 1109 ASSERT_TRUE(*offer != NULL);
999 VerifyCryptoParams((*offer)->description()); 1110 VerifyCryptoParams((*offer)->description());
1000 1111
1001 *nocrypto_answer = CreateRemoteAnswer(*offer, options, 1112 cricket::MediaSessionOptions answer_options;
1002 cricket::SEC_DISABLED); 1113 GetOptionsForAnswer(&answer_options);
1114 *nocrypto_answer =
1115 CreateRemoteAnswer(*offer, answer_options, cricket::SEC_DISABLED);
1003 EXPECT_TRUE(*nocrypto_answer != NULL); 1116 EXPECT_TRUE(*nocrypto_answer != NULL);
1004 } 1117 }
1005 1118
1006 void CreateDtlsOfferAndNonDtlsAnswer(SessionDescriptionInterface** offer, 1119 void CreateDtlsOfferAndNonDtlsAnswer(SessionDescriptionInterface** offer,
1007 SessionDescriptionInterface** nodtls_answer) { 1120 SessionDescriptionInterface** nodtls_answer) {
1008 cricket::MediaSessionOptions options; 1121 cricket::MediaSessionOptions options;
1009 options.recv_video = true; 1122 AddMediaSection(cricket::MEDIA_TYPE_AUDIO, cricket::CN_AUDIO,
1123 cricket::MD_RECVONLY, !kStopped, &options);
1124 AddMediaSection(cricket::MEDIA_TYPE_VIDEO, cricket::CN_VIDEO,
1125 cricket::MD_RECVONLY, !kStopped, &options);
1010 options.bundle_enabled = true; 1126 options.bundle_enabled = true;
1011 1127
1012 std::unique_ptr<SessionDescriptionInterface> temp_offer( 1128 std::unique_ptr<SessionDescriptionInterface> temp_offer(
1013 CreateRemoteOffer(options, cricket::SEC_ENABLED)); 1129 CreateRemoteOffer(options, cricket::SEC_ENABLED));
1014 1130
1015 *nodtls_answer = 1131 *nodtls_answer =
1016 CreateRemoteAnswer(temp_offer.get(), options, cricket::SEC_ENABLED); 1132 CreateRemoteAnswer(temp_offer.get(), options, cricket::SEC_ENABLED);
1017 EXPECT_TRUE(*nodtls_answer != NULL); 1133 EXPECT_TRUE(*nodtls_answer != NULL);
1018 VerifyFingerprintStatus((*nodtls_answer)->description(), false); 1134 VerifyFingerprintStatus((*nodtls_answer)->description(), false);
1019 VerifyCryptoParams((*nodtls_answer)->description()); 1135 VerifyCryptoParams((*nodtls_answer)->description());
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
1061 cricket::MediaSessionOptions options, 1177 cricket::MediaSessionOptions options,
1062 const SessionDescriptionInterface* current_desc) { 1178 const SessionDescriptionInterface* current_desc) {
1063 return CreateRemoteOfferWithVersion(options, cricket::SEC_ENABLED, 1179 return CreateRemoteOfferWithVersion(options, cricket::SEC_ENABLED,
1064 kSessionVersion, current_desc); 1180 kSessionVersion, current_desc);
1065 } 1181 }
1066 1182
1067 JsepSessionDescription* CreateRemoteOfferWithSctpPort( 1183 JsepSessionDescription* CreateRemoteOfferWithSctpPort(
1068 const char* sctp_stream_name, int new_port, 1184 const char* sctp_stream_name, int new_port,
1069 cricket::MediaSessionOptions options) { 1185 cricket::MediaSessionOptions options) {
1070 options.data_channel_type = cricket::DCT_SCTP; 1186 options.data_channel_type = cricket::DCT_SCTP;
1071 options.AddSendStream(cricket::MEDIA_TYPE_DATA, "datachannel", 1187 GetOptionsForRemoteOffer(&options);
1072 sctp_stream_name);
1073 return ChangeSDPSctpPort(new_port, CreateRemoteOffer(options)); 1188 return ChangeSDPSctpPort(new_port, CreateRemoteOffer(options));
1074 } 1189 }
1075 1190
1076 // Takes ownership of offer_basis (and deletes it). 1191 // Takes ownership of offer_basis (and deletes it).
1077 JsepSessionDescription* ChangeSDPSctpPort( 1192 JsepSessionDescription* ChangeSDPSctpPort(
1078 int new_port, webrtc::SessionDescriptionInterface *offer_basis) { 1193 int new_port, webrtc::SessionDescriptionInterface *offer_basis) {
1079 // Stringify the input SDP, swap the 5000 for 'new_port' and create a new 1194 // Stringify the input SDP, swap the 5000 for 'new_port' and create a new
1080 // SessionDescription from the mutated string. 1195 // SessionDescription from the mutated string.
1081 const char* default_port_str = "5000"; 1196 const char* default_port_str = "5000";
1082 char new_port_str[16]; 1197 char new_port_str[16];
1083 rtc::sprintfn(new_port_str, sizeof(new_port_str), "%d", new_port); 1198 rtc::sprintfn(new_port_str, sizeof(new_port_str), "%d", new_port);
1084 std::string offer_str; 1199 std::string offer_str;
1085 offer_basis->ToString(&offer_str); 1200 offer_basis->ToString(&offer_str);
1086 rtc::replace_substrs(default_port_str, strlen(default_port_str), 1201 rtc::replace_substrs(default_port_str, strlen(default_port_str),
1087 new_port_str, strlen(new_port_str), 1202 new_port_str, strlen(new_port_str),
1088 &offer_str); 1203 &offer_str);
1089 JsepSessionDescription* offer = new JsepSessionDescription( 1204 JsepSessionDescription* offer = new JsepSessionDescription(
1090 offer_basis->type()); 1205 offer_basis->type());
1091 delete offer_basis; 1206 delete offer_basis;
1092 offer->Initialize(offer_str, NULL); 1207 offer->Initialize(offer_str, NULL);
1093 return offer; 1208 return offer;
1094 } 1209 }
1095 1210
1096 // Create a remote offer. Call SendAudioVideoStreamX() 1211 // Create a remote offer. Call SendAudioVideoStreamX()
1097 // before this function to decide which streams to create. 1212 // before this function to decide which streams to create.
1098 JsepSessionDescription* CreateRemoteOffer() { 1213 JsepSessionDescription* CreateRemoteOffer() {
1099 cricket::MediaSessionOptions options; 1214 cricket::MediaSessionOptions options;
1100 GetOptionsForAnswer(&options); 1215 GetOptionsForRemoteOffer(&options);
1101 return CreateRemoteOffer(options, session_->remote_description()); 1216 return CreateRemoteOffer(options, session_->remote_description());
1102 } 1217 }
1103 1218
1104 JsepSessionDescription* CreateRemoteAnswer( 1219 JsepSessionDescription* CreateRemoteAnswer(
1105 const SessionDescriptionInterface* offer, 1220 const SessionDescriptionInterface* offer,
1106 cricket::MediaSessionOptions options, 1221 cricket::MediaSessionOptions options,
1107 cricket::SecurePolicy policy) { 1222 cricket::SecurePolicy policy) {
1108 desc_factory_->set_secure(policy); 1223 desc_factory_->set_secure(policy);
1109 const std::string session_id = 1224 const std::string session_id =
1110 rtc::ToString(rtc::CreateRandomId64()); 1225 rtc::ToString(rtc::CreateRandomId64());
(...skipping 14 matching lines...) Expand all
1125 return CreateRemoteAnswer(offer, options, cricket::SEC_REQUIRED); 1240 return CreateRemoteAnswer(offer, options, cricket::SEC_REQUIRED);
1126 } 1241 }
1127 1242
1128 // Creates an answer session description. 1243 // Creates an answer session description.
1129 // Call SendAudioVideoStreamX() before this function 1244 // Call SendAudioVideoStreamX() before this function
1130 // to decide which streams to create. 1245 // to decide which streams to create.
1131 JsepSessionDescription* CreateRemoteAnswer( 1246 JsepSessionDescription* CreateRemoteAnswer(
1132 const SessionDescriptionInterface* offer) { 1247 const SessionDescriptionInterface* offer) {
1133 cricket::MediaSessionOptions options; 1248 cricket::MediaSessionOptions options;
1134 GetOptionsForAnswer(&options); 1249 GetOptionsForAnswer(&options);
1250 options.bundle_enabled = true;
1135 return CreateRemoteAnswer(offer, options, cricket::SEC_REQUIRED); 1251 return CreateRemoteAnswer(offer, options, cricket::SEC_REQUIRED);
1136 } 1252 }
1137 1253
1138 void TestSessionCandidatesWithBundleRtcpMux(bool bundle, bool rtcp_mux) { 1254 void TestSessionCandidatesWithBundleRtcpMux(bool bundle, bool rtcp_mux) {
1139 AddInterface(rtc::SocketAddress(kClientAddrHost1, kClientAddrPort)); 1255 AddInterface(rtc::SocketAddress(kClientAddrHost1, kClientAddrPort));
1140 Init(); 1256 Init();
1141 SendAudioVideoStream1(); 1257 SendAudioVideoStream1();
1142 1258
1143 PeerConnectionInterface::RTCOfferAnswerOptions options; 1259 PeerConnectionInterface::RTCOfferAnswerOptions options;
1144 options.use_rtp_mux = bundle; 1260 options.use_rtp_mux = bundle;
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after
1448 InitWithDtlsIdentityGenFail(); 1564 InitWithDtlsIdentityGenFail();
1449 VerifyMultipleAsyncCreateDescriptionAfterInit(false, type); 1565 VerifyMultipleAsyncCreateDescriptionAfterInit(false, type);
1450 } 1566 }
1451 1567
1452 void VerifyMultipleAsyncCreateDescriptionAfterInit( 1568 void VerifyMultipleAsyncCreateDescriptionAfterInit(
1453 bool success, CreateSessionDescriptionRequest::Type type) { 1569 bool success, CreateSessionDescriptionRequest::Type type) {
1454 RTC_CHECK(session_); 1570 RTC_CHECK(session_);
1455 SetFactoryDtlsSrtp(); 1571 SetFactoryDtlsSrtp();
1456 if (type == CreateSessionDescriptionRequest::kAnswer) { 1572 if (type == CreateSessionDescriptionRequest::kAnswer) {
1457 cricket::MediaSessionOptions options; 1573 cricket::MediaSessionOptions options;
1574 GetOptionsForRemoteOffer(&options);
1458 std::unique_ptr<JsepSessionDescription> offer( 1575 std::unique_ptr<JsepSessionDescription> offer(
1459 CreateRemoteOffer(options, cricket::SEC_DISABLED)); 1576 CreateRemoteOffer(options, cricket::SEC_DISABLED));
1460 ASSERT_TRUE(offer.get() != NULL); 1577 ASSERT_TRUE(offer.get() != NULL);
1461 SetRemoteDescriptionWithoutError(offer.release()); 1578 SetRemoteDescriptionWithoutError(offer.release());
1462 } 1579 }
1463 1580
1464 PeerConnectionInterface::RTCOfferAnswerOptions options; 1581 PeerConnectionInterface::RTCOfferAnswerOptions options;
1465 cricket::MediaSessionOptions session_options; 1582 cricket::MediaSessionOptions offer_session_options;
1583 cricket::MediaSessionOptions answer_session_options;
1584 GetOptionsForOffer(options, &offer_session_options);
1585 GetOptionsForAnswer(&answer_session_options);
1466 const int kNumber = 3; 1586 const int kNumber = 3;
1467 rtc::scoped_refptr<WebRtcSessionCreateSDPObserverForTest> 1587 rtc::scoped_refptr<WebRtcSessionCreateSDPObserverForTest>
1468 observers[kNumber]; 1588 observers[kNumber];
1469 for (int i = 0; i < kNumber; ++i) { 1589 for (int i = 0; i < kNumber; ++i) {
1470 observers[i] = new WebRtcSessionCreateSDPObserverForTest(); 1590 observers[i] = new WebRtcSessionCreateSDPObserverForTest();
1471 if (type == CreateSessionDescriptionRequest::kOffer) { 1591 if (type == CreateSessionDescriptionRequest::kOffer) {
1472 session_->CreateOffer(observers[i], options, session_options); 1592 session_->CreateOffer(observers[i], options, offer_session_options);
1473 } else { 1593 } else {
1474 session_->CreateAnswer(observers[i], session_options); 1594 session_->CreateAnswer(observers[i], answer_session_options);
1475 } 1595 }
1476 } 1596 }
1477 1597
1478 WebRtcSessionCreateSDPObserverForTest::State expected_state = 1598 WebRtcSessionCreateSDPObserverForTest::State expected_state =
1479 success ? WebRtcSessionCreateSDPObserverForTest::kSucceeded : 1599 success ? WebRtcSessionCreateSDPObserverForTest::kSucceeded :
1480 WebRtcSessionCreateSDPObserverForTest::kFailed; 1600 WebRtcSessionCreateSDPObserverForTest::kFailed;
1481 1601
1482 for (int i = 0; i < kNumber; ++i) { 1602 for (int i = 0; i < kNumber; ++i) {
1483 EXPECT_EQ_WAIT(expected_state, observers[i]->state(), 1000); 1603 EXPECT_EQ_WAIT(expected_state, observers[i]->state(), 1000);
1484 if (success) { 1604 if (success) {
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
1524 std::unique_ptr<WebRtcSessionForTest> session_; 1644 std::unique_ptr<WebRtcSessionForTest> session_;
1525 MockIceObserver observer_; 1645 MockIceObserver observer_;
1526 cricket::FakeVideoMediaChannel* video_channel_; 1646 cricket::FakeVideoMediaChannel* video_channel_;
1527 cricket::FakeVoiceMediaChannel* voice_channel_; 1647 cricket::FakeVoiceMediaChannel* voice_channel_;
1528 rtc::scoped_refptr<FakeMetricsObserver> metrics_observer_; 1648 rtc::scoped_refptr<FakeMetricsObserver> metrics_observer_;
1529 // The following flags affect options created for CreateOffer/CreateAnswer. 1649 // The following flags affect options created for CreateOffer/CreateAnswer.
1530 bool send_stream_1_ = false; 1650 bool send_stream_1_ = false;
1531 bool send_stream_2_ = false; 1651 bool send_stream_2_ = false;
1532 bool send_audio_ = false; 1652 bool send_audio_ = false;
1533 bool send_video_ = false; 1653 bool send_video_ = false;
1654 bool recv_audio_ = true;
1655 bool recv_video_ = true;
1656 std::vector<cricket::MediaDescriptionOptions> offered_media_sections_;
1534 rtc::scoped_refptr<DataChannel> data_channel_; 1657 rtc::scoped_refptr<DataChannel> data_channel_;
1535 // Last values received from data channel creation signal. 1658 // Last values received from data channel creation signal.
1536 std::string last_data_channel_label_; 1659 std::string last_data_channel_label_;
1537 InternalDataChannelInit last_data_channel_config_; 1660 InternalDataChannelInit last_data_channel_config_;
1538 rtc::CryptoOptions crypto_options_; 1661 rtc::CryptoOptions crypto_options_;
1539 }; 1662 };
1540 1663
1541 TEST_P(WebRtcSessionTest, TestInitializeWithDtls) { 1664 TEST_P(WebRtcSessionTest, TestInitializeWithDtls) {
1542 InitWithDtls(GetParam()); 1665 InitWithDtls(GetParam());
1543 // SDES is disabled when DTLS is on. 1666 // SDES is disabled when DTLS is on.
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after
1763 // answer without SDES or DTLS --> success 1886 // answer without SDES or DTLS --> success
1764 // TestCreateAnswerReceiveOfferWithoutEncryption: set remote offer and local 1887 // TestCreateAnswerReceiveOfferWithoutEncryption: set remote offer and local
1765 // answer without SDES or DTLS --> success 1888 // answer without SDES or DTLS --> success
1766 // 1889 //
1767 1890
1768 // Test that we return a failure when applying a remote/local offer that doesn't 1891 // Test that we return a failure when applying a remote/local offer that doesn't
1769 // have cryptos enabled when DTLS is off. 1892 // have cryptos enabled when DTLS is off.
1770 TEST_F(WebRtcSessionTest, TestSetNonSdesOfferWhenSdesOn) { 1893 TEST_F(WebRtcSessionTest, TestSetNonSdesOfferWhenSdesOn) {
1771 Init(); 1894 Init();
1772 cricket::MediaSessionOptions options; 1895 cricket::MediaSessionOptions options;
1773 options.recv_video = true; 1896 GetOptionsForRemoteOffer(&options);
1774 JsepSessionDescription* offer = CreateRemoteOffer( 1897 JsepSessionDescription* offer = CreateRemoteOffer(
1775 options, cricket::SEC_DISABLED); 1898 options, cricket::SEC_DISABLED);
1776 ASSERT_TRUE(offer != NULL); 1899 ASSERT_TRUE(offer != NULL);
1777 VerifyNoCryptoParams(offer->description(), false); 1900 VerifyNoCryptoParams(offer->description(), false);
1778 // SetRemoteDescription and SetLocalDescription will take the ownership of 1901 // SetRemoteDescription and SetLocalDescription will take the ownership of
1779 // the offer. 1902 // the offer.
1780 SetRemoteDescriptionOfferExpectError(kSdpWithoutSdesCrypto, offer); 1903 SetRemoteDescriptionOfferExpectError(kSdpWithoutSdesCrypto, offer);
1781 offer = CreateRemoteOffer(options, cricket::SEC_DISABLED); 1904 offer = CreateRemoteOffer(options, cricket::SEC_DISABLED);
1782 ASSERT_TRUE(offer != NULL); 1905 ASSERT_TRUE(offer != NULL);
1783 SetLocalDescriptionOfferExpectError(kSdpWithoutSdesCrypto, offer); 1906 SetLocalDescriptionOfferExpectError(kSdpWithoutSdesCrypto, offer);
(...skipping 25 matching lines...) Expand all
1809 SetRemoteDescriptionAnswerExpectError(kSdpWithoutSdesCrypto, answer); 1932 SetRemoteDescriptionAnswerExpectError(kSdpWithoutSdesCrypto, answer);
1810 } 1933 }
1811 1934
1812 // Test that we accept an offer with a DTLS fingerprint when DTLS is on 1935 // Test that we accept an offer with a DTLS fingerprint when DTLS is on
1813 // and that we return an answer with a DTLS fingerprint. 1936 // and that we return an answer with a DTLS fingerprint.
1814 TEST_P(WebRtcSessionTest, TestReceiveDtlsOfferCreateDtlsAnswer) { 1937 TEST_P(WebRtcSessionTest, TestReceiveDtlsOfferCreateDtlsAnswer) {
1815 SendAudioVideoStream1(); 1938 SendAudioVideoStream1();
1816 InitWithDtls(GetParam()); 1939 InitWithDtls(GetParam());
1817 SetFactoryDtlsSrtp(); 1940 SetFactoryDtlsSrtp();
1818 cricket::MediaSessionOptions options; 1941 cricket::MediaSessionOptions options;
1819 options.recv_video = true; 1942 GetOptionsForRemoteOffer(&options);
1820 JsepSessionDescription* offer = 1943 JsepSessionDescription* offer =
1821 CreateRemoteOffer(options, cricket::SEC_DISABLED); 1944 CreateRemoteOffer(options, cricket::SEC_DISABLED);
1822 ASSERT_TRUE(offer != NULL); 1945 ASSERT_TRUE(offer != NULL);
1823 VerifyFingerprintStatus(offer->description(), true); 1946 VerifyFingerprintStatus(offer->description(), true);
1824 VerifyNoCryptoParams(offer->description(), true); 1947 VerifyNoCryptoParams(offer->description(), true);
1825 1948
1826 // SetRemoteDescription will take the ownership of the offer. 1949 // SetRemoteDescription will take the ownership of the offer.
1827 SetRemoteDescriptionWithoutError(offer); 1950 SetRemoteDescriptionWithoutError(offer);
1828 1951
1829 // Verify that we get a crypto fingerprint in the answer. 1952 // Verify that we get a crypto fingerprint in the answer.
(...skipping 18 matching lines...) Expand all
1848 SessionDescriptionInterface* offer = CreateOffer(); 1971 SessionDescriptionInterface* offer = CreateOffer();
1849 ASSERT_TRUE(offer != NULL); 1972 ASSERT_TRUE(offer != NULL);
1850 VerifyFingerprintStatus(offer->description(), true); 1973 VerifyFingerprintStatus(offer->description(), true);
1851 // Check that we don't have an a=crypto line in the offer. 1974 // Check that we don't have an a=crypto line in the offer.
1852 VerifyNoCryptoParams(offer->description(), true); 1975 VerifyNoCryptoParams(offer->description(), true);
1853 1976
1854 // Now set the local description, which should work, even without a=crypto. 1977 // Now set the local description, which should work, even without a=crypto.
1855 SetLocalDescriptionWithoutError(offer); 1978 SetLocalDescriptionWithoutError(offer);
1856 1979
1857 cricket::MediaSessionOptions options; 1980 cricket::MediaSessionOptions options;
1858 options.recv_video = true; 1981 GetOptionsForAnswer(&options);
1859 JsepSessionDescription* answer = 1982 JsepSessionDescription* answer =
1860 CreateRemoteAnswer(offer, options, cricket::SEC_DISABLED); 1983 CreateRemoteAnswer(offer, options, cricket::SEC_DISABLED);
1861 ASSERT_TRUE(answer != NULL); 1984 ASSERT_TRUE(answer != NULL);
1862 VerifyFingerprintStatus(answer->description(), true); 1985 VerifyFingerprintStatus(answer->description(), true);
1863 VerifyNoCryptoParams(answer->description(), true); 1986 VerifyNoCryptoParams(answer->description(), true);
1864 1987
1865 // SetRemoteDescription will take the ownership of the answer. 1988 // SetRemoteDescription will take the ownership of the answer.
1866 SetRemoteDescriptionWithoutError(answer); 1989 SetRemoteDescriptionWithoutError(answer);
1867 } 1990 }
1868 1991
1869 // Test that if we support DTLS and the other side didn't offer a fingerprint, 1992 // Test that if we support DTLS and the other side didn't offer a fingerprint,
1870 // we will fail to set the remote description. 1993 // we will fail to set the remote description.
1871 TEST_P(WebRtcSessionTest, TestReceiveNonDtlsOfferWhenDtlsOn) { 1994 TEST_P(WebRtcSessionTest, TestReceiveNonDtlsOfferWhenDtlsOn) {
1872 InitWithDtls(GetParam()); 1995 InitWithDtls(GetParam());
1873 cricket::MediaSessionOptions options; 1996 cricket::MediaSessionOptions options;
1874 options.recv_video = true; 1997 GetOptionsForRemoteOffer(&options);
1875 options.bundle_enabled = true; 1998 options.bundle_enabled = true;
1876 JsepSessionDescription* offer = CreateRemoteOffer( 1999 JsepSessionDescription* offer = CreateRemoteOffer(
1877 options, cricket::SEC_REQUIRED); 2000 options, cricket::SEC_REQUIRED);
1878 ASSERT_TRUE(offer != NULL); 2001 ASSERT_TRUE(offer != NULL);
1879 VerifyFingerprintStatus(offer->description(), false); 2002 VerifyFingerprintStatus(offer->description(), false);
1880 VerifyCryptoParams(offer->description()); 2003 VerifyCryptoParams(offer->description());
1881 2004
1882 // SetRemoteDescription will take the ownership of the offer. 2005 // SetRemoteDescription will take the ownership of the offer.
1883 SetRemoteDescriptionOfferExpectError( 2006 SetRemoteDescriptionOfferExpectError(
1884 kSdpWithoutDtlsFingerprint, offer); 2007 kSdpWithoutDtlsFingerprint, offer);
(...skipping 17 matching lines...) Expand all
1902 SetRemoteDescriptionWithoutError(offer); 2025 SetRemoteDescriptionWithoutError(offer);
1903 SetLocalDescriptionAnswerExpectError( 2026 SetLocalDescriptionAnswerExpectError(
1904 kSdpWithoutDtlsFingerprint, answer); 2027 kSdpWithoutDtlsFingerprint, answer);
1905 } 2028 }
1906 2029
1907 // Test that we return a failure when applying a remote answer that doesn't have 2030 // Test that we return a failure when applying a remote answer that doesn't have
1908 // a DTLS fingerprint when DTLS is required. 2031 // a DTLS fingerprint when DTLS is required.
1909 TEST_P(WebRtcSessionTest, TestSetRemoteNonDtlsAnswerWhenDtlsOn) { 2032 TEST_P(WebRtcSessionTest, TestSetRemoteNonDtlsAnswerWhenDtlsOn) {
1910 InitWithDtls(GetParam()); 2033 InitWithDtls(GetParam());
1911 SessionDescriptionInterface* offer = CreateOffer(); 2034 SessionDescriptionInterface* offer = CreateOffer();
1912 cricket::MediaSessionOptions options; 2035 cricket::MediaSessionOptions offer_options;
1913 options.recv_video = true; 2036 GetOptionsForRemoteOffer(&offer_options);
2037
1914 std::unique_ptr<SessionDescriptionInterface> temp_offer( 2038 std::unique_ptr<SessionDescriptionInterface> temp_offer(
1915 CreateRemoteOffer(options, cricket::SEC_ENABLED)); 2039 CreateRemoteOffer(offer_options, cricket::SEC_ENABLED));
1916 JsepSessionDescription* answer = 2040
1917 CreateRemoteAnswer(temp_offer.get(), options, cricket::SEC_ENABLED); 2041 cricket::MediaSessionOptions answer_options;
2042 GetOptionsForAnswer(&answer_options);
2043 JsepSessionDescription* answer = CreateRemoteAnswer(
2044 temp_offer.get(), answer_options, cricket::SEC_ENABLED);
1918 2045
1919 // SetRemoteDescription and SetLocalDescription will take the ownership of 2046 // SetRemoteDescription and SetLocalDescription will take the ownership of
1920 // the offer and answer. 2047 // the offer and answer.
1921 SetLocalDescriptionWithoutError(offer); 2048 SetLocalDescriptionWithoutError(offer);
1922 SetRemoteDescriptionAnswerExpectError( 2049 SetRemoteDescriptionAnswerExpectError(
1923 kSdpWithoutDtlsFingerprint, answer); 2050 kSdpWithoutDtlsFingerprint, answer);
1924 } 2051 }
1925 2052
1926 // Test that we create a local offer without SDES or DTLS and accept a remote 2053 // Test that we create a local offer without SDES or DTLS and accept a remote
1927 // answer without SDES or DTLS when encryption is disabled. 2054 // answer without SDES or DTLS when encryption is disabled.
1928 TEST_P(WebRtcSessionTest, TestCreateOfferReceiveAnswerWithoutEncryption) { 2055 TEST_P(WebRtcSessionTest, TestCreateOfferReceiveAnswerWithoutEncryption) {
1929 SendAudioVideoStream1(); 2056 SendAudioVideoStream1();
1930 options_.disable_encryption = true; 2057 options_.disable_encryption = true;
1931 InitWithDtls(GetParam()); 2058 InitWithDtls(GetParam());
1932 2059
1933 // Verify that we get a crypto fingerprint in the answer. 2060 // Verify that we get a crypto fingerprint in the answer.
1934 SessionDescriptionInterface* offer = CreateOffer(); 2061 SessionDescriptionInterface* offer = CreateOffer();
1935 ASSERT_TRUE(offer != NULL); 2062 ASSERT_TRUE(offer != NULL);
1936 VerifyFingerprintStatus(offer->description(), false); 2063 VerifyFingerprintStatus(offer->description(), false);
1937 // Check that we don't have an a=crypto line in the offer. 2064 // Check that we don't have an a=crypto line in the offer.
1938 VerifyNoCryptoParams(offer->description(), false); 2065 VerifyNoCryptoParams(offer->description(), false);
1939 2066
1940 // Now set the local description, which should work, even without a=crypto. 2067 // Now set the local description, which should work, even without a=crypto.
1941 SetLocalDescriptionWithoutError(offer); 2068 SetLocalDescriptionWithoutError(offer);
1942 2069
1943 cricket::MediaSessionOptions options; 2070 cricket::MediaSessionOptions options;
1944 options.recv_video = true; 2071 GetOptionsForAnswer(&options);
1945 JsepSessionDescription* answer = 2072 JsepSessionDescription* answer =
1946 CreateRemoteAnswer(offer, options, cricket::SEC_DISABLED); 2073 CreateRemoteAnswer(offer, options, cricket::SEC_DISABLED);
1947 ASSERT_TRUE(answer != NULL); 2074 ASSERT_TRUE(answer != NULL);
1948 VerifyFingerprintStatus(answer->description(), false); 2075 VerifyFingerprintStatus(answer->description(), false);
1949 VerifyNoCryptoParams(answer->description(), false); 2076 VerifyNoCryptoParams(answer->description(), false);
1950 2077
1951 // SetRemoteDescription will take the ownership of the answer. 2078 // SetRemoteDescription will take the ownership of the answer.
1952 SetRemoteDescriptionWithoutError(answer); 2079 SetRemoteDescriptionWithoutError(answer);
1953 } 2080 }
1954 2081
1955 // Test that we create a local answer without SDES or DTLS and accept a remote 2082 // Test that we create a local answer without SDES or DTLS and accept a remote
1956 // offer without SDES or DTLS when encryption is disabled. 2083 // offer without SDES or DTLS when encryption is disabled.
1957 TEST_P(WebRtcSessionTest, TestCreateAnswerReceiveOfferWithoutEncryption) { 2084 TEST_P(WebRtcSessionTest, TestCreateAnswerReceiveOfferWithoutEncryption) {
1958 options_.disable_encryption = true; 2085 options_.disable_encryption = true;
1959 InitWithDtls(GetParam()); 2086 InitWithDtls(GetParam());
1960 2087
1961 cricket::MediaSessionOptions options; 2088 cricket::MediaSessionOptions options;
1962 options.recv_video = true; 2089 GetOptionsForRemoteOffer(&options);
1963 JsepSessionDescription* offer = 2090 JsepSessionDescription* offer =
1964 CreateRemoteOffer(options, cricket::SEC_DISABLED); 2091 CreateRemoteOffer(options, cricket::SEC_DISABLED);
1965 ASSERT_TRUE(offer != NULL); 2092 ASSERT_TRUE(offer != NULL);
1966 VerifyFingerprintStatus(offer->description(), false); 2093 VerifyFingerprintStatus(offer->description(), false);
1967 VerifyNoCryptoParams(offer->description(), false); 2094 VerifyNoCryptoParams(offer->description(), false);
1968 2095
1969 // SetRemoteDescription will take the ownership of the offer. 2096 // SetRemoteDescription will take the ownership of the offer.
1970 SetRemoteDescriptionWithoutError(offer); 2097 SetRemoteDescriptionWithoutError(offer);
1971 2098
1972 // Verify that we get a crypto fingerprint in the answer. 2099 // Verify that we get a crypto fingerprint in the answer.
(...skipping 12 matching lines...) Expand all
1985 // See: https://bugs.chromium.org/p/webrtc/issues/detail?id=4525 2112 // See: https://bugs.chromium.org/p/webrtc/issues/detail?id=4525
1986 TEST_P(WebRtcSessionTest, TestCreateAnswerWithDifferentSslRoles) { 2113 TEST_P(WebRtcSessionTest, TestCreateAnswerWithDifferentSslRoles) {
1987 SendAudioVideoStream1(); 2114 SendAudioVideoStream1();
1988 InitWithDtls(GetParam()); 2115 InitWithDtls(GetParam());
1989 SetFactoryDtlsSrtp(); 2116 SetFactoryDtlsSrtp();
1990 2117
1991 SessionDescriptionInterface* offer = CreateOffer(); 2118 SessionDescriptionInterface* offer = CreateOffer();
1992 SetLocalDescriptionWithoutError(offer); 2119 SetLocalDescriptionWithoutError(offer);
1993 2120
1994 cricket::MediaSessionOptions options; 2121 cricket::MediaSessionOptions options;
1995 options.recv_video = true; 2122 GetOptionsForAnswer(&options);
1996 2123
1997 // First, negotiate different SSL roles. 2124 // First, negotiate different SSL roles.
1998 SessionDescriptionInterface* answer = 2125 SessionDescriptionInterface* answer =
1999 CreateRemoteAnswer(offer, options, cricket::SEC_DISABLED); 2126 CreateRemoteAnswer(offer, options, cricket::SEC_DISABLED);
2000 TransportInfo* audio_transport_info = 2127 TransportInfo* audio_transport_info =
2001 answer->description()->GetTransportInfoByName("audio"); 2128 answer->description()->GetTransportInfoByName("audio");
2002 audio_transport_info->description.connection_role = 2129 audio_transport_info->description.connection_role =
2003 cricket::CONNECTIONROLE_ACTIVE; 2130 cricket::CONNECTIONROLE_ACTIVE;
2004 TransportInfo* video_transport_info = 2131 TransportInfo* video_transport_info =
2005 answer->description()->GetTransportInfoByName("video"); 2132 answer->description()->GetTransportInfoByName("video");
2006 video_transport_info->description.connection_role = 2133 video_transport_info->description.connection_role =
2007 cricket::CONNECTIONROLE_PASSIVE; 2134 cricket::CONNECTIONROLE_PASSIVE;
2008 SetRemoteDescriptionWithoutError(answer); 2135 SetRemoteDescriptionWithoutError(answer);
2009 2136
2010 // Now create an offer in the reverse direction, and ensure the initial 2137 // Now create an offer in the reverse direction, and ensure the initial
2011 // offerer responds with an answer with correct SSL roles. 2138 // offerer responds with an answer with correct SSL roles.
2012 offer = CreateRemoteOfferWithVersion(options, cricket::SEC_DISABLED, 2139 offer = CreateRemoteOfferWithVersion(options, cricket::SEC_DISABLED,
2013 kSessionVersion, 2140 kSessionVersion,
2014 session_->remote_description()); 2141 session_->remote_description());
2015 SetRemoteDescriptionWithoutError(offer); 2142 SetRemoteDescriptionWithoutError(offer);
2016 2143
2017 answer = CreateAnswer(); 2144 cricket::MediaSessionOptions answer_options;
2145 answer_options.bundle_enabled = true;
2146 answer = CreateAnswer(answer_options);
2018 audio_transport_info = answer->description()->GetTransportInfoByName("audio"); 2147 audio_transport_info = answer->description()->GetTransportInfoByName("audio");
2019 EXPECT_EQ(cricket::CONNECTIONROLE_PASSIVE, 2148 EXPECT_EQ(cricket::CONNECTIONROLE_PASSIVE,
2020 audio_transport_info->description.connection_role); 2149 audio_transport_info->description.connection_role);
2021 video_transport_info = answer->description()->GetTransportInfoByName("video"); 2150 video_transport_info = answer->description()->GetTransportInfoByName("video");
2022 EXPECT_EQ(cricket::CONNECTIONROLE_ACTIVE, 2151 EXPECT_EQ(cricket::CONNECTIONROLE_ACTIVE,
2023 video_transport_info->description.connection_role); 2152 video_transport_info->description.connection_role);
2024 SetLocalDescriptionWithoutError(answer); 2153 SetLocalDescriptionWithoutError(answer);
2025 2154
2026 // Lastly, start BUNDLE-ing on "audio", expecting that the "passive" role of 2155 // Lastly, start BUNDLE-ing on "audio", expecting that the "passive" role of
2027 // audio is transferred over to video in the answer that completes the BUNDLE 2156 // audio is transferred over to video in the answer that completes the BUNDLE
2028 // negotiation. 2157 // negotiation.
2029 options.bundle_enabled = true; 2158 options.bundle_enabled = true;
2030 offer = CreateRemoteOfferWithVersion(options, cricket::SEC_DISABLED, 2159 offer = CreateRemoteOfferWithVersion(options, cricket::SEC_DISABLED,
2031 kSessionVersion, 2160 kSessionVersion,
2032 session_->remote_description()); 2161 session_->remote_description());
2033 SetRemoteDescriptionWithoutError(offer); 2162 SetRemoteDescriptionWithoutError(offer);
2034 answer = CreateAnswer(); 2163 answer = CreateAnswer(answer_options);
2035 audio_transport_info = answer->description()->GetTransportInfoByName("audio"); 2164 audio_transport_info = answer->description()->GetTransportInfoByName("audio");
2036 EXPECT_EQ(cricket::CONNECTIONROLE_PASSIVE, 2165 EXPECT_EQ(cricket::CONNECTIONROLE_PASSIVE,
2037 audio_transport_info->description.connection_role); 2166 audio_transport_info->description.connection_role);
2038 video_transport_info = answer->description()->GetTransportInfoByName("video"); 2167 video_transport_info = answer->description()->GetTransportInfoByName("video");
2039 EXPECT_EQ(cricket::CONNECTIONROLE_PASSIVE, 2168 EXPECT_EQ(cricket::CONNECTIONROLE_PASSIVE,
2040 video_transport_info->description.connection_role); 2169 video_transport_info->description.connection_role);
2041 SetLocalDescriptionWithoutError(answer); 2170 SetLocalDescriptionWithoutError(answer);
2042 } 2171 }
2043 2172
2044 TEST_F(WebRtcSessionTest, TestSetLocalOfferTwice) { 2173 TEST_F(WebRtcSessionTest, TestSetLocalOfferTwice) {
(...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after
2385 // is called. 2514 // is called.
2386 EXPECT_EQ(0u, observer_.mline_0_candidates_.size()); 2515 EXPECT_EQ(0u, observer_.mline_0_candidates_.size());
2387 EXPECT_EQ(0u, observer_.mline_1_candidates_.size()); 2516 EXPECT_EQ(0u, observer_.mline_1_candidates_.size());
2388 CreateAndSetRemoteOfferAndLocalAnswer(); 2517 CreateAndSetRemoteOfferAndLocalAnswer();
2389 // Wait until at least one local candidate has been collected. 2518 // Wait until at least one local candidate has been collected.
2390 EXPECT_TRUE_WAIT(0u < observer_.mline_0_candidates_.size(), 2519 EXPECT_TRUE_WAIT(0u < observer_.mline_0_candidates_.size(),
2391 kIceCandidatesTimeout); 2520 kIceCandidatesTimeout);
2392 2521
2393 std::unique_ptr<SessionDescriptionInterface> local_offer(CreateOffer()); 2522 std::unique_ptr<SessionDescriptionInterface> local_offer(CreateOffer());
2394 2523
2524 ASSERT_TRUE(local_offer);
2395 ASSERT_TRUE(local_offer->candidates(kMediaContentIndex0) != NULL); 2525 ASSERT_TRUE(local_offer->candidates(kMediaContentIndex0) != NULL);
2396 EXPECT_LT(0u, local_offer->candidates(kMediaContentIndex0)->count()); 2526 EXPECT_LT(0u, local_offer->candidates(kMediaContentIndex0)->count());
2397 2527
2398 SessionDescriptionInterface* remote_offer(CreateRemoteOffer()); 2528 SessionDescriptionInterface* remote_offer(CreateRemoteOffer());
2399 SetRemoteDescriptionWithoutError(remote_offer); 2529 SetRemoteDescriptionWithoutError(remote_offer);
2400 SessionDescriptionInterface* answer = CreateAnswer(); 2530 SessionDescriptionInterface* answer = CreateAnswer();
2401 ASSERT_TRUE(answer->candidates(kMediaContentIndex0) != NULL); 2531 ASSERT_TRUE(answer->candidates(kMediaContentIndex0) != NULL);
2402 EXPECT_LT(0u, answer->candidates(kMediaContentIndex0)->count()); 2532 EXPECT_LT(0u, answer->candidates(kMediaContentIndex0)->count());
2403 SetLocalDescriptionWithoutError(answer); 2533 SetLocalDescriptionWithoutError(answer);
2404 } 2534 }
2405 2535
2406 // Verifies TransportProxy and media channels are created with content names 2536 // Verifies TransportProxy and media channels are created with content names
2407 // present in the SessionDescription. 2537 // present in the SessionDescription.
2408 TEST_F(WebRtcSessionTest, TestChannelCreationsWithContentNames) { 2538 TEST_F(WebRtcSessionTest, TestChannelCreationsWithContentNames) {
2409 Init(); 2539 Init();
2410 SendAudioVideoStream1(); 2540 SendAudioVideoStream1();
2411 std::unique_ptr<SessionDescriptionInterface> offer(CreateOffer()); 2541 std::unique_ptr<SessionDescriptionInterface> offer(CreateOffer());
2412 2542
2413 // CreateOffer creates session description with the content names "audio" and 2543 // CreateOffer creates session description with the content names "audio" and
2414 // "video". Goal is to modify these content names and verify transport 2544 // "video". Goal is to modify these content names and verify transport
2415 // channels 2545 // channels
2416 // in the WebRtcSession, as channels are created with the content names 2546 // in the WebRtcSession, as channels are created with the content names
2417 // present in SDP. 2547 // present in SDP.
2418 std::string sdp; 2548 std::string sdp;
2419 EXPECT_TRUE(offer->ToString(&sdp)); 2549 EXPECT_TRUE(offer->ToString(&sdp));
2420 const std::string kAudioMid = "a=mid:audio";
2421 const std::string kAudioMidReplaceStr = "a=mid:audio_content_name";
2422 const std::string kVideoMid = "a=mid:video";
2423 const std::string kVideoMidReplaceStr = "a=mid:video_content_name";
2424
2425 // Replacing |audio| with |audio_content_name|.
2426 rtc::replace_substrs(kAudioMid.c_str(), kAudioMid.length(),
2427 kAudioMidReplaceStr.c_str(),
2428 kAudioMidReplaceStr.length(),
2429 &sdp);
2430 // Replacing |video| with |video_content_name|.
2431 rtc::replace_substrs(kVideoMid.c_str(), kVideoMid.length(),
2432 kVideoMidReplaceStr.c_str(),
2433 kVideoMidReplaceStr.length(),
2434 &sdp);
2435 2550
2436 SessionDescriptionInterface* modified_offer = 2551 SessionDescriptionInterface* modified_offer =
2437 CreateSessionDescription(JsepSessionDescription::kOffer, sdp, NULL); 2552 CreateSessionDescription(JsepSessionDescription::kOffer, sdp, NULL);
2438 2553
2439 SetRemoteDescriptionWithoutError(modified_offer); 2554 SetRemoteDescriptionWithoutError(modified_offer);
2440 2555
2441 SessionDescriptionInterface* answer = CreateAnswer(); 2556 cricket::MediaSessionOptions answer_options;
2557 answer_options.bundle_enabled = false;
2558 SessionDescriptionInterface* answer = CreateAnswer(answer_options);
2442 SetLocalDescriptionWithoutError(answer); 2559 SetLocalDescriptionWithoutError(answer);
2443 2560
2444 rtc::PacketTransportInternal* voice_transport_channel = 2561 rtc::PacketTransportInternal* voice_transport_channel =
2445 session_->voice_rtp_transport_channel(); 2562 session_->voice_rtp_transport_channel();
2446 EXPECT_TRUE(voice_transport_channel != NULL); 2563 EXPECT_TRUE(voice_transport_channel != NULL);
2447 EXPECT_EQ(voice_transport_channel->debug_name(), 2564 EXPECT_EQ(voice_transport_channel->debug_name(),
2448 "audio_content_name " + 2565 "audio " + std::to_string(cricket::ICE_CANDIDATE_COMPONENT_RTP));
2449 std::to_string(cricket::ICE_CANDIDATE_COMPONENT_RTP));
2450 rtc::PacketTransportInternal* video_transport_channel = 2566 rtc::PacketTransportInternal* video_transport_channel =
2451 session_->video_rtp_transport_channel(); 2567 session_->video_rtp_transport_channel();
2452 ASSERT_TRUE(video_transport_channel != NULL); 2568 ASSERT_TRUE(video_transport_channel != NULL);
2453 EXPECT_EQ(video_transport_channel->debug_name(), 2569 EXPECT_EQ(video_transport_channel->debug_name(),
2454 "video_content_name " + 2570 "video " + std::to_string(cricket::ICE_CANDIDATE_COMPONENT_RTP));
2455 std::to_string(cricket::ICE_CANDIDATE_COMPONENT_RTP));
2456 EXPECT_TRUE((video_channel_ = media_engine_->GetVideoChannel(0)) != NULL); 2571 EXPECT_TRUE((video_channel_ = media_engine_->GetVideoChannel(0)) != NULL);
2457 EXPECT_TRUE((voice_channel_ = media_engine_->GetVoiceChannel(0)) != NULL); 2572 EXPECT_TRUE((voice_channel_ = media_engine_->GetVoiceChannel(0)) != NULL);
2458 } 2573 }
2459 2574
2460 // Test that an offer contains the correct media content descriptions based on 2575 // Test that an offer contains the correct media content descriptions based on
2461 // the send streams when no constraints have been set. 2576 // the send streams when no constraints have been set.
2462 TEST_F(WebRtcSessionTest, CreateOfferWithoutConstraintsOrStreams) { 2577 TEST_F(WebRtcSessionTest, CreateOfferWithoutConstraintsOrStreams) {
2463 Init(); 2578 Init();
2464 std::unique_ptr<SessionDescriptionInterface> offer(CreateOffer()); 2579 std::unique_ptr<SessionDescriptionInterface> offer(CreateOffer());
2465 2580
2466 ASSERT_TRUE(offer != NULL); 2581 ASSERT_TRUE(offer != NULL);
2467 const cricket::ContentInfo* content = 2582 const cricket::ContentInfo* content =
2468 cricket::GetFirstAudioContent(offer->description()); 2583 cricket::GetFirstAudioContent(offer->description());
2469 EXPECT_TRUE(content != NULL); 2584 ASSERT_TRUE(content != NULL);
2585 EXPECT_EQ(
2586 cricket::MD_RECVONLY,
2587 static_cast<const cricket::AudioContentDescription*>(content->description)
2588 ->direction());
2470 content = cricket::GetFirstVideoContent(offer->description()); 2589 content = cricket::GetFirstVideoContent(offer->description());
2471 EXPECT_TRUE(content == NULL); 2590 ASSERT_TRUE(content != NULL);
2591 EXPECT_EQ(
2592 cricket::MD_RECVONLY,
2593 static_cast<const cricket::VideoContentDescription*>(content->description)
2594 ->direction());
2472 } 2595 }
2473 2596
2474 // Test that an offer contains the correct media content descriptions based on 2597 // Test that an offer contains the correct media content descriptions based on
2475 // the send streams when no constraints have been set. 2598 // the send streams when no constraints have been set.
2476 TEST_F(WebRtcSessionTest, CreateOfferWithoutConstraints) { 2599 TEST_F(WebRtcSessionTest, CreateOfferWithoutConstraints) {
2477 Init(); 2600 Init();
2478 // Test Audio only offer. 2601 // Test Audio only offer.
2479 SendAudioOnlyStream2(); 2602 SendAudioOnlyStream2();
2480 std::unique_ptr<SessionDescriptionInterface> offer(CreateOffer()); 2603 std::unique_ptr<SessionDescriptionInterface> offer(CreateOffer());
2481 2604
2482 const cricket::ContentInfo* content = 2605 const cricket::ContentInfo* content =
2483 cricket::GetFirstAudioContent(offer->description()); 2606 cricket::GetFirstAudioContent(offer->description());
2484 EXPECT_TRUE(content != NULL); 2607 ASSERT_TRUE(content != NULL);
2608 EXPECT_EQ(
2609 cricket::MD_SENDRECV,
2610 static_cast<const cricket::AudioContentDescription*>(content->description)
2611 ->direction());
2485 content = cricket::GetFirstVideoContent(offer->description()); 2612 content = cricket::GetFirstVideoContent(offer->description());
2486 EXPECT_TRUE(content == NULL); 2613 ASSERT_TRUE(content != NULL);
2614 EXPECT_EQ(
2615 cricket::MD_RECVONLY,
2616 static_cast<const cricket::VideoContentDescription*>(content->description)
2617 ->direction());
2487 2618
2488 // Test Audio / Video offer. 2619 // Test Audio / Video offer.
2489 SendAudioVideoStream1(); 2620 SendAudioVideoStream1();
2490 offer.reset(CreateOffer()); 2621 offer.reset(CreateOffer());
2491 content = cricket::GetFirstAudioContent(offer->description()); 2622 content = cricket::GetFirstAudioContent(offer->description());
2492 EXPECT_TRUE(content != NULL); 2623 ASSERT_TRUE(content != NULL);
2624 EXPECT_EQ(
2625 cricket::MD_SENDRECV,
2626 static_cast<const cricket::AudioContentDescription*>(content->description)
2627 ->direction());
2628
2493 content = cricket::GetFirstVideoContent(offer->description()); 2629 content = cricket::GetFirstVideoContent(offer->description());
2494 EXPECT_TRUE(content != NULL); 2630 ASSERT_TRUE(content != NULL);
2631 EXPECT_EQ(
2632 cricket::MD_SENDRECV,
2633 static_cast<const cricket::VideoContentDescription*>(content->description)
2634 ->direction());
2495 } 2635 }
2496 2636
2497 // Test that an offer contains no media content descriptions if 2637 // Test that an offer contains no media content descriptions if
2498 // kOfferToReceiveVideo and kOfferToReceiveAudio constraints are set to false. 2638 // kOfferToReceiveVideo and kOfferToReceiveAudio constraints are set to false.
2499 TEST_F(WebRtcSessionTest, CreateOfferWithConstraintsWithoutStreams) { 2639 TEST_F(WebRtcSessionTest, CreateOfferWithConstraintsWithoutStreams) {
2500 Init(); 2640 Init();
2501 PeerConnectionInterface::RTCOfferAnswerOptions options; 2641 PeerConnectionInterface::RTCOfferAnswerOptions options;
2502 options.offer_to_receive_audio = 0; 2642 options.offer_to_receive_audio = 0;
2503 options.offer_to_receive_video = 0; 2643 options.offer_to_receive_video = 0;
2504 2644
2505 std::unique_ptr<SessionDescriptionInterface> offer(CreateOffer(options)); 2645 std::unique_ptr<SessionDescriptionInterface> offer(CreateOffer(options));
2506 2646
2507 ASSERT_TRUE(offer != NULL); 2647 ASSERT_TRUE(offer != NULL);
2508 const cricket::ContentInfo* content = 2648 const cricket::ContentInfo* content =
2509 cricket::GetFirstAudioContent(offer->description()); 2649 cricket::GetFirstAudioContent(offer->description());
2510 EXPECT_TRUE(content == NULL); 2650 EXPECT_TRUE(content == NULL);
2511 content = cricket::GetFirstVideoContent(offer->description()); 2651 content = cricket::GetFirstVideoContent(offer->description());
2512 EXPECT_TRUE(content == NULL); 2652 EXPECT_TRUE(content == NULL);
2513 } 2653 }
2514 2654
2515 // Test that an offer contains only audio media content descriptions if 2655 // Test that an offer contains only audio media content descriptions if
2516 // kOfferToReceiveAudio constraints are set to true. 2656 // kOfferToReceiveAudio constraints are set to true.
2517 TEST_F(WebRtcSessionTest, CreateAudioOnlyOfferWithConstraints) { 2657 TEST_F(WebRtcSessionTest, CreateAudioOnlyOfferWithConstraints) {
2518 Init(); 2658 Init();
2519 PeerConnectionInterface::RTCOfferAnswerOptions options; 2659 PeerConnectionInterface::RTCOfferAnswerOptions options;
2520 options.offer_to_receive_audio = 2660 options.offer_to_receive_audio =
2521 RTCOfferAnswerOptions::kOfferToReceiveMediaTrue; 2661 RTCOfferAnswerOptions::kOfferToReceiveMediaTrue;
2662 options.offer_to_receive_video = 0;
2522 2663
2523 std::unique_ptr<SessionDescriptionInterface> offer(CreateOffer(options)); 2664 std::unique_ptr<SessionDescriptionInterface> offer(CreateOffer(options));
2524 2665
2525 const cricket::ContentInfo* content = 2666 const cricket::ContentInfo* content =
2526 cricket::GetFirstAudioContent(offer->description()); 2667 cricket::GetFirstAudioContent(offer->description());
2527 EXPECT_TRUE(content != NULL); 2668 EXPECT_TRUE(content != NULL);
2528 content = cricket::GetFirstVideoContent(offer->description()); 2669 content = cricket::GetFirstVideoContent(offer->description());
2529 EXPECT_TRUE(content == NULL); 2670 EXPECT_TRUE(content == NULL);
2530 } 2671 }
2531 2672
(...skipping 14 matching lines...) Expand all
2546 cricket::GetFirstAudioContent(offer->description()); 2687 cricket::GetFirstAudioContent(offer->description());
2547 EXPECT_TRUE(content != NULL); 2688 EXPECT_TRUE(content != NULL);
2548 2689
2549 content = cricket::GetFirstVideoContent(offer->description()); 2690 content = cricket::GetFirstVideoContent(offer->description());
2550 EXPECT_TRUE(content != NULL); 2691 EXPECT_TRUE(content != NULL);
2551 2692
2552 // Sets constraints to false and verifies that audio/video contents are 2693 // Sets constraints to false and verifies that audio/video contents are
2553 // removed. 2694 // removed.
2554 options.offer_to_receive_audio = 0; 2695 options.offer_to_receive_audio = 0;
2555 options.offer_to_receive_video = 0; 2696 options.offer_to_receive_video = 0;
2697 // Remove the media sections added in previous offer.
2698 offered_media_sections_.clear();
2556 offer.reset(CreateOffer(options)); 2699 offer.reset(CreateOffer(options));
2557 2700
2558 content = cricket::GetFirstAudioContent(offer->description()); 2701 content = cricket::GetFirstAudioContent(offer->description());
2559 EXPECT_TRUE(content == NULL); 2702 EXPECT_TRUE(content == NULL);
2560 content = cricket::GetFirstVideoContent(offer->description()); 2703 content = cricket::GetFirstVideoContent(offer->description());
2561 EXPECT_TRUE(content == NULL); 2704 EXPECT_TRUE(content == NULL);
2562 } 2705 }
2563 2706
2564 // Test that an answer can not be created if the last remote description is not 2707 // Test that an answer can not be created if the last remote description is not
2565 // an offer. 2708 // an offer.
(...skipping 23 matching lines...) Expand all
2589 ASSERT_TRUE(content != NULL); 2732 ASSERT_TRUE(content != NULL);
2590 EXPECT_FALSE(content->rejected); 2733 EXPECT_FALSE(content->rejected);
2591 } 2734 }
2592 2735
2593 // Test that an answer contains the correct media content descriptions when no 2736 // Test that an answer contains the correct media content descriptions when no
2594 // constraints have been set and the offer only contain audio. 2737 // constraints have been set and the offer only contain audio.
2595 TEST_F(WebRtcSessionTest, CreateAudioAnswerWithoutConstraintsOrStreams) { 2738 TEST_F(WebRtcSessionTest, CreateAudioAnswerWithoutConstraintsOrStreams) {
2596 Init(); 2739 Init();
2597 // Create a remote offer with audio only. 2740 // Create a remote offer with audio only.
2598 cricket::MediaSessionOptions options; 2741 cricket::MediaSessionOptions options;
2742 GetOptionsForAudioOnlyRemoteOffer(&options);
2599 2743
2600 std::unique_ptr<JsepSessionDescription> offer(CreateRemoteOffer(options)); 2744 std::unique_ptr<JsepSessionDescription> offer(CreateRemoteOffer(options));
2601 ASSERT_TRUE(cricket::GetFirstVideoContent(offer->description()) == NULL); 2745 ASSERT_TRUE(cricket::GetFirstVideoContent(offer->description()) == NULL);
2602 ASSERT_TRUE(cricket::GetFirstAudioContent(offer->description()) != NULL); 2746 ASSERT_TRUE(cricket::GetFirstAudioContent(offer->description()) != NULL);
2603 2747
2604 SetRemoteDescriptionWithoutError(offer.release()); 2748 SetRemoteDescriptionWithoutError(offer.release());
2605 std::unique_ptr<SessionDescriptionInterface> answer(CreateAnswer()); 2749 std::unique_ptr<SessionDescriptionInterface> answer(CreateAnswer());
2606 const cricket::ContentInfo* content = 2750 const cricket::ContentInfo* content =
2607 cricket::GetFirstAudioContent(answer->description()); 2751 cricket::GetFirstAudioContent(answer->description());
2608 ASSERT_TRUE(content != NULL); 2752 ASSERT_TRUE(content != NULL);
(...skipping 24 matching lines...) Expand all
2633 2777
2634 // Test that an answer contains the correct media content descriptions when 2778 // Test that an answer contains the correct media content descriptions when
2635 // constraints have been set but no stream is sent. 2779 // constraints have been set but no stream is sent.
2636 TEST_F(WebRtcSessionTest, CreateAnswerWithConstraintsWithoutStreams) { 2780 TEST_F(WebRtcSessionTest, CreateAnswerWithConstraintsWithoutStreams) {
2637 Init(); 2781 Init();
2638 // Create a remote offer with audio and video content. 2782 // Create a remote offer with audio and video content.
2639 std::unique_ptr<JsepSessionDescription> offer(CreateRemoteOffer()); 2783 std::unique_ptr<JsepSessionDescription> offer(CreateRemoteOffer());
2640 SetRemoteDescriptionWithoutError(offer.release()); 2784 SetRemoteDescriptionWithoutError(offer.release());
2641 2785
2642 cricket::MediaSessionOptions session_options; 2786 cricket::MediaSessionOptions session_options;
2643 session_options.recv_audio = false; 2787 recv_audio_ = false;
2644 session_options.recv_video = false; 2788 recv_video_ = false;
2645 std::unique_ptr<SessionDescriptionInterface> answer( 2789 std::unique_ptr<SessionDescriptionInterface> answer(
2646 CreateAnswer(session_options)); 2790 CreateAnswer(session_options));
2647 2791
2648 const cricket::ContentInfo* content = 2792 const cricket::ContentInfo* content =
2649 cricket::GetFirstAudioContent(answer->description()); 2793 cricket::GetFirstAudioContent(answer->description());
2650 ASSERT_TRUE(content != NULL); 2794 ASSERT_TRUE(content != NULL);
2651 EXPECT_TRUE(content->rejected); 2795 EXPECT_TRUE(content->rejected);
2652 2796
2653 content = cricket::GetFirstVideoContent(answer->description()); 2797 content = cricket::GetFirstVideoContent(answer->description());
2654 ASSERT_TRUE(content != NULL); 2798 ASSERT_TRUE(content != NULL);
2655 EXPECT_TRUE(content->rejected); 2799 EXPECT_TRUE(content->rejected);
2656 } 2800 }
2657 2801
2658 // Test that an answer contains the correct media content descriptions when 2802 // Test that an answer contains the correct media content descriptions when
2659 // constraints have been set and streams are sent. 2803 // constraints have been set and streams are sent.
2660 TEST_F(WebRtcSessionTest, CreateAnswerWithConstraints) { 2804 TEST_F(WebRtcSessionTest, CreateAnswerWithConstraints) {
2661 Init(); 2805 Init();
2662 // Create a remote offer with audio and video content. 2806 // Create a remote offer with audio and video content.
2663 std::unique_ptr<JsepSessionDescription> offer(CreateRemoteOffer()); 2807 std::unique_ptr<JsepSessionDescription> offer(CreateRemoteOffer());
2664 SetRemoteDescriptionWithoutError(offer.release()); 2808 SetRemoteDescriptionWithoutError(offer.release());
2665 2809
2666 cricket::MediaSessionOptions options; 2810 cricket::MediaSessionOptions options;
2667 options.recv_audio = false;
2668 options.recv_video = false;
2669
2670 // Test with a stream with tracks. 2811 // Test with a stream with tracks.
2671 SendAudioVideoStream1(); 2812 SendAudioVideoStream1();
2672 std::unique_ptr<SessionDescriptionInterface> answer(CreateAnswer(options)); 2813 std::unique_ptr<SessionDescriptionInterface> answer(CreateAnswer(options));
2673 2814
2674 // TODO(perkj): Should the direction be set to SEND_ONLY? 2815 // TODO(perkj): Should the direction be set to SEND_ONLY?
2675 const cricket::ContentInfo* content = 2816 const cricket::ContentInfo* content =
2676 cricket::GetFirstAudioContent(answer->description()); 2817 cricket::GetFirstAudioContent(answer->description());
2677 ASSERT_TRUE(content != NULL); 2818 ASSERT_TRUE(content != NULL);
2678 EXPECT_FALSE(content->rejected); 2819 EXPECT_FALSE(content->rejected);
2679 2820
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
2719 // later updates with video. 2860 // later updates with video.
2720 TEST_F(WebRtcSessionTest, TestAVOfferWithAudioOnlyAnswer) { 2861 TEST_F(WebRtcSessionTest, TestAVOfferWithAudioOnlyAnswer) {
2721 Init(); 2862 Init();
2722 EXPECT_TRUE(media_engine_->GetVideoChannel(0) == NULL); 2863 EXPECT_TRUE(media_engine_->GetVideoChannel(0) == NULL);
2723 EXPECT_TRUE(media_engine_->GetVoiceChannel(0) == NULL); 2864 EXPECT_TRUE(media_engine_->GetVoiceChannel(0) == NULL);
2724 2865
2725 SendAudioVideoStream1(); 2866 SendAudioVideoStream1();
2726 SessionDescriptionInterface* offer = CreateOffer(); 2867 SessionDescriptionInterface* offer = CreateOffer();
2727 2868
2728 cricket::MediaSessionOptions options; 2869 cricket::MediaSessionOptions options;
2870 AddMediaSection(cricket::MEDIA_TYPE_AUDIO, cricket::CN_AUDIO,
2871 cricket::MD_RECVONLY, !kStopped, &options);
2872 AddMediaSection(cricket::MEDIA_TYPE_VIDEO, cricket::CN_VIDEO,
2873 cricket::MD_INACTIVE, kStopped, &options);
2729 SessionDescriptionInterface* answer = CreateRemoteAnswer(offer, options); 2874 SessionDescriptionInterface* answer = CreateRemoteAnswer(offer, options);
2730 2875
2731 // SetLocalDescription and SetRemoteDescriptions takes ownership of offer 2876 // SetLocalDescription and SetRemoteDescriptions takes ownership of offer
2732 // and answer; 2877 // and answer;
2733 SetLocalDescriptionWithoutError(offer); 2878 SetLocalDescriptionWithoutError(offer);
2734 SetRemoteDescriptionWithoutError(answer); 2879 SetRemoteDescriptionWithoutError(answer);
2735 2880
2736 video_channel_ = media_engine_->GetVideoChannel(0); 2881 video_channel_ = media_engine_->GetVideoChannel(0);
2737 voice_channel_ = media_engine_->GetVoiceChannel(0); 2882 voice_channel_ = media_engine_->GetVoiceChannel(0);
2738 2883
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
2775 // This test verifies the call setup when remote answer with video only and 2920 // This test verifies the call setup when remote answer with video only and
2776 // later updates with audio. 2921 // later updates with audio.
2777 TEST_F(WebRtcSessionTest, TestAVOfferWithVideoOnlyAnswer) { 2922 TEST_F(WebRtcSessionTest, TestAVOfferWithVideoOnlyAnswer) {
2778 Init(); 2923 Init();
2779 EXPECT_TRUE(media_engine_->GetVideoChannel(0) == NULL); 2924 EXPECT_TRUE(media_engine_->GetVideoChannel(0) == NULL);
2780 EXPECT_TRUE(media_engine_->GetVoiceChannel(0) == NULL); 2925 EXPECT_TRUE(media_engine_->GetVoiceChannel(0) == NULL);
2781 SendAudioVideoStream1(); 2926 SendAudioVideoStream1();
2782 SessionDescriptionInterface* offer = CreateOffer(); 2927 SessionDescriptionInterface* offer = CreateOffer();
2783 2928
2784 cricket::MediaSessionOptions options; 2929 cricket::MediaSessionOptions options;
2785 options.recv_audio = false; 2930 AddMediaSection(cricket::MEDIA_TYPE_AUDIO, cricket::CN_AUDIO,
2786 options.recv_video = true; 2931 cricket::MD_INACTIVE, kStopped, &options);
2787 SessionDescriptionInterface* answer = CreateRemoteAnswer( 2932 AddMediaSection(cricket::MEDIA_TYPE_VIDEO, cricket::CN_VIDEO,
2788 offer, options, cricket::SEC_ENABLED); 2933 cricket::MD_RECVONLY, !kStopped, &options);
2934
2935 SessionDescriptionInterface* answer =
2936 CreateRemoteAnswer(offer, options, cricket::SEC_ENABLED);
2789 2937
2790 // SetLocalDescription and SetRemoteDescriptions takes ownership of offer 2938 // SetLocalDescription and SetRemoteDescriptions takes ownership of offer
2791 // and answer. 2939 // and answer.
2792 SetLocalDescriptionWithoutError(offer); 2940 SetLocalDescriptionWithoutError(offer);
2793 SetRemoteDescriptionWithoutError(answer); 2941 SetRemoteDescriptionWithoutError(answer);
2794 2942
2795 video_channel_ = media_engine_->GetVideoChannel(0); 2943 video_channel_ = media_engine_->GetVideoChannel(0);
2796 voice_channel_ = media_engine_->GetVoiceChannel(0); 2944 voice_channel_ = media_engine_->GetVoiceChannel(0);
2797 2945
2798 ASSERT_TRUE(voice_channel_ == NULL); 2946 ASSERT_TRUE(voice_channel_ == NULL);
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after
3018 } 3166 }
3019 3167
3020 // Test that candidates sent to the "video" transport do not get pushed down to 3168 // Test that candidates sent to the "video" transport do not get pushed down to
3021 // the "audio" transport channel when bundling. 3169 // the "audio" transport channel when bundling.
3022 TEST_F(WebRtcSessionTest, TestIgnoreCandidatesForUnusedTransportWhenBundling) { 3170 TEST_F(WebRtcSessionTest, TestIgnoreCandidatesForUnusedTransportWhenBundling) {
3023 AddInterface(rtc::SocketAddress(kClientAddrHost1, kClientAddrPort)); 3171 AddInterface(rtc::SocketAddress(kClientAddrHost1, kClientAddrPort));
3024 3172
3025 InitWithBundlePolicy(PeerConnectionInterface::kBundlePolicyBalanced); 3173 InitWithBundlePolicy(PeerConnectionInterface::kBundlePolicyBalanced);
3026 SendAudioVideoStream1(); 3174 SendAudioVideoStream1();
3027 3175
3028 PeerConnectionInterface::RTCOfferAnswerOptions options; 3176 cricket::MediaSessionOptions offer_options;
3029 options.use_rtp_mux = true; 3177 GetOptionsForRemoteOffer(&offer_options);
3178 offer_options.bundle_enabled = true;
3030 3179
3031 SessionDescriptionInterface* offer = CreateRemoteOffer(); 3180 SessionDescriptionInterface* offer = CreateRemoteOffer(offer_options);
3032 SetRemoteDescriptionWithoutError(offer); 3181 SetRemoteDescriptionWithoutError(offer);
3033 3182
3034 SessionDescriptionInterface* answer = CreateAnswer(); 3183 cricket::MediaSessionOptions answer_options;
3184 answer_options.bundle_enabled = true;
3185 SessionDescriptionInterface* answer = CreateAnswer(answer_options);
3035 SetLocalDescriptionWithoutError(answer); 3186 SetLocalDescriptionWithoutError(answer);
3036 3187
3037 EXPECT_EQ(session_->voice_rtp_transport_channel(), 3188 EXPECT_EQ(session_->voice_rtp_transport_channel(),
3038 session_->video_rtp_transport_channel()); 3189 session_->video_rtp_transport_channel());
3039 3190
3040 cricket::BaseChannel* voice_channel = session_->voice_channel(); 3191 cricket::BaseChannel* voice_channel = session_->voice_channel();
3041 ASSERT_TRUE(voice_channel != NULL); 3192 ASSERT_TRUE(voice_channel != NULL);
3042 3193
3043 // Checks if one of the transport channels contains a connection using a given 3194 // Checks if one of the transport channels contains a connection using a given
3044 // port. 3195 // port.
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
3189 3340
3190 PeerConnectionInterface::RTCOfferAnswerOptions options; 3341 PeerConnectionInterface::RTCOfferAnswerOptions options;
3191 options.use_rtp_mux = true; 3342 options.use_rtp_mux = true;
3192 3343
3193 SessionDescriptionInterface* offer = CreateOffer(options); 3344 SessionDescriptionInterface* offer = CreateOffer(options);
3194 SetLocalDescriptionWithoutError(offer); 3345 SetLocalDescriptionWithoutError(offer);
3195 3346
3196 EXPECT_EQ(session_->voice_rtp_transport_channel(), 3347 EXPECT_EQ(session_->voice_rtp_transport_channel(),
3197 session_->video_rtp_transport_channel()); 3348 session_->video_rtp_transport_channel());
3198 3349
3199 SendAudioVideoStream2(); 3350 SendVideoOnlyStream2();
3200 cricket::MediaSessionOptions recv_options; 3351 cricket::MediaSessionOptions recv_options;
3201 recv_options.recv_audio = false; 3352 recv_audio_ = false;
3202 recv_options.recv_video = true; 3353 GetOptionsForAnswer(&recv_options);
3203 SessionDescriptionInterface* answer = 3354 SessionDescriptionInterface* answer =
3204 CreateRemoteAnswer(session_->local_description(), recv_options); 3355 CreateRemoteAnswer(session_->local_description(), recv_options);
3205 SetRemoteDescriptionWithoutError(answer); 3356 SetRemoteDescriptionWithoutError(answer);
3206 3357
3207 EXPECT_TRUE(nullptr == session_->voice_channel()); 3358 EXPECT_TRUE(nullptr == session_->voice_channel());
3208 EXPECT_TRUE(nullptr != session_->video_rtp_transport_channel()); 3359 EXPECT_TRUE(nullptr != session_->video_rtp_transport_channel());
3209 3360
3210 session_->Close(); 3361 session_->Close();
3211 EXPECT_TRUE(nullptr == session_->voice_rtp_transport_channel()); 3362 EXPECT_TRUE(nullptr == session_->voice_rtp_transport_channel());
3212 EXPECT_TRUE(nullptr == session_->voice_rtcp_transport_channel()); 3363 EXPECT_TRUE(nullptr == session_->voice_rtcp_transport_channel());
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
3279 // Expect an error when applying the remote description 3430 // Expect an error when applying the remote description
3280 SetRemoteDescriptionExpectError(JsepSessionDescription::kOffer, 3431 SetRemoteDescriptionExpectError(JsepSessionDescription::kOffer,
3281 kCreateChannelFailed, modified_offer); 3432 kCreateChannelFailed, modified_offer);
3282 } 3433 }
3283 3434
3284 // kBundlePolicyMaxCompat bundle policy and answer contains BUNDLE. 3435 // kBundlePolicyMaxCompat bundle policy and answer contains BUNDLE.
3285 TEST_F(WebRtcSessionTest, TestMaxCompatBundleInAnswer) { 3436 TEST_F(WebRtcSessionTest, TestMaxCompatBundleInAnswer) {
3286 InitWithBundlePolicy(PeerConnectionInterface::kBundlePolicyMaxCompat); 3437 InitWithBundlePolicy(PeerConnectionInterface::kBundlePolicyMaxCompat);
3287 SendAudioVideoStream1(); 3438 SendAudioVideoStream1();
3288 3439
3289 PeerConnectionInterface::RTCOfferAnswerOptions options; 3440 PeerConnectionInterface::RTCOfferAnswerOptions rtc_options;
3290 options.use_rtp_mux = true; 3441 rtc_options.use_rtp_mux = true;
3291 3442
3292 SessionDescriptionInterface* offer = CreateOffer(options); 3443 SessionDescriptionInterface* offer = CreateOffer(rtc_options);
3293 SetLocalDescriptionWithoutError(offer); 3444 SetLocalDescriptionWithoutError(offer);
3294 3445
3295 EXPECT_NE(session_->voice_rtp_transport_channel(), 3446 EXPECT_NE(session_->voice_rtp_transport_channel(),
3296 session_->video_rtp_transport_channel()); 3447 session_->video_rtp_transport_channel());
3297 3448
3298 SendAudioVideoStream2(); 3449 SendAudioVideoStream2();
3299 SessionDescriptionInterface* answer = 3450 SessionDescriptionInterface* answer =
3300 CreateRemoteAnswer(session_->local_description()); 3451 CreateRemoteAnswer(session_->local_description());
3301 SetRemoteDescriptionWithoutError(answer); 3452 SetRemoteDescriptionWithoutError(answer);
3302 3453
(...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after
3638 SetLocalDescriptionWithoutError(jsep_offer_str); 3789 SetLocalDescriptionWithoutError(jsep_offer_str);
3639 EXPECT_FALSE(session_->voice_channel()->srtp_required_for_testing()); 3790 EXPECT_FALSE(session_->voice_channel()->srtp_required_for_testing());
3640 EXPECT_FALSE(session_->video_channel()->srtp_required_for_testing()); 3791 EXPECT_FALSE(session_->video_channel()->srtp_required_for_testing());
3641 } 3792 }
3642 3793
3643 // This test verifies that an answer contains new ufrag and password if an offer 3794 // This test verifies that an answer contains new ufrag and password if an offer
3644 // with new ufrag and password is received. 3795 // with new ufrag and password is received.
3645 TEST_F(WebRtcSessionTest, TestCreateAnswerWithNewUfragAndPassword) { 3796 TEST_F(WebRtcSessionTest, TestCreateAnswerWithNewUfragAndPassword) {
3646 Init(); 3797 Init();
3647 cricket::MediaSessionOptions options; 3798 cricket::MediaSessionOptions options;
3648 options.recv_video = true; 3799 GetOptionsForRemoteOffer(&options);
3649 std::unique_ptr<JsepSessionDescription> offer(CreateRemoteOffer(options)); 3800 std::unique_ptr<JsepSessionDescription> offer(CreateRemoteOffer(options));
3650 SetRemoteDescriptionWithoutError(offer.release()); 3801 SetRemoteDescriptionWithoutError(offer.release());
3651 3802
3652 SendAudioVideoStream1(); 3803 SendAudioVideoStream1();
3653 std::unique_ptr<SessionDescriptionInterface> answer(CreateAnswer()); 3804 std::unique_ptr<SessionDescriptionInterface> answer(CreateAnswer());
3654 SetLocalDescriptionWithoutError(answer.release()); 3805 SetLocalDescriptionWithoutError(answer.release());
3655 3806
3656 // Receive an offer with new ufrag and password. 3807 // Receive an offer with new ufrag and password.
3657 for (const cricket::ContentInfo& content : 3808 for (size_t i = 0; i < options.media_description_options.size(); ++i) {
3658 session_->local_description()->description()->contents()) { 3809 options.media_description_options[i].transport_options.ice_restart = true;
3659 options.transport_options[content.name].ice_restart = true;
3660 } 3810 }
3811
3661 std::unique_ptr<JsepSessionDescription> updated_offer1( 3812 std::unique_ptr<JsepSessionDescription> updated_offer1(
3662 CreateRemoteOffer(options, session_->remote_description())); 3813 CreateRemoteOffer(options, session_->remote_description()));
3663 SetRemoteDescriptionWithoutError(updated_offer1.release()); 3814 SetRemoteDescriptionWithoutError(updated_offer1.release());
3664 3815
3665 std::unique_ptr<SessionDescriptionInterface> updated_answer1(CreateAnswer()); 3816 std::unique_ptr<SessionDescriptionInterface> updated_answer1(CreateAnswer());
3666 3817
3667 EXPECT_FALSE(IceUfragPwdEqual(updated_answer1->description(), 3818 EXPECT_FALSE(IceUfragPwdEqual(updated_answer1->description(),
3668 session_->local_description()->description())); 3819 session_->local_description()->description()));
3669 3820
3670 // Even a second answer (created before the description is set) should have 3821 // Even a second answer (created before the description is set) should have
3671 // a new ufrag/password. 3822 // a new ufrag/password.
3672 std::unique_ptr<SessionDescriptionInterface> updated_answer2(CreateAnswer()); 3823 std::unique_ptr<SessionDescriptionInterface> updated_answer2(CreateAnswer());
3673 3824
3674 EXPECT_FALSE(IceUfragPwdEqual(updated_answer2->description(), 3825 EXPECT_FALSE(IceUfragPwdEqual(updated_answer2->description(),
3675 session_->local_description()->description())); 3826 session_->local_description()->description()));
3676 3827
3677 SetLocalDescriptionWithoutError(updated_answer2.release()); 3828 SetLocalDescriptionWithoutError(updated_answer2.release());
3678 } 3829 }
3679 3830
3680 // This test verifies that an answer contains new ufrag and password if an offer 3831 // This test verifies that an answer contains new ufrag and password if an offer
3681 // that changes either the ufrag or password (but not both) is received. 3832 // that changes either the ufrag or password (but not both) is received.
3682 // RFC 5245 says: "If the offer contained a change in the a=ice-ufrag or 3833 // RFC 5245 says: "If the offer contained a change in the a=ice-ufrag or
3683 // a=ice-pwd attributes compared to the previous SDP from the peer, it 3834 // a=ice-pwd attributes compared to the previous SDP from the peer, it
3684 // indicates that ICE is restarting for this media stream." 3835 // indicates that ICE is restarting for this media stream."
3685 TEST_F(WebRtcSessionTest, TestOfferChangingOnlyUfragOrPassword) { 3836 TEST_F(WebRtcSessionTest, TestOfferChangingOnlyUfragOrPassword) {
3686 Init(); 3837 Init();
3687 cricket::MediaSessionOptions options; 3838 cricket::MediaSessionOptions options;
3688 options.recv_audio = true; 3839 GetOptionsForRemoteOffer(&options);
3689 options.recv_video = true;
3690 // Create an offer with audio and video. 3840 // Create an offer with audio and video.
3691 std::unique_ptr<JsepSessionDescription> offer(CreateRemoteOffer(options)); 3841 std::unique_ptr<JsepSessionDescription> offer(CreateRemoteOffer(options));
3692 SetIceUfragPwd(offer.get(), "original_ufrag", "original_password12345"); 3842 SetIceUfragPwd(offer.get(), "original_ufrag", "original_password12345");
3693 SetRemoteDescriptionWithoutError(offer.release()); 3843 SetRemoteDescriptionWithoutError(offer.release());
3694 3844
3695 SendAudioVideoStream1(); 3845 SendAudioVideoStream1();
3696 std::unique_ptr<SessionDescriptionInterface> answer(CreateAnswer()); 3846 std::unique_ptr<SessionDescriptionInterface> answer(CreateAnswer());
3697 SetLocalDescriptionWithoutError(answer.release()); 3847 SetLocalDescriptionWithoutError(answer.release());
3698 3848
3699 // Receive an offer with a new ufrag but stale password. 3849 // Receive an offer with a new ufrag but stale password.
(...skipping 19 matching lines...) Expand all
3719 EXPECT_FALSE(IceUfragPwdEqual(updated_answer2->description(), 3869 EXPECT_FALSE(IceUfragPwdEqual(updated_answer2->description(),
3720 session_->local_description()->description())); 3870 session_->local_description()->description()));
3721 SetLocalDescriptionWithoutError(updated_answer2.release()); 3871 SetLocalDescriptionWithoutError(updated_answer2.release());
3722 } 3872 }
3723 3873
3724 // This test verifies that an answer contains old ufrag and password if an offer 3874 // This test verifies that an answer contains old ufrag and password if an offer
3725 // with old ufrag and password is received. 3875 // with old ufrag and password is received.
3726 TEST_F(WebRtcSessionTest, TestCreateAnswerWithOldUfragAndPassword) { 3876 TEST_F(WebRtcSessionTest, TestCreateAnswerWithOldUfragAndPassword) {
3727 Init(); 3877 Init();
3728 cricket::MediaSessionOptions options; 3878 cricket::MediaSessionOptions options;
3729 options.recv_video = true; 3879 GetOptionsForRemoteOffer(&options);
3730 std::unique_ptr<JsepSessionDescription> offer(CreateRemoteOffer(options)); 3880 std::unique_ptr<JsepSessionDescription> offer(CreateRemoteOffer(options));
3731 SetRemoteDescriptionWithoutError(offer.release()); 3881 SetRemoteDescriptionWithoutError(offer.release());
3732 3882
3733 SendAudioVideoStream1(); 3883 SendAudioVideoStream1();
3734 std::unique_ptr<SessionDescriptionInterface> answer(CreateAnswer()); 3884 std::unique_ptr<SessionDescriptionInterface> answer(CreateAnswer());
3735 SetLocalDescriptionWithoutError(answer.release()); 3885 SetLocalDescriptionWithoutError(answer.release());
3736 3886
3737 // Receive an offer without changed ufrag or password. 3887 // Receive an offer without changed ufrag or password.
3738 std::unique_ptr<JsepSessionDescription> updated_offer2( 3888 std::unique_ptr<JsepSessionDescription> updated_offer2(
3739 CreateRemoteOffer(options, session_->remote_description())); 3889 CreateRemoteOffer(options, session_->remote_description()));
3740 SetRemoteDescriptionWithoutError(updated_offer2.release()); 3890 SetRemoteDescriptionWithoutError(updated_offer2.release());
3741 3891
3742 std::unique_ptr<SessionDescriptionInterface> updated_answer2(CreateAnswer()); 3892 std::unique_ptr<SessionDescriptionInterface> updated_answer2(CreateAnswer());
3743 3893
3744 EXPECT_TRUE(IceUfragPwdEqual(updated_answer2->description(), 3894 EXPECT_TRUE(IceUfragPwdEqual(updated_answer2->description(),
3745 session_->local_description()->description())); 3895 session_->local_description()->description()));
3746 3896
3747 SetLocalDescriptionWithoutError(updated_answer2.release()); 3897 SetLocalDescriptionWithoutError(updated_answer2.release());
3748 } 3898 }
3749 3899
3750 // This test verifies that if an offer does an ICE restart on some, but not all 3900 // This test verifies that if an offer does an ICE restart on some, but not all
3751 // media sections, the answer will change the ufrag/password in the correct 3901 // media sections, the answer will change the ufrag/password in the correct
3752 // media sections. 3902 // media sections.
3753 TEST_F(WebRtcSessionTest, TestCreateAnswerWithNewAndOldUfragAndPassword) { 3903 TEST_F(WebRtcSessionTest, TestCreateAnswerWithNewAndOldUfragAndPassword) {
3754 Init(); 3904 Init();
3755 cricket::MediaSessionOptions options; 3905 cricket::MediaSessionOptions options;
3756 options.recv_video = true; 3906 GetOptionsForRemoteOffer(&options);
3757 options.recv_audio = true;
3758 options.bundle_enabled = false; 3907 options.bundle_enabled = false;
3759 std::unique_ptr<JsepSessionDescription> offer(CreateRemoteOffer(options)); 3908 std::unique_ptr<JsepSessionDescription> offer(CreateRemoteOffer(options));
3760 3909
3761 SetIceUfragPwd(offer.get(), cricket::MEDIA_TYPE_AUDIO, "aaaa", 3910 SetIceUfragPwd(offer.get(), cricket::MEDIA_TYPE_AUDIO, "aaaa",
3762 "aaaaaaaaaaaaaaaaaaaaaa"); 3911 "aaaaaaaaaaaaaaaaaaaaaa");
3763 SetIceUfragPwd(offer.get(), cricket::MEDIA_TYPE_VIDEO, "bbbb", 3912 SetIceUfragPwd(offer.get(), cricket::MEDIA_TYPE_VIDEO, "bbbb",
3764 "bbbbbbbbbbbbbbbbbbbbbb"); 3913 "bbbbbbbbbbbbbbbbbbbbbb");
3765 SetRemoteDescriptionWithoutError(offer.release()); 3914 SetRemoteDescriptionWithoutError(offer.release());
3766 3915
3767 SendAudioVideoStream1(); 3916 SendAudioVideoStream1();
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
3879 CreateDataChannel(); 4028 CreateDataChannel();
3880 InitiateCall(); 4029 InitiateCall();
3881 ASSERT_TRUE(session_->sctp_content_name()); 4030 ASSERT_TRUE(session_->sctp_content_name());
3882 ASSERT_TRUE(session_->sctp_transport_name()); 4031 ASSERT_TRUE(session_->sctp_transport_name());
3883 EXPECT_EQ("data", *session_->sctp_content_name()); 4032 EXPECT_EQ("data", *session_->sctp_content_name());
3884 EXPECT_EQ("data", *session_->sctp_transport_name()); 4033 EXPECT_EQ("data", *session_->sctp_transport_name());
3885 4034
3886 // Create answer that finishes BUNDLE negotiation, which means everything 4035 // Create answer that finishes BUNDLE negotiation, which means everything
3887 // should be bundled on the first transport (audio). 4036 // should be bundled on the first transport (audio).
3888 cricket::MediaSessionOptions answer_options; 4037 cricket::MediaSessionOptions answer_options;
3889 answer_options.recv_video = true;
3890 answer_options.bundle_enabled = true; 4038 answer_options.bundle_enabled = true;
3891 answer_options.data_channel_type = cricket::DCT_SCTP; 4039 answer_options.data_channel_type = cricket::DCT_SCTP;
4040 GetOptionsForAnswer(&answer_options);
3892 SetRemoteDescriptionWithoutError(CreateRemoteAnswer( 4041 SetRemoteDescriptionWithoutError(CreateRemoteAnswer(
3893 session_->local_description(), answer_options, cricket::SEC_DISABLED)); 4042 session_->local_description(), answer_options, cricket::SEC_DISABLED));
3894 ASSERT_TRUE(session_->sctp_content_name()); 4043 ASSERT_TRUE(session_->sctp_content_name());
3895 ASSERT_TRUE(session_->sctp_transport_name()); 4044 ASSERT_TRUE(session_->sctp_transport_name());
3896 EXPECT_EQ("data", *session_->sctp_content_name()); 4045 EXPECT_EQ("data", *session_->sctp_content_name());
3897 EXPECT_EQ("audio", *session_->sctp_transport_name()); 4046 EXPECT_EQ("audio", *session_->sctp_transport_name());
3898 } 4047 }
3899 4048
3900 TEST_P(WebRtcSessionTest, TestCreateOfferWithSctpEnabledWithoutStreams) { 4049 TEST_P(WebRtcSessionTest, TestCreateOfferWithSctpEnabledWithoutStreams) {
3901 InitWithDtls(GetParam()); 4050 InitWithDtls(GetParam());
3902 4051
3903 std::unique_ptr<SessionDescriptionInterface> offer(CreateOffer()); 4052 std::unique_ptr<SessionDescriptionInterface> offer(CreateOffer());
3904 EXPECT_TRUE(offer->description()->GetContentByName("data") == NULL); 4053 EXPECT_TRUE(offer->description()->GetContentByName("data") == NULL);
3905 EXPECT_TRUE(offer->description()->GetTransportInfoByName("data") == NULL); 4054 EXPECT_TRUE(offer->description()->GetTransportInfoByName("data") == NULL);
3906 } 4055 }
3907 4056
3908 TEST_P(WebRtcSessionTest, TestCreateAnswerWithSctpInOfferAndNoStreams) { 4057 TEST_P(WebRtcSessionTest, TestCreateAnswerWithSctpInOfferAndNoStreams) {
3909 SetFactoryDtlsSrtp(); 4058 SetFactoryDtlsSrtp();
3910 InitWithDtls(GetParam()); 4059 InitWithDtls(GetParam());
3911 4060
3912 // Create remote offer with SCTP. 4061 // Create remote offer with SCTP.
3913 cricket::MediaSessionOptions options; 4062 cricket::MediaSessionOptions options;
3914 options.data_channel_type = cricket::DCT_SCTP; 4063 options.data_channel_type = cricket::DCT_SCTP;
4064 GetOptionsForRemoteOffer(&options);
3915 JsepSessionDescription* offer = 4065 JsepSessionDescription* offer =
3916 CreateRemoteOffer(options, cricket::SEC_DISABLED); 4066 CreateRemoteOffer(options, cricket::SEC_DISABLED);
3917 SetRemoteDescriptionWithoutError(offer); 4067 SetRemoteDescriptionWithoutError(offer);
3918 4068
3919 // Verifies the answer contains SCTP. 4069 // Verifies the answer contains SCTP.
3920 std::unique_ptr<SessionDescriptionInterface> answer(CreateAnswer()); 4070 std::unique_ptr<SessionDescriptionInterface> answer(CreateAnswer());
3921 EXPECT_TRUE(answer != NULL); 4071 EXPECT_TRUE(answer != NULL);
3922 EXPECT_TRUE(answer->description()->GetContentByName("data") != NULL); 4072 EXPECT_TRUE(answer->description()->GetContentByName("data") != NULL);
3923 EXPECT_TRUE(answer->description()->GetTransportInfoByName("data") != NULL); 4073 EXPECT_TRUE(answer->description()->GetTransportInfoByName("data") != NULL);
3924 } 4074 }
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
4048 } 4198 }
4049 4199
4050 // Verifies that CreateAnswer succeeds when CreateOffer is called before async 4200 // Verifies that CreateAnswer succeeds when CreateOffer is called before async
4051 // identity generation is finished (even if a certificate is provided this is 4201 // identity generation is finished (even if a certificate is provided this is
4052 // an async op). 4202 // an async op).
4053 TEST_P(WebRtcSessionTest, TestCreateAnswerBeforeIdentityRequestReturnSuccess) { 4203 TEST_P(WebRtcSessionTest, TestCreateAnswerBeforeIdentityRequestReturnSuccess) {
4054 InitWithDtls(GetParam()); 4204 InitWithDtls(GetParam());
4055 SetFactoryDtlsSrtp(); 4205 SetFactoryDtlsSrtp();
4056 4206
4057 cricket::MediaSessionOptions options; 4207 cricket::MediaSessionOptions options;
4058 options.recv_video = true; 4208 GetOptionsForRemoteOffer(&options);
4059 std::unique_ptr<JsepSessionDescription> offer( 4209 std::unique_ptr<JsepSessionDescription> offer(
4060 CreateRemoteOffer(options, cricket::SEC_DISABLED)); 4210 CreateRemoteOffer(options, cricket::SEC_DISABLED));
4061 ASSERT_TRUE(offer.get() != NULL); 4211 ASSERT_TRUE(offer.get() != NULL);
4062 SetRemoteDescriptionWithoutError(offer.release()); 4212 SetRemoteDescriptionWithoutError(offer.release());
4063 4213
4064 std::unique_ptr<SessionDescriptionInterface> answer(CreateAnswer()); 4214 std::unique_ptr<SessionDescriptionInterface> answer(CreateAnswer());
4065 EXPECT_TRUE(answer != NULL); 4215 EXPECT_TRUE(answer != NULL);
4066 VerifyNoCryptoParams(answer->description(), true); 4216 VerifyNoCryptoParams(answer->description(), true);
4067 VerifyFingerprintStatus(answer->description(), true); 4217 VerifyFingerprintStatus(answer->description(), true);
4068 } 4218 }
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
4122 CreateSessionDescriptionRequest::kAnswer); 4272 CreateSessionDescriptionRequest::kAnswer);
4123 } 4273 }
4124 4274
4125 // Verifies that setRemoteDescription fails when DTLS is disabled and the remote 4275 // Verifies that setRemoteDescription fails when DTLS is disabled and the remote
4126 // offer has no SDES crypto but only DTLS fingerprint. 4276 // offer has no SDES crypto but only DTLS fingerprint.
4127 TEST_F(WebRtcSessionTest, TestSetRemoteOfferFailIfDtlsDisabledAndNoCrypto) { 4277 TEST_F(WebRtcSessionTest, TestSetRemoteOfferFailIfDtlsDisabledAndNoCrypto) {
4128 // Init without DTLS. 4278 // Init without DTLS.
4129 Init(); 4279 Init();
4130 // Create a remote offer with secured transport disabled. 4280 // Create a remote offer with secured transport disabled.
4131 cricket::MediaSessionOptions options; 4281 cricket::MediaSessionOptions options;
4282 GetOptionsForRemoteOffer(&options);
4132 JsepSessionDescription* offer(CreateRemoteOffer( 4283 JsepSessionDescription* offer(CreateRemoteOffer(
4133 options, cricket::SEC_DISABLED)); 4284 options, cricket::SEC_DISABLED));
4134 // Adds a DTLS fingerprint to the remote offer. 4285 // Adds a DTLS fingerprint to the remote offer.
4135 cricket::SessionDescription* sdp = offer->description(); 4286 cricket::SessionDescription* sdp = offer->description();
4136 TransportInfo* audio = sdp->GetTransportInfoByName("audio"); 4287 TransportInfo* audio = sdp->GetTransportInfoByName("audio");
4137 ASSERT_TRUE(audio != NULL); 4288 ASSERT_TRUE(audio != NULL);
4138 ASSERT_TRUE(audio->description.identity_fingerprint.get() == NULL); 4289 ASSERT_TRUE(audio->description.identity_fingerprint.get() == NULL);
4139 audio->description.identity_fingerprint.reset( 4290 audio->description.identity_fingerprint.reset(
4140 rtc::SSLFingerprint::CreateFromRfc4572( 4291 rtc::SSLFingerprint::CreateFromRfc4572(
4141 rtc::DIGEST_SHA_256, kFakeDtlsFingerprint)); 4292 rtc::DIGEST_SHA_256, kFakeDtlsFingerprint));
(...skipping 23 matching lines...) Expand all
4165 SetFactoryDtlsSrtp(); 4316 SetFactoryDtlsSrtp();
4166 4317
4167 SendAudioOnlyStream2(); 4318 SendAudioOnlyStream2();
4168 SessionDescriptionInterface* offer = CreateOffer(); 4319 SessionDescriptionInterface* offer = CreateOffer();
4169 SetLocalDescriptionWithoutError(offer); 4320 SetLocalDescriptionWithoutError(offer);
4170 4321
4171 SessionDescriptionInterface* answer = CreateRemoteAnswer(offer); 4322 SessionDescriptionInterface* answer = CreateRemoteAnswer(offer);
4172 SetRemoteDescriptionWithoutError(answer); 4323 SetRemoteDescriptionWithoutError(answer);
4173 4324
4174 cricket::MediaSessionOptions options; 4325 cricket::MediaSessionOptions options;
4175 options.recv_video = true; 4326 GetOptionsForRemoteOffer(&options);
4176 offer = CreateRemoteOffer(options, cricket::SEC_DISABLED); 4327 offer = CreateRemoteOffer(options, cricket::SEC_DISABLED);
4177 4328
4178 cricket::Candidate candidate1; 4329 cricket::Candidate candidate1;
4179 candidate1.set_address(rtc::SocketAddress("1.1.1.1", 5000)); 4330 candidate1.set_address(rtc::SocketAddress("1.1.1.1", 5000));
4180 candidate1.set_component(1); 4331 candidate1.set_component(1);
4181 JsepIceCandidate ice_candidate(kMediaContentName1, kMediaContentIndex1, 4332 JsepIceCandidate ice_candidate(kMediaContentName1, kMediaContentIndex1,
4182 candidate1); 4333 candidate1);
4183 EXPECT_TRUE(offer->AddCandidate(&ice_candidate)); 4334 EXPECT_TRUE(offer->AddCandidate(&ice_candidate));
4184 SetRemoteDescriptionWithoutError(offer); 4335 SetRemoteDescriptionWithoutError(offer);
4185 4336
4186 answer = CreateAnswer(); 4337 answer = CreateAnswer();
4187 SetLocalDescriptionWithoutError(answer); 4338 SetLocalDescriptionWithoutError(answer);
4188 } 4339 }
4189 4340
4190 // Tests that we can renegotiate new media content with ICE candidates separated 4341 // Tests that we can renegotiate new media content with ICE candidates separated
4191 // from the remote SDP. 4342 // from the remote SDP.
4192 TEST_P(WebRtcSessionTest, TestRenegotiateNewMediaWithCandidatesSeparated) { 4343 TEST_P(WebRtcSessionTest, TestRenegotiateNewMediaWithCandidatesSeparated) {
4193 InitWithDtls(GetParam()); 4344 InitWithDtls(GetParam());
4194 SetFactoryDtlsSrtp(); 4345 SetFactoryDtlsSrtp();
4195 4346
4196 SendAudioOnlyStream2(); 4347 SendAudioOnlyStream2();
4197 SessionDescriptionInterface* offer = CreateOffer(); 4348 SessionDescriptionInterface* offer = CreateOffer();
4198 SetLocalDescriptionWithoutError(offer); 4349 SetLocalDescriptionWithoutError(offer);
4199 4350
4200 SessionDescriptionInterface* answer = CreateRemoteAnswer(offer); 4351 SessionDescriptionInterface* answer = CreateRemoteAnswer(offer);
4201 SetRemoteDescriptionWithoutError(answer); 4352 SetRemoteDescriptionWithoutError(answer);
4202 4353
4203 cricket::MediaSessionOptions options; 4354 cricket::MediaSessionOptions options;
4204 options.recv_video = true; 4355 GetOptionsForRemoteOffer(&options);
4205 offer = CreateRemoteOffer(options, cricket::SEC_DISABLED); 4356 offer = CreateRemoteOffer(options, cricket::SEC_DISABLED);
4206 SetRemoteDescriptionWithoutError(offer); 4357 SetRemoteDescriptionWithoutError(offer);
4207 4358
4208 cricket::Candidate candidate1; 4359 cricket::Candidate candidate1;
4209 candidate1.set_address(rtc::SocketAddress("1.1.1.1", 5000)); 4360 candidate1.set_address(rtc::SocketAddress("1.1.1.1", 5000));
4210 candidate1.set_component(1); 4361 candidate1.set_component(1);
4211 JsepIceCandidate ice_candidate(kMediaContentName1, kMediaContentIndex1, 4362 JsepIceCandidate ice_candidate(kMediaContentName1, kMediaContentIndex1,
4212 candidate1); 4363 candidate1);
4213 EXPECT_TRUE(session_->ProcessIceMessage(&ice_candidate)); 4364 EXPECT_TRUE(session_->ProcessIceMessage(&ice_candidate));
4214 4365
4215 answer = CreateAnswer(); 4366 answer = CreateAnswer();
4216 SetLocalDescriptionWithoutError(answer); 4367 SetLocalDescriptionWithoutError(answer);
4217 } 4368 }
4218 4369
4219 #ifdef HAVE_QUIC 4370 #ifdef HAVE_QUIC
4220 TEST_P(WebRtcSessionTest, TestNegotiateQuic) { 4371 TEST_P(WebRtcSessionTest, TestNegotiateQuic) {
4221 configuration_.enable_quic = true; 4372 configuration_.enable_quic = true;
4222 InitWithDtls(GetParam()); 4373 InitWithDtls(GetParam());
4223 EXPECT_TRUE(session_->data_channel_type() == cricket::DCT_QUIC); 4374 EXPECT_TRUE(session_->data_channel_type() == cricket::DCT_QUIC);
4224 SessionDescriptionInterface* offer = CreateOffer(); 4375 SessionDescriptionInterface* offer = CreateOffer();
4225 ASSERT_TRUE(offer); 4376 ASSERT_TRUE(offer);
4226 ASSERT_TRUE(offer->description()); 4377 ASSERT_TRUE(offer->description());
4227 SetLocalDescriptionWithoutError(offer); 4378 SetLocalDescriptionWithoutError(offer);
4228 cricket::MediaSessionOptions options; 4379 cricket::MediaSessionOptions options;
4229 options.recv_audio = true; 4380 GetOptionsForAnswer(&options);
4230 options.recv_video = true;
4231 SessionDescriptionInterface* answer = 4381 SessionDescriptionInterface* answer =
4232 CreateRemoteAnswer(offer, options, cricket::SEC_DISABLED); 4382 CreateRemoteAnswer(offer, options, cricket::SEC_DISABLED);
4233 ASSERT_TRUE(answer); 4383 ASSERT_TRUE(answer);
4234 ASSERT_TRUE(answer->description()); 4384 ASSERT_TRUE(answer->description());
4235 SetRemoteDescriptionWithoutError(answer); 4385 SetRemoteDescriptionWithoutError(answer);
4236 } 4386 }
4237 #endif // HAVE_QUIC 4387 #endif // HAVE_QUIC
4238 4388
4239 // Tests that RTX codec is removed from the answer when it isn't supported 4389 // Tests that RTX codec is removed from the answer when it isn't supported
4240 // by local side. 4390 // by local side.
4241 TEST_F(WebRtcSessionTest, TestRtxRemovedByCreateAnswer) { 4391 TEST_F(WebRtcSessionTest, TestRtxRemovedByCreateAnswer) {
4242 Init(); 4392 Init();
4243 SendAudioVideoStream1(); 4393 // Send video only to match the |kSdpWithRtx|.
4394 SendVideoOnlyStream2();
4244 std::string offer_sdp(kSdpWithRtx); 4395 std::string offer_sdp(kSdpWithRtx);
4245 4396
4246 SessionDescriptionInterface* offer = 4397 SessionDescriptionInterface* offer =
4247 CreateSessionDescription(JsepSessionDescription::kOffer, offer_sdp, NULL); 4398 CreateSessionDescription(JsepSessionDescription::kOffer, offer_sdp, NULL);
4248 EXPECT_TRUE(offer->ToString(&offer_sdp)); 4399 EXPECT_TRUE(offer->ToString(&offer_sdp));
4249 4400
4250 // Offer SDP contains the RTX codec. 4401 // Offer SDP contains the RTX codec.
4251 EXPECT_TRUE(ContainsVideoCodecWithName(offer, "rtx")); 4402 EXPECT_TRUE(ContainsVideoCodecWithName(offer, "rtx"));
4252 SetRemoteDescriptionWithoutError(offer); 4403 SetRemoteDescriptionWithoutError(offer);
4253 4404
4405 // |offered_media_sections_| is used when creating answer.
4406 offered_media_sections_.push_back(cricket::MediaDescriptionOptions(
4407 cricket::MEDIA_TYPE_VIDEO, cricket::CN_VIDEO,
4408 cricket::RtpTransceiverDirection(true, true), false));
4409 // Don't create media section for audio in the answer.
4254 SessionDescriptionInterface* answer = CreateAnswer(); 4410 SessionDescriptionInterface* answer = CreateAnswer();
4255 // Answer SDP does not contain the RTX codec. 4411 // Answer SDP does not contain the RTX codec.
4256 EXPECT_FALSE(ContainsVideoCodecWithName(answer, "rtx")); 4412 EXPECT_FALSE(ContainsVideoCodecWithName(answer, "rtx"));
4257 SetLocalDescriptionWithoutError(answer); 4413 SetLocalDescriptionWithoutError(answer);
4258 } 4414 }
4259 4415
4260 // This verifies that the voice channel after bundle has both options from video 4416 // This verifies that the voice channel after bundle has both options from video
4261 // and voice channels. 4417 // and voice channels.
4262 TEST_F(WebRtcSessionTest, TestSetSocketOptionBeforeBundle) { 4418 TEST_F(WebRtcSessionTest, TestSetSocketOptionBeforeBundle) {
4263 InitWithBundlePolicy(PeerConnectionInterface::kBundlePolicyBalanced); 4419 InitWithBundlePolicy(PeerConnectionInterface::kBundlePolicyBalanced);
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
4309 // and make sure we got success/failure callbacks for all of the requests. 4465 // and make sure we got success/failure callbacks for all of the requests.
4310 // Background: crbug.com/507307 4466 // Background: crbug.com/507307
4311 TEST_F(WebRtcSessionTest, CreateOffersAndShutdown) { 4467 TEST_F(WebRtcSessionTest, CreateOffersAndShutdown) {
4312 Init(); 4468 Init();
4313 4469
4314 rtc::scoped_refptr<WebRtcSessionCreateSDPObserverForTest> observers[100]; 4470 rtc::scoped_refptr<WebRtcSessionCreateSDPObserverForTest> observers[100];
4315 PeerConnectionInterface::RTCOfferAnswerOptions options; 4471 PeerConnectionInterface::RTCOfferAnswerOptions options;
4316 options.offer_to_receive_audio = 4472 options.offer_to_receive_audio =
4317 RTCOfferAnswerOptions::kOfferToReceiveMediaTrue; 4473 RTCOfferAnswerOptions::kOfferToReceiveMediaTrue;
4318 cricket::MediaSessionOptions session_options; 4474 cricket::MediaSessionOptions session_options;
4319 session_options.recv_audio = true; 4475 GetOptionsForOffer(options, &session_options);
4320
4321 for (auto& o : observers) { 4476 for (auto& o : observers) {
4322 o = new WebRtcSessionCreateSDPObserverForTest(); 4477 o = new WebRtcSessionCreateSDPObserverForTest();
4323 session_->CreateOffer(o, options, session_options); 4478 session_->CreateOffer(o, options, session_options);
4324 } 4479 }
4325 4480
4326 session_.reset(); 4481 session_.reset();
4327 4482
4328 for (auto& o : observers) { 4483 for (auto& o : observers) {
4329 // We expect to have received a notification now even if the session was 4484 // We expect to have received a notification now even if the session was
4330 // terminated. The offer creation may or may not have succeeded, but we 4485 // terminated. The offer creation may or may not have succeeded, but we
4331 // must have received a notification which, so the only invalid state 4486 // must have received a notification which, so the only invalid state
4332 // is kInit. 4487 // is kInit.
4333 EXPECT_NE(WebRtcSessionCreateSDPObserverForTest::kInit, o->state()); 4488 EXPECT_NE(WebRtcSessionCreateSDPObserverForTest::kInit, o->state());
4334 } 4489 }
4335 } 4490 }
4336 4491
4337 TEST_F(WebRtcSessionTest, TestPacketOptionsAndOnPacketSent) { 4492 TEST_F(WebRtcSessionTest, TestPacketOptionsAndOnPacketSent) {
4338 TestPacketOptions(); 4493 TestPacketOptions();
4339 } 4494 }
4340 4495
4341 // TODO(bemasc): Add a TestIceStatesBundle with BUNDLE enabled. That test 4496 // TODO(bemasc): Add a TestIceStatesBundle with BUNDLE enabled. That test
4342 // currently fails because upon disconnection and reconnection OnIceComplete is 4497 // currently fails because upon disconnection and reconnection OnIceComplete is
4343 // called more than once without returning to IceGatheringGathering. 4498 // called more than once without returning to IceGatheringGathering.
4344 4499
4345 INSTANTIATE_TEST_CASE_P(WebRtcSessionTests, 4500 INSTANTIATE_TEST_CASE_P(WebRtcSessionTests,
4346 WebRtcSessionTest, 4501 WebRtcSessionTest,
4347 testing::Values(ALREADY_GENERATED, 4502 testing::Values(ALREADY_GENERATED,
4348 DTLS_IDENTITY_STORE)); 4503 DTLS_IDENTITY_STORE));
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698