Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 741 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 752 } | 752 } |
| 753 if (transport_desc1->ice_pwd != transport_desc2->ice_pwd || | 753 if (transport_desc1->ice_pwd != transport_desc2->ice_pwd || |
| 754 transport_desc1->ice_ufrag != transport_desc2->ice_ufrag) { | 754 transport_desc1->ice_ufrag != transport_desc2->ice_ufrag) { |
| 755 EXPECT_FALSE(expect_equal); | 755 EXPECT_FALSE(expect_equal); |
| 756 return; | 756 return; |
| 757 } | 757 } |
| 758 } | 758 } |
| 759 EXPECT_TRUE(expect_equal); | 759 EXPECT_TRUE(expect_equal); |
| 760 } | 760 } |
| 761 | 761 |
| 762 // Compares ufrag/password only for the specified media type. | |
| 763 void CompareIceUfragAndPassword(const cricket::SessionDescription* desc1, | |
| 764 const cricket::SessionDescription* desc2, | |
| 765 cricket::MediaType media_type, | |
| 766 bool expect_equal) { | |
|
pthatcher1
2016/02/17 06:46:58
Can you wrap this in something with the name "Expe
Taylor Brandstetter
2016/02/17 21:43:50
Again, just copy/pasted code. But I'll fix it...
| |
| 767 if (desc1->contents().size() != desc2->contents().size()) { | |
| 768 EXPECT_FALSE(expect_equal); | |
|
pthatcher1
2016/02/17 06:46:58
The test errors will be easier to read if you writ
Taylor Brandstetter
2016/02/17 21:43:50
I just made this function return a bool. I think i
| |
| 769 return; | |
| 770 } | |
| 771 | |
| 772 const cricket::ContentInfo* cinfo = | |
| 773 cricket::GetFirstMediaContent(desc1->contents(), media_type); | |
| 774 const cricket::TransportDescription* transport_desc1 = | |
| 775 desc1->GetTransportDescriptionByName(cinfo->name); | |
| 776 const cricket::TransportDescription* transport_desc2 = | |
| 777 desc2->GetTransportDescriptionByName(cinfo->name); | |
| 778 if (!transport_desc1 || !transport_desc2) { | |
| 779 EXPECT_FALSE(expect_equal); | |
| 780 return; | |
| 781 } | |
| 782 if (transport_desc1->ice_pwd != transport_desc2->ice_pwd || | |
| 783 transport_desc1->ice_ufrag != transport_desc2->ice_ufrag) { | |
| 784 EXPECT_FALSE(expect_equal); | |
| 785 return; | |
| 786 } | |
| 787 EXPECT_TRUE(expect_equal); | |
| 788 } | |
| 789 | |
| 762 void RemoveIceUfragPwdLines(const SessionDescriptionInterface* current_desc, | 790 void RemoveIceUfragPwdLines(const SessionDescriptionInterface* current_desc, |
| 763 std::string *sdp) { | 791 std::string *sdp) { |
| 764 const cricket::SessionDescription* desc = current_desc->description(); | 792 const cricket::SessionDescription* desc = current_desc->description(); |
| 765 EXPECT_TRUE(current_desc->ToString(sdp)); | 793 EXPECT_TRUE(current_desc->ToString(sdp)); |
| 766 | 794 |
| 767 const cricket::ContentInfos& contents = desc->contents(); | 795 const cricket::ContentInfos& contents = desc->contents(); |
| 768 cricket::ContentInfos::const_iterator it = contents.begin(); | 796 cricket::ContentInfos::const_iterator it = contents.begin(); |
| 769 // Replace ufrag and pwd lines with empty strings. | 797 // Replace ufrag and pwd lines with empty strings. |
| 770 for (; it != contents.end(); ++it) { | 798 for (; it != contents.end(); ++it) { |
| 771 const cricket::TransportDescription* transport_desc = | 799 const cricket::TransportDescription* transport_desc = |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 805 std::string mod_pwd = "a=ice-pwd:" + modified_ice_pwd + "\r\n"; | 833 std::string mod_pwd = "a=ice-pwd:" + modified_ice_pwd + "\r\n"; |
| 806 rtc::replace_substrs(ufrag_line.c_str(), ufrag_line.length(), | 834 rtc::replace_substrs(ufrag_line.c_str(), ufrag_line.length(), |
| 807 mod_ufrag.c_str(), mod_ufrag.length(), | 835 mod_ufrag.c_str(), mod_ufrag.length(), |
| 808 sdp); | 836 sdp); |
| 809 rtc::replace_substrs(pwd_line.c_str(), pwd_line.length(), | 837 rtc::replace_substrs(pwd_line.c_str(), pwd_line.length(), |
| 810 mod_pwd.c_str(), mod_pwd.length(), | 838 mod_pwd.c_str(), mod_pwd.length(), |
| 811 sdp); | 839 sdp); |
| 812 } | 840 } |
| 813 } | 841 } |
| 814 | 842 |
| 843 // Modifies ufrag/pwd for specified |media_type|, by directly modifying the | |
| 844 // description. | |
| 845 void ModifyIceUfragPwd(SessionDescriptionInterface* current_desc, | |
| 846 cricket::MediaType media_type, | |
| 847 const std::string& modified_ice_ufrag, | |
| 848 const std::string& modified_ice_pwd) { | |
|
pthatcher1
2016/02/17 06:46:58
Why not just call it SetIceUfragPwd and remove the
pthatcher1
2016/02/17 06:46:58
I think |ufrag| and |pwd| are probably sufficient
Taylor Brandstetter
2016/02/17 21:43:50
Done.
Taylor Brandstetter
2016/02/17 21:43:50
Done.
| |
| 849 cricket::SessionDescription* desc = current_desc->description(); | |
| 850 const cricket::ContentInfo* cinfo = | |
| 851 cricket::GetFirstMediaContent(desc->contents(), media_type); | |
| 852 // Replace ufrag and pwd with |modified_ice_ufrag| and | |
| 853 // |modified_ice_pwd| strings. | |
| 854 TransportInfo* transport_info = desc->GetTransportInfoByName(cinfo->name); | |
| 855 cricket::TransportDescription* transport_desc = | |
| 856 &transport_info->description; | |
| 857 transport_desc->ice_ufrag = modified_ice_ufrag; | |
| 858 transport_desc->ice_pwd = modified_ice_pwd; | |
| 859 } | |
| 860 | |
| 815 // Creates a remote offer and and applies it as a remote description, | 861 // Creates a remote offer and and applies it as a remote description, |
| 816 // creates a local answer and applies is as a local description. | 862 // creates a local answer and applies is as a local description. |
| 817 // Call SendAudioVideoStreamX() before this function | 863 // Call SendAudioVideoStreamX() before this function |
| 818 // to decide which local and remote streams to create. | 864 // to decide which local and remote streams to create. |
| 819 void CreateAndSetRemoteOfferAndLocalAnswer() { | 865 void CreateAndSetRemoteOfferAndLocalAnswer() { |
| 820 SessionDescriptionInterface* offer = CreateRemoteOffer(); | 866 SessionDescriptionInterface* offer = CreateRemoteOffer(); |
| 821 SetRemoteDescriptionWithoutError(offer); | 867 SetRemoteDescriptionWithoutError(offer); |
| 822 SessionDescriptionInterface* answer = CreateAnswer(NULL); | 868 SessionDescriptionInterface* answer = CreateAnswer(NULL); |
| 823 SetLocalDescriptionWithoutError(answer); | 869 SetLocalDescriptionWithoutError(answer); |
| 824 } | 870 } |
| (...skipping 2810 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3635 rtc::scoped_ptr<JsepSessionDescription> offer( | 3681 rtc::scoped_ptr<JsepSessionDescription> offer( |
| 3636 CreateRemoteOffer(options)); | 3682 CreateRemoteOffer(options)); |
| 3637 SetRemoteDescriptionWithoutError(offer.release()); | 3683 SetRemoteDescriptionWithoutError(offer.release()); |
| 3638 | 3684 |
| 3639 SendAudioVideoStream1(); | 3685 SendAudioVideoStream1(); |
| 3640 rtc::scoped_ptr<SessionDescriptionInterface> answer( | 3686 rtc::scoped_ptr<SessionDescriptionInterface> answer( |
| 3641 CreateAnswer(NULL)); | 3687 CreateAnswer(NULL)); |
| 3642 SetLocalDescriptionWithoutError(answer.release()); | 3688 SetLocalDescriptionWithoutError(answer.release()); |
| 3643 | 3689 |
| 3644 // Receive an offer with new ufrag and password. | 3690 // Receive an offer with new ufrag and password. |
| 3645 options.audio_transport_options.ice_restart = true; | 3691 for (const cricket::ContentInfo& content : |
| 3646 options.video_transport_options.ice_restart = true; | 3692 session_->local_description()->description()->contents()) { |
| 3647 options.data_transport_options.ice_restart = true; | 3693 options.transport_options[content.name].ice_restart = true; |
| 3694 } | |
| 3648 rtc::scoped_ptr<JsepSessionDescription> updated_offer1( | 3695 rtc::scoped_ptr<JsepSessionDescription> updated_offer1( |
| 3649 CreateRemoteOffer(options, session_->remote_description())); | 3696 CreateRemoteOffer(options, session_->remote_description())); |
| 3650 SetRemoteDescriptionWithoutError(updated_offer1.release()); | 3697 SetRemoteDescriptionWithoutError(updated_offer1.release()); |
| 3651 | 3698 |
| 3652 rtc::scoped_ptr<SessionDescriptionInterface> updated_answer1( | 3699 rtc::scoped_ptr<SessionDescriptionInterface> updated_answer1( |
| 3653 CreateAnswer(NULL)); | 3700 CreateAnswer(NULL)); |
| 3654 | 3701 |
| 3655 CompareIceUfragAndPassword(updated_answer1->description(), | 3702 CompareIceUfragAndPassword(updated_answer1->description(), |
| 3656 session_->local_description()->description(), | 3703 session_->local_description()->description(), |
| 3657 false); | 3704 false); |
| 3658 | 3705 |
| 3659 SetLocalDescriptionWithoutError(updated_answer1.release()); | 3706 // Even a second answer (created before the description is set) should have |
| 3707 // a new ufrag/password. | |
| 3708 rtc::scoped_ptr<SessionDescriptionInterface> updated_answer2( | |
| 3709 CreateAnswer(NULL)); | |
| 3710 | |
| 3711 CompareIceUfragAndPassword(updated_answer2->description(), | |
| 3712 session_->local_description()->description(), | |
| 3713 false); | |
| 3714 | |
| 3715 SetLocalDescriptionWithoutError(updated_answer2.release()); | |
| 3660 } | 3716 } |
| 3661 | 3717 |
| 3662 // This test verifies that an answer contains old ufrag and password if an offer | 3718 // This test verifies that an answer contains old ufrag and password if an offer |
| 3663 // with old ufrag and password is received. | 3719 // with old ufrag and password is received. |
| 3664 TEST_F(WebRtcSessionTest, TestCreateAnswerWithOldUfragAndPassword) { | 3720 TEST_F(WebRtcSessionTest, TestCreateAnswerWithOldUfragAndPassword) { |
| 3665 Init(); | 3721 Init(); |
| 3666 cricket::MediaSessionOptions options; | 3722 cricket::MediaSessionOptions options; |
| 3667 options.recv_video = true; | 3723 options.recv_video = true; |
| 3668 rtc::scoped_ptr<JsepSessionDescription> offer( | 3724 rtc::scoped_ptr<JsepSessionDescription> offer( |
| 3669 CreateRemoteOffer(options)); | 3725 CreateRemoteOffer(options)); |
| 3670 SetRemoteDescriptionWithoutError(offer.release()); | 3726 SetRemoteDescriptionWithoutError(offer.release()); |
| 3671 | 3727 |
| 3672 SendAudioVideoStream1(); | 3728 SendAudioVideoStream1(); |
| 3673 rtc::scoped_ptr<SessionDescriptionInterface> answer( | 3729 rtc::scoped_ptr<SessionDescriptionInterface> answer( |
| 3674 CreateAnswer(NULL)); | 3730 CreateAnswer(NULL)); |
| 3675 SetLocalDescriptionWithoutError(answer.release()); | 3731 SetLocalDescriptionWithoutError(answer.release()); |
| 3676 | 3732 |
| 3677 // Receive an offer without changed ufrag or password. | 3733 // Receive an offer without changed ufrag or password. |
| 3678 options.audio_transport_options.ice_restart = false; | |
| 3679 options.video_transport_options.ice_restart = false; | |
| 3680 options.data_transport_options.ice_restart = false; | |
| 3681 rtc::scoped_ptr<JsepSessionDescription> updated_offer2( | 3734 rtc::scoped_ptr<JsepSessionDescription> updated_offer2( |
| 3682 CreateRemoteOffer(options, session_->remote_description())); | 3735 CreateRemoteOffer(options, session_->remote_description())); |
| 3683 SetRemoteDescriptionWithoutError(updated_offer2.release()); | 3736 SetRemoteDescriptionWithoutError(updated_offer2.release()); |
| 3684 | 3737 |
| 3685 rtc::scoped_ptr<SessionDescriptionInterface> updated_answer2( | 3738 rtc::scoped_ptr<SessionDescriptionInterface> updated_answer2( |
| 3686 CreateAnswer(NULL)); | 3739 CreateAnswer(NULL)); |
| 3687 | 3740 |
| 3688 CompareIceUfragAndPassword(updated_answer2->description(), | 3741 CompareIceUfragAndPassword(updated_answer2->description(), |
| 3689 session_->local_description()->description(), | 3742 session_->local_description()->description(), |
| 3690 true); | 3743 true); |
| 3691 | 3744 |
| 3692 SetLocalDescriptionWithoutError(updated_answer2.release()); | 3745 SetLocalDescriptionWithoutError(updated_answer2.release()); |
| 3693 } | 3746 } |
| 3694 | 3747 |
| 3748 // This test verifies that if an offer does an ICE restart on some, but not all | |
| 3749 // media sections, the answer will change the ufrag/password in the correct | |
| 3750 // media sections. | |
| 3751 TEST_F(WebRtcSessionTest, TestCreateAnswerWithNewAndOldUfragAndPassword) { | |
| 3752 Init(); | |
| 3753 cricket::MediaSessionOptions options; | |
| 3754 options.recv_video = true; | |
| 3755 options.recv_audio = true; | |
| 3756 options.bundle_enabled = false; | |
| 3757 rtc::scoped_ptr<JsepSessionDescription> offer(CreateRemoteOffer(options)); | |
| 3758 | |
| 3759 ModifyIceUfragPwd(offer.get(), cricket::MEDIA_TYPE_AUDIO, "aaaa", | |
| 3760 "aaaaaaaaaaaaaaaaaaaaaa"); | |
|
pthatcher1
2016/02/17 06:46:58
This might be more readable as "ufrag_a1" and "pwd
Taylor Brandstetter
2016/02/17 21:43:50
I think "a", "b" and "c" makes it more clear since
| |
| 3761 ModifyIceUfragPwd(offer.get(), cricket::MEDIA_TYPE_VIDEO, "bbbb", | |
| 3762 "bbbbbbbbbbbbbbbbbbbbbb"); | |
| 3763 SetRemoteDescriptionWithoutError(offer.release()); | |
| 3764 | |
| 3765 SendAudioVideoStream1(); | |
| 3766 rtc::scoped_ptr<SessionDescriptionInterface> answer(CreateAnswer(nullptr)); | |
| 3767 SetLocalDescriptionWithoutError(answer.release()); | |
| 3768 | |
| 3769 // Receive an offer with new ufrag and password, but only for the video media | |
| 3770 // section. | |
| 3771 rtc::scoped_ptr<JsepSessionDescription> updated_offer( | |
| 3772 CreateRemoteOffer(options, session_->remote_description())); | |
| 3773 ModifyIceUfragPwd(updated_offer.get(), cricket::MEDIA_TYPE_VIDEO, "cccc", | |
| 3774 "cccccccccccccccccccccc"); | |
| 3775 SetRemoteDescriptionWithoutError(updated_offer.release()); | |
| 3776 | |
| 3777 rtc::scoped_ptr<SessionDescriptionInterface> updated_answer( | |
| 3778 CreateAnswer(nullptr)); | |
| 3779 | |
| 3780 CompareIceUfragAndPassword(updated_answer->description(), | |
| 3781 session_->local_description()->description(), | |
| 3782 cricket::MEDIA_TYPE_AUDIO, true); | |
| 3783 | |
| 3784 CompareIceUfragAndPassword(updated_answer->description(), | |
| 3785 session_->local_description()->description(), | |
| 3786 cricket::MEDIA_TYPE_VIDEO, false); | |
| 3787 | |
| 3788 SetLocalDescriptionWithoutError(updated_answer.release()); | |
|
pthatcher1
2016/02/17 06:46:58
Should we also test if you change only the ufrag o
Taylor Brandstetter
2016/02/17 21:43:50
Maybe? What SHOULD we do when that happens? Is it
pthatcher1
2016/02/17 21:53:38
I think we should treat changing either as restart
Taylor Brandstetter
2016/02/18 00:33:21
I was more asking what the spec says. The spec def
| |
| 3789 } | |
| 3790 | |
| 3695 TEST_F(WebRtcSessionTest, TestSessionContentError) { | 3791 TEST_F(WebRtcSessionTest, TestSessionContentError) { |
| 3696 Init(); | 3792 Init(); |
| 3697 SendAudioVideoStream1(); | 3793 SendAudioVideoStream1(); |
| 3698 SessionDescriptionInterface* offer = CreateOffer(); | 3794 SessionDescriptionInterface* offer = CreateOffer(); |
| 3699 const std::string session_id_orig = offer->session_id(); | 3795 const std::string session_id_orig = offer->session_id(); |
| 3700 const std::string session_version_orig = offer->session_version(); | 3796 const std::string session_version_orig = offer->session_version(); |
| 3701 SetLocalDescriptionWithoutError(offer); | 3797 SetLocalDescriptionWithoutError(offer); |
| 3702 | 3798 |
| 3703 video_channel_ = media_engine_->GetVideoChannel(0); | 3799 video_channel_ = media_engine_->GetVideoChannel(0); |
| 3704 video_channel_->set_fail_set_send_codecs(true); | 3800 video_channel_->set_fail_set_send_codecs(true); |
| (...skipping 571 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4276 } | 4372 } |
| 4277 | 4373 |
| 4278 // TODO(bemasc): Add a TestIceStatesBundle with BUNDLE enabled. That test | 4374 // TODO(bemasc): Add a TestIceStatesBundle with BUNDLE enabled. That test |
| 4279 // currently fails because upon disconnection and reconnection OnIceComplete is | 4375 // currently fails because upon disconnection and reconnection OnIceComplete is |
| 4280 // called more than once without returning to IceGatheringGathering. | 4376 // called more than once without returning to IceGatheringGathering. |
| 4281 | 4377 |
| 4282 INSTANTIATE_TEST_CASE_P(WebRtcSessionTests, | 4378 INSTANTIATE_TEST_CASE_P(WebRtcSessionTests, |
| 4283 WebRtcSessionTest, | 4379 WebRtcSessionTest, |
| 4284 testing::Values(ALREADY_GENERATED, | 4380 testing::Values(ALREADY_GENERATED, |
| 4285 DTLS_IDENTITY_STORE)); | 4381 DTLS_IDENTITY_STORE)); |
| OLD | NEW |