| 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 3087 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  3300   PeerConnectionInterface::RTCOfferAnswerOptions options; |  3303   PeerConnectionInterface::RTCOfferAnswerOptions options; | 
|  3301   options.use_rtp_mux = true; |  3304   options.use_rtp_mux = true; | 
|  3302  |  3305  | 
|  3303   SessionDescriptionInterface* offer = CreateOffer(options); |  3306   SessionDescriptionInterface* offer = CreateOffer(options); | 
|  3304   SetRemoteDescriptionWithoutError(offer); |  3307   SetRemoteDescriptionWithoutError(offer); | 
|  3305  |  3308  | 
|  3306   EXPECT_EQ(session_->voice_rtp_transport_channel(), |  3309   EXPECT_EQ(session_->voice_rtp_transport_channel(), | 
|  3307             session_->video_rtp_transport_channel()); |  3310             session_->video_rtp_transport_channel()); | 
|  3308 } |  3311 } | 
|  3309  |  3312  | 
 |  3313 // Adding a new channel to a BUNDLE which is already connected should directly | 
 |  3314 // assign the bundle transport to the channel, without first setting a | 
 |  3315 // disconnected non-bundle transport and then replacing it. The application | 
 |  3316 // should not receive any changes in the ICE state. | 
 |  3317 TEST_F(WebRtcSessionTest, TestAddChannelToConnectedBundle) { | 
 |  3318   LoopbackNetworkConfiguration config; | 
 |  3319   LoopbackNetworkManager loopback_network_manager(this, config); | 
 |  3320   // Both BUNDLE and RTCP-mux need to be enabled for the ICE state to remain | 
 |  3321   // connected. Disabling either of these two means that we need to wait for the | 
 |  3322   // answer to find out if more transports are needed. | 
 |  3323   configuration_.bundle_policy = | 
 |  3324       PeerConnectionInterface::kBundlePolicyMaxBundle; | 
 |  3325   configuration_.rtcp_mux_policy = | 
 |  3326       PeerConnectionInterface::kRtcpMuxPolicyRequire; | 
 |  3327   options_.disable_encryption = true; | 
 |  3328   Init(); | 
 |  3329  | 
 |  3330   // Negotiate an audio channel with MAX_BUNDLE enabled. | 
 |  3331   SendAudioOnlyStream2(); | 
 |  3332   SessionDescriptionInterface* offer = CreateOffer(); | 
 |  3333   SetLocalDescriptionWithoutError(offer); | 
 |  3334   EXPECT_EQ_WAIT(PeerConnectionInterface::kIceGatheringComplete, | 
 |  3335                  observer_.ice_gathering_state_, kIceCandidatesTimeout); | 
 |  3336   std::string sdp; | 
 |  3337   offer->ToString(&sdp); | 
 |  3338   SessionDescriptionInterface* answer = webrtc::CreateSessionDescription( | 
 |  3339       JsepSessionDescription::kAnswer, sdp, nullptr); | 
 |  3340   ASSERT_TRUE(answer != NULL); | 
 |  3341   SetRemoteDescriptionWithoutError(answer); | 
 |  3342  | 
 |  3343   // Wait for the ICE state to stabilize. | 
 |  3344   EXPECT_EQ_WAIT(PeerConnectionInterface::kIceConnectionCompleted, | 
 |  3345                  observer_.ice_connection_state_, kIceCandidatesTimeout); | 
 |  3346   observer_.ice_connection_state_history_.clear(); | 
 |  3347  | 
 |  3348   // Now add a video channel which should be using the same bundle transport. | 
 |  3349   SendAudioVideoStream2(); | 
 |  3350   offer = CreateOffer(); | 
 |  3351   offer->ToString(&sdp); | 
 |  3352   SetLocalDescriptionWithoutError(offer); | 
 |  3353   answer = webrtc::CreateSessionDescription(JsepSessionDescription::kAnswer, | 
 |  3354                                             sdp, nullptr); | 
 |  3355   ASSERT_TRUE(answer != NULL); | 
 |  3356   SetRemoteDescriptionWithoutError(answer); | 
 |  3357  | 
 |  3358   // Wait for ICE state to stabilize | 
 |  3359   rtc::Thread::Current()->ProcessMessages(0); | 
 |  3360   EXPECT_EQ_WAIT(PeerConnectionInterface::kIceConnectionCompleted, | 
 |  3361                  observer_.ice_connection_state_, kIceCandidatesTimeout); | 
 |  3362  | 
 |  3363   // No ICE state changes are expected to happen. | 
 |  3364   EXPECT_EQ(0, observer_.ice_connection_state_history_.size()); | 
 |  3365 } | 
 |  3366  | 
|  3310 TEST_F(WebRtcSessionTest, TestRequireRtcpMux) { |  3367 TEST_F(WebRtcSessionTest, TestRequireRtcpMux) { | 
|  3311   InitWithRtcpMuxPolicy(PeerConnectionInterface::kRtcpMuxPolicyRequire); |  3368   InitWithRtcpMuxPolicy(PeerConnectionInterface::kRtcpMuxPolicyRequire); | 
|  3312   SendAudioVideoStream1(); |  3369   SendAudioVideoStream1(); | 
|  3313  |  3370  | 
|  3314   PeerConnectionInterface::RTCOfferAnswerOptions options; |  3371   PeerConnectionInterface::RTCOfferAnswerOptions options; | 
|  3315   SessionDescriptionInterface* offer = CreateOffer(options); |  3372   SessionDescriptionInterface* offer = CreateOffer(options); | 
|  3316   SetLocalDescriptionWithoutError(offer); |  3373   SetLocalDescriptionWithoutError(offer); | 
|  3317  |  3374  | 
|  3318   EXPECT_TRUE(session_->voice_rtcp_transport_channel() == NULL); |  3375   EXPECT_TRUE(session_->voice_rtcp_transport_channel() == NULL); | 
|  3319   EXPECT_TRUE(session_->video_rtcp_transport_channel() == NULL); |  3376   EXPECT_TRUE(session_->video_rtcp_transport_channel() == NULL); | 
| (...skipping 1084 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  4404 } |  4461 } | 
|  4405  |  4462  | 
|  4406 // TODO(bemasc): Add a TestIceStatesBundle with BUNDLE enabled.  That test |  4463 // TODO(bemasc): Add a TestIceStatesBundle with BUNDLE enabled.  That test | 
|  4407 // currently fails because upon disconnection and reconnection OnIceComplete is |  4464 // currently fails because upon disconnection and reconnection OnIceComplete is | 
|  4408 // called more than once without returning to IceGatheringGathering. |  4465 // called more than once without returning to IceGatheringGathering. | 
|  4409  |  4466  | 
|  4410 INSTANTIATE_TEST_CASE_P(WebRtcSessionTests, |  4467 INSTANTIATE_TEST_CASE_P(WebRtcSessionTests, | 
|  4411                         WebRtcSessionTest, |  4468                         WebRtcSessionTest, | 
|  4412                         testing::Values(ALREADY_GENERATED, |  4469                         testing::Values(ALREADY_GENERATED, | 
|  4413                                         DTLS_IDENTITY_STORE)); |  4470                                         DTLS_IDENTITY_STORE)); | 
| OLD | NEW |