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

Side by Side Diff: talk/app/webrtc/webrtcsession_unittest.cc

Issue 1403633005: Revert of Moving MediaStreamSignaling logic into PeerConnection. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 5 years, 2 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 | « talk/app/webrtc/webrtcsession.cc ('k') | talk/app/webrtc/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 * libjingle 2 * libjingle
3 * Copyright 2012 Google Inc. 3 * Copyright 2012 Google Inc.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met: 6 * modification, are permitted provided that the following conditions are met:
7 * 7 *
8 * 1. Redistributions of source code must retain the above copyright notice, 8 * 1. Redistributions of source code must retain the above copyright notice,
9 * this list of conditions and the following disclaimer. 9 * this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright notice, 10 * 2. Redistributions in binary form must reproduce the above copyright notice,
(...skipping 13 matching lines...) Expand all
24 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 24 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
25 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */ 26 */
27 27
28 #include <vector> 28 #include <vector>
29 29
30 #include "talk/app/webrtc/audiotrack.h" 30 #include "talk/app/webrtc/audiotrack.h"
31 #include "talk/app/webrtc/fakemetricsobserver.h" 31 #include "talk/app/webrtc/fakemetricsobserver.h"
32 #include "talk/app/webrtc/jsepicecandidate.h" 32 #include "talk/app/webrtc/jsepicecandidate.h"
33 #include "talk/app/webrtc/jsepsessiondescription.h" 33 #include "talk/app/webrtc/jsepsessiondescription.h"
34 #include "talk/app/webrtc/peerconnection.h"
35 #include "talk/app/webrtc/mediastreamsignaling.h" 34 #include "talk/app/webrtc/mediastreamsignaling.h"
36 #include "talk/app/webrtc/sctputils.h"
37 #include "talk/app/webrtc/streamcollection.h"
38 #include "talk/app/webrtc/streamcollection.h" 35 #include "talk/app/webrtc/streamcollection.h"
39 #include "talk/app/webrtc/test/fakeconstraints.h" 36 #include "talk/app/webrtc/test/fakeconstraints.h"
40 #include "talk/app/webrtc/test/fakedtlsidentitystore.h" 37 #include "talk/app/webrtc/test/fakedtlsidentitystore.h"
38 #include "talk/app/webrtc/test/fakemediastreamsignaling.h"
41 #include "talk/app/webrtc/videotrack.h" 39 #include "talk/app/webrtc/videotrack.h"
42 #include "talk/app/webrtc/webrtcsession.h" 40 #include "talk/app/webrtc/webrtcsession.h"
43 #include "talk/app/webrtc/webrtcsessiondescriptionfactory.h" 41 #include "talk/app/webrtc/webrtcsessiondescriptionfactory.h"
44 #include "talk/media/base/fakemediaengine.h" 42 #include "talk/media/base/fakemediaengine.h"
45 #include "talk/media/base/fakevideorenderer.h" 43 #include "talk/media/base/fakevideorenderer.h"
46 #include "talk/media/base/mediachannel.h" 44 #include "talk/media/base/mediachannel.h"
47 #include "webrtc/p2p/base/stunserver.h" 45 #include "webrtc/p2p/base/stunserver.h"
48 #include "webrtc/p2p/base/teststunserver.h" 46 #include "webrtc/p2p/base/teststunserver.h"
49 #include "webrtc/p2p/base/testturnserver.h" 47 #include "webrtc/p2p/base/testturnserver.h"
50 #include "webrtc/p2p/base/transportchannel.h" 48 #include "webrtc/p2p/base/transportchannel.h"
(...skipping 23 matching lines...) Expand all
74 using cricket::DF_PLAY; 72 using cricket::DF_PLAY;
75 using cricket::DF_SEND; 73 using cricket::DF_SEND;
76 using cricket::FakeVoiceMediaChannel; 74 using cricket::FakeVoiceMediaChannel;
77 using cricket::TransportInfo; 75 using cricket::TransportInfo;
78 using rtc::SocketAddress; 76 using rtc::SocketAddress;
79 using rtc::scoped_ptr; 77 using rtc::scoped_ptr;
80 using rtc::Thread; 78 using rtc::Thread;
81 using webrtc::CreateSessionDescription; 79 using webrtc::CreateSessionDescription;
82 using webrtc::CreateSessionDescriptionObserver; 80 using webrtc::CreateSessionDescriptionObserver;
83 using webrtc::CreateSessionDescriptionRequest; 81 using webrtc::CreateSessionDescriptionRequest;
84 using webrtc::DataChannel;
85 using webrtc::DtlsIdentityStoreInterface; 82 using webrtc::DtlsIdentityStoreInterface;
86 using webrtc::FakeConstraints; 83 using webrtc::FakeConstraints;
87 using webrtc::FakeMetricsObserver; 84 using webrtc::FakeMetricsObserver;
88 using webrtc::IceCandidateCollection; 85 using webrtc::IceCandidateCollection;
89 using webrtc::InternalDataChannelInit;
90 using webrtc::JsepIceCandidate; 86 using webrtc::JsepIceCandidate;
91 using webrtc::JsepSessionDescription; 87 using webrtc::JsepSessionDescription;
92 using webrtc::PeerConnectionFactoryInterface; 88 using webrtc::PeerConnectionFactoryInterface;
93 using webrtc::PeerConnectionInterface; 89 using webrtc::PeerConnectionInterface;
94 using webrtc::SessionDescriptionInterface; 90 using webrtc::SessionDescriptionInterface;
95 using webrtc::StreamCollection; 91 using webrtc::StreamCollection;
96 using webrtc::WebRtcSession; 92 using webrtc::WebRtcSession;
97 using webrtc::kBundleWithoutRtcpMux; 93 using webrtc::kBundleWithoutRtcpMux;
98 using webrtc::kCreateChannelFailed; 94 using webrtc::kCreateChannelFailed;
99 using webrtc::kInvalidSdp; 95 using webrtc::kInvalidSdp;
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 "a=ice-pwd:cMvOlFvQ6ochez1ZOoC2uBEC\r\n" 150 "a=ice-pwd:cMvOlFvQ6ochez1ZOoC2uBEC\r\n"
155 "a=mid:video\r\n" 151 "a=mid:video\r\n"
156 "a=sendrecv\r\n" 152 "a=sendrecv\r\n"
157 "a=rtcp-mux\r\n" 153 "a=rtcp-mux\r\n"
158 "a=crypto:1 AES_CM_128_HMAC_SHA1_80 " 154 "a=crypto:1 AES_CM_128_HMAC_SHA1_80 "
159 "inline:5/4N5CDvMiyDArHtBByUM71VIkguH17ZNoX60GrA\r\n" 155 "inline:5/4N5CDvMiyDArHtBByUM71VIkguH17ZNoX60GrA\r\n"
160 "a=rtpmap:0 fake_video_codec/90000\r\n" 156 "a=rtpmap:0 fake_video_codec/90000\r\n"
161 "a=rtpmap:96 rtx/90000\r\n" 157 "a=rtpmap:96 rtx/90000\r\n"
162 "a=fmtp:96 apt=0\r\n"; 158 "a=fmtp:96 apt=0\r\n";
163 159
164 static const char kStream1[] = "stream1";
165 static const char kVideoTrack1[] = "video1";
166 static const char kAudioTrack1[] = "audio1";
167
168 static const char kStream2[] = "stream2";
169 static const char kVideoTrack2[] = "video2";
170 static const char kAudioTrack2[] = "audio2";
171
172 enum RTCCertificateGenerationMethod { ALREADY_GENERATED, DTLS_IDENTITY_STORE }; 160 enum RTCCertificateGenerationMethod { ALREADY_GENERATED, DTLS_IDENTITY_STORE };
173 161
174 // Add some extra |newlines| to the |message| after |line|. 162 // Add some extra |newlines| to the |message| after |line|.
175 static void InjectAfter(const std::string& line, 163 static void InjectAfter(const std::string& line,
176 const std::string& newlines, 164 const std::string& newlines,
177 std::string* message) { 165 std::string* message) {
178 const std::string tmp = line + newlines; 166 const std::string tmp = line + newlines;
179 rtc::replace_substrs(line.c_str(), line.length(), tmp.c_str(), tmp.length(), 167 rtc::replace_substrs(line.c_str(), line.length(), tmp.c_str(), tmp.length(),
180 message); 168 message);
181 } 169 }
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
242 PeerConnectionInterface::IceConnectionState ice_connection_state_; 230 PeerConnectionInterface::IceConnectionState ice_connection_state_;
243 PeerConnectionInterface::IceGatheringState ice_gathering_state_; 231 PeerConnectionInterface::IceGatheringState ice_gathering_state_;
244 }; 232 };
245 233
246 class WebRtcSessionForTest : public webrtc::WebRtcSession { 234 class WebRtcSessionForTest : public webrtc::WebRtcSession {
247 public: 235 public:
248 WebRtcSessionForTest(cricket::ChannelManager* cmgr, 236 WebRtcSessionForTest(cricket::ChannelManager* cmgr,
249 rtc::Thread* signaling_thread, 237 rtc::Thread* signaling_thread,
250 rtc::Thread* worker_thread, 238 rtc::Thread* worker_thread,
251 cricket::PortAllocator* port_allocator, 239 cricket::PortAllocator* port_allocator,
252 webrtc::IceObserver* ice_observer) 240 webrtc::IceObserver* ice_observer,
253 : WebRtcSession(cmgr, signaling_thread, worker_thread, port_allocator) { 241 webrtc::MediaStreamSignaling* mediastream_signaling)
242 : WebRtcSession(cmgr, signaling_thread, worker_thread, port_allocator,
243 mediastream_signaling) {
254 RegisterIceObserver(ice_observer); 244 RegisterIceObserver(ice_observer);
255 } 245 }
256 virtual ~WebRtcSessionForTest() {} 246 virtual ~WebRtcSessionForTest() {}
257 247
258 // Note that these methods are only safe to use if the signaling thread 248 // Note that these methods are only safe to use if the signaling thread
259 // is the same as the worker thread 249 // is the same as the worker thread
260 cricket::TransportChannel* voice_rtp_transport_channel() { 250 cricket::TransportChannel* voice_rtp_transport_channel() {
261 return rtp_transport_channel(voice_channel()); 251 return rtp_transport_channel(voice_channel());
262 } 252 }
263 253
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
347 } 337 }
348 338
349 void SetSink(Sink* sink) override { sink_ = sink; } 339 void SetSink(Sink* sink) override { sink_ = sink; }
350 340
351 cricket::AudioRenderer::Sink* sink() const { return sink_; } 341 cricket::AudioRenderer::Sink* sink() const { return sink_; }
352 private: 342 private:
353 cricket::AudioRenderer::Sink* sink_; 343 cricket::AudioRenderer::Sink* sink_;
354 }; 344 };
355 345
356 class WebRtcSessionTest 346 class WebRtcSessionTest
357 : public testing::TestWithParam<RTCCertificateGenerationMethod>, 347 : public testing::TestWithParam<RTCCertificateGenerationMethod> {
358 public sigslot::has_slots<> {
359 protected: 348 protected:
360 // TODO Investigate why ChannelManager crashes, if it's created 349 // TODO Investigate why ChannelManager crashes, if it's created
361 // after stun_server. 350 // after stun_server.
362 WebRtcSessionTest() 351 WebRtcSessionTest()
363 : media_engine_(new cricket::FakeMediaEngine()), 352 : media_engine_(new cricket::FakeMediaEngine()),
364 data_engine_(new cricket::FakeDataEngine()), 353 data_engine_(new cricket::FakeDataEngine()),
365 channel_manager_(new cricket::ChannelManager( 354 channel_manager_(new cricket::ChannelManager(
366 media_engine_, data_engine_, new cricket::CaptureManager(), 355 media_engine_, data_engine_, new cricket::CaptureManager(),
367 rtc::Thread::Current())), 356 rtc::Thread::Current())),
368 tdesc_factory_(new cricket::TransportDescriptionFactory()), 357 tdesc_factory_(new cricket::TransportDescriptionFactory()),
369 desc_factory_(new cricket::MediaSessionDescriptionFactory( 358 desc_factory_(new cricket::MediaSessionDescriptionFactory(
370 channel_manager_.get(), tdesc_factory_.get())), 359 channel_manager_.get(), tdesc_factory_.get())),
371 pss_(new rtc::PhysicalSocketServer), 360 pss_(new rtc::PhysicalSocketServer),
372 vss_(new rtc::VirtualSocketServer(pss_.get())), 361 vss_(new rtc::VirtualSocketServer(pss_.get())),
373 fss_(new rtc::FirewallSocketServer(vss_.get())), 362 fss_(new rtc::FirewallSocketServer(vss_.get())),
374 ss_scope_(fss_.get()), 363 ss_scope_(fss_.get()),
375 stun_socket_addr_(rtc::SocketAddress(kStunAddrHost, 364 stun_socket_addr_(rtc::SocketAddress(kStunAddrHost,
376 cricket::STUN_SERVER_PORT)), 365 cricket::STUN_SERVER_PORT)),
377 stun_server_(cricket::TestStunServer::Create(Thread::Current(), 366 stun_server_(cricket::TestStunServer::Create(Thread::Current(),
378 stun_socket_addr_)), 367 stun_socket_addr_)),
379 turn_server_(Thread::Current(), kTurnUdpIntAddr, kTurnUdpExtAddr), 368 turn_server_(Thread::Current(), kTurnUdpIntAddr, kTurnUdpExtAddr),
369 mediastream_signaling_(channel_manager_.get()),
380 metrics_observer_(new rtc::RefCountedObject<FakeMetricsObserver>()) { 370 metrics_observer_(new rtc::RefCountedObject<FakeMetricsObserver>()) {
381 cricket::ServerAddresses stun_servers; 371 cricket::ServerAddresses stun_servers;
382 stun_servers.insert(stun_socket_addr_); 372 stun_servers.insert(stun_socket_addr_);
383 allocator_.reset(new cricket::BasicPortAllocator( 373 allocator_.reset(new cricket::BasicPortAllocator(
384 &network_manager_, 374 &network_manager_,
385 stun_servers, 375 stun_servers,
386 SocketAddress(), SocketAddress(), SocketAddress())); 376 SocketAddress(), SocketAddress(), SocketAddress()));
387 allocator_->set_flags(cricket::PORTALLOCATOR_DISABLE_TCP | 377 allocator_->set_flags(cricket::PORTALLOCATOR_DISABLE_TCP |
388 cricket::PORTALLOCATOR_DISABLE_RELAY); 378 cricket::PORTALLOCATOR_DISABLE_RELAY);
389 EXPECT_TRUE(channel_manager_->Init()); 379 EXPECT_TRUE(channel_manager_->Init());
390 desc_factory_->set_add_legacy_streams(false); 380 desc_factory_->set_add_legacy_streams(false);
391 allocator_->set_step_delay(cricket::kMinimumStepDelay); 381 allocator_->set_step_delay(cricket::kMinimumStepDelay);
392 } 382 }
393 383
394 void AddInterface(const SocketAddress& addr) { 384 void AddInterface(const SocketAddress& addr) {
395 network_manager_.AddInterface(addr); 385 network_manager_.AddInterface(addr);
396 } 386 }
397 387
398 // If |dtls_identity_store| != null or |rtc_configuration| contains 388 // If |dtls_identity_store| != null or |rtc_configuration| contains
399 // |certificates| then DTLS will be enabled unless explicitly disabled by 389 // |certificates| then DTLS will be enabled unless explicitly disabled by
400 // |rtc_configuration| options. When DTLS is enabled a certificate will be 390 // |rtc_configuration| options. When DTLS is enabled a certificate will be
401 // used if provided, otherwise one will be generated using the 391 // used if provided, otherwise one will be generated using the
402 // |dtls_identity_store|. 392 // |dtls_identity_store|.
403 void Init( 393 void Init(
404 rtc::scoped_ptr<webrtc::DtlsIdentityStoreInterface> dtls_identity_store, 394 rtc::scoped_ptr<webrtc::DtlsIdentityStoreInterface> dtls_identity_store,
405 const PeerConnectionInterface::RTCConfiguration& rtc_configuration) { 395 const PeerConnectionInterface::RTCConfiguration& rtc_configuration) {
406 ASSERT_TRUE(session_.get() == NULL); 396 ASSERT_TRUE(session_.get() == NULL);
407 session_.reset(new WebRtcSessionForTest( 397 session_.reset(new WebRtcSessionForTest(
408 channel_manager_.get(), rtc::Thread::Current(), rtc::Thread::Current(), 398 channel_manager_.get(), rtc::Thread::Current(),
409 allocator_.get(), &observer_)); 399 rtc::Thread::Current(), allocator_.get(),
410 session_->SignalDataChannelOpenMessage.connect( 400 &observer_,
411 this, &WebRtcSessionTest::OnDataChannelOpenMessage); 401 &mediastream_signaling_));
412 402
413 EXPECT_EQ(PeerConnectionInterface::kIceConnectionNew, 403 EXPECT_EQ(PeerConnectionInterface::kIceConnectionNew,
414 observer_.ice_connection_state_); 404 observer_.ice_connection_state_);
415 EXPECT_EQ(PeerConnectionInterface::kIceGatheringNew, 405 EXPECT_EQ(PeerConnectionInterface::kIceGatheringNew,
416 observer_.ice_gathering_state_); 406 observer_.ice_gathering_state_);
417 407
418 EXPECT_TRUE(session_->Initialize(options_, constraints_.get(), 408 EXPECT_TRUE(session_->Initialize(options_, constraints_.get(),
419 dtls_identity_store.Pass(), 409 dtls_identity_store.Pass(),
420 rtc_configuration)); 410 rtc_configuration));
421 session_->set_metrics_observer(metrics_observer_); 411 session_->set_metrics_observer(metrics_observer_);
422 } 412 }
423 413
424 void OnDataChannelOpenMessage(const std::string& label,
425 const InternalDataChannelInit& config) {
426 last_data_channel_label_ = label;
427 last_data_channel_config_ = config;
428 }
429
430 void Init() { 414 void Init() {
431 PeerConnectionInterface::RTCConfiguration configuration; 415 PeerConnectionInterface::RTCConfiguration configuration;
432 Init(nullptr, configuration); 416 Init(nullptr, configuration);
433 } 417 }
434 418
435 void InitWithIceTransport( 419 void InitWithIceTransport(
436 PeerConnectionInterface::IceTransportsType ice_transport_type) { 420 PeerConnectionInterface::IceTransportsType ice_transport_type) {
437 PeerConnectionInterface::RTCConfiguration configuration; 421 PeerConnectionInterface::RTCConfiguration configuration;
438 configuration.type = ice_transport_type; 422 configuration.type = ice_transport_type;
439 Init(nullptr, configuration); 423 Init(nullptr, configuration);
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
483 // Add kTelephoneEventCodec for dtmf test. 467 // Add kTelephoneEventCodec for dtmf test.
484 const cricket::AudioCodec kTelephoneEventCodec( 468 const cricket::AudioCodec kTelephoneEventCodec(
485 106, "telephone-event", 8000, 0, 1, 0); 469 106, "telephone-event", 8000, 0, 1, 0);
486 std::vector<cricket::AudioCodec> codecs; 470 std::vector<cricket::AudioCodec> codecs;
487 codecs.push_back(kTelephoneEventCodec); 471 codecs.push_back(kTelephoneEventCodec);
488 media_engine_->SetAudioCodecs(codecs); 472 media_engine_->SetAudioCodecs(codecs);
489 desc_factory_->set_audio_codecs(codecs); 473 desc_factory_->set_audio_codecs(codecs);
490 Init(); 474 Init();
491 } 475 }
492 476
493 void SendAudioVideoStream1() { 477 // Creates a local offer and applies it. Starts ice.
494 send_stream_1_ = true; 478 // Call mediastream_signaling_.UseOptionsWithStreamX() before this function
495 send_stream_2_ = false;
496 send_audio_ = true;
497 send_video_ = true;
498 }
499
500 void SendAudioVideoStream2() {
501 send_stream_1_ = false;
502 send_stream_2_ = true;
503 send_audio_ = true;
504 send_video_ = true;
505 }
506
507 void SendAudioVideoStream1And2() {
508 send_stream_1_ = true;
509 send_stream_2_ = true;
510 send_audio_ = true;
511 send_video_ = true;
512 }
513
514 void SendNothing() {
515 send_stream_1_ = false;
516 send_stream_2_ = false;
517 send_audio_ = false;
518 send_video_ = false;
519 }
520
521 void SendAudioOnlyStream2() {
522 send_stream_1_ = false;
523 send_stream_2_ = true;
524 send_audio_ = true;
525 send_video_ = false;
526 }
527
528 void SendVideoOnlyStream2() {
529 send_stream_1_ = false;
530 send_stream_2_ = true;
531 send_audio_ = false;
532 send_video_ = true;
533 }
534
535 void AddStreamsToOptions(cricket::MediaSessionOptions* session_options) {
536 if (send_stream_1_ && send_audio_) {
537 session_options->AddSendStream(cricket::MEDIA_TYPE_AUDIO, kAudioTrack1,
538 kStream1);
539 }
540 if (send_stream_1_ && send_video_) {
541 session_options->AddSendStream(cricket::MEDIA_TYPE_VIDEO, kVideoTrack1,
542 kStream1);
543 }
544 if (send_stream_2_ && send_audio_) {
545 session_options->AddSendStream(cricket::MEDIA_TYPE_AUDIO, kAudioTrack2,
546 kStream2);
547 }
548 if (send_stream_2_ && send_video_) {
549 session_options->AddSendStream(cricket::MEDIA_TYPE_VIDEO, kVideoTrack2,
550 kStream2);
551 }
552 if (data_channel_ && session_->data_channel_type() == cricket::DCT_RTP) {
553 session_options->AddSendStream(cricket::MEDIA_TYPE_DATA,
554 data_channel_->label(),
555 data_channel_->label());
556 }
557 }
558
559 void GetOptionsForOffer(
560 const PeerConnectionInterface::RTCOfferAnswerOptions& rtc_options,
561 cricket::MediaSessionOptions* session_options) {
562 AddStreamsToOptions(session_options);
563 ASSERT_TRUE(ConvertRtcOptionsForOffer(rtc_options, session_options));
564
565 if (session_->data_channel_type() == cricket::DCT_SCTP && data_channel_) {
566 session_options->data_channel_type = cricket::DCT_SCTP;
567 }
568 }
569
570 void GetOptionsForAnswer(const webrtc::MediaConstraintsInterface* constraints,
571 cricket::MediaSessionOptions* session_options) {
572 AddStreamsToOptions(session_options);
573 session_options->recv_audio = false;
574 session_options->recv_video = false;
575 ASSERT_TRUE(ParseConstraintsForAnswer(constraints, session_options));
576
577 if (session_->data_channel_type() == cricket::DCT_SCTP) {
578 session_options->data_channel_type = cricket::DCT_SCTP;
579 }
580 }
581
582 // Creates a local offer and applies it. Starts ICE.
583 // Call SendAudioVideoStreamX() before this function
584 // to decide which streams to create. 479 // to decide which streams to create.
585 void InitiateCall() { 480 void InitiateCall() {
586 SessionDescriptionInterface* offer = CreateOffer(); 481 SessionDescriptionInterface* offer = CreateOffer();
587 SetLocalDescriptionWithoutError(offer); 482 SetLocalDescriptionWithoutError(offer);
588 EXPECT_TRUE_WAIT(PeerConnectionInterface::kIceGatheringNew != 483 EXPECT_TRUE_WAIT(PeerConnectionInterface::kIceGatheringNew !=
589 observer_.ice_gathering_state_, 484 observer_.ice_gathering_state_,
590 kIceCandidatesTimeout); 485 kIceCandidatesTimeout);
591 } 486 }
592 487
593 SessionDescriptionInterface* CreateOffer() { 488 SessionDescriptionInterface* CreateOffer() {
594 PeerConnectionInterface::RTCOfferAnswerOptions options; 489 PeerConnectionInterface::RTCOfferAnswerOptions options;
595 options.offer_to_receive_audio = 490 options.offer_to_receive_audio =
596 RTCOfferAnswerOptions::kOfferToReceiveMediaTrue; 491 RTCOfferAnswerOptions::kOfferToReceiveMediaTrue;
597 492
598 return CreateOffer(options); 493 return CreateOffer(options);
599 } 494 }
600 495
601 SessionDescriptionInterface* CreateOffer( 496 SessionDescriptionInterface* CreateOffer(
602 const PeerConnectionInterface::RTCOfferAnswerOptions& options) { 497 const PeerConnectionInterface::RTCOfferAnswerOptions& options) {
603 rtc::scoped_refptr<WebRtcSessionCreateSDPObserverForTest> 498 rtc::scoped_refptr<WebRtcSessionCreateSDPObserverForTest>
604 observer = new WebRtcSessionCreateSDPObserverForTest(); 499 observer = new WebRtcSessionCreateSDPObserverForTest();
605 cricket::MediaSessionOptions session_options; 500 session_->CreateOffer(observer, options);
606 GetOptionsForOffer(options, &session_options);
607 session_->CreateOffer(observer, options, session_options);
608 EXPECT_TRUE_WAIT( 501 EXPECT_TRUE_WAIT(
609 observer->state() != WebRtcSessionCreateSDPObserverForTest::kInit, 502 observer->state() != WebRtcSessionCreateSDPObserverForTest::kInit,
610 2000); 503 2000);
611 return observer->ReleaseDescription(); 504 return observer->ReleaseDescription();
612 } 505 }
613 506
614 SessionDescriptionInterface* CreateAnswer( 507 SessionDescriptionInterface* CreateAnswer(
615 const webrtc::MediaConstraintsInterface* constraints) { 508 const webrtc::MediaConstraintsInterface* constraints) {
616 rtc::scoped_refptr<WebRtcSessionCreateSDPObserverForTest> observer 509 rtc::scoped_refptr<WebRtcSessionCreateSDPObserverForTest> observer
617 = new WebRtcSessionCreateSDPObserverForTest(); 510 = new WebRtcSessionCreateSDPObserverForTest();
618 cricket::MediaSessionOptions session_options; 511 session_->CreateAnswer(observer, constraints);
619 GetOptionsForAnswer(constraints, &session_options);
620 session_->CreateAnswer(observer, constraints, session_options);
621 EXPECT_TRUE_WAIT( 512 EXPECT_TRUE_WAIT(
622 observer->state() != WebRtcSessionCreateSDPObserverForTest::kInit, 513 observer->state() != WebRtcSessionCreateSDPObserverForTest::kInit,
623 2000); 514 2000);
624 return observer->ReleaseDescription(); 515 return observer->ReleaseDescription();
625 } 516 }
626 517
627 bool ChannelsExist() const { 518 bool ChannelsExist() const {
628 return (session_->voice_channel() != NULL && 519 return (session_->voice_channel() != NULL &&
629 session_->video_channel() != NULL); 520 session_->video_channel() != NULL);
630 } 521 }
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
740 } 631 }
741 632
742 void SetAndVerifyNumUnsignalledRecvStreams( 633 void SetAndVerifyNumUnsignalledRecvStreams(
743 int value_set, int value_expected) { 634 int value_set, int value_expected) {
744 constraints_.reset(new FakeConstraints()); 635 constraints_.reset(new FakeConstraints());
745 constraints_->AddOptional( 636 constraints_->AddOptional(
746 webrtc::MediaConstraintsInterface::kNumUnsignalledRecvStreams, 637 webrtc::MediaConstraintsInterface::kNumUnsignalledRecvStreams,
747 value_set); 638 value_set);
748 session_.reset(); 639 session_.reset();
749 Init(); 640 Init();
750 SendAudioVideoStream1(); 641 mediastream_signaling_.SendAudioVideoStream1();
751 SessionDescriptionInterface* offer = CreateOffer(); 642 SessionDescriptionInterface* offer = CreateOffer();
752 643
753 SetLocalDescriptionWithoutError(offer); 644 SetLocalDescriptionWithoutError(offer);
754 645
755 video_channel_ = media_engine_->GetVideoChannel(0); 646 video_channel_ = media_engine_->GetVideoChannel(0);
756 647
757 ASSERT_TRUE(video_channel_ != NULL); 648 ASSERT_TRUE(video_channel_ != NULL);
758 const cricket::VideoOptions& video_options = video_channel_->options(); 649 const cricket::VideoOptions& video_options = video_channel_->options();
759 EXPECT_EQ(value_expected, 650 EXPECT_EQ(value_expected,
760 video_options.unsignalled_recv_stream_limit.GetWithDefaultIfUnset(-1)); 651 video_options.unsignalled_recv_stream_limit.GetWithDefaultIfUnset(-1));
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
837 mod_ufrag.c_str(), mod_ufrag.length(), 728 mod_ufrag.c_str(), mod_ufrag.length(),
838 sdp); 729 sdp);
839 rtc::replace_substrs(pwd_line.c_str(), pwd_line.length(), 730 rtc::replace_substrs(pwd_line.c_str(), pwd_line.length(),
840 mod_pwd.c_str(), mod_pwd.length(), 731 mod_pwd.c_str(), mod_pwd.length(),
841 sdp); 732 sdp);
842 } 733 }
843 } 734 }
844 735
845 // Creates a remote offer and and applies it as a remote description, 736 // Creates a remote offer and and applies it as a remote description,
846 // creates a local answer and applies is as a local description. 737 // creates a local answer and applies is as a local description.
847 // Call SendAudioVideoStreamX() before this function 738 // Call mediastream_signaling_.UseOptionsWithStreamX() before this function
848 // to decide which local and remote streams to create. 739 // to decide which local and remote streams to create.
849 void CreateAndSetRemoteOfferAndLocalAnswer() { 740 void CreateAndSetRemoteOfferAndLocalAnswer() {
850 SessionDescriptionInterface* offer = CreateRemoteOffer(); 741 SessionDescriptionInterface* offer = CreateRemoteOffer();
851 SetRemoteDescriptionWithoutError(offer); 742 SetRemoteDescriptionWithoutError(offer);
852 SessionDescriptionInterface* answer = CreateAnswer(NULL); 743 SessionDescriptionInterface* answer = CreateAnswer(NULL);
853 SetLocalDescriptionWithoutError(answer); 744 SetLocalDescriptionWithoutError(answer);
854 } 745 }
855 void SetLocalDescriptionWithoutError(SessionDescriptionInterface* desc) { 746 void SetLocalDescriptionWithoutError(SessionDescriptionInterface* desc) {
856 EXPECT_TRUE(session_->SetLocalDescription(desc, NULL)); 747 EXPECT_TRUE(session_->SetLocalDescription(desc, NULL));
857 session_->MaybeStartGathering(); 748 session_->MaybeStartGathering();
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
1013 rtc::replace_substrs(default_port_str, strlen(default_port_str), 904 rtc::replace_substrs(default_port_str, strlen(default_port_str),
1014 new_port_str, strlen(new_port_str), 905 new_port_str, strlen(new_port_str),
1015 &offer_str); 906 &offer_str);
1016 JsepSessionDescription* offer = new JsepSessionDescription( 907 JsepSessionDescription* offer = new JsepSessionDescription(
1017 offer_basis->type()); 908 offer_basis->type());
1018 delete offer_basis; 909 delete offer_basis;
1019 offer->Initialize(offer_str, NULL); 910 offer->Initialize(offer_str, NULL);
1020 return offer; 911 return offer;
1021 } 912 }
1022 913
1023 // Create a remote offer. Call SendAudioVideoStreamX() 914 // Create a remote offer. Call mediastream_signaling_.UseOptionsWithStreamX()
1024 // before this function to decide which streams to create. 915 // before this function to decide which streams to create.
1025 JsepSessionDescription* CreateRemoteOffer() { 916 JsepSessionDescription* CreateRemoteOffer() {
1026 cricket::MediaSessionOptions options; 917 cricket::MediaSessionOptions options;
1027 GetOptionsForAnswer(NULL, &options); 918 mediastream_signaling_.GetOptionsForAnswer(NULL, &options);
1028 return CreateRemoteOffer(options, session_->remote_description()); 919 return CreateRemoteOffer(options, session_->remote_description());
1029 } 920 }
1030 921
1031 JsepSessionDescription* CreateRemoteAnswer( 922 JsepSessionDescription* CreateRemoteAnswer(
1032 const SessionDescriptionInterface* offer, 923 const SessionDescriptionInterface* offer,
1033 cricket::MediaSessionOptions options, 924 cricket::MediaSessionOptions options,
1034 cricket::SecurePolicy policy) { 925 cricket::SecurePolicy policy) {
1035 desc_factory_->set_secure(policy); 926 desc_factory_->set_secure(policy);
1036 const std::string session_id = 927 const std::string session_id =
1037 rtc::ToString(rtc::CreateRandomId64()); 928 rtc::ToString(rtc::CreateRandomId64());
1038 JsepSessionDescription* answer( 929 JsepSessionDescription* answer(
1039 new JsepSessionDescription(JsepSessionDescription::kAnswer)); 930 new JsepSessionDescription(JsepSessionDescription::kAnswer));
1040 if (!answer->Initialize(desc_factory_->CreateAnswer(offer->description(), 931 if (!answer->Initialize(desc_factory_->CreateAnswer(offer->description(),
1041 options, NULL), 932 options, NULL),
1042 session_id, kSessionVersion)) { 933 session_id, kSessionVersion)) {
1043 delete answer; 934 delete answer;
1044 answer = NULL; 935 answer = NULL;
1045 } 936 }
1046 return answer; 937 return answer;
1047 } 938 }
1048 939
1049 JsepSessionDescription* CreateRemoteAnswer( 940 JsepSessionDescription* CreateRemoteAnswer(
1050 const SessionDescriptionInterface* offer, 941 const SessionDescriptionInterface* offer,
1051 cricket::MediaSessionOptions options) { 942 cricket::MediaSessionOptions options) {
1052 return CreateRemoteAnswer(offer, options, cricket::SEC_REQUIRED); 943 return CreateRemoteAnswer(offer, options, cricket::SEC_REQUIRED);
1053 } 944 }
1054 945
1055 // Creates an answer session description. 946 // Creates an answer session description with streams based on
1056 // Call SendAudioVideoStreamX() before this function 947 // |mediastream_signaling_|. Call
948 // mediastream_signaling_.UseOptionsWithStreamX() before this function
1057 // to decide which streams to create. 949 // to decide which streams to create.
1058 JsepSessionDescription* CreateRemoteAnswer( 950 JsepSessionDescription* CreateRemoteAnswer(
1059 const SessionDescriptionInterface* offer) { 951 const SessionDescriptionInterface* offer) {
1060 cricket::MediaSessionOptions options; 952 cricket::MediaSessionOptions options;
1061 GetOptionsForAnswer(NULL, &options); 953 mediastream_signaling_.GetOptionsForAnswer(NULL, &options);
1062 return CreateRemoteAnswer(offer, options, cricket::SEC_REQUIRED); 954 return CreateRemoteAnswer(offer, options, cricket::SEC_REQUIRED);
1063 } 955 }
1064 956
1065 void TestSessionCandidatesWithBundleRtcpMux(bool bundle, bool rtcp_mux) { 957 void TestSessionCandidatesWithBundleRtcpMux(bool bundle, bool rtcp_mux) {
1066 AddInterface(rtc::SocketAddress(kClientAddrHost1, kClientAddrPort)); 958 AddInterface(rtc::SocketAddress(kClientAddrHost1, kClientAddrPort));
1067 Init(); 959 Init();
1068 SendAudioVideoStream1(); 960 mediastream_signaling_.SendAudioVideoStream1();
1069 961
1070 PeerConnectionInterface::RTCOfferAnswerOptions options; 962 PeerConnectionInterface::RTCOfferAnswerOptions options;
1071 options.use_rtp_mux = bundle; 963 options.use_rtp_mux = bundle;
1072 964
1073 SessionDescriptionInterface* offer = CreateOffer(options); 965 SessionDescriptionInterface* offer = CreateOffer(options);
1074 // SetLocalDescription and SetRemoteDescriptions takes ownership of offer 966 // SetLocalDescription and SetRemoteDescriptions takes ownership of offer
1075 // and answer. 967 // and answer.
1076 SetLocalDescriptionWithoutError(offer); 968 SetLocalDescriptionWithoutError(offer);
1077 969
1078 rtc::scoped_ptr<SessionDescriptionInterface> answer( 970 rtc::scoped_ptr<SessionDescriptionInterface> answer(
(...skipping 27 matching lines...) Expand all
1106 EXPECT_EQ(expected_candidate_num, observer_.mline_1_candidates_.size()); 998 EXPECT_EQ(expected_candidate_num, observer_.mline_1_candidates_.size());
1107 } 999 }
1108 } 1000 }
1109 // Tests that we can only send DTMF when the dtmf codec is supported. 1001 // Tests that we can only send DTMF when the dtmf codec is supported.
1110 void TestCanInsertDtmf(bool can) { 1002 void TestCanInsertDtmf(bool can) {
1111 if (can) { 1003 if (can) {
1112 InitWithDtmfCodec(); 1004 InitWithDtmfCodec();
1113 } else { 1005 } else {
1114 Init(); 1006 Init();
1115 } 1007 }
1116 SendAudioVideoStream1(); 1008 mediastream_signaling_.SendAudioVideoStream1();
1117 CreateAndSetRemoteOfferAndLocalAnswer(); 1009 CreateAndSetRemoteOfferAndLocalAnswer();
1118 EXPECT_FALSE(session_->CanInsertDtmf("")); 1010 EXPECT_FALSE(session_->CanInsertDtmf(""));
1119 EXPECT_EQ(can, session_->CanInsertDtmf(kAudioTrack1)); 1011 EXPECT_EQ(can, session_->CanInsertDtmf(kAudioTrack1));
1120 } 1012 }
1121 1013
1122 // Helper class to configure loopback network and verify Best 1014 // Helper class to configure loopback network and verify Best
1123 // Connection using right IP protocol for TestLoopbackCall 1015 // Connection using right IP protocol for TestLoopbackCall
1124 // method. LoopbackNetworkManager applies firewall rules to block 1016 // method. LoopbackNetworkManager applies firewall rules to block
1125 // all ping traffic once ICE completed, and remove them to observe 1017 // all ping traffic once ICE completed, and remove them to observe
1126 // ICE reconnected again. This LoopbackNetworkConfiguration struct 1018 // ICE reconnected again. This LoopbackNetworkConfiguration struct
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
1222 // the correct sequence of ICE states when a connection is established, 1114 // the correct sequence of ICE states when a connection is established,
1223 // broken, and re-established. 1115 // broken, and re-established.
1224 // The Connection state should go: 1116 // The Connection state should go:
1225 // New -> Checking -> (Connected) -> Completed -> Disconnected -> Completed 1117 // New -> Checking -> (Connected) -> Completed -> Disconnected -> Completed
1226 // -> Failed. 1118 // -> Failed.
1227 // The Gathering state should go: New -> Gathering -> Completed. 1119 // The Gathering state should go: New -> Gathering -> Completed.
1228 1120
1229 void TestLoopbackCall(const LoopbackNetworkConfiguration& config) { 1121 void TestLoopbackCall(const LoopbackNetworkConfiguration& config) {
1230 LoopbackNetworkManager loopback_network_manager(this, config); 1122 LoopbackNetworkManager loopback_network_manager(this, config);
1231 Init(); 1123 Init();
1232 SendAudioVideoStream1(); 1124 mediastream_signaling_.SendAudioVideoStream1();
1233 SessionDescriptionInterface* offer = CreateOffer(); 1125 SessionDescriptionInterface* offer = CreateOffer();
1234 1126
1235 EXPECT_EQ(PeerConnectionInterface::kIceGatheringNew, 1127 EXPECT_EQ(PeerConnectionInterface::kIceGatheringNew,
1236 observer_.ice_gathering_state_); 1128 observer_.ice_gathering_state_);
1237 SetLocalDescriptionWithoutError(offer); 1129 SetLocalDescriptionWithoutError(offer);
1238 EXPECT_EQ(PeerConnectionInterface::kIceConnectionNew, 1130 EXPECT_EQ(PeerConnectionInterface::kIceConnectionNew,
1239 observer_.ice_connection_state_); 1131 observer_.ice_connection_state_);
1240 EXPECT_EQ_WAIT(PeerConnectionInterface::kIceGatheringGathering, 1132 EXPECT_EQ_WAIT(PeerConnectionInterface::kIceGatheringGathering,
1241 observer_.ice_gathering_state_, 1133 observer_.ice_gathering_state_,
1242 kIceCandidatesTimeout); 1134 kIceCandidatesTimeout);
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
1319 const cricket::AudioContentDescription* audio_content_desc = 1211 const cricket::AudioContentDescription* audio_content_desc =
1320 static_cast<const cricket::AudioContentDescription*>(description); 1212 static_cast<const cricket::AudioContentDescription*>(description);
1321 ASSERT(audio_content_desc != NULL); 1213 ASSERT(audio_content_desc != NULL);
1322 for (size_t i = 0; i < audio_content_desc->codecs().size(); ++i) { 1214 for (size_t i = 0; i < audio_content_desc->codecs().size(); ++i) {
1323 if (audio_content_desc->codecs()[i].name == "CN") 1215 if (audio_content_desc->codecs()[i].name == "CN")
1324 return false; 1216 return false;
1325 } 1217 }
1326 return true; 1218 return true;
1327 } 1219 }
1328 1220
1329 void CreateDataChannel() { 1221 void SetLocalDescriptionWithDataChannel() {
1330 webrtc::InternalDataChannelInit dci; 1222 webrtc::InternalDataChannelInit dci;
1331 dci.reliable = session_->data_channel_type() == cricket::DCT_SCTP; 1223 dci.reliable = false;
1332 data_channel_ = DataChannel::Create( 1224 session_->CreateDataChannel("datachannel", &dci);
1333 session_.get(), session_->data_channel_type(), "datachannel", dci);
1334 }
1335
1336 void SetLocalDescriptionWithDataChannel() {
1337 CreateDataChannel();
1338 SessionDescriptionInterface* offer = CreateOffer(); 1225 SessionDescriptionInterface* offer = CreateOffer();
1339 SetLocalDescriptionWithoutError(offer); 1226 SetLocalDescriptionWithoutError(offer);
1340 } 1227 }
1341 1228
1342 void VerifyMultipleAsyncCreateDescription( 1229 void VerifyMultipleAsyncCreateDescription(
1343 RTCCertificateGenerationMethod cert_gen_method, 1230 RTCCertificateGenerationMethod cert_gen_method,
1344 CreateSessionDescriptionRequest::Type type) { 1231 CreateSessionDescriptionRequest::Type type) {
1345 InitWithDtls(cert_gen_method); 1232 InitWithDtls(cert_gen_method);
1346 VerifyMultipleAsyncCreateDescriptionAfterInit(true, type); 1233 VerifyMultipleAsyncCreateDescriptionAfterInit(true, type);
1347 } 1234 }
(...skipping 10 matching lines...) Expand all
1358 SetFactoryDtlsSrtp(); 1245 SetFactoryDtlsSrtp();
1359 if (type == CreateSessionDescriptionRequest::kAnswer) { 1246 if (type == CreateSessionDescriptionRequest::kAnswer) {
1360 cricket::MediaSessionOptions options; 1247 cricket::MediaSessionOptions options;
1361 scoped_ptr<JsepSessionDescription> offer( 1248 scoped_ptr<JsepSessionDescription> offer(
1362 CreateRemoteOffer(options, cricket::SEC_DISABLED)); 1249 CreateRemoteOffer(options, cricket::SEC_DISABLED));
1363 ASSERT_TRUE(offer.get() != NULL); 1250 ASSERT_TRUE(offer.get() != NULL);
1364 SetRemoteDescriptionWithoutError(offer.release()); 1251 SetRemoteDescriptionWithoutError(offer.release());
1365 } 1252 }
1366 1253
1367 PeerConnectionInterface::RTCOfferAnswerOptions options; 1254 PeerConnectionInterface::RTCOfferAnswerOptions options;
1368 cricket::MediaSessionOptions session_options;
1369 const int kNumber = 3; 1255 const int kNumber = 3;
1370 rtc::scoped_refptr<WebRtcSessionCreateSDPObserverForTest> 1256 rtc::scoped_refptr<WebRtcSessionCreateSDPObserverForTest>
1371 observers[kNumber]; 1257 observers[kNumber];
1372 for (int i = 0; i < kNumber; ++i) { 1258 for (int i = 0; i < kNumber; ++i) {
1373 observers[i] = new WebRtcSessionCreateSDPObserverForTest(); 1259 observers[i] = new WebRtcSessionCreateSDPObserverForTest();
1374 if (type == CreateSessionDescriptionRequest::kOffer) { 1260 if (type == CreateSessionDescriptionRequest::kOffer) {
1375 session_->CreateOffer(observers[i], options, session_options); 1261 session_->CreateOffer(observers[i], options);
1376 } else { 1262 } else {
1377 session_->CreateAnswer(observers[i], nullptr, session_options); 1263 session_->CreateAnswer(observers[i], NULL);
1378 } 1264 }
1379 } 1265 }
1380 1266
1381 WebRtcSessionCreateSDPObserverForTest::State expected_state = 1267 WebRtcSessionCreateSDPObserverForTest::State expected_state =
1382 success ? WebRtcSessionCreateSDPObserverForTest::kSucceeded : 1268 success ? WebRtcSessionCreateSDPObserverForTest::kSucceeded :
1383 WebRtcSessionCreateSDPObserverForTest::kFailed; 1269 WebRtcSessionCreateSDPObserverForTest::kFailed;
1384 1270
1385 for (int i = 0; i < kNumber; ++i) { 1271 for (int i = 0; i < kNumber; ++i) {
1386 EXPECT_EQ_WAIT(expected_state, observers[i]->state(), 1000); 1272 EXPECT_EQ_WAIT(expected_state, observers[i]->state(), 1000);
1387 if (success) { 1273 if (success) {
(...skipping 24 matching lines...) Expand all
1412 rtc::scoped_ptr<rtc::VirtualSocketServer> vss_; 1298 rtc::scoped_ptr<rtc::VirtualSocketServer> vss_;
1413 rtc::scoped_ptr<rtc::FirewallSocketServer> fss_; 1299 rtc::scoped_ptr<rtc::FirewallSocketServer> fss_;
1414 rtc::SocketServerScope ss_scope_; 1300 rtc::SocketServerScope ss_scope_;
1415 rtc::SocketAddress stun_socket_addr_; 1301 rtc::SocketAddress stun_socket_addr_;
1416 rtc::scoped_ptr<cricket::TestStunServer> stun_server_; 1302 rtc::scoped_ptr<cricket::TestStunServer> stun_server_;
1417 cricket::TestTurnServer turn_server_; 1303 cricket::TestTurnServer turn_server_;
1418 rtc::FakeNetworkManager network_manager_; 1304 rtc::FakeNetworkManager network_manager_;
1419 rtc::scoped_ptr<cricket::BasicPortAllocator> allocator_; 1305 rtc::scoped_ptr<cricket::BasicPortAllocator> allocator_;
1420 PeerConnectionFactoryInterface::Options options_; 1306 PeerConnectionFactoryInterface::Options options_;
1421 rtc::scoped_ptr<FakeConstraints> constraints_; 1307 rtc::scoped_ptr<FakeConstraints> constraints_;
1308 FakeMediaStreamSignaling mediastream_signaling_;
1422 rtc::scoped_ptr<WebRtcSessionForTest> session_; 1309 rtc::scoped_ptr<WebRtcSessionForTest> session_;
1423 MockIceObserver observer_; 1310 MockIceObserver observer_;
1424 cricket::FakeVideoMediaChannel* video_channel_; 1311 cricket::FakeVideoMediaChannel* video_channel_;
1425 cricket::FakeVoiceMediaChannel* voice_channel_; 1312 cricket::FakeVoiceMediaChannel* voice_channel_;
1426 rtc::scoped_refptr<FakeMetricsObserver> metrics_observer_; 1313 rtc::scoped_refptr<FakeMetricsObserver> metrics_observer_;
1427 // The following flags affect options created for CreateOffer/CreateAnswer.
1428 bool send_stream_1_ = false;
1429 bool send_stream_2_ = false;
1430 bool send_audio_ = false;
1431 bool send_video_ = false;
1432 rtc::scoped_refptr<DataChannel> data_channel_;
1433 // Last values received from data channel creation signal.
1434 std::string last_data_channel_label_;
1435 InternalDataChannelInit last_data_channel_config_;
1436 }; 1314 };
1437 1315
1438 TEST_P(WebRtcSessionTest, TestInitializeWithDtls) { 1316 TEST_P(WebRtcSessionTest, TestInitializeWithDtls) {
1439 InitWithDtls(GetParam()); 1317 InitWithDtls(GetParam());
1440 // SDES is disabled when DTLS is on. 1318 // SDES is disabled when DTLS is on.
1441 EXPECT_EQ(cricket::SEC_DISABLED, session_->SdesPolicy()); 1319 EXPECT_EQ(cricket::SEC_DISABLED, session_->SdesPolicy());
1442 } 1320 }
1443 1321
1444 TEST_F(WebRtcSessionTest, TestInitializeWithoutDtls) { 1322 TEST_F(WebRtcSessionTest, TestInitializeWithoutDtls) {
1445 Init(); 1323 Init();
(...skipping 12 matching lines...) Expand all
1458 } 1336 }
1459 1337
1460 TEST_F(WebRtcSessionTest, TestSessionCandidatesWithBundleRtcpMux) { 1338 TEST_F(WebRtcSessionTest, TestSessionCandidatesWithBundleRtcpMux) {
1461 TestSessionCandidatesWithBundleRtcpMux(true, true); 1339 TestSessionCandidatesWithBundleRtcpMux(true, true);
1462 } 1340 }
1463 1341
1464 TEST_F(WebRtcSessionTest, TestMultihomeCandidates) { 1342 TEST_F(WebRtcSessionTest, TestMultihomeCandidates) {
1465 AddInterface(rtc::SocketAddress(kClientAddrHost1, kClientAddrPort)); 1343 AddInterface(rtc::SocketAddress(kClientAddrHost1, kClientAddrPort));
1466 AddInterface(rtc::SocketAddress(kClientAddrHost2, kClientAddrPort)); 1344 AddInterface(rtc::SocketAddress(kClientAddrHost2, kClientAddrPort));
1467 Init(); 1345 Init();
1468 SendAudioVideoStream1(); 1346 mediastream_signaling_.SendAudioVideoStream1();
1469 InitiateCall(); 1347 InitiateCall();
1470 EXPECT_TRUE_WAIT(observer_.oncandidatesready_, kIceCandidatesTimeout); 1348 EXPECT_TRUE_WAIT(observer_.oncandidatesready_, kIceCandidatesTimeout);
1471 EXPECT_EQ(8u, observer_.mline_0_candidates_.size()); 1349 EXPECT_EQ(8u, observer_.mline_0_candidates_.size());
1472 EXPECT_EQ(8u, observer_.mline_1_candidates_.size()); 1350 EXPECT_EQ(8u, observer_.mline_1_candidates_.size());
1473 } 1351 }
1474 1352
1475 TEST_F(WebRtcSessionTest, TestStunError) { 1353 TEST_F(WebRtcSessionTest, TestStunError) {
1476 AddInterface(rtc::SocketAddress(kClientAddrHost1, kClientAddrPort)); 1354 AddInterface(rtc::SocketAddress(kClientAddrHost1, kClientAddrPort));
1477 AddInterface(rtc::SocketAddress(kClientAddrHost2, kClientAddrPort)); 1355 AddInterface(rtc::SocketAddress(kClientAddrHost2, kClientAddrPort));
1478 fss_->AddRule(false, 1356 fss_->AddRule(false,
1479 rtc::FP_UDP, 1357 rtc::FP_UDP,
1480 rtc::FD_ANY, 1358 rtc::FD_ANY,
1481 rtc::SocketAddress(kClientAddrHost1, kClientAddrPort)); 1359 rtc::SocketAddress(kClientAddrHost1, kClientAddrPort));
1482 Init(); 1360 Init();
1483 SendAudioVideoStream1(); 1361 mediastream_signaling_.SendAudioVideoStream1();
1484 InitiateCall(); 1362 InitiateCall();
1485 // Since kClientAddrHost1 is blocked, not expecting stun candidates for it. 1363 // Since kClientAddrHost1 is blocked, not expecting stun candidates for it.
1486 EXPECT_TRUE_WAIT(observer_.oncandidatesready_, kIceCandidatesTimeout); 1364 EXPECT_TRUE_WAIT(observer_.oncandidatesready_, kIceCandidatesTimeout);
1487 EXPECT_EQ(6u, observer_.mline_0_candidates_.size()); 1365 EXPECT_EQ(6u, observer_.mline_0_candidates_.size());
1488 EXPECT_EQ(6u, observer_.mline_1_candidates_.size()); 1366 EXPECT_EQ(6u, observer_.mline_1_candidates_.size());
1489 } 1367 }
1490 1368
1491 // Test session delivers no candidates gathered when constraint set to "none". 1369 // Test session delivers no candidates gathered when constraint set to "none".
1492 TEST_F(WebRtcSessionTest, TestIceTransportsNone) { 1370 TEST_F(WebRtcSessionTest, TestIceTransportsNone) {
1493 AddInterface(rtc::SocketAddress(kClientAddrHost1, kClientAddrPort)); 1371 AddInterface(rtc::SocketAddress(kClientAddrHost1, kClientAddrPort));
1494 InitWithIceTransport(PeerConnectionInterface::kNone); 1372 InitWithIceTransport(PeerConnectionInterface::kNone);
1495 SendAudioVideoStream1(); 1373 mediastream_signaling_.SendAudioVideoStream1();
1496 InitiateCall(); 1374 InitiateCall();
1497 EXPECT_TRUE_WAIT(observer_.oncandidatesready_, kIceCandidatesTimeout); 1375 EXPECT_TRUE_WAIT(observer_.oncandidatesready_, kIceCandidatesTimeout);
1498 EXPECT_EQ(0u, observer_.mline_0_candidates_.size()); 1376 EXPECT_EQ(0u, observer_.mline_0_candidates_.size());
1499 EXPECT_EQ(0u, observer_.mline_1_candidates_.size()); 1377 EXPECT_EQ(0u, observer_.mline_1_candidates_.size());
1500 } 1378 }
1501 1379
1502 // Test session delivers only relay candidates gathered when constaint set to 1380 // Test session delivers only relay candidates gathered when constaint set to
1503 // "relay". 1381 // "relay".
1504 TEST_F(WebRtcSessionTest, TestIceTransportsRelay) { 1382 TEST_F(WebRtcSessionTest, TestIceTransportsRelay) {
1505 AddInterface(rtc::SocketAddress(kClientAddrHost1, kClientAddrPort)); 1383 AddInterface(rtc::SocketAddress(kClientAddrHost1, kClientAddrPort));
1506 ConfigureAllocatorWithTurn(); 1384 ConfigureAllocatorWithTurn();
1507 InitWithIceTransport(PeerConnectionInterface::kRelay); 1385 InitWithIceTransport(PeerConnectionInterface::kRelay);
1508 SendAudioVideoStream1(); 1386 mediastream_signaling_.SendAudioVideoStream1();
1509 InitiateCall(); 1387 InitiateCall();
1510 EXPECT_TRUE_WAIT(observer_.oncandidatesready_, kIceCandidatesTimeout); 1388 EXPECT_TRUE_WAIT(observer_.oncandidatesready_, kIceCandidatesTimeout);
1511 EXPECT_EQ(2u, observer_.mline_0_candidates_.size()); 1389 EXPECT_EQ(2u, observer_.mline_0_candidates_.size());
1512 EXPECT_EQ(2u, observer_.mline_1_candidates_.size()); 1390 EXPECT_EQ(2u, observer_.mline_1_candidates_.size());
1513 for (size_t i = 0; i < observer_.mline_0_candidates_.size(); ++i) { 1391 for (size_t i = 0; i < observer_.mline_0_candidates_.size(); ++i) {
1514 EXPECT_EQ(cricket::RELAY_PORT_TYPE, 1392 EXPECT_EQ(cricket::RELAY_PORT_TYPE,
1515 observer_.mline_0_candidates_[i].type()); 1393 observer_.mline_0_candidates_[i].type());
1516 } 1394 }
1517 for (size_t i = 0; i < observer_.mline_1_candidates_.size(); ++i) { 1395 for (size_t i = 0; i < observer_.mline_1_candidates_.size(); ++i) {
1518 EXPECT_EQ(cricket::RELAY_PORT_TYPE, 1396 EXPECT_EQ(cricket::RELAY_PORT_TYPE,
1519 observer_.mline_1_candidates_[i].type()); 1397 observer_.mline_1_candidates_[i].type());
1520 } 1398 }
1521 } 1399 }
1522 1400
1523 // Test session delivers all candidates gathered when constaint set to "all". 1401 // Test session delivers all candidates gathered when constaint set to "all".
1524 TEST_F(WebRtcSessionTest, TestIceTransportsAll) { 1402 TEST_F(WebRtcSessionTest, TestIceTransportsAll) {
1525 AddInterface(rtc::SocketAddress(kClientAddrHost1, kClientAddrPort)); 1403 AddInterface(rtc::SocketAddress(kClientAddrHost1, kClientAddrPort));
1526 InitWithIceTransport(PeerConnectionInterface::kAll); 1404 InitWithIceTransport(PeerConnectionInterface::kAll);
1527 SendAudioVideoStream1(); 1405 mediastream_signaling_.SendAudioVideoStream1();
1528 InitiateCall(); 1406 InitiateCall();
1529 EXPECT_TRUE_WAIT(observer_.oncandidatesready_, kIceCandidatesTimeout); 1407 EXPECT_TRUE_WAIT(observer_.oncandidatesready_, kIceCandidatesTimeout);
1530 // Host + STUN. By default allocator is disabled to gather relay candidates. 1408 // Host + STUN. By default allocator is disabled to gather relay candidates.
1531 EXPECT_EQ(4u, observer_.mline_0_candidates_.size()); 1409 EXPECT_EQ(4u, observer_.mline_0_candidates_.size());
1532 EXPECT_EQ(4u, observer_.mline_1_candidates_.size()); 1410 EXPECT_EQ(4u, observer_.mline_1_candidates_.size());
1533 } 1411 }
1534 1412
1535 TEST_F(WebRtcSessionTest, SetSdpFailedOnInvalidSdp) { 1413 TEST_F(WebRtcSessionTest, SetSdpFailedOnInvalidSdp) {
1536 Init(); 1414 Init();
1537 SessionDescriptionInterface* offer = NULL; 1415 SessionDescriptionInterface* offer = NULL;
1538 // Since |offer| is NULL, there's no way to tell if it's an offer or answer. 1416 // Since |offer| is NULL, there's no way to tell if it's an offer or answer.
1539 std::string unknown_action; 1417 std::string unknown_action;
1540 SetLocalDescriptionExpectError(unknown_action, kInvalidSdp, offer); 1418 SetLocalDescriptionExpectError(unknown_action, kInvalidSdp, offer);
1541 SetRemoteDescriptionExpectError(unknown_action, kInvalidSdp, offer); 1419 SetRemoteDescriptionExpectError(unknown_action, kInvalidSdp, offer);
1542 } 1420 }
1543 1421
1544 // Test creating offers and receive answers and make sure the 1422 // Test creating offers and receive answers and make sure the
1545 // media engine creates the expected send and receive streams. 1423 // media engine creates the expected send and receive streams.
1546 TEST_F(WebRtcSessionTest, TestCreateSdesOfferReceiveSdesAnswer) { 1424 TEST_F(WebRtcSessionTest, TestCreateSdesOfferReceiveSdesAnswer) {
1547 Init(); 1425 Init();
1548 SendAudioVideoStream1(); 1426 mediastream_signaling_.SendAudioVideoStream1();
1549 SessionDescriptionInterface* offer = CreateOffer(); 1427 SessionDescriptionInterface* offer = CreateOffer();
1550 const std::string session_id_orig = offer->session_id(); 1428 const std::string session_id_orig = offer->session_id();
1551 const std::string session_version_orig = offer->session_version(); 1429 const std::string session_version_orig = offer->session_version();
1552 SetLocalDescriptionWithoutError(offer); 1430 SetLocalDescriptionWithoutError(offer);
1553 1431
1554 SendAudioVideoStream2(); 1432 mediastream_signaling_.SendAudioVideoStream2();
1555 SessionDescriptionInterface* answer = 1433 SessionDescriptionInterface* answer =
1556 CreateRemoteAnswer(session_->local_description()); 1434 CreateRemoteAnswer(session_->local_description());
1557 SetRemoteDescriptionWithoutError(answer); 1435 SetRemoteDescriptionWithoutError(answer);
1558 1436
1559 video_channel_ = media_engine_->GetVideoChannel(0); 1437 video_channel_ = media_engine_->GetVideoChannel(0);
1560 voice_channel_ = media_engine_->GetVoiceChannel(0); 1438 voice_channel_ = media_engine_->GetVoiceChannel(0);
1561 1439
1562 ASSERT_EQ(1u, video_channel_->recv_streams().size()); 1440 ASSERT_EQ(1u, video_channel_->recv_streams().size());
1563 EXPECT_TRUE(kVideoTrack2 == video_channel_->recv_streams()[0].id); 1441 EXPECT_TRUE(kVideoTrack2 == video_channel_->recv_streams()[0].id);
1564 1442
1565 ASSERT_EQ(1u, voice_channel_->recv_streams().size()); 1443 ASSERT_EQ(1u, voice_channel_->recv_streams().size());
1566 EXPECT_TRUE(kAudioTrack2 == voice_channel_->recv_streams()[0].id); 1444 EXPECT_TRUE(kAudioTrack2 == voice_channel_->recv_streams()[0].id);
1567 1445
1568 ASSERT_EQ(1u, video_channel_->send_streams().size()); 1446 ASSERT_EQ(1u, video_channel_->send_streams().size());
1569 EXPECT_TRUE(kVideoTrack1 == video_channel_->send_streams()[0].id); 1447 EXPECT_TRUE(kVideoTrack1 == video_channel_->send_streams()[0].id);
1570 ASSERT_EQ(1u, voice_channel_->send_streams().size()); 1448 ASSERT_EQ(1u, voice_channel_->send_streams().size());
1571 EXPECT_TRUE(kAudioTrack1 == voice_channel_->send_streams()[0].id); 1449 EXPECT_TRUE(kAudioTrack1 == voice_channel_->send_streams()[0].id);
1572 1450
1573 // Create new offer without send streams. 1451 // Create new offer without send streams.
1574 SendNothing(); 1452 mediastream_signaling_.SendNothing();
1575 offer = CreateOffer(); 1453 offer = CreateOffer();
1576 1454
1577 // Verify the session id is the same and the session version is 1455 // Verify the session id is the same and the session version is
1578 // increased. 1456 // increased.
1579 EXPECT_EQ(session_id_orig, offer->session_id()); 1457 EXPECT_EQ(session_id_orig, offer->session_id());
1580 EXPECT_LT(rtc::FromString<uint64_t>(session_version_orig), 1458 EXPECT_LT(rtc::FromString<uint64_t>(session_version_orig),
1581 rtc::FromString<uint64_t>(offer->session_version())); 1459 rtc::FromString<uint64_t>(offer->session_version()));
1582 1460
1583 SetLocalDescriptionWithoutError(offer); 1461 SetLocalDescriptionWithoutError(offer);
1584 EXPECT_EQ(0u, video_channel_->send_streams().size()); 1462 EXPECT_EQ(0u, video_channel_->send_streams().size());
1585 EXPECT_EQ(0u, voice_channel_->send_streams().size()); 1463 EXPECT_EQ(0u, voice_channel_->send_streams().size());
1586 1464
1587 SendAudioVideoStream2(); 1465 mediastream_signaling_.SendAudioVideoStream2();
1588 answer = CreateRemoteAnswer(session_->local_description()); 1466 answer = CreateRemoteAnswer(session_->local_description());
1589 SetRemoteDescriptionWithoutError(answer); 1467 SetRemoteDescriptionWithoutError(answer);
1590 1468
1591 // Make sure the receive streams have not changed. 1469 // Make sure the receive streams have not changed.
1592 ASSERT_EQ(1u, video_channel_->recv_streams().size()); 1470 ASSERT_EQ(1u, video_channel_->recv_streams().size());
1593 EXPECT_TRUE(kVideoTrack2 == video_channel_->recv_streams()[0].id); 1471 EXPECT_TRUE(kVideoTrack2 == video_channel_->recv_streams()[0].id);
1594 ASSERT_EQ(1u, voice_channel_->recv_streams().size()); 1472 ASSERT_EQ(1u, voice_channel_->recv_streams().size());
1595 EXPECT_TRUE(kAudioTrack2 == voice_channel_->recv_streams()[0].id); 1473 EXPECT_TRUE(kAudioTrack2 == voice_channel_->recv_streams()[0].id);
1596 } 1474 }
1597 1475
1598 // Test receiving offers and creating answers and make sure the 1476 // Test receiving offers and creating answers and make sure the
1599 // media engine creates the expected send and receive streams. 1477 // media engine creates the expected send and receive streams.
1600 TEST_F(WebRtcSessionTest, TestReceiveSdesOfferCreateSdesAnswer) { 1478 TEST_F(WebRtcSessionTest, TestReceiveSdesOfferCreateSdesAnswer) {
1601 Init(); 1479 Init();
1602 SendAudioVideoStream2(); 1480 mediastream_signaling_.SendAudioVideoStream2();
1603 SessionDescriptionInterface* offer = CreateOffer(); 1481 SessionDescriptionInterface* offer = CreateOffer();
1604 VerifyCryptoParams(offer->description()); 1482 VerifyCryptoParams(offer->description());
1605 SetRemoteDescriptionWithoutError(offer); 1483 SetRemoteDescriptionWithoutError(offer);
1606 1484
1607 SendAudioVideoStream1(); 1485 mediastream_signaling_.SendAudioVideoStream1();
1608 SessionDescriptionInterface* answer = CreateAnswer(NULL); 1486 SessionDescriptionInterface* answer = CreateAnswer(NULL);
1609 VerifyCryptoParams(answer->description()); 1487 VerifyCryptoParams(answer->description());
1610 SetLocalDescriptionWithoutError(answer); 1488 SetLocalDescriptionWithoutError(answer);
1611 1489
1612 const std::string session_id_orig = answer->session_id(); 1490 const std::string session_id_orig = answer->session_id();
1613 const std::string session_version_orig = answer->session_version(); 1491 const std::string session_version_orig = answer->session_version();
1614 1492
1615 video_channel_ = media_engine_->GetVideoChannel(0); 1493 video_channel_ = media_engine_->GetVideoChannel(0);
1616 voice_channel_ = media_engine_->GetVoiceChannel(0); 1494 voice_channel_ = media_engine_->GetVoiceChannel(0);
1617 1495
1618 ASSERT_EQ(1u, video_channel_->recv_streams().size()); 1496 ASSERT_EQ(1u, video_channel_->recv_streams().size());
1619 EXPECT_TRUE(kVideoTrack2 == video_channel_->recv_streams()[0].id); 1497 EXPECT_TRUE(kVideoTrack2 == video_channel_->recv_streams()[0].id);
1620 1498
1621 ASSERT_EQ(1u, voice_channel_->recv_streams().size()); 1499 ASSERT_EQ(1u, voice_channel_->recv_streams().size());
1622 EXPECT_TRUE(kAudioTrack2 == voice_channel_->recv_streams()[0].id); 1500 EXPECT_TRUE(kAudioTrack2 == voice_channel_->recv_streams()[0].id);
1623 1501
1624 ASSERT_EQ(1u, video_channel_->send_streams().size()); 1502 ASSERT_EQ(1u, video_channel_->send_streams().size());
1625 EXPECT_TRUE(kVideoTrack1 == video_channel_->send_streams()[0].id); 1503 EXPECT_TRUE(kVideoTrack1 == video_channel_->send_streams()[0].id);
1626 ASSERT_EQ(1u, voice_channel_->send_streams().size()); 1504 ASSERT_EQ(1u, voice_channel_->send_streams().size());
1627 EXPECT_TRUE(kAudioTrack1 == voice_channel_->send_streams()[0].id); 1505 EXPECT_TRUE(kAudioTrack1 == voice_channel_->send_streams()[0].id);
1628 1506
1629 SendAudioVideoStream1And2(); 1507 mediastream_signaling_.SendAudioVideoStream1And2();
1630 offer = CreateOffer(); 1508 offer = CreateOffer();
1631 SetRemoteDescriptionWithoutError(offer); 1509 SetRemoteDescriptionWithoutError(offer);
1632 1510
1633 // Answer by turning off all send streams. 1511 // Answer by turning off all send streams.
1634 SendNothing(); 1512 mediastream_signaling_.SendNothing();
1635 answer = CreateAnswer(NULL); 1513 answer = CreateAnswer(NULL);
1636 1514
1637 // Verify the session id is the same and the session version is 1515 // Verify the session id is the same and the session version is
1638 // increased. 1516 // increased.
1639 EXPECT_EQ(session_id_orig, answer->session_id()); 1517 EXPECT_EQ(session_id_orig, answer->session_id());
1640 EXPECT_LT(rtc::FromString<uint64_t>(session_version_orig), 1518 EXPECT_LT(rtc::FromString<uint64_t>(session_version_orig),
1641 rtc::FromString<uint64_t>(answer->session_version())); 1519 rtc::FromString<uint64_t>(answer->session_version()));
1642 SetLocalDescriptionWithoutError(answer); 1520 SetLocalDescriptionWithoutError(answer);
1643 1521
1644 ASSERT_EQ(2u, video_channel_->recv_streams().size()); 1522 ASSERT_EQ(2u, video_channel_->recv_streams().size());
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
1738 // SetRemoteDescription and SetLocalDescription will take the ownership of 1616 // SetRemoteDescription and SetLocalDescription will take the ownership of
1739 // the offer. 1617 // the offer.
1740 SetLocalDescriptionWithoutError(offer); 1618 SetLocalDescriptionWithoutError(offer);
1741 SetRemoteDescriptionAnswerExpectError(kSdpWithoutSdesCrypto, answer); 1619 SetRemoteDescriptionAnswerExpectError(kSdpWithoutSdesCrypto, answer);
1742 } 1620 }
1743 1621
1744 // Test that we accept an offer with a DTLS fingerprint when DTLS is on 1622 // Test that we accept an offer with a DTLS fingerprint when DTLS is on
1745 // and that we return an answer with a DTLS fingerprint. 1623 // and that we return an answer with a DTLS fingerprint.
1746 TEST_P(WebRtcSessionTest, TestReceiveDtlsOfferCreateDtlsAnswer) { 1624 TEST_P(WebRtcSessionTest, TestReceiveDtlsOfferCreateDtlsAnswer) {
1747 MAYBE_SKIP_TEST(rtc::SSLStreamAdapter::HaveDtlsSrtp); 1625 MAYBE_SKIP_TEST(rtc::SSLStreamAdapter::HaveDtlsSrtp);
1748 SendAudioVideoStream1(); 1626 mediastream_signaling_.SendAudioVideoStream1();
1749 InitWithDtls(GetParam()); 1627 InitWithDtls(GetParam());
1750 SetFactoryDtlsSrtp(); 1628 SetFactoryDtlsSrtp();
1751 cricket::MediaSessionOptions options; 1629 cricket::MediaSessionOptions options;
1752 options.recv_video = true; 1630 options.recv_video = true;
1753 JsepSessionDescription* offer = 1631 JsepSessionDescription* offer =
1754 CreateRemoteOffer(options, cricket::SEC_DISABLED); 1632 CreateRemoteOffer(options, cricket::SEC_DISABLED);
1755 ASSERT_TRUE(offer != NULL); 1633 ASSERT_TRUE(offer != NULL);
1756 VerifyFingerprintStatus(offer->description(), true); 1634 VerifyFingerprintStatus(offer->description(), true);
1757 VerifyNoCryptoParams(offer->description(), true); 1635 VerifyNoCryptoParams(offer->description(), true);
1758 1636
1759 // SetRemoteDescription will take the ownership of the offer. 1637 // SetRemoteDescription will take the ownership of the offer.
1760 SetRemoteDescriptionWithoutError(offer); 1638 SetRemoteDescriptionWithoutError(offer);
1761 1639
1762 // Verify that we get a crypto fingerprint in the answer. 1640 // Verify that we get a crypto fingerprint in the answer.
1763 SessionDescriptionInterface* answer = CreateAnswer(NULL); 1641 SessionDescriptionInterface* answer = CreateAnswer(NULL);
1764 ASSERT_TRUE(answer != NULL); 1642 ASSERT_TRUE(answer != NULL);
1765 VerifyFingerprintStatus(answer->description(), true); 1643 VerifyFingerprintStatus(answer->description(), true);
1766 // Check that we don't have an a=crypto line in the answer. 1644 // Check that we don't have an a=crypto line in the answer.
1767 VerifyNoCryptoParams(answer->description(), true); 1645 VerifyNoCryptoParams(answer->description(), true);
1768 1646
1769 // Now set the local description, which should work, even without a=crypto. 1647 // Now set the local description, which should work, even without a=crypto.
1770 SetLocalDescriptionWithoutError(answer); 1648 SetLocalDescriptionWithoutError(answer);
1771 } 1649 }
1772 1650
1773 // Test that we set a local offer with a DTLS fingerprint when DTLS is on 1651 // Test that we set a local offer with a DTLS fingerprint when DTLS is on
1774 // and then we accept a remote answer with a DTLS fingerprint successfully. 1652 // and then we accept a remote answer with a DTLS fingerprint successfully.
1775 TEST_P(WebRtcSessionTest, TestCreateDtlsOfferReceiveDtlsAnswer) { 1653 TEST_P(WebRtcSessionTest, TestCreateDtlsOfferReceiveDtlsAnswer) {
1776 MAYBE_SKIP_TEST(rtc::SSLStreamAdapter::HaveDtlsSrtp); 1654 MAYBE_SKIP_TEST(rtc::SSLStreamAdapter::HaveDtlsSrtp);
1777 SendAudioVideoStream1(); 1655 mediastream_signaling_.SendAudioVideoStream1();
1778 InitWithDtls(GetParam()); 1656 InitWithDtls(GetParam());
1779 SetFactoryDtlsSrtp(); 1657 SetFactoryDtlsSrtp();
1780 1658
1781 // Verify that we get a crypto fingerprint in the answer. 1659 // Verify that we get a crypto fingerprint in the answer.
1782 SessionDescriptionInterface* offer = CreateOffer(); 1660 SessionDescriptionInterface* offer = CreateOffer();
1783 ASSERT_TRUE(offer != NULL); 1661 ASSERT_TRUE(offer != NULL);
1784 VerifyFingerprintStatus(offer->description(), true); 1662 VerifyFingerprintStatus(offer->description(), true);
1785 // Check that we don't have an a=crypto line in the offer. 1663 // Check that we don't have an a=crypto line in the offer.
1786 VerifyNoCryptoParams(offer->description(), true); 1664 VerifyNoCryptoParams(offer->description(), true);
1787 1665
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
1856 // SetRemoteDescription and SetLocalDescription will take the ownership of 1734 // SetRemoteDescription and SetLocalDescription will take the ownership of
1857 // the offer and answer. 1735 // the offer and answer.
1858 SetLocalDescriptionWithoutError(offer); 1736 SetLocalDescriptionWithoutError(offer);
1859 SetRemoteDescriptionAnswerExpectError( 1737 SetRemoteDescriptionAnswerExpectError(
1860 kSdpWithoutDtlsFingerprint, answer); 1738 kSdpWithoutDtlsFingerprint, answer);
1861 } 1739 }
1862 1740
1863 // Test that we create a local offer without SDES or DTLS and accept a remote 1741 // Test that we create a local offer without SDES or DTLS and accept a remote
1864 // answer without SDES or DTLS when encryption is disabled. 1742 // answer without SDES or DTLS when encryption is disabled.
1865 TEST_P(WebRtcSessionTest, TestCreateOfferReceiveAnswerWithoutEncryption) { 1743 TEST_P(WebRtcSessionTest, TestCreateOfferReceiveAnswerWithoutEncryption) {
1866 SendAudioVideoStream1(); 1744 mediastream_signaling_.SendAudioVideoStream1();
1867 options_.disable_encryption = true; 1745 options_.disable_encryption = true;
1868 InitWithDtls(GetParam()); 1746 InitWithDtls(GetParam());
1869 1747
1870 // Verify that we get a crypto fingerprint in the answer. 1748 // Verify that we get a crypto fingerprint in the answer.
1871 SessionDescriptionInterface* offer = CreateOffer(); 1749 SessionDescriptionInterface* offer = CreateOffer();
1872 ASSERT_TRUE(offer != NULL); 1750 ASSERT_TRUE(offer != NULL);
1873 VerifyFingerprintStatus(offer->description(), false); 1751 VerifyFingerprintStatus(offer->description(), false);
1874 // Check that we don't have an a=crypto line in the offer. 1752 // Check that we don't have an a=crypto line in the offer.
1875 VerifyNoCryptoParams(offer->description(), false); 1753 VerifyNoCryptoParams(offer->description(), false);
1876 1754
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
1912 VerifyFingerprintStatus(answer->description(), false); 1790 VerifyFingerprintStatus(answer->description(), false);
1913 // Check that we don't have an a=crypto line in the answer. 1791 // Check that we don't have an a=crypto line in the answer.
1914 VerifyNoCryptoParams(answer->description(), false); 1792 VerifyNoCryptoParams(answer->description(), false);
1915 1793
1916 // Now set the local description, which should work, even without a=crypto. 1794 // Now set the local description, which should work, even without a=crypto.
1917 SetLocalDescriptionWithoutError(answer); 1795 SetLocalDescriptionWithoutError(answer);
1918 } 1796 }
1919 1797
1920 TEST_F(WebRtcSessionTest, TestSetLocalOfferTwice) { 1798 TEST_F(WebRtcSessionTest, TestSetLocalOfferTwice) {
1921 Init(); 1799 Init();
1922 SendNothing(); 1800 mediastream_signaling_.SendNothing();
1923 // SetLocalDescription take ownership of offer. 1801 // SetLocalDescription take ownership of offer.
1924 SessionDescriptionInterface* offer = CreateOffer(); 1802 SessionDescriptionInterface* offer = CreateOffer();
1925 SetLocalDescriptionWithoutError(offer); 1803 SetLocalDescriptionWithoutError(offer);
1926 1804
1927 // SetLocalDescription take ownership of offer. 1805 // SetLocalDescription take ownership of offer.
1928 SessionDescriptionInterface* offer2 = CreateOffer(); 1806 SessionDescriptionInterface* offer2 = CreateOffer();
1929 SetLocalDescriptionWithoutError(offer2); 1807 SetLocalDescriptionWithoutError(offer2);
1930 } 1808 }
1931 1809
1932 TEST_F(WebRtcSessionTest, TestSetRemoteOfferTwice) { 1810 TEST_F(WebRtcSessionTest, TestSetRemoteOfferTwice) {
1933 Init(); 1811 Init();
1934 SendNothing(); 1812 mediastream_signaling_.SendNothing();
1935 // SetLocalDescription take ownership of offer. 1813 // SetLocalDescription take ownership of offer.
1936 SessionDescriptionInterface* offer = CreateOffer(); 1814 SessionDescriptionInterface* offer = CreateOffer();
1937 SetRemoteDescriptionWithoutError(offer); 1815 SetRemoteDescriptionWithoutError(offer);
1938 1816
1939 SessionDescriptionInterface* offer2 = CreateOffer(); 1817 SessionDescriptionInterface* offer2 = CreateOffer();
1940 SetRemoteDescriptionWithoutError(offer2); 1818 SetRemoteDescriptionWithoutError(offer2);
1941 } 1819 }
1942 1820
1943 TEST_F(WebRtcSessionTest, TestSetLocalAndRemoteOffer) { 1821 TEST_F(WebRtcSessionTest, TestSetLocalAndRemoteOffer) {
1944 Init(); 1822 Init();
1945 SendNothing(); 1823 mediastream_signaling_.SendNothing();
1946 SessionDescriptionInterface* offer = CreateOffer(); 1824 SessionDescriptionInterface* offer = CreateOffer();
1947 SetLocalDescriptionWithoutError(offer); 1825 SetLocalDescriptionWithoutError(offer);
1948 offer = CreateOffer(); 1826 offer = CreateOffer();
1949 SetRemoteDescriptionOfferExpectError( 1827 SetRemoteDescriptionOfferExpectError(
1950 "Called in wrong state: STATE_SENTINITIATE", offer); 1828 "Called in wrong state: STATE_SENTINITIATE", offer);
1951 } 1829 }
1952 1830
1953 TEST_F(WebRtcSessionTest, TestSetRemoteAndLocalOffer) { 1831 TEST_F(WebRtcSessionTest, TestSetRemoteAndLocalOffer) {
1954 Init(); 1832 Init();
1955 SendNothing(); 1833 mediastream_signaling_.SendNothing();
1956 SessionDescriptionInterface* offer = CreateOffer(); 1834 SessionDescriptionInterface* offer = CreateOffer();
1957 SetRemoteDescriptionWithoutError(offer); 1835 SetRemoteDescriptionWithoutError(offer);
1958 offer = CreateOffer(); 1836 offer = CreateOffer();
1959 SetLocalDescriptionOfferExpectError( 1837 SetLocalDescriptionOfferExpectError(
1960 "Called in wrong state: STATE_RECEIVEDINITIATE", offer); 1838 "Called in wrong state: STATE_RECEIVEDINITIATE", offer);
1961 } 1839 }
1962 1840
1963 TEST_F(WebRtcSessionTest, TestSetLocalPrAnswer) { 1841 TEST_F(WebRtcSessionTest, TestSetLocalPrAnswer) {
1964 Init(); 1842 Init();
1965 SendNothing(); 1843 mediastream_signaling_.SendNothing();
1966 SessionDescriptionInterface* offer = CreateRemoteOffer(); 1844 SessionDescriptionInterface* offer = CreateRemoteOffer();
1967 SetRemoteDescriptionExpectState(offer, BaseSession::STATE_RECEIVEDINITIATE); 1845 SetRemoteDescriptionExpectState(offer, BaseSession::STATE_RECEIVEDINITIATE);
1968 1846
1969 JsepSessionDescription* pranswer = static_cast<JsepSessionDescription*>( 1847 JsepSessionDescription* pranswer = static_cast<JsepSessionDescription*>(
1970 CreateAnswer(NULL)); 1848 CreateAnswer(NULL));
1971 pranswer->set_type(SessionDescriptionInterface::kPrAnswer); 1849 pranswer->set_type(SessionDescriptionInterface::kPrAnswer);
1972 SetLocalDescriptionExpectState(pranswer, BaseSession::STATE_SENTPRACCEPT); 1850 SetLocalDescriptionExpectState(pranswer, BaseSession::STATE_SENTPRACCEPT);
1973 1851
1974 SendAudioVideoStream1(); 1852 mediastream_signaling_.SendAudioVideoStream1();
1975 JsepSessionDescription* pranswer2 = static_cast<JsepSessionDescription*>( 1853 JsepSessionDescription* pranswer2 = static_cast<JsepSessionDescription*>(
1976 CreateAnswer(NULL)); 1854 CreateAnswer(NULL));
1977 pranswer2->set_type(SessionDescriptionInterface::kPrAnswer); 1855 pranswer2->set_type(SessionDescriptionInterface::kPrAnswer);
1978 1856
1979 SetLocalDescriptionExpectState(pranswer2, BaseSession::STATE_SENTPRACCEPT); 1857 SetLocalDescriptionExpectState(pranswer2, BaseSession::STATE_SENTPRACCEPT);
1980 1858
1981 SendAudioVideoStream2(); 1859 mediastream_signaling_.SendAudioVideoStream2();
1982 SessionDescriptionInterface* answer = CreateAnswer(NULL); 1860 SessionDescriptionInterface* answer = CreateAnswer(NULL);
1983 SetLocalDescriptionExpectState(answer, BaseSession::STATE_SENTACCEPT); 1861 SetLocalDescriptionExpectState(answer, BaseSession::STATE_SENTACCEPT);
1984 } 1862 }
1985 1863
1986 TEST_F(WebRtcSessionTest, TestSetRemotePrAnswer) { 1864 TEST_F(WebRtcSessionTest, TestSetRemotePrAnswer) {
1987 Init(); 1865 Init();
1988 SendNothing(); 1866 mediastream_signaling_.SendNothing();
1989 SessionDescriptionInterface* offer = CreateOffer(); 1867 SessionDescriptionInterface* offer = CreateOffer();
1990 SetLocalDescriptionExpectState(offer, BaseSession::STATE_SENTINITIATE); 1868 SetLocalDescriptionExpectState(offer, BaseSession::STATE_SENTINITIATE);
1991 1869
1992 JsepSessionDescription* pranswer = 1870 JsepSessionDescription* pranswer =
1993 CreateRemoteAnswer(session_->local_description()); 1871 CreateRemoteAnswer(session_->local_description());
1994 pranswer->set_type(SessionDescriptionInterface::kPrAnswer); 1872 pranswer->set_type(SessionDescriptionInterface::kPrAnswer);
1995 1873
1996 SetRemoteDescriptionExpectState(pranswer, 1874 SetRemoteDescriptionExpectState(pranswer,
1997 BaseSession::STATE_RECEIVEDPRACCEPT); 1875 BaseSession::STATE_RECEIVEDPRACCEPT);
1998 1876
1999 SendAudioVideoStream1(); 1877 mediastream_signaling_.SendAudioVideoStream1();
2000 JsepSessionDescription* pranswer2 = 1878 JsepSessionDescription* pranswer2 =
2001 CreateRemoteAnswer(session_->local_description()); 1879 CreateRemoteAnswer(session_->local_description());
2002 pranswer2->set_type(SessionDescriptionInterface::kPrAnswer); 1880 pranswer2->set_type(SessionDescriptionInterface::kPrAnswer);
2003 1881
2004 SetRemoteDescriptionExpectState(pranswer2, 1882 SetRemoteDescriptionExpectState(pranswer2,
2005 BaseSession::STATE_RECEIVEDPRACCEPT); 1883 BaseSession::STATE_RECEIVEDPRACCEPT);
2006 1884
2007 SendAudioVideoStream2(); 1885 mediastream_signaling_.SendAudioVideoStream2();
2008 SessionDescriptionInterface* answer = 1886 SessionDescriptionInterface* answer =
2009 CreateRemoteAnswer(session_->local_description()); 1887 CreateRemoteAnswer(session_->local_description());
2010 SetRemoteDescriptionExpectState(answer, BaseSession::STATE_RECEIVEDACCEPT); 1888 SetRemoteDescriptionExpectState(answer, BaseSession::STATE_RECEIVEDACCEPT);
2011 } 1889 }
2012 1890
2013 TEST_F(WebRtcSessionTest, TestSetLocalAnswerWithoutOffer) { 1891 TEST_F(WebRtcSessionTest, TestSetLocalAnswerWithoutOffer) {
2014 Init(); 1892 Init();
2015 SendNothing(); 1893 mediastream_signaling_.SendNothing();
2016 rtc::scoped_ptr<SessionDescriptionInterface> offer(CreateOffer()); 1894 rtc::scoped_ptr<SessionDescriptionInterface> offer(CreateOffer());
2017 1895
2018 SessionDescriptionInterface* answer = 1896 SessionDescriptionInterface* answer =
2019 CreateRemoteAnswer(offer.get()); 1897 CreateRemoteAnswer(offer.get());
2020 SetLocalDescriptionAnswerExpectError("Called in wrong state: STATE_INIT", 1898 SetLocalDescriptionAnswerExpectError("Called in wrong state: STATE_INIT",
2021 answer); 1899 answer);
2022 } 1900 }
2023 1901
2024 TEST_F(WebRtcSessionTest, TestSetRemoteAnswerWithoutOffer) { 1902 TEST_F(WebRtcSessionTest, TestSetRemoteAnswerWithoutOffer) {
2025 Init(); 1903 Init();
2026 SendNothing(); 1904 mediastream_signaling_.SendNothing();
2027 rtc::scoped_ptr<SessionDescriptionInterface> offer(CreateOffer()); 1905 rtc::scoped_ptr<SessionDescriptionInterface> offer(CreateOffer());
2028 1906
2029 SessionDescriptionInterface* answer = 1907 SessionDescriptionInterface* answer =
2030 CreateRemoteAnswer(offer.get()); 1908 CreateRemoteAnswer(offer.get());
2031 SetRemoteDescriptionAnswerExpectError( 1909 SetRemoteDescriptionAnswerExpectError(
2032 "Called in wrong state: STATE_INIT", answer); 1910 "Called in wrong state: STATE_INIT", answer);
2033 } 1911 }
2034 1912
2035 TEST_F(WebRtcSessionTest, TestAddRemoteCandidate) { 1913 TEST_F(WebRtcSessionTest, TestAddRemoteCandidate) {
2036 Init(); 1914 Init();
2037 SendAudioVideoStream1(); 1915 mediastream_signaling_.SendAudioVideoStream1();
2038 1916
2039 cricket::Candidate candidate; 1917 cricket::Candidate candidate;
2040 candidate.set_component(1); 1918 candidate.set_component(1);
2041 JsepIceCandidate ice_candidate1(kMediaContentName0, 0, candidate); 1919 JsepIceCandidate ice_candidate1(kMediaContentName0, 0, candidate);
2042 1920
2043 // Fail since we have not set a offer description. 1921 // Fail since we have not set a offer description.
2044 EXPECT_FALSE(session_->ProcessIceMessage(&ice_candidate1)); 1922 EXPECT_FALSE(session_->ProcessIceMessage(&ice_candidate1));
2045 1923
2046 SessionDescriptionInterface* offer = CreateOffer(); 1924 SessionDescriptionInterface* offer = CreateOffer();
2047 SetLocalDescriptionWithoutError(offer); 1925 SetLocalDescriptionWithoutError(offer);
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
2080 } 1958 }
2081 1959
2082 // Test that a remote candidate is added to the remote session description and 1960 // Test that a remote candidate is added to the remote session description and
2083 // that it is retained if the remote session description is changed. 1961 // that it is retained if the remote session description is changed.
2084 TEST_F(WebRtcSessionTest, TestRemoteCandidatesAddedToSessionDescription) { 1962 TEST_F(WebRtcSessionTest, TestRemoteCandidatesAddedToSessionDescription) {
2085 Init(); 1963 Init();
2086 cricket::Candidate candidate1; 1964 cricket::Candidate candidate1;
2087 candidate1.set_component(1); 1965 candidate1.set_component(1);
2088 JsepIceCandidate ice_candidate1(kMediaContentName0, kMediaContentIndex0, 1966 JsepIceCandidate ice_candidate1(kMediaContentName0, kMediaContentIndex0,
2089 candidate1); 1967 candidate1);
2090 SendAudioVideoStream1(); 1968 mediastream_signaling_.SendAudioVideoStream1();
2091 CreateAndSetRemoteOfferAndLocalAnswer(); 1969 CreateAndSetRemoteOfferAndLocalAnswer();
2092 1970
2093 EXPECT_TRUE(session_->ProcessIceMessage(&ice_candidate1)); 1971 EXPECT_TRUE(session_->ProcessIceMessage(&ice_candidate1));
2094 const SessionDescriptionInterface* remote_desc = 1972 const SessionDescriptionInterface* remote_desc =
2095 session_->remote_description(); 1973 session_->remote_description();
2096 ASSERT_TRUE(remote_desc != NULL); 1974 ASSERT_TRUE(remote_desc != NULL);
2097 ASSERT_EQ(2u, remote_desc->number_of_mediasections()); 1975 ASSERT_EQ(2u, remote_desc->number_of_mediasections());
2098 const IceCandidateCollection* candidates = 1976 const IceCandidateCollection* candidates =
2099 remote_desc->candidates(kMediaContentIndex0); 1977 remote_desc->candidates(kMediaContentIndex0);
2100 ASSERT_EQ(1u, candidates->count()); 1978 ASSERT_EQ(1u, candidates->count());
(...skipping 28 matching lines...) Expand all
2129 2007
2130 // Test that the candidate is ignored if we can add the same candidate again. 2008 // Test that the candidate is ignored if we can add the same candidate again.
2131 EXPECT_TRUE(session_->ProcessIceMessage(&ice_candidate2)); 2009 EXPECT_TRUE(session_->ProcessIceMessage(&ice_candidate2));
2132 } 2010 }
2133 2011
2134 // Test that local candidates are added to the local session description and 2012 // Test that local candidates are added to the local session description and
2135 // that they are retained if the local session description is changed. 2013 // that they are retained if the local session description is changed.
2136 TEST_F(WebRtcSessionTest, TestLocalCandidatesAddedToSessionDescription) { 2014 TEST_F(WebRtcSessionTest, TestLocalCandidatesAddedToSessionDescription) {
2137 AddInterface(rtc::SocketAddress(kClientAddrHost1, kClientAddrPort)); 2015 AddInterface(rtc::SocketAddress(kClientAddrHost1, kClientAddrPort));
2138 Init(); 2016 Init();
2139 SendAudioVideoStream1(); 2017 mediastream_signaling_.SendAudioVideoStream1();
2140 CreateAndSetRemoteOfferAndLocalAnswer(); 2018 CreateAndSetRemoteOfferAndLocalAnswer();
2141 2019
2142 const SessionDescriptionInterface* local_desc = session_->local_description(); 2020 const SessionDescriptionInterface* local_desc = session_->local_description();
2143 const IceCandidateCollection* candidates = 2021 const IceCandidateCollection* candidates =
2144 local_desc->candidates(kMediaContentIndex0); 2022 local_desc->candidates(kMediaContentIndex0);
2145 ASSERT_TRUE(candidates != NULL); 2023 ASSERT_TRUE(candidates != NULL);
2146 EXPECT_EQ(0u, candidates->count()); 2024 EXPECT_EQ(0u, candidates->count());
2147 2025
2148 EXPECT_TRUE_WAIT(observer_.oncandidatesready_, kIceCandidatesTimeout); 2026 EXPECT_TRUE_WAIT(observer_.oncandidatesready_, kIceCandidatesTimeout);
2149 2027
2150 local_desc = session_->local_description(); 2028 local_desc = session_->local_description();
2151 candidates = local_desc->candidates(kMediaContentIndex0); 2029 candidates = local_desc->candidates(kMediaContentIndex0);
2152 ASSERT_TRUE(candidates != NULL); 2030 ASSERT_TRUE(candidates != NULL);
2153 EXPECT_LT(0u, candidates->count()); 2031 EXPECT_LT(0u, candidates->count());
2154 candidates = local_desc->candidates(1); 2032 candidates = local_desc->candidates(1);
2155 ASSERT_TRUE(candidates != NULL); 2033 ASSERT_TRUE(candidates != NULL);
2156 EXPECT_EQ(0u, candidates->count()); 2034 EXPECT_EQ(0u, candidates->count());
2157 2035
2158 // Update the session descriptions. 2036 // Update the session descriptions.
2159 SendAudioVideoStream1(); 2037 mediastream_signaling_.SendAudioVideoStream1();
2160 CreateAndSetRemoteOfferAndLocalAnswer(); 2038 CreateAndSetRemoteOfferAndLocalAnswer();
2161 2039
2162 local_desc = session_->local_description(); 2040 local_desc = session_->local_description();
2163 candidates = local_desc->candidates(kMediaContentIndex0); 2041 candidates = local_desc->candidates(kMediaContentIndex0);
2164 ASSERT_TRUE(candidates != NULL); 2042 ASSERT_TRUE(candidates != NULL);
2165 EXPECT_LT(0u, candidates->count()); 2043 EXPECT_LT(0u, candidates->count());
2166 candidates = local_desc->candidates(1); 2044 candidates = local_desc->candidates(1);
2167 ASSERT_TRUE(candidates != NULL); 2045 ASSERT_TRUE(candidates != NULL);
2168 EXPECT_EQ(0u, candidates->count()); 2046 EXPECT_EQ(0u, candidates->count());
2169 } 2047 }
2170 2048
2171 // Test that we can set a remote session description with remote candidates. 2049 // Test that we can set a remote session description with remote candidates.
2172 TEST_F(WebRtcSessionTest, TestSetRemoteSessionDescriptionWithCandidates) { 2050 TEST_F(WebRtcSessionTest, TestSetRemoteSessionDescriptionWithCandidates) {
2173 Init(); 2051 Init();
2174 2052
2175 cricket::Candidate candidate1; 2053 cricket::Candidate candidate1;
2176 candidate1.set_component(1); 2054 candidate1.set_component(1);
2177 JsepIceCandidate ice_candidate(kMediaContentName0, kMediaContentIndex0, 2055 JsepIceCandidate ice_candidate(kMediaContentName0, kMediaContentIndex0,
2178 candidate1); 2056 candidate1);
2179 SendAudioVideoStream1(); 2057 mediastream_signaling_.SendAudioVideoStream1();
2180 SessionDescriptionInterface* offer = CreateOffer(); 2058 SessionDescriptionInterface* offer = CreateOffer();
2181 2059
2182 EXPECT_TRUE(offer->AddCandidate(&ice_candidate)); 2060 EXPECT_TRUE(offer->AddCandidate(&ice_candidate));
2183 SetRemoteDescriptionWithoutError(offer); 2061 SetRemoteDescriptionWithoutError(offer);
2184 2062
2185 const SessionDescriptionInterface* remote_desc = 2063 const SessionDescriptionInterface* remote_desc =
2186 session_->remote_description(); 2064 session_->remote_description();
2187 ASSERT_TRUE(remote_desc != NULL); 2065 ASSERT_TRUE(remote_desc != NULL);
2188 ASSERT_EQ(2u, remote_desc->number_of_mediasections()); 2066 ASSERT_EQ(2u, remote_desc->number_of_mediasections());
2189 const IceCandidateCollection* candidates = 2067 const IceCandidateCollection* candidates =
2190 remote_desc->candidates(kMediaContentIndex0); 2068 remote_desc->candidates(kMediaContentIndex0);
2191 ASSERT_EQ(1u, candidates->count()); 2069 ASSERT_EQ(1u, candidates->count());
2192 EXPECT_EQ(kMediaContentIndex0, candidates->at(0)->sdp_mline_index()); 2070 EXPECT_EQ(kMediaContentIndex0, candidates->at(0)->sdp_mline_index());
2193 2071
2194 SessionDescriptionInterface* answer = CreateAnswer(NULL); 2072 SessionDescriptionInterface* answer = CreateAnswer(NULL);
2195 SetLocalDescriptionWithoutError(answer); 2073 SetLocalDescriptionWithoutError(answer);
2196 } 2074 }
2197 2075
2198 // Test that offers and answers contains ice candidates when Ice candidates have 2076 // Test that offers and answers contains ice candidates when Ice candidates have
2199 // been gathered. 2077 // been gathered.
2200 TEST_F(WebRtcSessionTest, TestSetLocalAndRemoteDescriptionWithCandidates) { 2078 TEST_F(WebRtcSessionTest, TestSetLocalAndRemoteDescriptionWithCandidates) {
2201 AddInterface(rtc::SocketAddress(kClientAddrHost1, kClientAddrPort)); 2079 AddInterface(rtc::SocketAddress(kClientAddrHost1, kClientAddrPort));
2202 Init(); 2080 Init();
2203 SendAudioVideoStream1(); 2081 mediastream_signaling_.SendAudioVideoStream1();
2204 // Ice is started but candidates are not provided until SetLocalDescription 2082 // Ice is started but candidates are not provided until SetLocalDescription
2205 // is called. 2083 // is called.
2206 EXPECT_EQ(0u, observer_.mline_0_candidates_.size()); 2084 EXPECT_EQ(0u, observer_.mline_0_candidates_.size());
2207 EXPECT_EQ(0u, observer_.mline_1_candidates_.size()); 2085 EXPECT_EQ(0u, observer_.mline_1_candidates_.size());
2208 CreateAndSetRemoteOfferAndLocalAnswer(); 2086 CreateAndSetRemoteOfferAndLocalAnswer();
2209 // Wait until at least one local candidate has been collected. 2087 // Wait until at least one local candidate has been collected.
2210 EXPECT_TRUE_WAIT(0u < observer_.mline_0_candidates_.size(), 2088 EXPECT_TRUE_WAIT(0u < observer_.mline_0_candidates_.size(),
2211 kIceCandidatesTimeout); 2089 kIceCandidatesTimeout);
2212 2090
2213 rtc::scoped_ptr<SessionDescriptionInterface> local_offer(CreateOffer()); 2091 rtc::scoped_ptr<SessionDescriptionInterface> local_offer(CreateOffer());
2214 2092
2215 ASSERT_TRUE(local_offer->candidates(kMediaContentIndex0) != NULL); 2093 ASSERT_TRUE(local_offer->candidates(kMediaContentIndex0) != NULL);
2216 EXPECT_LT(0u, local_offer->candidates(kMediaContentIndex0)->count()); 2094 EXPECT_LT(0u, local_offer->candidates(kMediaContentIndex0)->count());
2217 2095
2218 SessionDescriptionInterface* remote_offer(CreateRemoteOffer()); 2096 SessionDescriptionInterface* remote_offer(CreateRemoteOffer());
2219 SetRemoteDescriptionWithoutError(remote_offer); 2097 SetRemoteDescriptionWithoutError(remote_offer);
2220 SessionDescriptionInterface* answer = CreateAnswer(NULL); 2098 SessionDescriptionInterface* answer = CreateAnswer(NULL);
2221 ASSERT_TRUE(answer->candidates(kMediaContentIndex0) != NULL); 2099 ASSERT_TRUE(answer->candidates(kMediaContentIndex0) != NULL);
2222 EXPECT_LT(0u, answer->candidates(kMediaContentIndex0)->count()); 2100 EXPECT_LT(0u, answer->candidates(kMediaContentIndex0)->count());
2223 SetLocalDescriptionWithoutError(answer); 2101 SetLocalDescriptionWithoutError(answer);
2224 } 2102 }
2225 2103
2226 // Verifies TransportProxy and media channels are created with content names 2104 // Verifies TransportProxy and media channels are created with content names
2227 // present in the SessionDescription. 2105 // present in the SessionDescription.
2228 TEST_F(WebRtcSessionTest, TestChannelCreationsWithContentNames) { 2106 TEST_F(WebRtcSessionTest, TestChannelCreationsWithContentNames) {
2229 Init(); 2107 Init();
2230 SendAudioVideoStream1(); 2108 mediastream_signaling_.SendAudioVideoStream1();
2231 rtc::scoped_ptr<SessionDescriptionInterface> offer(CreateOffer()); 2109 rtc::scoped_ptr<SessionDescriptionInterface> offer(CreateOffer());
2232 2110
2233 // CreateOffer creates session description with the content names "audio" and 2111 // CreateOffer creates session description with the content names "audio" and
2234 // "video". Goal is to modify these content names and verify transport channel 2112 // "video". Goal is to modify these content names and verify transport channel
2235 // proxy in the BaseSession, as proxies are created with the content names 2113 // proxy in the BaseSession, as proxies are created with the content names
2236 // present in SDP. 2114 // present in SDP.
2237 std::string sdp; 2115 std::string sdp;
2238 EXPECT_TRUE(offer->ToString(&sdp)); 2116 EXPECT_TRUE(offer->ToString(&sdp));
2239 const std::string kAudioMid = "a=mid:audio"; 2117 const std::string kAudioMid = "a=mid:audio";
2240 const std::string kAudioMidReplaceStr = "a=mid:audio_content_name"; 2118 const std::string kAudioMidReplaceStr = "a=mid:audio_content_name";
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
2285 EXPECT_TRUE(content != NULL); 2163 EXPECT_TRUE(content != NULL);
2286 content = cricket::GetFirstVideoContent(offer->description()); 2164 content = cricket::GetFirstVideoContent(offer->description());
2287 EXPECT_TRUE(content == NULL); 2165 EXPECT_TRUE(content == NULL);
2288 } 2166 }
2289 2167
2290 // Test that an offer contains the correct media content descriptions based on 2168 // Test that an offer contains the correct media content descriptions based on
2291 // the send streams when no constraints have been set. 2169 // the send streams when no constraints have been set.
2292 TEST_F(WebRtcSessionTest, CreateOfferWithoutConstraints) { 2170 TEST_F(WebRtcSessionTest, CreateOfferWithoutConstraints) {
2293 Init(); 2171 Init();
2294 // Test Audio only offer. 2172 // Test Audio only offer.
2295 SendAudioOnlyStream2(); 2173 mediastream_signaling_.UseOptionsAudioOnly();
2296 rtc::scoped_ptr<SessionDescriptionInterface> offer(CreateOffer()); 2174 rtc::scoped_ptr<SessionDescriptionInterface> offer(CreateOffer());
2297 2175
2298 const cricket::ContentInfo* content = 2176 const cricket::ContentInfo* content =
2299 cricket::GetFirstAudioContent(offer->description()); 2177 cricket::GetFirstAudioContent(offer->description());
2300 EXPECT_TRUE(content != NULL); 2178 EXPECT_TRUE(content != NULL);
2301 content = cricket::GetFirstVideoContent(offer->description()); 2179 content = cricket::GetFirstVideoContent(offer->description());
2302 EXPECT_TRUE(content == NULL); 2180 EXPECT_TRUE(content == NULL);
2303 2181
2304 // Test Audio / Video offer. 2182 // Test Audio / Video offer.
2305 SendAudioVideoStream1(); 2183 mediastream_signaling_.SendAudioVideoStream1();
2306 offer.reset(CreateOffer()); 2184 offer.reset(CreateOffer());
2307 content = cricket::GetFirstAudioContent(offer->description()); 2185 content = cricket::GetFirstAudioContent(offer->description());
2308 EXPECT_TRUE(content != NULL); 2186 EXPECT_TRUE(content != NULL);
2309 content = cricket::GetFirstVideoContent(offer->description()); 2187 content = cricket::GetFirstVideoContent(offer->description());
2310 EXPECT_TRUE(content != NULL); 2188 EXPECT_TRUE(content != NULL);
2311 } 2189 }
2312 2190
2313 // Test that an offer contains no media content descriptions if 2191 // Test that an offer contains no media content descriptions if
2314 // kOfferToReceiveVideo and kOfferToReceiveAudio constraints are set to false. 2192 // kOfferToReceiveVideo and kOfferToReceiveAudio constraints are set to false.
2315 TEST_F(WebRtcSessionTest, CreateOfferWithConstraintsWithoutStreams) { 2193 TEST_F(WebRtcSessionTest, CreateOfferWithConstraintsWithoutStreams) {
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
2434 } 2312 }
2435 2313
2436 // Test that an answer contains the correct media content descriptions when no 2314 // Test that an answer contains the correct media content descriptions when no
2437 // constraints have been set. 2315 // constraints have been set.
2438 TEST_F(WebRtcSessionTest, CreateAnswerWithoutConstraints) { 2316 TEST_F(WebRtcSessionTest, CreateAnswerWithoutConstraints) {
2439 Init(); 2317 Init();
2440 // Create a remote offer with audio and video content. 2318 // Create a remote offer with audio and video content.
2441 rtc::scoped_ptr<JsepSessionDescription> offer(CreateRemoteOffer()); 2319 rtc::scoped_ptr<JsepSessionDescription> offer(CreateRemoteOffer());
2442 SetRemoteDescriptionWithoutError(offer.release()); 2320 SetRemoteDescriptionWithoutError(offer.release());
2443 // Test with a stream with tracks. 2321 // Test with a stream with tracks.
2444 SendAudioVideoStream1(); 2322 mediastream_signaling_.SendAudioVideoStream1();
2445 rtc::scoped_ptr<SessionDescriptionInterface> answer( 2323 rtc::scoped_ptr<SessionDescriptionInterface> answer(
2446 CreateAnswer(NULL)); 2324 CreateAnswer(NULL));
2447 const cricket::ContentInfo* content = 2325 const cricket::ContentInfo* content =
2448 cricket::GetFirstAudioContent(answer->description()); 2326 cricket::GetFirstAudioContent(answer->description());
2449 ASSERT_TRUE(content != NULL); 2327 ASSERT_TRUE(content != NULL);
2450 EXPECT_FALSE(content->rejected); 2328 EXPECT_FALSE(content->rejected);
2451 2329
2452 content = cricket::GetFirstVideoContent(answer->description()); 2330 content = cricket::GetFirstVideoContent(answer->description());
2453 ASSERT_TRUE(content != NULL); 2331 ASSERT_TRUE(content != NULL);
2454 EXPECT_FALSE(content->rejected); 2332 EXPECT_FALSE(content->rejected);
(...skipping 29 matching lines...) Expand all
2484 Init(); 2362 Init();
2485 // Create a remote offer with audio and video content. 2363 // Create a remote offer with audio and video content.
2486 rtc::scoped_ptr<JsepSessionDescription> offer(CreateRemoteOffer()); 2364 rtc::scoped_ptr<JsepSessionDescription> offer(CreateRemoteOffer());
2487 SetRemoteDescriptionWithoutError(offer.release()); 2365 SetRemoteDescriptionWithoutError(offer.release());
2488 2366
2489 webrtc::FakeConstraints constraints_no_receive; 2367 webrtc::FakeConstraints constraints_no_receive;
2490 constraints_no_receive.SetMandatoryReceiveAudio(false); 2368 constraints_no_receive.SetMandatoryReceiveAudio(false);
2491 constraints_no_receive.SetMandatoryReceiveVideo(false); 2369 constraints_no_receive.SetMandatoryReceiveVideo(false);
2492 2370
2493 // Test with a stream with tracks. 2371 // Test with a stream with tracks.
2494 SendAudioVideoStream1(); 2372 mediastream_signaling_.SendAudioVideoStream1();
2495 rtc::scoped_ptr<SessionDescriptionInterface> answer( 2373 rtc::scoped_ptr<SessionDescriptionInterface> answer(
2496 CreateAnswer(&constraints_no_receive)); 2374 CreateAnswer(&constraints_no_receive));
2497 2375
2498 // TODO(perkj): Should the direction be set to SEND_ONLY? 2376 // TODO(perkj): Should the direction be set to SEND_ONLY?
2499 const cricket::ContentInfo* content = 2377 const cricket::ContentInfo* content =
2500 cricket::GetFirstAudioContent(answer->description()); 2378 cricket::GetFirstAudioContent(answer->description());
2501 ASSERT_TRUE(content != NULL); 2379 ASSERT_TRUE(content != NULL);
2502 EXPECT_FALSE(content->rejected); 2380 EXPECT_FALSE(content->rejected);
2503 2381
2504 // TODO(perkj): Should the direction be set to SEND_ONLY? 2382 // TODO(perkj): Should the direction be set to SEND_ONLY?
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
2541 EXPECT_TRUE(VerifyNoCNCodecs(content)); 2419 EXPECT_TRUE(VerifyNoCNCodecs(content));
2542 } 2420 }
2543 2421
2544 // This test verifies the call setup when remote answer with audio only and 2422 // This test verifies the call setup when remote answer with audio only and
2545 // later updates with video. 2423 // later updates with video.
2546 TEST_F(WebRtcSessionTest, TestAVOfferWithAudioOnlyAnswer) { 2424 TEST_F(WebRtcSessionTest, TestAVOfferWithAudioOnlyAnswer) {
2547 Init(); 2425 Init();
2548 EXPECT_TRUE(media_engine_->GetVideoChannel(0) == NULL); 2426 EXPECT_TRUE(media_engine_->GetVideoChannel(0) == NULL);
2549 EXPECT_TRUE(media_engine_->GetVoiceChannel(0) == NULL); 2427 EXPECT_TRUE(media_engine_->GetVoiceChannel(0) == NULL);
2550 2428
2551 SendAudioVideoStream1(); 2429 mediastream_signaling_.SendAudioVideoStream1();
2552 SessionDescriptionInterface* offer = CreateOffer(); 2430 SessionDescriptionInterface* offer = CreateOffer();
2553 2431
2554 cricket::MediaSessionOptions options; 2432 cricket::MediaSessionOptions options;
2555 SessionDescriptionInterface* answer = CreateRemoteAnswer(offer, options); 2433 SessionDescriptionInterface* answer = CreateRemoteAnswer(offer, options);
2556 2434
2557 // SetLocalDescription and SetRemoteDescriptions takes ownership of offer 2435 // SetLocalDescription and SetRemoteDescriptions takes ownership of offer
2558 // and answer; 2436 // and answer;
2559 SetLocalDescriptionWithoutError(offer); 2437 SetLocalDescriptionWithoutError(offer);
2560 SetRemoteDescriptionWithoutError(answer); 2438 SetRemoteDescriptionWithoutError(answer);
2561 2439
2562 video_channel_ = media_engine_->GetVideoChannel(0); 2440 video_channel_ = media_engine_->GetVideoChannel(0);
2563 voice_channel_ = media_engine_->GetVoiceChannel(0); 2441 voice_channel_ = media_engine_->GetVoiceChannel(0);
2564 2442
2565 ASSERT_TRUE(video_channel_ == NULL); 2443 ASSERT_TRUE(video_channel_ == NULL);
2566 2444
2567 ASSERT_EQ(0u, voice_channel_->recv_streams().size()); 2445 ASSERT_EQ(0u, voice_channel_->recv_streams().size());
2568 ASSERT_EQ(1u, voice_channel_->send_streams().size()); 2446 ASSERT_EQ(1u, voice_channel_->send_streams().size());
2569 EXPECT_EQ(kAudioTrack1, voice_channel_->send_streams()[0].id); 2447 EXPECT_EQ(kAudioTrack1, voice_channel_->send_streams()[0].id);
2570 2448
2571 // Let the remote end update the session descriptions, with Audio and Video. 2449 // Let the remote end update the session descriptions, with Audio and Video.
2572 SendAudioVideoStream2(); 2450 mediastream_signaling_.SendAudioVideoStream2();
2573 CreateAndSetRemoteOfferAndLocalAnswer(); 2451 CreateAndSetRemoteOfferAndLocalAnswer();
2574 2452
2575 video_channel_ = media_engine_->GetVideoChannel(0); 2453 video_channel_ = media_engine_->GetVideoChannel(0);
2576 voice_channel_ = media_engine_->GetVoiceChannel(0); 2454 voice_channel_ = media_engine_->GetVoiceChannel(0);
2577 2455
2578 ASSERT_TRUE(video_channel_ != NULL); 2456 ASSERT_TRUE(video_channel_ != NULL);
2579 ASSERT_TRUE(voice_channel_ != NULL); 2457 ASSERT_TRUE(voice_channel_ != NULL);
2580 2458
2581 ASSERT_EQ(1u, video_channel_->recv_streams().size()); 2459 ASSERT_EQ(1u, video_channel_->recv_streams().size());
2582 ASSERT_EQ(1u, video_channel_->send_streams().size()); 2460 ASSERT_EQ(1u, video_channel_->send_streams().size());
2583 EXPECT_EQ(kVideoTrack2, video_channel_->recv_streams()[0].id); 2461 EXPECT_EQ(kVideoTrack2, video_channel_->recv_streams()[0].id);
2584 EXPECT_EQ(kVideoTrack2, video_channel_->send_streams()[0].id); 2462 EXPECT_EQ(kVideoTrack2, video_channel_->send_streams()[0].id);
2585 ASSERT_EQ(1u, voice_channel_->recv_streams().size()); 2463 ASSERT_EQ(1u, voice_channel_->recv_streams().size());
2586 ASSERT_EQ(1u, voice_channel_->send_streams().size()); 2464 ASSERT_EQ(1u, voice_channel_->send_streams().size());
2587 EXPECT_EQ(kAudioTrack2, voice_channel_->recv_streams()[0].id); 2465 EXPECT_EQ(kAudioTrack2, voice_channel_->recv_streams()[0].id);
2588 EXPECT_EQ(kAudioTrack2, voice_channel_->send_streams()[0].id); 2466 EXPECT_EQ(kAudioTrack2, voice_channel_->send_streams()[0].id);
2589 2467
2590 // Change session back to audio only. 2468 // Change session back to audio only.
2591 SendAudioOnlyStream2(); 2469 mediastream_signaling_.UseOptionsAudioOnly();
2592 CreateAndSetRemoteOfferAndLocalAnswer(); 2470 CreateAndSetRemoteOfferAndLocalAnswer();
2593 2471
2594 EXPECT_EQ(0u, video_channel_->recv_streams().size()); 2472 EXPECT_EQ(0u, video_channel_->recv_streams().size());
2595 ASSERT_EQ(1u, voice_channel_->recv_streams().size()); 2473 ASSERT_EQ(1u, voice_channel_->recv_streams().size());
2596 EXPECT_EQ(kAudioTrack2, voice_channel_->recv_streams()[0].id); 2474 EXPECT_EQ(kAudioTrack2, voice_channel_->recv_streams()[0].id);
2597 ASSERT_EQ(1u, voice_channel_->send_streams().size()); 2475 ASSERT_EQ(1u, voice_channel_->send_streams().size());
2598 EXPECT_EQ(kAudioTrack2, voice_channel_->send_streams()[0].id); 2476 EXPECT_EQ(kAudioTrack2, voice_channel_->send_streams()[0].id);
2599 } 2477 }
2600 2478
2601 // This test verifies the call setup when remote answer with video only and 2479 // This test verifies the call setup when remote answer with video only and
2602 // later updates with audio. 2480 // later updates with audio.
2603 TEST_F(WebRtcSessionTest, TestAVOfferWithVideoOnlyAnswer) { 2481 TEST_F(WebRtcSessionTest, TestAVOfferWithVideoOnlyAnswer) {
2604 Init(); 2482 Init();
2605 EXPECT_TRUE(media_engine_->GetVideoChannel(0) == NULL); 2483 EXPECT_TRUE(media_engine_->GetVideoChannel(0) == NULL);
2606 EXPECT_TRUE(media_engine_->GetVoiceChannel(0) == NULL); 2484 EXPECT_TRUE(media_engine_->GetVoiceChannel(0) == NULL);
2607 SendAudioVideoStream1(); 2485 mediastream_signaling_.SendAudioVideoStream1();
2608 SessionDescriptionInterface* offer = CreateOffer(); 2486 SessionDescriptionInterface* offer = CreateOffer();
2609 2487
2610 cricket::MediaSessionOptions options; 2488 cricket::MediaSessionOptions options;
2611 options.recv_audio = false; 2489 options.recv_audio = false;
2612 options.recv_video = true; 2490 options.recv_video = true;
2613 SessionDescriptionInterface* answer = CreateRemoteAnswer( 2491 SessionDescriptionInterface* answer = CreateRemoteAnswer(
2614 offer, options, cricket::SEC_ENABLED); 2492 offer, options, cricket::SEC_ENABLED);
2615 2493
2616 // SetLocalDescription and SetRemoteDescriptions takes ownership of offer 2494 // SetLocalDescription and SetRemoteDescriptions takes ownership of offer
2617 // and answer. 2495 // and answer.
2618 SetLocalDescriptionWithoutError(offer); 2496 SetLocalDescriptionWithoutError(offer);
2619 SetRemoteDescriptionWithoutError(answer); 2497 SetRemoteDescriptionWithoutError(answer);
2620 2498
2621 video_channel_ = media_engine_->GetVideoChannel(0); 2499 video_channel_ = media_engine_->GetVideoChannel(0);
2622 voice_channel_ = media_engine_->GetVoiceChannel(0); 2500 voice_channel_ = media_engine_->GetVoiceChannel(0);
2623 2501
2624 ASSERT_TRUE(voice_channel_ == NULL); 2502 ASSERT_TRUE(voice_channel_ == NULL);
2625 ASSERT_TRUE(video_channel_ != NULL); 2503 ASSERT_TRUE(video_channel_ != NULL);
2626 2504
2627 EXPECT_EQ(0u, video_channel_->recv_streams().size()); 2505 EXPECT_EQ(0u, video_channel_->recv_streams().size());
2628 ASSERT_EQ(1u, video_channel_->send_streams().size()); 2506 ASSERT_EQ(1u, video_channel_->send_streams().size());
2629 EXPECT_EQ(kVideoTrack1, video_channel_->send_streams()[0].id); 2507 EXPECT_EQ(kVideoTrack1, video_channel_->send_streams()[0].id);
2630 2508
2631 // Update the session descriptions, with Audio and Video. 2509 // Update the session descriptions, with Audio and Video.
2632 SendAudioVideoStream2(); 2510 mediastream_signaling_.SendAudioVideoStream2();
2633 CreateAndSetRemoteOfferAndLocalAnswer(); 2511 CreateAndSetRemoteOfferAndLocalAnswer();
2634 2512
2635 voice_channel_ = media_engine_->GetVoiceChannel(0); 2513 voice_channel_ = media_engine_->GetVoiceChannel(0);
2636 ASSERT_TRUE(voice_channel_ != NULL); 2514 ASSERT_TRUE(voice_channel_ != NULL);
2637 2515
2638 ASSERT_EQ(1u, voice_channel_->recv_streams().size()); 2516 ASSERT_EQ(1u, voice_channel_->recv_streams().size());
2639 ASSERT_EQ(1u, voice_channel_->send_streams().size()); 2517 ASSERT_EQ(1u, voice_channel_->send_streams().size());
2640 EXPECT_EQ(kAudioTrack2, voice_channel_->recv_streams()[0].id); 2518 EXPECT_EQ(kAudioTrack2, voice_channel_->recv_streams()[0].id);
2641 EXPECT_EQ(kAudioTrack2, voice_channel_->send_streams()[0].id); 2519 EXPECT_EQ(kAudioTrack2, voice_channel_->send_streams()[0].id);
2642 2520
2643 // Change session back to video only. 2521 // Change session back to video only.
2644 SendVideoOnlyStream2(); 2522 mediastream_signaling_.UseOptionsVideoOnly();
2645 CreateAndSetRemoteOfferAndLocalAnswer(); 2523 CreateAndSetRemoteOfferAndLocalAnswer();
2646 2524
2647 video_channel_ = media_engine_->GetVideoChannel(0); 2525 video_channel_ = media_engine_->GetVideoChannel(0);
2648 voice_channel_ = media_engine_->GetVoiceChannel(0); 2526 voice_channel_ = media_engine_->GetVoiceChannel(0);
2649 2527
2650 ASSERT_EQ(1u, video_channel_->recv_streams().size()); 2528 ASSERT_EQ(1u, video_channel_->recv_streams().size());
2651 EXPECT_EQ(kVideoTrack2, video_channel_->recv_streams()[0].id); 2529 EXPECT_EQ(kVideoTrack2, video_channel_->recv_streams()[0].id);
2652 ASSERT_EQ(1u, video_channel_->send_streams().size()); 2530 ASSERT_EQ(1u, video_channel_->send_streams().size());
2653 EXPECT_EQ(kVideoTrack2, video_channel_->send_streams()[0].id); 2531 EXPECT_EQ(kVideoTrack2, video_channel_->send_streams()[0].id);
2654 } 2532 }
2655 2533
2656 TEST_F(WebRtcSessionTest, VerifyCryptoParamsInSDP) { 2534 TEST_F(WebRtcSessionTest, VerifyCryptoParamsInSDP) {
2657 Init(); 2535 Init();
2658 SendAudioVideoStream1(); 2536 mediastream_signaling_.SendAudioVideoStream1();
2659 scoped_ptr<SessionDescriptionInterface> offer(CreateOffer()); 2537 scoped_ptr<SessionDescriptionInterface> offer(CreateOffer());
2660 VerifyCryptoParams(offer->description()); 2538 VerifyCryptoParams(offer->description());
2661 SetRemoteDescriptionWithoutError(offer.release()); 2539 SetRemoteDescriptionWithoutError(offer.release());
2662 scoped_ptr<SessionDescriptionInterface> answer(CreateAnswer(NULL)); 2540 scoped_ptr<SessionDescriptionInterface> answer(CreateAnswer(NULL));
2663 VerifyCryptoParams(answer->description()); 2541 VerifyCryptoParams(answer->description());
2664 } 2542 }
2665 2543
2666 TEST_F(WebRtcSessionTest, VerifyNoCryptoParamsInSDP) { 2544 TEST_F(WebRtcSessionTest, VerifyNoCryptoParamsInSDP) {
2667 options_.disable_encryption = true; 2545 options_.disable_encryption = true;
2668 Init(); 2546 Init();
2669 SendAudioVideoStream1(); 2547 mediastream_signaling_.SendAudioVideoStream1();
2670 scoped_ptr<SessionDescriptionInterface> offer(CreateOffer()); 2548 scoped_ptr<SessionDescriptionInterface> offer(CreateOffer());
2671 VerifyNoCryptoParams(offer->description(), false); 2549 VerifyNoCryptoParams(offer->description(), false);
2672 } 2550 }
2673 2551
2674 TEST_F(WebRtcSessionTest, VerifyAnswerFromNonCryptoOffer) { 2552 TEST_F(WebRtcSessionTest, VerifyAnswerFromNonCryptoOffer) {
2675 Init(); 2553 Init();
2676 VerifyAnswerFromNonCryptoOffer(); 2554 VerifyAnswerFromNonCryptoOffer();
2677 } 2555 }
2678 2556
2679 TEST_F(WebRtcSessionTest, VerifyAnswerFromCryptoOffer) { 2557 TEST_F(WebRtcSessionTest, VerifyAnswerFromCryptoOffer) {
2680 Init(); 2558 Init();
2681 VerifyAnswerFromCryptoOffer(); 2559 VerifyAnswerFromCryptoOffer();
2682 } 2560 }
2683 2561
2684 // This test verifies that setLocalDescription fails if 2562 // This test verifies that setLocalDescription fails if
2685 // no a=ice-ufrag and a=ice-pwd lines are present in the SDP. 2563 // no a=ice-ufrag and a=ice-pwd lines are present in the SDP.
2686 TEST_F(WebRtcSessionTest, TestSetLocalDescriptionWithoutIce) { 2564 TEST_F(WebRtcSessionTest, TestSetLocalDescriptionWithoutIce) {
2687 Init(); 2565 Init();
2688 SendAudioVideoStream1(); 2566 mediastream_signaling_.SendAudioVideoStream1();
2689 rtc::scoped_ptr<SessionDescriptionInterface> offer(CreateOffer()); 2567 rtc::scoped_ptr<SessionDescriptionInterface> offer(CreateOffer());
2690 2568
2691 std::string sdp; 2569 std::string sdp;
2692 RemoveIceUfragPwdLines(offer.get(), &sdp); 2570 RemoveIceUfragPwdLines(offer.get(), &sdp);
2693 SessionDescriptionInterface* modified_offer = 2571 SessionDescriptionInterface* modified_offer =
2694 CreateSessionDescription(JsepSessionDescription::kOffer, sdp, NULL); 2572 CreateSessionDescription(JsepSessionDescription::kOffer, sdp, NULL);
2695 SetLocalDescriptionOfferExpectError(kSdpWithoutIceUfragPwd, modified_offer); 2573 SetLocalDescriptionOfferExpectError(kSdpWithoutIceUfragPwd, modified_offer);
2696 } 2574 }
2697 2575
2698 // This test verifies that setRemoteDescription fails if 2576 // This test verifies that setRemoteDescription fails if
2699 // no a=ice-ufrag and a=ice-pwd lines are present in the SDP. 2577 // no a=ice-ufrag and a=ice-pwd lines are present in the SDP.
2700 TEST_F(WebRtcSessionTest, TestSetRemoteDescriptionWithoutIce) { 2578 TEST_F(WebRtcSessionTest, TestSetRemoteDescriptionWithoutIce) {
2701 Init(); 2579 Init();
2702 rtc::scoped_ptr<SessionDescriptionInterface> offer(CreateRemoteOffer()); 2580 rtc::scoped_ptr<SessionDescriptionInterface> offer(CreateRemoteOffer());
2703 std::string sdp; 2581 std::string sdp;
2704 RemoveIceUfragPwdLines(offer.get(), &sdp); 2582 RemoveIceUfragPwdLines(offer.get(), &sdp);
2705 SessionDescriptionInterface* modified_offer = 2583 SessionDescriptionInterface* modified_offer =
2706 CreateSessionDescription(JsepSessionDescription::kOffer, sdp, NULL); 2584 CreateSessionDescription(JsepSessionDescription::kOffer, sdp, NULL);
2707 SetRemoteDescriptionOfferExpectError(kSdpWithoutIceUfragPwd, modified_offer); 2585 SetRemoteDescriptionOfferExpectError(kSdpWithoutIceUfragPwd, modified_offer);
2708 } 2586 }
2709 2587
2710 // This test verifies that setLocalDescription fails if local offer has 2588 // This test verifies that setLocalDescription fails if local offer has
2711 // too short ice ufrag and pwd strings. 2589 // too short ice ufrag and pwd strings.
2712 TEST_F(WebRtcSessionTest, TestSetLocalDescriptionInvalidIceCredentials) { 2590 TEST_F(WebRtcSessionTest, TestSetLocalDescriptionInvalidIceCredentials) {
2713 Init(); 2591 Init();
2714 SendAudioVideoStream1(); 2592 mediastream_signaling_.SendAudioVideoStream1();
2715 rtc::scoped_ptr<SessionDescriptionInterface> offer(CreateOffer()); 2593 rtc::scoped_ptr<SessionDescriptionInterface> offer(CreateOffer());
2716 2594
2717 std::string sdp; 2595 std::string sdp;
2718 // Modifying ice ufrag and pwd in local offer with strings smaller than the 2596 // Modifying ice ufrag and pwd in local offer with strings smaller than the
2719 // recommended values of 4 and 22 bytes respectively. 2597 // recommended values of 4 and 22 bytes respectively.
2720 ModifyIceUfragPwdLines(offer.get(), "ice", "icepwd", &sdp); 2598 ModifyIceUfragPwdLines(offer.get(), "ice", "icepwd", &sdp);
2721 SessionDescriptionInterface* modified_offer = 2599 SessionDescriptionInterface* modified_offer =
2722 CreateSessionDescription(JsepSessionDescription::kOffer, sdp, NULL); 2600 CreateSessionDescription(JsepSessionDescription::kOffer, sdp, NULL);
2723 std::string error; 2601 std::string error;
2724 EXPECT_FALSE(session_->SetLocalDescription(modified_offer, &error)); 2602 EXPECT_FALSE(session_->SetLocalDescription(modified_offer, &error));
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
2810 SetRemoteDescriptionWithoutError(offer4); 2688 SetRemoteDescriptionWithoutError(offer4);
2811 EXPECT_EQ(0, session_->remote_description()->candidates(0)->count()); 2689 EXPECT_EQ(0, session_->remote_description()->candidates(0)->count());
2812 } 2690 }
2813 2691
2814 // Test that candidates sent to the "video" transport do not get pushed down to 2692 // Test that candidates sent to the "video" transport do not get pushed down to
2815 // the "audio" transport channel when bundling using TransportProxy. 2693 // the "audio" transport channel when bundling using TransportProxy.
2816 TEST_F(WebRtcSessionTest, TestIgnoreCandidatesForUnusedTransportWhenBundling) { 2694 TEST_F(WebRtcSessionTest, TestIgnoreCandidatesForUnusedTransportWhenBundling) {
2817 AddInterface(rtc::SocketAddress(kClientAddrHost1, kClientAddrPort)); 2695 AddInterface(rtc::SocketAddress(kClientAddrHost1, kClientAddrPort));
2818 2696
2819 InitWithBundlePolicy(PeerConnectionInterface::kBundlePolicyBalanced); 2697 InitWithBundlePolicy(PeerConnectionInterface::kBundlePolicyBalanced);
2820 SendAudioVideoStream1(); 2698 mediastream_signaling_.SendAudioVideoStream1();
2821 2699
2822 PeerConnectionInterface::RTCOfferAnswerOptions options; 2700 PeerConnectionInterface::RTCOfferAnswerOptions options;
2823 options.use_rtp_mux = true; 2701 options.use_rtp_mux = true;
2824 2702
2825 SessionDescriptionInterface* offer = CreateRemoteOffer(); 2703 SessionDescriptionInterface* offer = CreateRemoteOffer();
2826 SetRemoteDescriptionWithoutError(offer); 2704 SetRemoteDescriptionWithoutError(offer);
2827 2705
2828 SessionDescriptionInterface* answer = CreateAnswer(NULL); 2706 SessionDescriptionInterface* answer = CreateAnswer(NULL);
2829 SetLocalDescriptionWithoutError(answer); 2707 SetLocalDescriptionWithoutError(answer);
2830 2708
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
2893 2771
2894 // No need here for a _WAIT check since we are checking that state hasn't 2772 // No need here for a _WAIT check since we are checking that state hasn't
2895 // changed: if this is false we would be doing waits for nothing and if this 2773 // changed: if this is false we would be doing waits for nothing and if this
2896 // is true then there will be no messages processed anyways. 2774 // is true then there will be no messages processed anyways.
2897 EXPECT_FALSE(connection_with_remote_port(6000)); 2775 EXPECT_FALSE(connection_with_remote_port(6000));
2898 } 2776 }
2899 2777
2900 // kBundlePolicyBalanced BUNDLE policy and answer contains BUNDLE. 2778 // kBundlePolicyBalanced BUNDLE policy and answer contains BUNDLE.
2901 TEST_F(WebRtcSessionTest, TestBalancedBundleInAnswer) { 2779 TEST_F(WebRtcSessionTest, TestBalancedBundleInAnswer) {
2902 InitWithBundlePolicy(PeerConnectionInterface::kBundlePolicyBalanced); 2780 InitWithBundlePolicy(PeerConnectionInterface::kBundlePolicyBalanced);
2903 SendAudioVideoStream1(); 2781 mediastream_signaling_.SendAudioVideoStream1();
2904 2782
2905 PeerConnectionInterface::RTCOfferAnswerOptions options; 2783 PeerConnectionInterface::RTCOfferAnswerOptions options;
2906 options.use_rtp_mux = true; 2784 options.use_rtp_mux = true;
2907 2785
2908 SessionDescriptionInterface* offer = CreateOffer(options); 2786 SessionDescriptionInterface* offer = CreateOffer(options);
2909 SetLocalDescriptionWithoutError(offer); 2787 SetLocalDescriptionWithoutError(offer);
2910 2788
2911 EXPECT_NE(session_->voice_rtp_transport_channel(), 2789 EXPECT_NE(session_->voice_rtp_transport_channel(),
2912 session_->video_rtp_transport_channel()); 2790 session_->video_rtp_transport_channel());
2913 2791
2914 SendAudioVideoStream2(); 2792 mediastream_signaling_.SendAudioVideoStream2();
2915 SessionDescriptionInterface* answer = 2793 SessionDescriptionInterface* answer =
2916 CreateRemoteAnswer(session_->local_description()); 2794 CreateRemoteAnswer(session_->local_description());
2917 SetRemoteDescriptionWithoutError(answer); 2795 SetRemoteDescriptionWithoutError(answer);
2918 2796
2919 EXPECT_EQ(session_->voice_rtp_transport_channel(), 2797 EXPECT_EQ(session_->voice_rtp_transport_channel(),
2920 session_->video_rtp_transport_channel()); 2798 session_->video_rtp_transport_channel());
2921 } 2799 }
2922 2800
2923 // kBundlePolicyBalanced BUNDLE policy but no BUNDLE in the answer. 2801 // kBundlePolicyBalanced BUNDLE policy but no BUNDLE in the answer.
2924 TEST_F(WebRtcSessionTest, TestBalancedNoBundleInAnswer) { 2802 TEST_F(WebRtcSessionTest, TestBalancedNoBundleInAnswer) {
2925 InitWithBundlePolicy(PeerConnectionInterface::kBundlePolicyBalanced); 2803 InitWithBundlePolicy(PeerConnectionInterface::kBundlePolicyBalanced);
2926 SendAudioVideoStream1(); 2804 mediastream_signaling_.SendAudioVideoStream1();
2927 2805
2928 PeerConnectionInterface::RTCOfferAnswerOptions options; 2806 PeerConnectionInterface::RTCOfferAnswerOptions options;
2929 options.use_rtp_mux = true; 2807 options.use_rtp_mux = true;
2930 2808
2931 SessionDescriptionInterface* offer = CreateOffer(options); 2809 SessionDescriptionInterface* offer = CreateOffer(options);
2932 SetLocalDescriptionWithoutError(offer); 2810 SetLocalDescriptionWithoutError(offer);
2933 2811
2934 EXPECT_NE(session_->voice_rtp_transport_channel(), 2812 EXPECT_NE(session_->voice_rtp_transport_channel(),
2935 session_->video_rtp_transport_channel()); 2813 session_->video_rtp_transport_channel());
2936 2814
2937 SendAudioVideoStream2(); 2815 mediastream_signaling_.SendAudioVideoStream2();
2938 2816
2939 // Remove BUNDLE from the answer. 2817 // Remove BUNDLE from the answer.
2940 rtc::scoped_ptr<SessionDescriptionInterface> answer( 2818 rtc::scoped_ptr<SessionDescriptionInterface> answer(
2941 CreateRemoteAnswer(session_->local_description())); 2819 CreateRemoteAnswer(session_->local_description()));
2942 cricket::SessionDescription* answer_copy = answer->description()->Copy(); 2820 cricket::SessionDescription* answer_copy = answer->description()->Copy();
2943 answer_copy->RemoveGroupByName(cricket::GROUP_TYPE_BUNDLE); 2821 answer_copy->RemoveGroupByName(cricket::GROUP_TYPE_BUNDLE);
2944 JsepSessionDescription* modified_answer = 2822 JsepSessionDescription* modified_answer =
2945 new JsepSessionDescription(JsepSessionDescription::kAnswer); 2823 new JsepSessionDescription(JsepSessionDescription::kAnswer);
2946 modified_answer->Initialize(answer_copy, "1", "1"); 2824 modified_answer->Initialize(answer_copy, "1", "1");
2947 SetRemoteDescriptionWithoutError(modified_answer); // 2825 SetRemoteDescriptionWithoutError(modified_answer); //
2948 2826
2949 EXPECT_NE(session_->voice_rtp_transport_channel(), 2827 EXPECT_NE(session_->voice_rtp_transport_channel(),
2950 session_->video_rtp_transport_channel()); 2828 session_->video_rtp_transport_channel());
2951 } 2829 }
2952 2830
2953 // kBundlePolicyMaxBundle policy with BUNDLE in the answer. 2831 // kBundlePolicyMaxBundle policy with BUNDLE in the answer.
2954 TEST_F(WebRtcSessionTest, TestMaxBundleBundleInAnswer) { 2832 TEST_F(WebRtcSessionTest, TestMaxBundleBundleInAnswer) {
2955 InitWithBundlePolicy(PeerConnectionInterface::kBundlePolicyMaxBundle); 2833 InitWithBundlePolicy(PeerConnectionInterface::kBundlePolicyMaxBundle);
2956 SendAudioVideoStream1(); 2834 mediastream_signaling_.SendAudioVideoStream1();
2957 2835
2958 PeerConnectionInterface::RTCOfferAnswerOptions options; 2836 PeerConnectionInterface::RTCOfferAnswerOptions options;
2959 options.use_rtp_mux = true; 2837 options.use_rtp_mux = true;
2960 2838
2961 SessionDescriptionInterface* offer = CreateOffer(options); 2839 SessionDescriptionInterface* offer = CreateOffer(options);
2962 SetLocalDescriptionWithoutError(offer); 2840 SetLocalDescriptionWithoutError(offer);
2963 2841
2964 EXPECT_EQ(session_->voice_rtp_transport_channel(), 2842 EXPECT_EQ(session_->voice_rtp_transport_channel(),
2965 session_->video_rtp_transport_channel()); 2843 session_->video_rtp_transport_channel());
2966 2844
2967 SendAudioVideoStream2(); 2845 mediastream_signaling_.SendAudioVideoStream2();
2968 SessionDescriptionInterface* answer = 2846 SessionDescriptionInterface* answer =
2969 CreateRemoteAnswer(session_->local_description()); 2847 CreateRemoteAnswer(session_->local_description());
2970 SetRemoteDescriptionWithoutError(answer); 2848 SetRemoteDescriptionWithoutError(answer);
2971 2849
2972 EXPECT_EQ(session_->voice_rtp_transport_channel(), 2850 EXPECT_EQ(session_->voice_rtp_transport_channel(),
2973 session_->video_rtp_transport_channel()); 2851 session_->video_rtp_transport_channel());
2974 } 2852 }
2975 2853
2976 // kBundlePolicyMaxBundle policy with BUNDLE in the answer, but no 2854 // kBundlePolicyMaxBundle policy with BUNDLE in the answer, but no
2977 // audio content in the answer. 2855 // audio content in the answer.
2978 TEST_F(WebRtcSessionTest, TestMaxBundleRejectAudio) { 2856 TEST_F(WebRtcSessionTest, TestMaxBundleRejectAudio) {
2979 InitWithBundlePolicy(PeerConnectionInterface::kBundlePolicyMaxBundle); 2857 InitWithBundlePolicy(PeerConnectionInterface::kBundlePolicyMaxBundle);
2980 SendAudioVideoStream1(); 2858 mediastream_signaling_.SendAudioVideoStream1();
2981 2859
2982 PeerConnectionInterface::RTCOfferAnswerOptions options; 2860 PeerConnectionInterface::RTCOfferAnswerOptions options;
2983 options.use_rtp_mux = true; 2861 options.use_rtp_mux = true;
2984 2862
2985 SessionDescriptionInterface* offer = CreateOffer(options); 2863 SessionDescriptionInterface* offer = CreateOffer(options);
2986 SetLocalDescriptionWithoutError(offer); 2864 SetLocalDescriptionWithoutError(offer);
2987 2865
2988 EXPECT_EQ(session_->voice_rtp_transport_channel(), 2866 EXPECT_EQ(session_->voice_rtp_transport_channel(),
2989 session_->video_rtp_transport_channel()); 2867 session_->video_rtp_transport_channel());
2990 2868
2991 SendAudioVideoStream2(); 2869 mediastream_signaling_.SendAudioVideoStream2();
2992 cricket::MediaSessionOptions recv_options; 2870 cricket::MediaSessionOptions recv_options;
2993 recv_options.recv_audio = false; 2871 recv_options.recv_audio = false;
2994 recv_options.recv_video = true; 2872 recv_options.recv_video = true;
2995 SessionDescriptionInterface* answer = 2873 SessionDescriptionInterface* answer =
2996 CreateRemoteAnswer(session_->local_description(), recv_options); 2874 CreateRemoteAnswer(session_->local_description(), recv_options);
2997 SetRemoteDescriptionWithoutError(answer); 2875 SetRemoteDescriptionWithoutError(answer);
2998 2876
2999 EXPECT_TRUE(NULL == session_->voice_channel()); 2877 EXPECT_TRUE(NULL == session_->voice_channel());
3000 EXPECT_TRUE(NULL != session_->video_rtp_transport_channel()); 2878 EXPECT_TRUE(NULL != session_->video_rtp_transport_channel());
3001 2879
3002 session_->Terminate(); 2880 session_->Terminate();
3003 EXPECT_TRUE(NULL == session_->voice_rtp_transport_channel()); 2881 EXPECT_TRUE(NULL == session_->voice_rtp_transport_channel());
3004 EXPECT_TRUE(NULL == session_->voice_rtcp_transport_channel()); 2882 EXPECT_TRUE(NULL == session_->voice_rtcp_transport_channel());
3005 EXPECT_TRUE(NULL == session_->video_rtp_transport_channel()); 2883 EXPECT_TRUE(NULL == session_->video_rtp_transport_channel());
3006 EXPECT_TRUE(NULL == session_->video_rtcp_transport_channel()); 2884 EXPECT_TRUE(NULL == session_->video_rtcp_transport_channel());
3007 } 2885 }
3008 2886
3009 // kBundlePolicyMaxBundle policy but no BUNDLE in the answer. 2887 // kBundlePolicyMaxBundle policy but no BUNDLE in the answer.
3010 TEST_F(WebRtcSessionTest, TestMaxBundleNoBundleInAnswer) { 2888 TEST_F(WebRtcSessionTest, TestMaxBundleNoBundleInAnswer) {
3011 InitWithBundlePolicy(PeerConnectionInterface::kBundlePolicyMaxBundle); 2889 InitWithBundlePolicy(PeerConnectionInterface::kBundlePolicyMaxBundle);
3012 SendAudioVideoStream1(); 2890 mediastream_signaling_.SendAudioVideoStream1();
3013 2891
3014 PeerConnectionInterface::RTCOfferAnswerOptions options; 2892 PeerConnectionInterface::RTCOfferAnswerOptions options;
3015 options.use_rtp_mux = true; 2893 options.use_rtp_mux = true;
3016 2894
3017 SessionDescriptionInterface* offer = CreateOffer(options); 2895 SessionDescriptionInterface* offer = CreateOffer(options);
3018 SetLocalDescriptionWithoutError(offer); 2896 SetLocalDescriptionWithoutError(offer);
3019 2897
3020 EXPECT_EQ(session_->voice_rtp_transport_channel(), 2898 EXPECT_EQ(session_->voice_rtp_transport_channel(),
3021 session_->video_rtp_transport_channel()); 2899 session_->video_rtp_transport_channel());
3022 2900
3023 SendAudioVideoStream2(); 2901 mediastream_signaling_.SendAudioVideoStream2();
3024 2902
3025 // Remove BUNDLE from the answer. 2903 // Remove BUNDLE from the answer.
3026 rtc::scoped_ptr<SessionDescriptionInterface> answer( 2904 rtc::scoped_ptr<SessionDescriptionInterface> answer(
3027 CreateRemoteAnswer(session_->local_description())); 2905 CreateRemoteAnswer(session_->local_description()));
3028 cricket::SessionDescription* answer_copy = answer->description()->Copy(); 2906 cricket::SessionDescription* answer_copy = answer->description()->Copy();
3029 answer_copy->RemoveGroupByName(cricket::GROUP_TYPE_BUNDLE); 2907 answer_copy->RemoveGroupByName(cricket::GROUP_TYPE_BUNDLE);
3030 JsepSessionDescription* modified_answer = 2908 JsepSessionDescription* modified_answer =
3031 new JsepSessionDescription(JsepSessionDescription::kAnswer); 2909 new JsepSessionDescription(JsepSessionDescription::kAnswer);
3032 modified_answer->Initialize(answer_copy, "1", "1"); 2910 modified_answer->Initialize(answer_copy, "1", "1");
3033 SetRemoteDescriptionWithoutError(modified_answer); 2911 SetRemoteDescriptionWithoutError(modified_answer);
3034 2912
3035 EXPECT_EQ(session_->voice_rtp_transport_channel(), 2913 EXPECT_EQ(session_->voice_rtp_transport_channel(),
3036 session_->video_rtp_transport_channel()); 2914 session_->video_rtp_transport_channel());
3037 } 2915 }
3038 2916
3039 // kBundlePolicyMaxBundle policy with BUNDLE in the remote offer. 2917 // kBundlePolicyMaxBundle policy with BUNDLE in the remote offer.
3040 TEST_F(WebRtcSessionTest, TestMaxBundleBundleInRemoteOffer) { 2918 TEST_F(WebRtcSessionTest, TestMaxBundleBundleInRemoteOffer) {
3041 InitWithBundlePolicy(PeerConnectionInterface::kBundlePolicyMaxBundle); 2919 InitWithBundlePolicy(PeerConnectionInterface::kBundlePolicyMaxBundle);
3042 SendAudioVideoStream1(); 2920 mediastream_signaling_.SendAudioVideoStream1();
3043 2921
3044 SessionDescriptionInterface* offer = CreateRemoteOffer(); 2922 SessionDescriptionInterface* offer = CreateRemoteOffer();
3045 SetRemoteDescriptionWithoutError(offer); 2923 SetRemoteDescriptionWithoutError(offer);
3046 2924
3047 EXPECT_EQ(session_->voice_rtp_transport_channel(), 2925 EXPECT_EQ(session_->voice_rtp_transport_channel(),
3048 session_->video_rtp_transport_channel()); 2926 session_->video_rtp_transport_channel());
3049 2927
3050 SendAudioVideoStream2(); 2928 mediastream_signaling_.SendAudioVideoStream2();
3051 SessionDescriptionInterface* answer = CreateAnswer(nullptr); 2929 SessionDescriptionInterface* answer = CreateAnswer(nullptr);
3052 SetLocalDescriptionWithoutError(answer); 2930 SetLocalDescriptionWithoutError(answer);
3053 2931
3054 EXPECT_EQ(session_->voice_rtp_transport_channel(), 2932 EXPECT_EQ(session_->voice_rtp_transport_channel(),
3055 session_->video_rtp_transport_channel()); 2933 session_->video_rtp_transport_channel());
3056 } 2934 }
3057 2935
3058 // kBundlePolicyMaxBundle policy but no BUNDLE in the remote offer. 2936 // kBundlePolicyMaxBundle policy but no BUNDLE in the remote offer.
3059 TEST_F(WebRtcSessionTest, TestMaxBundleNoBundleInRemoteOffer) { 2937 TEST_F(WebRtcSessionTest, TestMaxBundleNoBundleInRemoteOffer) {
3060 InitWithBundlePolicy(PeerConnectionInterface::kBundlePolicyMaxBundle); 2938 InitWithBundlePolicy(PeerConnectionInterface::kBundlePolicyMaxBundle);
3061 SendAudioVideoStream1(); 2939 mediastream_signaling_.SendAudioVideoStream1();
3062 2940
3063 // Remove BUNDLE from the offer. 2941 // Remove BUNDLE from the offer.
3064 rtc::scoped_ptr<SessionDescriptionInterface> offer(CreateRemoteOffer()); 2942 rtc::scoped_ptr<SessionDescriptionInterface> offer(CreateRemoteOffer());
3065 cricket::SessionDescription* offer_copy = offer->description()->Copy(); 2943 cricket::SessionDescription* offer_copy = offer->description()->Copy();
3066 offer_copy->RemoveGroupByName(cricket::GROUP_TYPE_BUNDLE); 2944 offer_copy->RemoveGroupByName(cricket::GROUP_TYPE_BUNDLE);
3067 JsepSessionDescription* modified_offer = 2945 JsepSessionDescription* modified_offer =
3068 new JsepSessionDescription(JsepSessionDescription::kOffer); 2946 new JsepSessionDescription(JsepSessionDescription::kOffer);
3069 modified_offer->Initialize(offer_copy, "1", "1"); 2947 modified_offer->Initialize(offer_copy, "1", "1");
3070 2948
3071 // Expect an error when applying the remote description 2949 // Expect an error when applying the remote description
3072 SetRemoteDescriptionExpectError(JsepSessionDescription::kOffer, 2950 SetRemoteDescriptionExpectError(JsepSessionDescription::kOffer,
3073 kCreateChannelFailed, modified_offer); 2951 kCreateChannelFailed, modified_offer);
3074 } 2952 }
3075 2953
3076 // kBundlePolicyMaxCompat bundle policy and answer contains BUNDLE. 2954 // kBundlePolicyMaxCompat bundle policy and answer contains BUNDLE.
3077 TEST_F(WebRtcSessionTest, TestMaxCompatBundleInAnswer) { 2955 TEST_F(WebRtcSessionTest, TestMaxCompatBundleInAnswer) {
3078 InitWithBundlePolicy(PeerConnectionInterface::kBundlePolicyMaxCompat); 2956 InitWithBundlePolicy(PeerConnectionInterface::kBundlePolicyMaxCompat);
3079 SendAudioVideoStream1(); 2957 mediastream_signaling_.SendAudioVideoStream1();
3080 2958
3081 PeerConnectionInterface::RTCOfferAnswerOptions options; 2959 PeerConnectionInterface::RTCOfferAnswerOptions options;
3082 options.use_rtp_mux = true; 2960 options.use_rtp_mux = true;
3083 2961
3084 SessionDescriptionInterface* offer = CreateOffer(options); 2962 SessionDescriptionInterface* offer = CreateOffer(options);
3085 SetLocalDescriptionWithoutError(offer); 2963 SetLocalDescriptionWithoutError(offer);
3086 2964
3087 EXPECT_NE(session_->voice_rtp_transport_channel(), 2965 EXPECT_NE(session_->voice_rtp_transport_channel(),
3088 session_->video_rtp_transport_channel()); 2966 session_->video_rtp_transport_channel());
3089 2967
3090 SendAudioVideoStream2(); 2968 mediastream_signaling_.SendAudioVideoStream2();
3091 SessionDescriptionInterface* answer = 2969 SessionDescriptionInterface* answer =
3092 CreateRemoteAnswer(session_->local_description()); 2970 CreateRemoteAnswer(session_->local_description());
3093 SetRemoteDescriptionWithoutError(answer); 2971 SetRemoteDescriptionWithoutError(answer);
3094 2972
3095 // This should lead to an audio-only call but isn't implemented 2973 // This should lead to an audio-only call but isn't implemented
3096 // correctly yet. 2974 // correctly yet.
3097 EXPECT_EQ(session_->voice_rtp_transport_channel(), 2975 EXPECT_EQ(session_->voice_rtp_transport_channel(),
3098 session_->video_rtp_transport_channel()); 2976 session_->video_rtp_transport_channel());
3099 } 2977 }
3100 2978
3101 // kBundlePolicyMaxCompat BUNDLE policy but no BUNDLE in the answer. 2979 // kBundlePolicyMaxCompat BUNDLE policy but no BUNDLE in the answer.
3102 TEST_F(WebRtcSessionTest, TestMaxCompatNoBundleInAnswer) { 2980 TEST_F(WebRtcSessionTest, TestMaxCompatNoBundleInAnswer) {
3103 InitWithBundlePolicy(PeerConnectionInterface::kBundlePolicyMaxCompat); 2981 InitWithBundlePolicy(PeerConnectionInterface::kBundlePolicyMaxCompat);
3104 SendAudioVideoStream1(); 2982 mediastream_signaling_.SendAudioVideoStream1();
3105 PeerConnectionInterface::RTCOfferAnswerOptions options; 2983 PeerConnectionInterface::RTCOfferAnswerOptions options;
3106 options.use_rtp_mux = true; 2984 options.use_rtp_mux = true;
3107 2985
3108 SessionDescriptionInterface* offer = CreateOffer(options); 2986 SessionDescriptionInterface* offer = CreateOffer(options);
3109 SetLocalDescriptionWithoutError(offer); 2987 SetLocalDescriptionWithoutError(offer);
3110 2988
3111 EXPECT_NE(session_->voice_rtp_transport_channel(), 2989 EXPECT_NE(session_->voice_rtp_transport_channel(),
3112 session_->video_rtp_transport_channel()); 2990 session_->video_rtp_transport_channel());
3113 2991
3114 SendAudioVideoStream2(); 2992 mediastream_signaling_.SendAudioVideoStream2();
3115 2993
3116 // Remove BUNDLE from the answer. 2994 // Remove BUNDLE from the answer.
3117 rtc::scoped_ptr<SessionDescriptionInterface> answer( 2995 rtc::scoped_ptr<SessionDescriptionInterface> answer(
3118 CreateRemoteAnswer(session_->local_description())); 2996 CreateRemoteAnswer(session_->local_description()));
3119 cricket::SessionDescription* answer_copy = answer->description()->Copy(); 2997 cricket::SessionDescription* answer_copy = answer->description()->Copy();
3120 answer_copy->RemoveGroupByName(cricket::GROUP_TYPE_BUNDLE); 2998 answer_copy->RemoveGroupByName(cricket::GROUP_TYPE_BUNDLE);
3121 JsepSessionDescription* modified_answer = 2999 JsepSessionDescription* modified_answer =
3122 new JsepSessionDescription(JsepSessionDescription::kAnswer); 3000 new JsepSessionDescription(JsepSessionDescription::kAnswer);
3123 modified_answer->Initialize(answer_copy, "1", "1"); 3001 modified_answer->Initialize(answer_copy, "1", "1");
3124 SetRemoteDescriptionWithoutError(modified_answer); // 3002 SetRemoteDescriptionWithoutError(modified_answer); //
3125 3003
3126 EXPECT_NE(session_->voice_rtp_transport_channel(), 3004 EXPECT_NE(session_->voice_rtp_transport_channel(),
3127 session_->video_rtp_transport_channel()); 3005 session_->video_rtp_transport_channel());
3128 } 3006 }
3129 3007
3130 // kBundlePolicyMaxbundle and then we call SetRemoteDescription first. 3008 // kBundlePolicyMaxbundle and then we call SetRemoteDescription first.
3131 TEST_F(WebRtcSessionTest, TestMaxBundleWithSetRemoteDescriptionFirst) { 3009 TEST_F(WebRtcSessionTest, TestMaxBundleWithSetRemoteDescriptionFirst) {
3132 InitWithBundlePolicy(PeerConnectionInterface::kBundlePolicyMaxBundle); 3010 InitWithBundlePolicy(PeerConnectionInterface::kBundlePolicyMaxBundle);
3133 SendAudioVideoStream1(); 3011 mediastream_signaling_.SendAudioVideoStream1();
3134 3012
3135 PeerConnectionInterface::RTCOfferAnswerOptions options; 3013 PeerConnectionInterface::RTCOfferAnswerOptions options;
3136 options.use_rtp_mux = true; 3014 options.use_rtp_mux = true;
3137 3015
3138 SessionDescriptionInterface* offer = CreateOffer(options); 3016 SessionDescriptionInterface* offer = CreateOffer(options);
3139 SetRemoteDescriptionWithoutError(offer); 3017 SetRemoteDescriptionWithoutError(offer);
3140 3018
3141 EXPECT_EQ(session_->voice_rtp_transport_channel(), 3019 EXPECT_EQ(session_->voice_rtp_transport_channel(),
3142 session_->video_rtp_transport_channel()); 3020 session_->video_rtp_transport_channel());
3143 } 3021 }
3144 3022
3145 TEST_F(WebRtcSessionTest, TestRequireRtcpMux) { 3023 TEST_F(WebRtcSessionTest, TestRequireRtcpMux) {
3146 InitWithRtcpMuxPolicy(PeerConnectionInterface::kRtcpMuxPolicyRequire); 3024 InitWithRtcpMuxPolicy(PeerConnectionInterface::kRtcpMuxPolicyRequire);
3147 SendAudioVideoStream1(); 3025 mediastream_signaling_.SendAudioVideoStream1();
3148 3026
3149 PeerConnectionInterface::RTCOfferAnswerOptions options; 3027 PeerConnectionInterface::RTCOfferAnswerOptions options;
3150 SessionDescriptionInterface* offer = CreateOffer(options); 3028 SessionDescriptionInterface* offer = CreateOffer(options);
3151 SetLocalDescriptionWithoutError(offer); 3029 SetLocalDescriptionWithoutError(offer);
3152 3030
3153 EXPECT_TRUE(session_->voice_rtcp_transport_channel() == NULL); 3031 EXPECT_TRUE(session_->voice_rtcp_transport_channel() == NULL);
3154 EXPECT_TRUE(session_->video_rtcp_transport_channel() == NULL); 3032 EXPECT_TRUE(session_->video_rtcp_transport_channel() == NULL);
3155 3033
3156 SendAudioVideoStream2(); 3034 mediastream_signaling_.SendAudioVideoStream2();
3157 SessionDescriptionInterface* answer = 3035 SessionDescriptionInterface* answer =
3158 CreateRemoteAnswer(session_->local_description()); 3036 CreateRemoteAnswer(session_->local_description());
3159 SetRemoteDescriptionWithoutError(answer); 3037 SetRemoteDescriptionWithoutError(answer);
3160 3038
3161 EXPECT_TRUE(session_->voice_rtcp_transport_channel() == NULL); 3039 EXPECT_TRUE(session_->voice_rtcp_transport_channel() == NULL);
3162 EXPECT_TRUE(session_->video_rtcp_transport_channel() == NULL); 3040 EXPECT_TRUE(session_->video_rtcp_transport_channel() == NULL);
3163 } 3041 }
3164 3042
3165 TEST_F(WebRtcSessionTest, TestNegotiateRtcpMux) { 3043 TEST_F(WebRtcSessionTest, TestNegotiateRtcpMux) {
3166 InitWithRtcpMuxPolicy(PeerConnectionInterface::kRtcpMuxPolicyNegotiate); 3044 InitWithRtcpMuxPolicy(PeerConnectionInterface::kRtcpMuxPolicyNegotiate);
3167 SendAudioVideoStream1(); 3045 mediastream_signaling_.SendAudioVideoStream1();
3168 3046
3169 PeerConnectionInterface::RTCOfferAnswerOptions options; 3047 PeerConnectionInterface::RTCOfferAnswerOptions options;
3170 SessionDescriptionInterface* offer = CreateOffer(options); 3048 SessionDescriptionInterface* offer = CreateOffer(options);
3171 SetLocalDescriptionWithoutError(offer); 3049 SetLocalDescriptionWithoutError(offer);
3172 3050
3173 EXPECT_TRUE(session_->voice_rtcp_transport_channel() != NULL); 3051 EXPECT_TRUE(session_->voice_rtcp_transport_channel() != NULL);
3174 EXPECT_TRUE(session_->video_rtcp_transport_channel() != NULL); 3052 EXPECT_TRUE(session_->video_rtcp_transport_channel() != NULL);
3175 3053
3176 SendAudioVideoStream2(); 3054 mediastream_signaling_.SendAudioVideoStream2();
3177 SessionDescriptionInterface* answer = 3055 SessionDescriptionInterface* answer =
3178 CreateRemoteAnswer(session_->local_description()); 3056 CreateRemoteAnswer(session_->local_description());
3179 SetRemoteDescriptionWithoutError(answer); 3057 SetRemoteDescriptionWithoutError(answer);
3180 3058
3181 EXPECT_TRUE(session_->voice_rtcp_transport_channel() == NULL); 3059 EXPECT_TRUE(session_->voice_rtcp_transport_channel() == NULL);
3182 EXPECT_TRUE(session_->video_rtcp_transport_channel() == NULL); 3060 EXPECT_TRUE(session_->video_rtcp_transport_channel() == NULL);
3183 } 3061 }
3184 3062
3185 // This test verifies that SetLocalDescription and SetRemoteDescription fails 3063 // This test verifies that SetLocalDescription and SetRemoteDescription fails
3186 // if BUNDLE is enabled but rtcp-mux is disabled in m-lines. 3064 // if BUNDLE is enabled but rtcp-mux is disabled in m-lines.
3187 TEST_F(WebRtcSessionTest, TestDisabledRtcpMuxWithBundleEnabled) { 3065 TEST_F(WebRtcSessionTest, TestDisabledRtcpMuxWithBundleEnabled) {
3188 Init(); 3066 Init();
3189 SendAudioVideoStream1(); 3067 mediastream_signaling_.SendAudioVideoStream1();
3190 3068
3191 PeerConnectionInterface::RTCOfferAnswerOptions options; 3069 PeerConnectionInterface::RTCOfferAnswerOptions options;
3192 options.use_rtp_mux = true; 3070 options.use_rtp_mux = true;
3193 3071
3194 SessionDescriptionInterface* offer = CreateOffer(options); 3072 SessionDescriptionInterface* offer = CreateOffer(options);
3195 std::string offer_str; 3073 std::string offer_str;
3196 offer->ToString(&offer_str); 3074 offer->ToString(&offer_str);
3197 // Disable rtcp-mux 3075 // Disable rtcp-mux
3198 const std::string rtcp_mux = "rtcp-mux"; 3076 const std::string rtcp_mux = "rtcp-mux";
3199 const std::string xrtcp_mux = "xrtcp-mux"; 3077 const std::string xrtcp_mux = "xrtcp-mux";
3200 rtc::replace_substrs(rtcp_mux.c_str(), rtcp_mux.length(), 3078 rtc::replace_substrs(rtcp_mux.c_str(), rtcp_mux.length(),
3201 xrtcp_mux.c_str(), xrtcp_mux.length(), 3079 xrtcp_mux.c_str(), xrtcp_mux.length(),
3202 &offer_str); 3080 &offer_str);
3203 JsepSessionDescription* local_offer = 3081 JsepSessionDescription* local_offer =
3204 new JsepSessionDescription(JsepSessionDescription::kOffer); 3082 new JsepSessionDescription(JsepSessionDescription::kOffer);
3205 EXPECT_TRUE((local_offer)->Initialize(offer_str, NULL)); 3083 EXPECT_TRUE((local_offer)->Initialize(offer_str, NULL));
3206 SetLocalDescriptionOfferExpectError(kBundleWithoutRtcpMux, local_offer); 3084 SetLocalDescriptionOfferExpectError(kBundleWithoutRtcpMux, local_offer);
3207 JsepSessionDescription* remote_offer = 3085 JsepSessionDescription* remote_offer =
3208 new JsepSessionDescription(JsepSessionDescription::kOffer); 3086 new JsepSessionDescription(JsepSessionDescription::kOffer);
3209 EXPECT_TRUE((remote_offer)->Initialize(offer_str, NULL)); 3087 EXPECT_TRUE((remote_offer)->Initialize(offer_str, NULL));
3210 SetRemoteDescriptionOfferExpectError(kBundleWithoutRtcpMux, remote_offer); 3088 SetRemoteDescriptionOfferExpectError(kBundleWithoutRtcpMux, remote_offer);
3211 // Trying unmodified SDP. 3089 // Trying unmodified SDP.
3212 SetLocalDescriptionWithoutError(offer); 3090 SetLocalDescriptionWithoutError(offer);
3213 } 3091 }
3214 3092
3215 TEST_F(WebRtcSessionTest, SetAudioPlayout) { 3093 TEST_F(WebRtcSessionTest, SetAudioPlayout) {
3216 Init(); 3094 Init();
3217 SendAudioVideoStream1(); 3095 mediastream_signaling_.SendAudioVideoStream1();
3218 CreateAndSetRemoteOfferAndLocalAnswer(); 3096 CreateAndSetRemoteOfferAndLocalAnswer();
3219 cricket::FakeVoiceMediaChannel* channel = media_engine_->GetVoiceChannel(0); 3097 cricket::FakeVoiceMediaChannel* channel = media_engine_->GetVoiceChannel(0);
3220 ASSERT_TRUE(channel != NULL); 3098 ASSERT_TRUE(channel != NULL);
3221 ASSERT_EQ(1u, channel->recv_streams().size()); 3099 ASSERT_EQ(1u, channel->recv_streams().size());
3222 uint32_t receive_ssrc = channel->recv_streams()[0].first_ssrc(); 3100 uint32_t receive_ssrc = channel->recv_streams()[0].first_ssrc();
3223 double volume; 3101 double volume;
3224 EXPECT_TRUE(channel->GetOutputVolume(receive_ssrc, &volume)); 3102 EXPECT_TRUE(channel->GetOutputVolume(receive_ssrc, &volume));
3225 EXPECT_EQ(1, volume); 3103 EXPECT_EQ(1, volume);
3226 session_->SetAudioPlayout(receive_ssrc, false); 3104 session_->SetAudioPlayout(receive_ssrc, false);
3227 EXPECT_TRUE(channel->GetOutputVolume(receive_ssrc, &volume)); 3105 EXPECT_TRUE(channel->GetOutputVolume(receive_ssrc, &volume));
3228 EXPECT_EQ(0, volume); 3106 EXPECT_EQ(0, volume);
3229 session_->SetAudioPlayout(receive_ssrc, true); 3107 session_->SetAudioPlayout(receive_ssrc, true);
3230 EXPECT_TRUE(channel->GetOutputVolume(receive_ssrc, &volume)); 3108 EXPECT_TRUE(channel->GetOutputVolume(receive_ssrc, &volume));
3231 EXPECT_EQ(1, volume); 3109 EXPECT_EQ(1, volume);
3232 } 3110 }
3233 3111
3234 TEST_F(WebRtcSessionTest, SetAudioSend) { 3112 TEST_F(WebRtcSessionTest, SetAudioSend) {
3235 Init(); 3113 Init();
3236 SendAudioVideoStream1(); 3114 mediastream_signaling_.SendAudioVideoStream1();
3237 CreateAndSetRemoteOfferAndLocalAnswer(); 3115 CreateAndSetRemoteOfferAndLocalAnswer();
3238 cricket::FakeVoiceMediaChannel* channel = media_engine_->GetVoiceChannel(0); 3116 cricket::FakeVoiceMediaChannel* channel = media_engine_->GetVoiceChannel(0);
3239 ASSERT_TRUE(channel != NULL); 3117 ASSERT_TRUE(channel != NULL);
3240 ASSERT_EQ(1u, channel->send_streams().size()); 3118 ASSERT_EQ(1u, channel->send_streams().size());
3241 uint32_t send_ssrc = channel->send_streams()[0].first_ssrc(); 3119 uint32_t send_ssrc = channel->send_streams()[0].first_ssrc();
3242 EXPECT_FALSE(channel->IsStreamMuted(send_ssrc)); 3120 EXPECT_FALSE(channel->IsStreamMuted(send_ssrc));
3243 3121
3244 cricket::AudioOptions options; 3122 cricket::AudioOptions options;
3245 options.echo_cancellation.Set(true); 3123 options.echo_cancellation.Set(true);
3246 3124
3247 rtc::scoped_ptr<FakeAudioRenderer> renderer(new FakeAudioRenderer()); 3125 rtc::scoped_ptr<FakeAudioRenderer> renderer(new FakeAudioRenderer());
3248 session_->SetAudioSend(send_ssrc, false, options, renderer.get()); 3126 session_->SetAudioSend(send_ssrc, false, options, renderer.get());
3249 EXPECT_TRUE(channel->IsStreamMuted(send_ssrc)); 3127 EXPECT_TRUE(channel->IsStreamMuted(send_ssrc));
3250 EXPECT_FALSE(channel->options().echo_cancellation.IsSet()); 3128 EXPECT_FALSE(channel->options().echo_cancellation.IsSet());
3251 EXPECT_TRUE(renderer->sink() != NULL); 3129 EXPECT_TRUE(renderer->sink() != NULL);
3252 3130
3253 // This will trigger SetSink(NULL) to the |renderer|. 3131 // This will trigger SetSink(NULL) to the |renderer|.
3254 session_->SetAudioSend(send_ssrc, true, options, NULL); 3132 session_->SetAudioSend(send_ssrc, true, options, NULL);
3255 EXPECT_FALSE(channel->IsStreamMuted(send_ssrc)); 3133 EXPECT_FALSE(channel->IsStreamMuted(send_ssrc));
3256 bool value; 3134 bool value;
3257 EXPECT_TRUE(channel->options().echo_cancellation.Get(&value)); 3135 EXPECT_TRUE(channel->options().echo_cancellation.Get(&value));
3258 EXPECT_TRUE(value); 3136 EXPECT_TRUE(value);
3259 EXPECT_TRUE(renderer->sink() == NULL); 3137 EXPECT_TRUE(renderer->sink() == NULL);
3260 } 3138 }
3261 3139
3262 TEST_F(WebRtcSessionTest, AudioRendererForLocalStream) { 3140 TEST_F(WebRtcSessionTest, AudioRendererForLocalStream) {
3263 Init(); 3141 Init();
3264 SendAudioVideoStream1(); 3142 mediastream_signaling_.SendAudioVideoStream1();
3265 CreateAndSetRemoteOfferAndLocalAnswer(); 3143 CreateAndSetRemoteOfferAndLocalAnswer();
3266 cricket::FakeVoiceMediaChannel* channel = media_engine_->GetVoiceChannel(0); 3144 cricket::FakeVoiceMediaChannel* channel = media_engine_->GetVoiceChannel(0);
3267 ASSERT_TRUE(channel != NULL); 3145 ASSERT_TRUE(channel != NULL);
3268 ASSERT_EQ(1u, channel->send_streams().size()); 3146 ASSERT_EQ(1u, channel->send_streams().size());
3269 uint32_t send_ssrc = channel->send_streams()[0].first_ssrc(); 3147 uint32_t send_ssrc = channel->send_streams()[0].first_ssrc();
3270 3148
3271 rtc::scoped_ptr<FakeAudioRenderer> renderer(new FakeAudioRenderer()); 3149 rtc::scoped_ptr<FakeAudioRenderer> renderer(new FakeAudioRenderer());
3272 cricket::AudioOptions options; 3150 cricket::AudioOptions options;
3273 session_->SetAudioSend(send_ssrc, true, options, renderer.get()); 3151 session_->SetAudioSend(send_ssrc, true, options, renderer.get());
3274 EXPECT_TRUE(renderer->sink() != NULL); 3152 EXPECT_TRUE(renderer->sink() != NULL);
3275 3153
3276 // Delete the |renderer| and it will trigger OnClose() to the sink, and this 3154 // Delete the |renderer| and it will trigger OnClose() to the sink, and this
3277 // will invalidate the |renderer_| pointer in the sink and prevent getting a 3155 // will invalidate the |renderer_| pointer in the sink and prevent getting a
3278 // SetSink(NULL) callback afterwards. 3156 // SetSink(NULL) callback afterwards.
3279 renderer.reset(); 3157 renderer.reset();
3280 3158
3281 // This will trigger SetSink(NULL) if no OnClose() callback. 3159 // This will trigger SetSink(NULL) if no OnClose() callback.
3282 session_->SetAudioSend(send_ssrc, true, options, NULL); 3160 session_->SetAudioSend(send_ssrc, true, options, NULL);
3283 } 3161 }
3284 3162
3285 TEST_F(WebRtcSessionTest, SetVideoPlayout) { 3163 TEST_F(WebRtcSessionTest, SetVideoPlayout) {
3286 Init(); 3164 Init();
3287 SendAudioVideoStream1(); 3165 mediastream_signaling_.SendAudioVideoStream1();
3288 CreateAndSetRemoteOfferAndLocalAnswer(); 3166 CreateAndSetRemoteOfferAndLocalAnswer();
3289 cricket::FakeVideoMediaChannel* channel = media_engine_->GetVideoChannel(0); 3167 cricket::FakeVideoMediaChannel* channel = media_engine_->GetVideoChannel(0);
3290 ASSERT_TRUE(channel != NULL); 3168 ASSERT_TRUE(channel != NULL);
3291 ASSERT_LT(0u, channel->renderers().size()); 3169 ASSERT_LT(0u, channel->renderers().size());
3292 EXPECT_TRUE(channel->renderers().begin()->second == NULL); 3170 EXPECT_TRUE(channel->renderers().begin()->second == NULL);
3293 ASSERT_EQ(1u, channel->recv_streams().size()); 3171 ASSERT_EQ(1u, channel->recv_streams().size());
3294 uint32_t receive_ssrc = channel->recv_streams()[0].first_ssrc(); 3172 uint32_t receive_ssrc = channel->recv_streams()[0].first_ssrc();
3295 cricket::FakeVideoRenderer renderer; 3173 cricket::FakeVideoRenderer renderer;
3296 session_->SetVideoPlayout(receive_ssrc, true, &renderer); 3174 session_->SetVideoPlayout(receive_ssrc, true, &renderer);
3297 EXPECT_TRUE(channel->renderers().begin()->second == &renderer); 3175 EXPECT_TRUE(channel->renderers().begin()->second == &renderer);
3298 session_->SetVideoPlayout(receive_ssrc, false, &renderer); 3176 session_->SetVideoPlayout(receive_ssrc, false, &renderer);
3299 EXPECT_TRUE(channel->renderers().begin()->second == NULL); 3177 EXPECT_TRUE(channel->renderers().begin()->second == NULL);
3300 } 3178 }
3301 3179
3302 TEST_F(WebRtcSessionTest, SetVideoSend) { 3180 TEST_F(WebRtcSessionTest, SetVideoSend) {
3303 Init(); 3181 Init();
3304 SendAudioVideoStream1(); 3182 mediastream_signaling_.SendAudioVideoStream1();
3305 CreateAndSetRemoteOfferAndLocalAnswer(); 3183 CreateAndSetRemoteOfferAndLocalAnswer();
3306 cricket::FakeVideoMediaChannel* channel = media_engine_->GetVideoChannel(0); 3184 cricket::FakeVideoMediaChannel* channel = media_engine_->GetVideoChannel(0);
3307 ASSERT_TRUE(channel != NULL); 3185 ASSERT_TRUE(channel != NULL);
3308 ASSERT_EQ(1u, channel->send_streams().size()); 3186 ASSERT_EQ(1u, channel->send_streams().size());
3309 uint32_t send_ssrc = channel->send_streams()[0].first_ssrc(); 3187 uint32_t send_ssrc = channel->send_streams()[0].first_ssrc();
3310 EXPECT_FALSE(channel->IsStreamMuted(send_ssrc)); 3188 EXPECT_FALSE(channel->IsStreamMuted(send_ssrc));
3311 cricket::VideoOptions* options = NULL; 3189 cricket::VideoOptions* options = NULL;
3312 session_->SetVideoSend(send_ssrc, false, options); 3190 session_->SetVideoSend(send_ssrc, false, options);
3313 EXPECT_TRUE(channel->IsStreamMuted(send_ssrc)); 3191 EXPECT_TRUE(channel->IsStreamMuted(send_ssrc));
3314 session_->SetVideoSend(send_ssrc, true, options); 3192 session_->SetVideoSend(send_ssrc, true, options);
3315 EXPECT_FALSE(channel->IsStreamMuted(send_ssrc)); 3193 EXPECT_FALSE(channel->IsStreamMuted(send_ssrc));
3316 } 3194 }
3317 3195
3318 TEST_F(WebRtcSessionTest, CanNotInsertDtmf) { 3196 TEST_F(WebRtcSessionTest, CanNotInsertDtmf) {
3319 TestCanInsertDtmf(false); 3197 TestCanInsertDtmf(false);
3320 } 3198 }
3321 3199
3322 TEST_F(WebRtcSessionTest, CanInsertDtmf) { 3200 TEST_F(WebRtcSessionTest, CanInsertDtmf) {
3323 TestCanInsertDtmf(true); 3201 TestCanInsertDtmf(true);
3324 } 3202 }
3325 3203
3326 TEST_F(WebRtcSessionTest, InsertDtmf) { 3204 TEST_F(WebRtcSessionTest, InsertDtmf) {
3327 // Setup 3205 // Setup
3328 Init(); 3206 Init();
3329 SendAudioVideoStream1(); 3207 mediastream_signaling_.SendAudioVideoStream1();
3330 CreateAndSetRemoteOfferAndLocalAnswer(); 3208 CreateAndSetRemoteOfferAndLocalAnswer();
3331 FakeVoiceMediaChannel* channel = media_engine_->GetVoiceChannel(0); 3209 FakeVoiceMediaChannel* channel = media_engine_->GetVoiceChannel(0);
3332 EXPECT_EQ(0U, channel->dtmf_info_queue().size()); 3210 EXPECT_EQ(0U, channel->dtmf_info_queue().size());
3333 3211
3334 // Insert DTMF 3212 // Insert DTMF
3335 const int expected_flags = DF_SEND; 3213 const int expected_flags = DF_SEND;
3336 const int expected_duration = 90; 3214 const int expected_duration = 90;
3337 session_->InsertDtmf(kAudioTrack1, 0, expected_duration); 3215 session_->InsertDtmf(kAudioTrack1, 0, expected_duration);
3338 session_->InsertDtmf(kAudioTrack1, 1, expected_duration); 3216 session_->InsertDtmf(kAudioTrack1, 1, expected_duration);
3339 session_->InsertDtmf(kAudioTrack1, 2, expected_duration); 3217 session_->InsertDtmf(kAudioTrack1, 2, expected_duration);
(...skipping 30 matching lines...) Expand all
3370 SessionDescriptionInterface* answer = CreateAnswer(NULL); 3248 SessionDescriptionInterface* answer = CreateAnswer(NULL);
3371 3249
3372 EXPECT_FALSE(session_->initiator()); 3250 EXPECT_FALSE(session_->initiator());
3373 SetLocalDescriptionWithoutError(answer); 3251 SetLocalDescriptionWithoutError(answer);
3374 EXPECT_FALSE(session_->initiator()); 3252 EXPECT_FALSE(session_->initiator());
3375 } 3253 }
3376 3254
3377 // Verifing local offer and remote answer have matching m-lines as per RFC 3264. 3255 // Verifing local offer and remote answer have matching m-lines as per RFC 3264.
3378 TEST_F(WebRtcSessionTest, TestIncorrectMLinesInRemoteAnswer) { 3256 TEST_F(WebRtcSessionTest, TestIncorrectMLinesInRemoteAnswer) {
3379 Init(); 3257 Init();
3380 SendAudioVideoStream1(); 3258 mediastream_signaling_.SendAudioVideoStream1();
3381 SessionDescriptionInterface* offer = CreateOffer(); 3259 SessionDescriptionInterface* offer = CreateOffer();
3382 SetLocalDescriptionWithoutError(offer); 3260 SetLocalDescriptionWithoutError(offer);
3383 rtc::scoped_ptr<SessionDescriptionInterface> answer( 3261 rtc::scoped_ptr<SessionDescriptionInterface> answer(
3384 CreateRemoteAnswer(session_->local_description())); 3262 CreateRemoteAnswer(session_->local_description()));
3385 3263
3386 cricket::SessionDescription* answer_copy = answer->description()->Copy(); 3264 cricket::SessionDescription* answer_copy = answer->description()->Copy();
3387 answer_copy->RemoveContentByName("video"); 3265 answer_copy->RemoveContentByName("video");
3388 JsepSessionDescription* modified_answer = 3266 JsepSessionDescription* modified_answer =
3389 new JsepSessionDescription(JsepSessionDescription::kAnswer); 3267 new JsepSessionDescription(JsepSessionDescription::kAnswer);
3390 3268
(...skipping 27 matching lines...) Expand all
3418 CreateSessionDescription(JsepSessionDescription::kAnswer, sdp, NULL); 3296 CreateSessionDescription(JsepSessionDescription::kAnswer, sdp, NULL);
3419 SetRemoteDescriptionAnswerExpectError(kMlineMismatch, modified_answer2); 3297 SetRemoteDescriptionAnswerExpectError(kMlineMismatch, modified_answer2);
3420 3298
3421 SetRemoteDescriptionWithoutError(answer.release()); 3299 SetRemoteDescriptionWithoutError(answer.release());
3422 } 3300 }
3423 3301
3424 // Verifying remote offer and local answer have matching m-lines as per 3302 // Verifying remote offer and local answer have matching m-lines as per
3425 // RFC 3264. 3303 // RFC 3264.
3426 TEST_F(WebRtcSessionTest, TestIncorrectMLinesInLocalAnswer) { 3304 TEST_F(WebRtcSessionTest, TestIncorrectMLinesInLocalAnswer) {
3427 Init(); 3305 Init();
3428 SendAudioVideoStream1(); 3306 mediastream_signaling_.SendAudioVideoStream1();
3429 SessionDescriptionInterface* offer = CreateRemoteOffer(); 3307 SessionDescriptionInterface* offer = CreateRemoteOffer();
3430 SetRemoteDescriptionWithoutError(offer); 3308 SetRemoteDescriptionWithoutError(offer);
3431 SessionDescriptionInterface* answer = CreateAnswer(NULL); 3309 SessionDescriptionInterface* answer = CreateAnswer(NULL);
3432 3310
3433 cricket::SessionDescription* answer_copy = answer->description()->Copy(); 3311 cricket::SessionDescription* answer_copy = answer->description()->Copy();
3434 answer_copy->RemoveContentByName("video"); 3312 answer_copy->RemoveContentByName("video");
3435 JsepSessionDescription* modified_answer = 3313 JsepSessionDescription* modified_answer =
3436 new JsepSessionDescription(JsepSessionDescription::kAnswer); 3314 new JsepSessionDescription(JsepSessionDescription::kAnswer);
3437 3315
3438 EXPECT_TRUE(modified_answer->Initialize(answer_copy, 3316 EXPECT_TRUE(modified_answer->Initialize(answer_copy,
3439 answer->session_id(), 3317 answer->session_id(),
3440 answer->session_version())); 3318 answer->session_version()));
3441 SetLocalDescriptionAnswerExpectError(kMlineMismatch, modified_answer); 3319 SetLocalDescriptionAnswerExpectError(kMlineMismatch, modified_answer);
3442 SetLocalDescriptionWithoutError(answer); 3320 SetLocalDescriptionWithoutError(answer);
3443 } 3321 }
3444 3322
3445 // This test verifies that WebRtcSession does not start candidate allocation 3323 // This test verifies that WebRtcSession does not start candidate allocation
3446 // before SetLocalDescription is called. 3324 // before SetLocalDescription is called.
3447 TEST_F(WebRtcSessionTest, TestIceStartAfterSetLocalDescriptionOnly) { 3325 TEST_F(WebRtcSessionTest, TestIceStartAfterSetLocalDescriptionOnly) {
3448 Init(); 3326 Init();
3449 SendAudioVideoStream1(); 3327 mediastream_signaling_.SendAudioVideoStream1();
3450 SessionDescriptionInterface* offer = CreateRemoteOffer(); 3328 SessionDescriptionInterface* offer = CreateRemoteOffer();
3451 cricket::Candidate candidate; 3329 cricket::Candidate candidate;
3452 candidate.set_component(1); 3330 candidate.set_component(1);
3453 JsepIceCandidate ice_candidate(kMediaContentName0, kMediaContentIndex0, 3331 JsepIceCandidate ice_candidate(kMediaContentName0, kMediaContentIndex0,
3454 candidate); 3332 candidate);
3455 EXPECT_TRUE(offer->AddCandidate(&ice_candidate)); 3333 EXPECT_TRUE(offer->AddCandidate(&ice_candidate));
3456 cricket::Candidate candidate1; 3334 cricket::Candidate candidate1;
3457 candidate1.set_component(1); 3335 candidate1.set_component(1);
3458 JsepIceCandidate ice_candidate1(kMediaContentName1, kMediaContentIndex1, 3336 JsepIceCandidate ice_candidate1(kMediaContentName1, kMediaContentIndex1,
3459 candidate1); 3337 candidate1);
3460 EXPECT_TRUE(offer->AddCandidate(&ice_candidate1)); 3338 EXPECT_TRUE(offer->AddCandidate(&ice_candidate1));
3461 SetRemoteDescriptionWithoutError(offer); 3339 SetRemoteDescriptionWithoutError(offer);
3462 ASSERT_TRUE(session_->voice_rtp_transport_channel() != NULL); 3340 ASSERT_TRUE(session_->voice_rtp_transport_channel() != NULL);
3463 ASSERT_TRUE(session_->video_rtp_transport_channel() != NULL); 3341 ASSERT_TRUE(session_->video_rtp_transport_channel() != NULL);
3464 3342
3465 // Pump for 1 second and verify that no candidates are generated. 3343 // Pump for 1 second and verify that no candidates are generated.
3466 rtc::Thread::Current()->ProcessMessages(1000); 3344 rtc::Thread::Current()->ProcessMessages(1000);
3467 EXPECT_TRUE(observer_.mline_0_candidates_.empty()); 3345 EXPECT_TRUE(observer_.mline_0_candidates_.empty());
3468 EXPECT_TRUE(observer_.mline_1_candidates_.empty()); 3346 EXPECT_TRUE(observer_.mline_1_candidates_.empty());
3469 3347
3470 SessionDescriptionInterface* answer = CreateAnswer(NULL); 3348 SessionDescriptionInterface* answer = CreateAnswer(NULL);
3471 SetLocalDescriptionWithoutError(answer); 3349 SetLocalDescriptionWithoutError(answer);
3472 EXPECT_TRUE_WAIT(observer_.oncandidatesready_, kIceCandidatesTimeout); 3350 EXPECT_TRUE_WAIT(observer_.oncandidatesready_, kIceCandidatesTimeout);
3473 } 3351 }
3474 3352
3475 // This test verifies that crypto parameter is updated in local session 3353 // This test verifies that crypto parameter is updated in local session
3476 // description as per security policy set in MediaSessionDescriptionFactory. 3354 // description as per security policy set in MediaSessionDescriptionFactory.
3477 TEST_F(WebRtcSessionTest, TestCryptoAfterSetLocalDescription) { 3355 TEST_F(WebRtcSessionTest, TestCryptoAfterSetLocalDescription) {
3478 Init(); 3356 Init();
3479 SendAudioVideoStream1(); 3357 mediastream_signaling_.SendAudioVideoStream1();
3480 rtc::scoped_ptr<SessionDescriptionInterface> offer(CreateOffer()); 3358 rtc::scoped_ptr<SessionDescriptionInterface> offer(CreateOffer());
3481 3359
3482 // Making sure SetLocalDescription correctly sets crypto value in 3360 // Making sure SetLocalDescription correctly sets crypto value in
3483 // SessionDescription object after de-serialization of sdp string. The value 3361 // SessionDescription object after de-serialization of sdp string. The value
3484 // will be set as per MediaSessionDescriptionFactory. 3362 // will be set as per MediaSessionDescriptionFactory.
3485 std::string offer_str; 3363 std::string offer_str;
3486 offer->ToString(&offer_str); 3364 offer->ToString(&offer_str);
3487 SessionDescriptionInterface* jsep_offer_str = 3365 SessionDescriptionInterface* jsep_offer_str =
3488 CreateSessionDescription(JsepSessionDescription::kOffer, offer_str, NULL); 3366 CreateSessionDescription(JsepSessionDescription::kOffer, offer_str, NULL);
3489 SetLocalDescriptionWithoutError(jsep_offer_str); 3367 SetLocalDescriptionWithoutError(jsep_offer_str);
3490 EXPECT_TRUE(session_->voice_channel()->secure_required()); 3368 EXPECT_TRUE(session_->voice_channel()->secure_required());
3491 EXPECT_TRUE(session_->video_channel()->secure_required()); 3369 EXPECT_TRUE(session_->video_channel()->secure_required());
3492 } 3370 }
3493 3371
3494 // This test verifies the crypto parameter when security is disabled. 3372 // This test verifies the crypto parameter when security is disabled.
3495 TEST_F(WebRtcSessionTest, TestCryptoAfterSetLocalDescriptionWithDisabled) { 3373 TEST_F(WebRtcSessionTest, TestCryptoAfterSetLocalDescriptionWithDisabled) {
3496 options_.disable_encryption = true; 3374 options_.disable_encryption = true;
3497 Init(); 3375 Init();
3498 SendAudioVideoStream1(); 3376 mediastream_signaling_.SendAudioVideoStream1();
3499 rtc::scoped_ptr<SessionDescriptionInterface> offer(CreateOffer()); 3377 rtc::scoped_ptr<SessionDescriptionInterface> offer(CreateOffer());
3500 3378
3501 // Making sure SetLocalDescription correctly sets crypto value in 3379 // Making sure SetLocalDescription correctly sets crypto value in
3502 // SessionDescription object after de-serialization of sdp string. The value 3380 // SessionDescription object after de-serialization of sdp string. The value
3503 // will be set as per MediaSessionDescriptionFactory. 3381 // will be set as per MediaSessionDescriptionFactory.
3504 std::string offer_str; 3382 std::string offer_str;
3505 offer->ToString(&offer_str); 3383 offer->ToString(&offer_str);
3506 SessionDescriptionInterface* jsep_offer_str = 3384 SessionDescriptionInterface* jsep_offer_str =
3507 CreateSessionDescription(JsepSessionDescription::kOffer, offer_str, NULL); 3385 CreateSessionDescription(JsepSessionDescription::kOffer, offer_str, NULL);
3508 SetLocalDescriptionWithoutError(jsep_offer_str); 3386 SetLocalDescriptionWithoutError(jsep_offer_str);
3509 EXPECT_FALSE(session_->voice_channel()->secure_required()); 3387 EXPECT_FALSE(session_->voice_channel()->secure_required());
3510 EXPECT_FALSE(session_->video_channel()->secure_required()); 3388 EXPECT_FALSE(session_->video_channel()->secure_required());
3511 } 3389 }
3512 3390
3513 // This test verifies that an answer contains new ufrag and password if an offer 3391 // This test verifies that an answer contains new ufrag and password if an offer
3514 // with new ufrag and password is received. 3392 // with new ufrag and password is received.
3515 TEST_F(WebRtcSessionTest, TestCreateAnswerWithNewUfragAndPassword) { 3393 TEST_F(WebRtcSessionTest, TestCreateAnswerWithNewUfragAndPassword) {
3516 Init(); 3394 Init();
3517 cricket::MediaSessionOptions options; 3395 cricket::MediaSessionOptions options;
3518 options.recv_video = true; 3396 options.recv_video = true;
3519 rtc::scoped_ptr<JsepSessionDescription> offer( 3397 rtc::scoped_ptr<JsepSessionDescription> offer(
3520 CreateRemoteOffer(options)); 3398 CreateRemoteOffer(options));
3521 SetRemoteDescriptionWithoutError(offer.release()); 3399 SetRemoteDescriptionWithoutError(offer.release());
3522 3400
3523 SendAudioVideoStream1(); 3401 mediastream_signaling_.SendAudioVideoStream1();
3524 rtc::scoped_ptr<SessionDescriptionInterface> answer( 3402 rtc::scoped_ptr<SessionDescriptionInterface> answer(
3525 CreateAnswer(NULL)); 3403 CreateAnswer(NULL));
3526 SetLocalDescriptionWithoutError(answer.release()); 3404 SetLocalDescriptionWithoutError(answer.release());
3527 3405
3528 // Receive an offer with new ufrag and password. 3406 // Receive an offer with new ufrag and password.
3529 options.transport_options.ice_restart = true; 3407 options.transport_options.ice_restart = true;
3530 rtc::scoped_ptr<JsepSessionDescription> updated_offer1( 3408 rtc::scoped_ptr<JsepSessionDescription> updated_offer1(
3531 CreateRemoteOffer(options, session_->remote_description())); 3409 CreateRemoteOffer(options, session_->remote_description()));
3532 SetRemoteDescriptionWithoutError(updated_offer1.release()); 3410 SetRemoteDescriptionWithoutError(updated_offer1.release());
3533 3411
(...skipping 10 matching lines...) Expand all
3544 // This test verifies that an answer contains old ufrag and password if an offer 3422 // This test verifies that an answer contains old ufrag and password if an offer
3545 // with old ufrag and password is received. 3423 // with old ufrag and password is received.
3546 TEST_F(WebRtcSessionTest, TestCreateAnswerWithOldUfragAndPassword) { 3424 TEST_F(WebRtcSessionTest, TestCreateAnswerWithOldUfragAndPassword) {
3547 Init(); 3425 Init();
3548 cricket::MediaSessionOptions options; 3426 cricket::MediaSessionOptions options;
3549 options.recv_video = true; 3427 options.recv_video = true;
3550 rtc::scoped_ptr<JsepSessionDescription> offer( 3428 rtc::scoped_ptr<JsepSessionDescription> offer(
3551 CreateRemoteOffer(options)); 3429 CreateRemoteOffer(options));
3552 SetRemoteDescriptionWithoutError(offer.release()); 3430 SetRemoteDescriptionWithoutError(offer.release());
3553 3431
3554 SendAudioVideoStream1(); 3432 mediastream_signaling_.SendAudioVideoStream1();
3555 rtc::scoped_ptr<SessionDescriptionInterface> answer( 3433 rtc::scoped_ptr<SessionDescriptionInterface> answer(
3556 CreateAnswer(NULL)); 3434 CreateAnswer(NULL));
3557 SetLocalDescriptionWithoutError(answer.release()); 3435 SetLocalDescriptionWithoutError(answer.release());
3558 3436
3559 // Receive an offer without changed ufrag or password. 3437 // Receive an offer without changed ufrag or password.
3560 options.transport_options.ice_restart = false; 3438 options.transport_options.ice_restart = false;
3561 rtc::scoped_ptr<JsepSessionDescription> updated_offer2( 3439 rtc::scoped_ptr<JsepSessionDescription> updated_offer2(
3562 CreateRemoteOffer(options, session_->remote_description())); 3440 CreateRemoteOffer(options, session_->remote_description()));
3563 SetRemoteDescriptionWithoutError(updated_offer2.release()); 3441 SetRemoteDescriptionWithoutError(updated_offer2.release());
3564 3442
3565 rtc::scoped_ptr<SessionDescriptionInterface> updated_answer2( 3443 rtc::scoped_ptr<SessionDescriptionInterface> updated_answer2(
3566 CreateAnswer(NULL)); 3444 CreateAnswer(NULL));
3567 3445
3568 CompareIceUfragAndPassword(updated_answer2->description(), 3446 CompareIceUfragAndPassword(updated_answer2->description(),
3569 session_->local_description()->description(), 3447 session_->local_description()->description(),
3570 true); 3448 true);
3571 3449
3572 SetLocalDescriptionWithoutError(updated_answer2.release()); 3450 SetLocalDescriptionWithoutError(updated_answer2.release());
3573 } 3451 }
3574 3452
3575 TEST_F(WebRtcSessionTest, TestSessionContentError) { 3453 TEST_F(WebRtcSessionTest, TestSessionContentError) {
3576 Init(); 3454 Init();
3577 SendAudioVideoStream1(); 3455 mediastream_signaling_.SendAudioVideoStream1();
3578 SessionDescriptionInterface* offer = CreateOffer(); 3456 SessionDescriptionInterface* offer = CreateOffer();
3579 const std::string session_id_orig = offer->session_id(); 3457 const std::string session_id_orig = offer->session_id();
3580 const std::string session_version_orig = offer->session_version(); 3458 const std::string session_version_orig = offer->session_version();
3581 SetLocalDescriptionWithoutError(offer); 3459 SetLocalDescriptionWithoutError(offer);
3582 3460
3583 video_channel_ = media_engine_->GetVideoChannel(0); 3461 video_channel_ = media_engine_->GetVideoChannel(0);
3584 video_channel_->set_fail_set_send_codecs(true); 3462 video_channel_->set_fail_set_send_codecs(true);
3585 3463
3586 SendAudioVideoStream2(); 3464 mediastream_signaling_.SendAudioVideoStream2();
3587 SessionDescriptionInterface* answer = 3465 SessionDescriptionInterface* answer =
3588 CreateRemoteAnswer(session_->local_description()); 3466 CreateRemoteAnswer(session_->local_description());
3589 SetRemoteDescriptionAnswerExpectError("ERROR_CONTENT", answer); 3467 SetRemoteDescriptionAnswerExpectError("ERROR_CONTENT", answer);
3590 } 3468 }
3591 3469
3592 // Runs the loopback call test with BUNDLE and STUN disabled. 3470 // Runs the loopback call test with BUNDLE and STUN disabled.
3593 TEST_F(WebRtcSessionTest, TestIceStatesBasic) { 3471 TEST_F(WebRtcSessionTest, TestIceStatesBasic) {
3594 // Lets try with only UDP ports. 3472 // Lets try with only UDP ports.
3595 allocator_->set_flags(cricket::PORTALLOCATOR_DISABLE_TCP | 3473 allocator_->set_flags(cricket::PORTALLOCATOR_DISABLE_TCP |
3596 cricket::PORTALLOCATOR_DISABLE_STUN | 3474 cricket::PORTALLOCATOR_DISABLE_STUN |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
3744 3622
3745 SessionDescriptionInterface* answer = ChangeSDPSctpPort( 3623 SessionDescriptionInterface* answer = ChangeSDPSctpPort(
3746 new_recv_port, CreateAnswer(NULL)); 3624 new_recv_port, CreateAnswer(NULL));
3747 ASSERT_TRUE(answer != NULL); 3625 ASSERT_TRUE(answer != NULL);
3748 3626
3749 // Now set the local description, which'll take ownership of the answer. 3627 // Now set the local description, which'll take ownership of the answer.
3750 SetLocalDescriptionWithoutError(answer); 3628 SetLocalDescriptionWithoutError(answer);
3751 3629
3752 // TEST PLAN: Set the port number to something new, set it in the SDP, 3630 // TEST PLAN: Set the port number to something new, set it in the SDP,
3753 // and pass it all the way down. 3631 // and pass it all the way down.
3632 webrtc::InternalDataChannelInit dci;
3633 dci.reliable = true;
3754 EXPECT_EQ(cricket::DCT_SCTP, data_engine_->last_channel_type()); 3634 EXPECT_EQ(cricket::DCT_SCTP, data_engine_->last_channel_type());
3755 CreateDataChannel(); 3635 rtc::scoped_refptr<webrtc::DataChannel> dc =
3636 session_->CreateDataChannel("datachannel", &dci);
3756 3637
3757 cricket::FakeDataMediaChannel* ch = data_engine_->GetChannel(0); 3638 cricket::FakeDataMediaChannel* ch = data_engine_->GetChannel(0);
3758 int portnum = -1; 3639 int portnum = -1;
3759 ASSERT_TRUE(ch != NULL); 3640 ASSERT_TRUE(ch != NULL);
3760 ASSERT_EQ(1UL, ch->send_codecs().size()); 3641 ASSERT_EQ(1UL, ch->send_codecs().size());
3761 EXPECT_EQ(cricket::kGoogleSctpDataCodecId, ch->send_codecs()[0].id); 3642 EXPECT_EQ(cricket::kGoogleSctpDataCodecId, ch->send_codecs()[0].id);
3762 EXPECT_EQ(0, strcmp(cricket::kGoogleSctpDataCodecName, 3643 EXPECT_EQ(0, strcmp(cricket::kGoogleSctpDataCodecName,
3763 ch->send_codecs()[0].name.c_str())); 3644 ch->send_codecs()[0].name.c_str()));
3764 EXPECT_TRUE(ch->send_codecs()[0].GetParam(cricket::kCodecParamPort, 3645 EXPECT_TRUE(ch->send_codecs()[0].GetParam(cricket::kCodecParamPort,
3765 &portnum)); 3646 &portnum));
3766 EXPECT_EQ(new_send_port, portnum); 3647 EXPECT_EQ(new_send_port, portnum);
3767 3648
3768 ASSERT_EQ(1UL, ch->recv_codecs().size()); 3649 ASSERT_EQ(1UL, ch->recv_codecs().size());
3769 EXPECT_EQ(cricket::kGoogleSctpDataCodecId, ch->recv_codecs()[0].id); 3650 EXPECT_EQ(cricket::kGoogleSctpDataCodecId, ch->recv_codecs()[0].id);
3770 EXPECT_EQ(0, strcmp(cricket::kGoogleSctpDataCodecName, 3651 EXPECT_EQ(0, strcmp(cricket::kGoogleSctpDataCodecName,
3771 ch->recv_codecs()[0].name.c_str())); 3652 ch->recv_codecs()[0].name.c_str()));
3772 EXPECT_TRUE(ch->recv_codecs()[0].GetParam(cricket::kCodecParamPort, 3653 EXPECT_TRUE(ch->recv_codecs()[0].GetParam(cricket::kCodecParamPort,
3773 &portnum)); 3654 &portnum));
3774 EXPECT_EQ(new_recv_port, portnum); 3655 EXPECT_EQ(new_recv_port, portnum);
3775 } 3656 }
3776 3657
3777 // Verifies that when a session's DataChannel receives an OPEN message, 3658 TEST_F(WebRtcSessionTest, TestUsesProvidedCertificate) {
3778 // WebRtcSession signals the DataChannel creation request with the expected
3779 // config.
3780 TEST_P(WebRtcSessionTest, TestSctpDataChannelOpenMessage) {
3781 MAYBE_SKIP_TEST(rtc::SSLStreamAdapter::HaveDtlsSrtp);
3782
3783 InitWithDtls(GetParam());
3784
3785 SetLocalDescriptionWithDataChannel();
3786 EXPECT_EQ(cricket::DCT_SCTP, data_engine_->last_channel_type());
3787
3788 webrtc::DataChannelInit config;
3789 config.id = 1;
3790 rtc::Buffer payload;
3791 webrtc::WriteDataChannelOpenMessage("a", config, &payload);
3792 cricket::ReceiveDataParams params;
3793 params.ssrc = config.id;
3794 params.type = cricket::DMT_CONTROL;
3795
3796 cricket::DataChannel* data_channel = session_->data_channel();
3797 data_channel->SignalDataReceived(data_channel, params, payload);
3798
3799 EXPECT_EQ("a", last_data_channel_label_);
3800 EXPECT_EQ(config.id, last_data_channel_config_.id);
3801 EXPECT_FALSE(last_data_channel_config_.negotiated);
3802 EXPECT_EQ(webrtc::InternalDataChannelInit::kAcker,
3803 last_data_channel_config_.open_handshake_role);
3804 }
3805
3806 TEST_P(WebRtcSessionTest, TestUsesProvidedCertificate) {
3807 rtc::scoped_refptr<rtc::RTCCertificate> certificate = 3659 rtc::scoped_refptr<rtc::RTCCertificate> certificate =
3808 FakeDtlsIdentityStore::GenerateCertificate(); 3660 FakeDtlsIdentityStore::GenerateCertificate();
3809 3661
3810 PeerConnectionInterface::RTCConfiguration configuration; 3662 PeerConnectionInterface::RTCConfiguration configuration;
3811 configuration.certificates.push_back(certificate); 3663 configuration.certificates.push_back(certificate);
3812 Init(nullptr, configuration); 3664 Init(nullptr, configuration);
3813 EXPECT_TRUE_WAIT(!session_->waiting_for_certificate_for_testing(), 1000); 3665 EXPECT_TRUE_WAIT(!session_->waiting_for_certificate_for_testing(), 1000);
3814 3666
3815 EXPECT_EQ(session_->certificate_for_testing(), certificate); 3667 EXPECT_EQ(session_->certificate_for_testing(), certificate);
3816 } 3668 }
3817 3669
3818 // Verifies that CreateOffer succeeds when CreateOffer is called before async 3670 // Verifies that CreateOffer succeeds when CreateOffer is called before async
3819 // identity generation is finished (even if a certificate is provided this is 3671 // identity generation is finished (even if a certificate is provided this is
3820 // an async op). 3672 // an async op).
3821 TEST_P(WebRtcSessionTest, TestCreateOfferBeforeIdentityRequestReturnSuccess) { 3673 TEST_P(WebRtcSessionTest, TestCreateOfferBeforeIdentityRequestReturnSuccess) {
3822 MAYBE_SKIP_TEST(rtc::SSLStreamAdapter::HaveDtlsSrtp); 3674 MAYBE_SKIP_TEST(rtc::SSLStreamAdapter::HaveDtlsSrtp);
3823 InitWithDtls(GetParam()); 3675 InitWithDtls(GetParam());
3824 3676
3825 EXPECT_TRUE(session_->waiting_for_certificate_for_testing()); 3677 EXPECT_TRUE(session_->waiting_for_certificate_for_testing());
3826 SendAudioVideoStream1(); 3678 mediastream_signaling_.SendAudioVideoStream1();
3827 rtc::scoped_ptr<SessionDescriptionInterface> offer(CreateOffer()); 3679 rtc::scoped_ptr<SessionDescriptionInterface> offer(CreateOffer());
3828 3680
3829 EXPECT_TRUE(offer != NULL); 3681 EXPECT_TRUE(offer != NULL);
3830 VerifyNoCryptoParams(offer->description(), true); 3682 VerifyNoCryptoParams(offer->description(), true);
3831 VerifyFingerprintStatus(offer->description(), true); 3683 VerifyFingerprintStatus(offer->description(), true);
3832 } 3684 }
3833 3685
3834 // Verifies that CreateAnswer succeeds when CreateOffer is called before async 3686 // Verifies that CreateAnswer succeeds when CreateOffer is called before async
3835 // identity generation is finished (even if a certificate is provided this is 3687 // identity generation is finished (even if a certificate is provided this is
3836 // an async op). 3688 // an async op).
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
3933 SetRemoteDescriptionOfferExpectError(kSdpWithoutSdesCrypto, 3785 SetRemoteDescriptionOfferExpectError(kSdpWithoutSdesCrypto,
3934 offer); 3786 offer);
3935 } 3787 }
3936 3788
3937 // This test verifies DSCP is properly applied on the media channels. 3789 // This test verifies DSCP is properly applied on the media channels.
3938 TEST_F(WebRtcSessionTest, TestDscpConstraint) { 3790 TEST_F(WebRtcSessionTest, TestDscpConstraint) {
3939 constraints_.reset(new FakeConstraints()); 3791 constraints_.reset(new FakeConstraints());
3940 constraints_->AddOptional( 3792 constraints_->AddOptional(
3941 webrtc::MediaConstraintsInterface::kEnableDscp, true); 3793 webrtc::MediaConstraintsInterface::kEnableDscp, true);
3942 Init(); 3794 Init();
3943 SendAudioVideoStream1(); 3795 mediastream_signaling_.SendAudioVideoStream1();
3944 SessionDescriptionInterface* offer = CreateOffer(); 3796 SessionDescriptionInterface* offer = CreateOffer();
3945 3797
3946 SetLocalDescriptionWithoutError(offer); 3798 SetLocalDescriptionWithoutError(offer);
3947 3799
3948 video_channel_ = media_engine_->GetVideoChannel(0); 3800 video_channel_ = media_engine_->GetVideoChannel(0);
3949 voice_channel_ = media_engine_->GetVoiceChannel(0); 3801 voice_channel_ = media_engine_->GetVoiceChannel(0);
3950 3802
3951 ASSERT_TRUE(video_channel_ != NULL); 3803 ASSERT_TRUE(video_channel_ != NULL);
3952 ASSERT_TRUE(voice_channel_ != NULL); 3804 ASSERT_TRUE(voice_channel_ != NULL);
3953 const cricket::AudioOptions& audio_options = voice_channel_->options(); 3805 const cricket::AudioOptions& audio_options = voice_channel_->options();
3954 const cricket::VideoOptions& video_options = video_channel_->options(); 3806 const cricket::VideoOptions& video_options = video_channel_->options();
3955 EXPECT_TRUE(audio_options.dscp.IsSet()); 3807 EXPECT_TRUE(audio_options.dscp.IsSet());
3956 EXPECT_TRUE(audio_options.dscp.GetWithDefaultIfUnset(false)); 3808 EXPECT_TRUE(audio_options.dscp.GetWithDefaultIfUnset(false));
3957 EXPECT_TRUE(video_options.dscp.IsSet()); 3809 EXPECT_TRUE(video_options.dscp.IsSet());
3958 EXPECT_TRUE(video_options.dscp.GetWithDefaultIfUnset(false)); 3810 EXPECT_TRUE(video_options.dscp.GetWithDefaultIfUnset(false));
3959 } 3811 }
3960 3812
3961 TEST_F(WebRtcSessionTest, TestSuspendBelowMinBitrateConstraint) { 3813 TEST_F(WebRtcSessionTest, TestSuspendBelowMinBitrateConstraint) {
3962 constraints_.reset(new FakeConstraints()); 3814 constraints_.reset(new FakeConstraints());
3963 constraints_->AddOptional( 3815 constraints_->AddOptional(
3964 webrtc::MediaConstraintsInterface::kEnableVideoSuspendBelowMinBitrate, 3816 webrtc::MediaConstraintsInterface::kEnableVideoSuspendBelowMinBitrate,
3965 true); 3817 true);
3966 Init(); 3818 Init();
3967 SendAudioVideoStream1(); 3819 mediastream_signaling_.SendAudioVideoStream1();
3968 SessionDescriptionInterface* offer = CreateOffer(); 3820 SessionDescriptionInterface* offer = CreateOffer();
3969 3821
3970 SetLocalDescriptionWithoutError(offer); 3822 SetLocalDescriptionWithoutError(offer);
3971 3823
3972 video_channel_ = media_engine_->GetVideoChannel(0); 3824 video_channel_ = media_engine_->GetVideoChannel(0);
3973 3825
3974 ASSERT_TRUE(video_channel_ != NULL); 3826 ASSERT_TRUE(video_channel_ != NULL);
3975 const cricket::VideoOptions& video_options = video_channel_->options(); 3827 const cricket::VideoOptions& video_options = video_channel_->options();
3976 EXPECT_TRUE( 3828 EXPECT_TRUE(
3977 video_options.suspend_below_min_bitrate.GetWithDefaultIfUnset(false)); 3829 video_options.suspend_below_min_bitrate.GetWithDefaultIfUnset(false));
3978 } 3830 }
3979 3831
3980 TEST_F(WebRtcSessionTest, TestNumUnsignalledRecvStreamsConstraint) { 3832 TEST_F(WebRtcSessionTest, TestNumUnsignalledRecvStreamsConstraint) {
3981 // Number of unsignalled receiving streams should be between 0 and 3833 // Number of unsignalled receiving streams should be between 0 and
3982 // kMaxUnsignalledRecvStreams. 3834 // kMaxUnsignalledRecvStreams.
3983 SetAndVerifyNumUnsignalledRecvStreams(10, 10); 3835 SetAndVerifyNumUnsignalledRecvStreams(10, 10);
3984 SetAndVerifyNumUnsignalledRecvStreams(kMaxUnsignalledRecvStreams + 1, 3836 SetAndVerifyNumUnsignalledRecvStreams(kMaxUnsignalledRecvStreams + 1,
3985 kMaxUnsignalledRecvStreams); 3837 kMaxUnsignalledRecvStreams);
3986 SetAndVerifyNumUnsignalledRecvStreams(-1, 0); 3838 SetAndVerifyNumUnsignalledRecvStreams(-1, 0);
3987 } 3839 }
3988 3840
3989 TEST_F(WebRtcSessionTest, TestCombinedAudioVideoBweConstraint) { 3841 TEST_F(WebRtcSessionTest, TestCombinedAudioVideoBweConstraint) {
3990 constraints_.reset(new FakeConstraints()); 3842 constraints_.reset(new FakeConstraints());
3991 constraints_->AddOptional( 3843 constraints_->AddOptional(
3992 webrtc::MediaConstraintsInterface::kCombinedAudioVideoBwe, 3844 webrtc::MediaConstraintsInterface::kCombinedAudioVideoBwe,
3993 true); 3845 true);
3994 Init(); 3846 Init();
3995 SendAudioVideoStream1(); 3847 mediastream_signaling_.SendAudioVideoStream1();
3996 SessionDescriptionInterface* offer = CreateOffer(); 3848 SessionDescriptionInterface* offer = CreateOffer();
3997 3849
3998 SetLocalDescriptionWithoutError(offer); 3850 SetLocalDescriptionWithoutError(offer);
3999 3851
4000 voice_channel_ = media_engine_->GetVoiceChannel(0); 3852 voice_channel_ = media_engine_->GetVoiceChannel(0);
4001 3853
4002 ASSERT_TRUE(voice_channel_ != NULL); 3854 ASSERT_TRUE(voice_channel_ != NULL);
4003 const cricket::AudioOptions& audio_options = voice_channel_->options(); 3855 const cricket::AudioOptions& audio_options = voice_channel_->options();
4004 EXPECT_TRUE( 3856 EXPECT_TRUE(
4005 audio_options.combined_audio_video_bwe.GetWithDefaultIfUnset(false)); 3857 audio_options.combined_audio_video_bwe.GetWithDefaultIfUnset(false));
4006 } 3858 }
4007 3859
4008 // Tests that we can renegotiate new media content with ICE candidates in the 3860 // Tests that we can renegotiate new media content with ICE candidates in the
4009 // new remote SDP. 3861 // new remote SDP.
4010 TEST_P(WebRtcSessionTest, TestRenegotiateNewMediaWithCandidatesInSdp) { 3862 TEST_P(WebRtcSessionTest, TestRenegotiateNewMediaWithCandidatesInSdp) {
4011 MAYBE_SKIP_TEST(rtc::SSLStreamAdapter::HaveDtlsSrtp); 3863 MAYBE_SKIP_TEST(rtc::SSLStreamAdapter::HaveDtlsSrtp);
4012 InitWithDtls(GetParam()); 3864 InitWithDtls(GetParam());
4013 SetFactoryDtlsSrtp(); 3865 SetFactoryDtlsSrtp();
4014 3866
4015 SendAudioOnlyStream2(); 3867 mediastream_signaling_.UseOptionsAudioOnly();
4016 SessionDescriptionInterface* offer = CreateOffer(); 3868 SessionDescriptionInterface* offer = CreateOffer();
4017 SetLocalDescriptionWithoutError(offer); 3869 SetLocalDescriptionWithoutError(offer);
4018 3870
4019 SessionDescriptionInterface* answer = CreateRemoteAnswer(offer); 3871 SessionDescriptionInterface* answer = CreateRemoteAnswer(offer);
4020 SetRemoteDescriptionWithoutError(answer); 3872 SetRemoteDescriptionWithoutError(answer);
4021 3873
4022 cricket::MediaSessionOptions options; 3874 cricket::MediaSessionOptions options;
4023 options.recv_video = true; 3875 options.recv_video = true;
4024 offer = CreateRemoteOffer(options, cricket::SEC_DISABLED); 3876 offer = CreateRemoteOffer(options, cricket::SEC_DISABLED);
4025 3877
4026 cricket::Candidate candidate1; 3878 cricket::Candidate candidate1;
4027 candidate1.set_address(rtc::SocketAddress("1.1.1.1", 5000)); 3879 candidate1.set_address(rtc::SocketAddress("1.1.1.1", 5000));
4028 candidate1.set_component(1); 3880 candidate1.set_component(1);
4029 JsepIceCandidate ice_candidate(kMediaContentName1, kMediaContentIndex1, 3881 JsepIceCandidate ice_candidate(kMediaContentName1, kMediaContentIndex1,
4030 candidate1); 3882 candidate1);
4031 EXPECT_TRUE(offer->AddCandidate(&ice_candidate)); 3883 EXPECT_TRUE(offer->AddCandidate(&ice_candidate));
4032 SetRemoteDescriptionWithoutError(offer); 3884 SetRemoteDescriptionWithoutError(offer);
4033 3885
4034 answer = CreateAnswer(NULL); 3886 answer = CreateAnswer(NULL);
4035 SetLocalDescriptionWithoutError(answer); 3887 SetLocalDescriptionWithoutError(answer);
4036 } 3888 }
4037 3889
4038 // Tests that we can renegotiate new media content with ICE candidates separated 3890 // Tests that we can renegotiate new media content with ICE candidates separated
4039 // from the remote SDP. 3891 // from the remote SDP.
4040 TEST_P(WebRtcSessionTest, TestRenegotiateNewMediaWithCandidatesSeparated) { 3892 TEST_P(WebRtcSessionTest, TestRenegotiateNewMediaWithCandidatesSeparated) {
4041 MAYBE_SKIP_TEST(rtc::SSLStreamAdapter::HaveDtlsSrtp); 3893 MAYBE_SKIP_TEST(rtc::SSLStreamAdapter::HaveDtlsSrtp);
4042 InitWithDtls(GetParam()); 3894 InitWithDtls(GetParam());
4043 SetFactoryDtlsSrtp(); 3895 SetFactoryDtlsSrtp();
4044 3896
4045 SendAudioOnlyStream2(); 3897 mediastream_signaling_.UseOptionsAudioOnly();
4046 SessionDescriptionInterface* offer = CreateOffer(); 3898 SessionDescriptionInterface* offer = CreateOffer();
4047 SetLocalDescriptionWithoutError(offer); 3899 SetLocalDescriptionWithoutError(offer);
4048 3900
4049 SessionDescriptionInterface* answer = CreateRemoteAnswer(offer); 3901 SessionDescriptionInterface* answer = CreateRemoteAnswer(offer);
4050 SetRemoteDescriptionWithoutError(answer); 3902 SetRemoteDescriptionWithoutError(answer);
4051 3903
4052 cricket::MediaSessionOptions options; 3904 cricket::MediaSessionOptions options;
4053 options.recv_video = true; 3905 options.recv_video = true;
4054 offer = CreateRemoteOffer(options, cricket::SEC_DISABLED); 3906 offer = CreateRemoteOffer(options, cricket::SEC_DISABLED);
4055 SetRemoteDescriptionWithoutError(offer); 3907 SetRemoteDescriptionWithoutError(offer);
4056 3908
4057 cricket::Candidate candidate1; 3909 cricket::Candidate candidate1;
4058 candidate1.set_address(rtc::SocketAddress("1.1.1.1", 5000)); 3910 candidate1.set_address(rtc::SocketAddress("1.1.1.1", 5000));
4059 candidate1.set_component(1); 3911 candidate1.set_component(1);
4060 JsepIceCandidate ice_candidate(kMediaContentName1, kMediaContentIndex1, 3912 JsepIceCandidate ice_candidate(kMediaContentName1, kMediaContentIndex1,
4061 candidate1); 3913 candidate1);
4062 EXPECT_TRUE(session_->ProcessIceMessage(&ice_candidate)); 3914 EXPECT_TRUE(session_->ProcessIceMessage(&ice_candidate));
4063 3915
4064 answer = CreateAnswer(NULL); 3916 answer = CreateAnswer(NULL);
4065 SetLocalDescriptionWithoutError(answer); 3917 SetLocalDescriptionWithoutError(answer);
4066 } 3918 }
4067 // Tests that RTX codec is removed from the answer when it isn't supported 3919 // Tests that RTX codec is removed from the answer when it isn't supported
4068 // by local side. 3920 // by local side.
4069 TEST_F(WebRtcSessionTest, TestRtxRemovedByCreateAnswer) { 3921 TEST_F(WebRtcSessionTest, TestRtxRemovedByCreateAnswer) {
4070 Init(); 3922 Init();
4071 SendAudioVideoStream1(); 3923 mediastream_signaling_.SendAudioVideoStream1();
4072 std::string offer_sdp(kSdpWithRtx); 3924 std::string offer_sdp(kSdpWithRtx);
4073 3925
4074 SessionDescriptionInterface* offer = 3926 SessionDescriptionInterface* offer =
4075 CreateSessionDescription(JsepSessionDescription::kOffer, offer_sdp, NULL); 3927 CreateSessionDescription(JsepSessionDescription::kOffer, offer_sdp, NULL);
4076 EXPECT_TRUE(offer->ToString(&offer_sdp)); 3928 EXPECT_TRUE(offer->ToString(&offer_sdp));
4077 3929
4078 // Offer SDP contains the RTX codec. 3930 // Offer SDP contains the RTX codec.
4079 EXPECT_TRUE(offer_sdp.find("rtx") != std::string::npos); 3931 EXPECT_TRUE(offer_sdp.find("rtx") != std::string::npos);
4080 SetRemoteDescriptionWithoutError(offer); 3932 SetRemoteDescriptionWithoutError(offer);
4081 3933
4082 SessionDescriptionInterface* answer = CreateAnswer(NULL); 3934 SessionDescriptionInterface* answer = CreateAnswer(NULL);
4083 std::string answer_sdp; 3935 std::string answer_sdp;
4084 answer->ToString(&answer_sdp); 3936 answer->ToString(&answer_sdp);
4085 // Answer SDP removes the unsupported RTX codec. 3937 // Answer SDP removes the unsupported RTX codec.
4086 EXPECT_TRUE(answer_sdp.find("rtx") == std::string::npos); 3938 EXPECT_TRUE(answer_sdp.find("rtx") == std::string::npos);
4087 SetLocalDescriptionWithoutError(answer); 3939 SetLocalDescriptionWithoutError(answer);
4088 } 3940 }
4089 3941
4090 // This verifies that the voice channel after bundle has both options from video 3942 // This verifies that the voice channel after bundle has both options from video
4091 // and voice channels. 3943 // and voice channels.
4092 TEST_F(WebRtcSessionTest, TestSetSocketOptionBeforeBundle) { 3944 TEST_F(WebRtcSessionTest, TestSetSocketOptionBeforeBundle) {
4093 InitWithBundlePolicy(PeerConnectionInterface::kBundlePolicyBalanced); 3945 InitWithBundlePolicy(PeerConnectionInterface::kBundlePolicyBalanced);
4094 SendAudioVideoStream1(); 3946 mediastream_signaling_.SendAudioVideoStream1();
4095 3947
4096 PeerConnectionInterface::RTCOfferAnswerOptions options; 3948 PeerConnectionInterface::RTCOfferAnswerOptions options;
4097 options.use_rtp_mux = true; 3949 options.use_rtp_mux = true;
4098 3950
4099 SessionDescriptionInterface* offer = CreateOffer(options); 3951 SessionDescriptionInterface* offer = CreateOffer(options);
4100 SetLocalDescriptionWithoutError(offer); 3952 SetLocalDescriptionWithoutError(offer);
4101 3953
4102 session_->video_channel()->SetOption(cricket::BaseChannel::ST_RTP, 3954 session_->video_channel()->SetOption(cricket::BaseChannel::ST_RTP,
4103 rtc::Socket::Option::OPT_SNDBUF, 4000); 3955 rtc::Socket::Option::OPT_SNDBUF, 4000);
4104 3956
4105 session_->voice_channel()->SetOption(cricket::BaseChannel::ST_RTP, 3957 session_->voice_channel()->SetOption(cricket::BaseChannel::ST_RTP,
4106 rtc::Socket::Option::OPT_RCVBUF, 8000); 3958 rtc::Socket::Option::OPT_RCVBUF, 8000);
4107 3959
4108 int option_val; 3960 int option_val;
4109 EXPECT_TRUE(session_->video_rtp_transport_channel()->GetOption( 3961 EXPECT_TRUE(session_->video_rtp_transport_channel()->GetOption(
4110 rtc::Socket::Option::OPT_SNDBUF, &option_val)); 3962 rtc::Socket::Option::OPT_SNDBUF, &option_val));
4111 EXPECT_EQ(4000, option_val); 3963 EXPECT_EQ(4000, option_val);
4112 EXPECT_FALSE(session_->voice_rtp_transport_channel()->GetOption( 3964 EXPECT_FALSE(session_->voice_rtp_transport_channel()->GetOption(
4113 rtc::Socket::Option::OPT_SNDBUF, &option_val)); 3965 rtc::Socket::Option::OPT_SNDBUF, &option_val));
4114 3966
4115 EXPECT_TRUE(session_->voice_rtp_transport_channel()->GetOption( 3967 EXPECT_TRUE(session_->voice_rtp_transport_channel()->GetOption(
4116 rtc::Socket::Option::OPT_RCVBUF, &option_val)); 3968 rtc::Socket::Option::OPT_RCVBUF, &option_val));
4117 EXPECT_EQ(8000, option_val); 3969 EXPECT_EQ(8000, option_val);
4118 EXPECT_FALSE(session_->video_rtp_transport_channel()->GetOption( 3970 EXPECT_FALSE(session_->video_rtp_transport_channel()->GetOption(
4119 rtc::Socket::Option::OPT_RCVBUF, &option_val)); 3971 rtc::Socket::Option::OPT_RCVBUF, &option_val));
4120 3972
4121 EXPECT_NE(session_->voice_rtp_transport_channel(), 3973 EXPECT_NE(session_->voice_rtp_transport_channel(),
4122 session_->video_rtp_transport_channel()); 3974 session_->video_rtp_transport_channel());
4123 3975
4124 SendAudioVideoStream2(); 3976 mediastream_signaling_.SendAudioVideoStream2();
4125 SessionDescriptionInterface* answer = 3977 SessionDescriptionInterface* answer =
4126 CreateRemoteAnswer(session_->local_description()); 3978 CreateRemoteAnswer(session_->local_description());
4127 SetRemoteDescriptionWithoutError(answer); 3979 SetRemoteDescriptionWithoutError(answer);
4128 3980
4129 EXPECT_TRUE(session_->voice_rtp_transport_channel()->GetOption( 3981 EXPECT_TRUE(session_->voice_rtp_transport_channel()->GetOption(
4130 rtc::Socket::Option::OPT_SNDBUF, &option_val)); 3982 rtc::Socket::Option::OPT_SNDBUF, &option_val));
4131 EXPECT_EQ(4000, option_val); 3983 EXPECT_EQ(4000, option_val);
4132 3984
4133 EXPECT_TRUE(session_->voice_rtp_transport_channel()->GetOption( 3985 EXPECT_TRUE(session_->voice_rtp_transport_channel()->GetOption(
4134 rtc::Socket::Option::OPT_RCVBUF, &option_val)); 3986 rtc::Socket::Option::OPT_RCVBUF, &option_val));
4135 EXPECT_EQ(8000, option_val); 3987 EXPECT_EQ(8000, option_val);
4136 } 3988 }
4137 3989
4138 // Test creating a session, request multiple offers, destroy the session 3990 // Test creating a session, request multiple offers, destroy the session
4139 // and make sure we got success/failure callbacks for all of the requests. 3991 // and make sure we got success/failure callbacks for all of the requests.
4140 // Background: crbug.com/507307 3992 // Background: crbug.com/507307
4141 TEST_F(WebRtcSessionTest, CreateOffersAndShutdown) { 3993 TEST_F(WebRtcSessionTest, CreateOffersAndShutdown) {
4142 Init(); 3994 Init();
4143 3995
4144 rtc::scoped_refptr<WebRtcSessionCreateSDPObserverForTest> observers[100]; 3996 rtc::scoped_refptr<WebRtcSessionCreateSDPObserverForTest> observers[100];
4145 PeerConnectionInterface::RTCOfferAnswerOptions options; 3997 PeerConnectionInterface::RTCOfferAnswerOptions options;
4146 options.offer_to_receive_audio = 3998 options.offer_to_receive_audio =
4147 RTCOfferAnswerOptions::kOfferToReceiveMediaTrue; 3999 RTCOfferAnswerOptions::kOfferToReceiveMediaTrue;
4148 cricket::MediaSessionOptions session_options;
4149 session_options.recv_audio = true;
4150 4000
4151 for (auto& o : observers) { 4001 for (auto& o : observers) {
4152 o = new WebRtcSessionCreateSDPObserverForTest(); 4002 o = new WebRtcSessionCreateSDPObserverForTest();
4153 session_->CreateOffer(o, options, session_options); 4003 session_->CreateOffer(o, options);
4154 } 4004 }
4155 4005
4156 session_.reset(); 4006 session_.reset();
4157 4007
4158 for (auto& o : observers) { 4008 for (auto& o : observers) {
4159 // We expect to have received a notification now even if the session was 4009 // We expect to have received a notification now even if the session was
4160 // terminated. The offer creation may or may not have succeeded, but we 4010 // terminated. The offer creation may or may not have succeeded, but we
4161 // must have received a notification which, so the only invalid state 4011 // must have received a notification which, so the only invalid state
4162 // is kInit. 4012 // is kInit.
4163 EXPECT_NE(WebRtcSessionCreateSDPObserverForTest::kInit, o->state()); 4013 EXPECT_NE(WebRtcSessionCreateSDPObserverForTest::kInit, o->state());
4164 } 4014 }
4165 } 4015 }
4166 4016
4167 // TODO(bemasc): Add a TestIceStatesBundle with BUNDLE enabled. That test 4017 // TODO(bemasc): Add a TestIceStatesBundle with BUNDLE enabled. That test
4168 // currently fails because upon disconnection and reconnection OnIceComplete is 4018 // currently fails because upon disconnection and reconnection OnIceComplete is
4169 // called more than once without returning to IceGatheringGathering. 4019 // called more than once without returning to IceGatheringGathering.
4170 4020
4171 INSTANTIATE_TEST_CASE_P(WebRtcSessionTests, 4021 INSTANTIATE_TEST_CASE_P(WebRtcSessionTests,
4172 WebRtcSessionTest, 4022 WebRtcSessionTest,
4173 testing::Values(ALREADY_GENERATED, 4023 testing::Values(ALREADY_GENERATED,
4174 DTLS_IDENTITY_STORE)); 4024 DTLS_IDENTITY_STORE));
OLDNEW
« no previous file with comments | « talk/app/webrtc/webrtcsession.cc ('k') | talk/app/webrtc/webrtcsessiondescriptionfactory.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698