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