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

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

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

Powered by Google App Engine
This is Rietveld 408576698