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

Side by Side Diff: webrtc/api/webrtcsession_unittest.cc

Issue 1972493002: Do not create a temporary transport channel when using max-bundle (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Rebase Created 4 years, 7 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
« no previous file with comments | « webrtc/api/webrtcsession.cc ('k') | webrtc/pc/channel.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 virtual ~MockIceObserver() = default; 161 virtual ~MockIceObserver() = default;
162 162
163 void OnIceConnectionChange( 163 void OnIceConnectionChange(
164 PeerConnectionInterface::IceConnectionState new_state) override { 164 PeerConnectionInterface::IceConnectionState new_state) override {
165 ice_connection_state_ = new_state; 165 ice_connection_state_ = new_state;
166 ice_connection_state_history_.push_back(new_state);
166 } 167 }
167 void OnIceGatheringChange( 168 void OnIceGatheringChange(
168 PeerConnectionInterface::IceGatheringState new_state) override { 169 PeerConnectionInterface::IceGatheringState new_state) override {
169 // We can never transition back to "new". 170 // We can never transition back to "new".
170 EXPECT_NE(PeerConnectionInterface::kIceGatheringNew, new_state); 171 EXPECT_NE(PeerConnectionInterface::kIceGatheringNew, new_state);
171 ice_gathering_state_ = new_state; 172 ice_gathering_state_ = new_state;
172 oncandidatesready_ = 173 oncandidatesready_ =
173 new_state == PeerConnectionInterface::kIceGatheringComplete; 174 new_state == PeerConnectionInterface::kIceGatheringComplete;
174 } 175 }
175 176
(...skipping 19 matching lines...) Expand all
195 void OnIceCandidatesRemoved( 196 void OnIceCandidatesRemoved(
196 const std::vector<cricket::Candidate>& candidates) override { 197 const std::vector<cricket::Candidate>& candidates) override {
197 num_candidates_removed_ += candidates.size(); 198 num_candidates_removed_ += candidates.size();
198 } 199 }
199 200
200 bool oncandidatesready_; 201 bool oncandidatesready_;
201 std::vector<cricket::Candidate> mline_0_candidates_; 202 std::vector<cricket::Candidate> mline_0_candidates_;
202 std::vector<cricket::Candidate> mline_1_candidates_; 203 std::vector<cricket::Candidate> mline_1_candidates_;
203 PeerConnectionInterface::IceConnectionState ice_connection_state_; 204 PeerConnectionInterface::IceConnectionState ice_connection_state_;
204 PeerConnectionInterface::IceGatheringState ice_gathering_state_; 205 PeerConnectionInterface::IceGatheringState ice_gathering_state_;
206 std::vector<PeerConnectionInterface::IceConnectionState>
207 ice_connection_state_history_;
205 size_t num_candidates_removed_ = 0; 208 size_t num_candidates_removed_ = 0;
206 }; 209 };
207 210
208 class WebRtcSessionForTest : public webrtc::WebRtcSession { 211 class WebRtcSessionForTest : public webrtc::WebRtcSession {
209 public: 212 public:
210 WebRtcSessionForTest(webrtc::MediaControllerInterface* media_controller, 213 WebRtcSessionForTest(webrtc::MediaControllerInterface* media_controller,
211 rtc::Thread* network_thread, 214 rtc::Thread* network_thread,
212 rtc::Thread* worker_thread, 215 rtc::Thread* worker_thread,
213 rtc::Thread* signaling_thread, 216 rtc::Thread* signaling_thread,
214 cricket::PortAllocator* port_allocator, 217 cricket::PortAllocator* port_allocator,
(...skipping 3041 matching lines...) Expand 10 before | Expand all | Expand 10 after
3256 PeerConnectionInterface::RTCOfferAnswerOptions options; 3259 PeerConnectionInterface::RTCOfferAnswerOptions options;
3257 options.use_rtp_mux = true; 3260 options.use_rtp_mux = true;
3258 3261
3259 SessionDescriptionInterface* offer = CreateOffer(options); 3262 SessionDescriptionInterface* offer = CreateOffer(options);
3260 SetRemoteDescriptionWithoutError(offer); 3263 SetRemoteDescriptionWithoutError(offer);
3261 3264
3262 EXPECT_EQ(session_->voice_rtp_transport_channel(), 3265 EXPECT_EQ(session_->voice_rtp_transport_channel(),
3263 session_->video_rtp_transport_channel()); 3266 session_->video_rtp_transport_channel());
3264 } 3267 }
3265 3268
3269 // Adding a new channel to a BUNDLE which is already connected should directly
3270 // assign the bundle transport to the channel, without first setting a
3271 // disconnected non-bundle transport and then replacing it. The application
3272 // should not receive any changes in the ICE state.
3273 TEST_F(WebRtcSessionTest, TestAddChannelToConnectedBundle) {
3274 LoopbackNetworkConfiguration config;
3275 LoopbackNetworkManager loopback_network_manager(this, config);
3276 // Both BUNDLE and RTCP-mux need to be enabled for the ICE state to remain
3277 // connected. Disabling either of these two means that we need to wait for the
3278 // answer to find out if more transports are needed.
3279 configuration_.bundle_policy =
3280 PeerConnectionInterface::kBundlePolicyMaxBundle;
3281 configuration_.rtcp_mux_policy =
3282 PeerConnectionInterface::kRtcpMuxPolicyRequire;
3283 options_.disable_encryption = true;
3284 Init();
3285
3286 // Negotiate an audio channel with MAX_BUNDLE enabled.
3287 SendAudioOnlyStream2();
3288 SessionDescriptionInterface* offer = CreateOffer();
3289 SetLocalDescriptionWithoutError(offer);
3290 EXPECT_EQ_WAIT(PeerConnectionInterface::kIceGatheringComplete,
3291 observer_.ice_gathering_state_, kIceCandidatesTimeout);
3292 std::string sdp;
3293 offer->ToString(&sdp);
3294 SessionDescriptionInterface* answer = webrtc::CreateSessionDescription(
3295 JsepSessionDescription::kAnswer, sdp, nullptr);
3296 ASSERT_TRUE(answer != NULL);
3297 SetRemoteDescriptionWithoutError(answer);
3298
3299 // Wait for the ICE state to stabilize.
3300 EXPECT_EQ_WAIT(PeerConnectionInterface::kIceConnectionCompleted,
3301 observer_.ice_connection_state_, kIceCandidatesTimeout);
3302 observer_.ice_connection_state_history_.clear();
3303
3304 // Now add a video channel which should be using the same bundle transport.
3305 SendAudioVideoStream2();
3306 offer = CreateOffer();
3307 offer->ToString(&sdp);
3308 SetLocalDescriptionWithoutError(offer);
3309 answer = webrtc::CreateSessionDescription(JsepSessionDescription::kAnswer,
3310 sdp, nullptr);
3311 ASSERT_TRUE(answer != NULL);
3312 SetRemoteDescriptionWithoutError(answer);
3313
3314 // Wait for ICE state to stabilize
3315 rtc::Thread::Current()->ProcessMessages(0);
3316 EXPECT_EQ_WAIT(PeerConnectionInterface::kIceConnectionCompleted,
3317 observer_.ice_connection_state_, kIceCandidatesTimeout);
3318
3319 // No ICE state changes are expected to happen.
3320 EXPECT_EQ(0, observer_.ice_connection_state_history_.size());
3321 }
3322
3266 TEST_F(WebRtcSessionTest, TestRequireRtcpMux) { 3323 TEST_F(WebRtcSessionTest, TestRequireRtcpMux) {
3267 InitWithRtcpMuxPolicy(PeerConnectionInterface::kRtcpMuxPolicyRequire); 3324 InitWithRtcpMuxPolicy(PeerConnectionInterface::kRtcpMuxPolicyRequire);
3268 SendAudioVideoStream1(); 3325 SendAudioVideoStream1();
3269 3326
3270 PeerConnectionInterface::RTCOfferAnswerOptions options; 3327 PeerConnectionInterface::RTCOfferAnswerOptions options;
3271 SessionDescriptionInterface* offer = CreateOffer(options); 3328 SessionDescriptionInterface* offer = CreateOffer(options);
3272 SetLocalDescriptionWithoutError(offer); 3329 SetLocalDescriptionWithoutError(offer);
3273 3330
3274 EXPECT_TRUE(session_->voice_rtcp_transport_channel() == NULL); 3331 EXPECT_TRUE(session_->voice_rtcp_transport_channel() == NULL);
3275 EXPECT_TRUE(session_->video_rtcp_transport_channel() == NULL); 3332 EXPECT_TRUE(session_->video_rtcp_transport_channel() == NULL);
(...skipping 1084 matching lines...) Expand 10 before | Expand all | Expand 10 after
4360 } 4417 }
4361 4418
4362 // TODO(bemasc): Add a TestIceStatesBundle with BUNDLE enabled. That test 4419 // TODO(bemasc): Add a TestIceStatesBundle with BUNDLE enabled. That test
4363 // currently fails because upon disconnection and reconnection OnIceComplete is 4420 // currently fails because upon disconnection and reconnection OnIceComplete is
4364 // called more than once without returning to IceGatheringGathering. 4421 // called more than once without returning to IceGatheringGathering.
4365 4422
4366 INSTANTIATE_TEST_CASE_P(WebRtcSessionTests, 4423 INSTANTIATE_TEST_CASE_P(WebRtcSessionTests,
4367 WebRtcSessionTest, 4424 WebRtcSessionTest,
4368 testing::Values(ALREADY_GENERATED, 4425 testing::Values(ALREADY_GENERATED,
4369 DTLS_IDENTITY_STORE)); 4426 DTLS_IDENTITY_STORE));
OLDNEW
« no previous file with comments | « webrtc/api/webrtcsession.cc ('k') | webrtc/pc/channel.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698