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

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

Issue 1930463002: Replace scoped_ptr with unique_ptr in webrtc/api/ (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: 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/api/webrtcsessiondescriptionfactory.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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 49
50 #define MAYBE_SKIP_TEST(feature) \ 50 #define MAYBE_SKIP_TEST(feature) \
51 if (!(feature())) { \ 51 if (!(feature())) { \
52 LOG(LS_INFO) << "Feature disabled... skipping"; \ 52 LOG(LS_INFO) << "Feature disabled... skipping"; \
53 return; \ 53 return; \
54 } 54 }
55 55
56 using cricket::FakeVoiceMediaChannel; 56 using cricket::FakeVoiceMediaChannel;
57 using cricket::TransportInfo; 57 using cricket::TransportInfo;
58 using rtc::SocketAddress; 58 using rtc::SocketAddress;
59 using rtc::scoped_ptr;
60 using rtc::Thread; 59 using rtc::Thread;
61 using webrtc::CreateSessionDescription; 60 using webrtc::CreateSessionDescription;
62 using webrtc::CreateSessionDescriptionObserver; 61 using webrtc::CreateSessionDescriptionObserver;
63 using webrtc::CreateSessionDescriptionRequest; 62 using webrtc::CreateSessionDescriptionRequest;
64 using webrtc::DataChannel; 63 using webrtc::DataChannel;
65 using webrtc::DtlsIdentityStoreInterface; 64 using webrtc::DtlsIdentityStoreInterface;
66 using webrtc::FakeMetricsObserver; 65 using webrtc::FakeMetricsObserver;
67 using webrtc::IceCandidateCollection; 66 using webrtc::IceCandidateCollection;
68 using webrtc::InternalDataChannelInit; 67 using webrtc::InternalDataChannelInit;
69 using webrtc::JsepIceCandidate; 68 using webrtc::JsepIceCandidate;
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after
291 SessionDescriptionInterface* ReleaseDescription() { 290 SessionDescriptionInterface* ReleaseDescription() {
292 return description_.release(); 291 return description_.release();
293 } 292 }
294 293
295 State state() const { return state_; } 294 State state() const { return state_; }
296 295
297 protected: 296 protected:
298 ~WebRtcSessionCreateSDPObserverForTest() {} 297 ~WebRtcSessionCreateSDPObserverForTest() {}
299 298
300 private: 299 private:
301 rtc::scoped_ptr<SessionDescriptionInterface> description_; 300 std::unique_ptr<SessionDescriptionInterface> description_;
302 State state_; 301 State state_;
303 }; 302 };
304 303
305 class FakeAudioSource : public cricket::AudioSource { 304 class FakeAudioSource : public cricket::AudioSource {
306 public: 305 public:
307 FakeAudioSource() : sink_(NULL) {} 306 FakeAudioSource() : sink_(NULL) {}
308 virtual ~FakeAudioSource() { 307 virtual ~FakeAudioSource() {
309 if (sink_) 308 if (sink_)
310 sink_->OnClose(); 309 sink_->OnClose();
311 } 310 }
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
369 void RemoveInterface(const SocketAddress& addr) { 368 void RemoveInterface(const SocketAddress& addr) {
370 network_manager_.RemoveInterface(addr); 369 network_manager_.RemoveInterface(addr);
371 } 370 }
372 371
373 // If |dtls_identity_store| != null or |rtc_configuration| contains 372 // If |dtls_identity_store| != null or |rtc_configuration| contains
374 // |certificates| then DTLS will be enabled unless explicitly disabled by 373 // |certificates| then DTLS will be enabled unless explicitly disabled by
375 // |rtc_configuration| options. When DTLS is enabled a certificate will be 374 // |rtc_configuration| options. When DTLS is enabled a certificate will be
376 // used if provided, otherwise one will be generated using the 375 // used if provided, otherwise one will be generated using the
377 // |dtls_identity_store|. 376 // |dtls_identity_store|.
378 void Init( 377 void Init(
379 rtc::scoped_ptr<webrtc::DtlsIdentityStoreInterface> dtls_identity_store) { 378 std::unique_ptr<webrtc::DtlsIdentityStoreInterface> dtls_identity_store) {
380 ASSERT_TRUE(session_.get() == NULL); 379 ASSERT_TRUE(session_.get() == NULL);
381 session_.reset(new WebRtcSessionForTest( 380 session_.reset(new WebRtcSessionForTest(
382 media_controller_.get(), rtc::Thread::Current(), rtc::Thread::Current(), 381 media_controller_.get(), rtc::Thread::Current(), rtc::Thread::Current(),
383 allocator_.get(), &observer_)); 382 allocator_.get(), &observer_));
384 session_->SignalDataChannelOpenMessage.connect( 383 session_->SignalDataChannelOpenMessage.connect(
385 this, &WebRtcSessionTest::OnDataChannelOpenMessage); 384 this, &WebRtcSessionTest::OnDataChannelOpenMessage);
386 session_->GetOnDestroyedSignal()->connect( 385 session_->GetOnDestroyedSignal()->connect(
387 this, &WebRtcSessionTest::OnSessionDestroyed); 386 this, &WebRtcSessionTest::OnSessionDestroyed);
388 387
389 EXPECT_EQ(PeerConnectionInterface::kIceConnectionNew, 388 EXPECT_EQ(PeerConnectionInterface::kIceConnectionNew,
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
421 void InitWithRtcpMuxPolicy( 420 void InitWithRtcpMuxPolicy(
422 PeerConnectionInterface::RtcpMuxPolicy rtcp_mux_policy) { 421 PeerConnectionInterface::RtcpMuxPolicy rtcp_mux_policy) {
423 PeerConnectionInterface::RTCConfiguration configuration; 422 PeerConnectionInterface::RTCConfiguration configuration;
424 configuration_.rtcp_mux_policy = rtcp_mux_policy; 423 configuration_.rtcp_mux_policy = rtcp_mux_policy;
425 Init(); 424 Init();
426 } 425 }
427 426
428 // Successfully init with DTLS; with a certificate generated and supplied or 427 // Successfully init with DTLS; with a certificate generated and supplied or
429 // with a store that generates it for us. 428 // with a store that generates it for us.
430 void InitWithDtls(RTCCertificateGenerationMethod cert_gen_method) { 429 void InitWithDtls(RTCCertificateGenerationMethod cert_gen_method) {
431 rtc::scoped_ptr<FakeDtlsIdentityStore> dtls_identity_store; 430 std::unique_ptr<FakeDtlsIdentityStore> dtls_identity_store;
432 if (cert_gen_method == ALREADY_GENERATED) { 431 if (cert_gen_method == ALREADY_GENERATED) {
433 configuration_.certificates.push_back( 432 configuration_.certificates.push_back(
434 FakeDtlsIdentityStore::GenerateCertificate()); 433 FakeDtlsIdentityStore::GenerateCertificate());
435 } else if (cert_gen_method == DTLS_IDENTITY_STORE) { 434 } else if (cert_gen_method == DTLS_IDENTITY_STORE) {
436 dtls_identity_store.reset(new FakeDtlsIdentityStore()); 435 dtls_identity_store.reset(new FakeDtlsIdentityStore());
437 dtls_identity_store->set_should_fail(false); 436 dtls_identity_store->set_should_fail(false);
438 } else { 437 } else {
439 RTC_CHECK(false); 438 RTC_CHECK(false);
440 } 439 }
441 Init(std::move(dtls_identity_store)); 440 Init(std::move(dtls_identity_store));
442 } 441 }
443 442
444 // Init with DTLS with a store that will fail to generate a certificate. 443 // Init with DTLS with a store that will fail to generate a certificate.
445 void InitWithDtlsIdentityGenFail() { 444 void InitWithDtlsIdentityGenFail() {
446 rtc::scoped_ptr<FakeDtlsIdentityStore> dtls_identity_store( 445 std::unique_ptr<FakeDtlsIdentityStore> dtls_identity_store(
447 new FakeDtlsIdentityStore()); 446 new FakeDtlsIdentityStore());
448 dtls_identity_store->set_should_fail(true); 447 dtls_identity_store->set_should_fail(true);
449 Init(std::move(dtls_identity_store)); 448 Init(std::move(dtls_identity_store));
450 } 449 }
451 450
452 void InitWithDtmfCodec() { 451 void InitWithDtmfCodec() {
453 // Add kTelephoneEventCodec for dtmf test. 452 // Add kTelephoneEventCodec for dtmf test.
454 const cricket::AudioCodec kTelephoneEventCodec(106, "telephone-event", 8000, 453 const cricket::AudioCodec kTelephoneEventCodec(106, "telephone-event", 8000,
455 0, 1); 454 0, 1);
456 std::vector<cricket::AudioCodec> codecs; 455 std::vector<cricket::AudioCodec> codecs;
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after
720 offer); 719 offer);
721 const webrtc::SessionDescriptionInterface* answer = CreateAnswer(); 720 const webrtc::SessionDescriptionInterface* answer = CreateAnswer();
722 // Answer should be NULL as no crypto params in offer. 721 // Answer should be NULL as no crypto params in offer.
723 ASSERT_TRUE(answer == NULL); 722 ASSERT_TRUE(answer == NULL);
724 } 723 }
725 724
726 void VerifyAnswerFromCryptoOffer() { 725 void VerifyAnswerFromCryptoOffer() {
727 cricket::MediaSessionOptions options; 726 cricket::MediaSessionOptions options;
728 options.recv_video = true; 727 options.recv_video = true;
729 options.bundle_enabled = true; 728 options.bundle_enabled = true;
730 scoped_ptr<JsepSessionDescription> offer( 729 std::unique_ptr<JsepSessionDescription> offer(
731 CreateRemoteOffer(options, cricket::SEC_REQUIRED)); 730 CreateRemoteOffer(options, cricket::SEC_REQUIRED));
732 ASSERT_TRUE(offer.get() != NULL); 731 ASSERT_TRUE(offer.get() != NULL);
733 VerifyCryptoParams(offer->description()); 732 VerifyCryptoParams(offer->description());
734 SetRemoteDescriptionWithoutError(offer.release()); 733 SetRemoteDescriptionWithoutError(offer.release());
735 scoped_ptr<SessionDescriptionInterface> answer(CreateAnswer()); 734 std::unique_ptr<SessionDescriptionInterface> answer(CreateAnswer());
736 ASSERT_TRUE(answer.get() != NULL); 735 ASSERT_TRUE(answer.get() != NULL);
737 VerifyCryptoParams(answer->description()); 736 VerifyCryptoParams(answer->description());
738 } 737 }
739 738
740 bool IceUfragPwdEqual(const cricket::SessionDescription* desc1, 739 bool IceUfragPwdEqual(const cricket::SessionDescription* desc1,
741 const cricket::SessionDescription* desc2) { 740 const cricket::SessionDescription* desc2) {
742 if (desc1->contents().size() != desc2->contents().size()) { 741 if (desc1->contents().size() != desc2->contents().size()) {
743 return false; 742 return false;
744 } 743 }
745 744
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
924 cricket::SEC_DISABLED); 923 cricket::SEC_DISABLED);
925 EXPECT_TRUE(*nocrypto_answer != NULL); 924 EXPECT_TRUE(*nocrypto_answer != NULL);
926 } 925 }
927 926
928 void CreateDtlsOfferAndNonDtlsAnswer(SessionDescriptionInterface** offer, 927 void CreateDtlsOfferAndNonDtlsAnswer(SessionDescriptionInterface** offer,
929 SessionDescriptionInterface** nodtls_answer) { 928 SessionDescriptionInterface** nodtls_answer) {
930 cricket::MediaSessionOptions options; 929 cricket::MediaSessionOptions options;
931 options.recv_video = true; 930 options.recv_video = true;
932 options.bundle_enabled = true; 931 options.bundle_enabled = true;
933 932
934 rtc::scoped_ptr<SessionDescriptionInterface> temp_offer( 933 std::unique_ptr<SessionDescriptionInterface> temp_offer(
935 CreateRemoteOffer(options, cricket::SEC_ENABLED)); 934 CreateRemoteOffer(options, cricket::SEC_ENABLED));
936 935
937 *nodtls_answer = 936 *nodtls_answer =
938 CreateRemoteAnswer(temp_offer.get(), options, cricket::SEC_ENABLED); 937 CreateRemoteAnswer(temp_offer.get(), options, cricket::SEC_ENABLED);
939 EXPECT_TRUE(*nodtls_answer != NULL); 938 EXPECT_TRUE(*nodtls_answer != NULL);
940 VerifyFingerprintStatus((*nodtls_answer)->description(), false); 939 VerifyFingerprintStatus((*nodtls_answer)->description(), false);
941 VerifyCryptoParams((*nodtls_answer)->description()); 940 VerifyCryptoParams((*nodtls_answer)->description());
942 941
943 SetFactoryDtlsSrtp(); 942 SetFactoryDtlsSrtp();
944 *offer = CreateRemoteOffer(options, cricket::SEC_ENABLED); 943 *offer = CreateRemoteOffer(options, cricket::SEC_ENABLED);
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
1063 SendAudioVideoStream1(); 1062 SendAudioVideoStream1();
1064 1063
1065 PeerConnectionInterface::RTCOfferAnswerOptions options; 1064 PeerConnectionInterface::RTCOfferAnswerOptions options;
1066 options.use_rtp_mux = bundle; 1065 options.use_rtp_mux = bundle;
1067 1066
1068 SessionDescriptionInterface* offer = CreateOffer(options); 1067 SessionDescriptionInterface* offer = CreateOffer(options);
1069 // SetLocalDescription and SetRemoteDescriptions takes ownership of offer 1068 // SetLocalDescription and SetRemoteDescriptions takes ownership of offer
1070 // and answer. 1069 // and answer.
1071 SetLocalDescriptionWithoutError(offer); 1070 SetLocalDescriptionWithoutError(offer);
1072 1071
1073 rtc::scoped_ptr<SessionDescriptionInterface> answer( 1072 std::unique_ptr<SessionDescriptionInterface> answer(
1074 CreateRemoteAnswer(session_->local_description())); 1073 CreateRemoteAnswer(session_->local_description()));
1075 std::string sdp; 1074 std::string sdp;
1076 EXPECT_TRUE(answer->ToString(&sdp)); 1075 EXPECT_TRUE(answer->ToString(&sdp));
1077 1076
1078 size_t expected_candidate_num = 2; 1077 size_t expected_candidate_num = 2;
1079 if (!rtcp_mux) { 1078 if (!rtcp_mux) {
1080 // If rtcp_mux is enabled we should expect 4 candidates - host and srflex 1079 // If rtcp_mux is enabled we should expect 4 candidates - host and srflex
1081 // for rtp and rtcp. 1080 // for rtp and rtcp.
1082 expected_candidate_num = 4; 1081 expected_candidate_num = 4;
1083 // Disable rtcp-mux from the answer 1082 // Disable rtcp-mux from the answer
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after
1364 InitWithDtlsIdentityGenFail(); 1363 InitWithDtlsIdentityGenFail();
1365 VerifyMultipleAsyncCreateDescriptionAfterInit(false, type); 1364 VerifyMultipleAsyncCreateDescriptionAfterInit(false, type);
1366 } 1365 }
1367 1366
1368 void VerifyMultipleAsyncCreateDescriptionAfterInit( 1367 void VerifyMultipleAsyncCreateDescriptionAfterInit(
1369 bool success, CreateSessionDescriptionRequest::Type type) { 1368 bool success, CreateSessionDescriptionRequest::Type type) {
1370 RTC_CHECK(session_); 1369 RTC_CHECK(session_);
1371 SetFactoryDtlsSrtp(); 1370 SetFactoryDtlsSrtp();
1372 if (type == CreateSessionDescriptionRequest::kAnswer) { 1371 if (type == CreateSessionDescriptionRequest::kAnswer) {
1373 cricket::MediaSessionOptions options; 1372 cricket::MediaSessionOptions options;
1374 scoped_ptr<JsepSessionDescription> offer( 1373 std::unique_ptr<JsepSessionDescription> offer(
1375 CreateRemoteOffer(options, cricket::SEC_DISABLED)); 1374 CreateRemoteOffer(options, cricket::SEC_DISABLED));
1376 ASSERT_TRUE(offer.get() != NULL); 1375 ASSERT_TRUE(offer.get() != NULL);
1377 SetRemoteDescriptionWithoutError(offer.release()); 1376 SetRemoteDescriptionWithoutError(offer.release());
1378 } 1377 }
1379 1378
1380 PeerConnectionInterface::RTCOfferAnswerOptions options; 1379 PeerConnectionInterface::RTCOfferAnswerOptions options;
1381 cricket::MediaSessionOptions session_options; 1380 cricket::MediaSessionOptions session_options;
1382 const int kNumber = 3; 1381 const int kNumber = 3;
1383 rtc::scoped_refptr<WebRtcSessionCreateSDPObserverForTest> 1382 rtc::scoped_refptr<WebRtcSessionCreateSDPObserverForTest>
1384 observers[kNumber]; 1383 observers[kNumber];
1385 for (int i = 0; i < kNumber; ++i) { 1384 for (int i = 0; i < kNumber; ++i) {
(...skipping 25 matching lines...) Expand all
1411 turn_server.credentials = credentials; 1410 turn_server.credentials = credentials;
1412 turn_server.ports.push_back( 1411 turn_server.ports.push_back(
1413 cricket::ProtocolAddress(kTurnUdpIntAddr, cricket::PROTO_UDP, false)); 1412 cricket::ProtocolAddress(kTurnUdpIntAddr, cricket::PROTO_UDP, false));
1414 allocator_->AddTurnServer(turn_server); 1413 allocator_->AddTurnServer(turn_server);
1415 allocator_->set_step_delay(cricket::kMinimumStepDelay); 1414 allocator_->set_step_delay(cricket::kMinimumStepDelay);
1416 allocator_->set_flags(cricket::PORTALLOCATOR_DISABLE_TCP); 1415 allocator_->set_flags(cricket::PORTALLOCATOR_DISABLE_TCP);
1417 } 1416 }
1418 1417
1419 cricket::FakeMediaEngine* media_engine_; 1418 cricket::FakeMediaEngine* media_engine_;
1420 cricket::FakeDataEngine* data_engine_; 1419 cricket::FakeDataEngine* data_engine_;
1421 rtc::scoped_ptr<cricket::ChannelManager> channel_manager_; 1420 std::unique_ptr<cricket::ChannelManager> channel_manager_;
1422 cricket::FakeCall fake_call_; 1421 cricket::FakeCall fake_call_;
1423 rtc::scoped_ptr<webrtc::MediaControllerInterface> media_controller_; 1422 std::unique_ptr<webrtc::MediaControllerInterface> media_controller_;
1424 rtc::scoped_ptr<cricket::TransportDescriptionFactory> tdesc_factory_; 1423 std::unique_ptr<cricket::TransportDescriptionFactory> tdesc_factory_;
1425 rtc::scoped_ptr<cricket::MediaSessionDescriptionFactory> desc_factory_; 1424 std::unique_ptr<cricket::MediaSessionDescriptionFactory> desc_factory_;
1426 rtc::scoped_ptr<rtc::PhysicalSocketServer> pss_; 1425 std::unique_ptr<rtc::PhysicalSocketServer> pss_;
1427 rtc::scoped_ptr<rtc::VirtualSocketServer> vss_; 1426 std::unique_ptr<rtc::VirtualSocketServer> vss_;
1428 rtc::scoped_ptr<rtc::FirewallSocketServer> fss_; 1427 std::unique_ptr<rtc::FirewallSocketServer> fss_;
1429 rtc::SocketServerScope ss_scope_; 1428 rtc::SocketServerScope ss_scope_;
1430 rtc::SocketAddress stun_socket_addr_; 1429 rtc::SocketAddress stun_socket_addr_;
1431 rtc::scoped_ptr<cricket::TestStunServer> stun_server_; 1430 std::unique_ptr<cricket::TestStunServer> stun_server_;
1432 cricket::TestTurnServer turn_server_; 1431 cricket::TestTurnServer turn_server_;
1433 rtc::FakeNetworkManager network_manager_; 1432 rtc::FakeNetworkManager network_manager_;
1434 rtc::scoped_ptr<cricket::BasicPortAllocator> allocator_; 1433 std::unique_ptr<cricket::BasicPortAllocator> allocator_;
1435 PeerConnectionFactoryInterface::Options options_; 1434 PeerConnectionFactoryInterface::Options options_;
1436 PeerConnectionInterface::RTCConfiguration configuration_; 1435 PeerConnectionInterface::RTCConfiguration configuration_;
1437 rtc::scoped_ptr<WebRtcSessionForTest> session_; 1436 std::unique_ptr<WebRtcSessionForTest> session_;
1438 MockIceObserver observer_; 1437 MockIceObserver observer_;
1439 cricket::FakeVideoMediaChannel* video_channel_; 1438 cricket::FakeVideoMediaChannel* video_channel_;
1440 cricket::FakeVoiceMediaChannel* voice_channel_; 1439 cricket::FakeVoiceMediaChannel* voice_channel_;
1441 rtc::scoped_refptr<FakeMetricsObserver> metrics_observer_; 1440 rtc::scoped_refptr<FakeMetricsObserver> metrics_observer_;
1442 // The following flags affect options created for CreateOffer/CreateAnswer. 1441 // The following flags affect options created for CreateOffer/CreateAnswer.
1443 bool send_stream_1_ = false; 1442 bool send_stream_1_ = false;
1444 bool send_stream_2_ = false; 1443 bool send_stream_2_ = false;
1445 bool send_audio_ = false; 1444 bool send_audio_ = false;
1446 bool send_video_ = false; 1445 bool send_video_ = false;
1447 rtc::scoped_refptr<DataChannel> data_channel_; 1446 rtc::scoped_refptr<DataChannel> data_channel_;
(...skipping 417 matching lines...) Expand 10 before | Expand all | Expand 10 after
1865 } 1864 }
1866 1865
1867 // Test that we return a failure when applying a remote answer that doesn't have 1866 // Test that we return a failure when applying a remote answer that doesn't have
1868 // a DTLS fingerprint when DTLS is required. 1867 // a DTLS fingerprint when DTLS is required.
1869 TEST_P(WebRtcSessionTest, TestSetRemoteNonDtlsAnswerWhenDtlsOn) { 1868 TEST_P(WebRtcSessionTest, TestSetRemoteNonDtlsAnswerWhenDtlsOn) {
1870 MAYBE_SKIP_TEST(rtc::SSLStreamAdapter::HaveDtlsSrtp); 1869 MAYBE_SKIP_TEST(rtc::SSLStreamAdapter::HaveDtlsSrtp);
1871 InitWithDtls(GetParam()); 1870 InitWithDtls(GetParam());
1872 SessionDescriptionInterface* offer = CreateOffer(); 1871 SessionDescriptionInterface* offer = CreateOffer();
1873 cricket::MediaSessionOptions options; 1872 cricket::MediaSessionOptions options;
1874 options.recv_video = true; 1873 options.recv_video = true;
1875 rtc::scoped_ptr<SessionDescriptionInterface> temp_offer( 1874 std::unique_ptr<SessionDescriptionInterface> temp_offer(
1876 CreateRemoteOffer(options, cricket::SEC_ENABLED)); 1875 CreateRemoteOffer(options, cricket::SEC_ENABLED));
1877 JsepSessionDescription* answer = 1876 JsepSessionDescription* answer =
1878 CreateRemoteAnswer(temp_offer.get(), options, cricket::SEC_ENABLED); 1877 CreateRemoteAnswer(temp_offer.get(), options, cricket::SEC_ENABLED);
1879 1878
1880 // SetRemoteDescription and SetLocalDescription will take the ownership of 1879 // SetRemoteDescription and SetLocalDescription will take the ownership of
1881 // the offer and answer. 1880 // the offer and answer.
1882 SetLocalDescriptionWithoutError(offer); 1881 SetLocalDescriptionWithoutError(offer);
1883 SetRemoteDescriptionAnswerExpectError( 1882 SetRemoteDescriptionAnswerExpectError(
1884 kSdpWithoutDtlsFingerprint, answer); 1883 kSdpWithoutDtlsFingerprint, answer);
1885 } 1884 }
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after
2091 2090
2092 SendAudioVideoStream2(); 2091 SendAudioVideoStream2();
2093 SessionDescriptionInterface* answer = 2092 SessionDescriptionInterface* answer =
2094 CreateRemoteAnswer(session_->local_description()); 2093 CreateRemoteAnswer(session_->local_description());
2095 SetRemoteDescriptionExpectState(answer, WebRtcSession::STATE_INPROGRESS); 2094 SetRemoteDescriptionExpectState(answer, WebRtcSession::STATE_INPROGRESS);
2096 } 2095 }
2097 2096
2098 TEST_F(WebRtcSessionTest, TestSetLocalAnswerWithoutOffer) { 2097 TEST_F(WebRtcSessionTest, TestSetLocalAnswerWithoutOffer) {
2099 Init(); 2098 Init();
2100 SendNothing(); 2099 SendNothing();
2101 rtc::scoped_ptr<SessionDescriptionInterface> offer(CreateOffer()); 2100 std::unique_ptr<SessionDescriptionInterface> offer(CreateOffer());
2102 2101
2103 SessionDescriptionInterface* answer = 2102 SessionDescriptionInterface* answer =
2104 CreateRemoteAnswer(offer.get()); 2103 CreateRemoteAnswer(offer.get());
2105 SetLocalDescriptionAnswerExpectError("Called in wrong state: STATE_INIT", 2104 SetLocalDescriptionAnswerExpectError("Called in wrong state: STATE_INIT",
2106 answer); 2105 answer);
2107 } 2106 }
2108 2107
2109 TEST_F(WebRtcSessionTest, TestSetRemoteAnswerWithoutOffer) { 2108 TEST_F(WebRtcSessionTest, TestSetRemoteAnswerWithoutOffer) {
2110 Init(); 2109 Init();
2111 SendNothing(); 2110 SendNothing();
2112 rtc::scoped_ptr<SessionDescriptionInterface> offer(CreateOffer()); 2111 std::unique_ptr<SessionDescriptionInterface> offer(CreateOffer());
2113 2112
2114 SessionDescriptionInterface* answer = 2113 SessionDescriptionInterface* answer =
2115 CreateRemoteAnswer(offer.get()); 2114 CreateRemoteAnswer(offer.get());
2116 SetRemoteDescriptionAnswerExpectError( 2115 SetRemoteDescriptionAnswerExpectError(
2117 "Called in wrong state: STATE_INIT", answer); 2116 "Called in wrong state: STATE_INIT", answer);
2118 } 2117 }
2119 2118
2120 // Tests that the remote candidates are added and removed successfully. 2119 // Tests that the remote candidates are added and removed successfully.
2121 TEST_F(WebRtcSessionTest, TestAddAndRemoveRemoteCandidates) { 2120 TEST_F(WebRtcSessionTest, TestAddAndRemoveRemoteCandidates) {
2122 Init(); 2121 Init();
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after
2341 SendAudioVideoStream1(); 2340 SendAudioVideoStream1();
2342 // Ice is started but candidates are not provided until SetLocalDescription 2341 // Ice is started but candidates are not provided until SetLocalDescription
2343 // is called. 2342 // is called.
2344 EXPECT_EQ(0u, observer_.mline_0_candidates_.size()); 2343 EXPECT_EQ(0u, observer_.mline_0_candidates_.size());
2345 EXPECT_EQ(0u, observer_.mline_1_candidates_.size()); 2344 EXPECT_EQ(0u, observer_.mline_1_candidates_.size());
2346 CreateAndSetRemoteOfferAndLocalAnswer(); 2345 CreateAndSetRemoteOfferAndLocalAnswer();
2347 // Wait until at least one local candidate has been collected. 2346 // Wait until at least one local candidate has been collected.
2348 EXPECT_TRUE_WAIT(0u < observer_.mline_0_candidates_.size(), 2347 EXPECT_TRUE_WAIT(0u < observer_.mline_0_candidates_.size(),
2349 kIceCandidatesTimeout); 2348 kIceCandidatesTimeout);
2350 2349
2351 rtc::scoped_ptr<SessionDescriptionInterface> local_offer(CreateOffer()); 2350 std::unique_ptr<SessionDescriptionInterface> local_offer(CreateOffer());
2352 2351
2353 ASSERT_TRUE(local_offer->candidates(kMediaContentIndex0) != NULL); 2352 ASSERT_TRUE(local_offer->candidates(kMediaContentIndex0) != NULL);
2354 EXPECT_LT(0u, local_offer->candidates(kMediaContentIndex0)->count()); 2353 EXPECT_LT(0u, local_offer->candidates(kMediaContentIndex0)->count());
2355 2354
2356 SessionDescriptionInterface* remote_offer(CreateRemoteOffer()); 2355 SessionDescriptionInterface* remote_offer(CreateRemoteOffer());
2357 SetRemoteDescriptionWithoutError(remote_offer); 2356 SetRemoteDescriptionWithoutError(remote_offer);
2358 SessionDescriptionInterface* answer = CreateAnswer(); 2357 SessionDescriptionInterface* answer = CreateAnswer();
2359 ASSERT_TRUE(answer->candidates(kMediaContentIndex0) != NULL); 2358 ASSERT_TRUE(answer->candidates(kMediaContentIndex0) != NULL);
2360 EXPECT_LT(0u, answer->candidates(kMediaContentIndex0)->count()); 2359 EXPECT_LT(0u, answer->candidates(kMediaContentIndex0)->count());
2361 SetLocalDescriptionWithoutError(answer); 2360 SetLocalDescriptionWithoutError(answer);
2362 } 2361 }
2363 2362
2364 // Verifies TransportProxy and media channels are created with content names 2363 // Verifies TransportProxy and media channels are created with content names
2365 // present in the SessionDescription. 2364 // present in the SessionDescription.
2366 TEST_F(WebRtcSessionTest, TestChannelCreationsWithContentNames) { 2365 TEST_F(WebRtcSessionTest, TestChannelCreationsWithContentNames) {
2367 Init(); 2366 Init();
2368 SendAudioVideoStream1(); 2367 SendAudioVideoStream1();
2369 rtc::scoped_ptr<SessionDescriptionInterface> offer(CreateOffer()); 2368 std::unique_ptr<SessionDescriptionInterface> offer(CreateOffer());
2370 2369
2371 // CreateOffer creates session description with the content names "audio" and 2370 // CreateOffer creates session description with the content names "audio" and
2372 // "video". Goal is to modify these content names and verify transport 2371 // "video". Goal is to modify these content names and verify transport
2373 // channels 2372 // channels
2374 // in the WebRtcSession, as channels are created with the content names 2373 // in the WebRtcSession, as channels are created with the content names
2375 // present in SDP. 2374 // present in SDP.
2376 std::string sdp; 2375 std::string sdp;
2377 EXPECT_TRUE(offer->ToString(&sdp)); 2376 EXPECT_TRUE(offer->ToString(&sdp));
2378 const std::string kAudioMid = "a=mid:audio"; 2377 const std::string kAudioMid = "a=mid:audio";
2379 const std::string kAudioMidReplaceStr = "a=mid:audio_content_name"; 2378 const std::string kAudioMidReplaceStr = "a=mid:audio_content_name";
(...skipping 28 matching lines...) Expand all
2408 ASSERT_TRUE(video_transport_channel != NULL); 2407 ASSERT_TRUE(video_transport_channel != NULL);
2409 EXPECT_EQ(video_transport_channel->transport_name(), "video_content_name"); 2408 EXPECT_EQ(video_transport_channel->transport_name(), "video_content_name");
2410 EXPECT_TRUE((video_channel_ = media_engine_->GetVideoChannel(0)) != NULL); 2409 EXPECT_TRUE((video_channel_ = media_engine_->GetVideoChannel(0)) != NULL);
2411 EXPECT_TRUE((voice_channel_ = media_engine_->GetVoiceChannel(0)) != NULL); 2410 EXPECT_TRUE((voice_channel_ = media_engine_->GetVoiceChannel(0)) != NULL);
2412 } 2411 }
2413 2412
2414 // Test that an offer contains the correct media content descriptions based on 2413 // Test that an offer contains the correct media content descriptions based on
2415 // the send streams when no constraints have been set. 2414 // the send streams when no constraints have been set.
2416 TEST_F(WebRtcSessionTest, CreateOfferWithoutConstraintsOrStreams) { 2415 TEST_F(WebRtcSessionTest, CreateOfferWithoutConstraintsOrStreams) {
2417 Init(); 2416 Init();
2418 rtc::scoped_ptr<SessionDescriptionInterface> offer(CreateOffer()); 2417 std::unique_ptr<SessionDescriptionInterface> offer(CreateOffer());
2419 2418
2420 ASSERT_TRUE(offer != NULL); 2419 ASSERT_TRUE(offer != NULL);
2421 const cricket::ContentInfo* content = 2420 const cricket::ContentInfo* content =
2422 cricket::GetFirstAudioContent(offer->description()); 2421 cricket::GetFirstAudioContent(offer->description());
2423 EXPECT_TRUE(content != NULL); 2422 EXPECT_TRUE(content != NULL);
2424 content = cricket::GetFirstVideoContent(offer->description()); 2423 content = cricket::GetFirstVideoContent(offer->description());
2425 EXPECT_TRUE(content == NULL); 2424 EXPECT_TRUE(content == NULL);
2426 } 2425 }
2427 2426
2428 // Test that an offer contains the correct media content descriptions based on 2427 // Test that an offer contains the correct media content descriptions based on
2429 // the send streams when no constraints have been set. 2428 // the send streams when no constraints have been set.
2430 TEST_F(WebRtcSessionTest, CreateOfferWithoutConstraints) { 2429 TEST_F(WebRtcSessionTest, CreateOfferWithoutConstraints) {
2431 Init(); 2430 Init();
2432 // Test Audio only offer. 2431 // Test Audio only offer.
2433 SendAudioOnlyStream2(); 2432 SendAudioOnlyStream2();
2434 rtc::scoped_ptr<SessionDescriptionInterface> offer(CreateOffer()); 2433 std::unique_ptr<SessionDescriptionInterface> offer(CreateOffer());
2435 2434
2436 const cricket::ContentInfo* content = 2435 const cricket::ContentInfo* content =
2437 cricket::GetFirstAudioContent(offer->description()); 2436 cricket::GetFirstAudioContent(offer->description());
2438 EXPECT_TRUE(content != NULL); 2437 EXPECT_TRUE(content != NULL);
2439 content = cricket::GetFirstVideoContent(offer->description()); 2438 content = cricket::GetFirstVideoContent(offer->description());
2440 EXPECT_TRUE(content == NULL); 2439 EXPECT_TRUE(content == NULL);
2441 2440
2442 // Test Audio / Video offer. 2441 // Test Audio / Video offer.
2443 SendAudioVideoStream1(); 2442 SendAudioVideoStream1();
2444 offer.reset(CreateOffer()); 2443 offer.reset(CreateOffer());
2445 content = cricket::GetFirstAudioContent(offer->description()); 2444 content = cricket::GetFirstAudioContent(offer->description());
2446 EXPECT_TRUE(content != NULL); 2445 EXPECT_TRUE(content != NULL);
2447 content = cricket::GetFirstVideoContent(offer->description()); 2446 content = cricket::GetFirstVideoContent(offer->description());
2448 EXPECT_TRUE(content != NULL); 2447 EXPECT_TRUE(content != NULL);
2449 } 2448 }
2450 2449
2451 // Test that an offer contains no media content descriptions if 2450 // Test that an offer contains no media content descriptions if
2452 // kOfferToReceiveVideo and kOfferToReceiveAudio constraints are set to false. 2451 // kOfferToReceiveVideo and kOfferToReceiveAudio constraints are set to false.
2453 TEST_F(WebRtcSessionTest, CreateOfferWithConstraintsWithoutStreams) { 2452 TEST_F(WebRtcSessionTest, CreateOfferWithConstraintsWithoutStreams) {
2454 Init(); 2453 Init();
2455 PeerConnectionInterface::RTCOfferAnswerOptions options; 2454 PeerConnectionInterface::RTCOfferAnswerOptions options;
2456 options.offer_to_receive_audio = 0; 2455 options.offer_to_receive_audio = 0;
2457 options.offer_to_receive_video = 0; 2456 options.offer_to_receive_video = 0;
2458 2457
2459 rtc::scoped_ptr<SessionDescriptionInterface> offer( 2458 std::unique_ptr<SessionDescriptionInterface> offer(CreateOffer(options));
2460 CreateOffer(options));
2461 2459
2462 ASSERT_TRUE(offer != NULL); 2460 ASSERT_TRUE(offer != NULL);
2463 const cricket::ContentInfo* content = 2461 const cricket::ContentInfo* content =
2464 cricket::GetFirstAudioContent(offer->description()); 2462 cricket::GetFirstAudioContent(offer->description());
2465 EXPECT_TRUE(content == NULL); 2463 EXPECT_TRUE(content == NULL);
2466 content = cricket::GetFirstVideoContent(offer->description()); 2464 content = cricket::GetFirstVideoContent(offer->description());
2467 EXPECT_TRUE(content == NULL); 2465 EXPECT_TRUE(content == NULL);
2468 } 2466 }
2469 2467
2470 // Test that an offer contains only audio media content descriptions if 2468 // Test that an offer contains only audio media content descriptions if
2471 // kOfferToReceiveAudio constraints are set to true. 2469 // kOfferToReceiveAudio constraints are set to true.
2472 TEST_F(WebRtcSessionTest, CreateAudioOnlyOfferWithConstraints) { 2470 TEST_F(WebRtcSessionTest, CreateAudioOnlyOfferWithConstraints) {
2473 Init(); 2471 Init();
2474 PeerConnectionInterface::RTCOfferAnswerOptions options; 2472 PeerConnectionInterface::RTCOfferAnswerOptions options;
2475 options.offer_to_receive_audio = 2473 options.offer_to_receive_audio =
2476 RTCOfferAnswerOptions::kOfferToReceiveMediaTrue; 2474 RTCOfferAnswerOptions::kOfferToReceiveMediaTrue;
2477 2475
2478 rtc::scoped_ptr<SessionDescriptionInterface> offer( 2476 std::unique_ptr<SessionDescriptionInterface> offer(CreateOffer(options));
2479 CreateOffer(options));
2480 2477
2481 const cricket::ContentInfo* content = 2478 const cricket::ContentInfo* content =
2482 cricket::GetFirstAudioContent(offer->description()); 2479 cricket::GetFirstAudioContent(offer->description());
2483 EXPECT_TRUE(content != NULL); 2480 EXPECT_TRUE(content != NULL);
2484 content = cricket::GetFirstVideoContent(offer->description()); 2481 content = cricket::GetFirstVideoContent(offer->description());
2485 EXPECT_TRUE(content == NULL); 2482 EXPECT_TRUE(content == NULL);
2486 } 2483 }
2487 2484
2488 // Test that an offer contains audio and video media content descriptions if 2485 // Test that an offer contains audio and video media content descriptions if
2489 // kOfferToReceiveAudio and kOfferToReceiveVideo constraints are set to true. 2486 // kOfferToReceiveAudio and kOfferToReceiveVideo constraints are set to true.
2490 TEST_F(WebRtcSessionTest, CreateOfferWithConstraints) { 2487 TEST_F(WebRtcSessionTest, CreateOfferWithConstraints) {
2491 Init(); 2488 Init();
2492 // Test Audio / Video offer. 2489 // Test Audio / Video offer.
2493 PeerConnectionInterface::RTCOfferAnswerOptions options; 2490 PeerConnectionInterface::RTCOfferAnswerOptions options;
2494 options.offer_to_receive_audio = 2491 options.offer_to_receive_audio =
2495 RTCOfferAnswerOptions::kOfferToReceiveMediaTrue; 2492 RTCOfferAnswerOptions::kOfferToReceiveMediaTrue;
2496 options.offer_to_receive_video = 2493 options.offer_to_receive_video =
2497 RTCOfferAnswerOptions::kOfferToReceiveMediaTrue; 2494 RTCOfferAnswerOptions::kOfferToReceiveMediaTrue;
2498 2495
2499 rtc::scoped_ptr<SessionDescriptionInterface> offer( 2496 std::unique_ptr<SessionDescriptionInterface> offer(CreateOffer(options));
2500 CreateOffer(options));
2501 2497
2502 const cricket::ContentInfo* content = 2498 const cricket::ContentInfo* content =
2503 cricket::GetFirstAudioContent(offer->description()); 2499 cricket::GetFirstAudioContent(offer->description());
2504 EXPECT_TRUE(content != NULL); 2500 EXPECT_TRUE(content != NULL);
2505 2501
2506 content = cricket::GetFirstVideoContent(offer->description()); 2502 content = cricket::GetFirstVideoContent(offer->description());
2507 EXPECT_TRUE(content != NULL); 2503 EXPECT_TRUE(content != NULL);
2508 2504
2509 // Sets constraints to false and verifies that audio/video contents are 2505 // Sets constraints to false and verifies that audio/video contents are
2510 // removed. 2506 // removed.
(...skipping 16 matching lines...) Expand all
2527 SessionDescriptionInterface* answer = CreateRemoteAnswer(offer); 2523 SessionDescriptionInterface* answer = CreateRemoteAnswer(offer);
2528 SetRemoteDescriptionWithoutError(answer); 2524 SetRemoteDescriptionWithoutError(answer);
2529 EXPECT_TRUE(CreateAnswer() == NULL); 2525 EXPECT_TRUE(CreateAnswer() == NULL);
2530 } 2526 }
2531 2527
2532 // Test that an answer contains the correct media content descriptions when no 2528 // Test that an answer contains the correct media content descriptions when no
2533 // constraints have been set. 2529 // constraints have been set.
2534 TEST_F(WebRtcSessionTest, CreateAnswerWithoutConstraintsOrStreams) { 2530 TEST_F(WebRtcSessionTest, CreateAnswerWithoutConstraintsOrStreams) {
2535 Init(); 2531 Init();
2536 // Create a remote offer with audio and video content. 2532 // Create a remote offer with audio and video content.
2537 rtc::scoped_ptr<JsepSessionDescription> offer(CreateRemoteOffer()); 2533 std::unique_ptr<JsepSessionDescription> offer(CreateRemoteOffer());
2538 SetRemoteDescriptionWithoutError(offer.release()); 2534 SetRemoteDescriptionWithoutError(offer.release());
2539 rtc::scoped_ptr<SessionDescriptionInterface> answer(CreateAnswer()); 2535 std::unique_ptr<SessionDescriptionInterface> answer(CreateAnswer());
2540 const cricket::ContentInfo* content = 2536 const cricket::ContentInfo* content =
2541 cricket::GetFirstAudioContent(answer->description()); 2537 cricket::GetFirstAudioContent(answer->description());
2542 ASSERT_TRUE(content != NULL); 2538 ASSERT_TRUE(content != NULL);
2543 EXPECT_FALSE(content->rejected); 2539 EXPECT_FALSE(content->rejected);
2544 2540
2545 content = cricket::GetFirstVideoContent(answer->description()); 2541 content = cricket::GetFirstVideoContent(answer->description());
2546 ASSERT_TRUE(content != NULL); 2542 ASSERT_TRUE(content != NULL);
2547 EXPECT_FALSE(content->rejected); 2543 EXPECT_FALSE(content->rejected);
2548 } 2544 }
2549 2545
2550 // Test that an answer contains the correct media content descriptions when no 2546 // Test that an answer contains the correct media content descriptions when no
2551 // constraints have been set and the offer only contain audio. 2547 // constraints have been set and the offer only contain audio.
2552 TEST_F(WebRtcSessionTest, CreateAudioAnswerWithoutConstraintsOrStreams) { 2548 TEST_F(WebRtcSessionTest, CreateAudioAnswerWithoutConstraintsOrStreams) {
2553 Init(); 2549 Init();
2554 // Create a remote offer with audio only. 2550 // Create a remote offer with audio only.
2555 cricket::MediaSessionOptions options; 2551 cricket::MediaSessionOptions options;
2556 2552
2557 rtc::scoped_ptr<JsepSessionDescription> offer( 2553 std::unique_ptr<JsepSessionDescription> offer(CreateRemoteOffer(options));
2558 CreateRemoteOffer(options));
2559 ASSERT_TRUE(cricket::GetFirstVideoContent(offer->description()) == NULL); 2554 ASSERT_TRUE(cricket::GetFirstVideoContent(offer->description()) == NULL);
2560 ASSERT_TRUE(cricket::GetFirstAudioContent(offer->description()) != NULL); 2555 ASSERT_TRUE(cricket::GetFirstAudioContent(offer->description()) != NULL);
2561 2556
2562 SetRemoteDescriptionWithoutError(offer.release()); 2557 SetRemoteDescriptionWithoutError(offer.release());
2563 rtc::scoped_ptr<SessionDescriptionInterface> answer(CreateAnswer()); 2558 std::unique_ptr<SessionDescriptionInterface> answer(CreateAnswer());
2564 const cricket::ContentInfo* content = 2559 const cricket::ContentInfo* content =
2565 cricket::GetFirstAudioContent(answer->description()); 2560 cricket::GetFirstAudioContent(answer->description());
2566 ASSERT_TRUE(content != NULL); 2561 ASSERT_TRUE(content != NULL);
2567 EXPECT_FALSE(content->rejected); 2562 EXPECT_FALSE(content->rejected);
2568 2563
2569 EXPECT_TRUE(cricket::GetFirstVideoContent(answer->description()) == NULL); 2564 EXPECT_TRUE(cricket::GetFirstVideoContent(answer->description()) == NULL);
2570 } 2565 }
2571 2566
2572 // Test that an answer contains the correct media content descriptions when no 2567 // Test that an answer contains the correct media content descriptions when no
2573 // constraints have been set. 2568 // constraints have been set.
2574 TEST_F(WebRtcSessionTest, CreateAnswerWithoutConstraints) { 2569 TEST_F(WebRtcSessionTest, CreateAnswerWithoutConstraints) {
2575 Init(); 2570 Init();
2576 // Create a remote offer with audio and video content. 2571 // Create a remote offer with audio and video content.
2577 rtc::scoped_ptr<JsepSessionDescription> offer(CreateRemoteOffer()); 2572 std::unique_ptr<JsepSessionDescription> offer(CreateRemoteOffer());
2578 SetRemoteDescriptionWithoutError(offer.release()); 2573 SetRemoteDescriptionWithoutError(offer.release());
2579 // Test with a stream with tracks. 2574 // Test with a stream with tracks.
2580 SendAudioVideoStream1(); 2575 SendAudioVideoStream1();
2581 rtc::scoped_ptr<SessionDescriptionInterface> answer(CreateAnswer()); 2576 std::unique_ptr<SessionDescriptionInterface> answer(CreateAnswer());
2582 const cricket::ContentInfo* content = 2577 const cricket::ContentInfo* content =
2583 cricket::GetFirstAudioContent(answer->description()); 2578 cricket::GetFirstAudioContent(answer->description());
2584 ASSERT_TRUE(content != NULL); 2579 ASSERT_TRUE(content != NULL);
2585 EXPECT_FALSE(content->rejected); 2580 EXPECT_FALSE(content->rejected);
2586 2581
2587 content = cricket::GetFirstVideoContent(answer->description()); 2582 content = cricket::GetFirstVideoContent(answer->description());
2588 ASSERT_TRUE(content != NULL); 2583 ASSERT_TRUE(content != NULL);
2589 EXPECT_FALSE(content->rejected); 2584 EXPECT_FALSE(content->rejected);
2590 } 2585 }
2591 2586
2592 // Test that an answer contains the correct media content descriptions when 2587 // Test that an answer contains the correct media content descriptions when
2593 // constraints have been set but no stream is sent. 2588 // constraints have been set but no stream is sent.
2594 TEST_F(WebRtcSessionTest, CreateAnswerWithConstraintsWithoutStreams) { 2589 TEST_F(WebRtcSessionTest, CreateAnswerWithConstraintsWithoutStreams) {
2595 Init(); 2590 Init();
2596 // Create a remote offer with audio and video content. 2591 // Create a remote offer with audio and video content.
2597 rtc::scoped_ptr<JsepSessionDescription> offer(CreateRemoteOffer()); 2592 std::unique_ptr<JsepSessionDescription> offer(CreateRemoteOffer());
2598 SetRemoteDescriptionWithoutError(offer.release()); 2593 SetRemoteDescriptionWithoutError(offer.release());
2599 2594
2600 cricket::MediaSessionOptions session_options; 2595 cricket::MediaSessionOptions session_options;
2601 session_options.recv_audio = false; 2596 session_options.recv_audio = false;
2602 session_options.recv_video = false; 2597 session_options.recv_video = false;
2603 rtc::scoped_ptr<SessionDescriptionInterface> answer( 2598 std::unique_ptr<SessionDescriptionInterface> answer(
2604 CreateAnswer(session_options)); 2599 CreateAnswer(session_options));
2605 2600
2606 const cricket::ContentInfo* content = 2601 const cricket::ContentInfo* content =
2607 cricket::GetFirstAudioContent(answer->description()); 2602 cricket::GetFirstAudioContent(answer->description());
2608 ASSERT_TRUE(content != NULL); 2603 ASSERT_TRUE(content != NULL);
2609 EXPECT_TRUE(content->rejected); 2604 EXPECT_TRUE(content->rejected);
2610 2605
2611 content = cricket::GetFirstVideoContent(answer->description()); 2606 content = cricket::GetFirstVideoContent(answer->description());
2612 ASSERT_TRUE(content != NULL); 2607 ASSERT_TRUE(content != NULL);
2613 EXPECT_TRUE(content->rejected); 2608 EXPECT_TRUE(content->rejected);
2614 } 2609 }
2615 2610
2616 // Test that an answer contains the correct media content descriptions when 2611 // Test that an answer contains the correct media content descriptions when
2617 // constraints have been set and streams are sent. 2612 // constraints have been set and streams are sent.
2618 TEST_F(WebRtcSessionTest, CreateAnswerWithConstraints) { 2613 TEST_F(WebRtcSessionTest, CreateAnswerWithConstraints) {
2619 Init(); 2614 Init();
2620 // Create a remote offer with audio and video content. 2615 // Create a remote offer with audio and video content.
2621 rtc::scoped_ptr<JsepSessionDescription> offer(CreateRemoteOffer()); 2616 std::unique_ptr<JsepSessionDescription> offer(CreateRemoteOffer());
2622 SetRemoteDescriptionWithoutError(offer.release()); 2617 SetRemoteDescriptionWithoutError(offer.release());
2623 2618
2624 cricket::MediaSessionOptions options; 2619 cricket::MediaSessionOptions options;
2625 options.recv_audio = false; 2620 options.recv_audio = false;
2626 options.recv_video = false; 2621 options.recv_video = false;
2627 2622
2628 // Test with a stream with tracks. 2623 // Test with a stream with tracks.
2629 SendAudioVideoStream1(); 2624 SendAudioVideoStream1();
2630 rtc::scoped_ptr<SessionDescriptionInterface> answer(CreateAnswer(options)); 2625 std::unique_ptr<SessionDescriptionInterface> answer(CreateAnswer(options));
2631 2626
2632 // TODO(perkj): Should the direction be set to SEND_ONLY? 2627 // TODO(perkj): Should the direction be set to SEND_ONLY?
2633 const cricket::ContentInfo* content = 2628 const cricket::ContentInfo* content =
2634 cricket::GetFirstAudioContent(answer->description()); 2629 cricket::GetFirstAudioContent(answer->description());
2635 ASSERT_TRUE(content != NULL); 2630 ASSERT_TRUE(content != NULL);
2636 EXPECT_FALSE(content->rejected); 2631 EXPECT_FALSE(content->rejected);
2637 2632
2638 // TODO(perkj): Should the direction be set to SEND_ONLY? 2633 // TODO(perkj): Should the direction be set to SEND_ONLY?
2639 content = cricket::GetFirstVideoContent(answer->description()); 2634 content = cricket::GetFirstVideoContent(answer->description());
2640 ASSERT_TRUE(content != NULL); 2635 ASSERT_TRUE(content != NULL);
2641 EXPECT_FALSE(content->rejected); 2636 EXPECT_FALSE(content->rejected);
2642 } 2637 }
2643 2638
2644 TEST_F(WebRtcSessionTest, CreateOfferWithoutCNCodecs) { 2639 TEST_F(WebRtcSessionTest, CreateOfferWithoutCNCodecs) {
2645 AddCNCodecs(); 2640 AddCNCodecs();
2646 Init(); 2641 Init();
2647 PeerConnectionInterface::RTCOfferAnswerOptions options; 2642 PeerConnectionInterface::RTCOfferAnswerOptions options;
2648 options.offer_to_receive_audio = 2643 options.offer_to_receive_audio =
2649 RTCOfferAnswerOptions::kOfferToReceiveMediaTrue; 2644 RTCOfferAnswerOptions::kOfferToReceiveMediaTrue;
2650 options.voice_activity_detection = false; 2645 options.voice_activity_detection = false;
2651 2646
2652 rtc::scoped_ptr<SessionDescriptionInterface> offer( 2647 std::unique_ptr<SessionDescriptionInterface> offer(CreateOffer(options));
2653 CreateOffer(options));
2654 2648
2655 const cricket::ContentInfo* content = 2649 const cricket::ContentInfo* content =
2656 cricket::GetFirstAudioContent(offer->description()); 2650 cricket::GetFirstAudioContent(offer->description());
2657 EXPECT_TRUE(content != NULL); 2651 EXPECT_TRUE(content != NULL);
2658 EXPECT_TRUE(VerifyNoCNCodecs(content)); 2652 EXPECT_TRUE(VerifyNoCNCodecs(content));
2659 } 2653 }
2660 2654
2661 TEST_F(WebRtcSessionTest, CreateAnswerWithoutCNCodecs) { 2655 TEST_F(WebRtcSessionTest, CreateAnswerWithoutCNCodecs) {
2662 AddCNCodecs(); 2656 AddCNCodecs();
2663 Init(); 2657 Init();
2664 // Create a remote offer with audio and video content. 2658 // Create a remote offer with audio and video content.
2665 rtc::scoped_ptr<JsepSessionDescription> offer(CreateRemoteOffer()); 2659 std::unique_ptr<JsepSessionDescription> offer(CreateRemoteOffer());
2666 SetRemoteDescriptionWithoutError(offer.release()); 2660 SetRemoteDescriptionWithoutError(offer.release());
2667 2661
2668 cricket::MediaSessionOptions options; 2662 cricket::MediaSessionOptions options;
2669 options.vad_enabled = false; 2663 options.vad_enabled = false;
2670 rtc::scoped_ptr<SessionDescriptionInterface> answer(CreateAnswer(options)); 2664 std::unique_ptr<SessionDescriptionInterface> answer(CreateAnswer(options));
2671 const cricket::ContentInfo* content = 2665 const cricket::ContentInfo* content =
2672 cricket::GetFirstAudioContent(answer->description()); 2666 cricket::GetFirstAudioContent(answer->description());
2673 ASSERT_TRUE(content != NULL); 2667 ASSERT_TRUE(content != NULL);
2674 EXPECT_TRUE(VerifyNoCNCodecs(content)); 2668 EXPECT_TRUE(VerifyNoCNCodecs(content));
2675 } 2669 }
2676 2670
2677 // This test verifies the call setup when remote answer with audio only and 2671 // This test verifies the call setup when remote answer with audio only and
2678 // later updates with video. 2672 // later updates with video.
2679 TEST_F(WebRtcSessionTest, TestAVOfferWithAudioOnlyAnswer) { 2673 TEST_F(WebRtcSessionTest, TestAVOfferWithAudioOnlyAnswer) {
2680 Init(); 2674 Init();
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
2782 2776
2783 ASSERT_EQ(1u, video_channel_->recv_streams().size()); 2777 ASSERT_EQ(1u, video_channel_->recv_streams().size());
2784 EXPECT_EQ(kVideoTrack2, video_channel_->recv_streams()[0].id); 2778 EXPECT_EQ(kVideoTrack2, video_channel_->recv_streams()[0].id);
2785 ASSERT_EQ(1u, video_channel_->send_streams().size()); 2779 ASSERT_EQ(1u, video_channel_->send_streams().size());
2786 EXPECT_EQ(kVideoTrack2, video_channel_->send_streams()[0].id); 2780 EXPECT_EQ(kVideoTrack2, video_channel_->send_streams()[0].id);
2787 } 2781 }
2788 2782
2789 TEST_F(WebRtcSessionTest, VerifyCryptoParamsInSDP) { 2783 TEST_F(WebRtcSessionTest, VerifyCryptoParamsInSDP) {
2790 Init(); 2784 Init();
2791 SendAudioVideoStream1(); 2785 SendAudioVideoStream1();
2792 scoped_ptr<SessionDescriptionInterface> offer(CreateOffer()); 2786 std::unique_ptr<SessionDescriptionInterface> offer(CreateOffer());
2793 VerifyCryptoParams(offer->description()); 2787 VerifyCryptoParams(offer->description());
2794 SetRemoteDescriptionWithoutError(offer.release()); 2788 SetRemoteDescriptionWithoutError(offer.release());
2795 scoped_ptr<SessionDescriptionInterface> answer(CreateAnswer()); 2789 std::unique_ptr<SessionDescriptionInterface> answer(CreateAnswer());
2796 VerifyCryptoParams(answer->description()); 2790 VerifyCryptoParams(answer->description());
2797 } 2791 }
2798 2792
2799 TEST_F(WebRtcSessionTest, VerifyNoCryptoParamsInSDP) { 2793 TEST_F(WebRtcSessionTest, VerifyNoCryptoParamsInSDP) {
2800 options_.disable_encryption = true; 2794 options_.disable_encryption = true;
2801 Init(); 2795 Init();
2802 SendAudioVideoStream1(); 2796 SendAudioVideoStream1();
2803 scoped_ptr<SessionDescriptionInterface> offer(CreateOffer()); 2797 std::unique_ptr<SessionDescriptionInterface> offer(CreateOffer());
2804 VerifyNoCryptoParams(offer->description(), false); 2798 VerifyNoCryptoParams(offer->description(), false);
2805 } 2799 }
2806 2800
2807 TEST_F(WebRtcSessionTest, VerifyAnswerFromNonCryptoOffer) { 2801 TEST_F(WebRtcSessionTest, VerifyAnswerFromNonCryptoOffer) {
2808 Init(); 2802 Init();
2809 VerifyAnswerFromNonCryptoOffer(); 2803 VerifyAnswerFromNonCryptoOffer();
2810 } 2804 }
2811 2805
2812 TEST_F(WebRtcSessionTest, VerifyAnswerFromCryptoOffer) { 2806 TEST_F(WebRtcSessionTest, VerifyAnswerFromCryptoOffer) {
2813 Init(); 2807 Init();
2814 VerifyAnswerFromCryptoOffer(); 2808 VerifyAnswerFromCryptoOffer();
2815 } 2809 }
2816 2810
2817 // This test verifies that setLocalDescription fails if 2811 // This test verifies that setLocalDescription fails if
2818 // no a=ice-ufrag and a=ice-pwd lines are present in the SDP. 2812 // no a=ice-ufrag and a=ice-pwd lines are present in the SDP.
2819 TEST_F(WebRtcSessionTest, TestSetLocalDescriptionWithoutIce) { 2813 TEST_F(WebRtcSessionTest, TestSetLocalDescriptionWithoutIce) {
2820 Init(); 2814 Init();
2821 SendAudioVideoStream1(); 2815 SendAudioVideoStream1();
2822 rtc::scoped_ptr<SessionDescriptionInterface> offer(CreateOffer()); 2816 std::unique_ptr<SessionDescriptionInterface> offer(CreateOffer());
2823 2817
2824 std::string sdp; 2818 std::string sdp;
2825 RemoveIceUfragPwdLines(offer.get(), &sdp); 2819 RemoveIceUfragPwdLines(offer.get(), &sdp);
2826 SessionDescriptionInterface* modified_offer = 2820 SessionDescriptionInterface* modified_offer =
2827 CreateSessionDescription(JsepSessionDescription::kOffer, sdp, NULL); 2821 CreateSessionDescription(JsepSessionDescription::kOffer, sdp, NULL);
2828 SetLocalDescriptionOfferExpectError(kSdpWithoutIceUfragPwd, modified_offer); 2822 SetLocalDescriptionOfferExpectError(kSdpWithoutIceUfragPwd, modified_offer);
2829 } 2823 }
2830 2824
2831 // This test verifies that setRemoteDescription fails if 2825 // This test verifies that setRemoteDescription fails if
2832 // no a=ice-ufrag and a=ice-pwd lines are present in the SDP. 2826 // no a=ice-ufrag and a=ice-pwd lines are present in the SDP.
2833 TEST_F(WebRtcSessionTest, TestSetRemoteDescriptionWithoutIce) { 2827 TEST_F(WebRtcSessionTest, TestSetRemoteDescriptionWithoutIce) {
2834 Init(); 2828 Init();
2835 rtc::scoped_ptr<SessionDescriptionInterface> offer(CreateRemoteOffer()); 2829 std::unique_ptr<SessionDescriptionInterface> offer(CreateRemoteOffer());
2836 std::string sdp; 2830 std::string sdp;
2837 RemoveIceUfragPwdLines(offer.get(), &sdp); 2831 RemoveIceUfragPwdLines(offer.get(), &sdp);
2838 SessionDescriptionInterface* modified_offer = 2832 SessionDescriptionInterface* modified_offer =
2839 CreateSessionDescription(JsepSessionDescription::kOffer, sdp, NULL); 2833 CreateSessionDescription(JsepSessionDescription::kOffer, sdp, NULL);
2840 SetRemoteDescriptionOfferExpectError(kSdpWithoutIceUfragPwd, modified_offer); 2834 SetRemoteDescriptionOfferExpectError(kSdpWithoutIceUfragPwd, modified_offer);
2841 } 2835 }
2842 2836
2843 // This test verifies that setLocalDescription fails if local offer has 2837 // This test verifies that setLocalDescription fails if local offer has
2844 // too short ice ufrag and pwd strings. 2838 // too short ice ufrag and pwd strings.
2845 TEST_F(WebRtcSessionTest, TestSetLocalDescriptionInvalidIceCredentials) { 2839 TEST_F(WebRtcSessionTest, TestSetLocalDescriptionInvalidIceCredentials) {
2846 Init(); 2840 Init();
2847 SendAudioVideoStream1(); 2841 SendAudioVideoStream1();
2848 rtc::scoped_ptr<SessionDescriptionInterface> offer(CreateOffer()); 2842 std::unique_ptr<SessionDescriptionInterface> offer(CreateOffer());
2849 // Modifying ice ufrag and pwd in local offer with strings smaller than the 2843 // Modifying ice ufrag and pwd in local offer with strings smaller than the
2850 // recommended values of 4 and 22 bytes respectively. 2844 // recommended values of 4 and 22 bytes respectively.
2851 SetIceUfragPwd(offer.get(), "ice", "icepwd"); 2845 SetIceUfragPwd(offer.get(), "ice", "icepwd");
2852 std::string error; 2846 std::string error;
2853 EXPECT_FALSE(session_->SetLocalDescription(offer.release(), &error)); 2847 EXPECT_FALSE(session_->SetLocalDescription(offer.release(), &error));
2854 2848
2855 // Test with string greater than 256. 2849 // Test with string greater than 256.
2856 offer.reset(CreateOffer()); 2850 offer.reset(CreateOffer());
2857 SetIceUfragPwd(offer.get(), kTooLongIceUfragPwd, kTooLongIceUfragPwd); 2851 SetIceUfragPwd(offer.get(), kTooLongIceUfragPwd, kTooLongIceUfragPwd);
2858 EXPECT_FALSE(session_->SetLocalDescription(offer.release(), &error)); 2852 EXPECT_FALSE(session_->SetLocalDescription(offer.release(), &error));
2859 } 2853 }
2860 2854
2861 // This test verifies that setRemoteDescription fails if remote offer has 2855 // This test verifies that setRemoteDescription fails if remote offer has
2862 // too short ice ufrag and pwd strings. 2856 // too short ice ufrag and pwd strings.
2863 TEST_F(WebRtcSessionTest, TestSetRemoteDescriptionInvalidIceCredentials) { 2857 TEST_F(WebRtcSessionTest, TestSetRemoteDescriptionInvalidIceCredentials) {
2864 Init(); 2858 Init();
2865 rtc::scoped_ptr<SessionDescriptionInterface> offer(CreateRemoteOffer()); 2859 std::unique_ptr<SessionDescriptionInterface> offer(CreateRemoteOffer());
2866 // Modifying ice ufrag and pwd in remote offer with strings smaller than the 2860 // Modifying ice ufrag and pwd in remote offer with strings smaller than the
2867 // recommended values of 4 and 22 bytes respectively. 2861 // recommended values of 4 and 22 bytes respectively.
2868 SetIceUfragPwd(offer.get(), "ice", "icepwd"); 2862 SetIceUfragPwd(offer.get(), "ice", "icepwd");
2869 std::string error; 2863 std::string error;
2870 EXPECT_FALSE(session_->SetRemoteDescription(offer.release(), &error)); 2864 EXPECT_FALSE(session_->SetRemoteDescription(offer.release(), &error));
2871 2865
2872 offer.reset(CreateRemoteOffer()); 2866 offer.reset(CreateRemoteOffer());
2873 SetIceUfragPwd(offer.get(), kTooLongIceUfragPwd, kTooLongIceUfragPwd); 2867 SetIceUfragPwd(offer.get(), kTooLongIceUfragPwd, kTooLongIceUfragPwd);
2874 EXPECT_FALSE(session_->SetRemoteDescription(offer.release(), &error)); 2868 EXPECT_FALSE(session_->SetRemoteDescription(offer.release(), &error));
2875 } 2869 }
2876 2870
2877 // Test that if the remote offer indicates the peer requested ICE restart (via 2871 // Test that if the remote offer indicates the peer requested ICE restart (via
2878 // a new ufrag or pwd), the old ICE candidates are not copied, and vice versa. 2872 // a new ufrag or pwd), the old ICE candidates are not copied, and vice versa.
2879 TEST_F(WebRtcSessionTest, TestSetRemoteOfferWithIceRestart) { 2873 TEST_F(WebRtcSessionTest, TestSetRemoteOfferWithIceRestart) {
2880 Init(); 2874 Init();
2881 2875
2882 // Create the first offer. 2876 // Create the first offer.
2883 scoped_ptr<SessionDescriptionInterface> offer(CreateRemoteOffer()); 2877 std::unique_ptr<SessionDescriptionInterface> offer(CreateRemoteOffer());
2884 SetIceUfragPwd(offer.get(), "0123456789012345", "abcdefghijklmnopqrstuvwx"); 2878 SetIceUfragPwd(offer.get(), "0123456789012345", "abcdefghijklmnopqrstuvwx");
2885 cricket::Candidate candidate1(1, "udp", rtc::SocketAddress("1.1.1.1", 5000), 2879 cricket::Candidate candidate1(1, "udp", rtc::SocketAddress("1.1.1.1", 5000),
2886 0, "", "", "relay", 0, ""); 2880 0, "", "", "relay", 0, "");
2887 JsepIceCandidate ice_candidate1(kMediaContentName0, kMediaContentIndex0, 2881 JsepIceCandidate ice_candidate1(kMediaContentName0, kMediaContentIndex0,
2888 candidate1); 2882 candidate1);
2889 EXPECT_TRUE(offer->AddCandidate(&ice_candidate1)); 2883 EXPECT_TRUE(offer->AddCandidate(&ice_candidate1));
2890 SetRemoteDescriptionWithoutError(offer.release()); 2884 SetRemoteDescriptionWithoutError(offer.release());
2891 EXPECT_EQ(1, session_->remote_description()->candidates(0)->count()); 2885 EXPECT_EQ(1, session_->remote_description()->candidates(0)->count());
2892 2886
2893 // The second offer has the same ufrag and pwd but different address. 2887 // The second offer has the same ufrag and pwd but different address.
(...skipping 24 matching lines...) Expand all
2918 } 2912 }
2919 2913
2920 // Test that if the remote answer indicates the peer requested ICE restart (via 2914 // Test that if the remote answer indicates the peer requested ICE restart (via
2921 // a new ufrag or pwd), the old ICE candidates are not copied, and vice versa. 2915 // a new ufrag or pwd), the old ICE candidates are not copied, and vice versa.
2922 TEST_F(WebRtcSessionTest, TestSetRemoteAnswerWithIceRestart) { 2916 TEST_F(WebRtcSessionTest, TestSetRemoteAnswerWithIceRestart) {
2923 Init(); 2917 Init();
2924 SessionDescriptionInterface* offer = CreateOffer(); 2918 SessionDescriptionInterface* offer = CreateOffer();
2925 SetLocalDescriptionWithoutError(offer); 2919 SetLocalDescriptionWithoutError(offer);
2926 2920
2927 // Create the first answer. 2921 // Create the first answer.
2928 scoped_ptr<JsepSessionDescription> answer(CreateRemoteAnswer(offer)); 2922 std::unique_ptr<JsepSessionDescription> answer(CreateRemoteAnswer(offer));
2929 answer->set_type(JsepSessionDescription::kPrAnswer); 2923 answer->set_type(JsepSessionDescription::kPrAnswer);
2930 SetIceUfragPwd(answer.get(), "0123456789012345", "abcdefghijklmnopqrstuvwx"); 2924 SetIceUfragPwd(answer.get(), "0123456789012345", "abcdefghijklmnopqrstuvwx");
2931 cricket::Candidate candidate1(1, "udp", rtc::SocketAddress("1.1.1.1", 5000), 2925 cricket::Candidate candidate1(1, "udp", rtc::SocketAddress("1.1.1.1", 5000),
2932 0, "", "", "relay", 0, ""); 2926 0, "", "", "relay", 0, "");
2933 JsepIceCandidate ice_candidate1(kMediaContentName0, kMediaContentIndex0, 2927 JsepIceCandidate ice_candidate1(kMediaContentName0, kMediaContentIndex0,
2934 candidate1); 2928 candidate1);
2935 EXPECT_TRUE(answer->AddCandidate(&ice_candidate1)); 2929 EXPECT_TRUE(answer->AddCandidate(&ice_candidate1));
2936 SetRemoteDescriptionWithoutError(answer.release()); 2930 SetRemoteDescriptionWithoutError(answer.release());
2937 EXPECT_EQ(1, session_->remote_description()->candidates(0)->count()); 2931 EXPECT_EQ(1, session_->remote_description()->candidates(0)->count());
2938 2932
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
3085 3079
3086 SessionDescriptionInterface* offer = CreateOffer(options); 3080 SessionDescriptionInterface* offer = CreateOffer(options);
3087 SetLocalDescriptionWithoutError(offer); 3081 SetLocalDescriptionWithoutError(offer);
3088 3082
3089 EXPECT_NE(session_->voice_rtp_transport_channel(), 3083 EXPECT_NE(session_->voice_rtp_transport_channel(),
3090 session_->video_rtp_transport_channel()); 3084 session_->video_rtp_transport_channel());
3091 3085
3092 SendAudioVideoStream2(); 3086 SendAudioVideoStream2();
3093 3087
3094 // Remove BUNDLE from the answer. 3088 // Remove BUNDLE from the answer.
3095 rtc::scoped_ptr<SessionDescriptionInterface> answer( 3089 std::unique_ptr<SessionDescriptionInterface> answer(
3096 CreateRemoteAnswer(session_->local_description())); 3090 CreateRemoteAnswer(session_->local_description()));
3097 cricket::SessionDescription* answer_copy = answer->description()->Copy(); 3091 cricket::SessionDescription* answer_copy = answer->description()->Copy();
3098 answer_copy->RemoveGroupByName(cricket::GROUP_TYPE_BUNDLE); 3092 answer_copy->RemoveGroupByName(cricket::GROUP_TYPE_BUNDLE);
3099 JsepSessionDescription* modified_answer = 3093 JsepSessionDescription* modified_answer =
3100 new JsepSessionDescription(JsepSessionDescription::kAnswer); 3094 new JsepSessionDescription(JsepSessionDescription::kAnswer);
3101 modified_answer->Initialize(answer_copy, "1", "1"); 3095 modified_answer->Initialize(answer_copy, "1", "1");
3102 SetRemoteDescriptionWithoutError(modified_answer); // 3096 SetRemoteDescriptionWithoutError(modified_answer); //
3103 3097
3104 EXPECT_NE(session_->voice_rtp_transport_channel(), 3098 EXPECT_NE(session_->voice_rtp_transport_channel(),
3105 session_->video_rtp_transport_channel()); 3099 session_->video_rtp_transport_channel());
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
3171 3165
3172 SessionDescriptionInterface* offer = CreateOffer(options); 3166 SessionDescriptionInterface* offer = CreateOffer(options);
3173 SetLocalDescriptionWithoutError(offer); 3167 SetLocalDescriptionWithoutError(offer);
3174 3168
3175 EXPECT_EQ(session_->voice_rtp_transport_channel(), 3169 EXPECT_EQ(session_->voice_rtp_transport_channel(),
3176 session_->video_rtp_transport_channel()); 3170 session_->video_rtp_transport_channel());
3177 3171
3178 SendAudioVideoStream2(); 3172 SendAudioVideoStream2();
3179 3173
3180 // Remove BUNDLE from the answer. 3174 // Remove BUNDLE from the answer.
3181 rtc::scoped_ptr<SessionDescriptionInterface> answer( 3175 std::unique_ptr<SessionDescriptionInterface> answer(
3182 CreateRemoteAnswer(session_->local_description())); 3176 CreateRemoteAnswer(session_->local_description()));
3183 cricket::SessionDescription* answer_copy = answer->description()->Copy(); 3177 cricket::SessionDescription* answer_copy = answer->description()->Copy();
3184 answer_copy->RemoveGroupByName(cricket::GROUP_TYPE_BUNDLE); 3178 answer_copy->RemoveGroupByName(cricket::GROUP_TYPE_BUNDLE);
3185 JsepSessionDescription* modified_answer = 3179 JsepSessionDescription* modified_answer =
3186 new JsepSessionDescription(JsepSessionDescription::kAnswer); 3180 new JsepSessionDescription(JsepSessionDescription::kAnswer);
3187 modified_answer->Initialize(answer_copy, "1", "1"); 3181 modified_answer->Initialize(answer_copy, "1", "1");
3188 SetRemoteDescriptionWithoutError(modified_answer); 3182 SetRemoteDescriptionWithoutError(modified_answer);
3189 3183
3190 EXPECT_EQ(session_->voice_rtp_transport_channel(), 3184 EXPECT_EQ(session_->voice_rtp_transport_channel(),
3191 session_->video_rtp_transport_channel()); 3185 session_->video_rtp_transport_channel());
(...skipping 17 matching lines...) Expand all
3209 EXPECT_EQ(session_->voice_rtp_transport_channel(), 3203 EXPECT_EQ(session_->voice_rtp_transport_channel(),
3210 session_->video_rtp_transport_channel()); 3204 session_->video_rtp_transport_channel());
3211 } 3205 }
3212 3206
3213 // kBundlePolicyMaxBundle policy but no BUNDLE in the remote offer. 3207 // kBundlePolicyMaxBundle policy but no BUNDLE in the remote offer.
3214 TEST_F(WebRtcSessionTest, TestMaxBundleNoBundleInRemoteOffer) { 3208 TEST_F(WebRtcSessionTest, TestMaxBundleNoBundleInRemoteOffer) {
3215 InitWithBundlePolicy(PeerConnectionInterface::kBundlePolicyMaxBundle); 3209 InitWithBundlePolicy(PeerConnectionInterface::kBundlePolicyMaxBundle);
3216 SendAudioVideoStream1(); 3210 SendAudioVideoStream1();
3217 3211
3218 // Remove BUNDLE from the offer. 3212 // Remove BUNDLE from the offer.
3219 rtc::scoped_ptr<SessionDescriptionInterface> offer(CreateRemoteOffer()); 3213 std::unique_ptr<SessionDescriptionInterface> offer(CreateRemoteOffer());
3220 cricket::SessionDescription* offer_copy = offer->description()->Copy(); 3214 cricket::SessionDescription* offer_copy = offer->description()->Copy();
3221 offer_copy->RemoveGroupByName(cricket::GROUP_TYPE_BUNDLE); 3215 offer_copy->RemoveGroupByName(cricket::GROUP_TYPE_BUNDLE);
3222 JsepSessionDescription* modified_offer = 3216 JsepSessionDescription* modified_offer =
3223 new JsepSessionDescription(JsepSessionDescription::kOffer); 3217 new JsepSessionDescription(JsepSessionDescription::kOffer);
3224 modified_offer->Initialize(offer_copy, "1", "1"); 3218 modified_offer->Initialize(offer_copy, "1", "1");
3225 3219
3226 // Expect an error when applying the remote description 3220 // Expect an error when applying the remote description
3227 SetRemoteDescriptionExpectError(JsepSessionDescription::kOffer, 3221 SetRemoteDescriptionExpectError(JsepSessionDescription::kOffer,
3228 kCreateChannelFailed, modified_offer); 3222 kCreateChannelFailed, modified_offer);
3229 } 3223 }
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
3262 3256
3263 SessionDescriptionInterface* offer = CreateOffer(options); 3257 SessionDescriptionInterface* offer = CreateOffer(options);
3264 SetLocalDescriptionWithoutError(offer); 3258 SetLocalDescriptionWithoutError(offer);
3265 3259
3266 EXPECT_NE(session_->voice_rtp_transport_channel(), 3260 EXPECT_NE(session_->voice_rtp_transport_channel(),
3267 session_->video_rtp_transport_channel()); 3261 session_->video_rtp_transport_channel());
3268 3262
3269 SendAudioVideoStream2(); 3263 SendAudioVideoStream2();
3270 3264
3271 // Remove BUNDLE from the answer. 3265 // Remove BUNDLE from the answer.
3272 rtc::scoped_ptr<SessionDescriptionInterface> answer( 3266 std::unique_ptr<SessionDescriptionInterface> answer(
3273 CreateRemoteAnswer(session_->local_description())); 3267 CreateRemoteAnswer(session_->local_description()));
3274 cricket::SessionDescription* answer_copy = answer->description()->Copy(); 3268 cricket::SessionDescription* answer_copy = answer->description()->Copy();
3275 answer_copy->RemoveGroupByName(cricket::GROUP_TYPE_BUNDLE); 3269 answer_copy->RemoveGroupByName(cricket::GROUP_TYPE_BUNDLE);
3276 JsepSessionDescription* modified_answer = 3270 JsepSessionDescription* modified_answer =
3277 new JsepSessionDescription(JsepSessionDescription::kAnswer); 3271 new JsepSessionDescription(JsepSessionDescription::kAnswer);
3278 modified_answer->Initialize(answer_copy, "1", "1"); 3272 modified_answer->Initialize(answer_copy, "1", "1");
3279 SetRemoteDescriptionWithoutError(modified_answer); // 3273 SetRemoteDescriptionWithoutError(modified_answer); //
3280 3274
3281 EXPECT_NE(session_->voice_rtp_transport_channel(), 3275 EXPECT_NE(session_->voice_rtp_transport_channel(),
3282 session_->video_rtp_transport_channel()); 3276 session_->video_rtp_transport_channel());
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
3420 CreateAndSetRemoteOfferAndLocalAnswer(); 3414 CreateAndSetRemoteOfferAndLocalAnswer();
3421 cricket::FakeVoiceMediaChannel* channel = media_engine_->GetVoiceChannel(0); 3415 cricket::FakeVoiceMediaChannel* channel = media_engine_->GetVoiceChannel(0);
3422 ASSERT_TRUE(channel != NULL); 3416 ASSERT_TRUE(channel != NULL);
3423 ASSERT_EQ(1u, channel->send_streams().size()); 3417 ASSERT_EQ(1u, channel->send_streams().size());
3424 uint32_t send_ssrc = channel->send_streams()[0].first_ssrc(); 3418 uint32_t send_ssrc = channel->send_streams()[0].first_ssrc();
3425 EXPECT_FALSE(channel->IsStreamMuted(send_ssrc)); 3419 EXPECT_FALSE(channel->IsStreamMuted(send_ssrc));
3426 3420
3427 cricket::AudioOptions options; 3421 cricket::AudioOptions options;
3428 options.echo_cancellation = rtc::Optional<bool>(true); 3422 options.echo_cancellation = rtc::Optional<bool>(true);
3429 3423
3430 rtc::scoped_ptr<FakeAudioSource> source(new FakeAudioSource()); 3424 std::unique_ptr<FakeAudioSource> source(new FakeAudioSource());
3431 session_->SetAudioSend(send_ssrc, false, options, source.get()); 3425 session_->SetAudioSend(send_ssrc, false, options, source.get());
3432 EXPECT_TRUE(channel->IsStreamMuted(send_ssrc)); 3426 EXPECT_TRUE(channel->IsStreamMuted(send_ssrc));
3433 EXPECT_EQ(rtc::Optional<bool>(), channel->options().echo_cancellation); 3427 EXPECT_EQ(rtc::Optional<bool>(), channel->options().echo_cancellation);
3434 EXPECT_TRUE(source->sink() != nullptr); 3428 EXPECT_TRUE(source->sink() != nullptr);
3435 3429
3436 // This will trigger SetSink(nullptr) to the |source|. 3430 // This will trigger SetSink(nullptr) to the |source|.
3437 session_->SetAudioSend(send_ssrc, true, options, nullptr); 3431 session_->SetAudioSend(send_ssrc, true, options, nullptr);
3438 EXPECT_FALSE(channel->IsStreamMuted(send_ssrc)); 3432 EXPECT_FALSE(channel->IsStreamMuted(send_ssrc));
3439 EXPECT_EQ(rtc::Optional<bool>(true), channel->options().echo_cancellation); 3433 EXPECT_EQ(rtc::Optional<bool>(true), channel->options().echo_cancellation);
3440 EXPECT_TRUE(source->sink() == nullptr); 3434 EXPECT_TRUE(source->sink() == nullptr);
3441 } 3435 }
3442 3436
3443 TEST_F(WebRtcSessionTest, AudioSourceForLocalStream) { 3437 TEST_F(WebRtcSessionTest, AudioSourceForLocalStream) {
3444 Init(); 3438 Init();
3445 SendAudioVideoStream1(); 3439 SendAudioVideoStream1();
3446 CreateAndSetRemoteOfferAndLocalAnswer(); 3440 CreateAndSetRemoteOfferAndLocalAnswer();
3447 cricket::FakeVoiceMediaChannel* channel = media_engine_->GetVoiceChannel(0); 3441 cricket::FakeVoiceMediaChannel* channel = media_engine_->GetVoiceChannel(0);
3448 ASSERT_TRUE(channel != NULL); 3442 ASSERT_TRUE(channel != NULL);
3449 ASSERT_EQ(1u, channel->send_streams().size()); 3443 ASSERT_EQ(1u, channel->send_streams().size());
3450 uint32_t send_ssrc = channel->send_streams()[0].first_ssrc(); 3444 uint32_t send_ssrc = channel->send_streams()[0].first_ssrc();
3451 3445
3452 rtc::scoped_ptr<FakeAudioSource> source(new FakeAudioSource()); 3446 std::unique_ptr<FakeAudioSource> source(new FakeAudioSource());
3453 cricket::AudioOptions options; 3447 cricket::AudioOptions options;
3454 session_->SetAudioSend(send_ssrc, true, options, source.get()); 3448 session_->SetAudioSend(send_ssrc, true, options, source.get());
3455 EXPECT_TRUE(source->sink() != nullptr); 3449 EXPECT_TRUE(source->sink() != nullptr);
3456 3450
3457 // Delete the |source| and it will trigger OnClose() to the sink, and this 3451 // Delete the |source| and it will trigger OnClose() to the sink, and this
3458 // will invalidate the |source_| pointer in the sink and prevent getting a 3452 // will invalidate the |source_| pointer in the sink and prevent getting a
3459 // SetSink(nullptr) callback afterwards. 3453 // SetSink(nullptr) callback afterwards.
3460 source.reset(); 3454 source.reset();
3461 3455
3462 // This will trigger SetSink(nullptr) if no OnClose() callback. 3456 // This will trigger SetSink(nullptr) if no OnClose() callback.
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
3582 SetLocalDescriptionWithoutError(answer); 3576 SetLocalDescriptionWithoutError(answer);
3583 EXPECT_FALSE(session_->initial_offerer()); 3577 EXPECT_FALSE(session_->initial_offerer());
3584 } 3578 }
3585 3579
3586 // Verifing local offer and remote answer have matching m-lines as per RFC 3264. 3580 // Verifing local offer and remote answer have matching m-lines as per RFC 3264.
3587 TEST_F(WebRtcSessionTest, TestIncorrectMLinesInRemoteAnswer) { 3581 TEST_F(WebRtcSessionTest, TestIncorrectMLinesInRemoteAnswer) {
3588 Init(); 3582 Init();
3589 SendAudioVideoStream1(); 3583 SendAudioVideoStream1();
3590 SessionDescriptionInterface* offer = CreateOffer(); 3584 SessionDescriptionInterface* offer = CreateOffer();
3591 SetLocalDescriptionWithoutError(offer); 3585 SetLocalDescriptionWithoutError(offer);
3592 rtc::scoped_ptr<SessionDescriptionInterface> answer( 3586 std::unique_ptr<SessionDescriptionInterface> answer(
3593 CreateRemoteAnswer(session_->local_description())); 3587 CreateRemoteAnswer(session_->local_description()));
3594 3588
3595 cricket::SessionDescription* answer_copy = answer->description()->Copy(); 3589 cricket::SessionDescription* answer_copy = answer->description()->Copy();
3596 answer_copy->RemoveContentByName("video"); 3590 answer_copy->RemoveContentByName("video");
3597 JsepSessionDescription* modified_answer = 3591 JsepSessionDescription* modified_answer =
3598 new JsepSessionDescription(JsepSessionDescription::kAnswer); 3592 new JsepSessionDescription(JsepSessionDescription::kAnswer);
3599 3593
3600 EXPECT_TRUE(modified_answer->Initialize(answer_copy, 3594 EXPECT_TRUE(modified_answer->Initialize(answer_copy,
3601 answer->session_id(), 3595 answer->session_id(),
3602 answer->session_version())); 3596 answer->session_version()));
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
3679 SessionDescriptionInterface* answer = CreateAnswer(); 3673 SessionDescriptionInterface* answer = CreateAnswer();
3680 SetLocalDescriptionWithoutError(answer); 3674 SetLocalDescriptionWithoutError(answer);
3681 EXPECT_TRUE_WAIT(observer_.oncandidatesready_, kIceCandidatesTimeout); 3675 EXPECT_TRUE_WAIT(observer_.oncandidatesready_, kIceCandidatesTimeout);
3682 } 3676 }
3683 3677
3684 // This test verifies that crypto parameter is updated in local session 3678 // This test verifies that crypto parameter is updated in local session
3685 // description as per security policy set in MediaSessionDescriptionFactory. 3679 // description as per security policy set in MediaSessionDescriptionFactory.
3686 TEST_F(WebRtcSessionTest, TestCryptoAfterSetLocalDescription) { 3680 TEST_F(WebRtcSessionTest, TestCryptoAfterSetLocalDescription) {
3687 Init(); 3681 Init();
3688 SendAudioVideoStream1(); 3682 SendAudioVideoStream1();
3689 rtc::scoped_ptr<SessionDescriptionInterface> offer(CreateOffer()); 3683 std::unique_ptr<SessionDescriptionInterface> offer(CreateOffer());
3690 3684
3691 // Making sure SetLocalDescription correctly sets crypto value in 3685 // Making sure SetLocalDescription correctly sets crypto value in
3692 // SessionDescription object after de-serialization of sdp string. The value 3686 // SessionDescription object after de-serialization of sdp string. The value
3693 // will be set as per MediaSessionDescriptionFactory. 3687 // will be set as per MediaSessionDescriptionFactory.
3694 std::string offer_str; 3688 std::string offer_str;
3695 offer->ToString(&offer_str); 3689 offer->ToString(&offer_str);
3696 SessionDescriptionInterface* jsep_offer_str = 3690 SessionDescriptionInterface* jsep_offer_str =
3697 CreateSessionDescription(JsepSessionDescription::kOffer, offer_str, NULL); 3691 CreateSessionDescription(JsepSessionDescription::kOffer, offer_str, NULL);
3698 SetLocalDescriptionWithoutError(jsep_offer_str); 3692 SetLocalDescriptionWithoutError(jsep_offer_str);
3699 EXPECT_TRUE(session_->voice_channel()->secure_required()); 3693 EXPECT_TRUE(session_->voice_channel()->secure_required());
3700 EXPECT_TRUE(session_->video_channel()->secure_required()); 3694 EXPECT_TRUE(session_->video_channel()->secure_required());
3701 } 3695 }
3702 3696
3703 // This test verifies the crypto parameter when security is disabled. 3697 // This test verifies the crypto parameter when security is disabled.
3704 TEST_F(WebRtcSessionTest, TestCryptoAfterSetLocalDescriptionWithDisabled) { 3698 TEST_F(WebRtcSessionTest, TestCryptoAfterSetLocalDescriptionWithDisabled) {
3705 options_.disable_encryption = true; 3699 options_.disable_encryption = true;
3706 Init(); 3700 Init();
3707 SendAudioVideoStream1(); 3701 SendAudioVideoStream1();
3708 rtc::scoped_ptr<SessionDescriptionInterface> offer(CreateOffer()); 3702 std::unique_ptr<SessionDescriptionInterface> offer(CreateOffer());
3709 3703
3710 // Making sure SetLocalDescription correctly sets crypto value in 3704 // Making sure SetLocalDescription correctly sets crypto value in
3711 // SessionDescription object after de-serialization of sdp string. The value 3705 // SessionDescription object after de-serialization of sdp string. The value
3712 // will be set as per MediaSessionDescriptionFactory. 3706 // will be set as per MediaSessionDescriptionFactory.
3713 std::string offer_str; 3707 std::string offer_str;
3714 offer->ToString(&offer_str); 3708 offer->ToString(&offer_str);
3715 SessionDescriptionInterface* jsep_offer_str = 3709 SessionDescriptionInterface* jsep_offer_str =
3716 CreateSessionDescription(JsepSessionDescription::kOffer, offer_str, NULL); 3710 CreateSessionDescription(JsepSessionDescription::kOffer, offer_str, NULL);
3717 SetLocalDescriptionWithoutError(jsep_offer_str); 3711 SetLocalDescriptionWithoutError(jsep_offer_str);
3718 EXPECT_FALSE(session_->voice_channel()->secure_required()); 3712 EXPECT_FALSE(session_->voice_channel()->secure_required());
3719 EXPECT_FALSE(session_->video_channel()->secure_required()); 3713 EXPECT_FALSE(session_->video_channel()->secure_required());
3720 } 3714 }
3721 3715
3722 // This test verifies that an answer contains new ufrag and password if an offer 3716 // This test verifies that an answer contains new ufrag and password if an offer
3723 // with new ufrag and password is received. 3717 // with new ufrag and password is received.
3724 TEST_F(WebRtcSessionTest, TestCreateAnswerWithNewUfragAndPassword) { 3718 TEST_F(WebRtcSessionTest, TestCreateAnswerWithNewUfragAndPassword) {
3725 Init(); 3719 Init();
3726 cricket::MediaSessionOptions options; 3720 cricket::MediaSessionOptions options;
3727 options.recv_video = true; 3721 options.recv_video = true;
3728 rtc::scoped_ptr<JsepSessionDescription> offer( 3722 std::unique_ptr<JsepSessionDescription> offer(CreateRemoteOffer(options));
3729 CreateRemoteOffer(options));
3730 SetRemoteDescriptionWithoutError(offer.release()); 3723 SetRemoteDescriptionWithoutError(offer.release());
3731 3724
3732 SendAudioVideoStream1(); 3725 SendAudioVideoStream1();
3733 rtc::scoped_ptr<SessionDescriptionInterface> answer(CreateAnswer()); 3726 std::unique_ptr<SessionDescriptionInterface> answer(CreateAnswer());
3734 SetLocalDescriptionWithoutError(answer.release()); 3727 SetLocalDescriptionWithoutError(answer.release());
3735 3728
3736 // Receive an offer with new ufrag and password. 3729 // Receive an offer with new ufrag and password.
3737 for (const cricket::ContentInfo& content : 3730 for (const cricket::ContentInfo& content :
3738 session_->local_description()->description()->contents()) { 3731 session_->local_description()->description()->contents()) {
3739 options.transport_options[content.name].ice_restart = true; 3732 options.transport_options[content.name].ice_restart = true;
3740 } 3733 }
3741 rtc::scoped_ptr<JsepSessionDescription> updated_offer1( 3734 std::unique_ptr<JsepSessionDescription> updated_offer1(
3742 CreateRemoteOffer(options, session_->remote_description())); 3735 CreateRemoteOffer(options, session_->remote_description()));
3743 SetRemoteDescriptionWithoutError(updated_offer1.release()); 3736 SetRemoteDescriptionWithoutError(updated_offer1.release());
3744 3737
3745 rtc::scoped_ptr<SessionDescriptionInterface> updated_answer1(CreateAnswer()); 3738 std::unique_ptr<SessionDescriptionInterface> updated_answer1(CreateAnswer());
3746 3739
3747 EXPECT_FALSE(IceUfragPwdEqual(updated_answer1->description(), 3740 EXPECT_FALSE(IceUfragPwdEqual(updated_answer1->description(),
3748 session_->local_description()->description())); 3741 session_->local_description()->description()));
3749 3742
3750 // Even a second answer (created before the description is set) should have 3743 // Even a second answer (created before the description is set) should have
3751 // a new ufrag/password. 3744 // a new ufrag/password.
3752 rtc::scoped_ptr<SessionDescriptionInterface> updated_answer2(CreateAnswer()); 3745 std::unique_ptr<SessionDescriptionInterface> updated_answer2(CreateAnswer());
3753 3746
3754 EXPECT_FALSE(IceUfragPwdEqual(updated_answer2->description(), 3747 EXPECT_FALSE(IceUfragPwdEqual(updated_answer2->description(),
3755 session_->local_description()->description())); 3748 session_->local_description()->description()));
3756 3749
3757 SetLocalDescriptionWithoutError(updated_answer2.release()); 3750 SetLocalDescriptionWithoutError(updated_answer2.release());
3758 } 3751 }
3759 3752
3760 // This test verifies that an answer contains new ufrag and password if an offer 3753 // This test verifies that an answer contains new ufrag and password if an offer
3761 // that changes either the ufrag or password (but not both) is received. 3754 // that changes either the ufrag or password (but not both) is received.
3762 // RFC 5245 says: "If the offer contained a change in the a=ice-ufrag or 3755 // RFC 5245 says: "If the offer contained a change in the a=ice-ufrag or
3763 // a=ice-pwd attributes compared to the previous SDP from the peer, it 3756 // a=ice-pwd attributes compared to the previous SDP from the peer, it
3764 // indicates that ICE is restarting for this media stream." 3757 // indicates that ICE is restarting for this media stream."
3765 TEST_F(WebRtcSessionTest, TestOfferChangingOnlyUfragOrPassword) { 3758 TEST_F(WebRtcSessionTest, TestOfferChangingOnlyUfragOrPassword) {
3766 Init(); 3759 Init();
3767 cricket::MediaSessionOptions options; 3760 cricket::MediaSessionOptions options;
3768 options.recv_audio = true; 3761 options.recv_audio = true;
3769 options.recv_video = true; 3762 options.recv_video = true;
3770 // Create an offer with audio and video. 3763 // Create an offer with audio and video.
3771 rtc::scoped_ptr<JsepSessionDescription> offer(CreateRemoteOffer(options)); 3764 std::unique_ptr<JsepSessionDescription> offer(CreateRemoteOffer(options));
3772 SetIceUfragPwd(offer.get(), "original_ufrag", "original_password12345"); 3765 SetIceUfragPwd(offer.get(), "original_ufrag", "original_password12345");
3773 SetRemoteDescriptionWithoutError(offer.release()); 3766 SetRemoteDescriptionWithoutError(offer.release());
3774 3767
3775 SendAudioVideoStream1(); 3768 SendAudioVideoStream1();
3776 rtc::scoped_ptr<SessionDescriptionInterface> answer(CreateAnswer()); 3769 std::unique_ptr<SessionDescriptionInterface> answer(CreateAnswer());
3777 SetLocalDescriptionWithoutError(answer.release()); 3770 SetLocalDescriptionWithoutError(answer.release());
3778 3771
3779 // Receive an offer with a new ufrag but stale password. 3772 // Receive an offer with a new ufrag but stale password.
3780 rtc::scoped_ptr<JsepSessionDescription> ufrag_changed_offer( 3773 std::unique_ptr<JsepSessionDescription> ufrag_changed_offer(
3781 CreateRemoteOffer(options, session_->remote_description())); 3774 CreateRemoteOffer(options, session_->remote_description()));
3782 SetIceUfragPwd(ufrag_changed_offer.get(), "modified_ufrag", 3775 SetIceUfragPwd(ufrag_changed_offer.get(), "modified_ufrag",
3783 "original_password12345"); 3776 "original_password12345");
3784 SetRemoteDescriptionWithoutError(ufrag_changed_offer.release()); 3777 SetRemoteDescriptionWithoutError(ufrag_changed_offer.release());
3785 3778
3786 rtc::scoped_ptr<SessionDescriptionInterface> updated_answer1(CreateAnswer()); 3779 std::unique_ptr<SessionDescriptionInterface> updated_answer1(CreateAnswer());
3787 EXPECT_FALSE(IceUfragPwdEqual(updated_answer1->description(), 3780 EXPECT_FALSE(IceUfragPwdEqual(updated_answer1->description(),
3788 session_->local_description()->description())); 3781 session_->local_description()->description()));
3789 SetLocalDescriptionWithoutError(updated_answer1.release()); 3782 SetLocalDescriptionWithoutError(updated_answer1.release());
3790 3783
3791 // Receive an offer with a new password but stale ufrag. 3784 // Receive an offer with a new password but stale ufrag.
3792 rtc::scoped_ptr<JsepSessionDescription> password_changed_offer( 3785 std::unique_ptr<JsepSessionDescription> password_changed_offer(
3793 CreateRemoteOffer(options, session_->remote_description())); 3786 CreateRemoteOffer(options, session_->remote_description()));
3794 SetIceUfragPwd(password_changed_offer.get(), "modified_ufrag", 3787 SetIceUfragPwd(password_changed_offer.get(), "modified_ufrag",
3795 "modified_password12345"); 3788 "modified_password12345");
3796 SetRemoteDescriptionWithoutError(password_changed_offer.release()); 3789 SetRemoteDescriptionWithoutError(password_changed_offer.release());
3797 3790
3798 rtc::scoped_ptr<SessionDescriptionInterface> updated_answer2(CreateAnswer()); 3791 std::unique_ptr<SessionDescriptionInterface> updated_answer2(CreateAnswer());
3799 EXPECT_FALSE(IceUfragPwdEqual(updated_answer2->description(), 3792 EXPECT_FALSE(IceUfragPwdEqual(updated_answer2->description(),
3800 session_->local_description()->description())); 3793 session_->local_description()->description()));
3801 SetLocalDescriptionWithoutError(updated_answer2.release()); 3794 SetLocalDescriptionWithoutError(updated_answer2.release());
3802 } 3795 }
3803 3796
3804 // This test verifies that an answer contains old ufrag and password if an offer 3797 // This test verifies that an answer contains old ufrag and password if an offer
3805 // with old ufrag and password is received. 3798 // with old ufrag and password is received.
3806 TEST_F(WebRtcSessionTest, TestCreateAnswerWithOldUfragAndPassword) { 3799 TEST_F(WebRtcSessionTest, TestCreateAnswerWithOldUfragAndPassword) {
3807 Init(); 3800 Init();
3808 cricket::MediaSessionOptions options; 3801 cricket::MediaSessionOptions options;
3809 options.recv_video = true; 3802 options.recv_video = true;
3810 rtc::scoped_ptr<JsepSessionDescription> offer( 3803 std::unique_ptr<JsepSessionDescription> offer(CreateRemoteOffer(options));
3811 CreateRemoteOffer(options));
3812 SetRemoteDescriptionWithoutError(offer.release()); 3804 SetRemoteDescriptionWithoutError(offer.release());
3813 3805
3814 SendAudioVideoStream1(); 3806 SendAudioVideoStream1();
3815 rtc::scoped_ptr<SessionDescriptionInterface> answer(CreateAnswer()); 3807 std::unique_ptr<SessionDescriptionInterface> answer(CreateAnswer());
3816 SetLocalDescriptionWithoutError(answer.release()); 3808 SetLocalDescriptionWithoutError(answer.release());
3817 3809
3818 // Receive an offer without changed ufrag or password. 3810 // Receive an offer without changed ufrag or password.
3819 rtc::scoped_ptr<JsepSessionDescription> updated_offer2( 3811 std::unique_ptr<JsepSessionDescription> updated_offer2(
3820 CreateRemoteOffer(options, session_->remote_description())); 3812 CreateRemoteOffer(options, session_->remote_description()));
3821 SetRemoteDescriptionWithoutError(updated_offer2.release()); 3813 SetRemoteDescriptionWithoutError(updated_offer2.release());
3822 3814
3823 rtc::scoped_ptr<SessionDescriptionInterface> updated_answer2(CreateAnswer()); 3815 std::unique_ptr<SessionDescriptionInterface> updated_answer2(CreateAnswer());
3824 3816
3825 EXPECT_TRUE(IceUfragPwdEqual(updated_answer2->description(), 3817 EXPECT_TRUE(IceUfragPwdEqual(updated_answer2->description(),
3826 session_->local_description()->description())); 3818 session_->local_description()->description()));
3827 3819
3828 SetLocalDescriptionWithoutError(updated_answer2.release()); 3820 SetLocalDescriptionWithoutError(updated_answer2.release());
3829 } 3821 }
3830 3822
3831 // This test verifies that if an offer does an ICE restart on some, but not all 3823 // This test verifies that if an offer does an ICE restart on some, but not all
3832 // media sections, the answer will change the ufrag/password in the correct 3824 // media sections, the answer will change the ufrag/password in the correct
3833 // media sections. 3825 // media sections.
3834 TEST_F(WebRtcSessionTest, TestCreateAnswerWithNewAndOldUfragAndPassword) { 3826 TEST_F(WebRtcSessionTest, TestCreateAnswerWithNewAndOldUfragAndPassword) {
3835 Init(); 3827 Init();
3836 cricket::MediaSessionOptions options; 3828 cricket::MediaSessionOptions options;
3837 options.recv_video = true; 3829 options.recv_video = true;
3838 options.recv_audio = true; 3830 options.recv_audio = true;
3839 options.bundle_enabled = false; 3831 options.bundle_enabled = false;
3840 rtc::scoped_ptr<JsepSessionDescription> offer(CreateRemoteOffer(options)); 3832 std::unique_ptr<JsepSessionDescription> offer(CreateRemoteOffer(options));
3841 3833
3842 SetIceUfragPwd(offer.get(), cricket::MEDIA_TYPE_AUDIO, "aaaa", 3834 SetIceUfragPwd(offer.get(), cricket::MEDIA_TYPE_AUDIO, "aaaa",
3843 "aaaaaaaaaaaaaaaaaaaaaa"); 3835 "aaaaaaaaaaaaaaaaaaaaaa");
3844 SetIceUfragPwd(offer.get(), cricket::MEDIA_TYPE_VIDEO, "bbbb", 3836 SetIceUfragPwd(offer.get(), cricket::MEDIA_TYPE_VIDEO, "bbbb",
3845 "bbbbbbbbbbbbbbbbbbbbbb"); 3837 "bbbbbbbbbbbbbbbbbbbbbb");
3846 SetRemoteDescriptionWithoutError(offer.release()); 3838 SetRemoteDescriptionWithoutError(offer.release());
3847 3839
3848 SendAudioVideoStream1(); 3840 SendAudioVideoStream1();
3849 rtc::scoped_ptr<SessionDescriptionInterface> answer(CreateAnswer()); 3841 std::unique_ptr<SessionDescriptionInterface> answer(CreateAnswer());
3850 SetLocalDescriptionWithoutError(answer.release()); 3842 SetLocalDescriptionWithoutError(answer.release());
3851 3843
3852 // Receive an offer with new ufrag and password, but only for the video media 3844 // Receive an offer with new ufrag and password, but only for the video media
3853 // section. 3845 // section.
3854 rtc::scoped_ptr<JsepSessionDescription> updated_offer( 3846 std::unique_ptr<JsepSessionDescription> updated_offer(
3855 CreateRemoteOffer(options, session_->remote_description())); 3847 CreateRemoteOffer(options, session_->remote_description()));
3856 SetIceUfragPwd(updated_offer.get(), cricket::MEDIA_TYPE_VIDEO, "cccc", 3848 SetIceUfragPwd(updated_offer.get(), cricket::MEDIA_TYPE_VIDEO, "cccc",
3857 "cccccccccccccccccccccc"); 3849 "cccccccccccccccccccccc");
3858 SetRemoteDescriptionWithoutError(updated_offer.release()); 3850 SetRemoteDescriptionWithoutError(updated_offer.release());
3859 3851
3860 rtc::scoped_ptr<SessionDescriptionInterface> updated_answer(CreateAnswer()); 3852 std::unique_ptr<SessionDescriptionInterface> updated_answer(CreateAnswer());
3861 3853
3862 EXPECT_TRUE(IceUfragPwdEqual(updated_answer->description(), 3854 EXPECT_TRUE(IceUfragPwdEqual(updated_answer->description(),
3863 session_->local_description()->description(), 3855 session_->local_description()->description(),
3864 cricket::MEDIA_TYPE_AUDIO)); 3856 cricket::MEDIA_TYPE_AUDIO));
3865 3857
3866 EXPECT_FALSE(IceUfragPwdEqual(updated_answer->description(), 3858 EXPECT_FALSE(IceUfragPwdEqual(updated_answer->description(),
3867 session_->local_description()->description(), 3859 session_->local_description()->description(),
3868 cricket::MEDIA_TYPE_VIDEO)); 3860 cricket::MEDIA_TYPE_VIDEO));
3869 3861
3870 SetLocalDescriptionWithoutError(updated_answer.release()); 3862 SetLocalDescriptionWithoutError(updated_answer.release());
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
3943 3935
3944 SetLocalDescriptionWithDataChannel(); 3936 SetLocalDescriptionWithDataChannel();
3945 EXPECT_EQ(cricket::DCT_RTP, data_engine_->last_channel_type()); 3937 EXPECT_EQ(cricket::DCT_RTP, data_engine_->last_channel_type());
3946 } 3938 }
3947 3939
3948 TEST_P(WebRtcSessionTest, TestCreateOfferWithSctpEnabledWithoutStreams) { 3940 TEST_P(WebRtcSessionTest, TestCreateOfferWithSctpEnabledWithoutStreams) {
3949 MAYBE_SKIP_TEST(rtc::SSLStreamAdapter::HaveDtlsSrtp); 3941 MAYBE_SKIP_TEST(rtc::SSLStreamAdapter::HaveDtlsSrtp);
3950 3942
3951 InitWithDtls(GetParam()); 3943 InitWithDtls(GetParam());
3952 3944
3953 rtc::scoped_ptr<SessionDescriptionInterface> offer(CreateOffer()); 3945 std::unique_ptr<SessionDescriptionInterface> offer(CreateOffer());
3954 EXPECT_TRUE(offer->description()->GetContentByName("data") == NULL); 3946 EXPECT_TRUE(offer->description()->GetContentByName("data") == NULL);
3955 EXPECT_TRUE(offer->description()->GetTransportInfoByName("data") == NULL); 3947 EXPECT_TRUE(offer->description()->GetTransportInfoByName("data") == NULL);
3956 } 3948 }
3957 3949
3958 TEST_P(WebRtcSessionTest, TestCreateAnswerWithSctpInOfferAndNoStreams) { 3950 TEST_P(WebRtcSessionTest, TestCreateAnswerWithSctpInOfferAndNoStreams) {
3959 MAYBE_SKIP_TEST(rtc::SSLStreamAdapter::HaveDtlsSrtp); 3951 MAYBE_SKIP_TEST(rtc::SSLStreamAdapter::HaveDtlsSrtp);
3960 SetFactoryDtlsSrtp(); 3952 SetFactoryDtlsSrtp();
3961 InitWithDtls(GetParam()); 3953 InitWithDtls(GetParam());
3962 3954
3963 // Create remote offer with SCTP. 3955 // Create remote offer with SCTP.
3964 cricket::MediaSessionOptions options; 3956 cricket::MediaSessionOptions options;
3965 options.data_channel_type = cricket::DCT_SCTP; 3957 options.data_channel_type = cricket::DCT_SCTP;
3966 JsepSessionDescription* offer = 3958 JsepSessionDescription* offer =
3967 CreateRemoteOffer(options, cricket::SEC_DISABLED); 3959 CreateRemoteOffer(options, cricket::SEC_DISABLED);
3968 SetRemoteDescriptionWithoutError(offer); 3960 SetRemoteDescriptionWithoutError(offer);
3969 3961
3970 // Verifies the answer contains SCTP. 3962 // Verifies the answer contains SCTP.
3971 rtc::scoped_ptr<SessionDescriptionInterface> answer(CreateAnswer()); 3963 std::unique_ptr<SessionDescriptionInterface> answer(CreateAnswer());
3972 EXPECT_TRUE(answer != NULL); 3964 EXPECT_TRUE(answer != NULL);
3973 EXPECT_TRUE(answer->description()->GetContentByName("data") != NULL); 3965 EXPECT_TRUE(answer->description()->GetContentByName("data") != NULL);
3974 EXPECT_TRUE(answer->description()->GetTransportInfoByName("data") != NULL); 3966 EXPECT_TRUE(answer->description()->GetTransportInfoByName("data") != NULL);
3975 } 3967 }
3976 3968
3977 TEST_P(WebRtcSessionTest, TestSctpDataChannelWithoutDtls) { 3969 TEST_P(WebRtcSessionTest, TestSctpDataChannelWithoutDtls) {
3978 configuration_.enable_dtls_srtp = rtc::Optional<bool>(false); 3970 configuration_.enable_dtls_srtp = rtc::Optional<bool>(false);
3979 InitWithDtls(GetParam()); 3971 InitWithDtls(GetParam());
3980 3972
3981 SetLocalDescriptionWithDataChannel(); 3973 SetLocalDescriptionWithDataChannel();
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
4093 4085
4094 // Verifies that CreateOffer succeeds when CreateOffer is called before async 4086 // Verifies that CreateOffer succeeds when CreateOffer is called before async
4095 // identity generation is finished (even if a certificate is provided this is 4087 // identity generation is finished (even if a certificate is provided this is
4096 // an async op). 4088 // an async op).
4097 TEST_P(WebRtcSessionTest, TestCreateOfferBeforeIdentityRequestReturnSuccess) { 4089 TEST_P(WebRtcSessionTest, TestCreateOfferBeforeIdentityRequestReturnSuccess) {
4098 MAYBE_SKIP_TEST(rtc::SSLStreamAdapter::HaveDtlsSrtp); 4090 MAYBE_SKIP_TEST(rtc::SSLStreamAdapter::HaveDtlsSrtp);
4099 InitWithDtls(GetParam()); 4091 InitWithDtls(GetParam());
4100 4092
4101 EXPECT_TRUE(session_->waiting_for_certificate_for_testing()); 4093 EXPECT_TRUE(session_->waiting_for_certificate_for_testing());
4102 SendAudioVideoStream1(); 4094 SendAudioVideoStream1();
4103 rtc::scoped_ptr<SessionDescriptionInterface> offer(CreateOffer()); 4095 std::unique_ptr<SessionDescriptionInterface> offer(CreateOffer());
4104 4096
4105 EXPECT_TRUE(offer != NULL); 4097 EXPECT_TRUE(offer != NULL);
4106 VerifyNoCryptoParams(offer->description(), true); 4098 VerifyNoCryptoParams(offer->description(), true);
4107 VerifyFingerprintStatus(offer->description(), true); 4099 VerifyFingerprintStatus(offer->description(), true);
4108 } 4100 }
4109 4101
4110 // Verifies that CreateAnswer succeeds when CreateOffer is called before async 4102 // Verifies that CreateAnswer succeeds when CreateOffer is called before async
4111 // identity generation is finished (even if a certificate is provided this is 4103 // identity generation is finished (even if a certificate is provided this is
4112 // an async op). 4104 // an async op).
4113 TEST_P(WebRtcSessionTest, TestCreateAnswerBeforeIdentityRequestReturnSuccess) { 4105 TEST_P(WebRtcSessionTest, TestCreateAnswerBeforeIdentityRequestReturnSuccess) {
4114 MAYBE_SKIP_TEST(rtc::SSLStreamAdapter::HaveDtlsSrtp); 4106 MAYBE_SKIP_TEST(rtc::SSLStreamAdapter::HaveDtlsSrtp);
4115 InitWithDtls(GetParam()); 4107 InitWithDtls(GetParam());
4116 SetFactoryDtlsSrtp(); 4108 SetFactoryDtlsSrtp();
4117 4109
4118 cricket::MediaSessionOptions options; 4110 cricket::MediaSessionOptions options;
4119 options.recv_video = true; 4111 options.recv_video = true;
4120 scoped_ptr<JsepSessionDescription> offer( 4112 std::unique_ptr<JsepSessionDescription> offer(
4121 CreateRemoteOffer(options, cricket::SEC_DISABLED)); 4113 CreateRemoteOffer(options, cricket::SEC_DISABLED));
4122 ASSERT_TRUE(offer.get() != NULL); 4114 ASSERT_TRUE(offer.get() != NULL);
4123 SetRemoteDescriptionWithoutError(offer.release()); 4115 SetRemoteDescriptionWithoutError(offer.release());
4124 4116
4125 rtc::scoped_ptr<SessionDescriptionInterface> answer(CreateAnswer()); 4117 std::unique_ptr<SessionDescriptionInterface> answer(CreateAnswer());
4126 EXPECT_TRUE(answer != NULL); 4118 EXPECT_TRUE(answer != NULL);
4127 VerifyNoCryptoParams(answer->description(), true); 4119 VerifyNoCryptoParams(answer->description(), true);
4128 VerifyFingerprintStatus(answer->description(), true); 4120 VerifyFingerprintStatus(answer->description(), true);
4129 } 4121 }
4130 4122
4131 // Verifies that CreateOffer succeeds when CreateOffer is called after async 4123 // Verifies that CreateOffer succeeds when CreateOffer is called after async
4132 // identity generation is finished (even if a certificate is provided this is 4124 // identity generation is finished (even if a certificate is provided this is
4133 // an async op). 4125 // an async op).
4134 TEST_P(WebRtcSessionTest, TestCreateOfferAfterIdentityRequestReturnSuccess) { 4126 TEST_P(WebRtcSessionTest, TestCreateOfferAfterIdentityRequestReturnSuccess) {
4135 MAYBE_SKIP_TEST(rtc::SSLStreamAdapter::HaveDtlsSrtp); 4127 MAYBE_SKIP_TEST(rtc::SSLStreamAdapter::HaveDtlsSrtp);
4136 InitWithDtls(GetParam()); 4128 InitWithDtls(GetParam());
4137 4129
4138 EXPECT_TRUE_WAIT(!session_->waiting_for_certificate_for_testing(), 1000); 4130 EXPECT_TRUE_WAIT(!session_->waiting_for_certificate_for_testing(), 1000);
4139 4131
4140 rtc::scoped_ptr<SessionDescriptionInterface> offer(CreateOffer()); 4132 std::unique_ptr<SessionDescriptionInterface> offer(CreateOffer());
4141 EXPECT_TRUE(offer != NULL); 4133 EXPECT_TRUE(offer != NULL);
4142 } 4134 }
4143 4135
4144 // Verifies that CreateOffer fails when CreateOffer is called after async 4136 // Verifies that CreateOffer fails when CreateOffer is called after async
4145 // identity generation fails. 4137 // identity generation fails.
4146 TEST_F(WebRtcSessionTest, TestCreateOfferAfterIdentityRequestReturnFailure) { 4138 TEST_F(WebRtcSessionTest, TestCreateOfferAfterIdentityRequestReturnFailure) {
4147 MAYBE_SKIP_TEST(rtc::SSLStreamAdapter::HaveDtlsSrtp); 4139 MAYBE_SKIP_TEST(rtc::SSLStreamAdapter::HaveDtlsSrtp);
4148 InitWithDtlsIdentityGenFail(); 4140 InitWithDtlsIdentityGenFail();
4149 4141
4150 EXPECT_TRUE_WAIT(!session_->waiting_for_certificate_for_testing(), 1000); 4142 EXPECT_TRUE_WAIT(!session_->waiting_for_certificate_for_testing(), 1000);
4151 4143
4152 rtc::scoped_ptr<SessionDescriptionInterface> offer(CreateOffer()); 4144 std::unique_ptr<SessionDescriptionInterface> offer(CreateOffer());
4153 EXPECT_TRUE(offer == NULL); 4145 EXPECT_TRUE(offer == NULL);
4154 } 4146 }
4155 4147
4156 // Verifies that CreateOffer succeeds when Multiple CreateOffer calls are made 4148 // Verifies that CreateOffer succeeds when Multiple CreateOffer calls are made
4157 // before async identity generation is finished. 4149 // before async identity generation is finished.
4158 TEST_P(WebRtcSessionTest, 4150 TEST_P(WebRtcSessionTest,
4159 TestMultipleCreateOfferBeforeIdentityRequestReturnSuccess) { 4151 TestMultipleCreateOfferBeforeIdentityRequestReturnSuccess) {
4160 MAYBE_SKIP_TEST(rtc::SSLStreamAdapter::HaveDtlsSrtp); 4152 MAYBE_SKIP_TEST(rtc::SSLStreamAdapter::HaveDtlsSrtp);
4161 VerifyMultipleAsyncCreateDescription(GetParam(), 4153 VerifyMultipleAsyncCreateDescription(GetParam(),
4162 CreateSessionDescriptionRequest::kOffer); 4154 CreateSessionDescriptionRequest::kOffer);
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after
4404 } 4396 }
4405 4397
4406 // TODO(bemasc): Add a TestIceStatesBundle with BUNDLE enabled. That test 4398 // TODO(bemasc): Add a TestIceStatesBundle with BUNDLE enabled. That test
4407 // currently fails because upon disconnection and reconnection OnIceComplete is 4399 // currently fails because upon disconnection and reconnection OnIceComplete is
4408 // called more than once without returning to IceGatheringGathering. 4400 // called more than once without returning to IceGatheringGathering.
4409 4401
4410 INSTANTIATE_TEST_CASE_P(WebRtcSessionTests, 4402 INSTANTIATE_TEST_CASE_P(WebRtcSessionTests,
4411 WebRtcSessionTest, 4403 WebRtcSessionTest,
4412 testing::Values(ALREADY_GENERATED, 4404 testing::Values(ALREADY_GENERATED,
4413 DTLS_IDENTITY_STORE)); 4405 DTLS_IDENTITY_STORE));
OLDNEW
« no previous file with comments | « webrtc/api/webrtcsession.cc ('k') | webrtc/api/webrtcsessiondescriptionfactory.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698