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 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
154 public: | 154 public: |
155 MockIceObserver() | 155 MockIceObserver() |
156 : oncandidatesready_(false), | 156 : oncandidatesready_(false), |
157 ice_connection_state_(PeerConnectionInterface::kIceConnectionNew), | 157 ice_connection_state_(PeerConnectionInterface::kIceConnectionNew), |
158 ice_gathering_state_(PeerConnectionInterface::kIceGatheringNew) { | 158 ice_gathering_state_(PeerConnectionInterface::kIceGatheringNew) { |
159 } | 159 } |
160 | 160 |
161 void OnIceConnectionChange( | 161 void OnIceConnectionChange( |
162 PeerConnectionInterface::IceConnectionState new_state) override { | 162 PeerConnectionInterface::IceConnectionState new_state) override { |
163 ice_connection_state_ = new_state; | 163 ice_connection_state_ = new_state; |
| 164 ice_connection_state_history_.push_back(new_state); |
164 } | 165 } |
165 void OnIceGatheringChange( | 166 void OnIceGatheringChange( |
166 PeerConnectionInterface::IceGatheringState new_state) override { | 167 PeerConnectionInterface::IceGatheringState new_state) override { |
167 // We can never transition back to "new". | 168 // We can never transition back to "new". |
168 EXPECT_NE(PeerConnectionInterface::kIceGatheringNew, new_state); | 169 EXPECT_NE(PeerConnectionInterface::kIceGatheringNew, new_state); |
169 ice_gathering_state_ = new_state; | 170 ice_gathering_state_ = new_state; |
170 oncandidatesready_ = | 171 oncandidatesready_ = |
171 new_state == PeerConnectionInterface::kIceGatheringComplete; | 172 new_state == PeerConnectionInterface::kIceGatheringComplete; |
172 } | 173 } |
173 | 174 |
(...skipping 19 matching lines...) Expand all Loading... |
193 void OnIceCandidatesRemoved( | 194 void OnIceCandidatesRemoved( |
194 const std::vector<cricket::Candidate>& candidates) override { | 195 const std::vector<cricket::Candidate>& candidates) override { |
195 num_candidates_removed_ += candidates.size(); | 196 num_candidates_removed_ += candidates.size(); |
196 } | 197 } |
197 | 198 |
198 bool oncandidatesready_; | 199 bool oncandidatesready_; |
199 std::vector<cricket::Candidate> mline_0_candidates_; | 200 std::vector<cricket::Candidate> mline_0_candidates_; |
200 std::vector<cricket::Candidate> mline_1_candidates_; | 201 std::vector<cricket::Candidate> mline_1_candidates_; |
201 PeerConnectionInterface::IceConnectionState ice_connection_state_; | 202 PeerConnectionInterface::IceConnectionState ice_connection_state_; |
202 PeerConnectionInterface::IceGatheringState ice_gathering_state_; | 203 PeerConnectionInterface::IceGatheringState ice_gathering_state_; |
| 204 std::vector<PeerConnectionInterface::IceConnectionState> |
| 205 ice_connection_state_history_; |
203 size_t num_candidates_removed_ = 0; | 206 size_t num_candidates_removed_ = 0; |
204 }; | 207 }; |
205 | 208 |
206 class WebRtcSessionForTest : public webrtc::WebRtcSession { | 209 class WebRtcSessionForTest : public webrtc::WebRtcSession { |
207 public: | 210 public: |
208 WebRtcSessionForTest(webrtc::MediaControllerInterface* media_controller, | 211 WebRtcSessionForTest(webrtc::MediaControllerInterface* media_controller, |
209 rtc::Thread* signaling_thread, | 212 rtc::Thread* signaling_thread, |
210 rtc::Thread* worker_thread, | 213 rtc::Thread* worker_thread, |
211 cricket::PortAllocator* port_allocator, | 214 cricket::PortAllocator* port_allocator, |
212 webrtc::IceObserver* ice_observer) | 215 webrtc::IceObserver* ice_observer) |
(...skipping 3089 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3302 PeerConnectionInterface::RTCOfferAnswerOptions options; | 3305 PeerConnectionInterface::RTCOfferAnswerOptions options; |
3303 options.use_rtp_mux = true; | 3306 options.use_rtp_mux = true; |
3304 | 3307 |
3305 SessionDescriptionInterface* offer = CreateOffer(options); | 3308 SessionDescriptionInterface* offer = CreateOffer(options); |
3306 SetRemoteDescriptionWithoutError(offer); | 3309 SetRemoteDescriptionWithoutError(offer); |
3307 | 3310 |
3308 EXPECT_EQ(session_->voice_rtp_transport_channel(), | 3311 EXPECT_EQ(session_->voice_rtp_transport_channel(), |
3309 session_->video_rtp_transport_channel()); | 3312 session_->video_rtp_transport_channel()); |
3310 } | 3313 } |
3311 | 3314 |
| 3315 // Adding a new channel to a BUNDLE which is already connected should directly |
| 3316 // assign the bundle transport to the channel, without first setting a |
| 3317 // disconnected non-bundle transport and then replacing it. The application |
| 3318 // should not receive any changes in the ICE state. |
| 3319 TEST_F(WebRtcSessionTest, TestAddChannelToConnectedBundle) { |
| 3320 LoopbackNetworkConfiguration config; |
| 3321 LoopbackNetworkManager loopback_network_manager(this, config); |
| 3322 // Both BUNDLE and RTCP-mux need to be enabled for the ICE state to remain |
| 3323 // connected. Disabling either of these two means that we need to wait for the |
| 3324 // answer to find out if more transports are needed. |
| 3325 configuration_.bundle_policy = |
| 3326 PeerConnectionInterface::kBundlePolicyMaxBundle; |
| 3327 configuration_.rtcp_mux_policy = |
| 3328 PeerConnectionInterface::kRtcpMuxPolicyRequire; |
| 3329 options_.disable_encryption = true; |
| 3330 Init(); |
| 3331 |
| 3332 // Negotiate an audio channel with MAX_BUNDLE enabled. |
| 3333 SendAudioOnlyStream2(); |
| 3334 SessionDescriptionInterface* offer = CreateOffer(); |
| 3335 SetLocalDescriptionWithoutError(offer); |
| 3336 EXPECT_EQ_WAIT(PeerConnectionInterface::kIceGatheringComplete, |
| 3337 observer_.ice_gathering_state_, kIceCandidatesTimeout); |
| 3338 std::string sdp; |
| 3339 offer->ToString(&sdp); |
| 3340 SessionDescriptionInterface* answer = webrtc::CreateSessionDescription( |
| 3341 JsepSessionDescription::kAnswer, sdp, nullptr); |
| 3342 ASSERT_TRUE(answer != NULL); |
| 3343 SetRemoteDescriptionWithoutError(answer); |
| 3344 |
| 3345 // Wait for the ICE state to stabilize. |
| 3346 EXPECT_EQ_WAIT(PeerConnectionInterface::kIceConnectionCompleted, |
| 3347 observer_.ice_connection_state_, kIceCandidatesTimeout); |
| 3348 observer_.ice_connection_state_history_.clear(); |
| 3349 |
| 3350 // Now add a video channel which should be using the same bundle transport. |
| 3351 SendAudioVideoStream2(); |
| 3352 offer = CreateOffer(); |
| 3353 offer->ToString(&sdp); |
| 3354 SetLocalDescriptionWithoutError(offer); |
| 3355 answer = webrtc::CreateSessionDescription(JsepSessionDescription::kAnswer, |
| 3356 sdp, nullptr); |
| 3357 ASSERT_TRUE(answer != NULL); |
| 3358 SetRemoteDescriptionWithoutError(answer); |
| 3359 |
| 3360 // Wait for ICE state to stabilize |
| 3361 rtc::Thread::Current()->ProcessMessages(0); |
| 3362 EXPECT_EQ_WAIT(PeerConnectionInterface::kIceConnectionCompleted, |
| 3363 observer_.ice_connection_state_, kIceCandidatesTimeout); |
| 3364 |
| 3365 // No ICE state changes are expected to happen. |
| 3366 EXPECT_EQ(0, observer_.ice_connection_state_history_.size()); |
| 3367 } |
| 3368 |
3312 TEST_F(WebRtcSessionTest, TestRequireRtcpMux) { | 3369 TEST_F(WebRtcSessionTest, TestRequireRtcpMux) { |
3313 InitWithRtcpMuxPolicy(PeerConnectionInterface::kRtcpMuxPolicyRequire); | 3370 InitWithRtcpMuxPolicy(PeerConnectionInterface::kRtcpMuxPolicyRequire); |
3314 SendAudioVideoStream1(); | 3371 SendAudioVideoStream1(); |
3315 | 3372 |
3316 PeerConnectionInterface::RTCOfferAnswerOptions options; | 3373 PeerConnectionInterface::RTCOfferAnswerOptions options; |
3317 SessionDescriptionInterface* offer = CreateOffer(options); | 3374 SessionDescriptionInterface* offer = CreateOffer(options); |
3318 SetLocalDescriptionWithoutError(offer); | 3375 SetLocalDescriptionWithoutError(offer); |
3319 | 3376 |
3320 EXPECT_TRUE(session_->voice_rtcp_transport_channel() == NULL); | 3377 EXPECT_TRUE(session_->voice_rtcp_transport_channel() == NULL); |
3321 EXPECT_TRUE(session_->video_rtcp_transport_channel() == NULL); | 3378 EXPECT_TRUE(session_->video_rtcp_transport_channel() == NULL); |
(...skipping 1084 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4406 } | 4463 } |
4407 | 4464 |
4408 // TODO(bemasc): Add a TestIceStatesBundle with BUNDLE enabled. That test | 4465 // TODO(bemasc): Add a TestIceStatesBundle with BUNDLE enabled. That test |
4409 // currently fails because upon disconnection and reconnection OnIceComplete is | 4466 // currently fails because upon disconnection and reconnection OnIceComplete is |
4410 // called more than once without returning to IceGatheringGathering. | 4467 // called more than once without returning to IceGatheringGathering. |
4411 | 4468 |
4412 INSTANTIATE_TEST_CASE_P(WebRtcSessionTests, | 4469 INSTANTIATE_TEST_CASE_P(WebRtcSessionTests, |
4413 WebRtcSessionTest, | 4470 WebRtcSessionTest, |
4414 testing::Values(ALREADY_GENERATED, | 4471 testing::Values(ALREADY_GENERATED, |
4415 DTLS_IDENTITY_STORE)); | 4472 DTLS_IDENTITY_STORE)); |
OLD | NEW |