OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2012 The WebRTC project authors. All Rights Reserved. | 2 * Copyright 2012 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
11 #include <utility> | 11 #include <utility> |
12 #include <vector> | 12 #include <vector> |
13 | 13 |
14 #include "webrtc/api/audiotrack.h" | 14 #include "webrtc/api/audiotrack.h" |
15 #include "webrtc/api/fakemediacontroller.h" | 15 #include "webrtc/api/fakemediacontroller.h" |
16 #include "webrtc/api/fakemetricsobserver.h" | 16 #include "webrtc/api/fakemetricsobserver.h" |
17 #include "webrtc/api/jsepicecandidate.h" | 17 #include "webrtc/api/jsepicecandidate.h" |
18 #include "webrtc/api/jsepsessiondescription.h" | 18 #include "webrtc/api/jsepsessiondescription.h" |
19 #include "webrtc/api/peerconnection.h" | 19 #include "webrtc/api/peerconnection.h" |
20 #include "webrtc/api/sctputils.h" | 20 #include "webrtc/api/sctputils.h" |
21 #include "webrtc/api/streamcollection.h" | 21 #include "webrtc/api/streamcollection.h" |
22 #include "webrtc/api/streamcollection.h" | 22 #include "webrtc/api/streamcollection.h" |
23 #include "webrtc/api/test/fakeconstraints.h" | |
24 #include "webrtc/api/test/fakedtlsidentitystore.h" | 23 #include "webrtc/api/test/fakedtlsidentitystore.h" |
25 #include "webrtc/api/videotrack.h" | 24 #include "webrtc/api/videotrack.h" |
26 #include "webrtc/api/webrtcsession.h" | 25 #include "webrtc/api/webrtcsession.h" |
27 #include "webrtc/api/webrtcsessiondescriptionfactory.h" | 26 #include "webrtc/api/webrtcsessiondescriptionfactory.h" |
28 #include "webrtc/base/fakenetwork.h" | 27 #include "webrtc/base/fakenetwork.h" |
29 #include "webrtc/base/firewallsocketserver.h" | 28 #include "webrtc/base/firewallsocketserver.h" |
30 #include "webrtc/base/gunit.h" | 29 #include "webrtc/base/gunit.h" |
31 #include "webrtc/base/logging.h" | 30 #include "webrtc/base/logging.h" |
32 #include "webrtc/base/network.h" | 31 #include "webrtc/base/network.h" |
33 #include "webrtc/base/physicalsocketserver.h" | 32 #include "webrtc/base/physicalsocketserver.h" |
(...skipping 24 matching lines...) Loading... |
58 using cricket::FakeVoiceMediaChannel; | 57 using cricket::FakeVoiceMediaChannel; |
59 using cricket::TransportInfo; | 58 using cricket::TransportInfo; |
60 using rtc::SocketAddress; | 59 using rtc::SocketAddress; |
61 using rtc::scoped_ptr; | 60 using rtc::scoped_ptr; |
62 using rtc::Thread; | 61 using rtc::Thread; |
63 using webrtc::CreateSessionDescription; | 62 using webrtc::CreateSessionDescription; |
64 using webrtc::CreateSessionDescriptionObserver; | 63 using webrtc::CreateSessionDescriptionObserver; |
65 using webrtc::CreateSessionDescriptionRequest; | 64 using webrtc::CreateSessionDescriptionRequest; |
66 using webrtc::DataChannel; | 65 using webrtc::DataChannel; |
67 using webrtc::DtlsIdentityStoreInterface; | 66 using webrtc::DtlsIdentityStoreInterface; |
68 using webrtc::FakeConstraints; | |
69 using webrtc::FakeMetricsObserver; | 67 using webrtc::FakeMetricsObserver; |
70 using webrtc::IceCandidateCollection; | 68 using webrtc::IceCandidateCollection; |
71 using webrtc::InternalDataChannelInit; | 69 using webrtc::InternalDataChannelInit; |
72 using webrtc::JsepIceCandidate; | 70 using webrtc::JsepIceCandidate; |
73 using webrtc::JsepSessionDescription; | 71 using webrtc::JsepSessionDescription; |
74 using webrtc::PeerConnectionFactoryInterface; | 72 using webrtc::PeerConnectionFactoryInterface; |
75 using webrtc::PeerConnectionInterface; | 73 using webrtc::PeerConnectionInterface; |
76 using webrtc::SessionDescriptionInterface; | 74 using webrtc::SessionDescriptionInterface; |
77 using webrtc::SessionStats; | 75 using webrtc::SessionStats; |
78 using webrtc::StreamCollection; | 76 using webrtc::StreamCollection; |
(...skipping 283 matching lines...) Loading... |
362 void AddInterface(const SocketAddress& addr) { | 360 void AddInterface(const SocketAddress& addr) { |
363 network_manager_.AddInterface(addr); | 361 network_manager_.AddInterface(addr); |
364 } | 362 } |
365 | 363 |
366 // If |dtls_identity_store| != null or |rtc_configuration| contains | 364 // If |dtls_identity_store| != null or |rtc_configuration| contains |
367 // |certificates| then DTLS will be enabled unless explicitly disabled by | 365 // |certificates| then DTLS will be enabled unless explicitly disabled by |
368 // |rtc_configuration| options. When DTLS is enabled a certificate will be | 366 // |rtc_configuration| options. When DTLS is enabled a certificate will be |
369 // used if provided, otherwise one will be generated using the | 367 // used if provided, otherwise one will be generated using the |
370 // |dtls_identity_store|. | 368 // |dtls_identity_store|. |
371 void Init( | 369 void Init( |
372 rtc::scoped_ptr<webrtc::DtlsIdentityStoreInterface> dtls_identity_store, | 370 rtc::scoped_ptr<webrtc::DtlsIdentityStoreInterface> dtls_identity_store) { |
373 const PeerConnectionInterface::RTCConfiguration& rtc_configuration) { | |
374 ASSERT_TRUE(session_.get() == NULL); | 371 ASSERT_TRUE(session_.get() == NULL); |
375 session_.reset(new WebRtcSessionForTest( | 372 session_.reset(new WebRtcSessionForTest( |
376 media_controller_.get(), rtc::Thread::Current(), rtc::Thread::Current(), | 373 media_controller_.get(), rtc::Thread::Current(), rtc::Thread::Current(), |
377 allocator_.get(), &observer_)); | 374 allocator_.get(), &observer_)); |
378 session_->SignalDataChannelOpenMessage.connect( | 375 session_->SignalDataChannelOpenMessage.connect( |
379 this, &WebRtcSessionTest::OnDataChannelOpenMessage); | 376 this, &WebRtcSessionTest::OnDataChannelOpenMessage); |
380 session_->GetOnDestroyedSignal()->connect( | 377 session_->GetOnDestroyedSignal()->connect( |
381 this, &WebRtcSessionTest::OnSessionDestroyed); | 378 this, &WebRtcSessionTest::OnSessionDestroyed); |
382 | 379 |
383 EXPECT_EQ(PeerConnectionInterface::kIceConnectionNew, | 380 EXPECT_EQ(PeerConnectionInterface::kIceConnectionNew, |
384 observer_.ice_connection_state_); | 381 observer_.ice_connection_state_); |
385 EXPECT_EQ(PeerConnectionInterface::kIceGatheringNew, | 382 EXPECT_EQ(PeerConnectionInterface::kIceGatheringNew, |
386 observer_.ice_gathering_state_); | 383 observer_.ice_gathering_state_); |
387 | 384 |
388 EXPECT_TRUE(session_->Initialize(options_, constraints_.get(), | 385 EXPECT_TRUE(session_->Initialize(options_, std::move(dtls_identity_store), |
389 std::move(dtls_identity_store), | 386 configuration_)); |
390 rtc_configuration)); | |
391 session_->set_metrics_observer(metrics_observer_); | 387 session_->set_metrics_observer(metrics_observer_); |
392 } | 388 } |
393 | 389 |
394 void OnDataChannelOpenMessage(const std::string& label, | 390 void OnDataChannelOpenMessage(const std::string& label, |
395 const InternalDataChannelInit& config) { | 391 const InternalDataChannelInit& config) { |
396 last_data_channel_label_ = label; | 392 last_data_channel_label_ = label; |
397 last_data_channel_config_ = config; | 393 last_data_channel_config_ = config; |
398 } | 394 } |
399 | 395 |
400 void OnSessionDestroyed() { session_destroyed_ = true; } | 396 void OnSessionDestroyed() { session_destroyed_ = true; } |
401 | 397 |
402 void Init() { | 398 void Init() { Init(nullptr); } |
403 PeerConnectionInterface::RTCConfiguration configuration; | |
404 Init(nullptr, configuration); | |
405 } | |
406 | 399 |
407 void InitWithIceTransport( | 400 void InitWithIceTransport( |
408 PeerConnectionInterface::IceTransportsType ice_transport_type) { | 401 PeerConnectionInterface::IceTransportsType ice_transport_type) { |
409 PeerConnectionInterface::RTCConfiguration configuration; | 402 configuration_.type = ice_transport_type; |
410 configuration.type = ice_transport_type; | 403 Init(); |
411 Init(nullptr, configuration); | |
412 } | 404 } |
413 | 405 |
414 void InitWithBundlePolicy( | 406 void InitWithBundlePolicy( |
415 PeerConnectionInterface::BundlePolicy bundle_policy) { | 407 PeerConnectionInterface::BundlePolicy bundle_policy) { |
416 PeerConnectionInterface::RTCConfiguration configuration; | 408 configuration_.bundle_policy = bundle_policy; |
417 configuration.bundle_policy = bundle_policy; | 409 Init(); |
418 Init(nullptr, configuration); | |
419 } | 410 } |
420 | 411 |
421 void InitWithRtcpMuxPolicy( | 412 void InitWithRtcpMuxPolicy( |
422 PeerConnectionInterface::RtcpMuxPolicy rtcp_mux_policy) { | 413 PeerConnectionInterface::RtcpMuxPolicy rtcp_mux_policy) { |
423 PeerConnectionInterface::RTCConfiguration configuration; | 414 PeerConnectionInterface::RTCConfiguration configuration; |
424 configuration.rtcp_mux_policy = rtcp_mux_policy; | 415 configuration_.rtcp_mux_policy = rtcp_mux_policy; |
425 Init(nullptr, configuration); | 416 Init(); |
426 } | 417 } |
427 | 418 |
428 // Successfully init with DTLS; with a certificate generated and supplied or | 419 // Successfully init with DTLS; with a certificate generated and supplied or |
429 // with a store that generates it for us. | 420 // with a store that generates it for us. |
430 void InitWithDtls(RTCCertificateGenerationMethod cert_gen_method) { | 421 void InitWithDtls(RTCCertificateGenerationMethod cert_gen_method) { |
431 rtc::scoped_ptr<FakeDtlsIdentityStore> dtls_identity_store; | 422 rtc::scoped_ptr<FakeDtlsIdentityStore> dtls_identity_store; |
432 PeerConnectionInterface::RTCConfiguration configuration; | |
433 if (cert_gen_method == ALREADY_GENERATED) { | 423 if (cert_gen_method == ALREADY_GENERATED) { |
434 configuration.certificates.push_back( | 424 configuration_.certificates.push_back( |
435 FakeDtlsIdentityStore::GenerateCertificate()); | 425 FakeDtlsIdentityStore::GenerateCertificate()); |
436 } else if (cert_gen_method == DTLS_IDENTITY_STORE) { | 426 } else if (cert_gen_method == DTLS_IDENTITY_STORE) { |
437 dtls_identity_store.reset(new FakeDtlsIdentityStore()); | 427 dtls_identity_store.reset(new FakeDtlsIdentityStore()); |
438 dtls_identity_store->set_should_fail(false); | 428 dtls_identity_store->set_should_fail(false); |
439 } else { | 429 } else { |
440 RTC_CHECK(false); | 430 RTC_CHECK(false); |
441 } | 431 } |
442 Init(std::move(dtls_identity_store), configuration); | 432 Init(std::move(dtls_identity_store)); |
443 } | 433 } |
444 | 434 |
445 // Init with DTLS with a store that will fail to generate a certificate. | 435 // Init with DTLS with a store that will fail to generate a certificate. |
446 void InitWithDtlsIdentityGenFail() { | 436 void InitWithDtlsIdentityGenFail() { |
447 rtc::scoped_ptr<FakeDtlsIdentityStore> dtls_identity_store( | 437 rtc::scoped_ptr<FakeDtlsIdentityStore> dtls_identity_store( |
448 new FakeDtlsIdentityStore()); | 438 new FakeDtlsIdentityStore()); |
449 dtls_identity_store->set_should_fail(true); | 439 dtls_identity_store->set_should_fail(true); |
450 PeerConnectionInterface::RTCConfiguration configuration; | 440 Init(std::move(dtls_identity_store)); |
451 Init(std::move(dtls_identity_store), configuration); | |
452 } | 441 } |
453 | 442 |
454 void InitWithDtmfCodec() { | 443 void InitWithDtmfCodec() { |
455 // Add kTelephoneEventCodec for dtmf test. | 444 // Add kTelephoneEventCodec for dtmf test. |
456 const cricket::AudioCodec kTelephoneEventCodec( | 445 const cricket::AudioCodec kTelephoneEventCodec( |
457 106, "telephone-event", 8000, 0, 1, 0); | 446 106, "telephone-event", 8000, 0, 1, 0); |
458 std::vector<cricket::AudioCodec> codecs; | 447 std::vector<cricket::AudioCodec> codecs; |
459 codecs.push_back(kTelephoneEventCodec); | 448 codecs.push_back(kTelephoneEventCodec); |
460 media_engine_->SetAudioCodecs(codecs); | 449 media_engine_->SetAudioCodecs(codecs); |
461 desc_factory_->set_audio_codecs(codecs); | 450 desc_factory_->set_audio_codecs(codecs); |
(...skipping 62 matching lines...) Loading... |
524 if (data_channel_ && session_->data_channel_type() == cricket::DCT_RTP) { | 513 if (data_channel_ && session_->data_channel_type() == cricket::DCT_RTP) { |
525 session_options->AddSendStream(cricket::MEDIA_TYPE_DATA, | 514 session_options->AddSendStream(cricket::MEDIA_TYPE_DATA, |
526 data_channel_->label(), | 515 data_channel_->label(), |
527 data_channel_->label()); | 516 data_channel_->label()); |
528 } | 517 } |
529 } | 518 } |
530 | 519 |
531 void GetOptionsForOffer( | 520 void GetOptionsForOffer( |
532 const PeerConnectionInterface::RTCOfferAnswerOptions& rtc_options, | 521 const PeerConnectionInterface::RTCOfferAnswerOptions& rtc_options, |
533 cricket::MediaSessionOptions* session_options) { | 522 cricket::MediaSessionOptions* session_options) { |
534 ASSERT_TRUE(ConvertRtcOptionsForOffer(rtc_options, session_options)); | 523 ASSERT_TRUE(ExtractMediaSessionOptions(rtc_options, session_options)); |
535 | 524 |
536 AddStreamsToOptions(session_options); | 525 AddStreamsToOptions(session_options); |
537 if (rtc_options.offer_to_receive_audio == | 526 if (rtc_options.offer_to_receive_audio == |
538 RTCOfferAnswerOptions::kUndefined) { | 527 RTCOfferAnswerOptions::kUndefined) { |
539 session_options->recv_audio = | 528 session_options->recv_audio = |
540 session_options->HasSendMediaStream(cricket::MEDIA_TYPE_AUDIO); | 529 session_options->HasSendMediaStream(cricket::MEDIA_TYPE_AUDIO); |
541 } | 530 } |
542 if (rtc_options.offer_to_receive_video == | 531 if (rtc_options.offer_to_receive_video == |
543 RTCOfferAnswerOptions::kUndefined) { | 532 RTCOfferAnswerOptions::kUndefined) { |
544 session_options->recv_video = | 533 session_options->recv_video = |
545 session_options->HasSendMediaStream(cricket::MEDIA_TYPE_VIDEO); | 534 session_options->HasSendMediaStream(cricket::MEDIA_TYPE_VIDEO); |
546 } | 535 } |
547 session_options->bundle_enabled = | 536 session_options->bundle_enabled = |
548 session_options->bundle_enabled && | 537 session_options->bundle_enabled && |
549 (session_options->has_audio() || session_options->has_video() || | 538 (session_options->has_audio() || session_options->has_video() || |
550 session_options->has_data()); | 539 session_options->has_data()); |
551 | 540 |
552 if (session_->data_channel_type() == cricket::DCT_SCTP && data_channel_) { | 541 if (session_->data_channel_type() == cricket::DCT_SCTP && data_channel_) { |
553 session_options->data_channel_type = cricket::DCT_SCTP; | 542 session_options->data_channel_type = cricket::DCT_SCTP; |
554 } | 543 } |
555 } | 544 } |
556 | 545 |
557 void GetOptionsForAnswer(const webrtc::MediaConstraintsInterface* constraints, | 546 void GetOptionsForAnswer(cricket::MediaSessionOptions* session_options) { |
558 cricket::MediaSessionOptions* session_options) { | 547 // ParseConstraintsForAnswer is used to set some defaults. |
559 session_options->recv_audio = false; | 548 ASSERT_TRUE(webrtc::ParseConstraintsForAnswer(nullptr, session_options)); |
560 session_options->recv_video = false; | |
561 ASSERT_TRUE(ParseConstraintsForAnswer(constraints, session_options)); | |
562 | 549 |
563 AddStreamsToOptions(session_options); | 550 AddStreamsToOptions(session_options); |
564 session_options->bundle_enabled = | 551 session_options->bundle_enabled = |
565 session_options->bundle_enabled && | 552 session_options->bundle_enabled && |
566 (session_options->has_audio() || session_options->has_video() || | 553 (session_options->has_audio() || session_options->has_video() || |
567 session_options->has_data()); | 554 session_options->has_data()); |
568 | 555 |
569 if (session_->data_channel_type() == cricket::DCT_SCTP) { | 556 if (session_->data_channel_type() == cricket::DCT_SCTP) { |
570 session_options->data_channel_type = cricket::DCT_SCTP; | 557 session_options->data_channel_type = cricket::DCT_SCTP; |
571 } | 558 } |
(...skipping 12 matching lines...) Loading... |
584 | 571 |
585 SessionDescriptionInterface* CreateOffer() { | 572 SessionDescriptionInterface* CreateOffer() { |
586 PeerConnectionInterface::RTCOfferAnswerOptions options; | 573 PeerConnectionInterface::RTCOfferAnswerOptions options; |
587 options.offer_to_receive_audio = | 574 options.offer_to_receive_audio = |
588 RTCOfferAnswerOptions::kOfferToReceiveMediaTrue; | 575 RTCOfferAnswerOptions::kOfferToReceiveMediaTrue; |
589 | 576 |
590 return CreateOffer(options); | 577 return CreateOffer(options); |
591 } | 578 } |
592 | 579 |
593 SessionDescriptionInterface* CreateOffer( | 580 SessionDescriptionInterface* CreateOffer( |
594 const PeerConnectionInterface::RTCOfferAnswerOptions& options) { | 581 const PeerConnectionInterface::RTCOfferAnswerOptions options) { |
595 rtc::scoped_refptr<WebRtcSessionCreateSDPObserverForTest> | 582 rtc::scoped_refptr<WebRtcSessionCreateSDPObserverForTest> |
596 observer = new WebRtcSessionCreateSDPObserverForTest(); | 583 observer = new WebRtcSessionCreateSDPObserverForTest(); |
597 cricket::MediaSessionOptions session_options; | 584 cricket::MediaSessionOptions session_options; |
598 GetOptionsForOffer(options, &session_options); | 585 GetOptionsForOffer(options, &session_options); |
599 session_->CreateOffer(observer, options, session_options); | 586 session_->CreateOffer(observer, options, session_options); |
600 EXPECT_TRUE_WAIT( | 587 EXPECT_TRUE_WAIT( |
601 observer->state() != WebRtcSessionCreateSDPObserverForTest::kInit, | 588 observer->state() != WebRtcSessionCreateSDPObserverForTest::kInit, |
602 2000); | 589 2000); |
603 return observer->ReleaseDescription(); | 590 return observer->ReleaseDescription(); |
604 } | 591 } |
605 | 592 |
606 SessionDescriptionInterface* CreateAnswer( | 593 SessionDescriptionInterface* CreateAnswer( |
607 const webrtc::MediaConstraintsInterface* constraints) { | 594 const cricket::MediaSessionOptions& options) { |
608 rtc::scoped_refptr<WebRtcSessionCreateSDPObserverForTest> observer | 595 rtc::scoped_refptr<WebRtcSessionCreateSDPObserverForTest> observer |
609 = new WebRtcSessionCreateSDPObserverForTest(); | 596 = new WebRtcSessionCreateSDPObserverForTest(); |
610 cricket::MediaSessionOptions session_options; | 597 cricket::MediaSessionOptions session_options = options; |
611 GetOptionsForAnswer(constraints, &session_options); | 598 GetOptionsForAnswer(&session_options); |
612 session_->CreateAnswer(observer, constraints, session_options); | 599 // Overwrite recv_audio and recv_video with passed-in values. |
| 600 session_options.recv_video = options.recv_video; |
| 601 session_options.recv_audio = options.recv_audio; |
| 602 session_->CreateAnswer(observer, session_options); |
613 EXPECT_TRUE_WAIT( | 603 EXPECT_TRUE_WAIT( |
614 observer->state() != WebRtcSessionCreateSDPObserverForTest::kInit, | 604 observer->state() != WebRtcSessionCreateSDPObserverForTest::kInit, |
615 2000); | 605 2000); |
616 return observer->ReleaseDescription(); | 606 return observer->ReleaseDescription(); |
617 } | 607 } |
618 | 608 |
| 609 SessionDescriptionInterface* CreateAnswer() { |
| 610 cricket::MediaSessionOptions options; |
| 611 options.recv_video = true; |
| 612 options.recv_audio = true; |
| 613 return CreateAnswer(options); |
| 614 } |
| 615 |
619 bool ChannelsExist() const { | 616 bool ChannelsExist() const { |
620 return (session_->voice_channel() != NULL && | 617 return (session_->voice_channel() != NULL && |
621 session_->video_channel() != NULL); | 618 session_->video_channel() != NULL); |
622 } | 619 } |
623 | 620 |
624 void VerifyCryptoParams(const cricket::SessionDescription* sdp) { | 621 void VerifyCryptoParams(const cricket::SessionDescription* sdp) { |
625 ASSERT_TRUE(session_.get() != NULL); | 622 ASSERT_TRUE(session_.get() != NULL); |
626 const cricket::ContentInfo* content = cricket::GetFirstAudioContent(sdp); | 623 const cricket::ContentInfo* content = cricket::GetFirstAudioContent(sdp); |
627 ASSERT_TRUE(content != NULL); | 624 ASSERT_TRUE(content != NULL); |
628 const cricket::AudioContentDescription* audio_content = | 625 const cricket::AudioContentDescription* audio_content = |
(...skipping 76 matching lines...) Loading... |
705 void VerifyAnswerFromNonCryptoOffer() { | 702 void VerifyAnswerFromNonCryptoOffer() { |
706 // Create an SDP without Crypto. | 703 // Create an SDP without Crypto. |
707 cricket::MediaSessionOptions options; | 704 cricket::MediaSessionOptions options; |
708 options.recv_video = true; | 705 options.recv_video = true; |
709 JsepSessionDescription* offer( | 706 JsepSessionDescription* offer( |
710 CreateRemoteOffer(options, cricket::SEC_DISABLED)); | 707 CreateRemoteOffer(options, cricket::SEC_DISABLED)); |
711 ASSERT_TRUE(offer != NULL); | 708 ASSERT_TRUE(offer != NULL); |
712 VerifyNoCryptoParams(offer->description(), false); | 709 VerifyNoCryptoParams(offer->description(), false); |
713 SetRemoteDescriptionOfferExpectError(kSdpWithoutSdesCrypto, | 710 SetRemoteDescriptionOfferExpectError(kSdpWithoutSdesCrypto, |
714 offer); | 711 offer); |
715 const webrtc::SessionDescriptionInterface* answer = CreateAnswer(NULL); | 712 const webrtc::SessionDescriptionInterface* answer = CreateAnswer(); |
716 // Answer should be NULL as no crypto params in offer. | 713 // Answer should be NULL as no crypto params in offer. |
717 ASSERT_TRUE(answer == NULL); | 714 ASSERT_TRUE(answer == NULL); |
718 } | 715 } |
719 | 716 |
720 void VerifyAnswerFromCryptoOffer() { | 717 void VerifyAnswerFromCryptoOffer() { |
721 cricket::MediaSessionOptions options; | 718 cricket::MediaSessionOptions options; |
722 options.recv_video = true; | 719 options.recv_video = true; |
723 options.bundle_enabled = true; | 720 options.bundle_enabled = true; |
724 scoped_ptr<JsepSessionDescription> offer( | 721 scoped_ptr<JsepSessionDescription> offer( |
725 CreateRemoteOffer(options, cricket::SEC_REQUIRED)); | 722 CreateRemoteOffer(options, cricket::SEC_REQUIRED)); |
726 ASSERT_TRUE(offer.get() != NULL); | 723 ASSERT_TRUE(offer.get() != NULL); |
727 VerifyCryptoParams(offer->description()); | 724 VerifyCryptoParams(offer->description()); |
728 SetRemoteDescriptionWithoutError(offer.release()); | 725 SetRemoteDescriptionWithoutError(offer.release()); |
729 scoped_ptr<SessionDescriptionInterface> answer(CreateAnswer(NULL)); | 726 scoped_ptr<SessionDescriptionInterface> answer(CreateAnswer()); |
730 ASSERT_TRUE(answer.get() != NULL); | 727 ASSERT_TRUE(answer.get() != NULL); |
731 VerifyCryptoParams(answer->description()); | 728 VerifyCryptoParams(answer->description()); |
732 } | 729 } |
733 | 730 |
734 bool IceUfragPwdEqual(const cricket::SessionDescription* desc1, | 731 bool IceUfragPwdEqual(const cricket::SessionDescription* desc1, |
735 const cricket::SessionDescription* desc2) { | 732 const cricket::SessionDescription* desc2) { |
736 if (desc1->contents().size() != desc2->contents().size()) { | 733 if (desc1->contents().size() != desc2->contents().size()) { |
737 return false; | 734 return false; |
738 } | 735 } |
739 | 736 |
(...skipping 91 matching lines...) Loading... |
831 transport_desc->ice_pwd = pwd; | 828 transport_desc->ice_pwd = pwd; |
832 } | 829 } |
833 | 830 |
834 // Creates a remote offer and and applies it as a remote description, | 831 // Creates a remote offer and and applies it as a remote description, |
835 // creates a local answer and applies is as a local description. | 832 // creates a local answer and applies is as a local description. |
836 // Call SendAudioVideoStreamX() before this function | 833 // Call SendAudioVideoStreamX() before this function |
837 // to decide which local and remote streams to create. | 834 // to decide which local and remote streams to create. |
838 void CreateAndSetRemoteOfferAndLocalAnswer() { | 835 void CreateAndSetRemoteOfferAndLocalAnswer() { |
839 SessionDescriptionInterface* offer = CreateRemoteOffer(); | 836 SessionDescriptionInterface* offer = CreateRemoteOffer(); |
840 SetRemoteDescriptionWithoutError(offer); | 837 SetRemoteDescriptionWithoutError(offer); |
841 SessionDescriptionInterface* answer = CreateAnswer(NULL); | 838 SessionDescriptionInterface* answer = CreateAnswer(); |
842 SetLocalDescriptionWithoutError(answer); | 839 SetLocalDescriptionWithoutError(answer); |
843 } | 840 } |
844 void SetLocalDescriptionWithoutError(SessionDescriptionInterface* desc) { | 841 void SetLocalDescriptionWithoutError(SessionDescriptionInterface* desc) { |
845 EXPECT_TRUE(session_->SetLocalDescription(desc, NULL)); | 842 EXPECT_TRUE(session_->SetLocalDescription(desc, NULL)); |
846 session_->MaybeStartGathering(); | 843 session_->MaybeStartGathering(); |
847 } | 844 } |
848 void SetLocalDescriptionExpectState(SessionDescriptionInterface* desc, | 845 void SetLocalDescriptionExpectState(SessionDescriptionInterface* desc, |
849 WebRtcSession::State expected_state) { | 846 WebRtcSession::State expected_state) { |
850 SetLocalDescriptionWithoutError(desc); | 847 SetLocalDescriptionWithoutError(desc); |
851 EXPECT_EQ(expected_state, session_->state()); | 848 EXPECT_EQ(expected_state, session_->state()); |
(...skipping 154 matching lines...) Loading... |
1006 offer_basis->type()); | 1003 offer_basis->type()); |
1007 delete offer_basis; | 1004 delete offer_basis; |
1008 offer->Initialize(offer_str, NULL); | 1005 offer->Initialize(offer_str, NULL); |
1009 return offer; | 1006 return offer; |
1010 } | 1007 } |
1011 | 1008 |
1012 // Create a remote offer. Call SendAudioVideoStreamX() | 1009 // Create a remote offer. Call SendAudioVideoStreamX() |
1013 // before this function to decide which streams to create. | 1010 // before this function to decide which streams to create. |
1014 JsepSessionDescription* CreateRemoteOffer() { | 1011 JsepSessionDescription* CreateRemoteOffer() { |
1015 cricket::MediaSessionOptions options; | 1012 cricket::MediaSessionOptions options; |
1016 GetOptionsForAnswer(NULL, &options); | 1013 GetOptionsForAnswer(&options); |
1017 return CreateRemoteOffer(options, session_->remote_description()); | 1014 return CreateRemoteOffer(options, session_->remote_description()); |
1018 } | 1015 } |
1019 | 1016 |
1020 JsepSessionDescription* CreateRemoteAnswer( | 1017 JsepSessionDescription* CreateRemoteAnswer( |
1021 const SessionDescriptionInterface* offer, | 1018 const SessionDescriptionInterface* offer, |
1022 cricket::MediaSessionOptions options, | 1019 cricket::MediaSessionOptions options, |
1023 cricket::SecurePolicy policy) { | 1020 cricket::SecurePolicy policy) { |
1024 desc_factory_->set_secure(policy); | 1021 desc_factory_->set_secure(policy); |
1025 const std::string session_id = | 1022 const std::string session_id = |
1026 rtc::ToString(rtc::CreateRandomId64()); | 1023 rtc::ToString(rtc::CreateRandomId64()); |
(...skipping 13 matching lines...) Loading... |
1040 cricket::MediaSessionOptions options) { | 1037 cricket::MediaSessionOptions options) { |
1041 return CreateRemoteAnswer(offer, options, cricket::SEC_REQUIRED); | 1038 return CreateRemoteAnswer(offer, options, cricket::SEC_REQUIRED); |
1042 } | 1039 } |
1043 | 1040 |
1044 // Creates an answer session description. | 1041 // Creates an answer session description. |
1045 // Call SendAudioVideoStreamX() before this function | 1042 // Call SendAudioVideoStreamX() before this function |
1046 // to decide which streams to create. | 1043 // to decide which streams to create. |
1047 JsepSessionDescription* CreateRemoteAnswer( | 1044 JsepSessionDescription* CreateRemoteAnswer( |
1048 const SessionDescriptionInterface* offer) { | 1045 const SessionDescriptionInterface* offer) { |
1049 cricket::MediaSessionOptions options; | 1046 cricket::MediaSessionOptions options; |
1050 GetOptionsForAnswer(NULL, &options); | 1047 GetOptionsForAnswer(&options); |
1051 return CreateRemoteAnswer(offer, options, cricket::SEC_REQUIRED); | 1048 return CreateRemoteAnswer(offer, options, cricket::SEC_REQUIRED); |
1052 } | 1049 } |
1053 | 1050 |
1054 void TestSessionCandidatesWithBundleRtcpMux(bool bundle, bool rtcp_mux) { | 1051 void TestSessionCandidatesWithBundleRtcpMux(bool bundle, bool rtcp_mux) { |
1055 AddInterface(rtc::SocketAddress(kClientAddrHost1, kClientAddrPort)); | 1052 AddInterface(rtc::SocketAddress(kClientAddrHost1, kClientAddrPort)); |
1056 Init(); | 1053 Init(); |
1057 SendAudioVideoStream1(); | 1054 SendAudioVideoStream1(); |
1058 | 1055 |
1059 PeerConnectionInterface::RTCOfferAnswerOptions options; | 1056 PeerConnectionInterface::RTCOfferAnswerOptions options; |
1060 options.use_rtp_mux = bundle; | 1057 options.use_rtp_mux = bundle; |
(...skipping 266 matching lines...) Loading... |
1327 ASSERT(audio_content_desc != NULL); | 1324 ASSERT(audio_content_desc != NULL); |
1328 for (size_t i = 0; i < audio_content_desc->codecs().size(); ++i) { | 1325 for (size_t i = 0; i < audio_content_desc->codecs().size(); ++i) { |
1329 if (audio_content_desc->codecs()[i].name == "CN") | 1326 if (audio_content_desc->codecs()[i].name == "CN") |
1330 return false; | 1327 return false; |
1331 } | 1328 } |
1332 return true; | 1329 return true; |
1333 } | 1330 } |
1334 | 1331 |
1335 void CreateDataChannel() { | 1332 void CreateDataChannel() { |
1336 webrtc::InternalDataChannelInit dci; | 1333 webrtc::InternalDataChannelInit dci; |
| 1334 ASSERT(session_.get()); |
1337 dci.reliable = session_->data_channel_type() == cricket::DCT_SCTP; | 1335 dci.reliable = session_->data_channel_type() == cricket::DCT_SCTP; |
1338 data_channel_ = DataChannel::Create( | 1336 data_channel_ = DataChannel::Create( |
1339 session_.get(), session_->data_channel_type(), "datachannel", dci); | 1337 session_.get(), session_->data_channel_type(), "datachannel", dci); |
1340 } | 1338 } |
1341 | 1339 |
1342 void SetLocalDescriptionWithDataChannel() { | 1340 void SetLocalDescriptionWithDataChannel() { |
1343 CreateDataChannel(); | 1341 CreateDataChannel(); |
1344 SessionDescriptionInterface* offer = CreateOffer(); | 1342 SessionDescriptionInterface* offer = CreateOffer(); |
1345 SetLocalDescriptionWithoutError(offer); | 1343 SetLocalDescriptionWithoutError(offer); |
1346 } | 1344 } |
(...skipping 26 matching lines...) Loading... |
1373 PeerConnectionInterface::RTCOfferAnswerOptions options; | 1371 PeerConnectionInterface::RTCOfferAnswerOptions options; |
1374 cricket::MediaSessionOptions session_options; | 1372 cricket::MediaSessionOptions session_options; |
1375 const int kNumber = 3; | 1373 const int kNumber = 3; |
1376 rtc::scoped_refptr<WebRtcSessionCreateSDPObserverForTest> | 1374 rtc::scoped_refptr<WebRtcSessionCreateSDPObserverForTest> |
1377 observers[kNumber]; | 1375 observers[kNumber]; |
1378 for (int i = 0; i < kNumber; ++i) { | 1376 for (int i = 0; i < kNumber; ++i) { |
1379 observers[i] = new WebRtcSessionCreateSDPObserverForTest(); | 1377 observers[i] = new WebRtcSessionCreateSDPObserverForTest(); |
1380 if (type == CreateSessionDescriptionRequest::kOffer) { | 1378 if (type == CreateSessionDescriptionRequest::kOffer) { |
1381 session_->CreateOffer(observers[i], options, session_options); | 1379 session_->CreateOffer(observers[i], options, session_options); |
1382 } else { | 1380 } else { |
1383 session_->CreateAnswer(observers[i], nullptr, session_options); | 1381 session_->CreateAnswer(observers[i], session_options); |
1384 } | 1382 } |
1385 } | 1383 } |
1386 | 1384 |
1387 WebRtcSessionCreateSDPObserverForTest::State expected_state = | 1385 WebRtcSessionCreateSDPObserverForTest::State expected_state = |
1388 success ? WebRtcSessionCreateSDPObserverForTest::kSucceeded : | 1386 success ? WebRtcSessionCreateSDPObserverForTest::kSucceeded : |
1389 WebRtcSessionCreateSDPObserverForTest::kFailed; | 1387 WebRtcSessionCreateSDPObserverForTest::kFailed; |
1390 | 1388 |
1391 for (int i = 0; i < kNumber; ++i) { | 1389 for (int i = 0; i < kNumber; ++i) { |
1392 EXPECT_EQ_WAIT(expected_state, observers[i]->state(), 1000); | 1390 EXPECT_EQ_WAIT(expected_state, observers[i]->state(), 1000); |
1393 if (success) { | 1391 if (success) { |
(...skipping 25 matching lines...) Loading... |
1419 rtc::scoped_ptr<rtc::PhysicalSocketServer> pss_; | 1417 rtc::scoped_ptr<rtc::PhysicalSocketServer> pss_; |
1420 rtc::scoped_ptr<rtc::VirtualSocketServer> vss_; | 1418 rtc::scoped_ptr<rtc::VirtualSocketServer> vss_; |
1421 rtc::scoped_ptr<rtc::FirewallSocketServer> fss_; | 1419 rtc::scoped_ptr<rtc::FirewallSocketServer> fss_; |
1422 rtc::SocketServerScope ss_scope_; | 1420 rtc::SocketServerScope ss_scope_; |
1423 rtc::SocketAddress stun_socket_addr_; | 1421 rtc::SocketAddress stun_socket_addr_; |
1424 rtc::scoped_ptr<cricket::TestStunServer> stun_server_; | 1422 rtc::scoped_ptr<cricket::TestStunServer> stun_server_; |
1425 cricket::TestTurnServer turn_server_; | 1423 cricket::TestTurnServer turn_server_; |
1426 rtc::FakeNetworkManager network_manager_; | 1424 rtc::FakeNetworkManager network_manager_; |
1427 rtc::scoped_ptr<cricket::BasicPortAllocator> allocator_; | 1425 rtc::scoped_ptr<cricket::BasicPortAllocator> allocator_; |
1428 PeerConnectionFactoryInterface::Options options_; | 1426 PeerConnectionFactoryInterface::Options options_; |
1429 rtc::scoped_ptr<FakeConstraints> constraints_; | 1427 PeerConnectionInterface::RTCConfiguration configuration_; |
1430 rtc::scoped_ptr<WebRtcSessionForTest> session_; | 1428 rtc::scoped_ptr<WebRtcSessionForTest> session_; |
1431 MockIceObserver observer_; | 1429 MockIceObserver observer_; |
1432 cricket::FakeVideoMediaChannel* video_channel_; | 1430 cricket::FakeVideoMediaChannel* video_channel_; |
1433 cricket::FakeVoiceMediaChannel* voice_channel_; | 1431 cricket::FakeVoiceMediaChannel* voice_channel_; |
1434 rtc::scoped_refptr<FakeMetricsObserver> metrics_observer_; | 1432 rtc::scoped_refptr<FakeMetricsObserver> metrics_observer_; |
1435 // The following flags affect options created for CreateOffer/CreateAnswer. | 1433 // The following flags affect options created for CreateOffer/CreateAnswer. |
1436 bool send_stream_1_ = false; | 1434 bool send_stream_1_ = false; |
1437 bool send_stream_2_ = false; | 1435 bool send_stream_2_ = false; |
1438 bool send_audio_ = false; | 1436 bool send_audio_ = false; |
1439 bool send_video_ = false; | 1437 bool send_video_ = false; |
(...skipping 173 matching lines...) Loading... |
1613 // Test receiving offers and creating answers and make sure the | 1611 // Test receiving offers and creating answers and make sure the |
1614 // media engine creates the expected send and receive streams. | 1612 // media engine creates the expected send and receive streams. |
1615 TEST_F(WebRtcSessionTest, TestReceiveSdesOfferCreateSdesAnswer) { | 1613 TEST_F(WebRtcSessionTest, TestReceiveSdesOfferCreateSdesAnswer) { |
1616 Init(); | 1614 Init(); |
1617 SendAudioVideoStream2(); | 1615 SendAudioVideoStream2(); |
1618 SessionDescriptionInterface* offer = CreateOffer(); | 1616 SessionDescriptionInterface* offer = CreateOffer(); |
1619 VerifyCryptoParams(offer->description()); | 1617 VerifyCryptoParams(offer->description()); |
1620 SetRemoteDescriptionWithoutError(offer); | 1618 SetRemoteDescriptionWithoutError(offer); |
1621 | 1619 |
1622 SendAudioVideoStream1(); | 1620 SendAudioVideoStream1(); |
1623 SessionDescriptionInterface* answer = CreateAnswer(NULL); | 1621 SessionDescriptionInterface* answer = CreateAnswer(); |
1624 VerifyCryptoParams(answer->description()); | 1622 VerifyCryptoParams(answer->description()); |
1625 SetLocalDescriptionWithoutError(answer); | 1623 SetLocalDescriptionWithoutError(answer); |
1626 | 1624 |
1627 const std::string session_id_orig = answer->session_id(); | 1625 const std::string session_id_orig = answer->session_id(); |
1628 const std::string session_version_orig = answer->session_version(); | 1626 const std::string session_version_orig = answer->session_version(); |
1629 | 1627 |
1630 video_channel_ = media_engine_->GetVideoChannel(0); | 1628 video_channel_ = media_engine_->GetVideoChannel(0); |
1631 voice_channel_ = media_engine_->GetVoiceChannel(0); | 1629 voice_channel_ = media_engine_->GetVoiceChannel(0); |
1632 | 1630 |
| 1631 ASSERT_TRUE(video_channel_); |
| 1632 ASSERT_TRUE(voice_channel_); |
1633 ASSERT_EQ(1u, video_channel_->recv_streams().size()); | 1633 ASSERT_EQ(1u, video_channel_->recv_streams().size()); |
1634 EXPECT_TRUE(kVideoTrack2 == video_channel_->recv_streams()[0].id); | 1634 EXPECT_TRUE(kVideoTrack2 == video_channel_->recv_streams()[0].id); |
1635 | 1635 |
1636 ASSERT_EQ(1u, voice_channel_->recv_streams().size()); | 1636 ASSERT_EQ(1u, voice_channel_->recv_streams().size()); |
1637 EXPECT_TRUE(kAudioTrack2 == voice_channel_->recv_streams()[0].id); | 1637 EXPECT_TRUE(kAudioTrack2 == voice_channel_->recv_streams()[0].id); |
1638 | 1638 |
1639 ASSERT_EQ(1u, video_channel_->send_streams().size()); | 1639 ASSERT_EQ(1u, video_channel_->send_streams().size()); |
1640 EXPECT_TRUE(kVideoTrack1 == video_channel_->send_streams()[0].id); | 1640 EXPECT_TRUE(kVideoTrack1 == video_channel_->send_streams()[0].id); |
1641 ASSERT_EQ(1u, voice_channel_->send_streams().size()); | 1641 ASSERT_EQ(1u, voice_channel_->send_streams().size()); |
1642 EXPECT_TRUE(kAudioTrack1 == voice_channel_->send_streams()[0].id); | 1642 EXPECT_TRUE(kAudioTrack1 == voice_channel_->send_streams()[0].id); |
1643 | 1643 |
1644 SendAudioVideoStream1And2(); | 1644 SendAudioVideoStream1And2(); |
1645 offer = CreateOffer(); | 1645 offer = CreateOffer(); |
1646 SetRemoteDescriptionWithoutError(offer); | 1646 SetRemoteDescriptionWithoutError(offer); |
1647 | 1647 |
1648 // Answer by turning off all send streams. | 1648 // Answer by turning off all send streams. |
1649 SendNothing(); | 1649 SendNothing(); |
1650 answer = CreateAnswer(NULL); | 1650 answer = CreateAnswer(); |
1651 | 1651 |
1652 // Verify the session id is the same and the session version is | 1652 // Verify the session id is the same and the session version is |
1653 // increased. | 1653 // increased. |
1654 EXPECT_EQ(session_id_orig, answer->session_id()); | 1654 EXPECT_EQ(session_id_orig, answer->session_id()); |
1655 EXPECT_LT(rtc::FromString<uint64_t>(session_version_orig), | 1655 EXPECT_LT(rtc::FromString<uint64_t>(session_version_orig), |
1656 rtc::FromString<uint64_t>(answer->session_version())); | 1656 rtc::FromString<uint64_t>(answer->session_version())); |
1657 SetLocalDescriptionWithoutError(answer); | 1657 SetLocalDescriptionWithoutError(answer); |
1658 | 1658 |
1659 ASSERT_EQ(2u, video_channel_->recv_streams().size()); | 1659 ASSERT_EQ(2u, video_channel_->recv_streams().size()); |
1660 EXPECT_TRUE(kVideoTrack1 == video_channel_->recv_streams()[0].id); | 1660 EXPECT_TRUE(kVideoTrack1 == video_channel_->recv_streams()[0].id); |
(...skipping 107 matching lines...) Loading... |
1768 JsepSessionDescription* offer = | 1768 JsepSessionDescription* offer = |
1769 CreateRemoteOffer(options, cricket::SEC_DISABLED); | 1769 CreateRemoteOffer(options, cricket::SEC_DISABLED); |
1770 ASSERT_TRUE(offer != NULL); | 1770 ASSERT_TRUE(offer != NULL); |
1771 VerifyFingerprintStatus(offer->description(), true); | 1771 VerifyFingerprintStatus(offer->description(), true); |
1772 VerifyNoCryptoParams(offer->description(), true); | 1772 VerifyNoCryptoParams(offer->description(), true); |
1773 | 1773 |
1774 // SetRemoteDescription will take the ownership of the offer. | 1774 // SetRemoteDescription will take the ownership of the offer. |
1775 SetRemoteDescriptionWithoutError(offer); | 1775 SetRemoteDescriptionWithoutError(offer); |
1776 | 1776 |
1777 // Verify that we get a crypto fingerprint in the answer. | 1777 // Verify that we get a crypto fingerprint in the answer. |
1778 SessionDescriptionInterface* answer = CreateAnswer(NULL); | 1778 SessionDescriptionInterface* answer = CreateAnswer(); |
1779 ASSERT_TRUE(answer != NULL); | 1779 ASSERT_TRUE(answer != NULL); |
1780 VerifyFingerprintStatus(answer->description(), true); | 1780 VerifyFingerprintStatus(answer->description(), true); |
1781 // Check that we don't have an a=crypto line in the answer. | 1781 // Check that we don't have an a=crypto line in the answer. |
1782 VerifyNoCryptoParams(answer->description(), true); | 1782 VerifyNoCryptoParams(answer->description(), true); |
1783 | 1783 |
1784 // Now set the local description, which should work, even without a=crypto. | 1784 // Now set the local description, which should work, even without a=crypto. |
1785 SetLocalDescriptionWithoutError(answer); | 1785 SetLocalDescriptionWithoutError(answer); |
1786 } | 1786 } |
1787 | 1787 |
1788 // Test that we set a local offer with a DTLS fingerprint when DTLS is on | 1788 // Test that we set a local offer with a DTLS fingerprint when DTLS is on |
(...skipping 126 matching lines...) Loading... |
1915 JsepSessionDescription* offer = | 1915 JsepSessionDescription* offer = |
1916 CreateRemoteOffer(options, cricket::SEC_DISABLED); | 1916 CreateRemoteOffer(options, cricket::SEC_DISABLED); |
1917 ASSERT_TRUE(offer != NULL); | 1917 ASSERT_TRUE(offer != NULL); |
1918 VerifyFingerprintStatus(offer->description(), false); | 1918 VerifyFingerprintStatus(offer->description(), false); |
1919 VerifyNoCryptoParams(offer->description(), false); | 1919 VerifyNoCryptoParams(offer->description(), false); |
1920 | 1920 |
1921 // SetRemoteDescription will take the ownership of the offer. | 1921 // SetRemoteDescription will take the ownership of the offer. |
1922 SetRemoteDescriptionWithoutError(offer); | 1922 SetRemoteDescriptionWithoutError(offer); |
1923 | 1923 |
1924 // Verify that we get a crypto fingerprint in the answer. | 1924 // Verify that we get a crypto fingerprint in the answer. |
1925 SessionDescriptionInterface* answer = CreateAnswer(NULL); | 1925 SessionDescriptionInterface* answer = CreateAnswer(); |
1926 ASSERT_TRUE(answer != NULL); | 1926 ASSERT_TRUE(answer != NULL); |
1927 VerifyFingerprintStatus(answer->description(), false); | 1927 VerifyFingerprintStatus(answer->description(), false); |
1928 // Check that we don't have an a=crypto line in the answer. | 1928 // Check that we don't have an a=crypto line in the answer. |
1929 VerifyNoCryptoParams(answer->description(), false); | 1929 VerifyNoCryptoParams(answer->description(), false); |
1930 | 1930 |
1931 // Now set the local description, which should work, even without a=crypto. | 1931 // Now set the local description, which should work, even without a=crypto. |
1932 SetLocalDescriptionWithoutError(answer); | 1932 SetLocalDescriptionWithoutError(answer); |
1933 } | 1933 } |
1934 | 1934 |
1935 // Test that we can create and set an answer correctly when different | 1935 // Test that we can create and set an answer correctly when different |
(...skipping 23 matching lines...) Loading... |
1959 cricket::CONNECTIONROLE_PASSIVE; | 1959 cricket::CONNECTIONROLE_PASSIVE; |
1960 SetRemoteDescriptionWithoutError(answer); | 1960 SetRemoteDescriptionWithoutError(answer); |
1961 | 1961 |
1962 // Now create an offer in the reverse direction, and ensure the initial | 1962 // Now create an offer in the reverse direction, and ensure the initial |
1963 // offerer responds with an answer with correct SSL roles. | 1963 // offerer responds with an answer with correct SSL roles. |
1964 offer = CreateRemoteOfferWithVersion(options, cricket::SEC_DISABLED, | 1964 offer = CreateRemoteOfferWithVersion(options, cricket::SEC_DISABLED, |
1965 kSessionVersion, | 1965 kSessionVersion, |
1966 session_->remote_description()); | 1966 session_->remote_description()); |
1967 SetRemoteDescriptionWithoutError(offer); | 1967 SetRemoteDescriptionWithoutError(offer); |
1968 | 1968 |
1969 answer = CreateAnswer(nullptr); | 1969 answer = CreateAnswer(); |
1970 audio_transport_info = answer->description()->GetTransportInfoByName("audio"); | 1970 audio_transport_info = answer->description()->GetTransportInfoByName("audio"); |
1971 EXPECT_EQ(cricket::CONNECTIONROLE_PASSIVE, | 1971 EXPECT_EQ(cricket::CONNECTIONROLE_PASSIVE, |
1972 audio_transport_info->description.connection_role); | 1972 audio_transport_info->description.connection_role); |
1973 video_transport_info = answer->description()->GetTransportInfoByName("video"); | 1973 video_transport_info = answer->description()->GetTransportInfoByName("video"); |
1974 EXPECT_EQ(cricket::CONNECTIONROLE_ACTIVE, | 1974 EXPECT_EQ(cricket::CONNECTIONROLE_ACTIVE, |
1975 video_transport_info->description.connection_role); | 1975 video_transport_info->description.connection_role); |
1976 SetLocalDescriptionWithoutError(answer); | 1976 SetLocalDescriptionWithoutError(answer); |
1977 | 1977 |
1978 // Lastly, start BUNDLE-ing on "audio", expecting that the "passive" role of | 1978 // Lastly, start BUNDLE-ing on "audio", expecting that the "passive" role of |
1979 // audio is transferred over to video in the answer that completes the BUNDLE | 1979 // audio is transferred over to video in the answer that completes the BUNDLE |
1980 // negotiation. | 1980 // negotiation. |
1981 options.bundle_enabled = true; | 1981 options.bundle_enabled = true; |
1982 offer = CreateRemoteOfferWithVersion(options, cricket::SEC_DISABLED, | 1982 offer = CreateRemoteOfferWithVersion(options, cricket::SEC_DISABLED, |
1983 kSessionVersion, | 1983 kSessionVersion, |
1984 session_->remote_description()); | 1984 session_->remote_description()); |
1985 SetRemoteDescriptionWithoutError(offer); | 1985 SetRemoteDescriptionWithoutError(offer); |
1986 answer = CreateAnswer(nullptr); | 1986 answer = CreateAnswer(); |
1987 audio_transport_info = answer->description()->GetTransportInfoByName("audio"); | 1987 audio_transport_info = answer->description()->GetTransportInfoByName("audio"); |
1988 EXPECT_EQ(cricket::CONNECTIONROLE_PASSIVE, | 1988 EXPECT_EQ(cricket::CONNECTIONROLE_PASSIVE, |
1989 audio_transport_info->description.connection_role); | 1989 audio_transport_info->description.connection_role); |
1990 video_transport_info = answer->description()->GetTransportInfoByName("video"); | 1990 video_transport_info = answer->description()->GetTransportInfoByName("video"); |
1991 EXPECT_EQ(cricket::CONNECTIONROLE_PASSIVE, | 1991 EXPECT_EQ(cricket::CONNECTIONROLE_PASSIVE, |
1992 video_transport_info->description.connection_role); | 1992 video_transport_info->description.connection_role); |
1993 SetLocalDescriptionWithoutError(answer); | 1993 SetLocalDescriptionWithoutError(answer); |
1994 } | 1994 } |
1995 | 1995 |
1996 TEST_F(WebRtcSessionTest, TestSetLocalOfferTwice) { | 1996 TEST_F(WebRtcSessionTest, TestSetLocalOfferTwice) { |
(...skipping 38 matching lines...) Loading... |
2035 SetLocalDescriptionOfferExpectError( | 2035 SetLocalDescriptionOfferExpectError( |
2036 "Called in wrong state: STATE_RECEIVEDOFFER", offer); | 2036 "Called in wrong state: STATE_RECEIVEDOFFER", offer); |
2037 } | 2037 } |
2038 | 2038 |
2039 TEST_F(WebRtcSessionTest, TestSetLocalPrAnswer) { | 2039 TEST_F(WebRtcSessionTest, TestSetLocalPrAnswer) { |
2040 Init(); | 2040 Init(); |
2041 SendNothing(); | 2041 SendNothing(); |
2042 SessionDescriptionInterface* offer = CreateRemoteOffer(); | 2042 SessionDescriptionInterface* offer = CreateRemoteOffer(); |
2043 SetRemoteDescriptionExpectState(offer, WebRtcSession::STATE_RECEIVEDOFFER); | 2043 SetRemoteDescriptionExpectState(offer, WebRtcSession::STATE_RECEIVEDOFFER); |
2044 | 2044 |
2045 JsepSessionDescription* pranswer = static_cast<JsepSessionDescription*>( | 2045 JsepSessionDescription* pranswer = |
2046 CreateAnswer(NULL)); | 2046 static_cast<JsepSessionDescription*>(CreateAnswer()); |
2047 pranswer->set_type(SessionDescriptionInterface::kPrAnswer); | 2047 pranswer->set_type(SessionDescriptionInterface::kPrAnswer); |
2048 SetLocalDescriptionExpectState(pranswer, WebRtcSession::STATE_SENTPRANSWER); | 2048 SetLocalDescriptionExpectState(pranswer, WebRtcSession::STATE_SENTPRANSWER); |
2049 | 2049 |
2050 SendAudioVideoStream1(); | 2050 SendAudioVideoStream1(); |
2051 JsepSessionDescription* pranswer2 = static_cast<JsepSessionDescription*>( | 2051 JsepSessionDescription* pranswer2 = |
2052 CreateAnswer(NULL)); | 2052 static_cast<JsepSessionDescription*>(CreateAnswer()); |
2053 pranswer2->set_type(SessionDescriptionInterface::kPrAnswer); | 2053 pranswer2->set_type(SessionDescriptionInterface::kPrAnswer); |
2054 | 2054 |
2055 SetLocalDescriptionExpectState(pranswer2, WebRtcSession::STATE_SENTPRANSWER); | 2055 SetLocalDescriptionExpectState(pranswer2, WebRtcSession::STATE_SENTPRANSWER); |
2056 | 2056 |
2057 SendAudioVideoStream2(); | 2057 SendAudioVideoStream2(); |
2058 SessionDescriptionInterface* answer = CreateAnswer(NULL); | 2058 SessionDescriptionInterface* answer = CreateAnswer(); |
2059 SetLocalDescriptionExpectState(answer, WebRtcSession::STATE_INPROGRESS); | 2059 SetLocalDescriptionExpectState(answer, WebRtcSession::STATE_INPROGRESS); |
2060 } | 2060 } |
2061 | 2061 |
2062 TEST_F(WebRtcSessionTest, TestSetRemotePrAnswer) { | 2062 TEST_F(WebRtcSessionTest, TestSetRemotePrAnswer) { |
2063 Init(); | 2063 Init(); |
2064 SendNothing(); | 2064 SendNothing(); |
2065 SessionDescriptionInterface* offer = CreateOffer(); | 2065 SessionDescriptionInterface* offer = CreateOffer(); |
2066 SetLocalDescriptionExpectState(offer, WebRtcSession::STATE_SENTOFFER); | 2066 SetLocalDescriptionExpectState(offer, WebRtcSession::STATE_SENTOFFER); |
2067 | 2067 |
2068 JsepSessionDescription* pranswer = | 2068 JsepSessionDescription* pranswer = |
(...skipping 194 matching lines...) Loading... |
2263 | 2263 |
2264 const SessionDescriptionInterface* remote_desc = | 2264 const SessionDescriptionInterface* remote_desc = |
2265 session_->remote_description(); | 2265 session_->remote_description(); |
2266 ASSERT_TRUE(remote_desc != NULL); | 2266 ASSERT_TRUE(remote_desc != NULL); |
2267 ASSERT_EQ(2u, remote_desc->number_of_mediasections()); | 2267 ASSERT_EQ(2u, remote_desc->number_of_mediasections()); |
2268 const IceCandidateCollection* candidates = | 2268 const IceCandidateCollection* candidates = |
2269 remote_desc->candidates(kMediaContentIndex0); | 2269 remote_desc->candidates(kMediaContentIndex0); |
2270 ASSERT_EQ(1u, candidates->count()); | 2270 ASSERT_EQ(1u, candidates->count()); |
2271 EXPECT_EQ(kMediaContentIndex0, candidates->at(0)->sdp_mline_index()); | 2271 EXPECT_EQ(kMediaContentIndex0, candidates->at(0)->sdp_mline_index()); |
2272 | 2272 |
2273 SessionDescriptionInterface* answer = CreateAnswer(NULL); | 2273 SessionDescriptionInterface* answer = CreateAnswer(); |
2274 SetLocalDescriptionWithoutError(answer); | 2274 SetLocalDescriptionWithoutError(answer); |
2275 } | 2275 } |
2276 | 2276 |
2277 // Test that offers and answers contains ice candidates when Ice candidates have | 2277 // Test that offers and answers contains ice candidates when Ice candidates have |
2278 // been gathered. | 2278 // been gathered. |
2279 TEST_F(WebRtcSessionTest, TestSetLocalAndRemoteDescriptionWithCandidates) { | 2279 TEST_F(WebRtcSessionTest, TestSetLocalAndRemoteDescriptionWithCandidates) { |
2280 AddInterface(rtc::SocketAddress(kClientAddrHost1, kClientAddrPort)); | 2280 AddInterface(rtc::SocketAddress(kClientAddrHost1, kClientAddrPort)); |
2281 Init(); | 2281 Init(); |
2282 SendAudioVideoStream1(); | 2282 SendAudioVideoStream1(); |
2283 // Ice is started but candidates are not provided until SetLocalDescription | 2283 // Ice is started but candidates are not provided until SetLocalDescription |
2284 // is called. | 2284 // is called. |
2285 EXPECT_EQ(0u, observer_.mline_0_candidates_.size()); | 2285 EXPECT_EQ(0u, observer_.mline_0_candidates_.size()); |
2286 EXPECT_EQ(0u, observer_.mline_1_candidates_.size()); | 2286 EXPECT_EQ(0u, observer_.mline_1_candidates_.size()); |
2287 CreateAndSetRemoteOfferAndLocalAnswer(); | 2287 CreateAndSetRemoteOfferAndLocalAnswer(); |
2288 // Wait until at least one local candidate has been collected. | 2288 // Wait until at least one local candidate has been collected. |
2289 EXPECT_TRUE_WAIT(0u < observer_.mline_0_candidates_.size(), | 2289 EXPECT_TRUE_WAIT(0u < observer_.mline_0_candidates_.size(), |
2290 kIceCandidatesTimeout); | 2290 kIceCandidatesTimeout); |
2291 | 2291 |
2292 rtc::scoped_ptr<SessionDescriptionInterface> local_offer(CreateOffer()); | 2292 rtc::scoped_ptr<SessionDescriptionInterface> local_offer(CreateOffer()); |
2293 | 2293 |
2294 ASSERT_TRUE(local_offer->candidates(kMediaContentIndex0) != NULL); | 2294 ASSERT_TRUE(local_offer->candidates(kMediaContentIndex0) != NULL); |
2295 EXPECT_LT(0u, local_offer->candidates(kMediaContentIndex0)->count()); | 2295 EXPECT_LT(0u, local_offer->candidates(kMediaContentIndex0)->count()); |
2296 | 2296 |
2297 SessionDescriptionInterface* remote_offer(CreateRemoteOffer()); | 2297 SessionDescriptionInterface* remote_offer(CreateRemoteOffer()); |
2298 SetRemoteDescriptionWithoutError(remote_offer); | 2298 SetRemoteDescriptionWithoutError(remote_offer); |
2299 SessionDescriptionInterface* answer = CreateAnswer(NULL); | 2299 SessionDescriptionInterface* answer = CreateAnswer(); |
2300 ASSERT_TRUE(answer->candidates(kMediaContentIndex0) != NULL); | 2300 ASSERT_TRUE(answer->candidates(kMediaContentIndex0) != NULL); |
2301 EXPECT_LT(0u, answer->candidates(kMediaContentIndex0)->count()); | 2301 EXPECT_LT(0u, answer->candidates(kMediaContentIndex0)->count()); |
2302 SetLocalDescriptionWithoutError(answer); | 2302 SetLocalDescriptionWithoutError(answer); |
2303 } | 2303 } |
2304 | 2304 |
2305 // Verifies TransportProxy and media channels are created with content names | 2305 // Verifies TransportProxy and media channels are created with content names |
2306 // present in the SessionDescription. | 2306 // present in the SessionDescription. |
2307 TEST_F(WebRtcSessionTest, TestChannelCreationsWithContentNames) { | 2307 TEST_F(WebRtcSessionTest, TestChannelCreationsWithContentNames) { |
2308 Init(); | 2308 Init(); |
2309 SendAudioVideoStream1(); | 2309 SendAudioVideoStream1(); |
(...skipping 20 matching lines...) Loading... |
2330 rtc::replace_substrs(kVideoMid.c_str(), kVideoMid.length(), | 2330 rtc::replace_substrs(kVideoMid.c_str(), kVideoMid.length(), |
2331 kVideoMidReplaceStr.c_str(), | 2331 kVideoMidReplaceStr.c_str(), |
2332 kVideoMidReplaceStr.length(), | 2332 kVideoMidReplaceStr.length(), |
2333 &sdp); | 2333 &sdp); |
2334 | 2334 |
2335 SessionDescriptionInterface* modified_offer = | 2335 SessionDescriptionInterface* modified_offer = |
2336 CreateSessionDescription(JsepSessionDescription::kOffer, sdp, NULL); | 2336 CreateSessionDescription(JsepSessionDescription::kOffer, sdp, NULL); |
2337 | 2337 |
2338 SetRemoteDescriptionWithoutError(modified_offer); | 2338 SetRemoteDescriptionWithoutError(modified_offer); |
2339 | 2339 |
2340 SessionDescriptionInterface* answer = | 2340 SessionDescriptionInterface* answer = CreateAnswer(); |
2341 CreateAnswer(NULL); | |
2342 SetLocalDescriptionWithoutError(answer); | 2341 SetLocalDescriptionWithoutError(answer); |
2343 | 2342 |
2344 cricket::TransportChannel* voice_transport_channel = | 2343 cricket::TransportChannel* voice_transport_channel = |
2345 session_->voice_rtp_transport_channel(); | 2344 session_->voice_rtp_transport_channel(); |
2346 EXPECT_TRUE(voice_transport_channel != NULL); | 2345 EXPECT_TRUE(voice_transport_channel != NULL); |
2347 EXPECT_EQ(voice_transport_channel->transport_name(), "audio_content_name"); | 2346 EXPECT_EQ(voice_transport_channel->transport_name(), "audio_content_name"); |
2348 cricket::TransportChannel* video_transport_channel = | 2347 cricket::TransportChannel* video_transport_channel = |
2349 session_->video_rtp_transport_channel(); | 2348 session_->video_rtp_transport_channel(); |
2350 EXPECT_TRUE(video_transport_channel != NULL); | 2349 ASSERT_TRUE(video_transport_channel != NULL); |
2351 EXPECT_EQ(video_transport_channel->transport_name(), "video_content_name"); | 2350 EXPECT_EQ(video_transport_channel->transport_name(), "video_content_name"); |
2352 EXPECT_TRUE((video_channel_ = media_engine_->GetVideoChannel(0)) != NULL); | 2351 EXPECT_TRUE((video_channel_ = media_engine_->GetVideoChannel(0)) != NULL); |
2353 EXPECT_TRUE((voice_channel_ = media_engine_->GetVoiceChannel(0)) != NULL); | 2352 EXPECT_TRUE((voice_channel_ = media_engine_->GetVoiceChannel(0)) != NULL); |
2354 } | 2353 } |
2355 | 2354 |
2356 // Test that an offer contains the correct media content descriptions based on | 2355 // Test that an offer contains the correct media content descriptions based on |
2357 // the send streams when no constraints have been set. | 2356 // the send streams when no constraints have been set. |
2358 TEST_F(WebRtcSessionTest, CreateOfferWithoutConstraintsOrStreams) { | 2357 TEST_F(WebRtcSessionTest, CreateOfferWithoutConstraintsOrStreams) { |
2359 Init(); | 2358 Init(); |
2360 rtc::scoped_ptr<SessionDescriptionInterface> offer(CreateOffer()); | 2359 rtc::scoped_ptr<SessionDescriptionInterface> offer(CreateOffer()); |
(...skipping 100 matching lines...) Loading... |
2461 } | 2460 } |
2462 | 2461 |
2463 // Test that an answer can not be created if the last remote description is not | 2462 // Test that an answer can not be created if the last remote description is not |
2464 // an offer. | 2463 // an offer. |
2465 TEST_F(WebRtcSessionTest, CreateAnswerWithoutAnOffer) { | 2464 TEST_F(WebRtcSessionTest, CreateAnswerWithoutAnOffer) { |
2466 Init(); | 2465 Init(); |
2467 SessionDescriptionInterface* offer = CreateOffer(); | 2466 SessionDescriptionInterface* offer = CreateOffer(); |
2468 SetLocalDescriptionWithoutError(offer); | 2467 SetLocalDescriptionWithoutError(offer); |
2469 SessionDescriptionInterface* answer = CreateRemoteAnswer(offer); | 2468 SessionDescriptionInterface* answer = CreateRemoteAnswer(offer); |
2470 SetRemoteDescriptionWithoutError(answer); | 2469 SetRemoteDescriptionWithoutError(answer); |
2471 EXPECT_TRUE(CreateAnswer(NULL) == NULL); | 2470 EXPECT_TRUE(CreateAnswer() == NULL); |
2472 } | 2471 } |
2473 | 2472 |
2474 // Test that an answer contains the correct media content descriptions when no | 2473 // Test that an answer contains the correct media content descriptions when no |
2475 // constraints have been set. | 2474 // constraints have been set. |
2476 TEST_F(WebRtcSessionTest, CreateAnswerWithoutConstraintsOrStreams) { | 2475 TEST_F(WebRtcSessionTest, CreateAnswerWithoutConstraintsOrStreams) { |
2477 Init(); | 2476 Init(); |
2478 // Create a remote offer with audio and video content. | 2477 // Create a remote offer with audio and video content. |
2479 rtc::scoped_ptr<JsepSessionDescription> offer(CreateRemoteOffer()); | 2478 rtc::scoped_ptr<JsepSessionDescription> offer(CreateRemoteOffer()); |
2480 SetRemoteDescriptionWithoutError(offer.release()); | 2479 SetRemoteDescriptionWithoutError(offer.release()); |
2481 rtc::scoped_ptr<SessionDescriptionInterface> answer( | 2480 rtc::scoped_ptr<SessionDescriptionInterface> answer(CreateAnswer()); |
2482 CreateAnswer(NULL)); | |
2483 const cricket::ContentInfo* content = | 2481 const cricket::ContentInfo* content = |
2484 cricket::GetFirstAudioContent(answer->description()); | 2482 cricket::GetFirstAudioContent(answer->description()); |
2485 ASSERT_TRUE(content != NULL); | 2483 ASSERT_TRUE(content != NULL); |
2486 EXPECT_FALSE(content->rejected); | 2484 EXPECT_FALSE(content->rejected); |
2487 | 2485 |
2488 content = cricket::GetFirstVideoContent(answer->description()); | 2486 content = cricket::GetFirstVideoContent(answer->description()); |
2489 ASSERT_TRUE(content != NULL); | 2487 ASSERT_TRUE(content != NULL); |
2490 EXPECT_FALSE(content->rejected); | 2488 EXPECT_FALSE(content->rejected); |
2491 } | 2489 } |
2492 | 2490 |
2493 // Test that an answer contains the correct media content descriptions when no | 2491 // Test that an answer contains the correct media content descriptions when no |
2494 // constraints have been set and the offer only contain audio. | 2492 // constraints have been set and the offer only contain audio. |
2495 TEST_F(WebRtcSessionTest, CreateAudioAnswerWithoutConstraintsOrStreams) { | 2493 TEST_F(WebRtcSessionTest, CreateAudioAnswerWithoutConstraintsOrStreams) { |
2496 Init(); | 2494 Init(); |
2497 // Create a remote offer with audio only. | 2495 // Create a remote offer with audio only. |
2498 cricket::MediaSessionOptions options; | 2496 cricket::MediaSessionOptions options; |
2499 | 2497 |
2500 rtc::scoped_ptr<JsepSessionDescription> offer( | 2498 rtc::scoped_ptr<JsepSessionDescription> offer( |
2501 CreateRemoteOffer(options)); | 2499 CreateRemoteOffer(options)); |
2502 ASSERT_TRUE(cricket::GetFirstVideoContent(offer->description()) == NULL); | 2500 ASSERT_TRUE(cricket::GetFirstVideoContent(offer->description()) == NULL); |
2503 ASSERT_TRUE(cricket::GetFirstAudioContent(offer->description()) != NULL); | 2501 ASSERT_TRUE(cricket::GetFirstAudioContent(offer->description()) != NULL); |
2504 | 2502 |
2505 SetRemoteDescriptionWithoutError(offer.release()); | 2503 SetRemoteDescriptionWithoutError(offer.release()); |
2506 rtc::scoped_ptr<SessionDescriptionInterface> answer( | 2504 rtc::scoped_ptr<SessionDescriptionInterface> answer(CreateAnswer()); |
2507 CreateAnswer(NULL)); | |
2508 const cricket::ContentInfo* content = | 2505 const cricket::ContentInfo* content = |
2509 cricket::GetFirstAudioContent(answer->description()); | 2506 cricket::GetFirstAudioContent(answer->description()); |
2510 ASSERT_TRUE(content != NULL); | 2507 ASSERT_TRUE(content != NULL); |
2511 EXPECT_FALSE(content->rejected); | 2508 EXPECT_FALSE(content->rejected); |
2512 | 2509 |
2513 EXPECT_TRUE(cricket::GetFirstVideoContent(answer->description()) == NULL); | 2510 EXPECT_TRUE(cricket::GetFirstVideoContent(answer->description()) == NULL); |
2514 } | 2511 } |
2515 | 2512 |
2516 // Test that an answer contains the correct media content descriptions when no | 2513 // Test that an answer contains the correct media content descriptions when no |
2517 // constraints have been set. | 2514 // constraints have been set. |
2518 TEST_F(WebRtcSessionTest, CreateAnswerWithoutConstraints) { | 2515 TEST_F(WebRtcSessionTest, CreateAnswerWithoutConstraints) { |
2519 Init(); | 2516 Init(); |
2520 // Create a remote offer with audio and video content. | 2517 // Create a remote offer with audio and video content. |
2521 rtc::scoped_ptr<JsepSessionDescription> offer(CreateRemoteOffer()); | 2518 rtc::scoped_ptr<JsepSessionDescription> offer(CreateRemoteOffer()); |
2522 SetRemoteDescriptionWithoutError(offer.release()); | 2519 SetRemoteDescriptionWithoutError(offer.release()); |
2523 // Test with a stream with tracks. | 2520 // Test with a stream with tracks. |
2524 SendAudioVideoStream1(); | 2521 SendAudioVideoStream1(); |
2525 rtc::scoped_ptr<SessionDescriptionInterface> answer( | 2522 rtc::scoped_ptr<SessionDescriptionInterface> answer(CreateAnswer()); |
2526 CreateAnswer(NULL)); | |
2527 const cricket::ContentInfo* content = | 2523 const cricket::ContentInfo* content = |
2528 cricket::GetFirstAudioContent(answer->description()); | 2524 cricket::GetFirstAudioContent(answer->description()); |
2529 ASSERT_TRUE(content != NULL); | 2525 ASSERT_TRUE(content != NULL); |
2530 EXPECT_FALSE(content->rejected); | 2526 EXPECT_FALSE(content->rejected); |
2531 | 2527 |
2532 content = cricket::GetFirstVideoContent(answer->description()); | 2528 content = cricket::GetFirstVideoContent(answer->description()); |
2533 ASSERT_TRUE(content != NULL); | 2529 ASSERT_TRUE(content != NULL); |
2534 EXPECT_FALSE(content->rejected); | 2530 EXPECT_FALSE(content->rejected); |
2535 } | 2531 } |
2536 | 2532 |
2537 // Test that an answer contains the correct media content descriptions when | 2533 // Test that an answer contains the correct media content descriptions when |
2538 // constraints have been set but no stream is sent. | 2534 // constraints have been set but no stream is sent. |
2539 TEST_F(WebRtcSessionTest, CreateAnswerWithConstraintsWithoutStreams) { | 2535 TEST_F(WebRtcSessionTest, CreateAnswerWithConstraintsWithoutStreams) { |
2540 Init(); | 2536 Init(); |
2541 // Create a remote offer with audio and video content. | 2537 // Create a remote offer with audio and video content. |
2542 rtc::scoped_ptr<JsepSessionDescription> offer(CreateRemoteOffer()); | 2538 rtc::scoped_ptr<JsepSessionDescription> offer(CreateRemoteOffer()); |
2543 SetRemoteDescriptionWithoutError(offer.release()); | 2539 SetRemoteDescriptionWithoutError(offer.release()); |
2544 | 2540 |
2545 webrtc::FakeConstraints constraints_no_receive; | 2541 cricket::MediaSessionOptions session_options; |
2546 constraints_no_receive.SetMandatoryReceiveAudio(false); | 2542 session_options.recv_audio = false; |
2547 constraints_no_receive.SetMandatoryReceiveVideo(false); | 2543 session_options.recv_video = false; |
| 2544 rtc::scoped_ptr<SessionDescriptionInterface> answer( |
| 2545 CreateAnswer(session_options)); |
2548 | 2546 |
2549 rtc::scoped_ptr<SessionDescriptionInterface> answer( | |
2550 CreateAnswer(&constraints_no_receive)); | |
2551 const cricket::ContentInfo* content = | 2547 const cricket::ContentInfo* content = |
2552 cricket::GetFirstAudioContent(answer->description()); | 2548 cricket::GetFirstAudioContent(answer->description()); |
2553 ASSERT_TRUE(content != NULL); | 2549 ASSERT_TRUE(content != NULL); |
2554 EXPECT_TRUE(content->rejected); | 2550 EXPECT_TRUE(content->rejected); |
2555 | 2551 |
2556 content = cricket::GetFirstVideoContent(answer->description()); | 2552 content = cricket::GetFirstVideoContent(answer->description()); |
2557 ASSERT_TRUE(content != NULL); | 2553 ASSERT_TRUE(content != NULL); |
2558 EXPECT_TRUE(content->rejected); | 2554 EXPECT_TRUE(content->rejected); |
2559 } | 2555 } |
2560 | 2556 |
2561 // Test that an answer contains the correct media content descriptions when | 2557 // Test that an answer contains the correct media content descriptions when |
2562 // constraints have been set and streams are sent. | 2558 // constraints have been set and streams are sent. |
2563 TEST_F(WebRtcSessionTest, CreateAnswerWithConstraints) { | 2559 TEST_F(WebRtcSessionTest, CreateAnswerWithConstraints) { |
2564 Init(); | 2560 Init(); |
2565 // Create a remote offer with audio and video content. | 2561 // Create a remote offer with audio and video content. |
2566 rtc::scoped_ptr<JsepSessionDescription> offer(CreateRemoteOffer()); | 2562 rtc::scoped_ptr<JsepSessionDescription> offer(CreateRemoteOffer()); |
2567 SetRemoteDescriptionWithoutError(offer.release()); | 2563 SetRemoteDescriptionWithoutError(offer.release()); |
2568 | 2564 |
2569 webrtc::FakeConstraints constraints_no_receive; | 2565 cricket::MediaSessionOptions options; |
2570 constraints_no_receive.SetMandatoryReceiveAudio(false); | 2566 options.recv_audio = false; |
2571 constraints_no_receive.SetMandatoryReceiveVideo(false); | 2567 options.recv_video = false; |
2572 | 2568 |
2573 // Test with a stream with tracks. | 2569 // Test with a stream with tracks. |
2574 SendAudioVideoStream1(); | 2570 SendAudioVideoStream1(); |
2575 rtc::scoped_ptr<SessionDescriptionInterface> answer( | 2571 rtc::scoped_ptr<SessionDescriptionInterface> answer(CreateAnswer(options)); |
2576 CreateAnswer(&constraints_no_receive)); | |
2577 | 2572 |
2578 // TODO(perkj): Should the direction be set to SEND_ONLY? | 2573 // TODO(perkj): Should the direction be set to SEND_ONLY? |
2579 const cricket::ContentInfo* content = | 2574 const cricket::ContentInfo* content = |
2580 cricket::GetFirstAudioContent(answer->description()); | 2575 cricket::GetFirstAudioContent(answer->description()); |
2581 ASSERT_TRUE(content != NULL); | 2576 ASSERT_TRUE(content != NULL); |
2582 EXPECT_FALSE(content->rejected); | 2577 EXPECT_FALSE(content->rejected); |
2583 | 2578 |
2584 // TODO(perkj): Should the direction be set to SEND_ONLY? | 2579 // TODO(perkj): Should the direction be set to SEND_ONLY? |
2585 content = cricket::GetFirstVideoContent(answer->description()); | 2580 content = cricket::GetFirstVideoContent(answer->description()); |
2586 ASSERT_TRUE(content != NULL); | 2581 ASSERT_TRUE(content != NULL); |
(...skipping 17 matching lines...) Loading... |
2604 EXPECT_TRUE(VerifyNoCNCodecs(content)); | 2599 EXPECT_TRUE(VerifyNoCNCodecs(content)); |
2605 } | 2600 } |
2606 | 2601 |
2607 TEST_F(WebRtcSessionTest, CreateAnswerWithoutCNCodecs) { | 2602 TEST_F(WebRtcSessionTest, CreateAnswerWithoutCNCodecs) { |
2608 AddCNCodecs(); | 2603 AddCNCodecs(); |
2609 Init(); | 2604 Init(); |
2610 // Create a remote offer with audio and video content. | 2605 // Create a remote offer with audio and video content. |
2611 rtc::scoped_ptr<JsepSessionDescription> offer(CreateRemoteOffer()); | 2606 rtc::scoped_ptr<JsepSessionDescription> offer(CreateRemoteOffer()); |
2612 SetRemoteDescriptionWithoutError(offer.release()); | 2607 SetRemoteDescriptionWithoutError(offer.release()); |
2613 | 2608 |
2614 webrtc::FakeConstraints constraints; | 2609 cricket::MediaSessionOptions options; |
2615 constraints.SetOptionalVAD(false); | 2610 options.vad_enabled = false; |
2616 rtc::scoped_ptr<SessionDescriptionInterface> answer( | 2611 rtc::scoped_ptr<SessionDescriptionInterface> answer(CreateAnswer(options)); |
2617 CreateAnswer(&constraints)); | |
2618 const cricket::ContentInfo* content = | 2612 const cricket::ContentInfo* content = |
2619 cricket::GetFirstAudioContent(answer->description()); | 2613 cricket::GetFirstAudioContent(answer->description()); |
2620 ASSERT_TRUE(content != NULL); | 2614 ASSERT_TRUE(content != NULL); |
2621 EXPECT_TRUE(VerifyNoCNCodecs(content)); | 2615 EXPECT_TRUE(VerifyNoCNCodecs(content)); |
2622 } | 2616 } |
2623 | 2617 |
2624 // This test verifies the call setup when remote answer with audio only and | 2618 // This test verifies the call setup when remote answer with audio only and |
2625 // later updates with video. | 2619 // later updates with video. |
2626 TEST_F(WebRtcSessionTest, TestAVOfferWithAudioOnlyAnswer) { | 2620 TEST_F(WebRtcSessionTest, TestAVOfferWithAudioOnlyAnswer) { |
2627 Init(); | 2621 Init(); |
(...skipping 104 matching lines...) Loading... |
2732 ASSERT_EQ(1u, video_channel_->send_streams().size()); | 2726 ASSERT_EQ(1u, video_channel_->send_streams().size()); |
2733 EXPECT_EQ(kVideoTrack2, video_channel_->send_streams()[0].id); | 2727 EXPECT_EQ(kVideoTrack2, video_channel_->send_streams()[0].id); |
2734 } | 2728 } |
2735 | 2729 |
2736 TEST_F(WebRtcSessionTest, VerifyCryptoParamsInSDP) { | 2730 TEST_F(WebRtcSessionTest, VerifyCryptoParamsInSDP) { |
2737 Init(); | 2731 Init(); |
2738 SendAudioVideoStream1(); | 2732 SendAudioVideoStream1(); |
2739 scoped_ptr<SessionDescriptionInterface> offer(CreateOffer()); | 2733 scoped_ptr<SessionDescriptionInterface> offer(CreateOffer()); |
2740 VerifyCryptoParams(offer->description()); | 2734 VerifyCryptoParams(offer->description()); |
2741 SetRemoteDescriptionWithoutError(offer.release()); | 2735 SetRemoteDescriptionWithoutError(offer.release()); |
2742 scoped_ptr<SessionDescriptionInterface> answer(CreateAnswer(NULL)); | 2736 scoped_ptr<SessionDescriptionInterface> answer(CreateAnswer()); |
2743 VerifyCryptoParams(answer->description()); | 2737 VerifyCryptoParams(answer->description()); |
2744 } | 2738 } |
2745 | 2739 |
2746 TEST_F(WebRtcSessionTest, VerifyNoCryptoParamsInSDP) { | 2740 TEST_F(WebRtcSessionTest, VerifyNoCryptoParamsInSDP) { |
2747 options_.disable_encryption = true; | 2741 options_.disable_encryption = true; |
2748 Init(); | 2742 Init(); |
2749 SendAudioVideoStream1(); | 2743 SendAudioVideoStream1(); |
2750 scoped_ptr<SessionDescriptionInterface> offer(CreateOffer()); | 2744 scoped_ptr<SessionDescriptionInterface> offer(CreateOffer()); |
2751 VerifyNoCryptoParams(offer->description(), false); | 2745 VerifyNoCryptoParams(offer->description(), false); |
2752 } | 2746 } |
(...skipping 167 matching lines...) Loading... |
2920 | 2914 |
2921 InitWithBundlePolicy(PeerConnectionInterface::kBundlePolicyBalanced); | 2915 InitWithBundlePolicy(PeerConnectionInterface::kBundlePolicyBalanced); |
2922 SendAudioVideoStream1(); | 2916 SendAudioVideoStream1(); |
2923 | 2917 |
2924 PeerConnectionInterface::RTCOfferAnswerOptions options; | 2918 PeerConnectionInterface::RTCOfferAnswerOptions options; |
2925 options.use_rtp_mux = true; | 2919 options.use_rtp_mux = true; |
2926 | 2920 |
2927 SessionDescriptionInterface* offer = CreateRemoteOffer(); | 2921 SessionDescriptionInterface* offer = CreateRemoteOffer(); |
2928 SetRemoteDescriptionWithoutError(offer); | 2922 SetRemoteDescriptionWithoutError(offer); |
2929 | 2923 |
2930 SessionDescriptionInterface* answer = CreateAnswer(NULL); | 2924 SessionDescriptionInterface* answer = CreateAnswer(); |
2931 SetLocalDescriptionWithoutError(answer); | 2925 SetLocalDescriptionWithoutError(answer); |
2932 | 2926 |
2933 EXPECT_EQ(session_->voice_rtp_transport_channel(), | 2927 EXPECT_EQ(session_->voice_rtp_transport_channel(), |
2934 session_->video_rtp_transport_channel()); | 2928 session_->video_rtp_transport_channel()); |
2935 | 2929 |
2936 cricket::BaseChannel* voice_channel = session_->voice_channel(); | 2930 cricket::BaseChannel* voice_channel = session_->voice_channel(); |
2937 ASSERT(voice_channel != NULL); | 2931 ASSERT(voice_channel != NULL); |
2938 | 2932 |
2939 // Checks if one of the transport channels contains a connection using a given | 2933 // Checks if one of the transport channels contains a connection using a given |
2940 // port. | 2934 // port. |
(...skipping 202 matching lines...) Loading... |
3143 InitWithBundlePolicy(PeerConnectionInterface::kBundlePolicyMaxBundle); | 3137 InitWithBundlePolicy(PeerConnectionInterface::kBundlePolicyMaxBundle); |
3144 SendAudioVideoStream1(); | 3138 SendAudioVideoStream1(); |
3145 | 3139 |
3146 SessionDescriptionInterface* offer = CreateRemoteOffer(); | 3140 SessionDescriptionInterface* offer = CreateRemoteOffer(); |
3147 SetRemoteDescriptionWithoutError(offer); | 3141 SetRemoteDescriptionWithoutError(offer); |
3148 | 3142 |
3149 EXPECT_EQ(session_->voice_rtp_transport_channel(), | 3143 EXPECT_EQ(session_->voice_rtp_transport_channel(), |
3150 session_->video_rtp_transport_channel()); | 3144 session_->video_rtp_transport_channel()); |
3151 | 3145 |
3152 SendAudioVideoStream2(); | 3146 SendAudioVideoStream2(); |
3153 SessionDescriptionInterface* answer = CreateAnswer(nullptr); | 3147 SessionDescriptionInterface* answer = CreateAnswer(); |
3154 SetLocalDescriptionWithoutError(answer); | 3148 SetLocalDescriptionWithoutError(answer); |
3155 | 3149 |
3156 EXPECT_EQ(session_->voice_rtp_transport_channel(), | 3150 EXPECT_EQ(session_->voice_rtp_transport_channel(), |
3157 session_->video_rtp_transport_channel()); | 3151 session_->video_rtp_transport_channel()); |
3158 } | 3152 } |
3159 | 3153 |
3160 // kBundlePolicyMaxBundle policy but no BUNDLE in the remote offer. | 3154 // kBundlePolicyMaxBundle policy but no BUNDLE in the remote offer. |
3161 TEST_F(WebRtcSessionTest, TestMaxBundleNoBundleInRemoteOffer) { | 3155 TEST_F(WebRtcSessionTest, TestMaxBundleNoBundleInRemoteOffer) { |
3162 InitWithBundlePolicy(PeerConnectionInterface::kBundlePolicyMaxBundle); | 3156 InitWithBundlePolicy(PeerConnectionInterface::kBundlePolicyMaxBundle); |
3163 SendAudioVideoStream1(); | 3157 SendAudioVideoStream1(); |
(...skipping 296 matching lines...) Loading... |
3460 SetRemoteDescriptionWithoutError(answer); | 3454 SetRemoteDescriptionWithoutError(answer); |
3461 EXPECT_TRUE(session_->initial_offerer()); | 3455 EXPECT_TRUE(session_->initial_offerer()); |
3462 } | 3456 } |
3463 | 3457 |
3464 // This test verifies the |initial_offerer| flag when session receives the call. | 3458 // This test verifies the |initial_offerer| flag when session receives the call. |
3465 TEST_F(WebRtcSessionTest, TestInitiatorFlagAsReceiver) { | 3459 TEST_F(WebRtcSessionTest, TestInitiatorFlagAsReceiver) { |
3466 Init(); | 3460 Init(); |
3467 EXPECT_FALSE(session_->initial_offerer()); | 3461 EXPECT_FALSE(session_->initial_offerer()); |
3468 SessionDescriptionInterface* offer = CreateRemoteOffer(); | 3462 SessionDescriptionInterface* offer = CreateRemoteOffer(); |
3469 SetRemoteDescriptionWithoutError(offer); | 3463 SetRemoteDescriptionWithoutError(offer); |
3470 SessionDescriptionInterface* answer = CreateAnswer(NULL); | 3464 SessionDescriptionInterface* answer = CreateAnswer(); |
3471 | 3465 |
3472 EXPECT_FALSE(session_->initial_offerer()); | 3466 EXPECT_FALSE(session_->initial_offerer()); |
3473 SetLocalDescriptionWithoutError(answer); | 3467 SetLocalDescriptionWithoutError(answer); |
3474 EXPECT_FALSE(session_->initial_offerer()); | 3468 EXPECT_FALSE(session_->initial_offerer()); |
3475 } | 3469 } |
3476 | 3470 |
3477 // Verifing local offer and remote answer have matching m-lines as per RFC 3264. | 3471 // Verifing local offer and remote answer have matching m-lines as per RFC 3264. |
3478 TEST_F(WebRtcSessionTest, TestIncorrectMLinesInRemoteAnswer) { | 3472 TEST_F(WebRtcSessionTest, TestIncorrectMLinesInRemoteAnswer) { |
3479 Init(); | 3473 Init(); |
3480 SendAudioVideoStream1(); | 3474 SendAudioVideoStream1(); |
(...skipping 40 matching lines...) Loading... |
3521 SetRemoteDescriptionWithoutError(answer.release()); | 3515 SetRemoteDescriptionWithoutError(answer.release()); |
3522 } | 3516 } |
3523 | 3517 |
3524 // Verifying remote offer and local answer have matching m-lines as per | 3518 // Verifying remote offer and local answer have matching m-lines as per |
3525 // RFC 3264. | 3519 // RFC 3264. |
3526 TEST_F(WebRtcSessionTest, TestIncorrectMLinesInLocalAnswer) { | 3520 TEST_F(WebRtcSessionTest, TestIncorrectMLinesInLocalAnswer) { |
3527 Init(); | 3521 Init(); |
3528 SendAudioVideoStream1(); | 3522 SendAudioVideoStream1(); |
3529 SessionDescriptionInterface* offer = CreateRemoteOffer(); | 3523 SessionDescriptionInterface* offer = CreateRemoteOffer(); |
3530 SetRemoteDescriptionWithoutError(offer); | 3524 SetRemoteDescriptionWithoutError(offer); |
3531 SessionDescriptionInterface* answer = CreateAnswer(NULL); | 3525 SessionDescriptionInterface* answer = CreateAnswer(); |
3532 | 3526 |
3533 cricket::SessionDescription* answer_copy = answer->description()->Copy(); | 3527 cricket::SessionDescription* answer_copy = answer->description()->Copy(); |
3534 answer_copy->RemoveContentByName("video"); | 3528 answer_copy->RemoveContentByName("video"); |
3535 JsepSessionDescription* modified_answer = | 3529 JsepSessionDescription* modified_answer = |
3536 new JsepSessionDescription(JsepSessionDescription::kAnswer); | 3530 new JsepSessionDescription(JsepSessionDescription::kAnswer); |
3537 | 3531 |
3538 EXPECT_TRUE(modified_answer->Initialize(answer_copy, | 3532 EXPECT_TRUE(modified_answer->Initialize(answer_copy, |
3539 answer->session_id(), | 3533 answer->session_id(), |
3540 answer->session_version())); | 3534 answer->session_version())); |
3541 SetLocalDescriptionAnswerExpectError(kMlineMismatch, modified_answer); | 3535 SetLocalDescriptionAnswerExpectError(kMlineMismatch, modified_answer); |
(...skipping 18 matching lines...) Loading... |
3560 EXPECT_TRUE(offer->AddCandidate(&ice_candidate1)); | 3554 EXPECT_TRUE(offer->AddCandidate(&ice_candidate1)); |
3561 SetRemoteDescriptionWithoutError(offer); | 3555 SetRemoteDescriptionWithoutError(offer); |
3562 ASSERT_TRUE(session_->voice_rtp_transport_channel() != NULL); | 3556 ASSERT_TRUE(session_->voice_rtp_transport_channel() != NULL); |
3563 ASSERT_TRUE(session_->video_rtp_transport_channel() != NULL); | 3557 ASSERT_TRUE(session_->video_rtp_transport_channel() != NULL); |
3564 | 3558 |
3565 // Pump for 1 second and verify that no candidates are generated. | 3559 // Pump for 1 second and verify that no candidates are generated. |
3566 rtc::Thread::Current()->ProcessMessages(1000); | 3560 rtc::Thread::Current()->ProcessMessages(1000); |
3567 EXPECT_TRUE(observer_.mline_0_candidates_.empty()); | 3561 EXPECT_TRUE(observer_.mline_0_candidates_.empty()); |
3568 EXPECT_TRUE(observer_.mline_1_candidates_.empty()); | 3562 EXPECT_TRUE(observer_.mline_1_candidates_.empty()); |
3569 | 3563 |
3570 SessionDescriptionInterface* answer = CreateAnswer(NULL); | 3564 SessionDescriptionInterface* answer = CreateAnswer(); |
3571 SetLocalDescriptionWithoutError(answer); | 3565 SetLocalDescriptionWithoutError(answer); |
3572 EXPECT_TRUE_WAIT(observer_.oncandidatesready_, kIceCandidatesTimeout); | 3566 EXPECT_TRUE_WAIT(observer_.oncandidatesready_, kIceCandidatesTimeout); |
3573 } | 3567 } |
3574 | 3568 |
3575 // This test verifies that crypto parameter is updated in local session | 3569 // This test verifies that crypto parameter is updated in local session |
3576 // description as per security policy set in MediaSessionDescriptionFactory. | 3570 // description as per security policy set in MediaSessionDescriptionFactory. |
3577 TEST_F(WebRtcSessionTest, TestCryptoAfterSetLocalDescription) { | 3571 TEST_F(WebRtcSessionTest, TestCryptoAfterSetLocalDescription) { |
3578 Init(); | 3572 Init(); |
3579 SendAudioVideoStream1(); | 3573 SendAudioVideoStream1(); |
3580 rtc::scoped_ptr<SessionDescriptionInterface> offer(CreateOffer()); | 3574 rtc::scoped_ptr<SessionDescriptionInterface> offer(CreateOffer()); |
(...skipping 33 matching lines...) Loading... |
3614 // with new ufrag and password is received. | 3608 // with new ufrag and password is received. |
3615 TEST_F(WebRtcSessionTest, TestCreateAnswerWithNewUfragAndPassword) { | 3609 TEST_F(WebRtcSessionTest, TestCreateAnswerWithNewUfragAndPassword) { |
3616 Init(); | 3610 Init(); |
3617 cricket::MediaSessionOptions options; | 3611 cricket::MediaSessionOptions options; |
3618 options.recv_video = true; | 3612 options.recv_video = true; |
3619 rtc::scoped_ptr<JsepSessionDescription> offer( | 3613 rtc::scoped_ptr<JsepSessionDescription> offer( |
3620 CreateRemoteOffer(options)); | 3614 CreateRemoteOffer(options)); |
3621 SetRemoteDescriptionWithoutError(offer.release()); | 3615 SetRemoteDescriptionWithoutError(offer.release()); |
3622 | 3616 |
3623 SendAudioVideoStream1(); | 3617 SendAudioVideoStream1(); |
3624 rtc::scoped_ptr<SessionDescriptionInterface> answer( | 3618 rtc::scoped_ptr<SessionDescriptionInterface> answer(CreateAnswer()); |
3625 CreateAnswer(NULL)); | |
3626 SetLocalDescriptionWithoutError(answer.release()); | 3619 SetLocalDescriptionWithoutError(answer.release()); |
3627 | 3620 |
3628 // Receive an offer with new ufrag and password. | 3621 // Receive an offer with new ufrag and password. |
3629 for (const cricket::ContentInfo& content : | 3622 for (const cricket::ContentInfo& content : |
3630 session_->local_description()->description()->contents()) { | 3623 session_->local_description()->description()->contents()) { |
3631 options.transport_options[content.name].ice_restart = true; | 3624 options.transport_options[content.name].ice_restart = true; |
3632 } | 3625 } |
3633 rtc::scoped_ptr<JsepSessionDescription> updated_offer1( | 3626 rtc::scoped_ptr<JsepSessionDescription> updated_offer1( |
3634 CreateRemoteOffer(options, session_->remote_description())); | 3627 CreateRemoteOffer(options, session_->remote_description())); |
3635 SetRemoteDescriptionWithoutError(updated_offer1.release()); | 3628 SetRemoteDescriptionWithoutError(updated_offer1.release()); |
3636 | 3629 |
3637 rtc::scoped_ptr<SessionDescriptionInterface> updated_answer1( | 3630 rtc::scoped_ptr<SessionDescriptionInterface> updated_answer1(CreateAnswer()); |
3638 CreateAnswer(NULL)); | |
3639 | 3631 |
3640 EXPECT_FALSE(IceUfragPwdEqual(updated_answer1->description(), | 3632 EXPECT_FALSE(IceUfragPwdEqual(updated_answer1->description(), |
3641 session_->local_description()->description())); | 3633 session_->local_description()->description())); |
3642 | 3634 |
3643 // Even a second answer (created before the description is set) should have | 3635 // Even a second answer (created before the description is set) should have |
3644 // a new ufrag/password. | 3636 // a new ufrag/password. |
3645 rtc::scoped_ptr<SessionDescriptionInterface> updated_answer2( | 3637 rtc::scoped_ptr<SessionDescriptionInterface> updated_answer2(CreateAnswer()); |
3646 CreateAnswer(NULL)); | |
3647 | 3638 |
3648 EXPECT_FALSE(IceUfragPwdEqual(updated_answer2->description(), | 3639 EXPECT_FALSE(IceUfragPwdEqual(updated_answer2->description(), |
3649 session_->local_description()->description())); | 3640 session_->local_description()->description())); |
3650 | 3641 |
3651 SetLocalDescriptionWithoutError(updated_answer2.release()); | 3642 SetLocalDescriptionWithoutError(updated_answer2.release()); |
3652 } | 3643 } |
3653 | 3644 |
3654 // This test verifies that an answer contains new ufrag and password if an offer | 3645 // This test verifies that an answer contains new ufrag and password if an offer |
3655 // that changes either the ufrag or password (but not both) is received. | 3646 // that changes either the ufrag or password (but not both) is received. |
3656 // RFC 5245 says: "If the offer contained a change in the a=ice-ufrag or | 3647 // RFC 5245 says: "If the offer contained a change in the a=ice-ufrag or |
3657 // a=ice-pwd attributes compared to the previous SDP from the peer, it | 3648 // a=ice-pwd attributes compared to the previous SDP from the peer, it |
3658 // indicates that ICE is restarting for this media stream." | 3649 // indicates that ICE is restarting for this media stream." |
3659 TEST_F(WebRtcSessionTest, TestOfferChangingOnlyUfragOrPassword) { | 3650 TEST_F(WebRtcSessionTest, TestOfferChangingOnlyUfragOrPassword) { |
3660 Init(); | 3651 Init(); |
3661 cricket::MediaSessionOptions options; | 3652 cricket::MediaSessionOptions options; |
3662 options.recv_audio = true; | 3653 options.recv_audio = true; |
3663 options.recv_video = true; | 3654 options.recv_video = true; |
3664 // Create an offer with audio and video. | 3655 // Create an offer with audio and video. |
3665 rtc::scoped_ptr<JsepSessionDescription> offer(CreateRemoteOffer(options)); | 3656 rtc::scoped_ptr<JsepSessionDescription> offer(CreateRemoteOffer(options)); |
3666 SetIceUfragPwd(offer.get(), "original_ufrag", "original_password12345"); | 3657 SetIceUfragPwd(offer.get(), "original_ufrag", "original_password12345"); |
3667 SetRemoteDescriptionWithoutError(offer.release()); | 3658 SetRemoteDescriptionWithoutError(offer.release()); |
3668 | 3659 |
3669 SendAudioVideoStream1(); | 3660 SendAudioVideoStream1(); |
3670 rtc::scoped_ptr<SessionDescriptionInterface> answer(CreateAnswer(nullptr)); | 3661 rtc::scoped_ptr<SessionDescriptionInterface> answer(CreateAnswer()); |
3671 SetLocalDescriptionWithoutError(answer.release()); | 3662 SetLocalDescriptionWithoutError(answer.release()); |
3672 | 3663 |
3673 // Receive an offer with a new ufrag but stale password. | 3664 // Receive an offer with a new ufrag but stale password. |
3674 rtc::scoped_ptr<JsepSessionDescription> ufrag_changed_offer( | 3665 rtc::scoped_ptr<JsepSessionDescription> ufrag_changed_offer( |
3675 CreateRemoteOffer(options, session_->remote_description())); | 3666 CreateRemoteOffer(options, session_->remote_description())); |
3676 SetIceUfragPwd(ufrag_changed_offer.get(), "modified_ufrag", | 3667 SetIceUfragPwd(ufrag_changed_offer.get(), "modified_ufrag", |
3677 "original_password12345"); | 3668 "original_password12345"); |
3678 SetRemoteDescriptionWithoutError(ufrag_changed_offer.release()); | 3669 SetRemoteDescriptionWithoutError(ufrag_changed_offer.release()); |
3679 | 3670 |
3680 rtc::scoped_ptr<SessionDescriptionInterface> updated_answer1( | 3671 rtc::scoped_ptr<SessionDescriptionInterface> updated_answer1(CreateAnswer()); |
3681 CreateAnswer(nullptr)); | |
3682 EXPECT_FALSE(IceUfragPwdEqual(updated_answer1->description(), | 3672 EXPECT_FALSE(IceUfragPwdEqual(updated_answer1->description(), |
3683 session_->local_description()->description())); | 3673 session_->local_description()->description())); |
3684 SetLocalDescriptionWithoutError(updated_answer1.release()); | 3674 SetLocalDescriptionWithoutError(updated_answer1.release()); |
3685 | 3675 |
3686 // Receive an offer with a new password but stale ufrag. | 3676 // Receive an offer with a new password but stale ufrag. |
3687 rtc::scoped_ptr<JsepSessionDescription> password_changed_offer( | 3677 rtc::scoped_ptr<JsepSessionDescription> password_changed_offer( |
3688 CreateRemoteOffer(options, session_->remote_description())); | 3678 CreateRemoteOffer(options, session_->remote_description())); |
3689 SetIceUfragPwd(password_changed_offer.get(), "modified_ufrag", | 3679 SetIceUfragPwd(password_changed_offer.get(), "modified_ufrag", |
3690 "modified_password12345"); | 3680 "modified_password12345"); |
3691 SetRemoteDescriptionWithoutError(password_changed_offer.release()); | 3681 SetRemoteDescriptionWithoutError(password_changed_offer.release()); |
3692 | 3682 |
3693 rtc::scoped_ptr<SessionDescriptionInterface> updated_answer2( | 3683 rtc::scoped_ptr<SessionDescriptionInterface> updated_answer2(CreateAnswer()); |
3694 CreateAnswer(nullptr)); | |
3695 EXPECT_FALSE(IceUfragPwdEqual(updated_answer2->description(), | 3684 EXPECT_FALSE(IceUfragPwdEqual(updated_answer2->description(), |
3696 session_->local_description()->description())); | 3685 session_->local_description()->description())); |
3697 SetLocalDescriptionWithoutError(updated_answer2.release()); | 3686 SetLocalDescriptionWithoutError(updated_answer2.release()); |
3698 } | 3687 } |
3699 | 3688 |
3700 // This test verifies that an answer contains old ufrag and password if an offer | 3689 // This test verifies that an answer contains old ufrag and password if an offer |
3701 // with old ufrag and password is received. | 3690 // with old ufrag and password is received. |
3702 TEST_F(WebRtcSessionTest, TestCreateAnswerWithOldUfragAndPassword) { | 3691 TEST_F(WebRtcSessionTest, TestCreateAnswerWithOldUfragAndPassword) { |
3703 Init(); | 3692 Init(); |
3704 cricket::MediaSessionOptions options; | 3693 cricket::MediaSessionOptions options; |
3705 options.recv_video = true; | 3694 options.recv_video = true; |
3706 rtc::scoped_ptr<JsepSessionDescription> offer( | 3695 rtc::scoped_ptr<JsepSessionDescription> offer( |
3707 CreateRemoteOffer(options)); | 3696 CreateRemoteOffer(options)); |
3708 SetRemoteDescriptionWithoutError(offer.release()); | 3697 SetRemoteDescriptionWithoutError(offer.release()); |
3709 | 3698 |
3710 SendAudioVideoStream1(); | 3699 SendAudioVideoStream1(); |
3711 rtc::scoped_ptr<SessionDescriptionInterface> answer( | 3700 rtc::scoped_ptr<SessionDescriptionInterface> answer(CreateAnswer()); |
3712 CreateAnswer(NULL)); | |
3713 SetLocalDescriptionWithoutError(answer.release()); | 3701 SetLocalDescriptionWithoutError(answer.release()); |
3714 | 3702 |
3715 // Receive an offer without changed ufrag or password. | 3703 // Receive an offer without changed ufrag or password. |
3716 rtc::scoped_ptr<JsepSessionDescription> updated_offer2( | 3704 rtc::scoped_ptr<JsepSessionDescription> updated_offer2( |
3717 CreateRemoteOffer(options, session_->remote_description())); | 3705 CreateRemoteOffer(options, session_->remote_description())); |
3718 SetRemoteDescriptionWithoutError(updated_offer2.release()); | 3706 SetRemoteDescriptionWithoutError(updated_offer2.release()); |
3719 | 3707 |
3720 rtc::scoped_ptr<SessionDescriptionInterface> updated_answer2( | 3708 rtc::scoped_ptr<SessionDescriptionInterface> updated_answer2(CreateAnswer()); |
3721 CreateAnswer(NULL)); | |
3722 | 3709 |
3723 EXPECT_TRUE(IceUfragPwdEqual(updated_answer2->description(), | 3710 EXPECT_TRUE(IceUfragPwdEqual(updated_answer2->description(), |
3724 session_->local_description()->description())); | 3711 session_->local_description()->description())); |
3725 | 3712 |
3726 SetLocalDescriptionWithoutError(updated_answer2.release()); | 3713 SetLocalDescriptionWithoutError(updated_answer2.release()); |
3727 } | 3714 } |
3728 | 3715 |
3729 // This test verifies that if an offer does an ICE restart on some, but not all | 3716 // This test verifies that if an offer does an ICE restart on some, but not all |
3730 // media sections, the answer will change the ufrag/password in the correct | 3717 // media sections, the answer will change the ufrag/password in the correct |
3731 // media sections. | 3718 // media sections. |
3732 TEST_F(WebRtcSessionTest, TestCreateAnswerWithNewAndOldUfragAndPassword) { | 3719 TEST_F(WebRtcSessionTest, TestCreateAnswerWithNewAndOldUfragAndPassword) { |
3733 Init(); | 3720 Init(); |
3734 cricket::MediaSessionOptions options; | 3721 cricket::MediaSessionOptions options; |
3735 options.recv_video = true; | 3722 options.recv_video = true; |
3736 options.recv_audio = true; | 3723 options.recv_audio = true; |
3737 options.bundle_enabled = false; | 3724 options.bundle_enabled = false; |
3738 rtc::scoped_ptr<JsepSessionDescription> offer(CreateRemoteOffer(options)); | 3725 rtc::scoped_ptr<JsepSessionDescription> offer(CreateRemoteOffer(options)); |
3739 | 3726 |
3740 SetIceUfragPwd(offer.get(), cricket::MEDIA_TYPE_AUDIO, "aaaa", | 3727 SetIceUfragPwd(offer.get(), cricket::MEDIA_TYPE_AUDIO, "aaaa", |
3741 "aaaaaaaaaaaaaaaaaaaaaa"); | 3728 "aaaaaaaaaaaaaaaaaaaaaa"); |
3742 SetIceUfragPwd(offer.get(), cricket::MEDIA_TYPE_VIDEO, "bbbb", | 3729 SetIceUfragPwd(offer.get(), cricket::MEDIA_TYPE_VIDEO, "bbbb", |
3743 "bbbbbbbbbbbbbbbbbbbbbb"); | 3730 "bbbbbbbbbbbbbbbbbbbbbb"); |
3744 SetRemoteDescriptionWithoutError(offer.release()); | 3731 SetRemoteDescriptionWithoutError(offer.release()); |
3745 | 3732 |
3746 SendAudioVideoStream1(); | 3733 SendAudioVideoStream1(); |
3747 rtc::scoped_ptr<SessionDescriptionInterface> answer(CreateAnswer(nullptr)); | 3734 rtc::scoped_ptr<SessionDescriptionInterface> answer(CreateAnswer()); |
3748 SetLocalDescriptionWithoutError(answer.release()); | 3735 SetLocalDescriptionWithoutError(answer.release()); |
3749 | 3736 |
3750 // Receive an offer with new ufrag and password, but only for the video media | 3737 // Receive an offer with new ufrag and password, but only for the video media |
3751 // section. | 3738 // section. |
3752 rtc::scoped_ptr<JsepSessionDescription> updated_offer( | 3739 rtc::scoped_ptr<JsepSessionDescription> updated_offer( |
3753 CreateRemoteOffer(options, session_->remote_description())); | 3740 CreateRemoteOffer(options, session_->remote_description())); |
3754 SetIceUfragPwd(updated_offer.get(), cricket::MEDIA_TYPE_VIDEO, "cccc", | 3741 SetIceUfragPwd(updated_offer.get(), cricket::MEDIA_TYPE_VIDEO, "cccc", |
3755 "cccccccccccccccccccccc"); | 3742 "cccccccccccccccccccccc"); |
3756 SetRemoteDescriptionWithoutError(updated_offer.release()); | 3743 SetRemoteDescriptionWithoutError(updated_offer.release()); |
3757 | 3744 |
3758 rtc::scoped_ptr<SessionDescriptionInterface> updated_answer( | 3745 rtc::scoped_ptr<SessionDescriptionInterface> updated_answer(CreateAnswer()); |
3759 CreateAnswer(nullptr)); | |
3760 | 3746 |
3761 EXPECT_TRUE(IceUfragPwdEqual(updated_answer->description(), | 3747 EXPECT_TRUE(IceUfragPwdEqual(updated_answer->description(), |
3762 session_->local_description()->description(), | 3748 session_->local_description()->description(), |
3763 cricket::MEDIA_TYPE_AUDIO)); | 3749 cricket::MEDIA_TYPE_AUDIO)); |
3764 | 3750 |
3765 EXPECT_FALSE(IceUfragPwdEqual(updated_answer->description(), | 3751 EXPECT_FALSE(IceUfragPwdEqual(updated_answer->description(), |
3766 session_->local_description()->description(), | 3752 session_->local_description()->description(), |
3767 cricket::MEDIA_TYPE_VIDEO)); | 3753 cricket::MEDIA_TYPE_VIDEO)); |
3768 | 3754 |
3769 SetLocalDescriptionWithoutError(updated_answer.release()); | 3755 SetLocalDescriptionWithoutError(updated_answer.release()); |
(...skipping 48 matching lines...) Loading... |
3818 } | 3804 } |
3819 | 3805 |
3820 // Runs the loopback call test with BUNDLE and STUN enabled. | 3806 // Runs the loopback call test with BUNDLE and STUN enabled. |
3821 TEST_F(WebRtcSessionTest, TestIceStatesBundle) { | 3807 TEST_F(WebRtcSessionTest, TestIceStatesBundle) { |
3822 allocator_->set_flags(cricket::PORTALLOCATOR_DISABLE_TCP | | 3808 allocator_->set_flags(cricket::PORTALLOCATOR_DISABLE_TCP | |
3823 cricket::PORTALLOCATOR_DISABLE_RELAY); | 3809 cricket::PORTALLOCATOR_DISABLE_RELAY); |
3824 TestLoopbackCall(); | 3810 TestLoopbackCall(); |
3825 } | 3811 } |
3826 | 3812 |
3827 TEST_F(WebRtcSessionTest, TestRtpDataChannel) { | 3813 TEST_F(WebRtcSessionTest, TestRtpDataChannel) { |
3828 constraints_.reset(new FakeConstraints()); | 3814 configuration_.enable_rtp_data_channel = true; |
3829 constraints_->AddOptional( | |
3830 webrtc::MediaConstraintsInterface::kEnableRtpDataChannels, true); | |
3831 Init(); | 3815 Init(); |
3832 | |
3833 SetLocalDescriptionWithDataChannel(); | 3816 SetLocalDescriptionWithDataChannel(); |
| 3817 ASSERT_TRUE(data_engine_); |
3834 EXPECT_EQ(cricket::DCT_RTP, data_engine_->last_channel_type()); | 3818 EXPECT_EQ(cricket::DCT_RTP, data_engine_->last_channel_type()); |
3835 } | 3819 } |
3836 | 3820 |
3837 TEST_P(WebRtcSessionTest, TestRtpDataChannelConstraintTakesPrecedence) { | 3821 TEST_P(WebRtcSessionTest, TestRtpDataChannelConstraintTakesPrecedence) { |
3838 MAYBE_SKIP_TEST(rtc::SSLStreamAdapter::HaveDtlsSrtp); | 3822 MAYBE_SKIP_TEST(rtc::SSLStreamAdapter::HaveDtlsSrtp); |
3839 | 3823 |
3840 constraints_.reset(new FakeConstraints()); | 3824 configuration_.enable_rtp_data_channel = true; |
3841 constraints_->AddOptional( | |
3842 webrtc::MediaConstraintsInterface::kEnableRtpDataChannels, true); | |
3843 options_.disable_sctp_data_channels = false; | 3825 options_.disable_sctp_data_channels = false; |
3844 | 3826 |
3845 InitWithDtls(GetParam()); | 3827 InitWithDtls(GetParam()); |
3846 | 3828 |
3847 SetLocalDescriptionWithDataChannel(); | 3829 SetLocalDescriptionWithDataChannel(); |
3848 EXPECT_EQ(cricket::DCT_RTP, data_engine_->last_channel_type()); | 3830 EXPECT_EQ(cricket::DCT_RTP, data_engine_->last_channel_type()); |
3849 } | 3831 } |
3850 | 3832 |
3851 TEST_P(WebRtcSessionTest, TestCreateOfferWithSctpEnabledWithoutStreams) { | 3833 TEST_P(WebRtcSessionTest, TestCreateOfferWithSctpEnabledWithoutStreams) { |
3852 MAYBE_SKIP_TEST(rtc::SSLStreamAdapter::HaveDtlsSrtp); | 3834 MAYBE_SKIP_TEST(rtc::SSLStreamAdapter::HaveDtlsSrtp); |
(...skipping 11 matching lines...) Loading... |
3864 InitWithDtls(GetParam()); | 3846 InitWithDtls(GetParam()); |
3865 | 3847 |
3866 // Create remote offer with SCTP. | 3848 // Create remote offer with SCTP. |
3867 cricket::MediaSessionOptions options; | 3849 cricket::MediaSessionOptions options; |
3868 options.data_channel_type = cricket::DCT_SCTP; | 3850 options.data_channel_type = cricket::DCT_SCTP; |
3869 JsepSessionDescription* offer = | 3851 JsepSessionDescription* offer = |
3870 CreateRemoteOffer(options, cricket::SEC_DISABLED); | 3852 CreateRemoteOffer(options, cricket::SEC_DISABLED); |
3871 SetRemoteDescriptionWithoutError(offer); | 3853 SetRemoteDescriptionWithoutError(offer); |
3872 | 3854 |
3873 // Verifies the answer contains SCTP. | 3855 // Verifies the answer contains SCTP. |
3874 rtc::scoped_ptr<SessionDescriptionInterface> answer(CreateAnswer(NULL)); | 3856 rtc::scoped_ptr<SessionDescriptionInterface> answer(CreateAnswer()); |
3875 EXPECT_TRUE(answer != NULL); | 3857 EXPECT_TRUE(answer != NULL); |
3876 EXPECT_TRUE(answer->description()->GetContentByName("data") != NULL); | 3858 EXPECT_TRUE(answer->description()->GetContentByName("data") != NULL); |
3877 EXPECT_TRUE(answer->description()->GetTransportInfoByName("data") != NULL); | 3859 EXPECT_TRUE(answer->description()->GetTransportInfoByName("data") != NULL); |
3878 } | 3860 } |
3879 | 3861 |
3880 TEST_P(WebRtcSessionTest, TestSctpDataChannelWithoutDtls) { | 3862 TEST_P(WebRtcSessionTest, TestSctpDataChannelWithoutDtls) { |
3881 constraints_.reset(new FakeConstraints()); | 3863 configuration_.enable_dtls_srtp = rtc::Optional<bool>(false); |
3882 constraints_->AddOptional( | |
3883 webrtc::MediaConstraintsInterface::kEnableDtlsSrtp, false); | |
3884 InitWithDtls(GetParam()); | 3864 InitWithDtls(GetParam()); |
3885 | 3865 |
3886 SetLocalDescriptionWithDataChannel(); | 3866 SetLocalDescriptionWithDataChannel(); |
3887 EXPECT_EQ(cricket::DCT_NONE, data_engine_->last_channel_type()); | 3867 EXPECT_EQ(cricket::DCT_NONE, data_engine_->last_channel_type()); |
3888 } | 3868 } |
3889 | 3869 |
3890 TEST_P(WebRtcSessionTest, TestSctpDataChannelWithDtls) { | 3870 TEST_P(WebRtcSessionTest, TestSctpDataChannelWithDtls) { |
3891 MAYBE_SKIP_TEST(rtc::SSLStreamAdapter::HaveDtlsSrtp); | 3871 MAYBE_SKIP_TEST(rtc::SSLStreamAdapter::HaveDtlsSrtp); |
3892 | 3872 |
3893 InitWithDtls(GetParam()); | 3873 InitWithDtls(GetParam()); |
(...skipping 23 matching lines...) Loading... |
3917 // actually get serialized for SCTP in BuildMediaDescription(). Instead, | 3897 // actually get serialized for SCTP in BuildMediaDescription(). Instead, |
3918 // let the session description get parsed. That'll get the proper codecs | 3898 // let the session description get parsed. That'll get the proper codecs |
3919 // into the stream. | 3899 // into the stream. |
3920 cricket::MediaSessionOptions options; | 3900 cricket::MediaSessionOptions options; |
3921 JsepSessionDescription* offer = CreateRemoteOfferWithSctpPort( | 3901 JsepSessionDescription* offer = CreateRemoteOfferWithSctpPort( |
3922 "stream1", new_send_port, options); | 3902 "stream1", new_send_port, options); |
3923 | 3903 |
3924 // SetRemoteDescription will take the ownership of the offer. | 3904 // SetRemoteDescription will take the ownership of the offer. |
3925 SetRemoteDescriptionWithoutError(offer); | 3905 SetRemoteDescriptionWithoutError(offer); |
3926 | 3906 |
3927 SessionDescriptionInterface* answer = ChangeSDPSctpPort( | 3907 SessionDescriptionInterface* answer = |
3928 new_recv_port, CreateAnswer(NULL)); | 3908 ChangeSDPSctpPort(new_recv_port, CreateAnswer()); |
3929 ASSERT_TRUE(answer != NULL); | 3909 ASSERT_TRUE(answer != NULL); |
3930 | 3910 |
3931 // Now set the local description, which'll take ownership of the answer. | 3911 // Now set the local description, which'll take ownership of the answer. |
3932 SetLocalDescriptionWithoutError(answer); | 3912 SetLocalDescriptionWithoutError(answer); |
3933 | 3913 |
3934 // TEST PLAN: Set the port number to something new, set it in the SDP, | 3914 // TEST PLAN: Set the port number to something new, set it in the SDP, |
3935 // and pass it all the way down. | 3915 // and pass it all the way down. |
3936 EXPECT_EQ(cricket::DCT_SCTP, data_engine_->last_channel_type()); | 3916 EXPECT_EQ(cricket::DCT_SCTP, data_engine_->last_channel_type()); |
3937 CreateDataChannel(); | 3917 CreateDataChannel(); |
3938 | 3918 |
(...skipping 43 matching lines...) Loading... |
3982 EXPECT_EQ(config.id, last_data_channel_config_.id); | 3962 EXPECT_EQ(config.id, last_data_channel_config_.id); |
3983 EXPECT_FALSE(last_data_channel_config_.negotiated); | 3963 EXPECT_FALSE(last_data_channel_config_.negotiated); |
3984 EXPECT_EQ(webrtc::InternalDataChannelInit::kAcker, | 3964 EXPECT_EQ(webrtc::InternalDataChannelInit::kAcker, |
3985 last_data_channel_config_.open_handshake_role); | 3965 last_data_channel_config_.open_handshake_role); |
3986 } | 3966 } |
3987 | 3967 |
3988 TEST_P(WebRtcSessionTest, TestUsesProvidedCertificate) { | 3968 TEST_P(WebRtcSessionTest, TestUsesProvidedCertificate) { |
3989 rtc::scoped_refptr<rtc::RTCCertificate> certificate = | 3969 rtc::scoped_refptr<rtc::RTCCertificate> certificate = |
3990 FakeDtlsIdentityStore::GenerateCertificate(); | 3970 FakeDtlsIdentityStore::GenerateCertificate(); |
3991 | 3971 |
3992 PeerConnectionInterface::RTCConfiguration configuration; | 3972 configuration_.certificates.push_back(certificate); |
3993 configuration.certificates.push_back(certificate); | 3973 Init(); |
3994 Init(nullptr, configuration); | |
3995 EXPECT_TRUE_WAIT(!session_->waiting_for_certificate_for_testing(), 1000); | 3974 EXPECT_TRUE_WAIT(!session_->waiting_for_certificate_for_testing(), 1000); |
3996 | 3975 |
3997 EXPECT_EQ(session_->certificate_for_testing(), certificate); | 3976 EXPECT_EQ(session_->certificate_for_testing(), certificate); |
3998 } | 3977 } |
3999 | 3978 |
4000 // Verifies that CreateOffer succeeds when CreateOffer is called before async | 3979 // Verifies that CreateOffer succeeds when CreateOffer is called before async |
4001 // identity generation is finished (even if a certificate is provided this is | 3980 // identity generation is finished (even if a certificate is provided this is |
4002 // an async op). | 3981 // an async op). |
4003 TEST_P(WebRtcSessionTest, TestCreateOfferBeforeIdentityRequestReturnSuccess) { | 3982 TEST_P(WebRtcSessionTest, TestCreateOfferBeforeIdentityRequestReturnSuccess) { |
4004 MAYBE_SKIP_TEST(rtc::SSLStreamAdapter::HaveDtlsSrtp); | 3983 MAYBE_SKIP_TEST(rtc::SSLStreamAdapter::HaveDtlsSrtp); |
(...skipping 16 matching lines...) Loading... |
4021 InitWithDtls(GetParam()); | 4000 InitWithDtls(GetParam()); |
4022 SetFactoryDtlsSrtp(); | 4001 SetFactoryDtlsSrtp(); |
4023 | 4002 |
4024 cricket::MediaSessionOptions options; | 4003 cricket::MediaSessionOptions options; |
4025 options.recv_video = true; | 4004 options.recv_video = true; |
4026 scoped_ptr<JsepSessionDescription> offer( | 4005 scoped_ptr<JsepSessionDescription> offer( |
4027 CreateRemoteOffer(options, cricket::SEC_DISABLED)); | 4006 CreateRemoteOffer(options, cricket::SEC_DISABLED)); |
4028 ASSERT_TRUE(offer.get() != NULL); | 4007 ASSERT_TRUE(offer.get() != NULL); |
4029 SetRemoteDescriptionWithoutError(offer.release()); | 4008 SetRemoteDescriptionWithoutError(offer.release()); |
4030 | 4009 |
4031 rtc::scoped_ptr<SessionDescriptionInterface> answer(CreateAnswer(NULL)); | 4010 rtc::scoped_ptr<SessionDescriptionInterface> answer(CreateAnswer()); |
4032 EXPECT_TRUE(answer != NULL); | 4011 EXPECT_TRUE(answer != NULL); |
4033 VerifyNoCryptoParams(answer->description(), true); | 4012 VerifyNoCryptoParams(answer->description(), true); |
4034 VerifyFingerprintStatus(answer->description(), true); | 4013 VerifyFingerprintStatus(answer->description(), true); |
4035 } | 4014 } |
4036 | 4015 |
4037 // Verifies that CreateOffer succeeds when CreateOffer is called after async | 4016 // Verifies that CreateOffer succeeds when CreateOffer is called after async |
4038 // identity generation is finished (even if a certificate is provided this is | 4017 // identity generation is finished (even if a certificate is provided this is |
4039 // an async op). | 4018 // an async op). |
4040 TEST_P(WebRtcSessionTest, TestCreateOfferAfterIdentityRequestReturnSuccess) { | 4019 TEST_P(WebRtcSessionTest, TestCreateOfferAfterIdentityRequestReturnSuccess) { |
4041 MAYBE_SKIP_TEST(rtc::SSLStreamAdapter::HaveDtlsSrtp); | 4020 MAYBE_SKIP_TEST(rtc::SSLStreamAdapter::HaveDtlsSrtp); |
(...skipping 68 matching lines...) Loading... |
4110 ASSERT_TRUE(audio != NULL); | 4089 ASSERT_TRUE(audio != NULL); |
4111 ASSERT_TRUE(audio->description.identity_fingerprint.get() == NULL); | 4090 ASSERT_TRUE(audio->description.identity_fingerprint.get() == NULL); |
4112 audio->description.identity_fingerprint.reset( | 4091 audio->description.identity_fingerprint.reset( |
4113 rtc::SSLFingerprint::CreateFromRfc4572( | 4092 rtc::SSLFingerprint::CreateFromRfc4572( |
4114 rtc::DIGEST_SHA_256, kFakeDtlsFingerprint)); | 4093 rtc::DIGEST_SHA_256, kFakeDtlsFingerprint)); |
4115 SetRemoteDescriptionOfferExpectError(kSdpWithoutSdesCrypto, | 4094 SetRemoteDescriptionOfferExpectError(kSdpWithoutSdesCrypto, |
4116 offer); | 4095 offer); |
4117 } | 4096 } |
4118 | 4097 |
4119 TEST_F(WebRtcSessionTest, TestCombinedAudioVideoBweConstraint) { | 4098 TEST_F(WebRtcSessionTest, TestCombinedAudioVideoBweConstraint) { |
4120 constraints_.reset(new FakeConstraints()); | 4099 configuration_.combined_audio_video_bwe = rtc::Optional<bool>(true); |
4121 constraints_->AddOptional( | |
4122 webrtc::MediaConstraintsInterface::kCombinedAudioVideoBwe, | |
4123 true); | |
4124 Init(); | 4100 Init(); |
4125 SendAudioVideoStream1(); | 4101 SendAudioVideoStream1(); |
4126 SessionDescriptionInterface* offer = CreateOffer(); | 4102 SessionDescriptionInterface* offer = CreateOffer(); |
4127 | 4103 |
4128 SetLocalDescriptionWithoutError(offer); | 4104 SetLocalDescriptionWithoutError(offer); |
4129 | 4105 |
4130 voice_channel_ = media_engine_->GetVoiceChannel(0); | 4106 voice_channel_ = media_engine_->GetVoiceChannel(0); |
4131 | 4107 |
4132 ASSERT_TRUE(voice_channel_ != NULL); | 4108 ASSERT_TRUE(voice_channel_ != NULL); |
4133 const cricket::AudioOptions& audio_options = voice_channel_->options(); | 4109 const cricket::AudioOptions& audio_options = voice_channel_->options(); |
(...skipping 19 matching lines...) Loading... |
4153 offer = CreateRemoteOffer(options, cricket::SEC_DISABLED); | 4129 offer = CreateRemoteOffer(options, cricket::SEC_DISABLED); |
4154 | 4130 |
4155 cricket::Candidate candidate1; | 4131 cricket::Candidate candidate1; |
4156 candidate1.set_address(rtc::SocketAddress("1.1.1.1", 5000)); | 4132 candidate1.set_address(rtc::SocketAddress("1.1.1.1", 5000)); |
4157 candidate1.set_component(1); | 4133 candidate1.set_component(1); |
4158 JsepIceCandidate ice_candidate(kMediaContentName1, kMediaContentIndex1, | 4134 JsepIceCandidate ice_candidate(kMediaContentName1, kMediaContentIndex1, |
4159 candidate1); | 4135 candidate1); |
4160 EXPECT_TRUE(offer->AddCandidate(&ice_candidate)); | 4136 EXPECT_TRUE(offer->AddCandidate(&ice_candidate)); |
4161 SetRemoteDescriptionWithoutError(offer); | 4137 SetRemoteDescriptionWithoutError(offer); |
4162 | 4138 |
4163 answer = CreateAnswer(NULL); | 4139 answer = CreateAnswer(); |
4164 SetLocalDescriptionWithoutError(answer); | 4140 SetLocalDescriptionWithoutError(answer); |
4165 } | 4141 } |
4166 | 4142 |
4167 // Tests that we can renegotiate new media content with ICE candidates separated | 4143 // Tests that we can renegotiate new media content with ICE candidates separated |
4168 // from the remote SDP. | 4144 // from the remote SDP. |
4169 TEST_P(WebRtcSessionTest, TestRenegotiateNewMediaWithCandidatesSeparated) { | 4145 TEST_P(WebRtcSessionTest, TestRenegotiateNewMediaWithCandidatesSeparated) { |
4170 MAYBE_SKIP_TEST(rtc::SSLStreamAdapter::HaveDtlsSrtp); | 4146 MAYBE_SKIP_TEST(rtc::SSLStreamAdapter::HaveDtlsSrtp); |
4171 InitWithDtls(GetParam()); | 4147 InitWithDtls(GetParam()); |
4172 SetFactoryDtlsSrtp(); | 4148 SetFactoryDtlsSrtp(); |
4173 | 4149 |
4174 SendAudioOnlyStream2(); | 4150 SendAudioOnlyStream2(); |
4175 SessionDescriptionInterface* offer = CreateOffer(); | 4151 SessionDescriptionInterface* offer = CreateOffer(); |
4176 SetLocalDescriptionWithoutError(offer); | 4152 SetLocalDescriptionWithoutError(offer); |
4177 | 4153 |
4178 SessionDescriptionInterface* answer = CreateRemoteAnswer(offer); | 4154 SessionDescriptionInterface* answer = CreateRemoteAnswer(offer); |
4179 SetRemoteDescriptionWithoutError(answer); | 4155 SetRemoteDescriptionWithoutError(answer); |
4180 | 4156 |
4181 cricket::MediaSessionOptions options; | 4157 cricket::MediaSessionOptions options; |
4182 options.recv_video = true; | 4158 options.recv_video = true; |
4183 offer = CreateRemoteOffer(options, cricket::SEC_DISABLED); | 4159 offer = CreateRemoteOffer(options, cricket::SEC_DISABLED); |
4184 SetRemoteDescriptionWithoutError(offer); | 4160 SetRemoteDescriptionWithoutError(offer); |
4185 | 4161 |
4186 cricket::Candidate candidate1; | 4162 cricket::Candidate candidate1; |
4187 candidate1.set_address(rtc::SocketAddress("1.1.1.1", 5000)); | 4163 candidate1.set_address(rtc::SocketAddress("1.1.1.1", 5000)); |
4188 candidate1.set_component(1); | 4164 candidate1.set_component(1); |
4189 JsepIceCandidate ice_candidate(kMediaContentName1, kMediaContentIndex1, | 4165 JsepIceCandidate ice_candidate(kMediaContentName1, kMediaContentIndex1, |
4190 candidate1); | 4166 candidate1); |
4191 EXPECT_TRUE(session_->ProcessIceMessage(&ice_candidate)); | 4167 EXPECT_TRUE(session_->ProcessIceMessage(&ice_candidate)); |
4192 | 4168 |
4193 answer = CreateAnswer(NULL); | 4169 answer = CreateAnswer(); |
4194 SetLocalDescriptionWithoutError(answer); | 4170 SetLocalDescriptionWithoutError(answer); |
4195 } | 4171 } |
4196 | 4172 |
4197 // Flaky on Win and Mac only. See webrtc:4943 | 4173 // Flaky on Win and Mac only. See webrtc:4943 |
4198 #if defined(WEBRTC_WIN) || defined(WEBRTC_MAC) | 4174 #if defined(WEBRTC_WIN) || defined(WEBRTC_MAC) |
4199 #define MAYBE_TestRtxRemovedByCreateAnswer DISABLED_TestRtxRemovedByCreateAnswer | 4175 #define MAYBE_TestRtxRemovedByCreateAnswer DISABLED_TestRtxRemovedByCreateAnswer |
4200 #else | 4176 #else |
4201 #define MAYBE_TestRtxRemovedByCreateAnswer TestRtxRemovedByCreateAnswer | 4177 #define MAYBE_TestRtxRemovedByCreateAnswer TestRtxRemovedByCreateAnswer |
4202 #endif | 4178 #endif |
4203 // Tests that RTX codec is removed from the answer when it isn't supported | 4179 // Tests that RTX codec is removed from the answer when it isn't supported |
4204 // by local side. | 4180 // by local side. |
4205 TEST_F(WebRtcSessionTest, MAYBE_TestRtxRemovedByCreateAnswer) { | 4181 TEST_F(WebRtcSessionTest, MAYBE_TestRtxRemovedByCreateAnswer) { |
4206 Init(); | 4182 Init(); |
4207 SendAudioVideoStream1(); | 4183 SendAudioVideoStream1(); |
4208 std::string offer_sdp(kSdpWithRtx); | 4184 std::string offer_sdp(kSdpWithRtx); |
4209 | 4185 |
4210 SessionDescriptionInterface* offer = | 4186 SessionDescriptionInterface* offer = |
4211 CreateSessionDescription(JsepSessionDescription::kOffer, offer_sdp, NULL); | 4187 CreateSessionDescription(JsepSessionDescription::kOffer, offer_sdp, NULL); |
4212 EXPECT_TRUE(offer->ToString(&offer_sdp)); | 4188 EXPECT_TRUE(offer->ToString(&offer_sdp)); |
4213 | 4189 |
4214 // Offer SDP contains the RTX codec. | 4190 // Offer SDP contains the RTX codec. |
4215 EXPECT_TRUE(offer_sdp.find("rtx") != std::string::npos); | 4191 EXPECT_TRUE(offer_sdp.find("rtx") != std::string::npos); |
4216 SetRemoteDescriptionWithoutError(offer); | 4192 SetRemoteDescriptionWithoutError(offer); |
4217 | 4193 |
4218 SessionDescriptionInterface* answer = CreateAnswer(NULL); | 4194 SessionDescriptionInterface* answer = CreateAnswer(); |
4219 std::string answer_sdp; | 4195 std::string answer_sdp; |
4220 answer->ToString(&answer_sdp); | 4196 answer->ToString(&answer_sdp); |
4221 // Answer SDP removes the unsupported RTX codec. | 4197 // Answer SDP removes the unsupported RTX codec. |
4222 EXPECT_TRUE(answer_sdp.find("rtx") == std::string::npos); | 4198 EXPECT_TRUE(answer_sdp.find("rtx") == std::string::npos); |
4223 SetLocalDescriptionWithoutError(answer); | 4199 SetLocalDescriptionWithoutError(answer); |
4224 } | 4200 } |
4225 | 4201 |
4226 // This verifies that the voice channel after bundle has both options from video | 4202 // This verifies that the voice channel after bundle has both options from video |
4227 // and voice channels. | 4203 // and voice channels. |
4228 TEST_F(WebRtcSessionTest, TestSetSocketOptionBeforeBundle) { | 4204 TEST_F(WebRtcSessionTest, TestSetSocketOptionBeforeBundle) { |
(...skipping 84 matching lines...) Loading... |
4313 } | 4289 } |
4314 | 4290 |
4315 // TODO(bemasc): Add a TestIceStatesBundle with BUNDLE enabled. That test | 4291 // TODO(bemasc): Add a TestIceStatesBundle with BUNDLE enabled. That test |
4316 // currently fails because upon disconnection and reconnection OnIceComplete is | 4292 // currently fails because upon disconnection and reconnection OnIceComplete is |
4317 // called more than once without returning to IceGatheringGathering. | 4293 // called more than once without returning to IceGatheringGathering. |
4318 | 4294 |
4319 INSTANTIATE_TEST_CASE_P(WebRtcSessionTests, | 4295 INSTANTIATE_TEST_CASE_P(WebRtcSessionTests, |
4320 WebRtcSessionTest, | 4296 WebRtcSessionTest, |
4321 testing::Values(ALREADY_GENERATED, | 4297 testing::Values(ALREADY_GENERATED, |
4322 DTLS_IDENTITY_STORE)); | 4298 DTLS_IDENTITY_STORE)); |
OLD | NEW |