Chromium Code Reviews| 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 |
| (...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 391 metrics_observer_(new rtc::RefCountedObject<FakeMetricsObserver>()) { | 391 metrics_observer_(new rtc::RefCountedObject<FakeMetricsObserver>()) { |
| 392 cricket::ServerAddresses stun_servers; | 392 cricket::ServerAddresses stun_servers; |
| 393 stun_servers.insert(stun_socket_addr_); | 393 stun_servers.insert(stun_socket_addr_); |
| 394 allocator_.reset(new cricket::BasicPortAllocator( | 394 allocator_.reset(new cricket::BasicPortAllocator( |
| 395 &network_manager_, | 395 &network_manager_, |
| 396 stun_servers, | 396 stun_servers, |
| 397 SocketAddress(), SocketAddress(), SocketAddress())); | 397 SocketAddress(), SocketAddress(), SocketAddress())); |
| 398 allocator_->set_flags(cricket::PORTALLOCATOR_DISABLE_TCP | | 398 allocator_->set_flags(cricket::PORTALLOCATOR_DISABLE_TCP | |
| 399 cricket::PORTALLOCATOR_DISABLE_RELAY); | 399 cricket::PORTALLOCATOR_DISABLE_RELAY); |
| 400 EXPECT_TRUE(channel_manager_->Init()); | 400 EXPECT_TRUE(channel_manager_->Init()); |
| 401 desc_factory_->set_add_legacy_streams(false); | |
| 402 allocator_->set_step_delay(cricket::kMinimumStepDelay); | 401 allocator_->set_step_delay(cricket::kMinimumStepDelay); |
| 403 } | 402 } |
| 404 | 403 |
| 405 void AddInterface(const SocketAddress& addr) { | 404 void AddInterface(const SocketAddress& addr) { |
| 406 network_manager_.AddInterface(addr); | 405 network_manager_.AddInterface(addr); |
| 407 } | 406 } |
| 408 void RemoveInterface(const SocketAddress& addr) { | 407 void RemoveInterface(const SocketAddress& addr) { |
| 409 network_manager_.RemoveInterface(addr); | 408 network_manager_.RemoveInterface(addr); |
| 410 } | 409 } |
| 411 | 410 |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 505 rtc::CryptoOptions crypto_options; | 504 rtc::CryptoOptions crypto_options; |
| 506 crypto_options.enable_gcm_crypto_suites = true; | 505 crypto_options.enable_gcm_crypto_suites = true; |
| 507 InitWithCryptoOptions(crypto_options); | 506 InitWithCryptoOptions(crypto_options); |
| 508 } | 507 } |
| 509 | 508 |
| 510 void SendAudioVideoStream1() { | 509 void SendAudioVideoStream1() { |
| 511 send_stream_1_ = true; | 510 send_stream_1_ = true; |
| 512 send_stream_2_ = false; | 511 send_stream_2_ = false; |
| 513 send_audio_ = true; | 512 send_audio_ = true; |
| 514 send_video_ = true; | 513 send_video_ = true; |
| 514 recv_audio_ = true; | |
| 515 recv_video_ = true; | |
|
Taylor Brandstetter
2017/07/28 19:00:26
It's not obvious why "SendAudioVideoStream1" would
Zhi Huang
2017/08/02 04:38:37
I realized that we don't need to set recv_X actual
| |
| 515 } | 516 } |
| 516 | 517 |
| 517 void SendAudioVideoStream2() { | 518 void SendAudioVideoStream2() { |
| 518 send_stream_1_ = false; | 519 send_stream_1_ = false; |
| 519 send_stream_2_ = true; | 520 send_stream_2_ = true; |
| 520 send_audio_ = true; | 521 send_audio_ = true; |
| 521 send_video_ = true; | 522 send_video_ = true; |
| 523 recv_audio_ = true; | |
| 524 recv_video_ = true; | |
| 522 } | 525 } |
| 523 | 526 |
| 524 void SendAudioVideoStream1And2() { | 527 void SendAudioVideoStream1And2() { |
| 525 send_stream_1_ = true; | 528 send_stream_1_ = true; |
| 526 send_stream_2_ = true; | 529 send_stream_2_ = true; |
| 527 send_audio_ = true; | 530 send_audio_ = true; |
| 528 send_video_ = true; | 531 send_video_ = true; |
| 532 recv_audio_ = true; | |
| 533 recv_video_ = true; | |
| 529 } | 534 } |
| 530 | 535 |
| 531 void SendNothing() { | 536 void SendNothing() { |
| 532 send_stream_1_ = false; | 537 send_stream_1_ = false; |
| 533 send_stream_2_ = false; | 538 send_stream_2_ = false; |
| 534 send_audio_ = false; | 539 send_audio_ = false; |
| 535 send_video_ = false; | 540 send_video_ = false; |
| 536 } | 541 } |
| 537 | 542 |
| 538 void SendAudioOnlyStream2() { | 543 void SendAudioOnlyStream2() { |
| 539 send_stream_1_ = false; | 544 send_stream_1_ = false; |
| 540 send_stream_2_ = true; | 545 send_stream_2_ = true; |
| 541 send_audio_ = true; | 546 send_audio_ = true; |
| 542 send_video_ = false; | 547 send_video_ = false; |
| 548 recv_audio_ = true; | |
| 549 recv_video_ = true; | |
| 543 } | 550 } |
| 544 | 551 |
| 545 void SendVideoOnlyStream2() { | 552 void SendVideoOnlyStream2() { |
| 546 send_stream_1_ = false; | 553 send_stream_1_ = false; |
| 547 send_stream_2_ = true; | 554 send_stream_2_ = true; |
| 548 send_audio_ = false; | 555 send_audio_ = false; |
| 549 send_video_ = true; | 556 send_video_ = true; |
| 557 recv_audio_ = true; | |
| 558 recv_video_ = true; | |
| 550 } | 559 } |
| 551 | 560 |
| 552 void AddStreamsToOptions(cricket::MediaSessionOptions* session_options) { | 561 // Helper function used to add a specific media section to the |
| 553 if (send_stream_1_ && send_audio_) { | 562 // |session_options|. |
| 554 session_options->AddSendStream(cricket::MEDIA_TYPE_AUDIO, kAudioTrack1, | 563 void AddMediaSection(cricket::MediaType type, |
| 555 kStream1); | 564 const std::string& mid, |
| 565 bool send, | |
| 566 bool recv, | |
| 567 bool stopped, | |
|
Taylor Brandstetter
2017/07/28 19:00:26
Similar comment for this as for AddMediaSection in
Zhi Huang
2017/08/02 04:38:37
Done.
| |
| 568 cricket::MediaSessionOptions& session_options) { | |
| 569 session_options.media_description_options.push_back( | |
| 570 cricket::MediaDescriptionOptions( | |
| 571 type, mid, cricket::RtpTransceiverDirection(send, recv), stopped)); | |
| 572 } | |
| 573 | |
| 574 // Add the media sections to the options from |offered_media_sections_| when | |
| 575 // creating an answer or a new offer. | |
|
Taylor Brandstetter
2017/07/28 19:00:27
Can you add a comment mentioning that this duplica
Zhi Huang
2017/08/02 04:38:37
Done.
| |
| 576 void AddExistingMediaSectionsAndSendersToOptions( | |
| 577 cricket::MediaSessionOptions* session_options, | |
| 578 bool send_audio, | |
| 579 bool recv_audio, | |
| 580 bool send_video, | |
| 581 bool recv_video) { | |
| 582 int num_sim_layer = 1; | |
| 583 for (auto media_description_options : offered_media_sections_) { | |
| 584 if (media_description_options.type == cricket::MEDIA_TYPE_AUDIO) { | |
| 585 bool stopped = !send_audio && !recv_audio; | |
| 586 auto media_desc_options = cricket::MediaDescriptionOptions( | |
| 587 cricket::MEDIA_TYPE_AUDIO, media_description_options.mid, | |
| 588 cricket::RtpTransceiverDirection(send_audio, recv_audio), stopped); | |
| 589 if (send_stream_1_ && send_audio_) { | |
| 590 media_desc_options.AddAudioSender(kAudioTrack1, kStream1); | |
| 591 } | |
| 592 if (send_stream_2_ && send_audio_) { | |
| 593 media_desc_options.AddAudioSender(kAudioTrack2, kStream2); | |
| 594 } | |
| 595 session_options->media_description_options.push_back( | |
| 596 media_desc_options); | |
| 597 audio_section_added_ = true; | |
| 598 } else if (media_description_options.type == cricket::MEDIA_TYPE_VIDEO) { | |
| 599 bool stopped = !send_video && !recv_video; | |
| 600 auto media_desc_options = cricket::MediaDescriptionOptions( | |
| 601 cricket::MEDIA_TYPE_VIDEO, media_description_options.mid, | |
| 602 cricket::RtpTransceiverDirection(send_video, recv_video), stopped); | |
| 603 if (send_stream_1_ && send_video_) { | |
| 604 media_desc_options.AddVideoSender(kVideoTrack1, kStream1, | |
| 605 num_sim_layer); | |
| 606 } | |
| 607 if (send_stream_2_ && send_video_) { | |
| 608 media_desc_options.AddVideoSender(kVideoTrack2, kStream2, | |
| 609 num_sim_layer); | |
| 610 } | |
| 611 session_options->media_description_options.push_back( | |
| 612 media_desc_options); | |
| 613 video_section_added_ = true; | |
| 614 } else if (media_description_options.type == cricket::MEDIA_TYPE_DATA) { | |
| 615 session_options->media_description_options.push_back( | |
| 616 cricket::MediaDescriptionOptions( | |
| 617 cricket::MEDIA_TYPE_DATA, media_description_options.mid, | |
| 618 // Direction for data sections is meaningless, but legacy | |
| 619 // endpoints might expect sendrecv. | |
| 620 cricket::RtpTransceiverDirection(true, true), false)); | |
| 621 data_section_added_ = true; | |
| 622 } else { | |
| 623 RTC_NOTREACHED(); | |
| 624 } | |
| 556 } | 625 } |
| 557 if (send_stream_1_ && send_video_) { | 626 } |
| 558 session_options->AddSendStream(cricket::MEDIA_TYPE_VIDEO, kVideoTrack1, | 627 |
| 559 kStream1); | 628 // Add the existing media sections first and then add new media sections if |
| 629 // needed. | |
| 630 void AddMediaSectionsAndSendersToOptions( | |
| 631 cricket::MediaSessionOptions* session_options, | |
| 632 bool recv_audio, | |
| 633 bool recv_video) { | |
| 634 audio_section_added_ = false; | |
| 635 video_section_added_ = false; | |
| 636 data_section_added_ = false; | |
|
Taylor Brandstetter
2017/07/28 19:00:26
nit: Using member variables here seems error-prone
Zhi Huang
2017/08/02 04:38:36
Done.
| |
| 637 AddExistingMediaSectionsAndSendersToOptions( | |
| 638 session_options, send_audio_, recv_audio, send_video_, recv_video); | |
| 639 | |
| 640 if (!audio_section_added_ && (send_audio_ || recv_audio)) { | |
| 641 cricket::MediaDescriptionOptions media_desc_options = | |
| 642 cricket::MediaDescriptionOptions( | |
| 643 cricket::MEDIA_TYPE_AUDIO, cricket::CN_AUDIO, | |
| 644 cricket::RtpTransceiverDirection(send_audio_, recv_audio), true); | |
| 645 if (send_stream_1_ && send_audio_) { | |
| 646 media_desc_options.AddAudioSender(kAudioTrack1, kStream1); | |
| 647 } | |
| 648 if (send_stream_2_ && send_audio_) { | |
| 649 media_desc_options.AddAudioSender(kAudioTrack2, kStream2); | |
| 650 } | |
| 651 session_options->media_description_options.push_back(media_desc_options); | |
| 652 offered_media_sections_.push_back(media_desc_options); | |
| 560 } | 653 } |
| 561 if (send_stream_2_ && send_audio_) { | 654 |
| 562 session_options->AddSendStream(cricket::MEDIA_TYPE_AUDIO, kAudioTrack2, | 655 if (!video_section_added_ && (send_video_ || recv_video)) { |
| 563 kStream2); | 656 cricket::MediaDescriptionOptions media_desc_options = |
| 657 cricket::MediaDescriptionOptions( | |
| 658 cricket::MEDIA_TYPE_VIDEO, cricket::CN_VIDEO, | |
| 659 cricket::RtpTransceiverDirection(send_video_, recv_video), true); | |
| 660 int num_sim_layer = 1; | |
| 661 if (send_stream_1_ && send_video_) { | |
| 662 media_desc_options.AddVideoSender(kVideoTrack1, kStream1, | |
| 663 num_sim_layer); | |
| 664 } | |
| 665 if (send_stream_2_ && send_video_) { | |
| 666 media_desc_options.AddVideoSender(kVideoTrack2, kStream2, | |
| 667 num_sim_layer); | |
| 668 } | |
| 669 session_options->media_description_options.push_back(media_desc_options); | |
| 670 offered_media_sections_.push_back(media_desc_options); | |
| 564 } | 671 } |
| 565 if (send_stream_2_ && send_video_) { | 672 |
| 566 session_options->AddSendStream(cricket::MEDIA_TYPE_VIDEO, kVideoTrack2, | 673 if (!data_section_added_ && |
| 567 kStream2); | 674 (data_channel_ || |
| 568 } | 675 session_options->data_channel_type != cricket::DCT_NONE)) { |
| 569 if (data_channel_ && session_->data_channel_type() == cricket::DCT_RTP) { | 676 cricket::MediaDescriptionOptions media_desc_options = |
| 570 session_options->AddSendStream(cricket::MEDIA_TYPE_DATA, | 677 cricket::MediaDescriptionOptions( |
| 571 data_channel_->label(), | 678 cricket::MEDIA_TYPE_DATA, cricket::CN_DATA, |
| 572 data_channel_->label()); | 679 cricket::RtpTransceiverDirection(true, true), false); |
| 680 if (session_options->data_channel_type == cricket::DCT_RTP) { | |
| 681 media_desc_options.AddRtpDataChannel(data_channel_->label(), | |
| 682 data_channel_->label()); | |
| 683 } | |
| 684 session_options->media_description_options.push_back(media_desc_options); | |
| 685 offered_media_sections_.push_back(media_desc_options); | |
| 573 } | 686 } |
| 574 } | 687 } |
| 575 | 688 |
| 576 void GetOptionsForOffer( | 689 void GetOptionsForOffer( |
| 577 const PeerConnectionInterface::RTCOfferAnswerOptions& rtc_options, | 690 const PeerConnectionInterface::RTCOfferAnswerOptions& rtc_options, |
| 578 cricket::MediaSessionOptions* session_options) { | 691 cricket::MediaSessionOptions* session_options) { |
| 579 ASSERT_TRUE(ExtractMediaSessionOptions(rtc_options, true, session_options)); | 692 ExtractSharedMediaSessionOptions(rtc_options, session_options); |
| 580 | 693 |
| 581 AddStreamsToOptions(session_options); | 694 // |recv_X| is true by default if |offer_to_receive_X| is undefined. |
| 582 if (rtc_options.offer_to_receive_audio == | 695 bool recv_audio = |
|
Taylor Brandstetter
2017/07/28 19:00:26
Couldn't this just be:
bool recv_audio = rtc_opti
Zhi Huang
2017/08/02 04:38:37
Done.
| |
| 583 RTCOfferAnswerOptions::kUndefined) { | 696 rtc_options.offer_to_receive_audio == RTCOfferAnswerOptions::kUndefined |
| 584 session_options->recv_audio = | 697 ? true |
| 585 session_options->HasSendMediaStream(cricket::MEDIA_TYPE_AUDIO); | 698 : (rtc_options.offer_to_receive_audio > 0); |
| 586 } | 699 bool recv_video = |
| 587 if (rtc_options.offer_to_receive_video == | 700 rtc_options.offer_to_receive_video == RTCOfferAnswerOptions::kUndefined |
| 588 RTCOfferAnswerOptions::kUndefined) { | 701 ? true |
| 589 session_options->recv_video = | 702 : (rtc_options.offer_to_receive_video > 0); |
| 590 session_options->HasSendMediaStream(cricket::MEDIA_TYPE_VIDEO); | 703 AddMediaSectionsAndSendersToOptions(session_options, recv_audio, |
| 591 } | 704 recv_video); |
| 592 session_options->bundle_enabled = | 705 session_options->bundle_enabled = |
| 593 session_options->bundle_enabled && | 706 session_options->bundle_enabled && |
| 594 (session_options->has_audio() || session_options->has_video() || | 707 (session_options->has_audio() || session_options->has_video() || |
| 595 session_options->has_data()); | 708 session_options->has_data()); |
| 596 | 709 |
| 597 if (session_->data_channel_type() == cricket::DCT_SCTP && data_channel_) { | 710 session_options->crypto_options = crypto_options_; |
| 598 session_options->data_channel_type = cricket::DCT_SCTP; | 711 } |
| 599 } else if (session_->data_channel_type() == cricket::DCT_QUIC) { | 712 |
| 600 session_options->data_channel_type = cricket::DCT_QUIC; | 713 void GetOptionsForAnswer(cricket::MediaSessionOptions* session_options) { |
| 714 // |recv_X| is true if callee wants to receive or the caller wants to send. | |
| 715 bool recv_audio = recv_audio_ || send_audio_; | |
| 716 bool recv_video = recv_video_ || send_video_; | |
| 717 bool send_audio = false; | |
| 718 bool send_video = false; | |
| 719 | |
| 720 AddExistingMediaSectionsAndSendersToOptions( | |
| 721 session_options, send_audio, recv_audio, send_video, recv_video); | |
| 722 | |
| 723 session_options->bundle_enabled = | |
| 724 session_options->bundle_enabled && | |
| 725 (session_options->has_audio() || session_options->has_video() || | |
| 726 session_options->has_data()); | |
| 727 | |
| 728 if (session_->data_channel_type() != cricket::DCT_RTP) { | |
| 729 session_options->data_channel_type = session_->data_channel_type(); | |
| 601 } | 730 } |
| 602 | 731 |
| 603 session_options->crypto_options = crypto_options_; | 732 session_options->crypto_options = crypto_options_; |
| 604 } | 733 } |
| 605 | 734 |
| 606 void GetOptionsForAnswer(cricket::MediaSessionOptions* session_options) { | 735 void GetOptionsForAudioOnlyRemoteOffer( |
| 607 // ParseConstraintsForAnswer is used to set some defaults. | 736 cricket::MediaSessionOptions* session_options) { |
| 608 ASSERT_TRUE(webrtc::ParseConstraintsForAnswer(nullptr, session_options)); | 737 recv_audio_ = true; |
| 738 recv_video_ = false; | |
| 739 GetOptionsForRemoteOffer(session_options); | |
| 740 } | |
| 609 | 741 |
| 610 AddStreamsToOptions(session_options); | 742 void GetOptionsForRemoteOffer(cricket::MediaSessionOptions* session_options) { |
| 743 AddMediaSectionsAndSendersToOptions(session_options, recv_audio_, | |
| 744 recv_video_); | |
| 611 session_options->bundle_enabled = | 745 session_options->bundle_enabled = |
| 612 session_options->bundle_enabled && | |
| 613 (session_options->has_audio() || session_options->has_video() || | 746 (session_options->has_audio() || session_options->has_video() || |
| 614 session_options->has_data()); | 747 session_options->has_data()); |
| 615 | 748 |
| 616 if (session_->data_channel_type() != cricket::DCT_RTP) { | 749 if (session_->data_channel_type() != cricket::DCT_RTP) { |
| 617 session_options->data_channel_type = session_->data_channel_type(); | 750 session_options->data_channel_type = session_->data_channel_type(); |
| 618 } | 751 } |
| 619 | 752 |
| 620 session_options->crypto_options = crypto_options_; | 753 session_options->crypto_options = crypto_options_; |
| 621 } | 754 } |
| 622 | 755 |
| 623 // Creates a local offer and applies it. Starts ICE. | 756 // Creates a local offer and applies it. Starts ICE. |
| 624 // Call SendAudioVideoStreamX() before this function | 757 // Call SendAudioVideoStreamX() before this function |
| 625 // to decide which streams to create. | 758 // to decide which streams to create. |
| 626 void InitiateCall() { | 759 void InitiateCall() { |
| 627 SessionDescriptionInterface* offer = CreateOffer(); | 760 SessionDescriptionInterface* offer = CreateOffer(); |
| 628 SetLocalDescriptionWithoutError(offer); | 761 SetLocalDescriptionWithoutError(offer); |
| 629 EXPECT_TRUE_WAIT(PeerConnectionInterface::kIceGatheringNew != | 762 EXPECT_TRUE_WAIT(PeerConnectionInterface::kIceGatheringNew != |
| 630 observer_.ice_gathering_state_, | 763 observer_.ice_gathering_state_, |
| 631 kIceCandidatesTimeout); | 764 kIceCandidatesTimeout); |
| 632 } | 765 } |
| 633 | 766 |
| 634 SessionDescriptionInterface* CreateOffer() { | 767 SessionDescriptionInterface* CreateOffer() { |
| 635 PeerConnectionInterface::RTCOfferAnswerOptions options; | 768 PeerConnectionInterface::RTCOfferAnswerOptions options; |
| 636 options.offer_to_receive_audio = | 769 options.offer_to_receive_audio = |
| 637 RTCOfferAnswerOptions::kOfferToReceiveMediaTrue; | 770 RTCOfferAnswerOptions::kOfferToReceiveMediaTrue; |
| 638 | |
| 639 return CreateOffer(options); | 771 return CreateOffer(options); |
| 640 } | 772 } |
| 641 | 773 |
| 642 SessionDescriptionInterface* CreateOffer( | 774 SessionDescriptionInterface* CreateOffer( |
| 643 const PeerConnectionInterface::RTCOfferAnswerOptions options) { | 775 const PeerConnectionInterface::RTCOfferAnswerOptions options) { |
| 644 rtc::scoped_refptr<WebRtcSessionCreateSDPObserverForTest> | 776 rtc::scoped_refptr<WebRtcSessionCreateSDPObserverForTest> |
| 645 observer = new WebRtcSessionCreateSDPObserverForTest(); | 777 observer = new WebRtcSessionCreateSDPObserverForTest(); |
| 646 cricket::MediaSessionOptions session_options; | 778 cricket::MediaSessionOptions session_options; |
| 647 GetOptionsForOffer(options, &session_options); | 779 GetOptionsForOffer(options, &session_options); |
| 648 session_->CreateOffer(observer, options, session_options); | 780 session_->CreateOffer(observer, options, session_options); |
| 649 EXPECT_TRUE_WAIT( | 781 EXPECT_TRUE_WAIT( |
| 650 observer->state() != WebRtcSessionCreateSDPObserverForTest::kInit, | 782 observer->state() != WebRtcSessionCreateSDPObserverForTest::kInit, |
| 651 2000); | 783 2000); |
| 652 return observer->ReleaseDescription(); | 784 return observer->ReleaseDescription(); |
| 653 } | 785 } |
| 654 | 786 |
| 655 SessionDescriptionInterface* CreateAnswer( | 787 SessionDescriptionInterface* CreateAnswer( |
| 656 const cricket::MediaSessionOptions& options) { | 788 const cricket::MediaSessionOptions& options) { |
| 657 rtc::scoped_refptr<WebRtcSessionCreateSDPObserverForTest> observer | 789 rtc::scoped_refptr<WebRtcSessionCreateSDPObserverForTest> observer |
| 658 = new WebRtcSessionCreateSDPObserverForTest(); | 790 = new WebRtcSessionCreateSDPObserverForTest(); |
| 659 cricket::MediaSessionOptions session_options = options; | 791 cricket::MediaSessionOptions session_options = options; |
| 660 GetOptionsForAnswer(&session_options); | 792 GetOptionsForAnswer(&session_options); |
| 661 // Overwrite recv_audio and recv_video with passed-in values. | |
| 662 session_options.recv_video = options.recv_video; | |
| 663 session_options.recv_audio = options.recv_audio; | |
| 664 session_->CreateAnswer(observer, session_options); | 793 session_->CreateAnswer(observer, session_options); |
| 665 EXPECT_TRUE_WAIT( | 794 EXPECT_TRUE_WAIT( |
| 666 observer->state() != WebRtcSessionCreateSDPObserverForTest::kInit, | 795 observer->state() != WebRtcSessionCreateSDPObserverForTest::kInit, |
| 667 2000); | 796 2000); |
| 668 return observer->ReleaseDescription(); | 797 return observer->ReleaseDescription(); |
| 669 } | 798 } |
| 670 | 799 |
| 671 SessionDescriptionInterface* CreateAnswer() { | 800 SessionDescriptionInterface* CreateAnswer() { |
| 672 cricket::MediaSessionOptions options; | 801 cricket::MediaSessionOptions options; |
| 673 options.recv_video = true; | 802 options.bundle_enabled = true; |
|
Taylor Brandstetter
2017/07/28 19:00:26
It seems odd to set bundle_enabled to true here, b
Zhi Huang
2017/08/02 04:38:37
The helper methods here are different. For answer,
Taylor Brandstetter
2017/08/03 00:24:48
Acknowledged; sorry for glossing over that.
| |
| 674 options.recv_audio = true; | |
| 675 return CreateAnswer(options); | 803 return CreateAnswer(options); |
| 676 } | 804 } |
| 677 | 805 |
| 678 bool ChannelsExist() const { | 806 bool ChannelsExist() const { |
| 679 return (session_->voice_channel() != NULL && | 807 return (session_->voice_channel() != NULL && |
| 680 session_->video_channel() != NULL); | 808 session_->video_channel() != NULL); |
| 681 } | 809 } |
| 682 | 810 |
| 683 void VerifyCryptoParams(const cricket::SessionDescription* sdp, | 811 void VerifyCryptoParams(const cricket::SessionDescription* sdp, |
| 684 bool gcm_enabled = false) { | 812 bool gcm_enabled = false) { |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 782 ASSERT_TRUE(audio != NULL); | 910 ASSERT_TRUE(audio != NULL); |
| 783 ASSERT_EQ(expected, audio->description.identity_fingerprint.get() != NULL); | 911 ASSERT_EQ(expected, audio->description.identity_fingerprint.get() != NULL); |
| 784 const TransportInfo* video = sdp->GetTransportInfoByName("video"); | 912 const TransportInfo* video = sdp->GetTransportInfoByName("video"); |
| 785 ASSERT_TRUE(video != NULL); | 913 ASSERT_TRUE(video != NULL); |
| 786 ASSERT_EQ(expected, video->description.identity_fingerprint.get() != NULL); | 914 ASSERT_EQ(expected, video->description.identity_fingerprint.get() != NULL); |
| 787 } | 915 } |
| 788 | 916 |
| 789 void VerifyAnswerFromNonCryptoOffer() { | 917 void VerifyAnswerFromNonCryptoOffer() { |
| 790 // Create an SDP without Crypto. | 918 // Create an SDP without Crypto. |
| 791 cricket::MediaSessionOptions options; | 919 cricket::MediaSessionOptions options; |
| 792 options.recv_video = true; | 920 GetOptionsForRemoteOffer(&options); |
| 793 JsepSessionDescription* offer( | 921 JsepSessionDescription* offer( |
| 794 CreateRemoteOffer(options, cricket::SEC_DISABLED)); | 922 CreateRemoteOffer(options, cricket::SEC_DISABLED)); |
| 795 ASSERT_TRUE(offer != NULL); | 923 ASSERT_TRUE(offer != NULL); |
| 796 VerifyNoCryptoParams(offer->description(), false); | 924 VerifyNoCryptoParams(offer->description(), false); |
| 797 SetRemoteDescriptionOfferExpectError(kSdpWithoutSdesCrypto, | 925 SetRemoteDescriptionOfferExpectError(kSdpWithoutSdesCrypto, |
| 798 offer); | 926 offer); |
| 799 const webrtc::SessionDescriptionInterface* answer = CreateAnswer(); | 927 const webrtc::SessionDescriptionInterface* answer = CreateAnswer(); |
| 800 // Answer should be NULL as no crypto params in offer. | 928 // Answer should be NULL as no crypto params in offer. |
| 801 ASSERT_TRUE(answer == NULL); | 929 ASSERT_TRUE(answer == NULL); |
| 802 } | 930 } |
| 803 | 931 |
| 804 void VerifyAnswerFromCryptoOffer() { | 932 void VerifyAnswerFromCryptoOffer() { |
| 805 cricket::MediaSessionOptions options; | 933 cricket::MediaSessionOptions options; |
| 806 options.recv_video = true; | 934 GetOptionsForRemoteOffer(&options); |
| 807 options.bundle_enabled = true; | 935 options.bundle_enabled = true; |
| 808 std::unique_ptr<JsepSessionDescription> offer( | 936 std::unique_ptr<JsepSessionDescription> offer( |
| 809 CreateRemoteOffer(options, cricket::SEC_REQUIRED)); | 937 CreateRemoteOffer(options, cricket::SEC_REQUIRED)); |
| 810 ASSERT_TRUE(offer.get() != NULL); | 938 ASSERT_TRUE(offer.get() != NULL); |
| 811 VerifyCryptoParams(offer->description()); | 939 VerifyCryptoParams(offer->description()); |
| 812 SetRemoteDescriptionWithoutError(offer.release()); | 940 SetRemoteDescriptionWithoutError(offer.release()); |
| 813 std::unique_ptr<SessionDescriptionInterface> answer(CreateAnswer()); | 941 std::unique_ptr<SessionDescriptionInterface> answer(CreateAnswer()); |
| 814 ASSERT_TRUE(answer.get() != NULL); | 942 ASSERT_TRUE(answer.get() != NULL); |
| 815 VerifyCryptoParams(answer->description()); | 943 VerifyCryptoParams(answer->description()); |
| 816 } | 944 } |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 985 void SetRemoteDescriptionAnswerExpectError( | 1113 void SetRemoteDescriptionAnswerExpectError( |
| 986 const std::string& expected_error, SessionDescriptionInterface* desc) { | 1114 const std::string& expected_error, SessionDescriptionInterface* desc) { |
| 987 SetRemoteDescriptionExpectError(SessionDescriptionInterface::kAnswer, | 1115 SetRemoteDescriptionExpectError(SessionDescriptionInterface::kAnswer, |
| 988 expected_error, desc); | 1116 expected_error, desc); |
| 989 } | 1117 } |
| 990 | 1118 |
| 991 void CreateCryptoOfferAndNonCryptoAnswer(SessionDescriptionInterface** offer, | 1119 void CreateCryptoOfferAndNonCryptoAnswer(SessionDescriptionInterface** offer, |
| 992 SessionDescriptionInterface** nocrypto_answer) { | 1120 SessionDescriptionInterface** nocrypto_answer) { |
| 993 // Create a SDP without Crypto. | 1121 // Create a SDP without Crypto. |
| 994 cricket::MediaSessionOptions options; | 1122 cricket::MediaSessionOptions options; |
| 995 options.recv_video = true; | 1123 GetOptionsForRemoteOffer(&options); |
| 996 options.bundle_enabled = true; | 1124 options.bundle_enabled = true; |
| 997 *offer = CreateRemoteOffer(options, cricket::SEC_ENABLED); | 1125 *offer = CreateRemoteOffer(options, cricket::SEC_ENABLED); |
| 998 ASSERT_TRUE(*offer != NULL); | 1126 ASSERT_TRUE(*offer != NULL); |
| 999 VerifyCryptoParams((*offer)->description()); | 1127 VerifyCryptoParams((*offer)->description()); |
| 1000 | 1128 |
| 1001 *nocrypto_answer = CreateRemoteAnswer(*offer, options, | 1129 cricket::MediaSessionOptions answer_options; |
| 1002 cricket::SEC_DISABLED); | 1130 GetOptionsForAnswer(&answer_options); |
| 1131 *nocrypto_answer = | |
| 1132 CreateRemoteAnswer(*offer, answer_options, cricket::SEC_DISABLED); | |
| 1003 EXPECT_TRUE(*nocrypto_answer != NULL); | 1133 EXPECT_TRUE(*nocrypto_answer != NULL); |
| 1004 } | 1134 } |
| 1005 | 1135 |
| 1006 void CreateDtlsOfferAndNonDtlsAnswer(SessionDescriptionInterface** offer, | 1136 void CreateDtlsOfferAndNonDtlsAnswer(SessionDescriptionInterface** offer, |
| 1007 SessionDescriptionInterface** nodtls_answer) { | 1137 SessionDescriptionInterface** nodtls_answer) { |
| 1008 cricket::MediaSessionOptions options; | 1138 cricket::MediaSessionOptions options; |
| 1009 options.recv_video = true; | 1139 AddMediaSection(cricket::MEDIA_TYPE_AUDIO, cricket::CN_AUDIO, |
| 1140 false /*send*/, true /*recv*/, false, options); | |
| 1141 AddMediaSection(cricket::MEDIA_TYPE_VIDEO, cricket::CN_VIDEO, | |
| 1142 false /*send*/, true /*recv*/, false, options); | |
| 1010 options.bundle_enabled = true; | 1143 options.bundle_enabled = true; |
| 1011 | 1144 |
| 1012 std::unique_ptr<SessionDescriptionInterface> temp_offer( | 1145 std::unique_ptr<SessionDescriptionInterface> temp_offer( |
| 1013 CreateRemoteOffer(options, cricket::SEC_ENABLED)); | 1146 CreateRemoteOffer(options, cricket::SEC_ENABLED)); |
| 1014 | 1147 |
| 1015 *nodtls_answer = | 1148 *nodtls_answer = |
| 1016 CreateRemoteAnswer(temp_offer.get(), options, cricket::SEC_ENABLED); | 1149 CreateRemoteAnswer(temp_offer.get(), options, cricket::SEC_ENABLED); |
| 1017 EXPECT_TRUE(*nodtls_answer != NULL); | 1150 EXPECT_TRUE(*nodtls_answer != NULL); |
| 1018 VerifyFingerprintStatus((*nodtls_answer)->description(), false); | 1151 VerifyFingerprintStatus((*nodtls_answer)->description(), false); |
| 1019 VerifyCryptoParams((*nodtls_answer)->description()); | 1152 VerifyCryptoParams((*nodtls_answer)->description()); |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1061 cricket::MediaSessionOptions options, | 1194 cricket::MediaSessionOptions options, |
| 1062 const SessionDescriptionInterface* current_desc) { | 1195 const SessionDescriptionInterface* current_desc) { |
| 1063 return CreateRemoteOfferWithVersion(options, cricket::SEC_ENABLED, | 1196 return CreateRemoteOfferWithVersion(options, cricket::SEC_ENABLED, |
| 1064 kSessionVersion, current_desc); | 1197 kSessionVersion, current_desc); |
| 1065 } | 1198 } |
| 1066 | 1199 |
| 1067 JsepSessionDescription* CreateRemoteOfferWithSctpPort( | 1200 JsepSessionDescription* CreateRemoteOfferWithSctpPort( |
| 1068 const char* sctp_stream_name, int new_port, | 1201 const char* sctp_stream_name, int new_port, |
| 1069 cricket::MediaSessionOptions options) { | 1202 cricket::MediaSessionOptions options) { |
| 1070 options.data_channel_type = cricket::DCT_SCTP; | 1203 options.data_channel_type = cricket::DCT_SCTP; |
| 1071 options.AddSendStream(cricket::MEDIA_TYPE_DATA, "datachannel", | 1204 GetOptionsForRemoteOffer(&options); |
| 1072 sctp_stream_name); | |
| 1073 return ChangeSDPSctpPort(new_port, CreateRemoteOffer(options)); | 1205 return ChangeSDPSctpPort(new_port, CreateRemoteOffer(options)); |
| 1074 } | 1206 } |
| 1075 | 1207 |
| 1076 // Takes ownership of offer_basis (and deletes it). | 1208 // Takes ownership of offer_basis (and deletes it). |
| 1077 JsepSessionDescription* ChangeSDPSctpPort( | 1209 JsepSessionDescription* ChangeSDPSctpPort( |
| 1078 int new_port, webrtc::SessionDescriptionInterface *offer_basis) { | 1210 int new_port, webrtc::SessionDescriptionInterface *offer_basis) { |
| 1079 // Stringify the input SDP, swap the 5000 for 'new_port' and create a new | 1211 // Stringify the input SDP, swap the 5000 for 'new_port' and create a new |
| 1080 // SessionDescription from the mutated string. | 1212 // SessionDescription from the mutated string. |
| 1081 const char* default_port_str = "5000"; | 1213 const char* default_port_str = "5000"; |
| 1082 char new_port_str[16]; | 1214 char new_port_str[16]; |
| 1083 rtc::sprintfn(new_port_str, sizeof(new_port_str), "%d", new_port); | 1215 rtc::sprintfn(new_port_str, sizeof(new_port_str), "%d", new_port); |
| 1084 std::string offer_str; | 1216 std::string offer_str; |
| 1085 offer_basis->ToString(&offer_str); | 1217 offer_basis->ToString(&offer_str); |
| 1086 rtc::replace_substrs(default_port_str, strlen(default_port_str), | 1218 rtc::replace_substrs(default_port_str, strlen(default_port_str), |
| 1087 new_port_str, strlen(new_port_str), | 1219 new_port_str, strlen(new_port_str), |
| 1088 &offer_str); | 1220 &offer_str); |
| 1089 JsepSessionDescription* offer = new JsepSessionDescription( | 1221 JsepSessionDescription* offer = new JsepSessionDescription( |
| 1090 offer_basis->type()); | 1222 offer_basis->type()); |
| 1091 delete offer_basis; | 1223 delete offer_basis; |
| 1092 offer->Initialize(offer_str, NULL); | 1224 offer->Initialize(offer_str, NULL); |
| 1093 return offer; | 1225 return offer; |
| 1094 } | 1226 } |
| 1095 | 1227 |
| 1096 // Create a remote offer. Call SendAudioVideoStreamX() | 1228 // Create a remote offer. Call SendAudioVideoStreamX() |
| 1097 // before this function to decide which streams to create. | 1229 // before this function to decide which streams to create. |
| 1098 JsepSessionDescription* CreateRemoteOffer() { | 1230 JsepSessionDescription* CreateRemoteOffer() { |
| 1099 cricket::MediaSessionOptions options; | 1231 cricket::MediaSessionOptions options; |
| 1100 GetOptionsForAnswer(&options); | 1232 GetOptionsForRemoteOffer(&options); |
| 1101 return CreateRemoteOffer(options, session_->remote_description()); | 1233 return CreateRemoteOffer(options, session_->remote_description()); |
| 1102 } | 1234 } |
| 1103 | 1235 |
| 1104 JsepSessionDescription* CreateRemoteAnswer( | 1236 JsepSessionDescription* CreateRemoteAnswer( |
| 1105 const SessionDescriptionInterface* offer, | 1237 const SessionDescriptionInterface* offer, |
| 1106 cricket::MediaSessionOptions options, | 1238 cricket::MediaSessionOptions options, |
| 1107 cricket::SecurePolicy policy) { | 1239 cricket::SecurePolicy policy) { |
| 1108 desc_factory_->set_secure(policy); | 1240 desc_factory_->set_secure(policy); |
| 1109 const std::string session_id = | 1241 const std::string session_id = |
| 1110 rtc::ToString(rtc::CreateRandomId64()); | 1242 rtc::ToString(rtc::CreateRandomId64()); |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 1125 return CreateRemoteAnswer(offer, options, cricket::SEC_REQUIRED); | 1257 return CreateRemoteAnswer(offer, options, cricket::SEC_REQUIRED); |
| 1126 } | 1258 } |
| 1127 | 1259 |
| 1128 // Creates an answer session description. | 1260 // Creates an answer session description. |
| 1129 // Call SendAudioVideoStreamX() before this function | 1261 // Call SendAudioVideoStreamX() before this function |
| 1130 // to decide which streams to create. | 1262 // to decide which streams to create. |
| 1131 JsepSessionDescription* CreateRemoteAnswer( | 1263 JsepSessionDescription* CreateRemoteAnswer( |
| 1132 const SessionDescriptionInterface* offer) { | 1264 const SessionDescriptionInterface* offer) { |
| 1133 cricket::MediaSessionOptions options; | 1265 cricket::MediaSessionOptions options; |
| 1134 GetOptionsForAnswer(&options); | 1266 GetOptionsForAnswer(&options); |
| 1267 options.bundle_enabled = true; | |
| 1135 return CreateRemoteAnswer(offer, options, cricket::SEC_REQUIRED); | 1268 return CreateRemoteAnswer(offer, options, cricket::SEC_REQUIRED); |
| 1136 } | 1269 } |
| 1137 | 1270 |
| 1138 void TestSessionCandidatesWithBundleRtcpMux(bool bundle, bool rtcp_mux) { | 1271 void TestSessionCandidatesWithBundleRtcpMux(bool bundle, bool rtcp_mux) { |
| 1139 AddInterface(rtc::SocketAddress(kClientAddrHost1, kClientAddrPort)); | 1272 AddInterface(rtc::SocketAddress(kClientAddrHost1, kClientAddrPort)); |
| 1140 Init(); | 1273 Init(); |
| 1141 SendAudioVideoStream1(); | 1274 SendAudioVideoStream1(); |
| 1142 | 1275 |
| 1143 PeerConnectionInterface::RTCOfferAnswerOptions options; | 1276 PeerConnectionInterface::RTCOfferAnswerOptions options; |
| 1144 options.use_rtp_mux = bundle; | 1277 options.use_rtp_mux = bundle; |
| (...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1448 InitWithDtlsIdentityGenFail(); | 1581 InitWithDtlsIdentityGenFail(); |
| 1449 VerifyMultipleAsyncCreateDescriptionAfterInit(false, type); | 1582 VerifyMultipleAsyncCreateDescriptionAfterInit(false, type); |
| 1450 } | 1583 } |
| 1451 | 1584 |
| 1452 void VerifyMultipleAsyncCreateDescriptionAfterInit( | 1585 void VerifyMultipleAsyncCreateDescriptionAfterInit( |
| 1453 bool success, CreateSessionDescriptionRequest::Type type) { | 1586 bool success, CreateSessionDescriptionRequest::Type type) { |
| 1454 RTC_CHECK(session_); | 1587 RTC_CHECK(session_); |
| 1455 SetFactoryDtlsSrtp(); | 1588 SetFactoryDtlsSrtp(); |
| 1456 if (type == CreateSessionDescriptionRequest::kAnswer) { | 1589 if (type == CreateSessionDescriptionRequest::kAnswer) { |
| 1457 cricket::MediaSessionOptions options; | 1590 cricket::MediaSessionOptions options; |
| 1591 GetOptionsForRemoteOffer(&options); | |
| 1458 std::unique_ptr<JsepSessionDescription> offer( | 1592 std::unique_ptr<JsepSessionDescription> offer( |
| 1459 CreateRemoteOffer(options, cricket::SEC_DISABLED)); | 1593 CreateRemoteOffer(options, cricket::SEC_DISABLED)); |
| 1460 ASSERT_TRUE(offer.get() != NULL); | 1594 ASSERT_TRUE(offer.get() != NULL); |
| 1461 SetRemoteDescriptionWithoutError(offer.release()); | 1595 SetRemoteDescriptionWithoutError(offer.release()); |
| 1462 } | 1596 } |
| 1463 | 1597 |
| 1464 PeerConnectionInterface::RTCOfferAnswerOptions options; | 1598 PeerConnectionInterface::RTCOfferAnswerOptions options; |
| 1465 cricket::MediaSessionOptions session_options; | 1599 cricket::MediaSessionOptions offer_session_options; |
| 1600 cricket::MediaSessionOptions answer_session_options; | |
| 1601 GetOptionsForOffer(options, &offer_session_options); | |
| 1602 GetOptionsForAnswer(&answer_session_options); | |
| 1466 const int kNumber = 3; | 1603 const int kNumber = 3; |
| 1467 rtc::scoped_refptr<WebRtcSessionCreateSDPObserverForTest> | 1604 rtc::scoped_refptr<WebRtcSessionCreateSDPObserverForTest> |
| 1468 observers[kNumber]; | 1605 observers[kNumber]; |
| 1469 for (int i = 0; i < kNumber; ++i) { | 1606 for (int i = 0; i < kNumber; ++i) { |
| 1470 observers[i] = new WebRtcSessionCreateSDPObserverForTest(); | 1607 observers[i] = new WebRtcSessionCreateSDPObserverForTest(); |
| 1471 if (type == CreateSessionDescriptionRequest::kOffer) { | 1608 if (type == CreateSessionDescriptionRequest::kOffer) { |
| 1472 session_->CreateOffer(observers[i], options, session_options); | 1609 session_->CreateOffer(observers[i], options, offer_session_options); |
| 1473 } else { | 1610 } else { |
| 1474 session_->CreateAnswer(observers[i], session_options); | 1611 session_->CreateAnswer(observers[i], answer_session_options); |
| 1475 } | 1612 } |
| 1476 } | 1613 } |
| 1477 | 1614 |
| 1478 WebRtcSessionCreateSDPObserverForTest::State expected_state = | 1615 WebRtcSessionCreateSDPObserverForTest::State expected_state = |
| 1479 success ? WebRtcSessionCreateSDPObserverForTest::kSucceeded : | 1616 success ? WebRtcSessionCreateSDPObserverForTest::kSucceeded : |
| 1480 WebRtcSessionCreateSDPObserverForTest::kFailed; | 1617 WebRtcSessionCreateSDPObserverForTest::kFailed; |
| 1481 | 1618 |
| 1482 for (int i = 0; i < kNumber; ++i) { | 1619 for (int i = 0; i < kNumber; ++i) { |
| 1483 EXPECT_EQ_WAIT(expected_state, observers[i]->state(), 1000); | 1620 EXPECT_EQ_WAIT(expected_state, observers[i]->state(), 1000); |
| 1484 if (success) { | 1621 if (success) { |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1524 std::unique_ptr<WebRtcSessionForTest> session_; | 1661 std::unique_ptr<WebRtcSessionForTest> session_; |
| 1525 MockIceObserver observer_; | 1662 MockIceObserver observer_; |
| 1526 cricket::FakeVideoMediaChannel* video_channel_; | 1663 cricket::FakeVideoMediaChannel* video_channel_; |
| 1527 cricket::FakeVoiceMediaChannel* voice_channel_; | 1664 cricket::FakeVoiceMediaChannel* voice_channel_; |
| 1528 rtc::scoped_refptr<FakeMetricsObserver> metrics_observer_; | 1665 rtc::scoped_refptr<FakeMetricsObserver> metrics_observer_; |
| 1529 // The following flags affect options created for CreateOffer/CreateAnswer. | 1666 // The following flags affect options created for CreateOffer/CreateAnswer. |
| 1530 bool send_stream_1_ = false; | 1667 bool send_stream_1_ = false; |
| 1531 bool send_stream_2_ = false; | 1668 bool send_stream_2_ = false; |
| 1532 bool send_audio_ = false; | 1669 bool send_audio_ = false; |
| 1533 bool send_video_ = false; | 1670 bool send_video_ = false; |
| 1671 bool recv_audio_ = true; | |
| 1672 bool recv_video_ = true; | |
| 1673 bool audio_section_added_ = false; | |
| 1674 bool video_section_added_ = false; | |
| 1675 bool data_section_added_ = false; | |
| 1676 std::vector<cricket::MediaDescriptionOptions> offered_media_sections_; | |
| 1534 rtc::scoped_refptr<DataChannel> data_channel_; | 1677 rtc::scoped_refptr<DataChannel> data_channel_; |
| 1535 // Last values received from data channel creation signal. | 1678 // Last values received from data channel creation signal. |
| 1536 std::string last_data_channel_label_; | 1679 std::string last_data_channel_label_; |
| 1537 InternalDataChannelInit last_data_channel_config_; | 1680 InternalDataChannelInit last_data_channel_config_; |
| 1538 rtc::CryptoOptions crypto_options_; | 1681 rtc::CryptoOptions crypto_options_; |
| 1539 }; | 1682 }; |
| 1540 | 1683 |
| 1541 TEST_P(WebRtcSessionTest, TestInitializeWithDtls) { | 1684 TEST_P(WebRtcSessionTest, TestInitializeWithDtls) { |
| 1542 InitWithDtls(GetParam()); | 1685 InitWithDtls(GetParam()); |
| 1543 // SDES is disabled when DTLS is on. | 1686 // SDES is disabled when DTLS is on. |
| (...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1763 // answer without SDES or DTLS --> success | 1906 // answer without SDES or DTLS --> success |
| 1764 // TestCreateAnswerReceiveOfferWithoutEncryption: set remote offer and local | 1907 // TestCreateAnswerReceiveOfferWithoutEncryption: set remote offer and local |
| 1765 // answer without SDES or DTLS --> success | 1908 // answer without SDES or DTLS --> success |
| 1766 // | 1909 // |
| 1767 | 1910 |
| 1768 // Test that we return a failure when applying a remote/local offer that doesn't | 1911 // Test that we return a failure when applying a remote/local offer that doesn't |
| 1769 // have cryptos enabled when DTLS is off. | 1912 // have cryptos enabled when DTLS is off. |
| 1770 TEST_F(WebRtcSessionTest, TestSetNonSdesOfferWhenSdesOn) { | 1913 TEST_F(WebRtcSessionTest, TestSetNonSdesOfferWhenSdesOn) { |
| 1771 Init(); | 1914 Init(); |
| 1772 cricket::MediaSessionOptions options; | 1915 cricket::MediaSessionOptions options; |
| 1773 options.recv_video = true; | 1916 GetOptionsForRemoteOffer(&options); |
| 1774 JsepSessionDescription* offer = CreateRemoteOffer( | 1917 JsepSessionDescription* offer = CreateRemoteOffer( |
| 1775 options, cricket::SEC_DISABLED); | 1918 options, cricket::SEC_DISABLED); |
| 1776 ASSERT_TRUE(offer != NULL); | 1919 ASSERT_TRUE(offer != NULL); |
| 1777 VerifyNoCryptoParams(offer->description(), false); | 1920 VerifyNoCryptoParams(offer->description(), false); |
| 1778 // SetRemoteDescription and SetLocalDescription will take the ownership of | 1921 // SetRemoteDescription and SetLocalDescription will take the ownership of |
| 1779 // the offer. | 1922 // the offer. |
| 1780 SetRemoteDescriptionOfferExpectError(kSdpWithoutSdesCrypto, offer); | 1923 SetRemoteDescriptionOfferExpectError(kSdpWithoutSdesCrypto, offer); |
| 1781 offer = CreateRemoteOffer(options, cricket::SEC_DISABLED); | 1924 offer = CreateRemoteOffer(options, cricket::SEC_DISABLED); |
| 1782 ASSERT_TRUE(offer != NULL); | 1925 ASSERT_TRUE(offer != NULL); |
| 1783 SetLocalDescriptionOfferExpectError(kSdpWithoutSdesCrypto, offer); | 1926 SetLocalDescriptionOfferExpectError(kSdpWithoutSdesCrypto, offer); |
| (...skipping 25 matching lines...) Expand all Loading... | |
| 1809 SetRemoteDescriptionAnswerExpectError(kSdpWithoutSdesCrypto, answer); | 1952 SetRemoteDescriptionAnswerExpectError(kSdpWithoutSdesCrypto, answer); |
| 1810 } | 1953 } |
| 1811 | 1954 |
| 1812 // Test that we accept an offer with a DTLS fingerprint when DTLS is on | 1955 // Test that we accept an offer with a DTLS fingerprint when DTLS is on |
| 1813 // and that we return an answer with a DTLS fingerprint. | 1956 // and that we return an answer with a DTLS fingerprint. |
| 1814 TEST_P(WebRtcSessionTest, TestReceiveDtlsOfferCreateDtlsAnswer) { | 1957 TEST_P(WebRtcSessionTest, TestReceiveDtlsOfferCreateDtlsAnswer) { |
| 1815 SendAudioVideoStream1(); | 1958 SendAudioVideoStream1(); |
| 1816 InitWithDtls(GetParam()); | 1959 InitWithDtls(GetParam()); |
| 1817 SetFactoryDtlsSrtp(); | 1960 SetFactoryDtlsSrtp(); |
| 1818 cricket::MediaSessionOptions options; | 1961 cricket::MediaSessionOptions options; |
| 1819 options.recv_video = true; | 1962 GetOptionsForRemoteOffer(&options); |
| 1820 JsepSessionDescription* offer = | 1963 JsepSessionDescription* offer = |
| 1821 CreateRemoteOffer(options, cricket::SEC_DISABLED); | 1964 CreateRemoteOffer(options, cricket::SEC_DISABLED); |
| 1822 ASSERT_TRUE(offer != NULL); | 1965 ASSERT_TRUE(offer != NULL); |
| 1823 VerifyFingerprintStatus(offer->description(), true); | 1966 VerifyFingerprintStatus(offer->description(), true); |
| 1824 VerifyNoCryptoParams(offer->description(), true); | 1967 VerifyNoCryptoParams(offer->description(), true); |
| 1825 | 1968 |
| 1826 // SetRemoteDescription will take the ownership of the offer. | 1969 // SetRemoteDescription will take the ownership of the offer. |
| 1827 SetRemoteDescriptionWithoutError(offer); | 1970 SetRemoteDescriptionWithoutError(offer); |
| 1828 | 1971 |
| 1829 // Verify that we get a crypto fingerprint in the answer. | 1972 // Verify that we get a crypto fingerprint in the answer. |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 1848 SessionDescriptionInterface* offer = CreateOffer(); | 1991 SessionDescriptionInterface* offer = CreateOffer(); |
| 1849 ASSERT_TRUE(offer != NULL); | 1992 ASSERT_TRUE(offer != NULL); |
| 1850 VerifyFingerprintStatus(offer->description(), true); | 1993 VerifyFingerprintStatus(offer->description(), true); |
| 1851 // Check that we don't have an a=crypto line in the offer. | 1994 // Check that we don't have an a=crypto line in the offer. |
| 1852 VerifyNoCryptoParams(offer->description(), true); | 1995 VerifyNoCryptoParams(offer->description(), true); |
| 1853 | 1996 |
| 1854 // Now set the local description, which should work, even without a=crypto. | 1997 // Now set the local description, which should work, even without a=crypto. |
| 1855 SetLocalDescriptionWithoutError(offer); | 1998 SetLocalDescriptionWithoutError(offer); |
| 1856 | 1999 |
| 1857 cricket::MediaSessionOptions options; | 2000 cricket::MediaSessionOptions options; |
| 1858 options.recv_video = true; | 2001 GetOptionsForAnswer(&options); |
| 1859 JsepSessionDescription* answer = | 2002 JsepSessionDescription* answer = |
| 1860 CreateRemoteAnswer(offer, options, cricket::SEC_DISABLED); | 2003 CreateRemoteAnswer(offer, options, cricket::SEC_DISABLED); |
| 1861 ASSERT_TRUE(answer != NULL); | 2004 ASSERT_TRUE(answer != NULL); |
| 1862 VerifyFingerprintStatus(answer->description(), true); | 2005 VerifyFingerprintStatus(answer->description(), true); |
| 1863 VerifyNoCryptoParams(answer->description(), true); | 2006 VerifyNoCryptoParams(answer->description(), true); |
| 1864 | 2007 |
| 1865 // SetRemoteDescription will take the ownership of the answer. | 2008 // SetRemoteDescription will take the ownership of the answer. |
| 1866 SetRemoteDescriptionWithoutError(answer); | 2009 SetRemoteDescriptionWithoutError(answer); |
| 1867 } | 2010 } |
| 1868 | 2011 |
| 1869 // Test that if we support DTLS and the other side didn't offer a fingerprint, | 2012 // Test that if we support DTLS and the other side didn't offer a fingerprint, |
| 1870 // we will fail to set the remote description. | 2013 // we will fail to set the remote description. |
| 1871 TEST_P(WebRtcSessionTest, TestReceiveNonDtlsOfferWhenDtlsOn) { | 2014 TEST_P(WebRtcSessionTest, TestReceiveNonDtlsOfferWhenDtlsOn) { |
| 1872 InitWithDtls(GetParam()); | 2015 InitWithDtls(GetParam()); |
| 1873 cricket::MediaSessionOptions options; | 2016 cricket::MediaSessionOptions options; |
| 1874 options.recv_video = true; | 2017 GetOptionsForRemoteOffer(&options); |
| 1875 options.bundle_enabled = true; | 2018 options.bundle_enabled = true; |
| 1876 JsepSessionDescription* offer = CreateRemoteOffer( | 2019 JsepSessionDescription* offer = CreateRemoteOffer( |
| 1877 options, cricket::SEC_REQUIRED); | 2020 options, cricket::SEC_REQUIRED); |
| 1878 ASSERT_TRUE(offer != NULL); | 2021 ASSERT_TRUE(offer != NULL); |
| 1879 VerifyFingerprintStatus(offer->description(), false); | 2022 VerifyFingerprintStatus(offer->description(), false); |
| 1880 VerifyCryptoParams(offer->description()); | 2023 VerifyCryptoParams(offer->description()); |
| 1881 | 2024 |
| 1882 // SetRemoteDescription will take the ownership of the offer. | 2025 // SetRemoteDescription will take the ownership of the offer. |
| 1883 SetRemoteDescriptionOfferExpectError( | 2026 SetRemoteDescriptionOfferExpectError( |
| 1884 kSdpWithoutDtlsFingerprint, offer); | 2027 kSdpWithoutDtlsFingerprint, offer); |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 1902 SetRemoteDescriptionWithoutError(offer); | 2045 SetRemoteDescriptionWithoutError(offer); |
| 1903 SetLocalDescriptionAnswerExpectError( | 2046 SetLocalDescriptionAnswerExpectError( |
| 1904 kSdpWithoutDtlsFingerprint, answer); | 2047 kSdpWithoutDtlsFingerprint, answer); |
| 1905 } | 2048 } |
| 1906 | 2049 |
| 1907 // Test that we return a failure when applying a remote answer that doesn't have | 2050 // Test that we return a failure when applying a remote answer that doesn't have |
| 1908 // a DTLS fingerprint when DTLS is required. | 2051 // a DTLS fingerprint when DTLS is required. |
| 1909 TEST_P(WebRtcSessionTest, TestSetRemoteNonDtlsAnswerWhenDtlsOn) { | 2052 TEST_P(WebRtcSessionTest, TestSetRemoteNonDtlsAnswerWhenDtlsOn) { |
| 1910 InitWithDtls(GetParam()); | 2053 InitWithDtls(GetParam()); |
| 1911 SessionDescriptionInterface* offer = CreateOffer(); | 2054 SessionDescriptionInterface* offer = CreateOffer(); |
| 1912 cricket::MediaSessionOptions options; | 2055 cricket::MediaSessionOptions offer_options; |
| 1913 options.recv_video = true; | 2056 GetOptionsForRemoteOffer(&offer_options); |
| 2057 | |
| 1914 std::unique_ptr<SessionDescriptionInterface> temp_offer( | 2058 std::unique_ptr<SessionDescriptionInterface> temp_offer( |
| 1915 CreateRemoteOffer(options, cricket::SEC_ENABLED)); | 2059 CreateRemoteOffer(offer_options, cricket::SEC_ENABLED)); |
| 1916 JsepSessionDescription* answer = | 2060 |
| 1917 CreateRemoteAnswer(temp_offer.get(), options, cricket::SEC_ENABLED); | 2061 cricket::MediaSessionOptions answer_options; |
| 2062 GetOptionsForAnswer(&answer_options); | |
| 2063 JsepSessionDescription* answer = CreateRemoteAnswer( | |
| 2064 temp_offer.get(), answer_options, cricket::SEC_ENABLED); | |
| 1918 | 2065 |
| 1919 // SetRemoteDescription and SetLocalDescription will take the ownership of | 2066 // SetRemoteDescription and SetLocalDescription will take the ownership of |
| 1920 // the offer and answer. | 2067 // the offer and answer. |
| 1921 SetLocalDescriptionWithoutError(offer); | 2068 SetLocalDescriptionWithoutError(offer); |
| 1922 SetRemoteDescriptionAnswerExpectError( | 2069 SetRemoteDescriptionAnswerExpectError( |
| 1923 kSdpWithoutDtlsFingerprint, answer); | 2070 kSdpWithoutDtlsFingerprint, answer); |
| 1924 } | 2071 } |
| 1925 | 2072 |
| 1926 // Test that we create a local offer without SDES or DTLS and accept a remote | 2073 // Test that we create a local offer without SDES or DTLS and accept a remote |
| 1927 // answer without SDES or DTLS when encryption is disabled. | 2074 // answer without SDES or DTLS when encryption is disabled. |
| 1928 TEST_P(WebRtcSessionTest, TestCreateOfferReceiveAnswerWithoutEncryption) { | 2075 TEST_P(WebRtcSessionTest, TestCreateOfferReceiveAnswerWithoutEncryption) { |
| 1929 SendAudioVideoStream1(); | 2076 SendAudioVideoStream1(); |
| 1930 options_.disable_encryption = true; | 2077 options_.disable_encryption = true; |
| 1931 InitWithDtls(GetParam()); | 2078 InitWithDtls(GetParam()); |
| 1932 | 2079 |
| 1933 // Verify that we get a crypto fingerprint in the answer. | 2080 // Verify that we get a crypto fingerprint in the answer. |
| 1934 SessionDescriptionInterface* offer = CreateOffer(); | 2081 SessionDescriptionInterface* offer = CreateOffer(); |
| 1935 ASSERT_TRUE(offer != NULL); | 2082 ASSERT_TRUE(offer != NULL); |
| 1936 VerifyFingerprintStatus(offer->description(), false); | 2083 VerifyFingerprintStatus(offer->description(), false); |
| 1937 // Check that we don't have an a=crypto line in the offer. | 2084 // Check that we don't have an a=crypto line in the offer. |
| 1938 VerifyNoCryptoParams(offer->description(), false); | 2085 VerifyNoCryptoParams(offer->description(), false); |
| 1939 | 2086 |
| 1940 // Now set the local description, which should work, even without a=crypto. | 2087 // Now set the local description, which should work, even without a=crypto. |
| 1941 SetLocalDescriptionWithoutError(offer); | 2088 SetLocalDescriptionWithoutError(offer); |
| 1942 | 2089 |
| 1943 cricket::MediaSessionOptions options; | 2090 cricket::MediaSessionOptions options; |
| 1944 options.recv_video = true; | 2091 GetOptionsForAnswer(&options); |
| 1945 JsepSessionDescription* answer = | 2092 JsepSessionDescription* answer = |
| 1946 CreateRemoteAnswer(offer, options, cricket::SEC_DISABLED); | 2093 CreateRemoteAnswer(offer, options, cricket::SEC_DISABLED); |
| 1947 ASSERT_TRUE(answer != NULL); | 2094 ASSERT_TRUE(answer != NULL); |
| 1948 VerifyFingerprintStatus(answer->description(), false); | 2095 VerifyFingerprintStatus(answer->description(), false); |
| 1949 VerifyNoCryptoParams(answer->description(), false); | 2096 VerifyNoCryptoParams(answer->description(), false); |
| 1950 | 2097 |
| 1951 // SetRemoteDescription will take the ownership of the answer. | 2098 // SetRemoteDescription will take the ownership of the answer. |
| 1952 SetRemoteDescriptionWithoutError(answer); | 2099 SetRemoteDescriptionWithoutError(answer); |
| 1953 } | 2100 } |
| 1954 | 2101 |
| 1955 // Test that we create a local answer without SDES or DTLS and accept a remote | 2102 // Test that we create a local answer without SDES or DTLS and accept a remote |
| 1956 // offer without SDES or DTLS when encryption is disabled. | 2103 // offer without SDES or DTLS when encryption is disabled. |
| 1957 TEST_P(WebRtcSessionTest, TestCreateAnswerReceiveOfferWithoutEncryption) { | 2104 TEST_P(WebRtcSessionTest, TestCreateAnswerReceiveOfferWithoutEncryption) { |
| 1958 options_.disable_encryption = true; | 2105 options_.disable_encryption = true; |
| 1959 InitWithDtls(GetParam()); | 2106 InitWithDtls(GetParam()); |
| 1960 | 2107 |
| 1961 cricket::MediaSessionOptions options; | 2108 cricket::MediaSessionOptions options; |
| 1962 options.recv_video = true; | 2109 GetOptionsForRemoteOffer(&options); |
| 1963 JsepSessionDescription* offer = | 2110 JsepSessionDescription* offer = |
| 1964 CreateRemoteOffer(options, cricket::SEC_DISABLED); | 2111 CreateRemoteOffer(options, cricket::SEC_DISABLED); |
| 1965 ASSERT_TRUE(offer != NULL); | 2112 ASSERT_TRUE(offer != NULL); |
| 1966 VerifyFingerprintStatus(offer->description(), false); | 2113 VerifyFingerprintStatus(offer->description(), false); |
| 1967 VerifyNoCryptoParams(offer->description(), false); | 2114 VerifyNoCryptoParams(offer->description(), false); |
| 1968 | 2115 |
| 1969 // SetRemoteDescription will take the ownership of the offer. | 2116 // SetRemoteDescription will take the ownership of the offer. |
| 1970 SetRemoteDescriptionWithoutError(offer); | 2117 SetRemoteDescriptionWithoutError(offer); |
| 1971 | 2118 |
| 1972 // Verify that we get a crypto fingerprint in the answer. | 2119 // Verify that we get a crypto fingerprint in the answer. |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 1985 // See: https://bugs.chromium.org/p/webrtc/issues/detail?id=4525 | 2132 // See: https://bugs.chromium.org/p/webrtc/issues/detail?id=4525 |
| 1986 TEST_P(WebRtcSessionTest, TestCreateAnswerWithDifferentSslRoles) { | 2133 TEST_P(WebRtcSessionTest, TestCreateAnswerWithDifferentSslRoles) { |
| 1987 SendAudioVideoStream1(); | 2134 SendAudioVideoStream1(); |
| 1988 InitWithDtls(GetParam()); | 2135 InitWithDtls(GetParam()); |
| 1989 SetFactoryDtlsSrtp(); | 2136 SetFactoryDtlsSrtp(); |
| 1990 | 2137 |
| 1991 SessionDescriptionInterface* offer = CreateOffer(); | 2138 SessionDescriptionInterface* offer = CreateOffer(); |
| 1992 SetLocalDescriptionWithoutError(offer); | 2139 SetLocalDescriptionWithoutError(offer); |
| 1993 | 2140 |
| 1994 cricket::MediaSessionOptions options; | 2141 cricket::MediaSessionOptions options; |
| 1995 options.recv_video = true; | 2142 GetOptionsForAnswer(&options); |
| 1996 | 2143 |
| 1997 // First, negotiate different SSL roles. | 2144 // First, negotiate different SSL roles. |
| 1998 SessionDescriptionInterface* answer = | 2145 SessionDescriptionInterface* answer = |
| 1999 CreateRemoteAnswer(offer, options, cricket::SEC_DISABLED); | 2146 CreateRemoteAnswer(offer, options, cricket::SEC_DISABLED); |
| 2000 TransportInfo* audio_transport_info = | 2147 TransportInfo* audio_transport_info = |
| 2001 answer->description()->GetTransportInfoByName("audio"); | 2148 answer->description()->GetTransportInfoByName("audio"); |
| 2002 audio_transport_info->description.connection_role = | 2149 audio_transport_info->description.connection_role = |
| 2003 cricket::CONNECTIONROLE_ACTIVE; | 2150 cricket::CONNECTIONROLE_ACTIVE; |
| 2004 TransportInfo* video_transport_info = | 2151 TransportInfo* video_transport_info = |
| 2005 answer->description()->GetTransportInfoByName("video"); | 2152 answer->description()->GetTransportInfoByName("video"); |
| 2006 video_transport_info->description.connection_role = | 2153 video_transport_info->description.connection_role = |
| 2007 cricket::CONNECTIONROLE_PASSIVE; | 2154 cricket::CONNECTIONROLE_PASSIVE; |
| 2008 SetRemoteDescriptionWithoutError(answer); | 2155 SetRemoteDescriptionWithoutError(answer); |
| 2009 | 2156 |
| 2010 // Now create an offer in the reverse direction, and ensure the initial | 2157 // Now create an offer in the reverse direction, and ensure the initial |
| 2011 // offerer responds with an answer with correct SSL roles. | 2158 // offerer responds with an answer with correct SSL roles. |
| 2012 offer = CreateRemoteOfferWithVersion(options, cricket::SEC_DISABLED, | 2159 offer = CreateRemoteOfferWithVersion(options, cricket::SEC_DISABLED, |
| 2013 kSessionVersion, | 2160 kSessionVersion, |
| 2014 session_->remote_description()); | 2161 session_->remote_description()); |
| 2015 SetRemoteDescriptionWithoutError(offer); | 2162 SetRemoteDescriptionWithoutError(offer); |
| 2016 | 2163 |
| 2017 answer = CreateAnswer(); | 2164 cricket::MediaSessionOptions answer_options; |
| 2165 answer_options.bundle_enabled = true; | |
| 2166 answer = CreateAnswer(answer_options); | |
| 2018 audio_transport_info = answer->description()->GetTransportInfoByName("audio"); | 2167 audio_transport_info = answer->description()->GetTransportInfoByName("audio"); |
| 2019 EXPECT_EQ(cricket::CONNECTIONROLE_PASSIVE, | 2168 EXPECT_EQ(cricket::CONNECTIONROLE_PASSIVE, |
| 2020 audio_transport_info->description.connection_role); | 2169 audio_transport_info->description.connection_role); |
| 2021 video_transport_info = answer->description()->GetTransportInfoByName("video"); | 2170 video_transport_info = answer->description()->GetTransportInfoByName("video"); |
| 2022 EXPECT_EQ(cricket::CONNECTIONROLE_ACTIVE, | 2171 EXPECT_EQ(cricket::CONNECTIONROLE_ACTIVE, |
| 2023 video_transport_info->description.connection_role); | 2172 video_transport_info->description.connection_role); |
| 2024 SetLocalDescriptionWithoutError(answer); | 2173 SetLocalDescriptionWithoutError(answer); |
| 2025 | 2174 |
| 2026 // Lastly, start BUNDLE-ing on "audio", expecting that the "passive" role of | 2175 // Lastly, start BUNDLE-ing on "audio", expecting that the "passive" role of |
| 2027 // audio is transferred over to video in the answer that completes the BUNDLE | 2176 // audio is transferred over to video in the answer that completes the BUNDLE |
| 2028 // negotiation. | 2177 // negotiation. |
| 2029 options.bundle_enabled = true; | 2178 options.bundle_enabled = true; |
| 2030 offer = CreateRemoteOfferWithVersion(options, cricket::SEC_DISABLED, | 2179 offer = CreateRemoteOfferWithVersion(options, cricket::SEC_DISABLED, |
| 2031 kSessionVersion, | 2180 kSessionVersion, |
| 2032 session_->remote_description()); | 2181 session_->remote_description()); |
| 2033 SetRemoteDescriptionWithoutError(offer); | 2182 SetRemoteDescriptionWithoutError(offer); |
| 2034 answer = CreateAnswer(); | 2183 answer = CreateAnswer(answer_options); |
| 2035 audio_transport_info = answer->description()->GetTransportInfoByName("audio"); | 2184 audio_transport_info = answer->description()->GetTransportInfoByName("audio"); |
| 2036 EXPECT_EQ(cricket::CONNECTIONROLE_PASSIVE, | 2185 EXPECT_EQ(cricket::CONNECTIONROLE_PASSIVE, |
| 2037 audio_transport_info->description.connection_role); | 2186 audio_transport_info->description.connection_role); |
| 2038 video_transport_info = answer->description()->GetTransportInfoByName("video"); | 2187 video_transport_info = answer->description()->GetTransportInfoByName("video"); |
| 2039 EXPECT_EQ(cricket::CONNECTIONROLE_PASSIVE, | 2188 EXPECT_EQ(cricket::CONNECTIONROLE_PASSIVE, |
| 2040 video_transport_info->description.connection_role); | 2189 video_transport_info->description.connection_role); |
| 2041 SetLocalDescriptionWithoutError(answer); | 2190 SetLocalDescriptionWithoutError(answer); |
| 2042 } | 2191 } |
| 2043 | 2192 |
| 2044 TEST_F(WebRtcSessionTest, TestSetLocalOfferTwice) { | 2193 TEST_F(WebRtcSessionTest, TestSetLocalOfferTwice) { |
| (...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2385 // is called. | 2534 // is called. |
| 2386 EXPECT_EQ(0u, observer_.mline_0_candidates_.size()); | 2535 EXPECT_EQ(0u, observer_.mline_0_candidates_.size()); |
| 2387 EXPECT_EQ(0u, observer_.mline_1_candidates_.size()); | 2536 EXPECT_EQ(0u, observer_.mline_1_candidates_.size()); |
| 2388 CreateAndSetRemoteOfferAndLocalAnswer(); | 2537 CreateAndSetRemoteOfferAndLocalAnswer(); |
| 2389 // Wait until at least one local candidate has been collected. | 2538 // Wait until at least one local candidate has been collected. |
| 2390 EXPECT_TRUE_WAIT(0u < observer_.mline_0_candidates_.size(), | 2539 EXPECT_TRUE_WAIT(0u < observer_.mline_0_candidates_.size(), |
| 2391 kIceCandidatesTimeout); | 2540 kIceCandidatesTimeout); |
| 2392 | 2541 |
| 2393 std::unique_ptr<SessionDescriptionInterface> local_offer(CreateOffer()); | 2542 std::unique_ptr<SessionDescriptionInterface> local_offer(CreateOffer()); |
| 2394 | 2543 |
| 2544 ASSERT_TRUE(local_offer); | |
| 2395 ASSERT_TRUE(local_offer->candidates(kMediaContentIndex0) != NULL); | 2545 ASSERT_TRUE(local_offer->candidates(kMediaContentIndex0) != NULL); |
| 2396 EXPECT_LT(0u, local_offer->candidates(kMediaContentIndex0)->count()); | 2546 EXPECT_LT(0u, local_offer->candidates(kMediaContentIndex0)->count()); |
| 2397 | 2547 |
| 2398 SessionDescriptionInterface* remote_offer(CreateRemoteOffer()); | 2548 SessionDescriptionInterface* remote_offer(CreateRemoteOffer()); |
| 2399 SetRemoteDescriptionWithoutError(remote_offer); | 2549 SetRemoteDescriptionWithoutError(remote_offer); |
| 2400 SessionDescriptionInterface* answer = CreateAnswer(); | 2550 SessionDescriptionInterface* answer = CreateAnswer(); |
| 2401 ASSERT_TRUE(answer->candidates(kMediaContentIndex0) != NULL); | 2551 ASSERT_TRUE(answer->candidates(kMediaContentIndex0) != NULL); |
| 2402 EXPECT_LT(0u, answer->candidates(kMediaContentIndex0)->count()); | 2552 EXPECT_LT(0u, answer->candidates(kMediaContentIndex0)->count()); |
| 2403 SetLocalDescriptionWithoutError(answer); | 2553 SetLocalDescriptionWithoutError(answer); |
| 2404 } | 2554 } |
| 2405 | 2555 |
| 2406 // Verifies TransportProxy and media channels are created with content names | 2556 // Verifies TransportProxy and media channels are created with content names |
| 2407 // present in the SessionDescription. | 2557 // present in the SessionDescription. |
| 2408 TEST_F(WebRtcSessionTest, TestChannelCreationsWithContentNames) { | 2558 TEST_F(WebRtcSessionTest, TestChannelCreationsWithContentNames) { |
| 2409 Init(); | 2559 Init(); |
| 2410 SendAudioVideoStream1(); | 2560 SendAudioVideoStream1(); |
| 2411 std::unique_ptr<SessionDescriptionInterface> offer(CreateOffer()); | 2561 std::unique_ptr<SessionDescriptionInterface> offer(CreateOffer()); |
| 2412 | 2562 |
| 2413 // CreateOffer creates session description with the content names "audio" and | 2563 // CreateOffer creates session description with the content names "audio" and |
| 2414 // "video". Goal is to modify these content names and verify transport | 2564 // "video". Goal is to modify these content names and verify transport |
| 2415 // channels | 2565 // channels |
| 2416 // in the WebRtcSession, as channels are created with the content names | 2566 // in the WebRtcSession, as channels are created with the content names |
| 2417 // present in SDP. | 2567 // present in SDP. |
| 2418 std::string sdp; | 2568 std::string sdp; |
| 2419 EXPECT_TRUE(offer->ToString(&sdp)); | 2569 EXPECT_TRUE(offer->ToString(&sdp)); |
| 2420 const std::string kAudioMid = "a=mid:audio"; | |
| 2421 const std::string kAudioMidReplaceStr = "a=mid:audio_content_name"; | |
| 2422 const std::string kVideoMid = "a=mid:video"; | |
| 2423 const std::string kVideoMidReplaceStr = "a=mid:video_content_name"; | |
| 2424 | |
| 2425 // Replacing |audio| with |audio_content_name|. | |
| 2426 rtc::replace_substrs(kAudioMid.c_str(), kAudioMid.length(), | |
| 2427 kAudioMidReplaceStr.c_str(), | |
| 2428 kAudioMidReplaceStr.length(), | |
| 2429 &sdp); | |
| 2430 // Replacing |video| with |video_content_name|. | |
| 2431 rtc::replace_substrs(kVideoMid.c_str(), kVideoMid.length(), | |
| 2432 kVideoMidReplaceStr.c_str(), | |
| 2433 kVideoMidReplaceStr.length(), | |
| 2434 &sdp); | |
| 2435 | 2570 |
| 2436 SessionDescriptionInterface* modified_offer = | 2571 SessionDescriptionInterface* modified_offer = |
| 2437 CreateSessionDescription(JsepSessionDescription::kOffer, sdp, NULL); | 2572 CreateSessionDescription(JsepSessionDescription::kOffer, sdp, NULL); |
| 2438 | 2573 |
| 2439 SetRemoteDescriptionWithoutError(modified_offer); | 2574 SetRemoteDescriptionWithoutError(modified_offer); |
| 2440 | 2575 |
| 2441 SessionDescriptionInterface* answer = CreateAnswer(); | 2576 cricket::MediaSessionOptions answer_options; |
| 2577 answer_options.bundle_enabled = false; | |
| 2578 SessionDescriptionInterface* answer = CreateAnswer(answer_options); | |
| 2442 SetLocalDescriptionWithoutError(answer); | 2579 SetLocalDescriptionWithoutError(answer); |
| 2443 | 2580 |
| 2444 rtc::PacketTransportInternal* voice_transport_channel = | 2581 rtc::PacketTransportInternal* voice_transport_channel = |
| 2445 session_->voice_rtp_transport_channel(); | 2582 session_->voice_rtp_transport_channel(); |
| 2446 EXPECT_TRUE(voice_transport_channel != NULL); | 2583 EXPECT_TRUE(voice_transport_channel != NULL); |
| 2447 EXPECT_EQ(voice_transport_channel->debug_name(), | 2584 EXPECT_EQ(voice_transport_channel->debug_name(), |
| 2448 "audio_content_name " + | 2585 "audio " + std::to_string(cricket::ICE_CANDIDATE_COMPONENT_RTP)); |
| 2449 std::to_string(cricket::ICE_CANDIDATE_COMPONENT_RTP)); | |
| 2450 rtc::PacketTransportInternal* video_transport_channel = | 2586 rtc::PacketTransportInternal* video_transport_channel = |
| 2451 session_->video_rtp_transport_channel(); | 2587 session_->video_rtp_transport_channel(); |
| 2452 ASSERT_TRUE(video_transport_channel != NULL); | 2588 ASSERT_TRUE(video_transport_channel != NULL); |
| 2453 EXPECT_EQ(video_transport_channel->debug_name(), | 2589 EXPECT_EQ(video_transport_channel->debug_name(), |
| 2454 "video_content_name " + | 2590 "video " + std::to_string(cricket::ICE_CANDIDATE_COMPONENT_RTP)); |
| 2455 std::to_string(cricket::ICE_CANDIDATE_COMPONENT_RTP)); | |
| 2456 EXPECT_TRUE((video_channel_ = media_engine_->GetVideoChannel(0)) != NULL); | 2591 EXPECT_TRUE((video_channel_ = media_engine_->GetVideoChannel(0)) != NULL); |
| 2457 EXPECT_TRUE((voice_channel_ = media_engine_->GetVoiceChannel(0)) != NULL); | 2592 EXPECT_TRUE((voice_channel_ = media_engine_->GetVoiceChannel(0)) != NULL); |
| 2458 } | 2593 } |
| 2459 | 2594 |
| 2460 // Test that an offer contains the correct media content descriptions based on | 2595 // Test that an offer contains the correct media content descriptions based on |
| 2461 // the send streams when no constraints have been set. | 2596 // the send streams when no constraints have been set. |
| 2462 TEST_F(WebRtcSessionTest, CreateOfferWithoutConstraintsOrStreams) { | 2597 TEST_F(WebRtcSessionTest, CreateOfferWithoutConstraintsOrStreams) { |
| 2463 Init(); | 2598 Init(); |
| 2464 std::unique_ptr<SessionDescriptionInterface> offer(CreateOffer()); | 2599 std::unique_ptr<SessionDescriptionInterface> offer(CreateOffer()); |
| 2465 | 2600 |
| 2466 ASSERT_TRUE(offer != NULL); | 2601 ASSERT_TRUE(offer != NULL); |
| 2467 const cricket::ContentInfo* content = | 2602 const cricket::ContentInfo* content = |
| 2468 cricket::GetFirstAudioContent(offer->description()); | 2603 cricket::GetFirstAudioContent(offer->description()); |
| 2469 EXPECT_TRUE(content != NULL); | 2604 ASSERT_TRUE(content != NULL); |
| 2605 EXPECT_EQ( | |
| 2606 cricket::MD_RECVONLY, | |
| 2607 static_cast<const cricket::AudioContentDescription*>(content->description) | |
| 2608 ->direction()); | |
| 2470 content = cricket::GetFirstVideoContent(offer->description()); | 2609 content = cricket::GetFirstVideoContent(offer->description()); |
| 2471 EXPECT_TRUE(content == NULL); | 2610 ASSERT_TRUE(content != NULL); |
| 2611 EXPECT_EQ( | |
| 2612 cricket::MD_RECVONLY, | |
| 2613 static_cast<const cricket::VideoContentDescription*>(content->description) | |
| 2614 ->direction()); | |
| 2472 } | 2615 } |
| 2473 | 2616 |
| 2474 // Test that an offer contains the correct media content descriptions based on | 2617 // Test that an offer contains the correct media content descriptions based on |
| 2475 // the send streams when no constraints have been set. | 2618 // the send streams when no constraints have been set. |
| 2476 TEST_F(WebRtcSessionTest, CreateOfferWithoutConstraints) { | 2619 TEST_F(WebRtcSessionTest, CreateOfferWithoutConstraints) { |
| 2477 Init(); | 2620 Init(); |
| 2478 // Test Audio only offer. | 2621 // Test Audio only offer. |
| 2479 SendAudioOnlyStream2(); | 2622 SendAudioOnlyStream2(); |
| 2480 std::unique_ptr<SessionDescriptionInterface> offer(CreateOffer()); | 2623 std::unique_ptr<SessionDescriptionInterface> offer(CreateOffer()); |
| 2481 | 2624 |
| 2482 const cricket::ContentInfo* content = | 2625 const cricket::ContentInfo* content = |
| 2483 cricket::GetFirstAudioContent(offer->description()); | 2626 cricket::GetFirstAudioContent(offer->description()); |
| 2484 EXPECT_TRUE(content != NULL); | 2627 ASSERT_TRUE(content != NULL); |
| 2628 EXPECT_EQ( | |
| 2629 cricket::MD_SENDRECV, | |
| 2630 static_cast<const cricket::AudioContentDescription*>(content->description) | |
| 2631 ->direction()); | |
| 2485 content = cricket::GetFirstVideoContent(offer->description()); | 2632 content = cricket::GetFirstVideoContent(offer->description()); |
| 2486 EXPECT_TRUE(content == NULL); | 2633 ASSERT_TRUE(content != NULL); |
| 2634 EXPECT_EQ( | |
| 2635 cricket::MD_RECVONLY, | |
| 2636 static_cast<const cricket::VideoContentDescription*>(content->description) | |
| 2637 ->direction()); | |
| 2487 | 2638 |
| 2488 // Test Audio / Video offer. | 2639 // Test Audio / Video offer. |
| 2489 SendAudioVideoStream1(); | 2640 SendAudioVideoStream1(); |
| 2490 offer.reset(CreateOffer()); | 2641 offer.reset(CreateOffer()); |
| 2491 content = cricket::GetFirstAudioContent(offer->description()); | 2642 content = cricket::GetFirstAudioContent(offer->description()); |
| 2492 EXPECT_TRUE(content != NULL); | 2643 ASSERT_TRUE(content != NULL); |
| 2644 EXPECT_EQ( | |
| 2645 cricket::MD_SENDRECV, | |
| 2646 static_cast<const cricket::AudioContentDescription*>(content->description) | |
| 2647 ->direction()); | |
| 2648 | |
| 2493 content = cricket::GetFirstVideoContent(offer->description()); | 2649 content = cricket::GetFirstVideoContent(offer->description()); |
| 2494 EXPECT_TRUE(content != NULL); | 2650 ASSERT_TRUE(content != NULL); |
| 2651 EXPECT_EQ( | |
| 2652 cricket::MD_SENDRECV, | |
| 2653 static_cast<const cricket::VideoContentDescription*>(content->description) | |
| 2654 ->direction()); | |
| 2495 } | 2655 } |
| 2496 | 2656 |
| 2497 // Test that an offer contains no media content descriptions if | 2657 // Test that an offer contains no media content descriptions if |
| 2498 // kOfferToReceiveVideo and kOfferToReceiveAudio constraints are set to false. | 2658 // kOfferToReceiveVideo and kOfferToReceiveAudio constraints are set to false. |
| 2499 TEST_F(WebRtcSessionTest, CreateOfferWithConstraintsWithoutStreams) { | 2659 TEST_F(WebRtcSessionTest, CreateOfferWithConstraintsWithoutStreams) { |
| 2500 Init(); | 2660 Init(); |
| 2501 PeerConnectionInterface::RTCOfferAnswerOptions options; | 2661 PeerConnectionInterface::RTCOfferAnswerOptions options; |
| 2502 options.offer_to_receive_audio = 0; | 2662 options.offer_to_receive_audio = 0; |
| 2503 options.offer_to_receive_video = 0; | 2663 options.offer_to_receive_video = 0; |
| 2504 | 2664 |
| 2505 std::unique_ptr<SessionDescriptionInterface> offer(CreateOffer(options)); | 2665 std::unique_ptr<SessionDescriptionInterface> offer(CreateOffer(options)); |
| 2506 | 2666 |
| 2507 ASSERT_TRUE(offer != NULL); | 2667 ASSERT_TRUE(offer != NULL); |
| 2508 const cricket::ContentInfo* content = | 2668 const cricket::ContentInfo* content = |
| 2509 cricket::GetFirstAudioContent(offer->description()); | 2669 cricket::GetFirstAudioContent(offer->description()); |
| 2510 EXPECT_TRUE(content == NULL); | 2670 EXPECT_TRUE(content == NULL); |
| 2511 content = cricket::GetFirstVideoContent(offer->description()); | 2671 content = cricket::GetFirstVideoContent(offer->description()); |
| 2512 EXPECT_TRUE(content == NULL); | 2672 EXPECT_TRUE(content == NULL); |
| 2513 } | 2673 } |
| 2514 | 2674 |
| 2515 // Test that an offer contains only audio media content descriptions if | 2675 // Test that an offer contains only audio media content descriptions if |
| 2516 // kOfferToReceiveAudio constraints are set to true. | 2676 // kOfferToReceiveAudio constraints are set to true. |
| 2517 TEST_F(WebRtcSessionTest, CreateAudioOnlyOfferWithConstraints) { | 2677 TEST_F(WebRtcSessionTest, CreateAudioOnlyOfferWithConstraints) { |
| 2518 Init(); | 2678 Init(); |
| 2519 PeerConnectionInterface::RTCOfferAnswerOptions options; | 2679 PeerConnectionInterface::RTCOfferAnswerOptions options; |
| 2520 options.offer_to_receive_audio = | 2680 options.offer_to_receive_audio = |
| 2521 RTCOfferAnswerOptions::kOfferToReceiveMediaTrue; | 2681 RTCOfferAnswerOptions::kOfferToReceiveMediaTrue; |
| 2682 options.offer_to_receive_video = 0; | |
| 2522 | 2683 |
| 2523 std::unique_ptr<SessionDescriptionInterface> offer(CreateOffer(options)); | 2684 std::unique_ptr<SessionDescriptionInterface> offer(CreateOffer(options)); |
| 2524 | 2685 |
| 2525 const cricket::ContentInfo* content = | 2686 const cricket::ContentInfo* content = |
| 2526 cricket::GetFirstAudioContent(offer->description()); | 2687 cricket::GetFirstAudioContent(offer->description()); |
| 2527 EXPECT_TRUE(content != NULL); | 2688 EXPECT_TRUE(content != NULL); |
| 2528 content = cricket::GetFirstVideoContent(offer->description()); | 2689 content = cricket::GetFirstVideoContent(offer->description()); |
| 2529 EXPECT_TRUE(content == NULL); | 2690 EXPECT_TRUE(content == NULL); |
| 2530 } | 2691 } |
| 2531 | 2692 |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 2546 cricket::GetFirstAudioContent(offer->description()); | 2707 cricket::GetFirstAudioContent(offer->description()); |
| 2547 EXPECT_TRUE(content != NULL); | 2708 EXPECT_TRUE(content != NULL); |
| 2548 | 2709 |
| 2549 content = cricket::GetFirstVideoContent(offer->description()); | 2710 content = cricket::GetFirstVideoContent(offer->description()); |
| 2550 EXPECT_TRUE(content != NULL); | 2711 EXPECT_TRUE(content != NULL); |
| 2551 | 2712 |
| 2552 // Sets constraints to false and verifies that audio/video contents are | 2713 // Sets constraints to false and verifies that audio/video contents are |
| 2553 // removed. | 2714 // removed. |
| 2554 options.offer_to_receive_audio = 0; | 2715 options.offer_to_receive_audio = 0; |
| 2555 options.offer_to_receive_video = 0; | 2716 options.offer_to_receive_video = 0; |
| 2717 // Remove the media sections added in previous offer. | |
| 2718 offered_media_sections_.clear(); | |
| 2556 offer.reset(CreateOffer(options)); | 2719 offer.reset(CreateOffer(options)); |
| 2557 | 2720 |
| 2558 content = cricket::GetFirstAudioContent(offer->description()); | 2721 content = cricket::GetFirstAudioContent(offer->description()); |
| 2559 EXPECT_TRUE(content == NULL); | 2722 EXPECT_TRUE(content == NULL); |
| 2560 content = cricket::GetFirstVideoContent(offer->description()); | 2723 content = cricket::GetFirstVideoContent(offer->description()); |
| 2561 EXPECT_TRUE(content == NULL); | 2724 EXPECT_TRUE(content == NULL); |
| 2562 } | 2725 } |
| 2563 | 2726 |
| 2564 // Test that an answer can not be created if the last remote description is not | 2727 // Test that an answer can not be created if the last remote description is not |
| 2565 // an offer. | 2728 // an offer. |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 2589 ASSERT_TRUE(content != NULL); | 2752 ASSERT_TRUE(content != NULL); |
| 2590 EXPECT_FALSE(content->rejected); | 2753 EXPECT_FALSE(content->rejected); |
| 2591 } | 2754 } |
| 2592 | 2755 |
| 2593 // Test that an answer contains the correct media content descriptions when no | 2756 // Test that an answer contains the correct media content descriptions when no |
| 2594 // constraints have been set and the offer only contain audio. | 2757 // constraints have been set and the offer only contain audio. |
| 2595 TEST_F(WebRtcSessionTest, CreateAudioAnswerWithoutConstraintsOrStreams) { | 2758 TEST_F(WebRtcSessionTest, CreateAudioAnswerWithoutConstraintsOrStreams) { |
| 2596 Init(); | 2759 Init(); |
| 2597 // Create a remote offer with audio only. | 2760 // Create a remote offer with audio only. |
| 2598 cricket::MediaSessionOptions options; | 2761 cricket::MediaSessionOptions options; |
| 2762 GetOptionsForAudioOnlyRemoteOffer(&options); | |
| 2599 | 2763 |
| 2600 std::unique_ptr<JsepSessionDescription> offer(CreateRemoteOffer(options)); | 2764 std::unique_ptr<JsepSessionDescription> offer(CreateRemoteOffer(options)); |
| 2601 ASSERT_TRUE(cricket::GetFirstVideoContent(offer->description()) == NULL); | 2765 ASSERT_TRUE(cricket::GetFirstVideoContent(offer->description()) == NULL); |
| 2602 ASSERT_TRUE(cricket::GetFirstAudioContent(offer->description()) != NULL); | 2766 ASSERT_TRUE(cricket::GetFirstAudioContent(offer->description()) != NULL); |
| 2603 | 2767 |
| 2604 SetRemoteDescriptionWithoutError(offer.release()); | 2768 SetRemoteDescriptionWithoutError(offer.release()); |
| 2605 std::unique_ptr<SessionDescriptionInterface> answer(CreateAnswer()); | 2769 std::unique_ptr<SessionDescriptionInterface> answer(CreateAnswer()); |
| 2606 const cricket::ContentInfo* content = | 2770 const cricket::ContentInfo* content = |
| 2607 cricket::GetFirstAudioContent(answer->description()); | 2771 cricket::GetFirstAudioContent(answer->description()); |
| 2608 ASSERT_TRUE(content != NULL); | 2772 ASSERT_TRUE(content != NULL); |
| (...skipping 24 matching lines...) Expand all Loading... | |
| 2633 | 2797 |
| 2634 // Test that an answer contains the correct media content descriptions when | 2798 // Test that an answer contains the correct media content descriptions when |
| 2635 // constraints have been set but no stream is sent. | 2799 // constraints have been set but no stream is sent. |
| 2636 TEST_F(WebRtcSessionTest, CreateAnswerWithConstraintsWithoutStreams) { | 2800 TEST_F(WebRtcSessionTest, CreateAnswerWithConstraintsWithoutStreams) { |
| 2637 Init(); | 2801 Init(); |
| 2638 // Create a remote offer with audio and video content. | 2802 // Create a remote offer with audio and video content. |
| 2639 std::unique_ptr<JsepSessionDescription> offer(CreateRemoteOffer()); | 2803 std::unique_ptr<JsepSessionDescription> offer(CreateRemoteOffer()); |
| 2640 SetRemoteDescriptionWithoutError(offer.release()); | 2804 SetRemoteDescriptionWithoutError(offer.release()); |
| 2641 | 2805 |
| 2642 cricket::MediaSessionOptions session_options; | 2806 cricket::MediaSessionOptions session_options; |
| 2643 session_options.recv_audio = false; | 2807 recv_audio_ = false; |
| 2644 session_options.recv_video = false; | 2808 recv_video_ = false; |
| 2645 std::unique_ptr<SessionDescriptionInterface> answer( | 2809 std::unique_ptr<SessionDescriptionInterface> answer( |
| 2646 CreateAnswer(session_options)); | 2810 CreateAnswer(session_options)); |
| 2647 | 2811 |
| 2648 const cricket::ContentInfo* content = | 2812 const cricket::ContentInfo* content = |
| 2649 cricket::GetFirstAudioContent(answer->description()); | 2813 cricket::GetFirstAudioContent(answer->description()); |
| 2650 ASSERT_TRUE(content != NULL); | 2814 ASSERT_TRUE(content != NULL); |
| 2651 EXPECT_TRUE(content->rejected); | 2815 EXPECT_TRUE(content->rejected); |
| 2652 | 2816 |
| 2653 content = cricket::GetFirstVideoContent(answer->description()); | 2817 content = cricket::GetFirstVideoContent(answer->description()); |
| 2654 ASSERT_TRUE(content != NULL); | 2818 ASSERT_TRUE(content != NULL); |
| 2655 EXPECT_TRUE(content->rejected); | 2819 EXPECT_TRUE(content->rejected); |
| 2656 } | 2820 } |
| 2657 | 2821 |
| 2658 // Test that an answer contains the correct media content descriptions when | 2822 // Test that an answer contains the correct media content descriptions when |
| 2659 // constraints have been set and streams are sent. | 2823 // constraints have been set and streams are sent. |
| 2660 TEST_F(WebRtcSessionTest, CreateAnswerWithConstraints) { | 2824 TEST_F(WebRtcSessionTest, CreateAnswerWithConstraints) { |
| 2661 Init(); | 2825 Init(); |
| 2662 // Create a remote offer with audio and video content. | 2826 // Create a remote offer with audio and video content. |
| 2663 std::unique_ptr<JsepSessionDescription> offer(CreateRemoteOffer()); | 2827 std::unique_ptr<JsepSessionDescription> offer(CreateRemoteOffer()); |
| 2664 SetRemoteDescriptionWithoutError(offer.release()); | 2828 SetRemoteDescriptionWithoutError(offer.release()); |
| 2665 | 2829 |
| 2666 cricket::MediaSessionOptions options; | 2830 cricket::MediaSessionOptions options; |
| 2667 options.recv_audio = false; | |
| 2668 options.recv_video = false; | |
| 2669 | |
| 2670 // Test with a stream with tracks. | 2831 // Test with a stream with tracks. |
| 2671 SendAudioVideoStream1(); | 2832 SendAudioVideoStream1(); |
| 2672 std::unique_ptr<SessionDescriptionInterface> answer(CreateAnswer(options)); | 2833 std::unique_ptr<SessionDescriptionInterface> answer(CreateAnswer(options)); |
| 2673 | 2834 |
| 2674 // TODO(perkj): Should the direction be set to SEND_ONLY? | 2835 // TODO(perkj): Should the direction be set to SEND_ONLY? |
| 2675 const cricket::ContentInfo* content = | 2836 const cricket::ContentInfo* content = |
| 2676 cricket::GetFirstAudioContent(answer->description()); | 2837 cricket::GetFirstAudioContent(answer->description()); |
| 2677 ASSERT_TRUE(content != NULL); | 2838 ASSERT_TRUE(content != NULL); |
| 2678 EXPECT_FALSE(content->rejected); | 2839 EXPECT_FALSE(content->rejected); |
| 2679 | 2840 |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2719 // later updates with video. | 2880 // later updates with video. |
| 2720 TEST_F(WebRtcSessionTest, TestAVOfferWithAudioOnlyAnswer) { | 2881 TEST_F(WebRtcSessionTest, TestAVOfferWithAudioOnlyAnswer) { |
| 2721 Init(); | 2882 Init(); |
| 2722 EXPECT_TRUE(media_engine_->GetVideoChannel(0) == NULL); | 2883 EXPECT_TRUE(media_engine_->GetVideoChannel(0) == NULL); |
| 2723 EXPECT_TRUE(media_engine_->GetVoiceChannel(0) == NULL); | 2884 EXPECT_TRUE(media_engine_->GetVoiceChannel(0) == NULL); |
| 2724 | 2885 |
| 2725 SendAudioVideoStream1(); | 2886 SendAudioVideoStream1(); |
| 2726 SessionDescriptionInterface* offer = CreateOffer(); | 2887 SessionDescriptionInterface* offer = CreateOffer(); |
| 2727 | 2888 |
| 2728 cricket::MediaSessionOptions options; | 2889 cricket::MediaSessionOptions options; |
| 2890 AddMediaSection(cricket::MEDIA_TYPE_AUDIO, cricket::CN_AUDIO, false /*send*/, | |
| 2891 true /*recv*/, false, options); | |
| 2892 AddMediaSection(cricket::MEDIA_TYPE_VIDEO, cricket::CN_VIDEO, false /*send*/, | |
| 2893 false /*recv*/, true, options); | |
| 2729 SessionDescriptionInterface* answer = CreateRemoteAnswer(offer, options); | 2894 SessionDescriptionInterface* answer = CreateRemoteAnswer(offer, options); |
| 2730 | 2895 |
| 2731 // SetLocalDescription and SetRemoteDescriptions takes ownership of offer | 2896 // SetLocalDescription and SetRemoteDescriptions takes ownership of offer |
| 2732 // and answer; | 2897 // and answer; |
| 2733 SetLocalDescriptionWithoutError(offer); | 2898 SetLocalDescriptionWithoutError(offer); |
| 2734 SetRemoteDescriptionWithoutError(answer); | 2899 SetRemoteDescriptionWithoutError(answer); |
| 2735 | 2900 |
| 2736 video_channel_ = media_engine_->GetVideoChannel(0); | 2901 video_channel_ = media_engine_->GetVideoChannel(0); |
| 2737 voice_channel_ = media_engine_->GetVoiceChannel(0); | 2902 voice_channel_ = media_engine_->GetVoiceChannel(0); |
| 2738 | 2903 |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2775 // This test verifies the call setup when remote answer with video only and | 2940 // This test verifies the call setup when remote answer with video only and |
| 2776 // later updates with audio. | 2941 // later updates with audio. |
| 2777 TEST_F(WebRtcSessionTest, TestAVOfferWithVideoOnlyAnswer) { | 2942 TEST_F(WebRtcSessionTest, TestAVOfferWithVideoOnlyAnswer) { |
| 2778 Init(); | 2943 Init(); |
| 2779 EXPECT_TRUE(media_engine_->GetVideoChannel(0) == NULL); | 2944 EXPECT_TRUE(media_engine_->GetVideoChannel(0) == NULL); |
| 2780 EXPECT_TRUE(media_engine_->GetVoiceChannel(0) == NULL); | 2945 EXPECT_TRUE(media_engine_->GetVoiceChannel(0) == NULL); |
| 2781 SendAudioVideoStream1(); | 2946 SendAudioVideoStream1(); |
| 2782 SessionDescriptionInterface* offer = CreateOffer(); | 2947 SessionDescriptionInterface* offer = CreateOffer(); |
| 2783 | 2948 |
| 2784 cricket::MediaSessionOptions options; | 2949 cricket::MediaSessionOptions options; |
| 2785 options.recv_audio = false; | 2950 AddMediaSection(cricket::MEDIA_TYPE_AUDIO, cricket::CN_AUDIO, false /*send*/, |
| 2786 options.recv_video = true; | 2951 false /*recv*/, true, options); |
| 2787 SessionDescriptionInterface* answer = CreateRemoteAnswer( | 2952 AddMediaSection(cricket::MEDIA_TYPE_VIDEO, cricket::CN_VIDEO, false /*send*/, |
| 2788 offer, options, cricket::SEC_ENABLED); | 2953 true /*recv*/, false, options); |
| 2954 | |
| 2955 SessionDescriptionInterface* answer = | |
| 2956 CreateRemoteAnswer(offer, options, cricket::SEC_ENABLED); | |
| 2789 | 2957 |
| 2790 // SetLocalDescription and SetRemoteDescriptions takes ownership of offer | 2958 // SetLocalDescription and SetRemoteDescriptions takes ownership of offer |
| 2791 // and answer. | 2959 // and answer. |
| 2792 SetLocalDescriptionWithoutError(offer); | 2960 SetLocalDescriptionWithoutError(offer); |
| 2793 SetRemoteDescriptionWithoutError(answer); | 2961 SetRemoteDescriptionWithoutError(answer); |
| 2794 | 2962 |
| 2795 video_channel_ = media_engine_->GetVideoChannel(0); | 2963 video_channel_ = media_engine_->GetVideoChannel(0); |
| 2796 voice_channel_ = media_engine_->GetVoiceChannel(0); | 2964 voice_channel_ = media_engine_->GetVoiceChannel(0); |
| 2797 | 2965 |
| 2798 ASSERT_TRUE(voice_channel_ == NULL); | 2966 ASSERT_TRUE(voice_channel_ == NULL); |
| (...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3018 } | 3186 } |
| 3019 | 3187 |
| 3020 // Test that candidates sent to the "video" transport do not get pushed down to | 3188 // Test that candidates sent to the "video" transport do not get pushed down to |
| 3021 // the "audio" transport channel when bundling. | 3189 // the "audio" transport channel when bundling. |
| 3022 TEST_F(WebRtcSessionTest, TestIgnoreCandidatesForUnusedTransportWhenBundling) { | 3190 TEST_F(WebRtcSessionTest, TestIgnoreCandidatesForUnusedTransportWhenBundling) { |
| 3023 AddInterface(rtc::SocketAddress(kClientAddrHost1, kClientAddrPort)); | 3191 AddInterface(rtc::SocketAddress(kClientAddrHost1, kClientAddrPort)); |
| 3024 | 3192 |
| 3025 InitWithBundlePolicy(PeerConnectionInterface::kBundlePolicyBalanced); | 3193 InitWithBundlePolicy(PeerConnectionInterface::kBundlePolicyBalanced); |
| 3026 SendAudioVideoStream1(); | 3194 SendAudioVideoStream1(); |
| 3027 | 3195 |
| 3028 PeerConnectionInterface::RTCOfferAnswerOptions options; | 3196 cricket::MediaSessionOptions offer_options; |
| 3029 options.use_rtp_mux = true; | 3197 GetOptionsForRemoteOffer(&offer_options); |
| 3198 offer_options.bundle_enabled = true; | |
| 3030 | 3199 |
| 3031 SessionDescriptionInterface* offer = CreateRemoteOffer(); | 3200 SessionDescriptionInterface* offer = CreateRemoteOffer(offer_options); |
| 3032 SetRemoteDescriptionWithoutError(offer); | 3201 SetRemoteDescriptionWithoutError(offer); |
| 3033 | 3202 |
| 3034 SessionDescriptionInterface* answer = CreateAnswer(); | 3203 cricket::MediaSessionOptions answer_options; |
| 3204 answer_options.bundle_enabled = true; | |
| 3205 SessionDescriptionInterface* answer = CreateAnswer(answer_options); | |
| 3035 SetLocalDescriptionWithoutError(answer); | 3206 SetLocalDescriptionWithoutError(answer); |
| 3036 | 3207 |
| 3037 EXPECT_EQ(session_->voice_rtp_transport_channel(), | 3208 EXPECT_EQ(session_->voice_rtp_transport_channel(), |
| 3038 session_->video_rtp_transport_channel()); | 3209 session_->video_rtp_transport_channel()); |
| 3039 | 3210 |
| 3040 cricket::BaseChannel* voice_channel = session_->voice_channel(); | 3211 cricket::BaseChannel* voice_channel = session_->voice_channel(); |
| 3041 ASSERT_TRUE(voice_channel != NULL); | 3212 ASSERT_TRUE(voice_channel != NULL); |
| 3042 | 3213 |
| 3043 // Checks if one of the transport channels contains a connection using a given | 3214 // Checks if one of the transport channels contains a connection using a given |
| 3044 // port. | 3215 // port. |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3189 | 3360 |
| 3190 PeerConnectionInterface::RTCOfferAnswerOptions options; | 3361 PeerConnectionInterface::RTCOfferAnswerOptions options; |
| 3191 options.use_rtp_mux = true; | 3362 options.use_rtp_mux = true; |
| 3192 | 3363 |
| 3193 SessionDescriptionInterface* offer = CreateOffer(options); | 3364 SessionDescriptionInterface* offer = CreateOffer(options); |
| 3194 SetLocalDescriptionWithoutError(offer); | 3365 SetLocalDescriptionWithoutError(offer); |
| 3195 | 3366 |
| 3196 EXPECT_EQ(session_->voice_rtp_transport_channel(), | 3367 EXPECT_EQ(session_->voice_rtp_transport_channel(), |
| 3197 session_->video_rtp_transport_channel()); | 3368 session_->video_rtp_transport_channel()); |
| 3198 | 3369 |
| 3199 SendAudioVideoStream2(); | 3370 SendVideoOnlyStream2(); |
| 3200 cricket::MediaSessionOptions recv_options; | 3371 cricket::MediaSessionOptions recv_options; |
| 3201 recv_options.recv_audio = false; | 3372 recv_audio_ = false; |
| 3202 recv_options.recv_video = true; | 3373 GetOptionsForAnswer(&recv_options); |
| 3203 SessionDescriptionInterface* answer = | 3374 SessionDescriptionInterface* answer = |
| 3204 CreateRemoteAnswer(session_->local_description(), recv_options); | 3375 CreateRemoteAnswer(session_->local_description(), recv_options); |
| 3205 SetRemoteDescriptionWithoutError(answer); | 3376 SetRemoteDescriptionWithoutError(answer); |
| 3206 | 3377 |
| 3207 EXPECT_TRUE(nullptr == session_->voice_channel()); | 3378 EXPECT_TRUE(nullptr == session_->voice_channel()); |
| 3208 EXPECT_TRUE(nullptr != session_->video_rtp_transport_channel()); | 3379 EXPECT_TRUE(nullptr != session_->video_rtp_transport_channel()); |
| 3209 | 3380 |
| 3210 session_->Close(); | 3381 session_->Close(); |
| 3211 EXPECT_TRUE(nullptr == session_->voice_rtp_transport_channel()); | 3382 EXPECT_TRUE(nullptr == session_->voice_rtp_transport_channel()); |
| 3212 EXPECT_TRUE(nullptr == session_->voice_rtcp_transport_channel()); | 3383 EXPECT_TRUE(nullptr == session_->voice_rtcp_transport_channel()); |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3279 // Expect an error when applying the remote description | 3450 // Expect an error when applying the remote description |
| 3280 SetRemoteDescriptionExpectError(JsepSessionDescription::kOffer, | 3451 SetRemoteDescriptionExpectError(JsepSessionDescription::kOffer, |
| 3281 kCreateChannelFailed, modified_offer); | 3452 kCreateChannelFailed, modified_offer); |
| 3282 } | 3453 } |
| 3283 | 3454 |
| 3284 // kBundlePolicyMaxCompat bundle policy and answer contains BUNDLE. | 3455 // kBundlePolicyMaxCompat bundle policy and answer contains BUNDLE. |
| 3285 TEST_F(WebRtcSessionTest, TestMaxCompatBundleInAnswer) { | 3456 TEST_F(WebRtcSessionTest, TestMaxCompatBundleInAnswer) { |
| 3286 InitWithBundlePolicy(PeerConnectionInterface::kBundlePolicyMaxCompat); | 3457 InitWithBundlePolicy(PeerConnectionInterface::kBundlePolicyMaxCompat); |
| 3287 SendAudioVideoStream1(); | 3458 SendAudioVideoStream1(); |
| 3288 | 3459 |
| 3289 PeerConnectionInterface::RTCOfferAnswerOptions options; | 3460 PeerConnectionInterface::RTCOfferAnswerOptions rtc_options; |
| 3290 options.use_rtp_mux = true; | 3461 rtc_options.use_rtp_mux = true; |
| 3291 | 3462 |
| 3292 SessionDescriptionInterface* offer = CreateOffer(options); | 3463 SessionDescriptionInterface* offer = CreateOffer(rtc_options); |
| 3293 SetLocalDescriptionWithoutError(offer); | 3464 SetLocalDescriptionWithoutError(offer); |
| 3294 | 3465 |
| 3295 EXPECT_NE(session_->voice_rtp_transport_channel(), | 3466 EXPECT_NE(session_->voice_rtp_transport_channel(), |
| 3296 session_->video_rtp_transport_channel()); | 3467 session_->video_rtp_transport_channel()); |
| 3297 | 3468 |
| 3298 SendAudioVideoStream2(); | 3469 SendAudioVideoStream2(); |
| 3299 SessionDescriptionInterface* answer = | 3470 SessionDescriptionInterface* answer = |
| 3300 CreateRemoteAnswer(session_->local_description()); | 3471 CreateRemoteAnswer(session_->local_description()); |
| 3301 SetRemoteDescriptionWithoutError(answer); | 3472 SetRemoteDescriptionWithoutError(answer); |
| 3302 | 3473 |
| (...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3638 SetLocalDescriptionWithoutError(jsep_offer_str); | 3809 SetLocalDescriptionWithoutError(jsep_offer_str); |
| 3639 EXPECT_FALSE(session_->voice_channel()->srtp_required_for_testing()); | 3810 EXPECT_FALSE(session_->voice_channel()->srtp_required_for_testing()); |
| 3640 EXPECT_FALSE(session_->video_channel()->srtp_required_for_testing()); | 3811 EXPECT_FALSE(session_->video_channel()->srtp_required_for_testing()); |
| 3641 } | 3812 } |
| 3642 | 3813 |
| 3643 // This test verifies that an answer contains new ufrag and password if an offer | 3814 // This test verifies that an answer contains new ufrag and password if an offer |
| 3644 // with new ufrag and password is received. | 3815 // with new ufrag and password is received. |
| 3645 TEST_F(WebRtcSessionTest, TestCreateAnswerWithNewUfragAndPassword) { | 3816 TEST_F(WebRtcSessionTest, TestCreateAnswerWithNewUfragAndPassword) { |
| 3646 Init(); | 3817 Init(); |
| 3647 cricket::MediaSessionOptions options; | 3818 cricket::MediaSessionOptions options; |
| 3648 options.recv_video = true; | 3819 GetOptionsForRemoteOffer(&options); |
| 3649 std::unique_ptr<JsepSessionDescription> offer(CreateRemoteOffer(options)); | 3820 std::unique_ptr<JsepSessionDescription> offer(CreateRemoteOffer(options)); |
| 3650 SetRemoteDescriptionWithoutError(offer.release()); | 3821 SetRemoteDescriptionWithoutError(offer.release()); |
| 3651 | 3822 |
| 3652 SendAudioVideoStream1(); | 3823 SendAudioVideoStream1(); |
| 3653 std::unique_ptr<SessionDescriptionInterface> answer(CreateAnswer()); | 3824 std::unique_ptr<SessionDescriptionInterface> answer(CreateAnswer()); |
| 3654 SetLocalDescriptionWithoutError(answer.release()); | 3825 SetLocalDescriptionWithoutError(answer.release()); |
| 3655 | 3826 |
| 3656 // Receive an offer with new ufrag and password. | 3827 // Receive an offer with new ufrag and password. |
| 3657 for (const cricket::ContentInfo& content : | 3828 for (const cricket::ContentInfo& content : |
| 3658 session_->local_description()->description()->contents()) { | 3829 session_->local_description()->description()->contents()) { |
| 3659 options.transport_options[content.name].ice_restart = true; | 3830 auto it = options.FindMediaDescription(content.name); |
|
Taylor Brandstetter
2017/07/28 19:00:26
"ASSERT_NE(options.media_description_options.end()
Zhi Huang
2017/08/02 04:38:36
We can change this to index based iteration.
| |
| 3831 it->transport_options.ice_restart = true; | |
| 3660 } | 3832 } |
| 3661 std::unique_ptr<JsepSessionDescription> updated_offer1( | 3833 std::unique_ptr<JsepSessionDescription> updated_offer1( |
| 3662 CreateRemoteOffer(options, session_->remote_description())); | 3834 CreateRemoteOffer(options, session_->remote_description())); |
| 3663 SetRemoteDescriptionWithoutError(updated_offer1.release()); | 3835 SetRemoteDescriptionWithoutError(updated_offer1.release()); |
| 3664 | 3836 |
| 3665 std::unique_ptr<SessionDescriptionInterface> updated_answer1(CreateAnswer()); | 3837 std::unique_ptr<SessionDescriptionInterface> updated_answer1(CreateAnswer()); |
| 3666 | 3838 |
| 3667 EXPECT_FALSE(IceUfragPwdEqual(updated_answer1->description(), | 3839 EXPECT_FALSE(IceUfragPwdEqual(updated_answer1->description(), |
| 3668 session_->local_description()->description())); | 3840 session_->local_description()->description())); |
| 3669 | 3841 |
| 3670 // Even a second answer (created before the description is set) should have | 3842 // Even a second answer (created before the description is set) should have |
| 3671 // a new ufrag/password. | 3843 // a new ufrag/password. |
| 3672 std::unique_ptr<SessionDescriptionInterface> updated_answer2(CreateAnswer()); | 3844 std::unique_ptr<SessionDescriptionInterface> updated_answer2(CreateAnswer()); |
| 3673 | 3845 |
| 3674 EXPECT_FALSE(IceUfragPwdEqual(updated_answer2->description(), | 3846 EXPECT_FALSE(IceUfragPwdEqual(updated_answer2->description(), |
| 3675 session_->local_description()->description())); | 3847 session_->local_description()->description())); |
| 3676 | 3848 |
| 3677 SetLocalDescriptionWithoutError(updated_answer2.release()); | 3849 SetLocalDescriptionWithoutError(updated_answer2.release()); |
| 3678 } | 3850 } |
| 3679 | 3851 |
| 3680 // This test verifies that an answer contains new ufrag and password if an offer | 3852 // This test verifies that an answer contains new ufrag and password if an offer |
| 3681 // that changes either the ufrag or password (but not both) is received. | 3853 // that changes either the ufrag or password (but not both) is received. |
| 3682 // RFC 5245 says: "If the offer contained a change in the a=ice-ufrag or | 3854 // RFC 5245 says: "If the offer contained a change in the a=ice-ufrag or |
| 3683 // a=ice-pwd attributes compared to the previous SDP from the peer, it | 3855 // a=ice-pwd attributes compared to the previous SDP from the peer, it |
| 3684 // indicates that ICE is restarting for this media stream." | 3856 // indicates that ICE is restarting for this media stream." |
| 3685 TEST_F(WebRtcSessionTest, TestOfferChangingOnlyUfragOrPassword) { | 3857 TEST_F(WebRtcSessionTest, TestOfferChangingOnlyUfragOrPassword) { |
| 3686 Init(); | 3858 Init(); |
| 3687 cricket::MediaSessionOptions options; | 3859 cricket::MediaSessionOptions options; |
| 3688 options.recv_audio = true; | 3860 GetOptionsForRemoteOffer(&options); |
| 3689 options.recv_video = true; | |
| 3690 // Create an offer with audio and video. | 3861 // Create an offer with audio and video. |
| 3691 std::unique_ptr<JsepSessionDescription> offer(CreateRemoteOffer(options)); | 3862 std::unique_ptr<JsepSessionDescription> offer(CreateRemoteOffer(options)); |
| 3692 SetIceUfragPwd(offer.get(), "original_ufrag", "original_password12345"); | 3863 SetIceUfragPwd(offer.get(), "original_ufrag", "original_password12345"); |
| 3693 SetRemoteDescriptionWithoutError(offer.release()); | 3864 SetRemoteDescriptionWithoutError(offer.release()); |
| 3694 | 3865 |
| 3695 SendAudioVideoStream1(); | 3866 SendAudioVideoStream1(); |
| 3696 std::unique_ptr<SessionDescriptionInterface> answer(CreateAnswer()); | 3867 std::unique_ptr<SessionDescriptionInterface> answer(CreateAnswer()); |
| 3697 SetLocalDescriptionWithoutError(answer.release()); | 3868 SetLocalDescriptionWithoutError(answer.release()); |
| 3698 | 3869 |
| 3699 // Receive an offer with a new ufrag but stale password. | 3870 // Receive an offer with a new ufrag but stale password. |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 3719 EXPECT_FALSE(IceUfragPwdEqual(updated_answer2->description(), | 3890 EXPECT_FALSE(IceUfragPwdEqual(updated_answer2->description(), |
| 3720 session_->local_description()->description())); | 3891 session_->local_description()->description())); |
| 3721 SetLocalDescriptionWithoutError(updated_answer2.release()); | 3892 SetLocalDescriptionWithoutError(updated_answer2.release()); |
| 3722 } | 3893 } |
| 3723 | 3894 |
| 3724 // This test verifies that an answer contains old ufrag and password if an offer | 3895 // This test verifies that an answer contains old ufrag and password if an offer |
| 3725 // with old ufrag and password is received. | 3896 // with old ufrag and password is received. |
| 3726 TEST_F(WebRtcSessionTest, TestCreateAnswerWithOldUfragAndPassword) { | 3897 TEST_F(WebRtcSessionTest, TestCreateAnswerWithOldUfragAndPassword) { |
| 3727 Init(); | 3898 Init(); |
| 3728 cricket::MediaSessionOptions options; | 3899 cricket::MediaSessionOptions options; |
| 3729 options.recv_video = true; | 3900 GetOptionsForRemoteOffer(&options); |
| 3730 std::unique_ptr<JsepSessionDescription> offer(CreateRemoteOffer(options)); | 3901 std::unique_ptr<JsepSessionDescription> offer(CreateRemoteOffer(options)); |
| 3731 SetRemoteDescriptionWithoutError(offer.release()); | 3902 SetRemoteDescriptionWithoutError(offer.release()); |
| 3732 | 3903 |
| 3733 SendAudioVideoStream1(); | 3904 SendAudioVideoStream1(); |
| 3734 std::unique_ptr<SessionDescriptionInterface> answer(CreateAnswer()); | 3905 std::unique_ptr<SessionDescriptionInterface> answer(CreateAnswer()); |
| 3735 SetLocalDescriptionWithoutError(answer.release()); | 3906 SetLocalDescriptionWithoutError(answer.release()); |
| 3736 | 3907 |
| 3737 // Receive an offer without changed ufrag or password. | 3908 // Receive an offer without changed ufrag or password. |
| 3738 std::unique_ptr<JsepSessionDescription> updated_offer2( | 3909 std::unique_ptr<JsepSessionDescription> updated_offer2( |
| 3739 CreateRemoteOffer(options, session_->remote_description())); | 3910 CreateRemoteOffer(options, session_->remote_description())); |
| 3740 SetRemoteDescriptionWithoutError(updated_offer2.release()); | 3911 SetRemoteDescriptionWithoutError(updated_offer2.release()); |
| 3741 | 3912 |
| 3742 std::unique_ptr<SessionDescriptionInterface> updated_answer2(CreateAnswer()); | 3913 std::unique_ptr<SessionDescriptionInterface> updated_answer2(CreateAnswer()); |
| 3743 | 3914 |
| 3744 EXPECT_TRUE(IceUfragPwdEqual(updated_answer2->description(), | 3915 EXPECT_TRUE(IceUfragPwdEqual(updated_answer2->description(), |
| 3745 session_->local_description()->description())); | 3916 session_->local_description()->description())); |
| 3746 | 3917 |
| 3747 SetLocalDescriptionWithoutError(updated_answer2.release()); | 3918 SetLocalDescriptionWithoutError(updated_answer2.release()); |
| 3748 } | 3919 } |
| 3749 | 3920 |
| 3750 // This test verifies that if an offer does an ICE restart on some, but not all | 3921 // This test verifies that if an offer does an ICE restart on some, but not all |
| 3751 // media sections, the answer will change the ufrag/password in the correct | 3922 // media sections, the answer will change the ufrag/password in the correct |
| 3752 // media sections. | 3923 // media sections. |
| 3753 TEST_F(WebRtcSessionTest, TestCreateAnswerWithNewAndOldUfragAndPassword) { | 3924 TEST_F(WebRtcSessionTest, TestCreateAnswerWithNewAndOldUfragAndPassword) { |
| 3754 Init(); | 3925 Init(); |
| 3755 cricket::MediaSessionOptions options; | 3926 cricket::MediaSessionOptions options; |
| 3756 options.recv_video = true; | 3927 GetOptionsForRemoteOffer(&options); |
| 3757 options.recv_audio = true; | |
| 3758 options.bundle_enabled = false; | 3928 options.bundle_enabled = false; |
| 3759 std::unique_ptr<JsepSessionDescription> offer(CreateRemoteOffer(options)); | 3929 std::unique_ptr<JsepSessionDescription> offer(CreateRemoteOffer(options)); |
| 3760 | 3930 |
| 3761 SetIceUfragPwd(offer.get(), cricket::MEDIA_TYPE_AUDIO, "aaaa", | 3931 SetIceUfragPwd(offer.get(), cricket::MEDIA_TYPE_AUDIO, "aaaa", |
| 3762 "aaaaaaaaaaaaaaaaaaaaaa"); | 3932 "aaaaaaaaaaaaaaaaaaaaaa"); |
| 3763 SetIceUfragPwd(offer.get(), cricket::MEDIA_TYPE_VIDEO, "bbbb", | 3933 SetIceUfragPwd(offer.get(), cricket::MEDIA_TYPE_VIDEO, "bbbb", |
| 3764 "bbbbbbbbbbbbbbbbbbbbbb"); | 3934 "bbbbbbbbbbbbbbbbbbbbbb"); |
| 3765 SetRemoteDescriptionWithoutError(offer.release()); | 3935 SetRemoteDescriptionWithoutError(offer.release()); |
| 3766 | 3936 |
| 3767 SendAudioVideoStream1(); | 3937 SendAudioVideoStream1(); |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3879 CreateDataChannel(); | 4049 CreateDataChannel(); |
| 3880 InitiateCall(); | 4050 InitiateCall(); |
| 3881 ASSERT_TRUE(session_->sctp_content_name()); | 4051 ASSERT_TRUE(session_->sctp_content_name()); |
| 3882 ASSERT_TRUE(session_->sctp_transport_name()); | 4052 ASSERT_TRUE(session_->sctp_transport_name()); |
| 3883 EXPECT_EQ("data", *session_->sctp_content_name()); | 4053 EXPECT_EQ("data", *session_->sctp_content_name()); |
| 3884 EXPECT_EQ("data", *session_->sctp_transport_name()); | 4054 EXPECT_EQ("data", *session_->sctp_transport_name()); |
| 3885 | 4055 |
| 3886 // Create answer that finishes BUNDLE negotiation, which means everything | 4056 // Create answer that finishes BUNDLE negotiation, which means everything |
| 3887 // should be bundled on the first transport (audio). | 4057 // should be bundled on the first transport (audio). |
| 3888 cricket::MediaSessionOptions answer_options; | 4058 cricket::MediaSessionOptions answer_options; |
| 3889 answer_options.recv_video = true; | |
| 3890 answer_options.bundle_enabled = true; | 4059 answer_options.bundle_enabled = true; |
| 3891 answer_options.data_channel_type = cricket::DCT_SCTP; | 4060 answer_options.data_channel_type = cricket::DCT_SCTP; |
| 4061 GetOptionsForAnswer(&answer_options); | |
| 3892 SetRemoteDescriptionWithoutError(CreateRemoteAnswer( | 4062 SetRemoteDescriptionWithoutError(CreateRemoteAnswer( |
| 3893 session_->local_description(), answer_options, cricket::SEC_DISABLED)); | 4063 session_->local_description(), answer_options, cricket::SEC_DISABLED)); |
| 3894 ASSERT_TRUE(session_->sctp_content_name()); | 4064 ASSERT_TRUE(session_->sctp_content_name()); |
| 3895 ASSERT_TRUE(session_->sctp_transport_name()); | 4065 ASSERT_TRUE(session_->sctp_transport_name()); |
| 3896 EXPECT_EQ("data", *session_->sctp_content_name()); | 4066 EXPECT_EQ("data", *session_->sctp_content_name()); |
| 3897 EXPECT_EQ("audio", *session_->sctp_transport_name()); | 4067 EXPECT_EQ("audio", *session_->sctp_transport_name()); |
| 3898 } | 4068 } |
| 3899 | 4069 |
| 3900 TEST_P(WebRtcSessionTest, TestCreateOfferWithSctpEnabledWithoutStreams) { | 4070 TEST_P(WebRtcSessionTest, TestCreateOfferWithSctpEnabledWithoutStreams) { |
| 3901 InitWithDtls(GetParam()); | 4071 InitWithDtls(GetParam()); |
| 3902 | 4072 |
| 3903 std::unique_ptr<SessionDescriptionInterface> offer(CreateOffer()); | 4073 std::unique_ptr<SessionDescriptionInterface> offer(CreateOffer()); |
| 3904 EXPECT_TRUE(offer->description()->GetContentByName("data") == NULL); | 4074 EXPECT_TRUE(offer->description()->GetContentByName("data") == NULL); |
| 3905 EXPECT_TRUE(offer->description()->GetTransportInfoByName("data") == NULL); | 4075 EXPECT_TRUE(offer->description()->GetTransportInfoByName("data") == NULL); |
| 3906 } | 4076 } |
| 3907 | 4077 |
| 3908 TEST_P(WebRtcSessionTest, TestCreateAnswerWithSctpInOfferAndNoStreams) { | 4078 TEST_P(WebRtcSessionTest, TestCreateAnswerWithSctpInOfferAndNoStreams) { |
| 3909 SetFactoryDtlsSrtp(); | 4079 SetFactoryDtlsSrtp(); |
| 3910 InitWithDtls(GetParam()); | 4080 InitWithDtls(GetParam()); |
| 3911 | 4081 |
| 3912 // Create remote offer with SCTP. | 4082 // Create remote offer with SCTP. |
| 3913 cricket::MediaSessionOptions options; | 4083 cricket::MediaSessionOptions options; |
| 3914 options.data_channel_type = cricket::DCT_SCTP; | 4084 options.data_channel_type = cricket::DCT_SCTP; |
| 4085 GetOptionsForRemoteOffer(&options); | |
| 3915 JsepSessionDescription* offer = | 4086 JsepSessionDescription* offer = |
| 3916 CreateRemoteOffer(options, cricket::SEC_DISABLED); | 4087 CreateRemoteOffer(options, cricket::SEC_DISABLED); |
| 3917 SetRemoteDescriptionWithoutError(offer); | 4088 SetRemoteDescriptionWithoutError(offer); |
| 3918 | 4089 |
| 3919 // Verifies the answer contains SCTP. | 4090 // Verifies the answer contains SCTP. |
| 3920 std::unique_ptr<SessionDescriptionInterface> answer(CreateAnswer()); | 4091 std::unique_ptr<SessionDescriptionInterface> answer(CreateAnswer()); |
| 3921 EXPECT_TRUE(answer != NULL); | 4092 EXPECT_TRUE(answer != NULL); |
| 3922 EXPECT_TRUE(answer->description()->GetContentByName("data") != NULL); | 4093 EXPECT_TRUE(answer->description()->GetContentByName("data") != NULL); |
| 3923 EXPECT_TRUE(answer->description()->GetTransportInfoByName("data") != NULL); | 4094 EXPECT_TRUE(answer->description()->GetTransportInfoByName("data") != NULL); |
| 3924 } | 4095 } |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4048 } | 4219 } |
| 4049 | 4220 |
| 4050 // Verifies that CreateAnswer succeeds when CreateOffer is called before async | 4221 // Verifies that CreateAnswer succeeds when CreateOffer is called before async |
| 4051 // identity generation is finished (even if a certificate is provided this is | 4222 // identity generation is finished (even if a certificate is provided this is |
| 4052 // an async op). | 4223 // an async op). |
| 4053 TEST_P(WebRtcSessionTest, TestCreateAnswerBeforeIdentityRequestReturnSuccess) { | 4224 TEST_P(WebRtcSessionTest, TestCreateAnswerBeforeIdentityRequestReturnSuccess) { |
| 4054 InitWithDtls(GetParam()); | 4225 InitWithDtls(GetParam()); |
| 4055 SetFactoryDtlsSrtp(); | 4226 SetFactoryDtlsSrtp(); |
| 4056 | 4227 |
| 4057 cricket::MediaSessionOptions options; | 4228 cricket::MediaSessionOptions options; |
| 4058 options.recv_video = true; | 4229 GetOptionsForRemoteOffer(&options); |
| 4059 std::unique_ptr<JsepSessionDescription> offer( | 4230 std::unique_ptr<JsepSessionDescription> offer( |
| 4060 CreateRemoteOffer(options, cricket::SEC_DISABLED)); | 4231 CreateRemoteOffer(options, cricket::SEC_DISABLED)); |
| 4061 ASSERT_TRUE(offer.get() != NULL); | 4232 ASSERT_TRUE(offer.get() != NULL); |
| 4062 SetRemoteDescriptionWithoutError(offer.release()); | 4233 SetRemoteDescriptionWithoutError(offer.release()); |
| 4063 | 4234 |
| 4064 std::unique_ptr<SessionDescriptionInterface> answer(CreateAnswer()); | 4235 std::unique_ptr<SessionDescriptionInterface> answer(CreateAnswer()); |
| 4065 EXPECT_TRUE(answer != NULL); | 4236 EXPECT_TRUE(answer != NULL); |
| 4066 VerifyNoCryptoParams(answer->description(), true); | 4237 VerifyNoCryptoParams(answer->description(), true); |
| 4067 VerifyFingerprintStatus(answer->description(), true); | 4238 VerifyFingerprintStatus(answer->description(), true); |
| 4068 } | 4239 } |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4122 CreateSessionDescriptionRequest::kAnswer); | 4293 CreateSessionDescriptionRequest::kAnswer); |
| 4123 } | 4294 } |
| 4124 | 4295 |
| 4125 // Verifies that setRemoteDescription fails when DTLS is disabled and the remote | 4296 // Verifies that setRemoteDescription fails when DTLS is disabled and the remote |
| 4126 // offer has no SDES crypto but only DTLS fingerprint. | 4297 // offer has no SDES crypto but only DTLS fingerprint. |
| 4127 TEST_F(WebRtcSessionTest, TestSetRemoteOfferFailIfDtlsDisabledAndNoCrypto) { | 4298 TEST_F(WebRtcSessionTest, TestSetRemoteOfferFailIfDtlsDisabledAndNoCrypto) { |
| 4128 // Init without DTLS. | 4299 // Init without DTLS. |
| 4129 Init(); | 4300 Init(); |
| 4130 // Create a remote offer with secured transport disabled. | 4301 // Create a remote offer with secured transport disabled. |
| 4131 cricket::MediaSessionOptions options; | 4302 cricket::MediaSessionOptions options; |
| 4303 GetOptionsForRemoteOffer(&options); | |
| 4132 JsepSessionDescription* offer(CreateRemoteOffer( | 4304 JsepSessionDescription* offer(CreateRemoteOffer( |
| 4133 options, cricket::SEC_DISABLED)); | 4305 options, cricket::SEC_DISABLED)); |
| 4134 // Adds a DTLS fingerprint to the remote offer. | 4306 // Adds a DTLS fingerprint to the remote offer. |
| 4135 cricket::SessionDescription* sdp = offer->description(); | 4307 cricket::SessionDescription* sdp = offer->description(); |
| 4136 TransportInfo* audio = sdp->GetTransportInfoByName("audio"); | 4308 TransportInfo* audio = sdp->GetTransportInfoByName("audio"); |
| 4137 ASSERT_TRUE(audio != NULL); | 4309 ASSERT_TRUE(audio != NULL); |
| 4138 ASSERT_TRUE(audio->description.identity_fingerprint.get() == NULL); | 4310 ASSERT_TRUE(audio->description.identity_fingerprint.get() == NULL); |
| 4139 audio->description.identity_fingerprint.reset( | 4311 audio->description.identity_fingerprint.reset( |
| 4140 rtc::SSLFingerprint::CreateFromRfc4572( | 4312 rtc::SSLFingerprint::CreateFromRfc4572( |
| 4141 rtc::DIGEST_SHA_256, kFakeDtlsFingerprint)); | 4313 rtc::DIGEST_SHA_256, kFakeDtlsFingerprint)); |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 4165 SetFactoryDtlsSrtp(); | 4337 SetFactoryDtlsSrtp(); |
| 4166 | 4338 |
| 4167 SendAudioOnlyStream2(); | 4339 SendAudioOnlyStream2(); |
| 4168 SessionDescriptionInterface* offer = CreateOffer(); | 4340 SessionDescriptionInterface* offer = CreateOffer(); |
| 4169 SetLocalDescriptionWithoutError(offer); | 4341 SetLocalDescriptionWithoutError(offer); |
| 4170 | 4342 |
| 4171 SessionDescriptionInterface* answer = CreateRemoteAnswer(offer); | 4343 SessionDescriptionInterface* answer = CreateRemoteAnswer(offer); |
| 4172 SetRemoteDescriptionWithoutError(answer); | 4344 SetRemoteDescriptionWithoutError(answer); |
| 4173 | 4345 |
| 4174 cricket::MediaSessionOptions options; | 4346 cricket::MediaSessionOptions options; |
| 4175 options.recv_video = true; | 4347 GetOptionsForRemoteOffer(&options); |
| 4176 offer = CreateRemoteOffer(options, cricket::SEC_DISABLED); | 4348 offer = CreateRemoteOffer(options, cricket::SEC_DISABLED); |
| 4177 | 4349 |
| 4178 cricket::Candidate candidate1; | 4350 cricket::Candidate candidate1; |
| 4179 candidate1.set_address(rtc::SocketAddress("1.1.1.1", 5000)); | 4351 candidate1.set_address(rtc::SocketAddress("1.1.1.1", 5000)); |
| 4180 candidate1.set_component(1); | 4352 candidate1.set_component(1); |
| 4181 JsepIceCandidate ice_candidate(kMediaContentName1, kMediaContentIndex1, | 4353 JsepIceCandidate ice_candidate(kMediaContentName1, kMediaContentIndex1, |
| 4182 candidate1); | 4354 candidate1); |
| 4183 EXPECT_TRUE(offer->AddCandidate(&ice_candidate)); | 4355 EXPECT_TRUE(offer->AddCandidate(&ice_candidate)); |
| 4184 SetRemoteDescriptionWithoutError(offer); | 4356 SetRemoteDescriptionWithoutError(offer); |
| 4185 | 4357 |
| 4186 answer = CreateAnswer(); | 4358 answer = CreateAnswer(); |
| 4187 SetLocalDescriptionWithoutError(answer); | 4359 SetLocalDescriptionWithoutError(answer); |
| 4188 } | 4360 } |
| 4189 | 4361 |
| 4190 // Tests that we can renegotiate new media content with ICE candidates separated | 4362 // Tests that we can renegotiate new media content with ICE candidates separated |
| 4191 // from the remote SDP. | 4363 // from the remote SDP. |
| 4192 TEST_P(WebRtcSessionTest, TestRenegotiateNewMediaWithCandidatesSeparated) { | 4364 TEST_P(WebRtcSessionTest, TestRenegotiateNewMediaWithCandidatesSeparated) { |
| 4193 InitWithDtls(GetParam()); | 4365 InitWithDtls(GetParam()); |
| 4194 SetFactoryDtlsSrtp(); | 4366 SetFactoryDtlsSrtp(); |
| 4195 | 4367 |
| 4196 SendAudioOnlyStream2(); | 4368 SendAudioOnlyStream2(); |
| 4197 SessionDescriptionInterface* offer = CreateOffer(); | 4369 SessionDescriptionInterface* offer = CreateOffer(); |
| 4198 SetLocalDescriptionWithoutError(offer); | 4370 SetLocalDescriptionWithoutError(offer); |
| 4199 | 4371 |
| 4200 SessionDescriptionInterface* answer = CreateRemoteAnswer(offer); | 4372 SessionDescriptionInterface* answer = CreateRemoteAnswer(offer); |
| 4201 SetRemoteDescriptionWithoutError(answer); | 4373 SetRemoteDescriptionWithoutError(answer); |
| 4202 | 4374 |
| 4203 cricket::MediaSessionOptions options; | 4375 cricket::MediaSessionOptions options; |
| 4204 options.recv_video = true; | 4376 GetOptionsForRemoteOffer(&options); |
| 4205 offer = CreateRemoteOffer(options, cricket::SEC_DISABLED); | 4377 offer = CreateRemoteOffer(options, cricket::SEC_DISABLED); |
| 4206 SetRemoteDescriptionWithoutError(offer); | 4378 SetRemoteDescriptionWithoutError(offer); |
| 4207 | 4379 |
| 4208 cricket::Candidate candidate1; | 4380 cricket::Candidate candidate1; |
| 4209 candidate1.set_address(rtc::SocketAddress("1.1.1.1", 5000)); | 4381 candidate1.set_address(rtc::SocketAddress("1.1.1.1", 5000)); |
| 4210 candidate1.set_component(1); | 4382 candidate1.set_component(1); |
| 4211 JsepIceCandidate ice_candidate(kMediaContentName1, kMediaContentIndex1, | 4383 JsepIceCandidate ice_candidate(kMediaContentName1, kMediaContentIndex1, |
| 4212 candidate1); | 4384 candidate1); |
| 4213 EXPECT_TRUE(session_->ProcessIceMessage(&ice_candidate)); | 4385 EXPECT_TRUE(session_->ProcessIceMessage(&ice_candidate)); |
| 4214 | 4386 |
| 4215 answer = CreateAnswer(); | 4387 answer = CreateAnswer(); |
| 4216 SetLocalDescriptionWithoutError(answer); | 4388 SetLocalDescriptionWithoutError(answer); |
| 4217 } | 4389 } |
| 4218 | 4390 |
| 4219 #ifdef HAVE_QUIC | 4391 #ifdef HAVE_QUIC |
| 4220 TEST_P(WebRtcSessionTest, TestNegotiateQuic) { | 4392 TEST_P(WebRtcSessionTest, TestNegotiateQuic) { |
| 4221 configuration_.enable_quic = true; | 4393 configuration_.enable_quic = true; |
| 4222 InitWithDtls(GetParam()); | 4394 InitWithDtls(GetParam()); |
| 4223 EXPECT_TRUE(session_->data_channel_type() == cricket::DCT_QUIC); | 4395 EXPECT_TRUE(session_->data_channel_type() == cricket::DCT_QUIC); |
| 4224 SessionDescriptionInterface* offer = CreateOffer(); | 4396 SessionDescriptionInterface* offer = CreateOffer(); |
| 4225 ASSERT_TRUE(offer); | 4397 ASSERT_TRUE(offer); |
| 4226 ASSERT_TRUE(offer->description()); | 4398 ASSERT_TRUE(offer->description()); |
| 4227 SetLocalDescriptionWithoutError(offer); | 4399 SetLocalDescriptionWithoutError(offer); |
| 4228 cricket::MediaSessionOptions options; | 4400 cricket::MediaSessionOptions options; |
| 4229 options.recv_audio = true; | 4401 GetOptionsForAnswer(&options); |
| 4230 options.recv_video = true; | |
| 4231 SessionDescriptionInterface* answer = | 4402 SessionDescriptionInterface* answer = |
| 4232 CreateRemoteAnswer(offer, options, cricket::SEC_DISABLED); | 4403 CreateRemoteAnswer(offer, options, cricket::SEC_DISABLED); |
| 4233 ASSERT_TRUE(answer); | 4404 ASSERT_TRUE(answer); |
| 4234 ASSERT_TRUE(answer->description()); | 4405 ASSERT_TRUE(answer->description()); |
| 4235 SetRemoteDescriptionWithoutError(answer); | 4406 SetRemoteDescriptionWithoutError(answer); |
| 4236 } | 4407 } |
| 4237 #endif // HAVE_QUIC | 4408 #endif // HAVE_QUIC |
| 4238 | 4409 |
| 4239 // Tests that RTX codec is removed from the answer when it isn't supported | 4410 // Tests that RTX codec is removed from the answer when it isn't supported |
| 4240 // by local side. | 4411 // by local side. |
| 4241 TEST_F(WebRtcSessionTest, TestRtxRemovedByCreateAnswer) { | 4412 TEST_F(WebRtcSessionTest, TestRtxRemovedByCreateAnswer) { |
| 4242 Init(); | 4413 Init(); |
| 4243 SendAudioVideoStream1(); | 4414 // Send video only to match the |kSdpWithRtx|. |
| 4415 SendVideoOnlyStream2(); | |
| 4244 std::string offer_sdp(kSdpWithRtx); | 4416 std::string offer_sdp(kSdpWithRtx); |
| 4245 | 4417 |
| 4246 SessionDescriptionInterface* offer = | 4418 SessionDescriptionInterface* offer = |
| 4247 CreateSessionDescription(JsepSessionDescription::kOffer, offer_sdp, NULL); | 4419 CreateSessionDescription(JsepSessionDescription::kOffer, offer_sdp, NULL); |
| 4248 EXPECT_TRUE(offer->ToString(&offer_sdp)); | 4420 EXPECT_TRUE(offer->ToString(&offer_sdp)); |
| 4249 | 4421 |
| 4250 // Offer SDP contains the RTX codec. | 4422 // Offer SDP contains the RTX codec. |
| 4251 EXPECT_TRUE(ContainsVideoCodecWithName(offer, "rtx")); | 4423 EXPECT_TRUE(ContainsVideoCodecWithName(offer, "rtx")); |
| 4252 SetRemoteDescriptionWithoutError(offer); | 4424 SetRemoteDescriptionWithoutError(offer); |
| 4253 | 4425 |
| 4426 // |offered_media_sections_| is used when creating answer. | |
| 4427 offered_media_sections_.push_back(cricket::MediaDescriptionOptions( | |
| 4428 cricket::MEDIA_TYPE_VIDEO, cricket::CN_VIDEO, | |
| 4429 cricket::RtpTransceiverDirection(true, true), false)); | |
| 4430 // Don't create media section for audio in the answer. | |
| 4254 SessionDescriptionInterface* answer = CreateAnswer(); | 4431 SessionDescriptionInterface* answer = CreateAnswer(); |
| 4255 // Answer SDP does not contain the RTX codec. | 4432 // Answer SDP does not contain the RTX codec. |
| 4256 EXPECT_FALSE(ContainsVideoCodecWithName(answer, "rtx")); | 4433 EXPECT_FALSE(ContainsVideoCodecWithName(answer, "rtx")); |
| 4257 SetLocalDescriptionWithoutError(answer); | 4434 SetLocalDescriptionWithoutError(answer); |
| 4258 } | 4435 } |
| 4259 | 4436 |
| 4260 // This verifies that the voice channel after bundle has both options from video | 4437 // This verifies that the voice channel after bundle has both options from video |
| 4261 // and voice channels. | 4438 // and voice channels. |
| 4262 TEST_F(WebRtcSessionTest, TestSetSocketOptionBeforeBundle) { | 4439 TEST_F(WebRtcSessionTest, TestSetSocketOptionBeforeBundle) { |
| 4263 InitWithBundlePolicy(PeerConnectionInterface::kBundlePolicyBalanced); | 4440 InitWithBundlePolicy(PeerConnectionInterface::kBundlePolicyBalanced); |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4309 // and make sure we got success/failure callbacks for all of the requests. | 4486 // and make sure we got success/failure callbacks for all of the requests. |
| 4310 // Background: crbug.com/507307 | 4487 // Background: crbug.com/507307 |
| 4311 TEST_F(WebRtcSessionTest, CreateOffersAndShutdown) { | 4488 TEST_F(WebRtcSessionTest, CreateOffersAndShutdown) { |
| 4312 Init(); | 4489 Init(); |
| 4313 | 4490 |
| 4314 rtc::scoped_refptr<WebRtcSessionCreateSDPObserverForTest> observers[100]; | 4491 rtc::scoped_refptr<WebRtcSessionCreateSDPObserverForTest> observers[100]; |
| 4315 PeerConnectionInterface::RTCOfferAnswerOptions options; | 4492 PeerConnectionInterface::RTCOfferAnswerOptions options; |
| 4316 options.offer_to_receive_audio = | 4493 options.offer_to_receive_audio = |
| 4317 RTCOfferAnswerOptions::kOfferToReceiveMediaTrue; | 4494 RTCOfferAnswerOptions::kOfferToReceiveMediaTrue; |
| 4318 cricket::MediaSessionOptions session_options; | 4495 cricket::MediaSessionOptions session_options; |
| 4319 session_options.recv_audio = true; | 4496 GetOptionsForOffer(options, &session_options); |
| 4320 | |
| 4321 for (auto& o : observers) { | 4497 for (auto& o : observers) { |
| 4322 o = new WebRtcSessionCreateSDPObserverForTest(); | 4498 o = new WebRtcSessionCreateSDPObserverForTest(); |
| 4323 session_->CreateOffer(o, options, session_options); | 4499 session_->CreateOffer(o, options, session_options); |
| 4324 } | 4500 } |
| 4325 | 4501 |
| 4326 session_.reset(); | 4502 session_.reset(); |
| 4327 | 4503 |
| 4328 for (auto& o : observers) { | 4504 for (auto& o : observers) { |
| 4329 // We expect to have received a notification now even if the session was | 4505 // We expect to have received a notification now even if the session was |
| 4330 // terminated. The offer creation may or may not have succeeded, but we | 4506 // terminated. The offer creation may or may not have succeeded, but we |
| 4331 // must have received a notification which, so the only invalid state | 4507 // must have received a notification which, so the only invalid state |
| 4332 // is kInit. | 4508 // is kInit. |
| 4333 EXPECT_NE(WebRtcSessionCreateSDPObserverForTest::kInit, o->state()); | 4509 EXPECT_NE(WebRtcSessionCreateSDPObserverForTest::kInit, o->state()); |
| 4334 } | 4510 } |
| 4335 } | 4511 } |
| 4336 | 4512 |
| 4337 TEST_F(WebRtcSessionTest, TestPacketOptionsAndOnPacketSent) { | 4513 TEST_F(WebRtcSessionTest, TestPacketOptionsAndOnPacketSent) { |
| 4338 TestPacketOptions(); | 4514 TestPacketOptions(); |
| 4339 } | 4515 } |
| 4340 | 4516 |
| 4341 // TODO(bemasc): Add a TestIceStatesBundle with BUNDLE enabled. That test | 4517 // TODO(bemasc): Add a TestIceStatesBundle with BUNDLE enabled. That test |
| 4342 // currently fails because upon disconnection and reconnection OnIceComplete is | 4518 // currently fails because upon disconnection and reconnection OnIceComplete is |
| 4343 // called more than once without returning to IceGatheringGathering. | 4519 // called more than once without returning to IceGatheringGathering. |
| 4344 | 4520 |
| 4345 INSTANTIATE_TEST_CASE_P(WebRtcSessionTests, | 4521 INSTANTIATE_TEST_CASE_P(WebRtcSessionTests, |
| 4346 WebRtcSessionTest, | 4522 WebRtcSessionTest, |
| 4347 testing::Values(ALREADY_GENERATED, | 4523 testing::Values(ALREADY_GENERATED, |
| 4348 DTLS_IDENTITY_STORE)); | 4524 DTLS_IDENTITY_STORE)); |
| OLD | NEW |