OLD | NEW |
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 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
63 #define MAYBE_SKIP_TEST(feature) \ | 63 #define MAYBE_SKIP_TEST(feature) \ |
64 if (!(feature())) { \ | 64 if (!(feature())) { \ |
65 LOG(LS_INFO) << "Feature disabled... skipping"; \ | 65 LOG(LS_INFO) << "Feature disabled... skipping"; \ |
66 return; \ | 66 return; \ |
67 } | 67 } |
68 | 68 |
69 using cricket::BaseSession; | 69 using cricket::BaseSession; |
70 using cricket::DF_PLAY; | 70 using cricket::DF_PLAY; |
71 using cricket::DF_SEND; | 71 using cricket::DF_SEND; |
72 using cricket::FakeVoiceMediaChannel; | 72 using cricket::FakeVoiceMediaChannel; |
73 using cricket::NS_GINGLE_P2P; | |
74 using cricket::NS_JINGLE_ICE_UDP; | |
75 using cricket::TransportInfo; | 73 using cricket::TransportInfo; |
76 using rtc::SocketAddress; | 74 using rtc::SocketAddress; |
77 using rtc::scoped_ptr; | 75 using rtc::scoped_ptr; |
78 using rtc::Thread; | 76 using rtc::Thread; |
79 using webrtc::CreateSessionDescription; | 77 using webrtc::CreateSessionDescription; |
80 using webrtc::CreateSessionDescriptionObserver; | 78 using webrtc::CreateSessionDescriptionObserver; |
81 using webrtc::CreateSessionDescriptionRequest; | 79 using webrtc::CreateSessionDescriptionRequest; |
82 using webrtc::DTLSIdentityRequestObserver; | 80 using webrtc::DTLSIdentityRequestObserver; |
83 using webrtc::DTLSIdentityServiceInterface; | 81 using webrtc::DTLSIdentityServiceInterface; |
84 using webrtc::FakeConstraints; | 82 using webrtc::FakeConstraints; |
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
330 vss_(new rtc::VirtualSocketServer(pss_.get())), | 328 vss_(new rtc::VirtualSocketServer(pss_.get())), |
331 fss_(new rtc::FirewallSocketServer(vss_.get())), | 329 fss_(new rtc::FirewallSocketServer(vss_.get())), |
332 ss_scope_(fss_.get()), | 330 ss_scope_(fss_.get()), |
333 stun_socket_addr_(rtc::SocketAddress(kStunAddrHost, | 331 stun_socket_addr_(rtc::SocketAddress(kStunAddrHost, |
334 cricket::STUN_SERVER_PORT)), | 332 cricket::STUN_SERVER_PORT)), |
335 stun_server_(cricket::TestStunServer::Create(Thread::Current(), | 333 stun_server_(cricket::TestStunServer::Create(Thread::Current(), |
336 stun_socket_addr_)), | 334 stun_socket_addr_)), |
337 turn_server_(Thread::Current(), kTurnUdpIntAddr, kTurnUdpExtAddr), | 335 turn_server_(Thread::Current(), kTurnUdpIntAddr, kTurnUdpExtAddr), |
338 mediastream_signaling_(channel_manager_.get()), | 336 mediastream_signaling_(channel_manager_.get()), |
339 metrics_observer_(new rtc::RefCountedObject<FakeMetricsObserver>()) { | 337 metrics_observer_(new rtc::RefCountedObject<FakeMetricsObserver>()) { |
340 tdesc_factory_->set_protocol(cricket::ICEPROTO_HYBRID); | |
341 | |
342 cricket::ServerAddresses stun_servers; | 338 cricket::ServerAddresses stun_servers; |
343 stun_servers.insert(stun_socket_addr_); | 339 stun_servers.insert(stun_socket_addr_); |
344 allocator_.reset(new cricket::BasicPortAllocator( | 340 allocator_.reset(new cricket::BasicPortAllocator( |
345 &network_manager_, | 341 &network_manager_, |
346 stun_servers, | 342 stun_servers, |
347 SocketAddress(), SocketAddress(), SocketAddress())); | 343 SocketAddress(), SocketAddress(), SocketAddress())); |
348 allocator_->set_flags(cricket::PORTALLOCATOR_DISABLE_TCP | | 344 allocator_->set_flags(cricket::PORTALLOCATOR_DISABLE_TCP | |
349 cricket::PORTALLOCATOR_DISABLE_RELAY | | 345 cricket::PORTALLOCATOR_DISABLE_RELAY | |
350 cricket::PORTALLOCATOR_ENABLE_SHARED_UFRAG); | 346 cricket::PORTALLOCATOR_ENABLE_SHARED_UFRAG); |
351 EXPECT_TRUE(channel_manager_->Init()); | 347 EXPECT_TRUE(channel_manager_->Init()); |
(...skipping 781 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1133 EXPECT_EQ_WAIT(PeerConnectionInterface::kIceConnectionDisconnected, | 1129 EXPECT_EQ_WAIT(PeerConnectionInterface::kIceConnectionDisconnected, |
1134 observer_.ice_connection_state_, | 1130 observer_.ice_connection_state_, |
1135 kIceCandidatesTimeout + port_timeout); | 1131 kIceCandidatesTimeout + port_timeout); |
1136 } | 1132 } |
1137 | 1133 |
1138 void TestLoopbackCall() { | 1134 void TestLoopbackCall() { |
1139 LoopbackNetworkConfiguration config; | 1135 LoopbackNetworkConfiguration config; |
1140 TestLoopbackCall(config); | 1136 TestLoopbackCall(config); |
1141 } | 1137 } |
1142 | 1138 |
1143 void VerifyTransportType(const std::string& content_name, | |
1144 cricket::TransportProtocol protocol) { | |
1145 const cricket::Transport* transport = session_->GetTransport(content_name); | |
1146 ASSERT_TRUE(transport != NULL); | |
1147 EXPECT_EQ(protocol, transport->protocol()); | |
1148 } | |
1149 | |
1150 // Adds CN codecs to FakeMediaEngine and MediaDescriptionFactory. | 1139 // Adds CN codecs to FakeMediaEngine and MediaDescriptionFactory. |
1151 void AddCNCodecs() { | 1140 void AddCNCodecs() { |
1152 const cricket::AudioCodec kCNCodec1(102, "CN", 8000, 0, 1, 0); | 1141 const cricket::AudioCodec kCNCodec1(102, "CN", 8000, 0, 1, 0); |
1153 const cricket::AudioCodec kCNCodec2(103, "CN", 16000, 0, 1, 0); | 1142 const cricket::AudioCodec kCNCodec2(103, "CN", 16000, 0, 1, 0); |
1154 | 1143 |
1155 // Add kCNCodec for dtmf test. | 1144 // Add kCNCodec for dtmf test. |
1156 std::vector<cricket::AudioCodec> codecs = media_engine_->audio_codecs();; | 1145 std::vector<cricket::AudioCodec> codecs = media_engine_->audio_codecs();; |
1157 codecs.push_back(kCNCodec1); | 1146 codecs.push_back(kCNCodec1); |
1158 codecs.push_back(kCNCodec2); | 1147 codecs.push_back(kCNCodec2); |
1159 media_engine_->SetAudioCodecs(codecs); | 1148 media_engine_->SetAudioCodecs(codecs); |
(...skipping 1368 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2528 RemoveIceUfragPwdLines(offer.get(), &sdp); | 2517 RemoveIceUfragPwdLines(offer.get(), &sdp); |
2529 SessionDescriptionInterface* modified_offer = | 2518 SessionDescriptionInterface* modified_offer = |
2530 CreateSessionDescription(JsepSessionDescription::kOffer, sdp, NULL); | 2519 CreateSessionDescription(JsepSessionDescription::kOffer, sdp, NULL); |
2531 SetRemoteDescriptionOfferExpectError(kSdpWithoutIceUfragPwd, modified_offer); | 2520 SetRemoteDescriptionOfferExpectError(kSdpWithoutIceUfragPwd, modified_offer); |
2532 } | 2521 } |
2533 | 2522 |
2534 // This test verifies that setLocalDescription fails if local offer has | 2523 // This test verifies that setLocalDescription fails if local offer has |
2535 // too short ice ufrag and pwd strings. | 2524 // too short ice ufrag and pwd strings. |
2536 TEST_F(WebRtcSessionTest, TestSetLocalDescriptionInvalidIceCredentials) { | 2525 TEST_F(WebRtcSessionTest, TestSetLocalDescriptionInvalidIceCredentials) { |
2537 Init(); | 2526 Init(); |
2538 tdesc_factory_->set_protocol(cricket::ICEPROTO_RFC5245); | |
2539 mediastream_signaling_.SendAudioVideoStream1(); | 2527 mediastream_signaling_.SendAudioVideoStream1(); |
2540 rtc::scoped_ptr<SessionDescriptionInterface> offer(CreateOffer()); | 2528 rtc::scoped_ptr<SessionDescriptionInterface> offer(CreateOffer()); |
2541 | 2529 |
2542 std::string sdp; | 2530 std::string sdp; |
2543 // Modifying ice ufrag and pwd in local offer with strings smaller than the | 2531 // Modifying ice ufrag and pwd in local offer with strings smaller than the |
2544 // recommended values of 4 and 22 bytes respectively. | 2532 // recommended values of 4 and 22 bytes respectively. |
2545 ModifyIceUfragPwdLines(offer.get(), "ice", "icepwd", &sdp); | 2533 ModifyIceUfragPwdLines(offer.get(), "ice", "icepwd", &sdp); |
2546 SessionDescriptionInterface* modified_offer = | 2534 SessionDescriptionInterface* modified_offer = |
2547 CreateSessionDescription(JsepSessionDescription::kOffer, sdp, NULL); | 2535 CreateSessionDescription(JsepSessionDescription::kOffer, sdp, NULL); |
2548 std::string error; | 2536 std::string error; |
2549 EXPECT_FALSE(session_->SetLocalDescription(modified_offer, &error)); | 2537 EXPECT_FALSE(session_->SetLocalDescription(modified_offer, &error)); |
2550 | 2538 |
2551 // Test with string greater than 256. | 2539 // Test with string greater than 256. |
2552 sdp.clear(); | 2540 sdp.clear(); |
2553 ModifyIceUfragPwdLines(offer.get(), kTooLongIceUfragPwd, kTooLongIceUfragPwd, | 2541 ModifyIceUfragPwdLines(offer.get(), kTooLongIceUfragPwd, kTooLongIceUfragPwd, |
2554 &sdp); | 2542 &sdp); |
2555 modified_offer = CreateSessionDescription(JsepSessionDescription::kOffer, sdp, | 2543 modified_offer = CreateSessionDescription(JsepSessionDescription::kOffer, sdp, |
2556 NULL); | 2544 NULL); |
2557 EXPECT_FALSE(session_->SetLocalDescription(modified_offer, &error)); | 2545 EXPECT_FALSE(session_->SetLocalDescription(modified_offer, &error)); |
2558 } | 2546 } |
2559 | 2547 |
2560 // This test verifies that setRemoteDescription fails if remote offer has | 2548 // This test verifies that setRemoteDescription fails if remote offer has |
2561 // too short ice ufrag and pwd strings. | 2549 // too short ice ufrag and pwd strings. |
2562 TEST_F(WebRtcSessionTest, TestSetRemoteDescriptionInvalidIceCredentials) { | 2550 TEST_F(WebRtcSessionTest, TestSetRemoteDescriptionInvalidIceCredentials) { |
2563 Init(); | 2551 Init(); |
2564 tdesc_factory_->set_protocol(cricket::ICEPROTO_RFC5245); | |
2565 rtc::scoped_ptr<SessionDescriptionInterface> offer(CreateRemoteOffer()); | 2552 rtc::scoped_ptr<SessionDescriptionInterface> offer(CreateRemoteOffer()); |
2566 std::string sdp; | 2553 std::string sdp; |
2567 // Modifying ice ufrag and pwd in remote offer with strings smaller than the | 2554 // Modifying ice ufrag and pwd in remote offer with strings smaller than the |
2568 // recommended values of 4 and 22 bytes respectively. | 2555 // recommended values of 4 and 22 bytes respectively. |
2569 ModifyIceUfragPwdLines(offer.get(), "ice", "icepwd", &sdp); | 2556 ModifyIceUfragPwdLines(offer.get(), "ice", "icepwd", &sdp); |
2570 SessionDescriptionInterface* modified_offer = | 2557 SessionDescriptionInterface* modified_offer = |
2571 CreateSessionDescription(JsepSessionDescription::kOffer, sdp, NULL); | 2558 CreateSessionDescription(JsepSessionDescription::kOffer, sdp, NULL); |
2572 std::string error; | 2559 std::string error; |
2573 EXPECT_FALSE(session_->SetRemoteDescription(modified_offer, &error)); | 2560 EXPECT_FALSE(session_->SetRemoteDescription(modified_offer, &error)); |
2574 | 2561 |
(...skipping 496 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3071 EXPECT_FALSE(session_->initiator()); | 3058 EXPECT_FALSE(session_->initiator()); |
3072 SessionDescriptionInterface* offer = CreateRemoteOffer(); | 3059 SessionDescriptionInterface* offer = CreateRemoteOffer(); |
3073 SetRemoteDescriptionWithoutError(offer); | 3060 SetRemoteDescriptionWithoutError(offer); |
3074 SessionDescriptionInterface* answer = CreateAnswer(NULL); | 3061 SessionDescriptionInterface* answer = CreateAnswer(NULL); |
3075 | 3062 |
3076 EXPECT_FALSE(session_->initiator()); | 3063 EXPECT_FALSE(session_->initiator()); |
3077 SetLocalDescriptionWithoutError(answer); | 3064 SetLocalDescriptionWithoutError(answer); |
3078 EXPECT_FALSE(session_->initiator()); | 3065 EXPECT_FALSE(session_->initiator()); |
3079 } | 3066 } |
3080 | 3067 |
3081 // This test verifies the ice protocol type at initiator of the call | |
3082 // if |a=ice-options:google-ice| is present in answer. | |
3083 TEST_F(WebRtcSessionTest, TestInitiatorGIceInAnswer) { | |
3084 Init(); | |
3085 mediastream_signaling_.SendAudioVideoStream1(); | |
3086 SessionDescriptionInterface* offer = CreateOffer(); | |
3087 rtc::scoped_ptr<SessionDescriptionInterface> answer( | |
3088 CreateRemoteAnswer(offer)); | |
3089 SetLocalDescriptionWithoutError(offer); | |
3090 std::string sdp; | |
3091 EXPECT_TRUE(answer->ToString(&sdp)); | |
3092 // Adding ice-options to the session level. | |
3093 InjectAfter("t=0 0\r\n", | |
3094 "a=ice-options:google-ice\r\n", | |
3095 &sdp); | |
3096 SessionDescriptionInterface* answer_with_gice = | |
3097 CreateSessionDescription(JsepSessionDescription::kAnswer, sdp, NULL); | |
3098 // Default offer is ICEPROTO_RFC5245, so we expect responder with | |
3099 // only gice to fail. | |
3100 SetRemoteDescriptionAnswerExpectError(kPushDownTDFailed, answer_with_gice); | |
3101 } | |
3102 | |
3103 // This test verifies the ice protocol type at initiator of the call | |
3104 // if ICE RFC5245 is supported in answer. | |
3105 TEST_F(WebRtcSessionTest, TestInitiatorIceInAnswer) { | |
3106 Init(); | |
3107 mediastream_signaling_.SendAudioVideoStream1(); | |
3108 SessionDescriptionInterface* offer = CreateOffer(); | |
3109 SessionDescriptionInterface* answer = CreateRemoteAnswer(offer); | |
3110 SetLocalDescriptionWithoutError(offer); | |
3111 | |
3112 SetRemoteDescriptionWithoutError(answer); | |
3113 VerifyTransportType("audio", cricket::ICEPROTO_RFC5245); | |
3114 VerifyTransportType("video", cricket::ICEPROTO_RFC5245); | |
3115 } | |
3116 | |
3117 // This test verifies the ice protocol type at receiver side of the call if | |
3118 // receiver decides to use ice RFC 5245. | |
3119 TEST_F(WebRtcSessionTest, TestReceiverIceInOffer) { | |
3120 Init(); | |
3121 mediastream_signaling_.SendAudioVideoStream1(); | |
3122 SessionDescriptionInterface* offer = CreateOffer(); | |
3123 SetRemoteDescriptionWithoutError(offer); | |
3124 SessionDescriptionInterface* answer = CreateAnswer(NULL); | |
3125 SetLocalDescriptionWithoutError(answer); | |
3126 VerifyTransportType("audio", cricket::ICEPROTO_RFC5245); | |
3127 VerifyTransportType("video", cricket::ICEPROTO_RFC5245); | |
3128 } | |
3129 | |
3130 // Verifing local offer and remote answer have matching m-lines as per RFC 3264. | 3068 // Verifing local offer and remote answer have matching m-lines as per RFC 3264. |
3131 TEST_F(WebRtcSessionTest, TestIncorrectMLinesInRemoteAnswer) { | 3069 TEST_F(WebRtcSessionTest, TestIncorrectMLinesInRemoteAnswer) { |
3132 Init(); | 3070 Init(); |
3133 mediastream_signaling_.SendAudioVideoStream1(); | 3071 mediastream_signaling_.SendAudioVideoStream1(); |
3134 SessionDescriptionInterface* offer = CreateOffer(); | 3072 SessionDescriptionInterface* offer = CreateOffer(); |
3135 SetLocalDescriptionWithoutError(offer); | 3073 SetLocalDescriptionWithoutError(offer); |
3136 rtc::scoped_ptr<SessionDescriptionInterface> answer( | 3074 rtc::scoped_ptr<SessionDescriptionInterface> answer( |
3137 CreateRemoteAnswer(session_->local_description())); | 3075 CreateRemoteAnswer(session_->local_description())); |
3138 | 3076 |
3139 cricket::SessionDescription* answer_copy = answer->description()->Copy(); | 3077 cricket::SessionDescription* answer_copy = answer->description()->Copy(); |
(...skipping 744 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3884 // terminated. The offer creation may or may not have succeeded, but we | 3822 // terminated. The offer creation may or may not have succeeded, but we |
3885 // must have received a notification which, so the only invalid state | 3823 // must have received a notification which, so the only invalid state |
3886 // is kInit. | 3824 // is kInit. |
3887 EXPECT_NE(WebRtcSessionCreateSDPObserverForTest::kInit, o->state()); | 3825 EXPECT_NE(WebRtcSessionCreateSDPObserverForTest::kInit, o->state()); |
3888 } | 3826 } |
3889 } | 3827 } |
3890 | 3828 |
3891 // TODO(bemasc): Add a TestIceStatesBundle with BUNDLE enabled. That test | 3829 // TODO(bemasc): Add a TestIceStatesBundle with BUNDLE enabled. That test |
3892 // currently fails because upon disconnection and reconnection OnIceComplete is | 3830 // currently fails because upon disconnection and reconnection OnIceComplete is |
3893 // called more than once without returning to IceGatheringGathering. | 3831 // called more than once without returning to IceGatheringGathering. |
OLD | NEW |