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

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

Issue 1671173002: Track pending ICE restarts independently for different media sections. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Revising some comments. Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * libjingle 2 * libjingle
3 * Copyright 2012 Google Inc. 3 * Copyright 2012 Google Inc.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met: 6 * modification, are permitted provided that the following conditions are met:
7 * 7 *
8 * 1. Redistributions of source code must retain the above copyright notice, 8 * 1. Redistributions of source code must retain the above copyright notice,
9 * this list of conditions and the following disclaimer. 9 * this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright notice, 10 * 2. Redistributions in binary form must reproduce the above copyright notice,
(...skipping 775 matching lines...) Expand 10 before | Expand all | Expand 10 after
786 } 786 }
787 if (transport_desc1->ice_pwd != transport_desc2->ice_pwd || 787 if (transport_desc1->ice_pwd != transport_desc2->ice_pwd ||
788 transport_desc1->ice_ufrag != transport_desc2->ice_ufrag) { 788 transport_desc1->ice_ufrag != transport_desc2->ice_ufrag) {
789 EXPECT_FALSE(expect_equal); 789 EXPECT_FALSE(expect_equal);
790 return; 790 return;
791 } 791 }
792 } 792 }
793 EXPECT_TRUE(expect_equal); 793 EXPECT_TRUE(expect_equal);
794 } 794 }
795 795
796 // Compares ufrag/password only for the specified media type.
797 void CompareIceUfragAndPassword(const cricket::SessionDescription* desc1,
798 const cricket::SessionDescription* desc2,
799 cricket::MediaType media_type,
800 bool expect_equal) {
801 if (desc1->contents().size() != desc2->contents().size()) {
802 EXPECT_FALSE(expect_equal);
803 return;
804 }
805
806 const cricket::ContentInfo* cinfo =
807 cricket::GetFirstMediaContent(desc1->contents(), media_type);
808 const cricket::TransportDescription* transport_desc1 =
809 desc1->GetTransportDescriptionByName(cinfo->name);
810 const cricket::TransportDescription* transport_desc2 =
811 desc2->GetTransportDescriptionByName(cinfo->name);
812 if (!transport_desc1 || !transport_desc2) {
813 EXPECT_FALSE(expect_equal);
814 return;
815 }
816 if (transport_desc1->ice_pwd != transport_desc2->ice_pwd ||
817 transport_desc1->ice_ufrag != transport_desc2->ice_ufrag) {
818 EXPECT_FALSE(expect_equal);
819 return;
820 }
821 EXPECT_TRUE(expect_equal);
822 }
823
796 void RemoveIceUfragPwdLines(const SessionDescriptionInterface* current_desc, 824 void RemoveIceUfragPwdLines(const SessionDescriptionInterface* current_desc,
797 std::string *sdp) { 825 std::string *sdp) {
798 const cricket::SessionDescription* desc = current_desc->description(); 826 const cricket::SessionDescription* desc = current_desc->description();
799 EXPECT_TRUE(current_desc->ToString(sdp)); 827 EXPECT_TRUE(current_desc->ToString(sdp));
800 828
801 const cricket::ContentInfos& contents = desc->contents(); 829 const cricket::ContentInfos& contents = desc->contents();
802 cricket::ContentInfos::const_iterator it = contents.begin(); 830 cricket::ContentInfos::const_iterator it = contents.begin();
803 // Replace ufrag and pwd lines with empty strings. 831 // Replace ufrag and pwd lines with empty strings.
804 for (; it != contents.end(); ++it) { 832 for (; it != contents.end(); ++it) {
805 const cricket::TransportDescription* transport_desc = 833 const cricket::TransportDescription* transport_desc =
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
839 std::string mod_pwd = "a=ice-pwd:" + modified_ice_pwd + "\r\n"; 867 std::string mod_pwd = "a=ice-pwd:" + modified_ice_pwd + "\r\n";
840 rtc::replace_substrs(ufrag_line.c_str(), ufrag_line.length(), 868 rtc::replace_substrs(ufrag_line.c_str(), ufrag_line.length(),
841 mod_ufrag.c_str(), mod_ufrag.length(), 869 mod_ufrag.c_str(), mod_ufrag.length(),
842 sdp); 870 sdp);
843 rtc::replace_substrs(pwd_line.c_str(), pwd_line.length(), 871 rtc::replace_substrs(pwd_line.c_str(), pwd_line.length(),
844 mod_pwd.c_str(), mod_pwd.length(), 872 mod_pwd.c_str(), mod_pwd.length(),
845 sdp); 873 sdp);
846 } 874 }
847 } 875 }
848 876
877 // Modifies ufrag/pwd for specified |media_type|, by directly modifying the
878 // description.
879 void ModifyIceUfragPwd(SessionDescriptionInterface* current_desc,
880 cricket::MediaType media_type,
881 const std::string& modified_ice_ufrag,
882 const std::string& modified_ice_pwd) {
883 cricket::SessionDescription* desc = current_desc->description();
884 const cricket::ContentInfo* cinfo =
885 cricket::GetFirstMediaContent(desc->contents(), media_type);
886 // Replace ufrag and pwd with |modified_ice_ufrag| and
887 // |modified_ice_pwd| strings.
888 TransportInfo* transport_info = desc->GetTransportInfoByName(cinfo->name);
889 cricket::TransportDescription* transport_desc =
890 &transport_info->description;
891 transport_desc->ice_ufrag = modified_ice_ufrag;
892 transport_desc->ice_pwd = modified_ice_pwd;
893 }
894
849 // Creates a remote offer and and applies it as a remote description, 895 // Creates a remote offer and and applies it as a remote description,
850 // creates a local answer and applies is as a local description. 896 // creates a local answer and applies is as a local description.
851 // Call SendAudioVideoStreamX() before this function 897 // Call SendAudioVideoStreamX() before this function
852 // to decide which local and remote streams to create. 898 // to decide which local and remote streams to create.
853 void CreateAndSetRemoteOfferAndLocalAnswer() { 899 void CreateAndSetRemoteOfferAndLocalAnswer() {
854 SessionDescriptionInterface* offer = CreateRemoteOffer(); 900 SessionDescriptionInterface* offer = CreateRemoteOffer();
855 SetRemoteDescriptionWithoutError(offer); 901 SetRemoteDescriptionWithoutError(offer);
856 SessionDescriptionInterface* answer = CreateAnswer(NULL); 902 SessionDescriptionInterface* answer = CreateAnswer(NULL);
857 SetLocalDescriptionWithoutError(answer); 903 SetLocalDescriptionWithoutError(answer);
858 } 904 }
(...skipping 2860 matching lines...) Expand 10 before | Expand all | Expand 10 after
3719 rtc::scoped_ptr<SessionDescriptionInterface> updated_answer2( 3765 rtc::scoped_ptr<SessionDescriptionInterface> updated_answer2(
3720 CreateAnswer(NULL)); 3766 CreateAnswer(NULL));
3721 3767
3722 CompareIceUfragAndPassword(updated_answer2->description(), 3768 CompareIceUfragAndPassword(updated_answer2->description(),
3723 session_->local_description()->description(), 3769 session_->local_description()->description(),
3724 true); 3770 true);
3725 3771
3726 SetLocalDescriptionWithoutError(updated_answer2.release()); 3772 SetLocalDescriptionWithoutError(updated_answer2.release());
3727 } 3773 }
3728 3774
3775 // This test verifies that if an offer does an ICE restart on some, but not all
3776 // media sections, the answer will change the ufrag/password in the correct
3777 // media sections.
3778 TEST_F(WebRtcSessionTest, TestCreateAnswerWithNewAndOldUfragAndPassword) {
3779 Init();
3780 cricket::MediaSessionOptions options;
3781 options.recv_video = true;
3782 options.recv_audio = true;
3783 options.bundle_enabled = false;
3784 rtc::scoped_ptr<JsepSessionDescription> offer(CreateRemoteOffer(options));
3785
3786 ModifyIceUfragPwd(offer.get(), cricket::MEDIA_TYPE_AUDIO, "aaaa",
3787 "aaaaaaaaaaaaaaaaaaaaaa");
3788 ModifyIceUfragPwd(offer.get(), cricket::MEDIA_TYPE_VIDEO, "bbbb",
3789 "bbbbbbbbbbbbbbbbbbbbbb");
3790 SetRemoteDescriptionWithoutError(offer.release());
3791
3792 SendAudioVideoStream1();
3793 rtc::scoped_ptr<SessionDescriptionInterface> answer(CreateAnswer(nullptr));
3794 SetLocalDescriptionWithoutError(answer.release());
3795
3796 // Receive an offer with new ufrag and password, but only for the video media
3797 // section.
3798 rtc::scoped_ptr<JsepSessionDescription> updated_offer(
3799 CreateRemoteOffer(options, session_->remote_description()));
3800 ModifyIceUfragPwd(updated_offer.get(), cricket::MEDIA_TYPE_VIDEO, "cccc",
3801 "cccccccccccccccccccccc");
3802 SetRemoteDescriptionWithoutError(updated_offer.release());
3803
3804 rtc::scoped_ptr<SessionDescriptionInterface> updated_answer(
3805 CreateAnswer(nullptr));
3806
3807 CompareIceUfragAndPassword(updated_answer->description(),
3808 session_->local_description()->description(),
3809 cricket::MEDIA_TYPE_AUDIO, true);
3810
3811 CompareIceUfragAndPassword(updated_answer->description(),
3812 session_->local_description()->description(),
3813 cricket::MEDIA_TYPE_VIDEO, false);
3814
3815 SetLocalDescriptionWithoutError(updated_answer.release());
3816 }
3817
3729 TEST_F(WebRtcSessionTest, TestSessionContentError) { 3818 TEST_F(WebRtcSessionTest, TestSessionContentError) {
3730 Init(); 3819 Init();
3731 SendAudioVideoStream1(); 3820 SendAudioVideoStream1();
3732 SessionDescriptionInterface* offer = CreateOffer(); 3821 SessionDescriptionInterface* offer = CreateOffer();
3733 const std::string session_id_orig = offer->session_id(); 3822 const std::string session_id_orig = offer->session_id();
3734 const std::string session_version_orig = offer->session_version(); 3823 const std::string session_version_orig = offer->session_version();
3735 SetLocalDescriptionWithoutError(offer); 3824 SetLocalDescriptionWithoutError(offer);
3736 3825
3737 video_channel_ = media_engine_->GetVideoChannel(0); 3826 video_channel_ = media_engine_->GetVideoChannel(0);
3738 video_channel_->set_fail_set_send_codecs(true); 3827 video_channel_->set_fail_set_send_codecs(true);
(...skipping 571 matching lines...) Expand 10 before | Expand all | Expand 10 after
4310 } 4399 }
4311 4400
4312 // TODO(bemasc): Add a TestIceStatesBundle with BUNDLE enabled. That test 4401 // TODO(bemasc): Add a TestIceStatesBundle with BUNDLE enabled. That test
4313 // currently fails because upon disconnection and reconnection OnIceComplete is 4402 // currently fails because upon disconnection and reconnection OnIceComplete is
4314 // called more than once without returning to IceGatheringGathering. 4403 // called more than once without returning to IceGatheringGathering.
4315 4404
4316 INSTANTIATE_TEST_CASE_P(WebRtcSessionTests, 4405 INSTANTIATE_TEST_CASE_P(WebRtcSessionTests,
4317 WebRtcSessionTest, 4406 WebRtcSessionTest,
4318 testing::Values(ALREADY_GENERATED, 4407 testing::Values(ALREADY_GENERATED,
4319 DTLS_IDENTITY_STORE)); 4408 DTLS_IDENTITY_STORE));
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698