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 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 136 "a=fmtp:96 apt=0\r\n"; | 136 "a=fmtp:96 apt=0\r\n"; |
| 137 | 137 |
| 138 static const char kStream1[] = "stream1"; | 138 static const char kStream1[] = "stream1"; |
| 139 static const char kVideoTrack1[] = "video1"; | 139 static const char kVideoTrack1[] = "video1"; |
| 140 static const char kAudioTrack1[] = "audio1"; | 140 static const char kAudioTrack1[] = "audio1"; |
| 141 | 141 |
| 142 static const char kStream2[] = "stream2"; | 142 static const char kStream2[] = "stream2"; |
| 143 static const char kVideoTrack2[] = "video2"; | 143 static const char kVideoTrack2[] = "video2"; |
| 144 static const char kAudioTrack2[] = "audio2"; | 144 static const char kAudioTrack2[] = "audio2"; |
| 145 | 145 |
| 146 static constexpr bool kStopped = true; | |
| 147 static constexpr bool kActive = false; | |
| 148 | |
| 146 enum RTCCertificateGenerationMethod { ALREADY_GENERATED, DTLS_IDENTITY_STORE }; | 149 enum RTCCertificateGenerationMethod { ALREADY_GENERATED, DTLS_IDENTITY_STORE }; |
| 147 | 150 |
| 148 class MockIceObserver : public webrtc::IceObserver { | 151 class MockIceObserver : public webrtc::IceObserver { |
| 149 public: | 152 public: |
| 150 MockIceObserver() | 153 MockIceObserver() |
| 151 : oncandidatesready_(false), | 154 : oncandidatesready_(false), |
| 152 ice_connection_state_(PeerConnectionInterface::kIceConnectionNew), | 155 ice_connection_state_(PeerConnectionInterface::kIceConnectionNew), |
| 153 ice_gathering_state_(PeerConnectionInterface::kIceGatheringNew) { | 156 ice_gathering_state_(PeerConnectionInterface::kIceGatheringNew) { |
| 154 } | 157 } |
| 155 | 158 |
| (...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 391 metrics_observer_(new rtc::RefCountedObject<FakeMetricsObserver>()) { | 394 metrics_observer_(new rtc::RefCountedObject<FakeMetricsObserver>()) { |
| 392 cricket::ServerAddresses stun_servers; | 395 cricket::ServerAddresses stun_servers; |
| 393 stun_servers.insert(stun_socket_addr_); | 396 stun_servers.insert(stun_socket_addr_); |
| 394 allocator_.reset(new cricket::BasicPortAllocator( | 397 allocator_.reset(new cricket::BasicPortAllocator( |
| 395 &network_manager_, | 398 &network_manager_, |
| 396 stun_servers, | 399 stun_servers, |
| 397 SocketAddress(), SocketAddress(), SocketAddress())); | 400 SocketAddress(), SocketAddress(), SocketAddress())); |
| 398 allocator_->set_flags(cricket::PORTALLOCATOR_DISABLE_TCP | | 401 allocator_->set_flags(cricket::PORTALLOCATOR_DISABLE_TCP | |
| 399 cricket::PORTALLOCATOR_DISABLE_RELAY); | 402 cricket::PORTALLOCATOR_DISABLE_RELAY); |
| 400 EXPECT_TRUE(channel_manager_->Init()); | 403 EXPECT_TRUE(channel_manager_->Init()); |
| 401 desc_factory_->set_add_legacy_streams(false); | |
| 402 allocator_->set_step_delay(cricket::kMinimumStepDelay); | 404 allocator_->set_step_delay(cricket::kMinimumStepDelay); |
| 403 } | 405 } |
| 404 | 406 |
| 405 void AddInterface(const SocketAddress& addr) { | 407 void AddInterface(const SocketAddress& addr) { |
| 406 network_manager_.AddInterface(addr); | 408 network_manager_.AddInterface(addr); |
| 407 } | 409 } |
| 408 void RemoveInterface(const SocketAddress& addr) { | 410 void RemoveInterface(const SocketAddress& addr) { |
| 409 network_manager_.RemoveInterface(addr); | 411 network_manager_.RemoveInterface(addr); |
| 410 } | 412 } |
| 411 | 413 |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 500 PeerConnectionInterface::kRtcpMuxPolicyNegotiate, | 502 PeerConnectionInterface::kRtcpMuxPolicyNegotiate, |
| 501 rtc::CryptoOptions()); | 503 rtc::CryptoOptions()); |
| 502 } | 504 } |
| 503 | 505 |
| 504 void InitWithGcm() { | 506 void InitWithGcm() { |
| 505 rtc::CryptoOptions crypto_options; | 507 rtc::CryptoOptions crypto_options; |
| 506 crypto_options.enable_gcm_crypto_suites = true; | 508 crypto_options.enable_gcm_crypto_suites = true; |
| 507 InitWithCryptoOptions(crypto_options); | 509 InitWithCryptoOptions(crypto_options); |
| 508 } | 510 } |
| 509 | 511 |
| 512 // The following convenience functions can be applied for both local side and | |
| 513 // remote side. The flags can be overwritten for different use cases. | |
| 510 void SendAudioVideoStream1() { | 514 void SendAudioVideoStream1() { |
| 511 send_stream_1_ = true; | 515 send_stream_1_ = true; |
| 512 send_stream_2_ = false; | 516 send_stream_2_ = false; |
| 513 send_audio_ = true; | 517 local_send_audio_ = true; |
| 514 send_video_ = true; | 518 local_send_video_ = true; |
| 519 remote_send_audio_ = true; | |
| 520 remote_send_video_ = true; | |
| 515 } | 521 } |
| 516 | 522 |
| 517 void SendAudioVideoStream2() { | 523 void SendAudioVideoStream2() { |
| 518 send_stream_1_ = false; | 524 send_stream_1_ = false; |
| 519 send_stream_2_ = true; | 525 send_stream_2_ = true; |
| 520 send_audio_ = true; | 526 local_send_audio_ = true; |
| 521 send_video_ = true; | 527 local_send_video_ = true; |
| 528 remote_send_audio_ = true; | |
| 529 remote_send_video_ = true; | |
| 522 } | 530 } |
| 523 | 531 |
| 524 void SendAudioVideoStream1And2() { | 532 void SendAudioVideoStream1And2() { |
| 525 send_stream_1_ = true; | 533 send_stream_1_ = true; |
| 526 send_stream_2_ = true; | 534 send_stream_2_ = true; |
| 527 send_audio_ = true; | 535 local_send_audio_ = true; |
| 528 send_video_ = true; | 536 local_send_video_ = true; |
| 537 remote_send_audio_ = true; | |
| 538 remote_send_video_ = true; | |
| 529 } | 539 } |
| 530 | 540 |
| 531 void SendNothing() { | 541 void SendNothing() { |
| 532 send_stream_1_ = false; | 542 send_stream_1_ = false; |
| 533 send_stream_2_ = false; | 543 send_stream_2_ = false; |
| 534 send_audio_ = false; | 544 local_send_audio_ = false; |
| 535 send_video_ = false; | 545 local_send_video_ = false; |
| 546 remote_send_audio_ = false; | |
| 547 remote_send_video_ = false; | |
| 536 } | 548 } |
| 537 | 549 |
| 538 void SendAudioOnlyStream2() { | 550 void SendAudioOnlyStream2() { |
| 539 send_stream_1_ = false; | 551 send_stream_1_ = false; |
| 540 send_stream_2_ = true; | 552 send_stream_2_ = true; |
| 541 send_audio_ = true; | 553 local_send_audio_ = true; |
| 542 send_video_ = false; | 554 local_send_video_ = false; |
| 555 remote_send_audio_ = true; | |
| 556 remote_send_video_ = false; | |
| 543 } | 557 } |
| 544 | 558 |
| 545 void SendVideoOnlyStream2() { | 559 void SendVideoOnlyStream2() { |
| 546 send_stream_1_ = false; | 560 send_stream_1_ = false; |
| 547 send_stream_2_ = true; | 561 send_stream_2_ = true; |
| 548 send_audio_ = false; | 562 local_send_audio_ = false; |
| 549 send_video_ = true; | 563 local_send_video_ = true; |
| 550 } | 564 remote_send_audio_ = false; |
| 551 | 565 remote_send_video_ = true; |
| 552 void AddStreamsToOptions(cricket::MediaSessionOptions* session_options) { | 566 } |
| 553 if (send_stream_1_ && send_audio_) { | 567 |
| 554 session_options->AddSendStream(cricket::MEDIA_TYPE_AUDIO, kAudioTrack1, | 568 // Helper function used to add a specific media section to the |
| 555 kStream1); | 569 // |session_options|. |
| 556 } | 570 void AddMediaSection(cricket::MediaType type, |
| 557 if (send_stream_1_ && send_video_) { | 571 const std::string& mid, |
| 558 session_options->AddSendStream(cricket::MEDIA_TYPE_VIDEO, kVideoTrack1, | 572 cricket::MediaContentDirection direction, |
| 559 kStream1); | 573 bool stopped, |
| 560 } | 574 cricket::MediaSessionOptions* opts) { |
| 561 if (send_stream_2_ && send_audio_) { | 575 opts->media_description_options.push_back(cricket::MediaDescriptionOptions( |
| 562 session_options->AddSendStream(cricket::MEDIA_TYPE_AUDIO, kAudioTrack2, | 576 type, mid, |
| 563 kStream2); | 577 cricket::RtpTransceiverDirection::FromMediaContentDirection(direction), |
| 564 } | 578 stopped)); |
| 565 if (send_stream_2_ && send_video_) { | 579 } |
| 566 session_options->AddSendStream(cricket::MEDIA_TYPE_VIDEO, kVideoTrack2, | 580 |
| 567 kStream2); | 581 // Add the media sections to the options from |offered_media_sections_| when |
| 568 } | 582 // creating an answer or a new offer. |
| 569 if (data_channel_ && session_->data_channel_type() == cricket::DCT_RTP) { | 583 // This duplicates a lot of logic from PeerConnection but this can be fixed |
| 570 session_options->AddSendStream(cricket::MEDIA_TYPE_DATA, | 584 // when PeerConnection and WebRtcSession are merged. |
| 571 data_channel_->label(), | 585 void AddExistingMediaSectionsAndSendersToOptions( |
| 572 data_channel_->label()); | 586 cricket::MediaSessionOptions* session_options, |
| 587 bool send_audio, | |
| 588 bool recv_audio, | |
| 589 bool send_video, | |
| 590 bool recv_video) { | |
| 591 int num_sim_layer = 1; | |
| 592 for (auto media_description_options : offered_media_sections_) { | |
| 593 if (media_description_options.type == cricket::MEDIA_TYPE_AUDIO) { | |
| 594 bool stopped = !send_audio && !recv_audio; | |
| 595 auto media_desc_options = cricket::MediaDescriptionOptions( | |
| 596 cricket::MEDIA_TYPE_AUDIO, media_description_options.mid, | |
| 597 cricket::RtpTransceiverDirection(send_audio, recv_audio), stopped); | |
| 598 if (send_stream_1_ && send_audio) { | |
| 599 media_desc_options.AddAudioSender(kAudioTrack1, kStream1); | |
| 600 } | |
| 601 if (send_stream_2_ && send_audio) { | |
| 602 media_desc_options.AddAudioSender(kAudioTrack2, kStream2); | |
| 603 } | |
| 604 session_options->media_description_options.push_back( | |
| 605 media_desc_options); | |
| 606 } else if (media_description_options.type == cricket::MEDIA_TYPE_VIDEO) { | |
| 607 bool stopped = !send_video && !recv_video; | |
| 608 auto media_desc_options = cricket::MediaDescriptionOptions( | |
| 609 cricket::MEDIA_TYPE_VIDEO, media_description_options.mid, | |
| 610 cricket::RtpTransceiverDirection(send_video, recv_video), stopped); | |
| 611 if (send_stream_1_ && send_video) { | |
| 612 media_desc_options.AddVideoSender(kVideoTrack1, kStream1, | |
| 613 num_sim_layer); | |
| 614 } | |
| 615 if (send_stream_2_ && send_video) { | |
| 616 media_desc_options.AddVideoSender(kVideoTrack2, kStream2, | |
| 617 num_sim_layer); | |
| 618 } | |
| 619 session_options->media_description_options.push_back( | |
| 620 media_desc_options); | |
| 621 } else if (media_description_options.type == cricket::MEDIA_TYPE_DATA) { | |
| 622 session_options->media_description_options.push_back( | |
| 623 cricket::MediaDescriptionOptions( | |
| 624 cricket::MEDIA_TYPE_DATA, media_description_options.mid, | |
| 625 // Direction for data sections is meaningless, but legacy | |
| 626 // endpoints might expect sendrecv. | |
| 627 cricket::RtpTransceiverDirection(true, true), false)); | |
| 628 } else { | |
| 629 RTC_NOTREACHED(); | |
| 630 } | |
| 631 } | |
| 632 } | |
| 633 | |
| 634 // Add the existing media sections first and then add new media sections if | |
| 635 // needed. | |
| 636 void AddMediaSectionsAndSendersToOptions( | |
| 637 cricket::MediaSessionOptions* session_options, | |
| 638 bool send_audio, | |
| 639 bool recv_audio, | |
| 640 bool send_video, | |
| 641 bool recv_video) { | |
| 642 AddExistingMediaSectionsAndSendersToOptions( | |
| 643 session_options, send_audio, recv_audio, send_video, recv_video); | |
| 644 | |
| 645 if (!session_options->has_audio() && (send_audio || recv_audio)) { | |
| 646 cricket::MediaDescriptionOptions media_desc_options = | |
| 647 cricket::MediaDescriptionOptions( | |
| 648 cricket::MEDIA_TYPE_AUDIO, cricket::CN_AUDIO, | |
| 649 cricket::RtpTransceiverDirection(send_audio, recv_audio), | |
| 650 kActive); | |
| 651 if (send_stream_1_ && send_audio) { | |
| 652 media_desc_options.AddAudioSender(kAudioTrack1, kStream1); | |
| 653 } | |
| 654 if (send_stream_2_ && send_audio) { | |
| 655 media_desc_options.AddAudioSender(kAudioTrack2, kStream2); | |
| 656 } | |
| 657 session_options->media_description_options.push_back(media_desc_options); | |
| 658 offered_media_sections_.push_back(media_desc_options); | |
| 659 } | |
| 660 | |
| 661 if (!session_options->has_video() && (send_video || recv_video)) { | |
| 662 cricket::MediaDescriptionOptions media_desc_options = | |
| 663 cricket::MediaDescriptionOptions( | |
| 664 cricket::MEDIA_TYPE_VIDEO, cricket::CN_VIDEO, | |
| 665 cricket::RtpTransceiverDirection(send_video, recv_video), | |
| 666 kActive); | |
| 667 int num_sim_layer = 1; | |
| 668 if (send_stream_1_ && send_video) { | |
| 669 media_desc_options.AddVideoSender(kVideoTrack1, kStream1, | |
| 670 num_sim_layer); | |
| 671 } | |
| 672 if (send_stream_2_ && send_video) { | |
| 673 media_desc_options.AddVideoSender(kVideoTrack2, kStream2, | |
| 674 num_sim_layer); | |
| 675 } | |
| 676 session_options->media_description_options.push_back(media_desc_options); | |
| 677 offered_media_sections_.push_back(media_desc_options); | |
| 678 } | |
| 679 | |
| 680 if (!session_options->has_data() && | |
| 681 (data_channel_ || | |
| 682 session_options->data_channel_type != cricket::DCT_NONE)) { | |
| 683 cricket::MediaDescriptionOptions media_desc_options = | |
| 684 cricket::MediaDescriptionOptions( | |
| 685 cricket::MEDIA_TYPE_DATA, cricket::CN_DATA, | |
| 686 cricket::RtpTransceiverDirection(true, true), kActive); | |
| 687 if (session_options->data_channel_type == cricket::DCT_RTP) { | |
| 688 media_desc_options.AddRtpDataChannel(data_channel_->label(), | |
| 689 data_channel_->label()); | |
| 690 } | |
| 691 session_options->media_description_options.push_back(media_desc_options); | |
| 692 offered_media_sections_.push_back(media_desc_options); | |
| 573 } | 693 } |
| 574 } | 694 } |
| 575 | 695 |
| 576 void GetOptionsForOffer( | 696 void GetOptionsForOffer( |
| 577 const PeerConnectionInterface::RTCOfferAnswerOptions& rtc_options, | 697 const PeerConnectionInterface::RTCOfferAnswerOptions& rtc_options, |
| 578 cricket::MediaSessionOptions* session_options) { | 698 cricket::MediaSessionOptions* session_options) { |
| 579 ASSERT_TRUE(ExtractMediaSessionOptions(rtc_options, true, session_options)); | 699 ExtractSharedMediaSessionOptions(rtc_options, session_options); |
| 580 | 700 |
| 581 AddStreamsToOptions(session_options); | 701 // |recv_X| is true by default if |offer_to_receive_X| is undefined. |
| 582 if (rtc_options.offer_to_receive_audio == | 702 bool recv_audio = rtc_options.offer_to_receive_audio != 0; |
| 583 RTCOfferAnswerOptions::kUndefined) { | 703 bool recv_video = rtc_options.offer_to_receive_video != 0; |
| 584 session_options->recv_audio = | 704 |
| 585 session_options->HasSendMediaStream(cricket::MEDIA_TYPE_AUDIO); | 705 AddMediaSectionsAndSendersToOptions(session_options, local_send_audio_, |
| 586 } | 706 recv_audio, local_send_video_, |
| 587 if (rtc_options.offer_to_receive_video == | 707 recv_video); |
| 588 RTCOfferAnswerOptions::kUndefined) { | |
| 589 session_options->recv_video = | |
| 590 session_options->HasSendMediaStream(cricket::MEDIA_TYPE_VIDEO); | |
| 591 } | |
| 592 session_options->bundle_enabled = | 708 session_options->bundle_enabled = |
| 593 session_options->bundle_enabled && | 709 session_options->bundle_enabled && |
| 594 (session_options->has_audio() || session_options->has_video() || | 710 (session_options->has_audio() || session_options->has_video() || |
| 595 session_options->has_data()); | 711 session_options->has_data()); |
| 596 | 712 |
| 597 if (session_->data_channel_type() == cricket::DCT_SCTP && data_channel_) { | |
| 598 session_options->data_channel_type = cricket::DCT_SCTP; | |
| 599 } else if (session_->data_channel_type() == cricket::DCT_QUIC) { | |
| 600 session_options->data_channel_type = cricket::DCT_QUIC; | |
| 601 } | |
| 602 | |
| 603 session_options->crypto_options = crypto_options_; | 713 session_options->crypto_options = crypto_options_; |
| 604 } | 714 } |
| 605 | 715 |
| 606 void GetOptionsForAnswer(cricket::MediaSessionOptions* session_options) { | 716 void GetOptionsForAnswer(cricket::MediaSessionOptions* session_options) { |
| 607 // ParseConstraintsForAnswer is used to set some defaults. | 717 AddExistingMediaSectionsAndSendersToOptions( |
| 608 ASSERT_TRUE(webrtc::ParseConstraintsForAnswer(nullptr, session_options)); | 718 session_options, local_send_audio_, local_recv_audio_, |
| 609 | 719 local_send_video_, local_recv_video_); |
| 610 AddStreamsToOptions(session_options); | 720 |
| 611 session_options->bundle_enabled = | 721 session_options->bundle_enabled = |
| 612 session_options->bundle_enabled && | 722 session_options->bundle_enabled && |
| 613 (session_options->has_audio() || session_options->has_video() || | 723 (session_options->has_audio() || session_options->has_video() || |
| 724 session_options->has_data()); | |
| 725 | |
| 726 if (session_->data_channel_type() != cricket::DCT_RTP) { | |
| 727 session_options->data_channel_type = session_->data_channel_type(); | |
| 728 } | |
| 729 | |
| 730 session_options->crypto_options = crypto_options_; | |
| 731 } | |
| 732 | |
| 733 void GetOptionsForRemoteAnswer( | |
| 734 cricket::MediaSessionOptions* session_options) { | |
| 735 bool recv_audio = local_send_audio_ || remote_recv_audio_; | |
| 736 bool recv_video = local_send_video_ || remote_recv_video_; | |
| 737 bool send_audio = false; | |
| 738 bool send_video = false; | |
| 739 | |
| 740 AddExistingMediaSectionsAndSendersToOptions( | |
| 741 session_options, send_audio, recv_audio, send_video, recv_video); | |
| 742 | |
| 743 session_options->bundle_enabled = | |
| 744 session_options->bundle_enabled && | |
| 745 (session_options->has_audio() || session_options->has_video() || | |
| 614 session_options->has_data()); | 746 session_options->has_data()); |
| 615 | 747 |
| 616 if (session_->data_channel_type() != cricket::DCT_RTP) { | 748 if (session_->data_channel_type() != cricket::DCT_RTP) { |
| 617 session_options->data_channel_type = session_->data_channel_type(); | 749 session_options->data_channel_type = session_->data_channel_type(); |
| 618 } | 750 } |
| 619 | 751 |
| 620 session_options->crypto_options = crypto_options_; | 752 session_options->crypto_options = crypto_options_; |
| 621 } | 753 } |
| 622 | 754 |
| 755 void GetOptionsForAudioOnlyRemoteOffer( | |
| 756 cricket::MediaSessionOptions* session_options) { | |
| 757 remote_recv_audio_ = true; | |
| 758 remote_recv_video_ = false; | |
| 759 GetOptionsForRemoteOffer(session_options); | |
| 760 } | |
| 761 | |
| 762 void GetOptionsForRemoteOffer(cricket::MediaSessionOptions* session_options) { | |
| 763 AddMediaSectionsAndSendersToOptions(session_options, remote_send_audio_, | |
| 764 remote_recv_audio_, remote_send_video_, | |
| 765 remote_recv_video_); | |
| 766 session_options->bundle_enabled = | |
| 767 (session_options->has_audio() || session_options->has_video() || | |
| 768 session_options->has_data()); | |
| 769 | |
| 770 if (session_->data_channel_type() != cricket::DCT_RTP) { | |
| 771 session_options->data_channel_type = session_->data_channel_type(); | |
| 772 } | |
| 773 | |
| 774 session_options->crypto_options = crypto_options_; | |
| 775 } | |
| 776 | |
| 623 // Creates a local offer and applies it. Starts ICE. | 777 // Creates a local offer and applies it. Starts ICE. |
| 624 // Call SendAudioVideoStreamX() before this function | 778 // Call SendAudioVideoStreamX() before this function |
| 625 // to decide which streams to create. | 779 // to decide which streams to create. |
| 626 void InitiateCall() { | 780 void InitiateCall() { |
| 627 SessionDescriptionInterface* offer = CreateOffer(); | 781 SessionDescriptionInterface* offer = CreateOffer(); |
| 628 SetLocalDescriptionWithoutError(offer); | 782 SetLocalDescriptionWithoutError(offer); |
| 629 EXPECT_TRUE_WAIT(PeerConnectionInterface::kIceGatheringNew != | 783 EXPECT_TRUE_WAIT(PeerConnectionInterface::kIceGatheringNew != |
| 630 observer_.ice_gathering_state_, | 784 observer_.ice_gathering_state_, |
| 631 kIceCandidatesTimeout); | 785 kIceCandidatesTimeout); |
| 632 } | 786 } |
| 633 | 787 |
| 634 SessionDescriptionInterface* CreateOffer() { | 788 SessionDescriptionInterface* CreateOffer() { |
| 635 PeerConnectionInterface::RTCOfferAnswerOptions options; | 789 PeerConnectionInterface::RTCOfferAnswerOptions options; |
| 636 options.offer_to_receive_audio = | 790 options.offer_to_receive_audio = |
| 637 RTCOfferAnswerOptions::kOfferToReceiveMediaTrue; | 791 RTCOfferAnswerOptions::kOfferToReceiveMediaTrue; |
| 638 | |
| 639 return CreateOffer(options); | 792 return CreateOffer(options); |
| 640 } | 793 } |
| 641 | 794 |
| 642 SessionDescriptionInterface* CreateOffer( | 795 SessionDescriptionInterface* CreateOffer( |
| 643 const PeerConnectionInterface::RTCOfferAnswerOptions options) { | 796 const PeerConnectionInterface::RTCOfferAnswerOptions options) { |
| 644 rtc::scoped_refptr<WebRtcSessionCreateSDPObserverForTest> | 797 rtc::scoped_refptr<WebRtcSessionCreateSDPObserverForTest> |
| 645 observer = new WebRtcSessionCreateSDPObserverForTest(); | 798 observer = new WebRtcSessionCreateSDPObserverForTest(); |
| 646 cricket::MediaSessionOptions session_options; | 799 cricket::MediaSessionOptions session_options; |
| 647 GetOptionsForOffer(options, &session_options); | 800 GetOptionsForOffer(options, &session_options); |
| 648 session_->CreateOffer(observer, options, session_options); | 801 session_->CreateOffer(observer, options, session_options); |
| 649 EXPECT_TRUE_WAIT( | 802 EXPECT_TRUE_WAIT( |
| 650 observer->state() != WebRtcSessionCreateSDPObserverForTest::kInit, | 803 observer->state() != WebRtcSessionCreateSDPObserverForTest::kInit, |
| 651 2000); | 804 2000); |
| 652 return observer->ReleaseDescription(); | 805 return observer->ReleaseDescription(); |
| 653 } | 806 } |
| 654 | 807 |
| 655 SessionDescriptionInterface* CreateAnswer( | 808 SessionDescriptionInterface* CreateAnswer( |
| 656 const cricket::MediaSessionOptions& options) { | 809 const cricket::MediaSessionOptions& options) { |
| 657 rtc::scoped_refptr<WebRtcSessionCreateSDPObserverForTest> observer | 810 rtc::scoped_refptr<WebRtcSessionCreateSDPObserverForTest> observer |
| 658 = new WebRtcSessionCreateSDPObserverForTest(); | 811 = new WebRtcSessionCreateSDPObserverForTest(); |
| 659 cricket::MediaSessionOptions session_options = options; | 812 cricket::MediaSessionOptions session_options = options; |
| 660 GetOptionsForAnswer(&session_options); | 813 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); | 814 session_->CreateAnswer(observer, session_options); |
| 665 EXPECT_TRUE_WAIT( | 815 EXPECT_TRUE_WAIT( |
| 666 observer->state() != WebRtcSessionCreateSDPObserverForTest::kInit, | 816 observer->state() != WebRtcSessionCreateSDPObserverForTest::kInit, |
| 667 2000); | 817 2000); |
| 668 return observer->ReleaseDescription(); | 818 return observer->ReleaseDescription(); |
| 669 } | 819 } |
| 670 | 820 |
| 671 SessionDescriptionInterface* CreateAnswer() { | 821 SessionDescriptionInterface* CreateAnswer() { |
| 672 cricket::MediaSessionOptions options; | 822 cricket::MediaSessionOptions options; |
| 673 options.recv_video = true; | 823 options.bundle_enabled = true; |
| 674 options.recv_audio = true; | |
| 675 return CreateAnswer(options); | 824 return CreateAnswer(options); |
| 676 } | 825 } |
| 677 | 826 |
| 678 bool ChannelsExist() const { | 827 bool ChannelsExist() const { |
| 679 return (session_->voice_channel() != NULL && | 828 return (session_->voice_channel() != NULL && |
| 680 session_->video_channel() != NULL); | 829 session_->video_channel() != NULL); |
| 681 } | 830 } |
| 682 | 831 |
| 683 void VerifyCryptoParams(const cricket::SessionDescription* sdp, | 832 void VerifyCryptoParams(const cricket::SessionDescription* sdp, |
| 684 bool gcm_enabled = false) { | 833 bool gcm_enabled = false) { |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 782 ASSERT_TRUE(audio != NULL); | 931 ASSERT_TRUE(audio != NULL); |
| 783 ASSERT_EQ(expected, audio->description.identity_fingerprint.get() != NULL); | 932 ASSERT_EQ(expected, audio->description.identity_fingerprint.get() != NULL); |
| 784 const TransportInfo* video = sdp->GetTransportInfoByName("video"); | 933 const TransportInfo* video = sdp->GetTransportInfoByName("video"); |
| 785 ASSERT_TRUE(video != NULL); | 934 ASSERT_TRUE(video != NULL); |
| 786 ASSERT_EQ(expected, video->description.identity_fingerprint.get() != NULL); | 935 ASSERT_EQ(expected, video->description.identity_fingerprint.get() != NULL); |
| 787 } | 936 } |
| 788 | 937 |
| 789 void VerifyAnswerFromNonCryptoOffer() { | 938 void VerifyAnswerFromNonCryptoOffer() { |
| 790 // Create an SDP without Crypto. | 939 // Create an SDP without Crypto. |
| 791 cricket::MediaSessionOptions options; | 940 cricket::MediaSessionOptions options; |
| 792 options.recv_video = true; | 941 GetOptionsForRemoteOffer(&options); |
| 793 JsepSessionDescription* offer( | 942 JsepSessionDescription* offer( |
| 794 CreateRemoteOffer(options, cricket::SEC_DISABLED)); | 943 CreateRemoteOffer(options, cricket::SEC_DISABLED)); |
| 795 ASSERT_TRUE(offer != NULL); | 944 ASSERT_TRUE(offer != NULL); |
| 796 VerifyNoCryptoParams(offer->description(), false); | 945 VerifyNoCryptoParams(offer->description(), false); |
| 797 SetRemoteDescriptionOfferExpectError(kSdpWithoutSdesCrypto, | 946 SetRemoteDescriptionOfferExpectError(kSdpWithoutSdesCrypto, |
| 798 offer); | 947 offer); |
| 799 const webrtc::SessionDescriptionInterface* answer = CreateAnswer(); | 948 const webrtc::SessionDescriptionInterface* answer = CreateAnswer(); |
| 800 // Answer should be NULL as no crypto params in offer. | 949 // Answer should be NULL as no crypto params in offer. |
| 801 ASSERT_TRUE(answer == NULL); | 950 ASSERT_TRUE(answer == NULL); |
| 802 } | 951 } |
| 803 | 952 |
| 804 void VerifyAnswerFromCryptoOffer() { | 953 void VerifyAnswerFromCryptoOffer() { |
| 805 cricket::MediaSessionOptions options; | 954 cricket::MediaSessionOptions options; |
| 806 options.recv_video = true; | 955 GetOptionsForRemoteOffer(&options); |
| 807 options.bundle_enabled = true; | 956 options.bundle_enabled = true; |
| 808 std::unique_ptr<JsepSessionDescription> offer( | 957 std::unique_ptr<JsepSessionDescription> offer( |
| 809 CreateRemoteOffer(options, cricket::SEC_REQUIRED)); | 958 CreateRemoteOffer(options, cricket::SEC_REQUIRED)); |
| 810 ASSERT_TRUE(offer.get() != NULL); | 959 ASSERT_TRUE(offer.get() != NULL); |
| 811 VerifyCryptoParams(offer->description()); | 960 VerifyCryptoParams(offer->description()); |
| 812 SetRemoteDescriptionWithoutError(offer.release()); | 961 SetRemoteDescriptionWithoutError(offer.release()); |
| 813 std::unique_ptr<SessionDescriptionInterface> answer(CreateAnswer()); | 962 std::unique_ptr<SessionDescriptionInterface> answer(CreateAnswer()); |
| 814 ASSERT_TRUE(answer.get() != NULL); | 963 ASSERT_TRUE(answer.get() != NULL); |
| 815 VerifyCryptoParams(answer->description()); | 964 VerifyCryptoParams(answer->description()); |
| 816 } | 965 } |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 919 // creates a local answer and applies is as a local description. | 1068 // creates a local answer and applies is as a local description. |
| 920 // Call SendAudioVideoStreamX() before this function | 1069 // Call SendAudioVideoStreamX() before this function |
| 921 // to decide which local and remote streams to create. | 1070 // to decide which local and remote streams to create. |
| 922 void CreateAndSetRemoteOfferAndLocalAnswer() { | 1071 void CreateAndSetRemoteOfferAndLocalAnswer() { |
| 923 SessionDescriptionInterface* offer = CreateRemoteOffer(); | 1072 SessionDescriptionInterface* offer = CreateRemoteOffer(); |
| 924 SetRemoteDescriptionWithoutError(offer); | 1073 SetRemoteDescriptionWithoutError(offer); |
| 925 SessionDescriptionInterface* answer = CreateAnswer(); | 1074 SessionDescriptionInterface* answer = CreateAnswer(); |
| 926 SetLocalDescriptionWithoutError(answer); | 1075 SetLocalDescriptionWithoutError(answer); |
| 927 } | 1076 } |
| 928 void SetLocalDescriptionWithoutError(SessionDescriptionInterface* desc) { | 1077 void SetLocalDescriptionWithoutError(SessionDescriptionInterface* desc) { |
| 929 EXPECT_TRUE(session_->SetLocalDescription(desc, NULL)); | 1078 ASSERT_TRUE(session_->SetLocalDescription(desc, nullptr)); |
| 930 session_->MaybeStartGathering(); | 1079 session_->MaybeStartGathering(); |
| 931 } | 1080 } |
| 932 void SetLocalDescriptionExpectState(SessionDescriptionInterface* desc, | 1081 void SetLocalDescriptionExpectState(SessionDescriptionInterface* desc, |
| 933 WebRtcSession::State expected_state) { | 1082 WebRtcSession::State expected_state) { |
| 934 SetLocalDescriptionWithoutError(desc); | 1083 SetLocalDescriptionWithoutError(desc); |
| 935 EXPECT_EQ(expected_state, session_->state()); | 1084 EXPECT_EQ(expected_state, session_->state()); |
| 936 } | 1085 } |
| 937 void SetLocalDescriptionExpectError(const std::string& action, | 1086 void SetLocalDescriptionExpectError(const std::string& action, |
| 938 const std::string& expected_error, | 1087 const std::string& expected_error, |
| 939 SessionDescriptionInterface* desc) { | 1088 SessionDescriptionInterface* desc) { |
| 940 std::string error; | 1089 std::string error; |
| 941 EXPECT_FALSE(session_->SetLocalDescription(desc, &error)); | 1090 EXPECT_FALSE(session_->SetLocalDescription(desc, &error)); |
| 942 std::string sdp_type = "local "; | 1091 std::string sdp_type = "local "; |
| 943 sdp_type.append(action); | 1092 sdp_type.append(action); |
| 944 EXPECT_NE(std::string::npos, error.find(sdp_type)); | 1093 EXPECT_NE(std::string::npos, error.find(sdp_type)); |
| 945 EXPECT_NE(std::string::npos, error.find(expected_error)); | 1094 EXPECT_NE(std::string::npos, error.find(expected_error)); |
| 946 } | 1095 } |
| 947 void SetLocalDescriptionOfferExpectError(const std::string& expected_error, | 1096 void SetLocalDescriptionOfferExpectError(const std::string& expected_error, |
| 948 SessionDescriptionInterface* desc) { | 1097 SessionDescriptionInterface* desc) { |
| 949 SetLocalDescriptionExpectError(SessionDescriptionInterface::kOffer, | 1098 SetLocalDescriptionExpectError(SessionDescriptionInterface::kOffer, |
| 950 expected_error, desc); | 1099 expected_error, desc); |
| 951 } | 1100 } |
| 952 void SetLocalDescriptionAnswerExpectError(const std::string& expected_error, | 1101 void SetLocalDescriptionAnswerExpectError(const std::string& expected_error, |
| 953 SessionDescriptionInterface* desc) { | 1102 SessionDescriptionInterface* desc) { |
| 954 SetLocalDescriptionExpectError(SessionDescriptionInterface::kAnswer, | 1103 SetLocalDescriptionExpectError(SessionDescriptionInterface::kAnswer, |
| 955 expected_error, desc); | 1104 expected_error, desc); |
| 956 } | 1105 } |
| 957 void SetRemoteDescriptionWithoutError(SessionDescriptionInterface* desc) { | 1106 void SetRemoteDescriptionWithoutError(SessionDescriptionInterface* desc) { |
| 958 EXPECT_TRUE(session_->SetRemoteDescription(desc, NULL)); | 1107 ASSERT_TRUE(session_->SetRemoteDescription(desc, nullptr)); |
| 959 } | 1108 } |
| 960 void SetRemoteDescriptionExpectState(SessionDescriptionInterface* desc, | 1109 void SetRemoteDescriptionExpectState(SessionDescriptionInterface* desc, |
| 961 WebRtcSession::State expected_state) { | 1110 WebRtcSession::State expected_state) { |
| 962 SetRemoteDescriptionWithoutError(desc); | 1111 SetRemoteDescriptionWithoutError(desc); |
| 963 EXPECT_EQ(expected_state, session_->state()); | 1112 EXPECT_EQ(expected_state, session_->state()); |
| 964 } | 1113 } |
| 965 void SetRemoteDescriptionExpectError(const std::string& action, | 1114 void SetRemoteDescriptionExpectError(const std::string& action, |
| 966 const std::string& expected_error, | 1115 const std::string& expected_error, |
| 967 SessionDescriptionInterface* desc) { | 1116 SessionDescriptionInterface* desc) { |
| 968 std::string error; | 1117 std::string error; |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 985 void SetRemoteDescriptionAnswerExpectError( | 1134 void SetRemoteDescriptionAnswerExpectError( |
| 986 const std::string& expected_error, SessionDescriptionInterface* desc) { | 1135 const std::string& expected_error, SessionDescriptionInterface* desc) { |
| 987 SetRemoteDescriptionExpectError(SessionDescriptionInterface::kAnswer, | 1136 SetRemoteDescriptionExpectError(SessionDescriptionInterface::kAnswer, |
| 988 expected_error, desc); | 1137 expected_error, desc); |
| 989 } | 1138 } |
| 990 | 1139 |
| 991 void CreateCryptoOfferAndNonCryptoAnswer(SessionDescriptionInterface** offer, | 1140 void CreateCryptoOfferAndNonCryptoAnswer(SessionDescriptionInterface** offer, |
| 992 SessionDescriptionInterface** nocrypto_answer) { | 1141 SessionDescriptionInterface** nocrypto_answer) { |
| 993 // Create a SDP without Crypto. | 1142 // Create a SDP without Crypto. |
| 994 cricket::MediaSessionOptions options; | 1143 cricket::MediaSessionOptions options; |
| 995 options.recv_video = true; | 1144 GetOptionsForRemoteOffer(&options); |
| 996 options.bundle_enabled = true; | 1145 options.bundle_enabled = true; |
| 997 *offer = CreateRemoteOffer(options, cricket::SEC_ENABLED); | 1146 *offer = CreateRemoteOffer(options, cricket::SEC_ENABLED); |
| 998 ASSERT_TRUE(*offer != NULL); | 1147 ASSERT_TRUE(*offer != NULL); |
| 999 VerifyCryptoParams((*offer)->description()); | 1148 VerifyCryptoParams((*offer)->description()); |
| 1000 | 1149 |
| 1001 *nocrypto_answer = CreateRemoteAnswer(*offer, options, | 1150 cricket::MediaSessionOptions answer_options; |
| 1002 cricket::SEC_DISABLED); | 1151 GetOptionsForRemoteAnswer(&answer_options); |
| 1152 *nocrypto_answer = | |
| 1153 CreateRemoteAnswer(*offer, answer_options, cricket::SEC_DISABLED); | |
| 1003 EXPECT_TRUE(*nocrypto_answer != NULL); | 1154 EXPECT_TRUE(*nocrypto_answer != NULL); |
| 1004 } | 1155 } |
| 1005 | 1156 |
| 1006 void CreateDtlsOfferAndNonDtlsAnswer(SessionDescriptionInterface** offer, | 1157 void CreateDtlsOfferAndNonDtlsAnswer(SessionDescriptionInterface** offer, |
| 1007 SessionDescriptionInterface** nodtls_answer) { | 1158 SessionDescriptionInterface** nodtls_answer) { |
| 1008 cricket::MediaSessionOptions options; | 1159 cricket::MediaSessionOptions options; |
| 1009 options.recv_video = true; | 1160 AddMediaSection(cricket::MEDIA_TYPE_AUDIO, cricket::CN_AUDIO, |
| 1161 cricket::MD_RECVONLY, kActive, &options); | |
| 1162 AddMediaSection(cricket::MEDIA_TYPE_VIDEO, cricket::CN_VIDEO, | |
| 1163 cricket::MD_RECVONLY, kActive, &options); | |
| 1010 options.bundle_enabled = true; | 1164 options.bundle_enabled = true; |
| 1011 | 1165 |
| 1012 std::unique_ptr<SessionDescriptionInterface> temp_offer( | 1166 std::unique_ptr<SessionDescriptionInterface> temp_offer( |
| 1013 CreateRemoteOffer(options, cricket::SEC_ENABLED)); | 1167 CreateRemoteOffer(options, cricket::SEC_ENABLED)); |
| 1014 | 1168 |
| 1015 *nodtls_answer = | 1169 *nodtls_answer = |
| 1016 CreateRemoteAnswer(temp_offer.get(), options, cricket::SEC_ENABLED); | 1170 CreateRemoteAnswer(temp_offer.get(), options, cricket::SEC_ENABLED); |
| 1017 EXPECT_TRUE(*nodtls_answer != NULL); | 1171 EXPECT_TRUE(*nodtls_answer != NULL); |
| 1018 VerifyFingerprintStatus((*nodtls_answer)->description(), false); | 1172 VerifyFingerprintStatus((*nodtls_answer)->description(), false); |
| 1019 VerifyCryptoParams((*nodtls_answer)->description()); | 1173 VerifyCryptoParams((*nodtls_answer)->description()); |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1061 cricket::MediaSessionOptions options, | 1215 cricket::MediaSessionOptions options, |
| 1062 const SessionDescriptionInterface* current_desc) { | 1216 const SessionDescriptionInterface* current_desc) { |
| 1063 return CreateRemoteOfferWithVersion(options, cricket::SEC_ENABLED, | 1217 return CreateRemoteOfferWithVersion(options, cricket::SEC_ENABLED, |
| 1064 kSessionVersion, current_desc); | 1218 kSessionVersion, current_desc); |
| 1065 } | 1219 } |
| 1066 | 1220 |
| 1067 JsepSessionDescription* CreateRemoteOfferWithSctpPort( | 1221 JsepSessionDescription* CreateRemoteOfferWithSctpPort( |
| 1068 const char* sctp_stream_name, int new_port, | 1222 const char* sctp_stream_name, int new_port, |
| 1069 cricket::MediaSessionOptions options) { | 1223 cricket::MediaSessionOptions options) { |
| 1070 options.data_channel_type = cricket::DCT_SCTP; | 1224 options.data_channel_type = cricket::DCT_SCTP; |
| 1071 options.AddSendStream(cricket::MEDIA_TYPE_DATA, "datachannel", | 1225 GetOptionsForRemoteOffer(&options); |
| 1072 sctp_stream_name); | |
| 1073 return ChangeSDPSctpPort(new_port, CreateRemoteOffer(options)); | 1226 return ChangeSDPSctpPort(new_port, CreateRemoteOffer(options)); |
| 1074 } | 1227 } |
| 1075 | 1228 |
| 1076 // Takes ownership of offer_basis (and deletes it). | 1229 // Takes ownership of offer_basis (and deletes it). |
| 1077 JsepSessionDescription* ChangeSDPSctpPort( | 1230 JsepSessionDescription* ChangeSDPSctpPort( |
| 1078 int new_port, webrtc::SessionDescriptionInterface *offer_basis) { | 1231 int new_port, webrtc::SessionDescriptionInterface *offer_basis) { |
| 1079 // Stringify the input SDP, swap the 5000 for 'new_port' and create a new | 1232 // Stringify the input SDP, swap the 5000 for 'new_port' and create a new |
| 1080 // SessionDescription from the mutated string. | 1233 // SessionDescription from the mutated string. |
| 1081 const char* default_port_str = "5000"; | 1234 const char* default_port_str = "5000"; |
| 1082 char new_port_str[16]; | 1235 char new_port_str[16]; |
| 1083 rtc::sprintfn(new_port_str, sizeof(new_port_str), "%d", new_port); | 1236 rtc::sprintfn(new_port_str, sizeof(new_port_str), "%d", new_port); |
| 1084 std::string offer_str; | 1237 std::string offer_str; |
| 1085 offer_basis->ToString(&offer_str); | 1238 offer_basis->ToString(&offer_str); |
| 1086 rtc::replace_substrs(default_port_str, strlen(default_port_str), | 1239 rtc::replace_substrs(default_port_str, strlen(default_port_str), |
| 1087 new_port_str, strlen(new_port_str), | 1240 new_port_str, strlen(new_port_str), |
| 1088 &offer_str); | 1241 &offer_str); |
| 1089 JsepSessionDescription* offer = new JsepSessionDescription( | 1242 JsepSessionDescription* offer = new JsepSessionDescription( |
| 1090 offer_basis->type()); | 1243 offer_basis->type()); |
| 1091 delete offer_basis; | 1244 delete offer_basis; |
| 1092 offer->Initialize(offer_str, NULL); | 1245 offer->Initialize(offer_str, NULL); |
| 1093 return offer; | 1246 return offer; |
| 1094 } | 1247 } |
| 1095 | 1248 |
| 1096 // Create a remote offer. Call SendAudioVideoStreamX() | 1249 // Create a remote offer. Call SendAudioVideoStreamX() |
| 1097 // before this function to decide which streams to create. | 1250 // before this function to decide which streams to create. |
| 1098 JsepSessionDescription* CreateRemoteOffer() { | 1251 JsepSessionDescription* CreateRemoteOffer() { |
| 1099 cricket::MediaSessionOptions options; | 1252 cricket::MediaSessionOptions options; |
| 1100 GetOptionsForAnswer(&options); | 1253 GetOptionsForRemoteOffer(&options); |
| 1101 return CreateRemoteOffer(options, session_->remote_description()); | 1254 return CreateRemoteOffer(options, session_->remote_description()); |
| 1102 } | 1255 } |
| 1103 | 1256 |
| 1104 JsepSessionDescription* CreateRemoteAnswer( | 1257 JsepSessionDescription* CreateRemoteAnswer( |
| 1105 const SessionDescriptionInterface* offer, | 1258 const SessionDescriptionInterface* offer, |
| 1106 cricket::MediaSessionOptions options, | 1259 cricket::MediaSessionOptions options, |
| 1107 cricket::SecurePolicy policy) { | 1260 cricket::SecurePolicy policy) { |
| 1108 desc_factory_->set_secure(policy); | 1261 desc_factory_->set_secure(policy); |
| 1109 const std::string session_id = | 1262 const std::string session_id = |
| 1110 rtc::ToString(rtc::CreateRandomId64()); | 1263 rtc::ToString(rtc::CreateRandomId64()); |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 1125 return CreateRemoteAnswer(offer, options, cricket::SEC_REQUIRED); | 1278 return CreateRemoteAnswer(offer, options, cricket::SEC_REQUIRED); |
| 1126 } | 1279 } |
| 1127 | 1280 |
| 1128 // Creates an answer session description. | 1281 // Creates an answer session description. |
| 1129 // Call SendAudioVideoStreamX() before this function | 1282 // Call SendAudioVideoStreamX() before this function |
| 1130 // to decide which streams to create. | 1283 // to decide which streams to create. |
| 1131 JsepSessionDescription* CreateRemoteAnswer( | 1284 JsepSessionDescription* CreateRemoteAnswer( |
| 1132 const SessionDescriptionInterface* offer) { | 1285 const SessionDescriptionInterface* offer) { |
| 1133 cricket::MediaSessionOptions options; | 1286 cricket::MediaSessionOptions options; |
| 1134 GetOptionsForAnswer(&options); | 1287 GetOptionsForAnswer(&options); |
| 1288 options.bundle_enabled = true; | |
| 1135 return CreateRemoteAnswer(offer, options, cricket::SEC_REQUIRED); | 1289 return CreateRemoteAnswer(offer, options, cricket::SEC_REQUIRED); |
| 1136 } | 1290 } |
| 1137 | 1291 |
| 1138 void TestSessionCandidatesWithBundleRtcpMux(bool bundle, bool rtcp_mux) { | 1292 void TestSessionCandidatesWithBundleRtcpMux(bool bundle, bool rtcp_mux) { |
| 1139 AddInterface(rtc::SocketAddress(kClientAddrHost1, kClientAddrPort)); | 1293 AddInterface(rtc::SocketAddress(kClientAddrHost1, kClientAddrPort)); |
| 1140 Init(); | 1294 Init(); |
| 1141 SendAudioVideoStream1(); | 1295 SendAudioVideoStream1(); |
| 1142 | 1296 |
| 1143 PeerConnectionInterface::RTCOfferAnswerOptions options; | 1297 PeerConnectionInterface::RTCOfferAnswerOptions options; |
| 1144 options.use_rtp_mux = bundle; | 1298 options.use_rtp_mux = bundle; |
| (...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1448 InitWithDtlsIdentityGenFail(); | 1602 InitWithDtlsIdentityGenFail(); |
| 1449 VerifyMultipleAsyncCreateDescriptionAfterInit(false, type); | 1603 VerifyMultipleAsyncCreateDescriptionAfterInit(false, type); |
| 1450 } | 1604 } |
| 1451 | 1605 |
| 1452 void VerifyMultipleAsyncCreateDescriptionAfterInit( | 1606 void VerifyMultipleAsyncCreateDescriptionAfterInit( |
| 1453 bool success, CreateSessionDescriptionRequest::Type type) { | 1607 bool success, CreateSessionDescriptionRequest::Type type) { |
| 1454 RTC_CHECK(session_); | 1608 RTC_CHECK(session_); |
| 1455 SetFactoryDtlsSrtp(); | 1609 SetFactoryDtlsSrtp(); |
| 1456 if (type == CreateSessionDescriptionRequest::kAnswer) { | 1610 if (type == CreateSessionDescriptionRequest::kAnswer) { |
| 1457 cricket::MediaSessionOptions options; | 1611 cricket::MediaSessionOptions options; |
| 1612 GetOptionsForRemoteOffer(&options); | |
| 1458 std::unique_ptr<JsepSessionDescription> offer( | 1613 std::unique_ptr<JsepSessionDescription> offer( |
| 1459 CreateRemoteOffer(options, cricket::SEC_DISABLED)); | 1614 CreateRemoteOffer(options, cricket::SEC_DISABLED)); |
| 1460 ASSERT_TRUE(offer.get() != NULL); | 1615 ASSERT_TRUE(offer.get() != NULL); |
| 1461 SetRemoteDescriptionWithoutError(offer.release()); | 1616 SetRemoteDescriptionWithoutError(offer.release()); |
| 1462 } | 1617 } |
| 1463 | 1618 |
| 1464 PeerConnectionInterface::RTCOfferAnswerOptions options; | 1619 PeerConnectionInterface::RTCOfferAnswerOptions options; |
| 1465 cricket::MediaSessionOptions session_options; | 1620 cricket::MediaSessionOptions offer_session_options; |
| 1621 cricket::MediaSessionOptions answer_session_options; | |
| 1622 GetOptionsForOffer(options, &offer_session_options); | |
| 1623 GetOptionsForAnswer(&answer_session_options); | |
| 1466 const int kNumber = 3; | 1624 const int kNumber = 3; |
| 1467 rtc::scoped_refptr<WebRtcSessionCreateSDPObserverForTest> | 1625 rtc::scoped_refptr<WebRtcSessionCreateSDPObserverForTest> |
| 1468 observers[kNumber]; | 1626 observers[kNumber]; |
| 1469 for (int i = 0; i < kNumber; ++i) { | 1627 for (int i = 0; i < kNumber; ++i) { |
| 1470 observers[i] = new WebRtcSessionCreateSDPObserverForTest(); | 1628 observers[i] = new WebRtcSessionCreateSDPObserverForTest(); |
| 1471 if (type == CreateSessionDescriptionRequest::kOffer) { | 1629 if (type == CreateSessionDescriptionRequest::kOffer) { |
| 1472 session_->CreateOffer(observers[i], options, session_options); | 1630 session_->CreateOffer(observers[i], options, offer_session_options); |
| 1473 } else { | 1631 } else { |
| 1474 session_->CreateAnswer(observers[i], session_options); | 1632 session_->CreateAnswer(observers[i], answer_session_options); |
| 1475 } | 1633 } |
| 1476 } | 1634 } |
| 1477 | 1635 |
| 1478 WebRtcSessionCreateSDPObserverForTest::State expected_state = | 1636 WebRtcSessionCreateSDPObserverForTest::State expected_state = |
| 1479 success ? WebRtcSessionCreateSDPObserverForTest::kSucceeded : | 1637 success ? WebRtcSessionCreateSDPObserverForTest::kSucceeded : |
| 1480 WebRtcSessionCreateSDPObserverForTest::kFailed; | 1638 WebRtcSessionCreateSDPObserverForTest::kFailed; |
| 1481 | 1639 |
| 1482 for (int i = 0; i < kNumber; ++i) { | 1640 for (int i = 0; i < kNumber; ++i) { |
| 1483 EXPECT_EQ_WAIT(expected_state, observers[i]->state(), 1000); | 1641 EXPECT_EQ_WAIT(expected_state, observers[i]->state(), 1000); |
| 1484 if (success) { | 1642 if (success) { |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1522 PeerConnectionFactoryInterface::Options options_; | 1680 PeerConnectionFactoryInterface::Options options_; |
| 1523 PeerConnectionInterface::RTCConfiguration configuration_; | 1681 PeerConnectionInterface::RTCConfiguration configuration_; |
| 1524 std::unique_ptr<WebRtcSessionForTest> session_; | 1682 std::unique_ptr<WebRtcSessionForTest> session_; |
| 1525 MockIceObserver observer_; | 1683 MockIceObserver observer_; |
| 1526 cricket::FakeVideoMediaChannel* video_channel_; | 1684 cricket::FakeVideoMediaChannel* video_channel_; |
| 1527 cricket::FakeVoiceMediaChannel* voice_channel_; | 1685 cricket::FakeVoiceMediaChannel* voice_channel_; |
| 1528 rtc::scoped_refptr<FakeMetricsObserver> metrics_observer_; | 1686 rtc::scoped_refptr<FakeMetricsObserver> metrics_observer_; |
| 1529 // The following flags affect options created for CreateOffer/CreateAnswer. | 1687 // The following flags affect options created for CreateOffer/CreateAnswer. |
| 1530 bool send_stream_1_ = false; | 1688 bool send_stream_1_ = false; |
| 1531 bool send_stream_2_ = false; | 1689 bool send_stream_2_ = false; |
| 1532 bool send_audio_ = false; | 1690 bool local_send_audio_ = false; |
| 1533 bool send_video_ = false; | 1691 bool local_send_video_ = false; |
| 1692 bool local_recv_audio_ = true; | |
| 1693 bool local_recv_video_ = true; | |
| 1694 bool remote_send_audio_ = false; | |
| 1695 bool remote_send_video_ = false; | |
| 1696 bool remote_recv_audio_ = true; | |
| 1697 bool remote_recv_video_ = true; | |
| 1698 std::vector<cricket::MediaDescriptionOptions> offered_media_sections_; | |
| 1534 rtc::scoped_refptr<DataChannel> data_channel_; | 1699 rtc::scoped_refptr<DataChannel> data_channel_; |
| 1535 // Last values received from data channel creation signal. | 1700 // Last values received from data channel creation signal. |
| 1536 std::string last_data_channel_label_; | 1701 std::string last_data_channel_label_; |
| 1537 InternalDataChannelInit last_data_channel_config_; | 1702 InternalDataChannelInit last_data_channel_config_; |
| 1538 rtc::CryptoOptions crypto_options_; | 1703 rtc::CryptoOptions crypto_options_; |
| 1539 }; | 1704 }; |
| 1540 | 1705 |
| 1541 TEST_P(WebRtcSessionTest, TestInitializeWithDtls) { | 1706 TEST_P(WebRtcSessionTest, TestInitializeWithDtls) { |
| 1542 InitWithDtls(GetParam()); | 1707 InitWithDtls(GetParam()); |
| 1543 // SDES is disabled when DTLS is on. | 1708 // 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 | 1928 // answer without SDES or DTLS --> success |
| 1764 // TestCreateAnswerReceiveOfferWithoutEncryption: set remote offer and local | 1929 // TestCreateAnswerReceiveOfferWithoutEncryption: set remote offer and local |
| 1765 // answer without SDES or DTLS --> success | 1930 // answer without SDES or DTLS --> success |
| 1766 // | 1931 // |
| 1767 | 1932 |
| 1768 // Test that we return a failure when applying a remote/local offer that doesn't | 1933 // Test that we return a failure when applying a remote/local offer that doesn't |
| 1769 // have cryptos enabled when DTLS is off. | 1934 // have cryptos enabled when DTLS is off. |
| 1770 TEST_F(WebRtcSessionTest, TestSetNonSdesOfferWhenSdesOn) { | 1935 TEST_F(WebRtcSessionTest, TestSetNonSdesOfferWhenSdesOn) { |
| 1771 Init(); | 1936 Init(); |
| 1772 cricket::MediaSessionOptions options; | 1937 cricket::MediaSessionOptions options; |
| 1773 options.recv_video = true; | 1938 GetOptionsForRemoteOffer(&options); |
| 1774 JsepSessionDescription* offer = CreateRemoteOffer( | 1939 JsepSessionDescription* offer = CreateRemoteOffer( |
| 1775 options, cricket::SEC_DISABLED); | 1940 options, cricket::SEC_DISABLED); |
| 1776 ASSERT_TRUE(offer != NULL); | 1941 ASSERT_TRUE(offer != NULL); |
| 1777 VerifyNoCryptoParams(offer->description(), false); | 1942 VerifyNoCryptoParams(offer->description(), false); |
| 1778 // SetRemoteDescription and SetLocalDescription will take the ownership of | 1943 // SetRemoteDescription and SetLocalDescription will take the ownership of |
| 1779 // the offer. | 1944 // the offer. |
| 1780 SetRemoteDescriptionOfferExpectError(kSdpWithoutSdesCrypto, offer); | 1945 SetRemoteDescriptionOfferExpectError(kSdpWithoutSdesCrypto, offer); |
| 1781 offer = CreateRemoteOffer(options, cricket::SEC_DISABLED); | 1946 offer = CreateRemoteOffer(options, cricket::SEC_DISABLED); |
| 1782 ASSERT_TRUE(offer != NULL); | 1947 ASSERT_TRUE(offer != NULL); |
| 1783 SetLocalDescriptionOfferExpectError(kSdpWithoutSdesCrypto, offer); | 1948 SetLocalDescriptionOfferExpectError(kSdpWithoutSdesCrypto, offer); |
| (...skipping 25 matching lines...) Expand all Loading... | |
| 1809 SetRemoteDescriptionAnswerExpectError(kSdpWithoutSdesCrypto, answer); | 1974 SetRemoteDescriptionAnswerExpectError(kSdpWithoutSdesCrypto, answer); |
| 1810 } | 1975 } |
| 1811 | 1976 |
| 1812 // Test that we accept an offer with a DTLS fingerprint when DTLS is on | 1977 // 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. | 1978 // and that we return an answer with a DTLS fingerprint. |
| 1814 TEST_P(WebRtcSessionTest, TestReceiveDtlsOfferCreateDtlsAnswer) { | 1979 TEST_P(WebRtcSessionTest, TestReceiveDtlsOfferCreateDtlsAnswer) { |
| 1815 SendAudioVideoStream1(); | 1980 SendAudioVideoStream1(); |
| 1816 InitWithDtls(GetParam()); | 1981 InitWithDtls(GetParam()); |
| 1817 SetFactoryDtlsSrtp(); | 1982 SetFactoryDtlsSrtp(); |
| 1818 cricket::MediaSessionOptions options; | 1983 cricket::MediaSessionOptions options; |
| 1819 options.recv_video = true; | 1984 GetOptionsForRemoteOffer(&options); |
| 1820 JsepSessionDescription* offer = | 1985 JsepSessionDescription* offer = |
| 1821 CreateRemoteOffer(options, cricket::SEC_DISABLED); | 1986 CreateRemoteOffer(options, cricket::SEC_DISABLED); |
| 1822 ASSERT_TRUE(offer != NULL); | 1987 ASSERT_TRUE(offer != NULL); |
| 1823 VerifyFingerprintStatus(offer->description(), true); | 1988 VerifyFingerprintStatus(offer->description(), true); |
| 1824 VerifyNoCryptoParams(offer->description(), true); | 1989 VerifyNoCryptoParams(offer->description(), true); |
| 1825 | 1990 |
| 1826 // SetRemoteDescription will take the ownership of the offer. | 1991 // SetRemoteDescription will take the ownership of the offer. |
| 1827 SetRemoteDescriptionWithoutError(offer); | 1992 SetRemoteDescriptionWithoutError(offer); |
| 1828 | 1993 |
| 1829 // Verify that we get a crypto fingerprint in the answer. | 1994 // Verify that we get a crypto fingerprint in the answer. |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 1848 SessionDescriptionInterface* offer = CreateOffer(); | 2013 SessionDescriptionInterface* offer = CreateOffer(); |
| 1849 ASSERT_TRUE(offer != NULL); | 2014 ASSERT_TRUE(offer != NULL); |
| 1850 VerifyFingerprintStatus(offer->description(), true); | 2015 VerifyFingerprintStatus(offer->description(), true); |
| 1851 // Check that we don't have an a=crypto line in the offer. | 2016 // Check that we don't have an a=crypto line in the offer. |
| 1852 VerifyNoCryptoParams(offer->description(), true); | 2017 VerifyNoCryptoParams(offer->description(), true); |
| 1853 | 2018 |
| 1854 // Now set the local description, which should work, even without a=crypto. | 2019 // Now set the local description, which should work, even without a=crypto. |
| 1855 SetLocalDescriptionWithoutError(offer); | 2020 SetLocalDescriptionWithoutError(offer); |
| 1856 | 2021 |
| 1857 cricket::MediaSessionOptions options; | 2022 cricket::MediaSessionOptions options; |
| 1858 options.recv_video = true; | 2023 GetOptionsForAnswer(&options); |
| 1859 JsepSessionDescription* answer = | 2024 JsepSessionDescription* answer = |
| 1860 CreateRemoteAnswer(offer, options, cricket::SEC_DISABLED); | 2025 CreateRemoteAnswer(offer, options, cricket::SEC_DISABLED); |
| 1861 ASSERT_TRUE(answer != NULL); | 2026 ASSERT_TRUE(answer != NULL); |
| 1862 VerifyFingerprintStatus(answer->description(), true); | 2027 VerifyFingerprintStatus(answer->description(), true); |
| 1863 VerifyNoCryptoParams(answer->description(), true); | 2028 VerifyNoCryptoParams(answer->description(), true); |
| 1864 | 2029 |
| 1865 // SetRemoteDescription will take the ownership of the answer. | 2030 // SetRemoteDescription will take the ownership of the answer. |
| 1866 SetRemoteDescriptionWithoutError(answer); | 2031 SetRemoteDescriptionWithoutError(answer); |
| 1867 } | 2032 } |
| 1868 | 2033 |
| 1869 // Test that if we support DTLS and the other side didn't offer a fingerprint, | 2034 // Test that if we support DTLS and the other side didn't offer a fingerprint, |
| 1870 // we will fail to set the remote description. | 2035 // we will fail to set the remote description. |
| 1871 TEST_P(WebRtcSessionTest, TestReceiveNonDtlsOfferWhenDtlsOn) { | 2036 TEST_P(WebRtcSessionTest, TestReceiveNonDtlsOfferWhenDtlsOn) { |
| 1872 InitWithDtls(GetParam()); | 2037 InitWithDtls(GetParam()); |
| 1873 cricket::MediaSessionOptions options; | 2038 cricket::MediaSessionOptions options; |
| 1874 options.recv_video = true; | 2039 GetOptionsForRemoteOffer(&options); |
| 1875 options.bundle_enabled = true; | 2040 options.bundle_enabled = true; |
| 1876 JsepSessionDescription* offer = CreateRemoteOffer( | 2041 JsepSessionDescription* offer = CreateRemoteOffer( |
| 1877 options, cricket::SEC_REQUIRED); | 2042 options, cricket::SEC_REQUIRED); |
| 1878 ASSERT_TRUE(offer != NULL); | 2043 ASSERT_TRUE(offer != NULL); |
| 1879 VerifyFingerprintStatus(offer->description(), false); | 2044 VerifyFingerprintStatus(offer->description(), false); |
| 1880 VerifyCryptoParams(offer->description()); | 2045 VerifyCryptoParams(offer->description()); |
| 1881 | 2046 |
| 1882 // SetRemoteDescription will take the ownership of the offer. | 2047 // SetRemoteDescription will take the ownership of the offer. |
| 1883 SetRemoteDescriptionOfferExpectError( | 2048 SetRemoteDescriptionOfferExpectError( |
| 1884 kSdpWithoutDtlsFingerprint, offer); | 2049 kSdpWithoutDtlsFingerprint, offer); |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 1902 SetRemoteDescriptionWithoutError(offer); | 2067 SetRemoteDescriptionWithoutError(offer); |
| 1903 SetLocalDescriptionAnswerExpectError( | 2068 SetLocalDescriptionAnswerExpectError( |
| 1904 kSdpWithoutDtlsFingerprint, answer); | 2069 kSdpWithoutDtlsFingerprint, answer); |
| 1905 } | 2070 } |
| 1906 | 2071 |
| 1907 // Test that we return a failure when applying a remote answer that doesn't have | 2072 // Test that we return a failure when applying a remote answer that doesn't have |
| 1908 // a DTLS fingerprint when DTLS is required. | 2073 // a DTLS fingerprint when DTLS is required. |
| 1909 TEST_P(WebRtcSessionTest, TestSetRemoteNonDtlsAnswerWhenDtlsOn) { | 2074 TEST_P(WebRtcSessionTest, TestSetRemoteNonDtlsAnswerWhenDtlsOn) { |
| 1910 InitWithDtls(GetParam()); | 2075 InitWithDtls(GetParam()); |
| 1911 SessionDescriptionInterface* offer = CreateOffer(); | 2076 SessionDescriptionInterface* offer = CreateOffer(); |
| 1912 cricket::MediaSessionOptions options; | 2077 cricket::MediaSessionOptions offer_options; |
| 1913 options.recv_video = true; | 2078 GetOptionsForRemoteOffer(&offer_options); |
| 2079 | |
| 1914 std::unique_ptr<SessionDescriptionInterface> temp_offer( | 2080 std::unique_ptr<SessionDescriptionInterface> temp_offer( |
| 1915 CreateRemoteOffer(options, cricket::SEC_ENABLED)); | 2081 CreateRemoteOffer(offer_options, cricket::SEC_ENABLED)); |
| 1916 JsepSessionDescription* answer = | 2082 |
| 1917 CreateRemoteAnswer(temp_offer.get(), options, cricket::SEC_ENABLED); | 2083 cricket::MediaSessionOptions answer_options; |
| 2084 GetOptionsForAnswer(&answer_options); | |
| 2085 JsepSessionDescription* answer = CreateRemoteAnswer( | |
| 2086 temp_offer.get(), answer_options, cricket::SEC_ENABLED); | |
| 1918 | 2087 |
| 1919 // SetRemoteDescription and SetLocalDescription will take the ownership of | 2088 // SetRemoteDescription and SetLocalDescription will take the ownership of |
| 1920 // the offer and answer. | 2089 // the offer and answer. |
| 1921 SetLocalDescriptionWithoutError(offer); | 2090 SetLocalDescriptionWithoutError(offer); |
| 1922 SetRemoteDescriptionAnswerExpectError( | 2091 SetRemoteDescriptionAnswerExpectError( |
| 1923 kSdpWithoutDtlsFingerprint, answer); | 2092 kSdpWithoutDtlsFingerprint, answer); |
| 1924 } | 2093 } |
| 1925 | 2094 |
| 1926 // Test that we create a local offer without SDES or DTLS and accept a remote | 2095 // 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. | 2096 // answer without SDES or DTLS when encryption is disabled. |
| 1928 TEST_P(WebRtcSessionTest, TestCreateOfferReceiveAnswerWithoutEncryption) { | 2097 TEST_P(WebRtcSessionTest, TestCreateOfferReceiveAnswerWithoutEncryption) { |
| 1929 SendAudioVideoStream1(); | 2098 SendAudioVideoStream1(); |
| 1930 options_.disable_encryption = true; | 2099 options_.disable_encryption = true; |
| 1931 InitWithDtls(GetParam()); | 2100 InitWithDtls(GetParam()); |
| 1932 | 2101 |
| 1933 // Verify that we get a crypto fingerprint in the answer. | 2102 // Verify that we get a crypto fingerprint in the answer. |
| 1934 SessionDescriptionInterface* offer = CreateOffer(); | 2103 SessionDescriptionInterface* offer = CreateOffer(); |
| 1935 ASSERT_TRUE(offer != NULL); | 2104 ASSERT_TRUE(offer != NULL); |
| 1936 VerifyFingerprintStatus(offer->description(), false); | 2105 VerifyFingerprintStatus(offer->description(), false); |
| 1937 // Check that we don't have an a=crypto line in the offer. | 2106 // Check that we don't have an a=crypto line in the offer. |
| 1938 VerifyNoCryptoParams(offer->description(), false); | 2107 VerifyNoCryptoParams(offer->description(), false); |
| 1939 | 2108 |
| 1940 // Now set the local description, which should work, even without a=crypto. | 2109 // Now set the local description, which should work, even without a=crypto. |
| 1941 SetLocalDescriptionWithoutError(offer); | 2110 SetLocalDescriptionWithoutError(offer); |
| 1942 | 2111 |
| 1943 cricket::MediaSessionOptions options; | 2112 cricket::MediaSessionOptions options; |
| 1944 options.recv_video = true; | 2113 GetOptionsForAnswer(&options); |
| 1945 JsepSessionDescription* answer = | 2114 JsepSessionDescription* answer = |
| 1946 CreateRemoteAnswer(offer, options, cricket::SEC_DISABLED); | 2115 CreateRemoteAnswer(offer, options, cricket::SEC_DISABLED); |
| 1947 ASSERT_TRUE(answer != NULL); | 2116 ASSERT_TRUE(answer != NULL); |
| 1948 VerifyFingerprintStatus(answer->description(), false); | 2117 VerifyFingerprintStatus(answer->description(), false); |
| 1949 VerifyNoCryptoParams(answer->description(), false); | 2118 VerifyNoCryptoParams(answer->description(), false); |
| 1950 | 2119 |
| 1951 // SetRemoteDescription will take the ownership of the answer. | 2120 // SetRemoteDescription will take the ownership of the answer. |
| 1952 SetRemoteDescriptionWithoutError(answer); | 2121 SetRemoteDescriptionWithoutError(answer); |
| 1953 } | 2122 } |
| 1954 | 2123 |
| 1955 // Test that we create a local answer without SDES or DTLS and accept a remote | 2124 // 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. | 2125 // offer without SDES or DTLS when encryption is disabled. |
| 1957 TEST_P(WebRtcSessionTest, TestCreateAnswerReceiveOfferWithoutEncryption) { | 2126 TEST_P(WebRtcSessionTest, TestCreateAnswerReceiveOfferWithoutEncryption) { |
| 1958 options_.disable_encryption = true; | 2127 options_.disable_encryption = true; |
| 1959 InitWithDtls(GetParam()); | 2128 InitWithDtls(GetParam()); |
| 1960 | 2129 |
| 1961 cricket::MediaSessionOptions options; | 2130 cricket::MediaSessionOptions options; |
| 1962 options.recv_video = true; | 2131 GetOptionsForRemoteOffer(&options); |
| 1963 JsepSessionDescription* offer = | 2132 JsepSessionDescription* offer = |
| 1964 CreateRemoteOffer(options, cricket::SEC_DISABLED); | 2133 CreateRemoteOffer(options, cricket::SEC_DISABLED); |
| 1965 ASSERT_TRUE(offer != NULL); | 2134 ASSERT_TRUE(offer != NULL); |
| 1966 VerifyFingerprintStatus(offer->description(), false); | 2135 VerifyFingerprintStatus(offer->description(), false); |
| 1967 VerifyNoCryptoParams(offer->description(), false); | 2136 VerifyNoCryptoParams(offer->description(), false); |
| 1968 | 2137 |
| 1969 // SetRemoteDescription will take the ownership of the offer. | 2138 // SetRemoteDescription will take the ownership of the offer. |
| 1970 SetRemoteDescriptionWithoutError(offer); | 2139 SetRemoteDescriptionWithoutError(offer); |
| 1971 | 2140 |
| 1972 // Verify that we get a crypto fingerprint in the answer. | 2141 // 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 | 2154 // See: https://bugs.chromium.org/p/webrtc/issues/detail?id=4525 |
| 1986 TEST_P(WebRtcSessionTest, TestCreateAnswerWithDifferentSslRoles) { | 2155 TEST_P(WebRtcSessionTest, TestCreateAnswerWithDifferentSslRoles) { |
| 1987 SendAudioVideoStream1(); | 2156 SendAudioVideoStream1(); |
| 1988 InitWithDtls(GetParam()); | 2157 InitWithDtls(GetParam()); |
| 1989 SetFactoryDtlsSrtp(); | 2158 SetFactoryDtlsSrtp(); |
| 1990 | 2159 |
| 1991 SessionDescriptionInterface* offer = CreateOffer(); | 2160 SessionDescriptionInterface* offer = CreateOffer(); |
| 1992 SetLocalDescriptionWithoutError(offer); | 2161 SetLocalDescriptionWithoutError(offer); |
| 1993 | 2162 |
| 1994 cricket::MediaSessionOptions options; | 2163 cricket::MediaSessionOptions options; |
| 1995 options.recv_video = true; | 2164 GetOptionsForAnswer(&options); |
| 1996 | 2165 |
| 1997 // First, negotiate different SSL roles. | 2166 // First, negotiate different SSL roles. |
| 1998 SessionDescriptionInterface* answer = | 2167 SessionDescriptionInterface* answer = |
| 1999 CreateRemoteAnswer(offer, options, cricket::SEC_DISABLED); | 2168 CreateRemoteAnswer(offer, options, cricket::SEC_DISABLED); |
| 2000 TransportInfo* audio_transport_info = | 2169 TransportInfo* audio_transport_info = |
| 2001 answer->description()->GetTransportInfoByName("audio"); | 2170 answer->description()->GetTransportInfoByName("audio"); |
| 2002 audio_transport_info->description.connection_role = | 2171 audio_transport_info->description.connection_role = |
| 2003 cricket::CONNECTIONROLE_ACTIVE; | 2172 cricket::CONNECTIONROLE_ACTIVE; |
| 2004 TransportInfo* video_transport_info = | 2173 TransportInfo* video_transport_info = |
| 2005 answer->description()->GetTransportInfoByName("video"); | 2174 answer->description()->GetTransportInfoByName("video"); |
| 2006 video_transport_info->description.connection_role = | 2175 video_transport_info->description.connection_role = |
| 2007 cricket::CONNECTIONROLE_PASSIVE; | 2176 cricket::CONNECTIONROLE_PASSIVE; |
| 2008 SetRemoteDescriptionWithoutError(answer); | 2177 SetRemoteDescriptionWithoutError(answer); |
| 2009 | 2178 |
| 2010 // Now create an offer in the reverse direction, and ensure the initial | 2179 // Now create an offer in the reverse direction, and ensure the initial |
| 2011 // offerer responds with an answer with correct SSL roles. | 2180 // offerer responds with an answer with correct SSL roles. |
| 2012 offer = CreateRemoteOfferWithVersion(options, cricket::SEC_DISABLED, | 2181 offer = CreateRemoteOfferWithVersion(options, cricket::SEC_DISABLED, |
| 2013 kSessionVersion, | 2182 kSessionVersion, |
| 2014 session_->remote_description()); | 2183 session_->remote_description()); |
| 2015 SetRemoteDescriptionWithoutError(offer); | 2184 SetRemoteDescriptionWithoutError(offer); |
| 2016 | 2185 |
| 2017 answer = CreateAnswer(); | 2186 cricket::MediaSessionOptions answer_options; |
| 2187 answer_options.bundle_enabled = true; | |
| 2188 answer = CreateAnswer(answer_options); | |
| 2018 audio_transport_info = answer->description()->GetTransportInfoByName("audio"); | 2189 audio_transport_info = answer->description()->GetTransportInfoByName("audio"); |
| 2019 EXPECT_EQ(cricket::CONNECTIONROLE_PASSIVE, | 2190 EXPECT_EQ(cricket::CONNECTIONROLE_PASSIVE, |
| 2020 audio_transport_info->description.connection_role); | 2191 audio_transport_info->description.connection_role); |
| 2021 video_transport_info = answer->description()->GetTransportInfoByName("video"); | 2192 video_transport_info = answer->description()->GetTransportInfoByName("video"); |
| 2022 EXPECT_EQ(cricket::CONNECTIONROLE_ACTIVE, | 2193 EXPECT_EQ(cricket::CONNECTIONROLE_ACTIVE, |
| 2023 video_transport_info->description.connection_role); | 2194 video_transport_info->description.connection_role); |
| 2024 SetLocalDescriptionWithoutError(answer); | 2195 SetLocalDescriptionWithoutError(answer); |
| 2025 | 2196 |
| 2026 // Lastly, start BUNDLE-ing on "audio", expecting that the "passive" role of | 2197 // 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 | 2198 // audio is transferred over to video in the answer that completes the BUNDLE |
| 2028 // negotiation. | 2199 // negotiation. |
| 2029 options.bundle_enabled = true; | 2200 options.bundle_enabled = true; |
| 2030 offer = CreateRemoteOfferWithVersion(options, cricket::SEC_DISABLED, | 2201 offer = CreateRemoteOfferWithVersion(options, cricket::SEC_DISABLED, |
| 2031 kSessionVersion, | 2202 kSessionVersion, |
| 2032 session_->remote_description()); | 2203 session_->remote_description()); |
| 2033 SetRemoteDescriptionWithoutError(offer); | 2204 SetRemoteDescriptionWithoutError(offer); |
| 2034 answer = CreateAnswer(); | 2205 answer = CreateAnswer(answer_options); |
| 2035 audio_transport_info = answer->description()->GetTransportInfoByName("audio"); | 2206 audio_transport_info = answer->description()->GetTransportInfoByName("audio"); |
| 2036 EXPECT_EQ(cricket::CONNECTIONROLE_PASSIVE, | 2207 EXPECT_EQ(cricket::CONNECTIONROLE_PASSIVE, |
| 2037 audio_transport_info->description.connection_role); | 2208 audio_transport_info->description.connection_role); |
| 2038 video_transport_info = answer->description()->GetTransportInfoByName("video"); | 2209 video_transport_info = answer->description()->GetTransportInfoByName("video"); |
| 2039 EXPECT_EQ(cricket::CONNECTIONROLE_PASSIVE, | 2210 EXPECT_EQ(cricket::CONNECTIONROLE_PASSIVE, |
| 2040 video_transport_info->description.connection_role); | 2211 video_transport_info->description.connection_role); |
| 2041 SetLocalDescriptionWithoutError(answer); | 2212 SetLocalDescriptionWithoutError(answer); |
| 2042 } | 2213 } |
| 2043 | 2214 |
| 2044 TEST_F(WebRtcSessionTest, TestSetLocalOfferTwice) { | 2215 TEST_F(WebRtcSessionTest, TestSetLocalOfferTwice) { |
| (...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2385 // is called. | 2556 // is called. |
| 2386 EXPECT_EQ(0u, observer_.mline_0_candidates_.size()); | 2557 EXPECT_EQ(0u, observer_.mline_0_candidates_.size()); |
| 2387 EXPECT_EQ(0u, observer_.mline_1_candidates_.size()); | 2558 EXPECT_EQ(0u, observer_.mline_1_candidates_.size()); |
| 2388 CreateAndSetRemoteOfferAndLocalAnswer(); | 2559 CreateAndSetRemoteOfferAndLocalAnswer(); |
| 2389 // Wait until at least one local candidate has been collected. | 2560 // Wait until at least one local candidate has been collected. |
| 2390 EXPECT_TRUE_WAIT(0u < observer_.mline_0_candidates_.size(), | 2561 EXPECT_TRUE_WAIT(0u < observer_.mline_0_candidates_.size(), |
| 2391 kIceCandidatesTimeout); | 2562 kIceCandidatesTimeout); |
| 2392 | 2563 |
| 2393 std::unique_ptr<SessionDescriptionInterface> local_offer(CreateOffer()); | 2564 std::unique_ptr<SessionDescriptionInterface> local_offer(CreateOffer()); |
| 2394 | 2565 |
| 2566 ASSERT_TRUE(local_offer); | |
| 2395 ASSERT_TRUE(local_offer->candidates(kMediaContentIndex0) != NULL); | 2567 ASSERT_TRUE(local_offer->candidates(kMediaContentIndex0) != NULL); |
| 2396 EXPECT_LT(0u, local_offer->candidates(kMediaContentIndex0)->count()); | 2568 EXPECT_LT(0u, local_offer->candidates(kMediaContentIndex0)->count()); |
| 2397 | 2569 |
| 2398 SessionDescriptionInterface* remote_offer(CreateRemoteOffer()); | 2570 SessionDescriptionInterface* remote_offer(CreateRemoteOffer()); |
| 2399 SetRemoteDescriptionWithoutError(remote_offer); | 2571 SetRemoteDescriptionWithoutError(remote_offer); |
| 2400 SessionDescriptionInterface* answer = CreateAnswer(); | 2572 SessionDescriptionInterface* answer = CreateAnswer(); |
| 2401 ASSERT_TRUE(answer->candidates(kMediaContentIndex0) != NULL); | 2573 ASSERT_TRUE(answer->candidates(kMediaContentIndex0) != NULL); |
| 2402 EXPECT_LT(0u, answer->candidates(kMediaContentIndex0)->count()); | 2574 EXPECT_LT(0u, answer->candidates(kMediaContentIndex0)->count()); |
| 2403 SetLocalDescriptionWithoutError(answer); | 2575 SetLocalDescriptionWithoutError(answer); |
| 2404 } | 2576 } |
| 2405 | 2577 |
| 2406 // Verifies TransportProxy and media channels are created with content names | 2578 // Verifies TransportProxy and media channels are created with content names |
| 2407 // present in the SessionDescription. | 2579 // present in the SessionDescription. |
| 2408 TEST_F(WebRtcSessionTest, TestChannelCreationsWithContentNames) { | 2580 TEST_F(WebRtcSessionTest, TestChannelCreationsWithContentNames) { |
| 2409 Init(); | 2581 Init(); |
| 2410 SendAudioVideoStream1(); | 2582 SendAudioVideoStream1(); |
| 2411 std::unique_ptr<SessionDescriptionInterface> offer(CreateOffer()); | 2583 std::unique_ptr<SessionDescriptionInterface> offer(CreateOffer()); |
| 2412 | 2584 |
| 2413 // CreateOffer creates session description with the content names "audio" and | 2585 // CreateOffer creates session description with the content names "audio" and |
| 2414 // "video". Goal is to modify these content names and verify transport | 2586 // "video". Goal is to modify these content names and verify transport |
| 2415 // channels | 2587 // channels |
| 2416 // in the WebRtcSession, as channels are created with the content names | 2588 // in the WebRtcSession, as channels are created with the content names |
| 2417 // present in SDP. | 2589 // present in SDP. |
| 2418 std::string sdp; | 2590 std::string sdp; |
| 2419 EXPECT_TRUE(offer->ToString(&sdp)); | 2591 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 | 2592 |
| 2436 SessionDescriptionInterface* modified_offer = | 2593 SessionDescriptionInterface* modified_offer = |
| 2437 CreateSessionDescription(JsepSessionDescription::kOffer, sdp, NULL); | 2594 CreateSessionDescription(JsepSessionDescription::kOffer, sdp, NULL); |
| 2438 | 2595 |
| 2439 SetRemoteDescriptionWithoutError(modified_offer); | 2596 SetRemoteDescriptionWithoutError(modified_offer); |
| 2440 | 2597 |
| 2441 SessionDescriptionInterface* answer = CreateAnswer(); | 2598 cricket::MediaSessionOptions answer_options; |
| 2599 answer_options.bundle_enabled = false; | |
| 2600 SessionDescriptionInterface* answer = CreateAnswer(answer_options); | |
| 2442 SetLocalDescriptionWithoutError(answer); | 2601 SetLocalDescriptionWithoutError(answer); |
| 2443 | 2602 |
| 2444 rtc::PacketTransportInternal* voice_transport_channel = | 2603 rtc::PacketTransportInternal* voice_transport_channel = |
| 2445 session_->voice_rtp_transport_channel(); | 2604 session_->voice_rtp_transport_channel(); |
| 2446 EXPECT_TRUE(voice_transport_channel != NULL); | 2605 EXPECT_TRUE(voice_transport_channel != NULL); |
| 2447 EXPECT_EQ(voice_transport_channel->debug_name(), | 2606 EXPECT_EQ(voice_transport_channel->debug_name(), |
| 2448 "audio_content_name " + | 2607 "audio " + std::to_string(cricket::ICE_CANDIDATE_COMPONENT_RTP)); |
| 2449 std::to_string(cricket::ICE_CANDIDATE_COMPONENT_RTP)); | |
| 2450 rtc::PacketTransportInternal* video_transport_channel = | 2608 rtc::PacketTransportInternal* video_transport_channel = |
| 2451 session_->video_rtp_transport_channel(); | 2609 session_->video_rtp_transport_channel(); |
| 2452 ASSERT_TRUE(video_transport_channel != NULL); | 2610 ASSERT_TRUE(video_transport_channel != NULL); |
| 2453 EXPECT_EQ(video_transport_channel->debug_name(), | 2611 EXPECT_EQ(video_transport_channel->debug_name(), |
| 2454 "video_content_name " + | 2612 "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); | 2613 EXPECT_TRUE((video_channel_ = media_engine_->GetVideoChannel(0)) != NULL); |
| 2457 EXPECT_TRUE((voice_channel_ = media_engine_->GetVoiceChannel(0)) != NULL); | 2614 EXPECT_TRUE((voice_channel_ = media_engine_->GetVoiceChannel(0)) != NULL); |
| 2458 } | 2615 } |
| 2459 | 2616 |
| 2460 // 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 |
| 2461 // the send streams when no constraints have been set. | 2618 // the send streams when no constraints have been set. |
| 2462 TEST_F(WebRtcSessionTest, CreateOfferWithoutConstraintsOrStreams) { | 2619 TEST_F(WebRtcSessionTest, CreateOfferWithoutConstraintsOrStreams) { |
| 2463 Init(); | 2620 Init(); |
| 2464 std::unique_ptr<SessionDescriptionInterface> offer(CreateOffer()); | 2621 std::unique_ptr<SessionDescriptionInterface> offer(CreateOffer()); |
| 2465 | 2622 |
| 2466 ASSERT_TRUE(offer != NULL); | 2623 ASSERT_TRUE(offer != NULL); |
| 2467 const cricket::ContentInfo* content = | 2624 const cricket::ContentInfo* content = |
| 2468 cricket::GetFirstAudioContent(offer->description()); | 2625 cricket::GetFirstAudioContent(offer->description()); |
| 2469 EXPECT_TRUE(content != NULL); | 2626 ASSERT_TRUE(content != NULL); |
| 2627 EXPECT_EQ( | |
| 2628 cricket::MD_RECVONLY, | |
| 2629 static_cast<const cricket::AudioContentDescription*>(content->description) | |
| 2630 ->direction()); | |
| 2470 content = cricket::GetFirstVideoContent(offer->description()); | 2631 content = cricket::GetFirstVideoContent(offer->description()); |
| 2471 EXPECT_TRUE(content == NULL); | 2632 ASSERT_TRUE(content != NULL); |
| 2633 EXPECT_EQ( | |
| 2634 cricket::MD_RECVONLY, | |
| 2635 static_cast<const cricket::VideoContentDescription*>(content->description) | |
| 2636 ->direction()); | |
| 2472 } | 2637 } |
| 2473 | 2638 |
| 2474 // Test that an offer contains the correct media content descriptions based on | 2639 // Test that an offer contains the correct media content descriptions based on |
| 2475 // the send streams when no constraints have been set. | 2640 // the send streams when no constraints have been set. |
| 2476 TEST_F(WebRtcSessionTest, CreateOfferWithoutConstraints) { | 2641 TEST_F(WebRtcSessionTest, CreateOfferWithoutConstraints) { |
| 2477 Init(); | 2642 Init(); |
| 2478 // Test Audio only offer. | 2643 // Test Audio only offer. |
| 2479 SendAudioOnlyStream2(); | 2644 SendAudioOnlyStream2(); |
| 2480 std::unique_ptr<SessionDescriptionInterface> offer(CreateOffer()); | 2645 std::unique_ptr<SessionDescriptionInterface> offer(CreateOffer()); |
| 2481 | 2646 |
| 2482 const cricket::ContentInfo* content = | 2647 const cricket::ContentInfo* content = |
| 2483 cricket::GetFirstAudioContent(offer->description()); | 2648 cricket::GetFirstAudioContent(offer->description()); |
| 2484 EXPECT_TRUE(content != NULL); | 2649 ASSERT_TRUE(content != NULL); |
| 2650 EXPECT_EQ( | |
| 2651 cricket::MD_SENDRECV, | |
| 2652 static_cast<const cricket::AudioContentDescription*>(content->description) | |
| 2653 ->direction()); | |
| 2485 content = cricket::GetFirstVideoContent(offer->description()); | 2654 content = cricket::GetFirstVideoContent(offer->description()); |
| 2486 EXPECT_TRUE(content == NULL); | 2655 ASSERT_TRUE(content != NULL); |
| 2656 EXPECT_EQ( | |
| 2657 cricket::MD_RECVONLY, | |
| 2658 static_cast<const cricket::VideoContentDescription*>(content->description) | |
| 2659 ->direction()); | |
| 2487 | 2660 |
| 2488 // Test Audio / Video offer. | 2661 // Test Audio / Video offer. |
| 2489 SendAudioVideoStream1(); | 2662 SendAudioVideoStream1(); |
| 2490 offer.reset(CreateOffer()); | 2663 offer.reset(CreateOffer()); |
| 2491 content = cricket::GetFirstAudioContent(offer->description()); | 2664 content = cricket::GetFirstAudioContent(offer->description()); |
| 2492 EXPECT_TRUE(content != NULL); | 2665 ASSERT_TRUE(content != NULL); |
| 2666 EXPECT_EQ( | |
| 2667 cricket::MD_SENDRECV, | |
| 2668 static_cast<const cricket::AudioContentDescription*>(content->description) | |
| 2669 ->direction()); | |
| 2670 | |
| 2493 content = cricket::GetFirstVideoContent(offer->description()); | 2671 content = cricket::GetFirstVideoContent(offer->description()); |
| 2494 EXPECT_TRUE(content != NULL); | 2672 ASSERT_TRUE(content != NULL); |
| 2673 EXPECT_EQ( | |
| 2674 cricket::MD_SENDRECV, | |
| 2675 static_cast<const cricket::VideoContentDescription*>(content->description) | |
| 2676 ->direction()); | |
| 2495 } | 2677 } |
| 2496 | 2678 |
| 2497 // Test that an offer contains no media content descriptions if | 2679 // Test that an offer contains no media content descriptions if |
| 2498 // kOfferToReceiveVideo and kOfferToReceiveAudio constraints are set to false. | 2680 // kOfferToReceiveVideo and kOfferToReceiveAudio constraints are set to false. |
| 2499 TEST_F(WebRtcSessionTest, CreateOfferWithConstraintsWithoutStreams) { | 2681 TEST_F(WebRtcSessionTest, CreateOfferWithConstraintsWithoutStreams) { |
| 2500 Init(); | 2682 Init(); |
| 2501 PeerConnectionInterface::RTCOfferAnswerOptions options; | 2683 PeerConnectionInterface::RTCOfferAnswerOptions options; |
| 2502 options.offer_to_receive_audio = 0; | 2684 options.offer_to_receive_audio = 0; |
| 2503 options.offer_to_receive_video = 0; | 2685 options.offer_to_receive_video = 0; |
| 2504 | 2686 |
| 2505 std::unique_ptr<SessionDescriptionInterface> offer(CreateOffer(options)); | 2687 std::unique_ptr<SessionDescriptionInterface> offer(CreateOffer(options)); |
| 2506 | 2688 |
| 2507 ASSERT_TRUE(offer != NULL); | 2689 ASSERT_TRUE(offer != NULL); |
| 2508 const cricket::ContentInfo* content = | 2690 const cricket::ContentInfo* content = |
| 2509 cricket::GetFirstAudioContent(offer->description()); | 2691 cricket::GetFirstAudioContent(offer->description()); |
| 2510 EXPECT_TRUE(content == NULL); | 2692 EXPECT_TRUE(content == NULL); |
| 2511 content = cricket::GetFirstVideoContent(offer->description()); | 2693 content = cricket::GetFirstVideoContent(offer->description()); |
| 2512 EXPECT_TRUE(content == NULL); | 2694 EXPECT_TRUE(content == NULL); |
| 2513 } | 2695 } |
| 2514 | 2696 |
| 2515 // Test that an offer contains only audio media content descriptions if | 2697 // Test that an offer contains only audio media content descriptions if |
| 2516 // kOfferToReceiveAudio constraints are set to true. | 2698 // kOfferToReceiveAudio constraints are set to true. |
| 2517 TEST_F(WebRtcSessionTest, CreateAudioOnlyOfferWithConstraints) { | 2699 TEST_F(WebRtcSessionTest, CreateAudioOnlyOfferWithConstraints) { |
| 2518 Init(); | 2700 Init(); |
| 2519 PeerConnectionInterface::RTCOfferAnswerOptions options; | 2701 PeerConnectionInterface::RTCOfferAnswerOptions options; |
| 2520 options.offer_to_receive_audio = | 2702 options.offer_to_receive_audio = |
| 2521 RTCOfferAnswerOptions::kOfferToReceiveMediaTrue; | 2703 RTCOfferAnswerOptions::kOfferToReceiveMediaTrue; |
| 2704 options.offer_to_receive_video = 0; | |
| 2522 | 2705 |
| 2523 std::unique_ptr<SessionDescriptionInterface> offer(CreateOffer(options)); | 2706 std::unique_ptr<SessionDescriptionInterface> offer(CreateOffer(options)); |
| 2524 | 2707 |
| 2525 const cricket::ContentInfo* content = | 2708 const cricket::ContentInfo* content = |
| 2526 cricket::GetFirstAudioContent(offer->description()); | 2709 cricket::GetFirstAudioContent(offer->description()); |
| 2527 EXPECT_TRUE(content != NULL); | 2710 EXPECT_TRUE(content != NULL); |
| 2528 content = cricket::GetFirstVideoContent(offer->description()); | 2711 content = cricket::GetFirstVideoContent(offer->description()); |
| 2529 EXPECT_TRUE(content == NULL); | 2712 EXPECT_TRUE(content == NULL); |
| 2530 } | 2713 } |
| 2531 | 2714 |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 2546 cricket::GetFirstAudioContent(offer->description()); | 2729 cricket::GetFirstAudioContent(offer->description()); |
| 2547 EXPECT_TRUE(content != NULL); | 2730 EXPECT_TRUE(content != NULL); |
| 2548 | 2731 |
| 2549 content = cricket::GetFirstVideoContent(offer->description()); | 2732 content = cricket::GetFirstVideoContent(offer->description()); |
| 2550 EXPECT_TRUE(content != NULL); | 2733 EXPECT_TRUE(content != NULL); |
| 2551 | 2734 |
| 2552 // Sets constraints to false and verifies that audio/video contents are | 2735 // Sets constraints to false and verifies that audio/video contents are |
| 2553 // removed. | 2736 // removed. |
| 2554 options.offer_to_receive_audio = 0; | 2737 options.offer_to_receive_audio = 0; |
| 2555 options.offer_to_receive_video = 0; | 2738 options.offer_to_receive_video = 0; |
| 2739 // Remove the media sections added in previous offer. | |
| 2740 offered_media_sections_.clear(); | |
| 2556 offer.reset(CreateOffer(options)); | 2741 offer.reset(CreateOffer(options)); |
| 2557 | 2742 |
| 2558 content = cricket::GetFirstAudioContent(offer->description()); | 2743 content = cricket::GetFirstAudioContent(offer->description()); |
| 2559 EXPECT_TRUE(content == NULL); | 2744 EXPECT_TRUE(content == NULL); |
| 2560 content = cricket::GetFirstVideoContent(offer->description()); | 2745 content = cricket::GetFirstVideoContent(offer->description()); |
| 2561 EXPECT_TRUE(content == NULL); | 2746 EXPECT_TRUE(content == NULL); |
| 2562 } | 2747 } |
| 2563 | 2748 |
| 2564 // Test that an answer can not be created if the last remote description is not | 2749 // Test that an answer can not be created if the last remote description is not |
| 2565 // an offer. | 2750 // an offer. |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 2589 ASSERT_TRUE(content != NULL); | 2774 ASSERT_TRUE(content != NULL); |
| 2590 EXPECT_FALSE(content->rejected); | 2775 EXPECT_FALSE(content->rejected); |
| 2591 } | 2776 } |
| 2592 | 2777 |
| 2593 // Test that an answer contains the correct media content descriptions when no | 2778 // Test that an answer contains the correct media content descriptions when no |
| 2594 // constraints have been set and the offer only contain audio. | 2779 // constraints have been set and the offer only contain audio. |
| 2595 TEST_F(WebRtcSessionTest, CreateAudioAnswerWithoutConstraintsOrStreams) { | 2780 TEST_F(WebRtcSessionTest, CreateAudioAnswerWithoutConstraintsOrStreams) { |
| 2596 Init(); | 2781 Init(); |
| 2597 // Create a remote offer with audio only. | 2782 // Create a remote offer with audio only. |
| 2598 cricket::MediaSessionOptions options; | 2783 cricket::MediaSessionOptions options; |
| 2784 GetOptionsForAudioOnlyRemoteOffer(&options); | |
| 2599 | 2785 |
| 2600 std::unique_ptr<JsepSessionDescription> offer(CreateRemoteOffer(options)); | 2786 std::unique_ptr<JsepSessionDescription> offer(CreateRemoteOffer(options)); |
| 2601 ASSERT_TRUE(cricket::GetFirstVideoContent(offer->description()) == NULL); | 2787 ASSERT_TRUE(cricket::GetFirstVideoContent(offer->description()) == NULL); |
| 2602 ASSERT_TRUE(cricket::GetFirstAudioContent(offer->description()) != NULL); | 2788 ASSERT_TRUE(cricket::GetFirstAudioContent(offer->description()) != NULL); |
| 2603 | 2789 |
| 2604 SetRemoteDescriptionWithoutError(offer.release()); | 2790 SetRemoteDescriptionWithoutError(offer.release()); |
| 2605 std::unique_ptr<SessionDescriptionInterface> answer(CreateAnswer()); | 2791 std::unique_ptr<SessionDescriptionInterface> answer(CreateAnswer()); |
| 2606 const cricket::ContentInfo* content = | 2792 const cricket::ContentInfo* content = |
| 2607 cricket::GetFirstAudioContent(answer->description()); | 2793 cricket::GetFirstAudioContent(answer->description()); |
| 2608 ASSERT_TRUE(content != NULL); | 2794 ASSERT_TRUE(content != NULL); |
| (...skipping 24 matching lines...) Expand all Loading... | |
| 2633 | 2819 |
| 2634 // Test that an answer contains the correct media content descriptions when | 2820 // Test that an answer contains the correct media content descriptions when |
| 2635 // constraints have been set but no stream is sent. | 2821 // constraints have been set but no stream is sent. |
| 2636 TEST_F(WebRtcSessionTest, CreateAnswerWithConstraintsWithoutStreams) { | 2822 TEST_F(WebRtcSessionTest, CreateAnswerWithConstraintsWithoutStreams) { |
| 2637 Init(); | 2823 Init(); |
| 2638 // Create a remote offer with audio and video content. | 2824 // Create a remote offer with audio and video content. |
| 2639 std::unique_ptr<JsepSessionDescription> offer(CreateRemoteOffer()); | 2825 std::unique_ptr<JsepSessionDescription> offer(CreateRemoteOffer()); |
| 2640 SetRemoteDescriptionWithoutError(offer.release()); | 2826 SetRemoteDescriptionWithoutError(offer.release()); |
| 2641 | 2827 |
| 2642 cricket::MediaSessionOptions session_options; | 2828 cricket::MediaSessionOptions session_options; |
| 2643 session_options.recv_audio = false; | 2829 remote_send_audio_ = false; |
| 2644 session_options.recv_video = false; | 2830 remote_send_video_ = false; |
| 2831 local_recv_audio_ = false; | |
| 2832 local_recv_video_ = false; | |
| 2645 std::unique_ptr<SessionDescriptionInterface> answer( | 2833 std::unique_ptr<SessionDescriptionInterface> answer( |
| 2646 CreateAnswer(session_options)); | 2834 CreateAnswer(session_options)); |
| 2647 | 2835 |
| 2648 const cricket::ContentInfo* content = | 2836 const cricket::ContentInfo* content = |
| 2649 cricket::GetFirstAudioContent(answer->description()); | 2837 cricket::GetFirstAudioContent(answer->description()); |
| 2650 ASSERT_TRUE(content != NULL); | 2838 ASSERT_TRUE(content != NULL); |
| 2651 EXPECT_TRUE(content->rejected); | 2839 EXPECT_TRUE(content->rejected); |
| 2652 | 2840 |
| 2653 content = cricket::GetFirstVideoContent(answer->description()); | 2841 content = cricket::GetFirstVideoContent(answer->description()); |
| 2654 ASSERT_TRUE(content != NULL); | 2842 ASSERT_TRUE(content != NULL); |
| 2655 EXPECT_TRUE(content->rejected); | 2843 EXPECT_TRUE(content->rejected); |
| 2656 } | 2844 } |
| 2657 | 2845 |
| 2658 // Test that an answer contains the correct media content descriptions when | 2846 // Test that an answer contains the correct media content descriptions when |
| 2659 // constraints have been set and streams are sent. | 2847 // constraints have been set and streams are sent. |
| 2660 TEST_F(WebRtcSessionTest, CreateAnswerWithConstraints) { | 2848 TEST_F(WebRtcSessionTest, CreateAnswerWithConstraints) { |
| 2661 Init(); | 2849 Init(); |
| 2662 // Create a remote offer with audio and video content. | 2850 // Create a remote offer with audio and video content. |
| 2663 std::unique_ptr<JsepSessionDescription> offer(CreateRemoteOffer()); | 2851 std::unique_ptr<JsepSessionDescription> offer(CreateRemoteOffer()); |
| 2664 SetRemoteDescriptionWithoutError(offer.release()); | 2852 SetRemoteDescriptionWithoutError(offer.release()); |
| 2665 | 2853 |
| 2666 cricket::MediaSessionOptions options; | 2854 cricket::MediaSessionOptions options; |
| 2667 options.recv_audio = false; | |
| 2668 options.recv_video = false; | |
| 2669 | |
| 2670 // Test with a stream with tracks. | 2855 // Test with a stream with tracks. |
| 2671 SendAudioVideoStream1(); | 2856 SendAudioVideoStream1(); |
| 2672 std::unique_ptr<SessionDescriptionInterface> answer(CreateAnswer(options)); | 2857 std::unique_ptr<SessionDescriptionInterface> answer(CreateAnswer(options)); |
| 2673 | 2858 |
| 2674 // TODO(perkj): Should the direction be set to SEND_ONLY? | 2859 // TODO(perkj): Should the direction be set to SEND_ONLY? |
| 2675 const cricket::ContentInfo* content = | 2860 const cricket::ContentInfo* content = |
| 2676 cricket::GetFirstAudioContent(answer->description()); | 2861 cricket::GetFirstAudioContent(answer->description()); |
| 2677 ASSERT_TRUE(content != NULL); | 2862 ASSERT_TRUE(content != NULL); |
| 2678 EXPECT_FALSE(content->rejected); | 2863 EXPECT_FALSE(content->rejected); |
| 2679 | 2864 |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2719 // later updates with video. | 2904 // later updates with video. |
| 2720 TEST_F(WebRtcSessionTest, TestAVOfferWithAudioOnlyAnswer) { | 2905 TEST_F(WebRtcSessionTest, TestAVOfferWithAudioOnlyAnswer) { |
| 2721 Init(); | 2906 Init(); |
| 2722 EXPECT_TRUE(media_engine_->GetVideoChannel(0) == NULL); | 2907 EXPECT_TRUE(media_engine_->GetVideoChannel(0) == NULL); |
| 2723 EXPECT_TRUE(media_engine_->GetVoiceChannel(0) == NULL); | 2908 EXPECT_TRUE(media_engine_->GetVoiceChannel(0) == NULL); |
| 2724 | 2909 |
| 2725 SendAudioVideoStream1(); | 2910 SendAudioVideoStream1(); |
| 2726 SessionDescriptionInterface* offer = CreateOffer(); | 2911 SessionDescriptionInterface* offer = CreateOffer(); |
| 2727 | 2912 |
| 2728 cricket::MediaSessionOptions options; | 2913 cricket::MediaSessionOptions options; |
| 2914 AddMediaSection(cricket::MEDIA_TYPE_AUDIO, cricket::CN_AUDIO, | |
| 2915 cricket::MD_RECVONLY, kActive, &options); | |
| 2916 AddMediaSection(cricket::MEDIA_TYPE_VIDEO, cricket::CN_VIDEO, | |
| 2917 cricket::MD_INACTIVE, kStopped, &options); | |
| 2918 local_recv_video_ = false; | |
| 2729 SessionDescriptionInterface* answer = CreateRemoteAnswer(offer, options); | 2919 SessionDescriptionInterface* answer = CreateRemoteAnswer(offer, options); |
| 2730 | 2920 |
| 2731 // SetLocalDescription and SetRemoteDescriptions takes ownership of offer | 2921 // SetLocalDescription and SetRemoteDescriptions takes ownership of offer |
| 2732 // and answer; | 2922 // and answer; |
| 2733 SetLocalDescriptionWithoutError(offer); | 2923 SetLocalDescriptionWithoutError(offer); |
| 2734 SetRemoteDescriptionWithoutError(answer); | 2924 SetRemoteDescriptionWithoutError(answer); |
| 2735 | 2925 |
| 2736 video_channel_ = media_engine_->GetVideoChannel(0); | 2926 video_channel_ = media_engine_->GetVideoChannel(0); |
| 2737 voice_channel_ = media_engine_->GetVoiceChannel(0); | 2927 voice_channel_ = media_engine_->GetVoiceChannel(0); |
| 2738 | 2928 |
| 2739 ASSERT_TRUE(video_channel_ == NULL); | 2929 ASSERT_TRUE(video_channel_ == nullptr); |
| 2740 | 2930 |
| 2741 ASSERT_EQ(0u, voice_channel_->recv_streams().size()); | 2931 ASSERT_EQ(0u, voice_channel_->recv_streams().size()); |
| 2742 ASSERT_EQ(1u, voice_channel_->send_streams().size()); | 2932 ASSERT_EQ(1u, voice_channel_->send_streams().size()); |
| 2743 EXPECT_EQ(kAudioTrack1, voice_channel_->send_streams()[0].id); | 2933 EXPECT_EQ(kAudioTrack1, voice_channel_->send_streams()[0].id); |
| 2744 | 2934 |
| 2745 // Let the remote end update the session descriptions, with Audio and Video. | 2935 // Let the remote end update the session descriptions, with Audio and Video. |
| 2746 SendAudioVideoStream2(); | 2936 SendAudioVideoStream2(); |
| 2937 local_recv_video_ = true; | |
| 2747 CreateAndSetRemoteOfferAndLocalAnswer(); | 2938 CreateAndSetRemoteOfferAndLocalAnswer(); |
| 2748 | 2939 |
| 2749 video_channel_ = media_engine_->GetVideoChannel(0); | 2940 video_channel_ = media_engine_->GetVideoChannel(0); |
| 2750 voice_channel_ = media_engine_->GetVoiceChannel(0); | 2941 voice_channel_ = media_engine_->GetVoiceChannel(0); |
| 2751 | 2942 |
| 2752 ASSERT_TRUE(video_channel_ != NULL); | 2943 ASSERT_TRUE(video_channel_ != nullptr); |
| 2753 ASSERT_TRUE(voice_channel_ != NULL); | 2944 ASSERT_TRUE(voice_channel_ != nullptr); |
| 2754 | 2945 |
| 2755 ASSERT_EQ(1u, video_channel_->recv_streams().size()); | 2946 ASSERT_EQ(1u, video_channel_->recv_streams().size()); |
| 2756 ASSERT_EQ(1u, video_channel_->send_streams().size()); | 2947 ASSERT_EQ(1u, video_channel_->send_streams().size()); |
| 2757 EXPECT_EQ(kVideoTrack2, video_channel_->recv_streams()[0].id); | 2948 EXPECT_EQ(kVideoTrack2, video_channel_->recv_streams()[0].id); |
| 2758 EXPECT_EQ(kVideoTrack2, video_channel_->send_streams()[0].id); | 2949 EXPECT_EQ(kVideoTrack2, video_channel_->send_streams()[0].id); |
| 2759 ASSERT_EQ(1u, voice_channel_->recv_streams().size()); | 2950 ASSERT_EQ(1u, voice_channel_->recv_streams().size()); |
| 2760 ASSERT_EQ(1u, voice_channel_->send_streams().size()); | 2951 ASSERT_EQ(1u, voice_channel_->send_streams().size()); |
| 2761 EXPECT_EQ(kAudioTrack2, voice_channel_->recv_streams()[0].id); | 2952 EXPECT_EQ(kAudioTrack2, voice_channel_->recv_streams()[0].id); |
| 2762 EXPECT_EQ(kAudioTrack2, voice_channel_->send_streams()[0].id); | 2953 EXPECT_EQ(kAudioTrack2, voice_channel_->send_streams()[0].id); |
| 2763 | 2954 |
| 2764 // Change session back to audio only. | 2955 // Change session back to audio only. |
| 2956 // The remote side doesn't send and recv video. | |
| 2765 SendAudioOnlyStream2(); | 2957 SendAudioOnlyStream2(); |
| 2958 remote_recv_video_ = false; | |
| 2766 CreateAndSetRemoteOfferAndLocalAnswer(); | 2959 CreateAndSetRemoteOfferAndLocalAnswer(); |
| 2767 | 2960 |
| 2768 EXPECT_EQ(0u, video_channel_->recv_streams().size()); | 2961 video_channel_ = media_engine_->GetVideoChannel(0); |
| 2962 voice_channel_ = media_engine_->GetVoiceChannel(0); | |
| 2963 | |
| 2964 // The audio is expected to be rejected. | |
| 2965 EXPECT_TRUE(video_channel_ == nullptr); | |
| 2966 | |
| 2769 ASSERT_EQ(1u, voice_channel_->recv_streams().size()); | 2967 ASSERT_EQ(1u, voice_channel_->recv_streams().size()); |
| 2770 EXPECT_EQ(kAudioTrack2, voice_channel_->recv_streams()[0].id); | 2968 EXPECT_EQ(kAudioTrack2, voice_channel_->recv_streams()[0].id); |
| 2771 ASSERT_EQ(1u, voice_channel_->send_streams().size()); | 2969 ASSERT_EQ(1u, voice_channel_->send_streams().size()); |
| 2772 EXPECT_EQ(kAudioTrack2, voice_channel_->send_streams()[0].id); | 2970 EXPECT_EQ(kAudioTrack2, voice_channel_->send_streams()[0].id); |
| 2773 } | 2971 } |
| 2774 | 2972 |
| 2775 // This test verifies the call setup when remote answer with video only and | 2973 // This test verifies the call setup when remote answer with video only and |
| 2776 // later updates with audio. | 2974 // later updates with audio. |
| 2777 TEST_F(WebRtcSessionTest, TestAVOfferWithVideoOnlyAnswer) { | 2975 TEST_F(WebRtcSessionTest, TestAVOfferWithVideoOnlyAnswer) { |
| 2778 Init(); | 2976 Init(); |
| 2779 EXPECT_TRUE(media_engine_->GetVideoChannel(0) == NULL); | 2977 EXPECT_TRUE(media_engine_->GetVideoChannel(0) == NULL); |
| 2780 EXPECT_TRUE(media_engine_->GetVoiceChannel(0) == NULL); | 2978 EXPECT_TRUE(media_engine_->GetVoiceChannel(0) == NULL); |
| 2781 SendAudioVideoStream1(); | 2979 SendAudioVideoStream1(); |
| 2782 SessionDescriptionInterface* offer = CreateOffer(); | 2980 SessionDescriptionInterface* offer = CreateOffer(); |
| 2783 | 2981 |
| 2784 cricket::MediaSessionOptions options; | 2982 cricket::MediaSessionOptions options; |
| 2785 options.recv_audio = false; | 2983 AddMediaSection(cricket::MEDIA_TYPE_AUDIO, cricket::CN_AUDIO, |
| 2786 options.recv_video = true; | 2984 cricket::MD_INACTIVE, kStopped, &options); |
| 2787 SessionDescriptionInterface* answer = CreateRemoteAnswer( | 2985 AddMediaSection(cricket::MEDIA_TYPE_VIDEO, cricket::CN_VIDEO, |
| 2788 offer, options, cricket::SEC_ENABLED); | 2986 cricket::MD_RECVONLY, kActive, &options); |
| 2987 local_recv_audio_ = false; | |
| 2988 SessionDescriptionInterface* answer = | |
| 2989 CreateRemoteAnswer(offer, options, cricket::SEC_ENABLED); | |
| 2789 | 2990 |
| 2790 // SetLocalDescription and SetRemoteDescriptions takes ownership of offer | 2991 // SetLocalDescription and SetRemoteDescriptions takes ownership of offer |
| 2791 // and answer. | 2992 // and answer. |
| 2792 SetLocalDescriptionWithoutError(offer); | 2993 SetLocalDescriptionWithoutError(offer); |
| 2793 SetRemoteDescriptionWithoutError(answer); | 2994 SetRemoteDescriptionWithoutError(answer); |
| 2794 | 2995 |
| 2795 video_channel_ = media_engine_->GetVideoChannel(0); | 2996 video_channel_ = media_engine_->GetVideoChannel(0); |
| 2796 voice_channel_ = media_engine_->GetVoiceChannel(0); | 2997 voice_channel_ = media_engine_->GetVoiceChannel(0); |
| 2797 | 2998 |
| 2798 ASSERT_TRUE(voice_channel_ == NULL); | 2999 ASSERT_TRUE(voice_channel_ == NULL); |
| 2799 ASSERT_TRUE(video_channel_ != NULL); | 3000 ASSERT_TRUE(video_channel_ != NULL); |
| 2800 | 3001 |
| 2801 EXPECT_EQ(0u, video_channel_->recv_streams().size()); | 3002 EXPECT_EQ(0u, video_channel_->recv_streams().size()); |
| 2802 ASSERT_EQ(1u, video_channel_->send_streams().size()); | 3003 ASSERT_EQ(1u, video_channel_->send_streams().size()); |
| 2803 EXPECT_EQ(kVideoTrack1, video_channel_->send_streams()[0].id); | 3004 EXPECT_EQ(kVideoTrack1, video_channel_->send_streams()[0].id); |
| 2804 | 3005 |
| 2805 // Update the session descriptions, with Audio and Video. | 3006 // Update the session descriptions, with Audio and Video. |
| 2806 SendAudioVideoStream2(); | 3007 SendAudioVideoStream2(); |
| 2807 CreateAndSetRemoteOfferAndLocalAnswer(); | 3008 local_recv_audio_ = true; |
| 3009 SessionDescriptionInterface* offer2 = CreateRemoteOffer(); | |
| 3010 SetRemoteDescriptionWithoutError(offer2); | |
| 3011 cricket::MediaSessionOptions answer_options; | |
| 3012 // Disable the bundling here. If the media is bundled on audio | |
| 3013 // transport, then we can't reject the audio because switching the bundled | |
| 3014 // transport is not currently supported. | |
|
Taylor Brandstetter
2017/08/09 17:05:12
Could link to the bug here: https://bugs.chromium.
Zhi Huang
2017/08/09 21:51:02
Done.
| |
| 3015 answer_options.bundle_enabled = false; | |
| 3016 SessionDescriptionInterface* answer2 = CreateAnswer(answer_options); | |
| 3017 SetLocalDescriptionWithoutError(answer2); | |
| 2808 | 3018 |
| 2809 voice_channel_ = media_engine_->GetVoiceChannel(0); | 3019 voice_channel_ = media_engine_->GetVoiceChannel(0); |
| 3020 | |
| 2810 ASSERT_TRUE(voice_channel_ != NULL); | 3021 ASSERT_TRUE(voice_channel_ != NULL); |
| 2811 | |
| 2812 ASSERT_EQ(1u, voice_channel_->recv_streams().size()); | 3022 ASSERT_EQ(1u, voice_channel_->recv_streams().size()); |
| 2813 ASSERT_EQ(1u, voice_channel_->send_streams().size()); | 3023 ASSERT_EQ(1u, voice_channel_->send_streams().size()); |
| 2814 EXPECT_EQ(kAudioTrack2, voice_channel_->recv_streams()[0].id); | 3024 EXPECT_EQ(kAudioTrack2, voice_channel_->recv_streams()[0].id); |
| 2815 EXPECT_EQ(kAudioTrack2, voice_channel_->send_streams()[0].id); | 3025 EXPECT_EQ(kAudioTrack2, voice_channel_->send_streams()[0].id); |
| 2816 | 3026 |
| 2817 // Change session back to video only. | 3027 // Change session back to video only. |
| 3028 // The remote side doesn't send and recv audio. | |
| 2818 SendVideoOnlyStream2(); | 3029 SendVideoOnlyStream2(); |
| 2819 CreateAndSetRemoteOfferAndLocalAnswer(); | 3030 remote_recv_audio_ = false; |
| 3031 SessionDescriptionInterface* offer3 = CreateRemoteOffer(); | |
| 3032 SetRemoteDescriptionWithoutError(offer3); | |
| 3033 SessionDescriptionInterface* answer3 = CreateAnswer(answer_options); | |
| 3034 SetLocalDescriptionWithoutError(answer3); | |
| 2820 | 3035 |
| 2821 video_channel_ = media_engine_->GetVideoChannel(0); | 3036 video_channel_ = media_engine_->GetVideoChannel(0); |
| 2822 voice_channel_ = media_engine_->GetVoiceChannel(0); | 3037 voice_channel_ = media_engine_->GetVoiceChannel(0); |
| 2823 | 3038 |
| 3039 // The video is expected to be rejected. | |
| 3040 EXPECT_TRUE(voice_channel_ == nullptr); | |
| 3041 | |
| 2824 ASSERT_EQ(1u, video_channel_->recv_streams().size()); | 3042 ASSERT_EQ(1u, video_channel_->recv_streams().size()); |
| 2825 EXPECT_EQ(kVideoTrack2, video_channel_->recv_streams()[0].id); | 3043 EXPECT_EQ(kVideoTrack2, video_channel_->recv_streams()[0].id); |
| 2826 ASSERT_EQ(1u, video_channel_->send_streams().size()); | 3044 ASSERT_EQ(1u, video_channel_->send_streams().size()); |
| 2827 EXPECT_EQ(kVideoTrack2, video_channel_->send_streams()[0].id); | 3045 EXPECT_EQ(kVideoTrack2, video_channel_->send_streams()[0].id); |
| 2828 } | 3046 } |
| 2829 | 3047 |
| 2830 TEST_F(WebRtcSessionTest, VerifyCryptoParamsInSDP) { | 3048 TEST_F(WebRtcSessionTest, VerifyCryptoParamsInSDP) { |
| 2831 Init(); | 3049 Init(); |
| 2832 SendAudioVideoStream1(); | 3050 SendAudioVideoStream1(); |
| 2833 std::unique_ptr<SessionDescriptionInterface> offer(CreateOffer()); | 3051 std::unique_ptr<SessionDescriptionInterface> offer(CreateOffer()); |
| (...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3018 } | 3236 } |
| 3019 | 3237 |
| 3020 // Test that candidates sent to the "video" transport do not get pushed down to | 3238 // Test that candidates sent to the "video" transport do not get pushed down to |
| 3021 // the "audio" transport channel when bundling. | 3239 // the "audio" transport channel when bundling. |
| 3022 TEST_F(WebRtcSessionTest, TestIgnoreCandidatesForUnusedTransportWhenBundling) { | 3240 TEST_F(WebRtcSessionTest, TestIgnoreCandidatesForUnusedTransportWhenBundling) { |
| 3023 AddInterface(rtc::SocketAddress(kClientAddrHost1, kClientAddrPort)); | 3241 AddInterface(rtc::SocketAddress(kClientAddrHost1, kClientAddrPort)); |
| 3024 | 3242 |
| 3025 InitWithBundlePolicy(PeerConnectionInterface::kBundlePolicyBalanced); | 3243 InitWithBundlePolicy(PeerConnectionInterface::kBundlePolicyBalanced); |
| 3026 SendAudioVideoStream1(); | 3244 SendAudioVideoStream1(); |
| 3027 | 3245 |
| 3028 PeerConnectionInterface::RTCOfferAnswerOptions options; | 3246 cricket::MediaSessionOptions offer_options; |
| 3029 options.use_rtp_mux = true; | 3247 GetOptionsForRemoteOffer(&offer_options); |
| 3248 offer_options.bundle_enabled = true; | |
| 3030 | 3249 |
| 3031 SessionDescriptionInterface* offer = CreateRemoteOffer(); | 3250 SessionDescriptionInterface* offer = CreateRemoteOffer(offer_options); |
| 3032 SetRemoteDescriptionWithoutError(offer); | 3251 SetRemoteDescriptionWithoutError(offer); |
| 3033 | 3252 |
| 3034 SessionDescriptionInterface* answer = CreateAnswer(); | 3253 cricket::MediaSessionOptions answer_options; |
| 3254 answer_options.bundle_enabled = true; | |
| 3255 SessionDescriptionInterface* answer = CreateAnswer(answer_options); | |
| 3035 SetLocalDescriptionWithoutError(answer); | 3256 SetLocalDescriptionWithoutError(answer); |
| 3036 | 3257 |
| 3037 EXPECT_EQ(session_->voice_rtp_transport_channel(), | 3258 EXPECT_EQ(session_->voice_rtp_transport_channel(), |
| 3038 session_->video_rtp_transport_channel()); | 3259 session_->video_rtp_transport_channel()); |
| 3039 | 3260 |
| 3040 cricket::BaseChannel* voice_channel = session_->voice_channel(); | 3261 cricket::BaseChannel* voice_channel = session_->voice_channel(); |
| 3041 ASSERT_TRUE(voice_channel != NULL); | 3262 ASSERT_TRUE(voice_channel != NULL); |
| 3042 | 3263 |
| 3043 // Checks if one of the transport channels contains a connection using a given | 3264 // Checks if one of the transport channels contains a connection using a given |
| 3044 // port. | 3265 // port. |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3189 | 3410 |
| 3190 PeerConnectionInterface::RTCOfferAnswerOptions options; | 3411 PeerConnectionInterface::RTCOfferAnswerOptions options; |
| 3191 options.use_rtp_mux = true; | 3412 options.use_rtp_mux = true; |
| 3192 | 3413 |
| 3193 SessionDescriptionInterface* offer = CreateOffer(options); | 3414 SessionDescriptionInterface* offer = CreateOffer(options); |
| 3194 SetLocalDescriptionWithoutError(offer); | 3415 SetLocalDescriptionWithoutError(offer); |
| 3195 | 3416 |
| 3196 EXPECT_EQ(session_->voice_rtp_transport_channel(), | 3417 EXPECT_EQ(session_->voice_rtp_transport_channel(), |
| 3197 session_->video_rtp_transport_channel()); | 3418 session_->video_rtp_transport_channel()); |
| 3198 | 3419 |
| 3199 SendAudioVideoStream2(); | 3420 SendVideoOnlyStream2(); |
| 3421 local_send_audio_ = false; | |
| 3422 remote_recv_audio_ = false; | |
| 3200 cricket::MediaSessionOptions recv_options; | 3423 cricket::MediaSessionOptions recv_options; |
| 3201 recv_options.recv_audio = false; | 3424 GetOptionsForRemoteAnswer(&recv_options); |
| 3202 recv_options.recv_video = true; | |
| 3203 SessionDescriptionInterface* answer = | 3425 SessionDescriptionInterface* answer = |
| 3204 CreateRemoteAnswer(session_->local_description(), recv_options); | 3426 CreateRemoteAnswer(session_->local_description(), recv_options); |
| 3205 SetRemoteDescriptionWithoutError(answer); | 3427 SetRemoteDescriptionWithoutError(answer); |
| 3206 | 3428 |
| 3207 EXPECT_TRUE(nullptr == session_->voice_channel()); | 3429 EXPECT_TRUE(nullptr == session_->voice_channel()); |
| 3208 EXPECT_TRUE(nullptr != session_->video_rtp_transport_channel()); | 3430 EXPECT_TRUE(nullptr != session_->video_rtp_transport_channel()); |
| 3209 | 3431 |
| 3210 session_->Close(); | 3432 session_->Close(); |
| 3211 EXPECT_TRUE(nullptr == session_->voice_rtp_transport_channel()); | 3433 EXPECT_TRUE(nullptr == session_->voice_rtp_transport_channel()); |
| 3212 EXPECT_TRUE(nullptr == session_->voice_rtcp_transport_channel()); | 3434 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 | 3501 // Expect an error when applying the remote description |
| 3280 SetRemoteDescriptionExpectError(JsepSessionDescription::kOffer, | 3502 SetRemoteDescriptionExpectError(JsepSessionDescription::kOffer, |
| 3281 kCreateChannelFailed, modified_offer); | 3503 kCreateChannelFailed, modified_offer); |
| 3282 } | 3504 } |
| 3283 | 3505 |
| 3284 // kBundlePolicyMaxCompat bundle policy and answer contains BUNDLE. | 3506 // kBundlePolicyMaxCompat bundle policy and answer contains BUNDLE. |
| 3285 TEST_F(WebRtcSessionTest, TestMaxCompatBundleInAnswer) { | 3507 TEST_F(WebRtcSessionTest, TestMaxCompatBundleInAnswer) { |
| 3286 InitWithBundlePolicy(PeerConnectionInterface::kBundlePolicyMaxCompat); | 3508 InitWithBundlePolicy(PeerConnectionInterface::kBundlePolicyMaxCompat); |
| 3287 SendAudioVideoStream1(); | 3509 SendAudioVideoStream1(); |
| 3288 | 3510 |
| 3289 PeerConnectionInterface::RTCOfferAnswerOptions options; | 3511 PeerConnectionInterface::RTCOfferAnswerOptions rtc_options; |
| 3290 options.use_rtp_mux = true; | 3512 rtc_options.use_rtp_mux = true; |
| 3291 | 3513 |
| 3292 SessionDescriptionInterface* offer = CreateOffer(options); | 3514 SessionDescriptionInterface* offer = CreateOffer(rtc_options); |
| 3293 SetLocalDescriptionWithoutError(offer); | 3515 SetLocalDescriptionWithoutError(offer); |
| 3294 | 3516 |
| 3295 EXPECT_NE(session_->voice_rtp_transport_channel(), | 3517 EXPECT_NE(session_->voice_rtp_transport_channel(), |
| 3296 session_->video_rtp_transport_channel()); | 3518 session_->video_rtp_transport_channel()); |
| 3297 | 3519 |
| 3298 SendAudioVideoStream2(); | 3520 SendAudioVideoStream2(); |
| 3299 SessionDescriptionInterface* answer = | 3521 SessionDescriptionInterface* answer = |
| 3300 CreateRemoteAnswer(session_->local_description()); | 3522 CreateRemoteAnswer(session_->local_description()); |
| 3301 SetRemoteDescriptionWithoutError(answer); | 3523 SetRemoteDescriptionWithoutError(answer); |
| 3302 | 3524 |
| (...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3638 SetLocalDescriptionWithoutError(jsep_offer_str); | 3860 SetLocalDescriptionWithoutError(jsep_offer_str); |
| 3639 EXPECT_FALSE(session_->voice_channel()->srtp_required_for_testing()); | 3861 EXPECT_FALSE(session_->voice_channel()->srtp_required_for_testing()); |
| 3640 EXPECT_FALSE(session_->video_channel()->srtp_required_for_testing()); | 3862 EXPECT_FALSE(session_->video_channel()->srtp_required_for_testing()); |
| 3641 } | 3863 } |
| 3642 | 3864 |
| 3643 // This test verifies that an answer contains new ufrag and password if an offer | 3865 // This test verifies that an answer contains new ufrag and password if an offer |
| 3644 // with new ufrag and password is received. | 3866 // with new ufrag and password is received. |
| 3645 TEST_F(WebRtcSessionTest, TestCreateAnswerWithNewUfragAndPassword) { | 3867 TEST_F(WebRtcSessionTest, TestCreateAnswerWithNewUfragAndPassword) { |
| 3646 Init(); | 3868 Init(); |
| 3647 cricket::MediaSessionOptions options; | 3869 cricket::MediaSessionOptions options; |
| 3648 options.recv_video = true; | 3870 GetOptionsForRemoteOffer(&options); |
| 3649 std::unique_ptr<JsepSessionDescription> offer(CreateRemoteOffer(options)); | 3871 std::unique_ptr<JsepSessionDescription> offer(CreateRemoteOffer(options)); |
| 3650 SetRemoteDescriptionWithoutError(offer.release()); | 3872 SetRemoteDescriptionWithoutError(offer.release()); |
| 3651 | 3873 |
| 3652 SendAudioVideoStream1(); | 3874 SendAudioVideoStream1(); |
| 3653 std::unique_ptr<SessionDescriptionInterface> answer(CreateAnswer()); | 3875 std::unique_ptr<SessionDescriptionInterface> answer(CreateAnswer()); |
| 3654 SetLocalDescriptionWithoutError(answer.release()); | 3876 SetLocalDescriptionWithoutError(answer.release()); |
| 3655 | 3877 |
| 3656 // Receive an offer with new ufrag and password. | 3878 // Receive an offer with new ufrag and password. |
| 3657 for (const cricket::ContentInfo& content : | 3879 for (size_t i = 0; i < options.media_description_options.size(); ++i) { |
| 3658 session_->local_description()->description()->contents()) { | 3880 options.media_description_options[i].transport_options.ice_restart = true; |
| 3659 options.transport_options[content.name].ice_restart = true; | |
| 3660 } | 3881 } |
| 3882 | |
| 3661 std::unique_ptr<JsepSessionDescription> updated_offer1( | 3883 std::unique_ptr<JsepSessionDescription> updated_offer1( |
| 3662 CreateRemoteOffer(options, session_->remote_description())); | 3884 CreateRemoteOffer(options, session_->remote_description())); |
| 3663 SetRemoteDescriptionWithoutError(updated_offer1.release()); | 3885 SetRemoteDescriptionWithoutError(updated_offer1.release()); |
| 3664 | 3886 |
| 3665 std::unique_ptr<SessionDescriptionInterface> updated_answer1(CreateAnswer()); | 3887 std::unique_ptr<SessionDescriptionInterface> updated_answer1(CreateAnswer()); |
| 3666 | 3888 |
| 3667 EXPECT_FALSE(IceUfragPwdEqual(updated_answer1->description(), | 3889 EXPECT_FALSE(IceUfragPwdEqual(updated_answer1->description(), |
| 3668 session_->local_description()->description())); | 3890 session_->local_description()->description())); |
| 3669 | 3891 |
| 3670 // Even a second answer (created before the description is set) should have | 3892 // Even a second answer (created before the description is set) should have |
| 3671 // a new ufrag/password. | 3893 // a new ufrag/password. |
| 3672 std::unique_ptr<SessionDescriptionInterface> updated_answer2(CreateAnswer()); | 3894 std::unique_ptr<SessionDescriptionInterface> updated_answer2(CreateAnswer()); |
| 3673 | 3895 |
| 3674 EXPECT_FALSE(IceUfragPwdEqual(updated_answer2->description(), | 3896 EXPECT_FALSE(IceUfragPwdEqual(updated_answer2->description(), |
| 3675 session_->local_description()->description())); | 3897 session_->local_description()->description())); |
| 3676 | 3898 |
| 3677 SetLocalDescriptionWithoutError(updated_answer2.release()); | 3899 SetLocalDescriptionWithoutError(updated_answer2.release()); |
| 3678 } | 3900 } |
| 3679 | 3901 |
| 3680 // This test verifies that an answer contains new ufrag and password if an offer | 3902 // 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. | 3903 // 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 | 3904 // 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 | 3905 // a=ice-pwd attributes compared to the previous SDP from the peer, it |
| 3684 // indicates that ICE is restarting for this media stream." | 3906 // indicates that ICE is restarting for this media stream." |
| 3685 TEST_F(WebRtcSessionTest, TestOfferChangingOnlyUfragOrPassword) { | 3907 TEST_F(WebRtcSessionTest, TestOfferChangingOnlyUfragOrPassword) { |
| 3686 Init(); | 3908 Init(); |
| 3687 cricket::MediaSessionOptions options; | 3909 cricket::MediaSessionOptions options; |
| 3688 options.recv_audio = true; | 3910 GetOptionsForRemoteOffer(&options); |
| 3689 options.recv_video = true; | |
| 3690 // Create an offer with audio and video. | 3911 // Create an offer with audio and video. |
| 3691 std::unique_ptr<JsepSessionDescription> offer(CreateRemoteOffer(options)); | 3912 std::unique_ptr<JsepSessionDescription> offer(CreateRemoteOffer(options)); |
| 3692 SetIceUfragPwd(offer.get(), "original_ufrag", "original_password12345"); | 3913 SetIceUfragPwd(offer.get(), "original_ufrag", "original_password12345"); |
| 3693 SetRemoteDescriptionWithoutError(offer.release()); | 3914 SetRemoteDescriptionWithoutError(offer.release()); |
| 3694 | 3915 |
| 3695 SendAudioVideoStream1(); | 3916 SendAudioVideoStream1(); |
| 3696 std::unique_ptr<SessionDescriptionInterface> answer(CreateAnswer()); | 3917 std::unique_ptr<SessionDescriptionInterface> answer(CreateAnswer()); |
| 3697 SetLocalDescriptionWithoutError(answer.release()); | 3918 SetLocalDescriptionWithoutError(answer.release()); |
| 3698 | 3919 |
| 3699 // Receive an offer with a new ufrag but stale password. | 3920 // Receive an offer with a new ufrag but stale password. |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 3719 EXPECT_FALSE(IceUfragPwdEqual(updated_answer2->description(), | 3940 EXPECT_FALSE(IceUfragPwdEqual(updated_answer2->description(), |
| 3720 session_->local_description()->description())); | 3941 session_->local_description()->description())); |
| 3721 SetLocalDescriptionWithoutError(updated_answer2.release()); | 3942 SetLocalDescriptionWithoutError(updated_answer2.release()); |
| 3722 } | 3943 } |
| 3723 | 3944 |
| 3724 // This test verifies that an answer contains old ufrag and password if an offer | 3945 // This test verifies that an answer contains old ufrag and password if an offer |
| 3725 // with old ufrag and password is received. | 3946 // with old ufrag and password is received. |
| 3726 TEST_F(WebRtcSessionTest, TestCreateAnswerWithOldUfragAndPassword) { | 3947 TEST_F(WebRtcSessionTest, TestCreateAnswerWithOldUfragAndPassword) { |
| 3727 Init(); | 3948 Init(); |
| 3728 cricket::MediaSessionOptions options; | 3949 cricket::MediaSessionOptions options; |
| 3729 options.recv_video = true; | 3950 GetOptionsForRemoteOffer(&options); |
| 3730 std::unique_ptr<JsepSessionDescription> offer(CreateRemoteOffer(options)); | 3951 std::unique_ptr<JsepSessionDescription> offer(CreateRemoteOffer(options)); |
| 3731 SetRemoteDescriptionWithoutError(offer.release()); | 3952 SetRemoteDescriptionWithoutError(offer.release()); |
| 3732 | 3953 |
| 3733 SendAudioVideoStream1(); | 3954 SendAudioVideoStream1(); |
| 3734 std::unique_ptr<SessionDescriptionInterface> answer(CreateAnswer()); | 3955 std::unique_ptr<SessionDescriptionInterface> answer(CreateAnswer()); |
| 3735 SetLocalDescriptionWithoutError(answer.release()); | 3956 SetLocalDescriptionWithoutError(answer.release()); |
| 3736 | 3957 |
| 3737 // Receive an offer without changed ufrag or password. | 3958 // Receive an offer without changed ufrag or password. |
| 3738 std::unique_ptr<JsepSessionDescription> updated_offer2( | 3959 std::unique_ptr<JsepSessionDescription> updated_offer2( |
| 3739 CreateRemoteOffer(options, session_->remote_description())); | 3960 CreateRemoteOffer(options, session_->remote_description())); |
| 3740 SetRemoteDescriptionWithoutError(updated_offer2.release()); | 3961 SetRemoteDescriptionWithoutError(updated_offer2.release()); |
| 3741 | 3962 |
| 3742 std::unique_ptr<SessionDescriptionInterface> updated_answer2(CreateAnswer()); | 3963 std::unique_ptr<SessionDescriptionInterface> updated_answer2(CreateAnswer()); |
| 3743 | 3964 |
| 3744 EXPECT_TRUE(IceUfragPwdEqual(updated_answer2->description(), | 3965 EXPECT_TRUE(IceUfragPwdEqual(updated_answer2->description(), |
| 3745 session_->local_description()->description())); | 3966 session_->local_description()->description())); |
| 3746 | 3967 |
| 3747 SetLocalDescriptionWithoutError(updated_answer2.release()); | 3968 SetLocalDescriptionWithoutError(updated_answer2.release()); |
| 3748 } | 3969 } |
| 3749 | 3970 |
| 3750 // This test verifies that if an offer does an ICE restart on some, but not all | 3971 // 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 | 3972 // media sections, the answer will change the ufrag/password in the correct |
| 3752 // media sections. | 3973 // media sections. |
| 3753 TEST_F(WebRtcSessionTest, TestCreateAnswerWithNewAndOldUfragAndPassword) { | 3974 TEST_F(WebRtcSessionTest, TestCreateAnswerWithNewAndOldUfragAndPassword) { |
| 3754 Init(); | 3975 Init(); |
| 3755 cricket::MediaSessionOptions options; | 3976 cricket::MediaSessionOptions options; |
| 3756 options.recv_video = true; | 3977 GetOptionsForRemoteOffer(&options); |
| 3757 options.recv_audio = true; | |
| 3758 options.bundle_enabled = false; | 3978 options.bundle_enabled = false; |
| 3759 std::unique_ptr<JsepSessionDescription> offer(CreateRemoteOffer(options)); | 3979 std::unique_ptr<JsepSessionDescription> offer(CreateRemoteOffer(options)); |
| 3760 | 3980 |
| 3761 SetIceUfragPwd(offer.get(), cricket::MEDIA_TYPE_AUDIO, "aaaa", | 3981 SetIceUfragPwd(offer.get(), cricket::MEDIA_TYPE_AUDIO, "aaaa", |
| 3762 "aaaaaaaaaaaaaaaaaaaaaa"); | 3982 "aaaaaaaaaaaaaaaaaaaaaa"); |
| 3763 SetIceUfragPwd(offer.get(), cricket::MEDIA_TYPE_VIDEO, "bbbb", | 3983 SetIceUfragPwd(offer.get(), cricket::MEDIA_TYPE_VIDEO, "bbbb", |
| 3764 "bbbbbbbbbbbbbbbbbbbbbb"); | 3984 "bbbbbbbbbbbbbbbbbbbbbb"); |
| 3765 SetRemoteDescriptionWithoutError(offer.release()); | 3985 SetRemoteDescriptionWithoutError(offer.release()); |
| 3766 | 3986 |
| 3767 SendAudioVideoStream1(); | 3987 SendAudioVideoStream1(); |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3879 CreateDataChannel(); | 4099 CreateDataChannel(); |
| 3880 InitiateCall(); | 4100 InitiateCall(); |
| 3881 ASSERT_TRUE(session_->sctp_content_name()); | 4101 ASSERT_TRUE(session_->sctp_content_name()); |
| 3882 ASSERT_TRUE(session_->sctp_transport_name()); | 4102 ASSERT_TRUE(session_->sctp_transport_name()); |
| 3883 EXPECT_EQ("data", *session_->sctp_content_name()); | 4103 EXPECT_EQ("data", *session_->sctp_content_name()); |
| 3884 EXPECT_EQ("data", *session_->sctp_transport_name()); | 4104 EXPECT_EQ("data", *session_->sctp_transport_name()); |
| 3885 | 4105 |
| 3886 // Create answer that finishes BUNDLE negotiation, which means everything | 4106 // Create answer that finishes BUNDLE negotiation, which means everything |
| 3887 // should be bundled on the first transport (audio). | 4107 // should be bundled on the first transport (audio). |
| 3888 cricket::MediaSessionOptions answer_options; | 4108 cricket::MediaSessionOptions answer_options; |
| 3889 answer_options.recv_video = true; | |
| 3890 answer_options.bundle_enabled = true; | 4109 answer_options.bundle_enabled = true; |
| 3891 answer_options.data_channel_type = cricket::DCT_SCTP; | 4110 answer_options.data_channel_type = cricket::DCT_SCTP; |
| 4111 GetOptionsForAnswer(&answer_options); | |
| 3892 SetRemoteDescriptionWithoutError(CreateRemoteAnswer( | 4112 SetRemoteDescriptionWithoutError(CreateRemoteAnswer( |
| 3893 session_->local_description(), answer_options, cricket::SEC_DISABLED)); | 4113 session_->local_description(), answer_options, cricket::SEC_DISABLED)); |
| 3894 ASSERT_TRUE(session_->sctp_content_name()); | 4114 ASSERT_TRUE(session_->sctp_content_name()); |
| 3895 ASSERT_TRUE(session_->sctp_transport_name()); | 4115 ASSERT_TRUE(session_->sctp_transport_name()); |
| 3896 EXPECT_EQ("data", *session_->sctp_content_name()); | 4116 EXPECT_EQ("data", *session_->sctp_content_name()); |
| 3897 EXPECT_EQ("audio", *session_->sctp_transport_name()); | 4117 EXPECT_EQ("audio", *session_->sctp_transport_name()); |
| 3898 } | 4118 } |
| 3899 | 4119 |
| 3900 TEST_P(WebRtcSessionTest, TestCreateOfferWithSctpEnabledWithoutStreams) { | 4120 TEST_P(WebRtcSessionTest, TestCreateOfferWithSctpEnabledWithoutStreams) { |
| 3901 InitWithDtls(GetParam()); | 4121 InitWithDtls(GetParam()); |
| 3902 | 4122 |
| 3903 std::unique_ptr<SessionDescriptionInterface> offer(CreateOffer()); | 4123 std::unique_ptr<SessionDescriptionInterface> offer(CreateOffer()); |
| 3904 EXPECT_TRUE(offer->description()->GetContentByName("data") == NULL); | 4124 EXPECT_TRUE(offer->description()->GetContentByName("data") == NULL); |
| 3905 EXPECT_TRUE(offer->description()->GetTransportInfoByName("data") == NULL); | 4125 EXPECT_TRUE(offer->description()->GetTransportInfoByName("data") == NULL); |
| 3906 } | 4126 } |
| 3907 | 4127 |
| 3908 TEST_P(WebRtcSessionTest, TestCreateAnswerWithSctpInOfferAndNoStreams) { | 4128 TEST_P(WebRtcSessionTest, TestCreateAnswerWithSctpInOfferAndNoStreams) { |
| 3909 SetFactoryDtlsSrtp(); | 4129 SetFactoryDtlsSrtp(); |
| 3910 InitWithDtls(GetParam()); | 4130 InitWithDtls(GetParam()); |
| 3911 | 4131 |
| 3912 // Create remote offer with SCTP. | 4132 // Create remote offer with SCTP. |
| 3913 cricket::MediaSessionOptions options; | 4133 cricket::MediaSessionOptions options; |
| 3914 options.data_channel_type = cricket::DCT_SCTP; | 4134 options.data_channel_type = cricket::DCT_SCTP; |
| 4135 GetOptionsForRemoteOffer(&options); | |
| 3915 JsepSessionDescription* offer = | 4136 JsepSessionDescription* offer = |
| 3916 CreateRemoteOffer(options, cricket::SEC_DISABLED); | 4137 CreateRemoteOffer(options, cricket::SEC_DISABLED); |
| 3917 SetRemoteDescriptionWithoutError(offer); | 4138 SetRemoteDescriptionWithoutError(offer); |
| 3918 | 4139 |
| 3919 // Verifies the answer contains SCTP. | 4140 // Verifies the answer contains SCTP. |
| 3920 std::unique_ptr<SessionDescriptionInterface> answer(CreateAnswer()); | 4141 std::unique_ptr<SessionDescriptionInterface> answer(CreateAnswer()); |
| 3921 EXPECT_TRUE(answer != NULL); | 4142 EXPECT_TRUE(answer != NULL); |
| 3922 EXPECT_TRUE(answer->description()->GetContentByName("data") != NULL); | 4143 EXPECT_TRUE(answer->description()->GetContentByName("data") != NULL); |
| 3923 EXPECT_TRUE(answer->description()->GetTransportInfoByName("data") != NULL); | 4144 EXPECT_TRUE(answer->description()->GetTransportInfoByName("data") != NULL); |
| 3924 } | 4145 } |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4048 } | 4269 } |
| 4049 | 4270 |
| 4050 // Verifies that CreateAnswer succeeds when CreateOffer is called before async | 4271 // Verifies that CreateAnswer succeeds when CreateOffer is called before async |
| 4051 // identity generation is finished (even if a certificate is provided this is | 4272 // identity generation is finished (even if a certificate is provided this is |
| 4052 // an async op). | 4273 // an async op). |
| 4053 TEST_P(WebRtcSessionTest, TestCreateAnswerBeforeIdentityRequestReturnSuccess) { | 4274 TEST_P(WebRtcSessionTest, TestCreateAnswerBeforeIdentityRequestReturnSuccess) { |
| 4054 InitWithDtls(GetParam()); | 4275 InitWithDtls(GetParam()); |
| 4055 SetFactoryDtlsSrtp(); | 4276 SetFactoryDtlsSrtp(); |
| 4056 | 4277 |
| 4057 cricket::MediaSessionOptions options; | 4278 cricket::MediaSessionOptions options; |
| 4058 options.recv_video = true; | 4279 GetOptionsForRemoteOffer(&options); |
| 4059 std::unique_ptr<JsepSessionDescription> offer( | 4280 std::unique_ptr<JsepSessionDescription> offer( |
| 4060 CreateRemoteOffer(options, cricket::SEC_DISABLED)); | 4281 CreateRemoteOffer(options, cricket::SEC_DISABLED)); |
| 4061 ASSERT_TRUE(offer.get() != NULL); | 4282 ASSERT_TRUE(offer.get() != NULL); |
| 4062 SetRemoteDescriptionWithoutError(offer.release()); | 4283 SetRemoteDescriptionWithoutError(offer.release()); |
| 4063 | 4284 |
| 4064 std::unique_ptr<SessionDescriptionInterface> answer(CreateAnswer()); | 4285 std::unique_ptr<SessionDescriptionInterface> answer(CreateAnswer()); |
| 4065 EXPECT_TRUE(answer != NULL); | 4286 EXPECT_TRUE(answer != NULL); |
| 4066 VerifyNoCryptoParams(answer->description(), true); | 4287 VerifyNoCryptoParams(answer->description(), true); |
| 4067 VerifyFingerprintStatus(answer->description(), true); | 4288 VerifyFingerprintStatus(answer->description(), true); |
| 4068 } | 4289 } |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4122 CreateSessionDescriptionRequest::kAnswer); | 4343 CreateSessionDescriptionRequest::kAnswer); |
| 4123 } | 4344 } |
| 4124 | 4345 |
| 4125 // Verifies that setRemoteDescription fails when DTLS is disabled and the remote | 4346 // Verifies that setRemoteDescription fails when DTLS is disabled and the remote |
| 4126 // offer has no SDES crypto but only DTLS fingerprint. | 4347 // offer has no SDES crypto but only DTLS fingerprint. |
| 4127 TEST_F(WebRtcSessionTest, TestSetRemoteOfferFailIfDtlsDisabledAndNoCrypto) { | 4348 TEST_F(WebRtcSessionTest, TestSetRemoteOfferFailIfDtlsDisabledAndNoCrypto) { |
| 4128 // Init without DTLS. | 4349 // Init without DTLS. |
| 4129 Init(); | 4350 Init(); |
| 4130 // Create a remote offer with secured transport disabled. | 4351 // Create a remote offer with secured transport disabled. |
| 4131 cricket::MediaSessionOptions options; | 4352 cricket::MediaSessionOptions options; |
| 4353 GetOptionsForRemoteOffer(&options); | |
| 4132 JsepSessionDescription* offer(CreateRemoteOffer( | 4354 JsepSessionDescription* offer(CreateRemoteOffer( |
| 4133 options, cricket::SEC_DISABLED)); | 4355 options, cricket::SEC_DISABLED)); |
| 4134 // Adds a DTLS fingerprint to the remote offer. | 4356 // Adds a DTLS fingerprint to the remote offer. |
| 4135 cricket::SessionDescription* sdp = offer->description(); | 4357 cricket::SessionDescription* sdp = offer->description(); |
| 4136 TransportInfo* audio = sdp->GetTransportInfoByName("audio"); | 4358 TransportInfo* audio = sdp->GetTransportInfoByName("audio"); |
| 4137 ASSERT_TRUE(audio != NULL); | 4359 ASSERT_TRUE(audio != NULL); |
| 4138 ASSERT_TRUE(audio->description.identity_fingerprint.get() == NULL); | 4360 ASSERT_TRUE(audio->description.identity_fingerprint.get() == NULL); |
| 4139 audio->description.identity_fingerprint.reset( | 4361 audio->description.identity_fingerprint.reset( |
| 4140 rtc::SSLFingerprint::CreateFromRfc4572( | 4362 rtc::SSLFingerprint::CreateFromRfc4572( |
| 4141 rtc::DIGEST_SHA_256, kFakeDtlsFingerprint)); | 4363 rtc::DIGEST_SHA_256, kFakeDtlsFingerprint)); |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 4165 SetFactoryDtlsSrtp(); | 4387 SetFactoryDtlsSrtp(); |
| 4166 | 4388 |
| 4167 SendAudioOnlyStream2(); | 4389 SendAudioOnlyStream2(); |
| 4168 SessionDescriptionInterface* offer = CreateOffer(); | 4390 SessionDescriptionInterface* offer = CreateOffer(); |
| 4169 SetLocalDescriptionWithoutError(offer); | 4391 SetLocalDescriptionWithoutError(offer); |
| 4170 | 4392 |
| 4171 SessionDescriptionInterface* answer = CreateRemoteAnswer(offer); | 4393 SessionDescriptionInterface* answer = CreateRemoteAnswer(offer); |
| 4172 SetRemoteDescriptionWithoutError(answer); | 4394 SetRemoteDescriptionWithoutError(answer); |
| 4173 | 4395 |
| 4174 cricket::MediaSessionOptions options; | 4396 cricket::MediaSessionOptions options; |
| 4175 options.recv_video = true; | 4397 GetOptionsForRemoteOffer(&options); |
| 4176 offer = CreateRemoteOffer(options, cricket::SEC_DISABLED); | 4398 offer = CreateRemoteOffer(options, cricket::SEC_DISABLED); |
| 4177 | 4399 |
| 4178 cricket::Candidate candidate1; | 4400 cricket::Candidate candidate1; |
| 4179 candidate1.set_address(rtc::SocketAddress("1.1.1.1", 5000)); | 4401 candidate1.set_address(rtc::SocketAddress("1.1.1.1", 5000)); |
| 4180 candidate1.set_component(1); | 4402 candidate1.set_component(1); |
| 4181 JsepIceCandidate ice_candidate(kMediaContentName1, kMediaContentIndex1, | 4403 JsepIceCandidate ice_candidate(kMediaContentName1, kMediaContentIndex1, |
| 4182 candidate1); | 4404 candidate1); |
| 4183 EXPECT_TRUE(offer->AddCandidate(&ice_candidate)); | 4405 EXPECT_TRUE(offer->AddCandidate(&ice_candidate)); |
| 4184 SetRemoteDescriptionWithoutError(offer); | 4406 SetRemoteDescriptionWithoutError(offer); |
| 4185 | 4407 |
| 4186 answer = CreateAnswer(); | 4408 answer = CreateAnswer(); |
| 4187 SetLocalDescriptionWithoutError(answer); | 4409 SetLocalDescriptionWithoutError(answer); |
| 4188 } | 4410 } |
| 4189 | 4411 |
| 4190 // Tests that we can renegotiate new media content with ICE candidates separated | 4412 // Tests that we can renegotiate new media content with ICE candidates separated |
| 4191 // from the remote SDP. | 4413 // from the remote SDP. |
| 4192 TEST_P(WebRtcSessionTest, TestRenegotiateNewMediaWithCandidatesSeparated) { | 4414 TEST_P(WebRtcSessionTest, TestRenegotiateNewMediaWithCandidatesSeparated) { |
| 4193 InitWithDtls(GetParam()); | 4415 InitWithDtls(GetParam()); |
| 4194 SetFactoryDtlsSrtp(); | 4416 SetFactoryDtlsSrtp(); |
| 4195 | 4417 |
| 4196 SendAudioOnlyStream2(); | 4418 SendAudioOnlyStream2(); |
| 4197 SessionDescriptionInterface* offer = CreateOffer(); | 4419 SessionDescriptionInterface* offer = CreateOffer(); |
| 4198 SetLocalDescriptionWithoutError(offer); | 4420 SetLocalDescriptionWithoutError(offer); |
| 4199 | 4421 |
| 4200 SessionDescriptionInterface* answer = CreateRemoteAnswer(offer); | 4422 SessionDescriptionInterface* answer = CreateRemoteAnswer(offer); |
| 4201 SetRemoteDescriptionWithoutError(answer); | 4423 SetRemoteDescriptionWithoutError(answer); |
| 4202 | 4424 |
| 4203 cricket::MediaSessionOptions options; | 4425 cricket::MediaSessionOptions options; |
| 4204 options.recv_video = true; | 4426 GetOptionsForRemoteOffer(&options); |
| 4205 offer = CreateRemoteOffer(options, cricket::SEC_DISABLED); | 4427 offer = CreateRemoteOffer(options, cricket::SEC_DISABLED); |
| 4206 SetRemoteDescriptionWithoutError(offer); | 4428 SetRemoteDescriptionWithoutError(offer); |
| 4207 | 4429 |
| 4208 cricket::Candidate candidate1; | 4430 cricket::Candidate candidate1; |
| 4209 candidate1.set_address(rtc::SocketAddress("1.1.1.1", 5000)); | 4431 candidate1.set_address(rtc::SocketAddress("1.1.1.1", 5000)); |
| 4210 candidate1.set_component(1); | 4432 candidate1.set_component(1); |
| 4211 JsepIceCandidate ice_candidate(kMediaContentName1, kMediaContentIndex1, | 4433 JsepIceCandidate ice_candidate(kMediaContentName1, kMediaContentIndex1, |
| 4212 candidate1); | 4434 candidate1); |
| 4213 EXPECT_TRUE(session_->ProcessIceMessage(&ice_candidate)); | 4435 EXPECT_TRUE(session_->ProcessIceMessage(&ice_candidate)); |
| 4214 | 4436 |
| 4215 answer = CreateAnswer(); | 4437 answer = CreateAnswer(); |
| 4216 SetLocalDescriptionWithoutError(answer); | 4438 SetLocalDescriptionWithoutError(answer); |
| 4217 } | 4439 } |
| 4218 | 4440 |
| 4219 #ifdef HAVE_QUIC | 4441 #ifdef HAVE_QUIC |
| 4220 TEST_P(WebRtcSessionTest, TestNegotiateQuic) { | 4442 TEST_P(WebRtcSessionTest, TestNegotiateQuic) { |
| 4221 configuration_.enable_quic = true; | 4443 configuration_.enable_quic = true; |
| 4222 InitWithDtls(GetParam()); | 4444 InitWithDtls(GetParam()); |
| 4223 EXPECT_TRUE(session_->data_channel_type() == cricket::DCT_QUIC); | 4445 EXPECT_TRUE(session_->data_channel_type() == cricket::DCT_QUIC); |
| 4224 SessionDescriptionInterface* offer = CreateOffer(); | 4446 SessionDescriptionInterface* offer = CreateOffer(); |
| 4225 ASSERT_TRUE(offer); | 4447 ASSERT_TRUE(offer); |
| 4226 ASSERT_TRUE(offer->description()); | 4448 ASSERT_TRUE(offer->description()); |
| 4227 SetLocalDescriptionWithoutError(offer); | 4449 SetLocalDescriptionWithoutError(offer); |
| 4228 cricket::MediaSessionOptions options; | 4450 cricket::MediaSessionOptions options; |
| 4229 options.recv_audio = true; | 4451 GetOptionsForAnswer(&options); |
| 4230 options.recv_video = true; | |
| 4231 SessionDescriptionInterface* answer = | 4452 SessionDescriptionInterface* answer = |
| 4232 CreateRemoteAnswer(offer, options, cricket::SEC_DISABLED); | 4453 CreateRemoteAnswer(offer, options, cricket::SEC_DISABLED); |
| 4233 ASSERT_TRUE(answer); | 4454 ASSERT_TRUE(answer); |
| 4234 ASSERT_TRUE(answer->description()); | 4455 ASSERT_TRUE(answer->description()); |
| 4235 SetRemoteDescriptionWithoutError(answer); | 4456 SetRemoteDescriptionWithoutError(answer); |
| 4236 } | 4457 } |
| 4237 #endif // HAVE_QUIC | 4458 #endif // HAVE_QUIC |
| 4238 | 4459 |
| 4239 // Tests that RTX codec is removed from the answer when it isn't supported | 4460 // Tests that RTX codec is removed from the answer when it isn't supported |
| 4240 // by local side. | 4461 // by local side. |
| 4241 TEST_F(WebRtcSessionTest, TestRtxRemovedByCreateAnswer) { | 4462 TEST_F(WebRtcSessionTest, TestRtxRemovedByCreateAnswer) { |
| 4242 Init(); | 4463 Init(); |
| 4243 SendAudioVideoStream1(); | 4464 // Send video only to match the |kSdpWithRtx|. |
| 4465 SendVideoOnlyStream2(); | |
| 4244 std::string offer_sdp(kSdpWithRtx); | 4466 std::string offer_sdp(kSdpWithRtx); |
| 4245 | 4467 |
| 4246 SessionDescriptionInterface* offer = | 4468 SessionDescriptionInterface* offer = |
| 4247 CreateSessionDescription(JsepSessionDescription::kOffer, offer_sdp, NULL); | 4469 CreateSessionDescription(JsepSessionDescription::kOffer, offer_sdp, NULL); |
| 4248 EXPECT_TRUE(offer->ToString(&offer_sdp)); | 4470 EXPECT_TRUE(offer->ToString(&offer_sdp)); |
| 4249 | 4471 |
| 4250 // Offer SDP contains the RTX codec. | 4472 // Offer SDP contains the RTX codec. |
| 4251 EXPECT_TRUE(ContainsVideoCodecWithName(offer, "rtx")); | 4473 EXPECT_TRUE(ContainsVideoCodecWithName(offer, "rtx")); |
| 4252 SetRemoteDescriptionWithoutError(offer); | 4474 SetRemoteDescriptionWithoutError(offer); |
| 4253 | 4475 |
| 4476 // |offered_media_sections_| is used when creating answer. | |
| 4477 offered_media_sections_.push_back(cricket::MediaDescriptionOptions( | |
| 4478 cricket::MEDIA_TYPE_VIDEO, cricket::CN_VIDEO, | |
| 4479 cricket::RtpTransceiverDirection(true, true), false)); | |
| 4480 // Don't create media section for audio in the answer. | |
| 4254 SessionDescriptionInterface* answer = CreateAnswer(); | 4481 SessionDescriptionInterface* answer = CreateAnswer(); |
| 4255 // Answer SDP does not contain the RTX codec. | 4482 // Answer SDP does not contain the RTX codec. |
| 4256 EXPECT_FALSE(ContainsVideoCodecWithName(answer, "rtx")); | 4483 EXPECT_FALSE(ContainsVideoCodecWithName(answer, "rtx")); |
| 4257 SetLocalDescriptionWithoutError(answer); | 4484 SetLocalDescriptionWithoutError(answer); |
| 4258 } | 4485 } |
| 4259 | 4486 |
| 4260 // This verifies that the voice channel after bundle has both options from video | 4487 // This verifies that the voice channel after bundle has both options from video |
| 4261 // and voice channels. | 4488 // and voice channels. |
| 4262 TEST_F(WebRtcSessionTest, TestSetSocketOptionBeforeBundle) { | 4489 TEST_F(WebRtcSessionTest, TestSetSocketOptionBeforeBundle) { |
| 4263 InitWithBundlePolicy(PeerConnectionInterface::kBundlePolicyBalanced); | 4490 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. | 4536 // and make sure we got success/failure callbacks for all of the requests. |
| 4310 // Background: crbug.com/507307 | 4537 // Background: crbug.com/507307 |
| 4311 TEST_F(WebRtcSessionTest, CreateOffersAndShutdown) { | 4538 TEST_F(WebRtcSessionTest, CreateOffersAndShutdown) { |
| 4312 Init(); | 4539 Init(); |
| 4313 | 4540 |
| 4314 rtc::scoped_refptr<WebRtcSessionCreateSDPObserverForTest> observers[100]; | 4541 rtc::scoped_refptr<WebRtcSessionCreateSDPObserverForTest> observers[100]; |
| 4315 PeerConnectionInterface::RTCOfferAnswerOptions options; | 4542 PeerConnectionInterface::RTCOfferAnswerOptions options; |
| 4316 options.offer_to_receive_audio = | 4543 options.offer_to_receive_audio = |
| 4317 RTCOfferAnswerOptions::kOfferToReceiveMediaTrue; | 4544 RTCOfferAnswerOptions::kOfferToReceiveMediaTrue; |
| 4318 cricket::MediaSessionOptions session_options; | 4545 cricket::MediaSessionOptions session_options; |
| 4319 session_options.recv_audio = true; | 4546 GetOptionsForOffer(options, &session_options); |
| 4320 | |
| 4321 for (auto& o : observers) { | 4547 for (auto& o : observers) { |
| 4322 o = new WebRtcSessionCreateSDPObserverForTest(); | 4548 o = new WebRtcSessionCreateSDPObserverForTest(); |
| 4323 session_->CreateOffer(o, options, session_options); | 4549 session_->CreateOffer(o, options, session_options); |
| 4324 } | 4550 } |
| 4325 | 4551 |
| 4326 session_.reset(); | 4552 session_.reset(); |
| 4327 | 4553 |
| 4328 for (auto& o : observers) { | 4554 for (auto& o : observers) { |
| 4329 // We expect to have received a notification now even if the session was | 4555 // 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 | 4556 // terminated. The offer creation may or may not have succeeded, but we |
| 4331 // must have received a notification which, so the only invalid state | 4557 // must have received a notification which, so the only invalid state |
| 4332 // is kInit. | 4558 // is kInit. |
| 4333 EXPECT_NE(WebRtcSessionCreateSDPObserverForTest::kInit, o->state()); | 4559 EXPECT_NE(WebRtcSessionCreateSDPObserverForTest::kInit, o->state()); |
| 4334 } | 4560 } |
| 4335 } | 4561 } |
| 4336 | 4562 |
| 4337 TEST_F(WebRtcSessionTest, TestPacketOptionsAndOnPacketSent) { | 4563 TEST_F(WebRtcSessionTest, TestPacketOptionsAndOnPacketSent) { |
| 4338 TestPacketOptions(); | 4564 TestPacketOptions(); |
| 4339 } | 4565 } |
| 4340 | 4566 |
| 4341 // TODO(bemasc): Add a TestIceStatesBundle with BUNDLE enabled. That test | 4567 // TODO(bemasc): Add a TestIceStatesBundle with BUNDLE enabled. That test |
| 4342 // currently fails because upon disconnection and reconnection OnIceComplete is | 4568 // currently fails because upon disconnection and reconnection OnIceComplete is |
| 4343 // called more than once without returning to IceGatheringGathering. | 4569 // called more than once without returning to IceGatheringGathering. |
| 4344 | 4570 |
| 4345 INSTANTIATE_TEST_CASE_P(WebRtcSessionTests, | 4571 INSTANTIATE_TEST_CASE_P(WebRtcSessionTests, |
| 4346 WebRtcSessionTest, | 4572 WebRtcSessionTest, |
| 4347 testing::Values(ALREADY_GENERATED, | 4573 testing::Values(ALREADY_GENERATED, |
| 4348 DTLS_IDENTITY_STORE)); | 4574 DTLS_IDENTITY_STORE)); |
| OLD | NEW |