| 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 619 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 630 audio_track_label, static_cast<AudioSourceInterface*>(NULL))); | 630 audio_track_label, static_cast<AudioSourceInterface*>(NULL))); |
| 631 stream->AddTrack(audio_track.get()); | 631 stream->AddTrack(audio_track.get()); |
| 632 scoped_refptr<VideoTrackInterface> video_track( | 632 scoped_refptr<VideoTrackInterface> video_track( |
| 633 pc_factory_->CreateVideoTrack(video_track_label, NULL)); | 633 pc_factory_->CreateVideoTrack(video_track_label, NULL)); |
| 634 stream->AddTrack(video_track.get()); | 634 stream->AddTrack(video_track.get()); |
| 635 EXPECT_TRUE(pc_->AddStream(stream)); | 635 EXPECT_TRUE(pc_->AddStream(stream)); |
| 636 EXPECT_TRUE_WAIT(observer_.renegotiation_needed_, kTimeout); | 636 EXPECT_TRUE_WAIT(observer_.renegotiation_needed_, kTimeout); |
| 637 observer_.renegotiation_needed_ = false; | 637 observer_.renegotiation_needed_ = false; |
| 638 } | 638 } |
| 639 | 639 |
| 640 bool DoCreateOfferAnswer(SessionDescriptionInterface** desc, | 640 bool DoCreateOfferAnswer(rtc::scoped_ptr<SessionDescriptionInterface>* desc, |
| 641 bool offer, | 641 bool offer, |
| 642 MediaConstraintsInterface* constraints) { | 642 MediaConstraintsInterface* constraints) { |
| 643 rtc::scoped_refptr<MockCreateSessionDescriptionObserver> | 643 rtc::scoped_refptr<MockCreateSessionDescriptionObserver> |
| 644 observer(new rtc::RefCountedObject< | 644 observer(new rtc::RefCountedObject< |
| 645 MockCreateSessionDescriptionObserver>()); | 645 MockCreateSessionDescriptionObserver>()); |
| 646 if (offer) { | 646 if (offer) { |
| 647 pc_->CreateOffer(observer, constraints); | 647 pc_->CreateOffer(observer, constraints); |
| 648 } else { | 648 } else { |
| 649 pc_->CreateAnswer(observer, constraints); | 649 pc_->CreateAnswer(observer, constraints); |
| 650 } | 650 } |
| 651 EXPECT_EQ_WAIT(true, observer->called(), kTimeout); | 651 EXPECT_EQ_WAIT(true, observer->called(), kTimeout); |
| 652 *desc = observer->release_desc(); | 652 desc->reset(observer->release_desc()); |
| 653 return observer->result(); | 653 return observer->result(); |
| 654 } | 654 } |
| 655 | 655 |
| 656 bool DoCreateOffer(SessionDescriptionInterface** desc, | 656 bool DoCreateOffer(rtc::scoped_ptr<SessionDescriptionInterface>* desc, |
| 657 MediaConstraintsInterface* constraints) { | 657 MediaConstraintsInterface* constraints) { |
| 658 return DoCreateOfferAnswer(desc, true, constraints); | 658 return DoCreateOfferAnswer(desc, true, constraints); |
| 659 } | 659 } |
| 660 | 660 |
| 661 bool DoCreateAnswer(SessionDescriptionInterface** desc, | 661 bool DoCreateAnswer(rtc::scoped_ptr<SessionDescriptionInterface>* desc, |
| 662 MediaConstraintsInterface* constraints) { | 662 MediaConstraintsInterface* constraints) { |
| 663 return DoCreateOfferAnswer(desc, false, constraints); | 663 return DoCreateOfferAnswer(desc, false, constraints); |
| 664 } | 664 } |
| 665 | 665 |
| 666 bool DoSetSessionDescription(SessionDescriptionInterface* desc, bool local) { | 666 bool DoSetSessionDescription(SessionDescriptionInterface* desc, bool local) { |
| 667 rtc::scoped_refptr<MockSetSessionDescriptionObserver> | 667 rtc::scoped_refptr<MockSetSessionDescriptionObserver> |
| 668 observer(new rtc::RefCountedObject< | 668 observer(new rtc::RefCountedObject< |
| 669 MockSetSessionDescriptionObserver>()); | 669 MockSetSessionDescriptionObserver>()); |
| 670 if (local) { | 670 if (local) { |
| 671 pc_->SetLocalDescription(observer, desc); | 671 pc_->SetLocalDescription(observer, desc); |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 713 EXPECT_GT(desc->rtp_header_extensions().size(), 0u); | 713 EXPECT_GT(desc->rtp_header_extensions().size(), 0u); |
| 714 | 714 |
| 715 desc = cricket::GetFirstVideoContentDescription( | 715 desc = cricket::GetFirstVideoContentDescription( |
| 716 pc_->remote_description()->description()); | 716 pc_->remote_description()->description()); |
| 717 ASSERT_TRUE(desc != NULL); | 717 ASSERT_TRUE(desc != NULL); |
| 718 EXPECT_GT(desc->rtp_header_extensions().size(), 0u); | 718 EXPECT_GT(desc->rtp_header_extensions().size(), 0u); |
| 719 } | 719 } |
| 720 | 720 |
| 721 void CreateOfferAsRemoteDescription() { | 721 void CreateOfferAsRemoteDescription() { |
| 722 rtc::scoped_ptr<SessionDescriptionInterface> offer; | 722 rtc::scoped_ptr<SessionDescriptionInterface> offer; |
| 723 ASSERT_TRUE(DoCreateOffer(offer.use(), nullptr)); | 723 ASSERT_TRUE(DoCreateOffer(&offer, nullptr)); |
| 724 std::string sdp; | 724 std::string sdp; |
| 725 EXPECT_TRUE(offer->ToString(&sdp)); | 725 EXPECT_TRUE(offer->ToString(&sdp)); |
| 726 SessionDescriptionInterface* remote_offer = | 726 SessionDescriptionInterface* remote_offer = |
| 727 webrtc::CreateSessionDescription(SessionDescriptionInterface::kOffer, | 727 webrtc::CreateSessionDescription(SessionDescriptionInterface::kOffer, |
| 728 sdp, NULL); | 728 sdp, NULL); |
| 729 EXPECT_TRUE(DoSetRemoteDescription(remote_offer)); | 729 EXPECT_TRUE(DoSetRemoteDescription(remote_offer)); |
| 730 EXPECT_EQ(PeerConnectionInterface::kHaveRemoteOffer, observer_.state_); | 730 EXPECT_EQ(PeerConnectionInterface::kHaveRemoteOffer, observer_.state_); |
| 731 } | 731 } |
| 732 | 732 |
| 733 void CreateAndSetRemoteOffer(const std::string& sdp) { | 733 void CreateAndSetRemoteOffer(const std::string& sdp) { |
| 734 SessionDescriptionInterface* remote_offer = | 734 SessionDescriptionInterface* remote_offer = |
| 735 webrtc::CreateSessionDescription(SessionDescriptionInterface::kOffer, | 735 webrtc::CreateSessionDescription(SessionDescriptionInterface::kOffer, |
| 736 sdp, nullptr); | 736 sdp, nullptr); |
| 737 EXPECT_TRUE(DoSetRemoteDescription(remote_offer)); | 737 EXPECT_TRUE(DoSetRemoteDescription(remote_offer)); |
| 738 EXPECT_EQ(PeerConnectionInterface::kHaveRemoteOffer, observer_.state_); | 738 EXPECT_EQ(PeerConnectionInterface::kHaveRemoteOffer, observer_.state_); |
| 739 } | 739 } |
| 740 | 740 |
| 741 void CreateAnswerAsLocalDescription() { | 741 void CreateAnswerAsLocalDescription() { |
| 742 scoped_ptr<SessionDescriptionInterface> answer; | 742 scoped_ptr<SessionDescriptionInterface> answer; |
| 743 ASSERT_TRUE(DoCreateAnswer(answer.use(), nullptr)); | 743 ASSERT_TRUE(DoCreateAnswer(&answer, nullptr)); |
| 744 | 744 |
| 745 // TODO(perkj): Currently SetLocalDescription fails if any parameters in an | 745 // TODO(perkj): Currently SetLocalDescription fails if any parameters in an |
| 746 // audio codec change, even if the parameter has nothing to do with | 746 // audio codec change, even if the parameter has nothing to do with |
| 747 // receiving. Not all parameters are serialized to SDP. | 747 // receiving. Not all parameters are serialized to SDP. |
| 748 // Since CreatePrAnswerAsLocalDescription serialize/deserialize | 748 // Since CreatePrAnswerAsLocalDescription serialize/deserialize |
| 749 // the SessionDescription, it is necessary to do that here to in order to | 749 // the SessionDescription, it is necessary to do that here to in order to |
| 750 // get ReceiveOfferCreatePrAnswerAndAnswer and RenegotiateAudioOnly to pass. | 750 // get ReceiveOfferCreatePrAnswerAndAnswer and RenegotiateAudioOnly to pass. |
| 751 // https://code.google.com/p/webrtc/issues/detail?id=1356 | 751 // https://code.google.com/p/webrtc/issues/detail?id=1356 |
| 752 std::string sdp; | 752 std::string sdp; |
| 753 EXPECT_TRUE(answer->ToString(&sdp)); | 753 EXPECT_TRUE(answer->ToString(&sdp)); |
| 754 SessionDescriptionInterface* new_answer = | 754 SessionDescriptionInterface* new_answer = |
| 755 webrtc::CreateSessionDescription(SessionDescriptionInterface::kAnswer, | 755 webrtc::CreateSessionDescription(SessionDescriptionInterface::kAnswer, |
| 756 sdp, NULL); | 756 sdp, NULL); |
| 757 EXPECT_TRUE(DoSetLocalDescription(new_answer)); | 757 EXPECT_TRUE(DoSetLocalDescription(new_answer)); |
| 758 EXPECT_EQ(PeerConnectionInterface::kStable, observer_.state_); | 758 EXPECT_EQ(PeerConnectionInterface::kStable, observer_.state_); |
| 759 } | 759 } |
| 760 | 760 |
| 761 void CreatePrAnswerAsLocalDescription() { | 761 void CreatePrAnswerAsLocalDescription() { |
| 762 scoped_ptr<SessionDescriptionInterface> answer; | 762 scoped_ptr<SessionDescriptionInterface> answer; |
| 763 ASSERT_TRUE(DoCreateAnswer(answer.use(), nullptr)); | 763 ASSERT_TRUE(DoCreateAnswer(&answer, nullptr)); |
| 764 | 764 |
| 765 std::string sdp; | 765 std::string sdp; |
| 766 EXPECT_TRUE(answer->ToString(&sdp)); | 766 EXPECT_TRUE(answer->ToString(&sdp)); |
| 767 SessionDescriptionInterface* pr_answer = | 767 SessionDescriptionInterface* pr_answer = |
| 768 webrtc::CreateSessionDescription(SessionDescriptionInterface::kPrAnswer, | 768 webrtc::CreateSessionDescription(SessionDescriptionInterface::kPrAnswer, |
| 769 sdp, NULL); | 769 sdp, NULL); |
| 770 EXPECT_TRUE(DoSetLocalDescription(pr_answer)); | 770 EXPECT_TRUE(DoSetLocalDescription(pr_answer)); |
| 771 EXPECT_EQ(PeerConnectionInterface::kHaveLocalPrAnswer, observer_.state_); | 771 EXPECT_EQ(PeerConnectionInterface::kHaveLocalPrAnswer, observer_.state_); |
| 772 } | 772 } |
| 773 | 773 |
| 774 void CreateOfferReceiveAnswer() { | 774 void CreateOfferReceiveAnswer() { |
| 775 CreateOfferAsLocalDescription(); | 775 CreateOfferAsLocalDescription(); |
| 776 std::string sdp; | 776 std::string sdp; |
| 777 EXPECT_TRUE(pc_->local_description()->ToString(&sdp)); | 777 EXPECT_TRUE(pc_->local_description()->ToString(&sdp)); |
| 778 CreateAnswerAsRemoteDescription(sdp); | 778 CreateAnswerAsRemoteDescription(sdp); |
| 779 } | 779 } |
| 780 | 780 |
| 781 void CreateOfferAsLocalDescription() { | 781 void CreateOfferAsLocalDescription() { |
| 782 rtc::scoped_ptr<SessionDescriptionInterface> offer; | 782 rtc::scoped_ptr<SessionDescriptionInterface> offer; |
| 783 ASSERT_TRUE(DoCreateOffer(offer.use(), nullptr)); | 783 ASSERT_TRUE(DoCreateOffer(&offer, nullptr)); |
| 784 // TODO(perkj): Currently SetLocalDescription fails if any parameters in an | 784 // TODO(perkj): Currently SetLocalDescription fails if any parameters in an |
| 785 // audio codec change, even if the parameter has nothing to do with | 785 // audio codec change, even if the parameter has nothing to do with |
| 786 // receiving. Not all parameters are serialized to SDP. | 786 // receiving. Not all parameters are serialized to SDP. |
| 787 // Since CreatePrAnswerAsLocalDescription serialize/deserialize | 787 // Since CreatePrAnswerAsLocalDescription serialize/deserialize |
| 788 // the SessionDescription, it is necessary to do that here to in order to | 788 // the SessionDescription, it is necessary to do that here to in order to |
| 789 // get ReceiveOfferCreatePrAnswerAndAnswer and RenegotiateAudioOnly to pass. | 789 // get ReceiveOfferCreatePrAnswerAndAnswer and RenegotiateAudioOnly to pass. |
| 790 // https://code.google.com/p/webrtc/issues/detail?id=1356 | 790 // https://code.google.com/p/webrtc/issues/detail?id=1356 |
| 791 std::string sdp; | 791 std::string sdp; |
| 792 EXPECT_TRUE(offer->ToString(&sdp)); | 792 EXPECT_TRUE(offer->ToString(&sdp)); |
| 793 SessionDescriptionInterface* new_offer = | 793 SessionDescriptionInterface* new_offer = |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 840 CreateOfferAsLocalDescription(); | 840 CreateOfferAsLocalDescription(); |
| 841 std::string sdp; | 841 std::string sdp; |
| 842 EXPECT_TRUE(pc_->local_description()->ToString(&sdp)); | 842 EXPECT_TRUE(pc_->local_description()->ToString(&sdp)); |
| 843 SetSsrcToZero(&sdp); | 843 SetSsrcToZero(&sdp); |
| 844 CreateAnswerAsRemoteDescription(sdp); | 844 CreateAnswerAsRemoteDescription(sdp); |
| 845 } | 845 } |
| 846 | 846 |
| 847 // This function creates a MediaStream with label kStreams[0] and | 847 // This function creates a MediaStream with label kStreams[0] and |
| 848 // |number_of_audio_tracks| and |number_of_video_tracks| tracks and the | 848 // |number_of_audio_tracks| and |number_of_video_tracks| tracks and the |
| 849 // corresponding SessionDescriptionInterface. The SessionDescriptionInterface | 849 // corresponding SessionDescriptionInterface. The SessionDescriptionInterface |
| 850 // is returned in |desc| and the MediaStream is stored in | 850 // is returned and the MediaStream is stored in |
| 851 // |reference_collection_| | 851 // |reference_collection_| |
| 852 void CreateSessionDescriptionAndReference( | 852 rtc::scoped_ptr<SessionDescriptionInterface> |
| 853 size_t number_of_audio_tracks, | 853 CreateSessionDescriptionAndReference(size_t number_of_audio_tracks, |
| 854 size_t number_of_video_tracks, | 854 size_t number_of_video_tracks) { |
| 855 SessionDescriptionInterface** desc) { | 855 EXPECT_LE(number_of_audio_tracks, 2u); |
| 856 ASSERT_TRUE(desc != nullptr); | 856 EXPECT_LE(number_of_video_tracks, 2u); |
| 857 ASSERT_LE(number_of_audio_tracks, 2u); | |
| 858 ASSERT_LE(number_of_video_tracks, 2u); | |
| 859 | 857 |
| 860 reference_collection_ = StreamCollection::Create(); | 858 reference_collection_ = StreamCollection::Create(); |
| 861 std::string sdp_ms1 = std::string(kSdpStringInit); | 859 std::string sdp_ms1 = std::string(kSdpStringInit); |
| 862 | 860 |
| 863 std::string mediastream_label = kStreams[0]; | 861 std::string mediastream_label = kStreams[0]; |
| 864 | 862 |
| 865 rtc::scoped_refptr<webrtc::MediaStreamInterface> stream( | 863 rtc::scoped_refptr<webrtc::MediaStreamInterface> stream( |
| 866 webrtc::MediaStream::Create(mediastream_label)); | 864 webrtc::MediaStream::Create(mediastream_label)); |
| 867 reference_collection_->AddStream(stream); | 865 reference_collection_->AddStream(stream); |
| 868 | 866 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 879 if (number_of_video_tracks > 0) { | 877 if (number_of_video_tracks > 0) { |
| 880 sdp_ms1 += std::string(kSdpStringVideo); | 878 sdp_ms1 += std::string(kSdpStringVideo); |
| 881 sdp_ms1 += std::string(kSdpStringMs1Video0); | 879 sdp_ms1 += std::string(kSdpStringMs1Video0); |
| 882 AddVideoTrack(kVideoTracks[0], stream); | 880 AddVideoTrack(kVideoTracks[0], stream); |
| 883 } | 881 } |
| 884 if (number_of_video_tracks > 1) { | 882 if (number_of_video_tracks > 1) { |
| 885 sdp_ms1 += kSdpStringMs1Video1; | 883 sdp_ms1 += kSdpStringMs1Video1; |
| 886 AddVideoTrack(kVideoTracks[1], stream); | 884 AddVideoTrack(kVideoTracks[1], stream); |
| 887 } | 885 } |
| 888 | 886 |
| 889 *desc = webrtc::CreateSessionDescription( | 887 return rtc::scoped_ptr<SessionDescriptionInterface>( |
| 890 SessionDescriptionInterface::kOffer, sdp_ms1, nullptr); | 888 webrtc::CreateSessionDescription(SessionDescriptionInterface::kOffer, |
| 889 sdp_ms1, nullptr)); |
| 891 } | 890 } |
| 892 | 891 |
| 893 void AddAudioTrack(const std::string& track_id, | 892 void AddAudioTrack(const std::string& track_id, |
| 894 MediaStreamInterface* stream) { | 893 MediaStreamInterface* stream) { |
| 895 rtc::scoped_refptr<webrtc::AudioTrackInterface> audio_track( | 894 rtc::scoped_refptr<webrtc::AudioTrackInterface> audio_track( |
| 896 webrtc::AudioTrack::Create(track_id, nullptr)); | 895 webrtc::AudioTrack::Create(track_id, nullptr)); |
| 897 ASSERT_TRUE(stream->AddTrack(audio_track)); | 896 ASSERT_TRUE(stream->AddTrack(audio_track)); |
| 898 } | 897 } |
| 899 | 898 |
| 900 void AddVideoTrack(const std::string& track_id, | 899 void AddVideoTrack(const std::string& track_id, |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 943 // Remove the first stream. | 942 // Remove the first stream. |
| 944 pc_->RemoveStream(pc_->local_streams()->at(0)); | 943 pc_->RemoveStream(pc_->local_streams()->at(0)); |
| 945 EXPECT_EQ(0u, pc_->local_streams()->count()); | 944 EXPECT_EQ(0u, pc_->local_streams()->count()); |
| 946 } | 945 } |
| 947 | 946 |
| 948 // Test that the created offer includes streams we added. | 947 // Test that the created offer includes streams we added. |
| 949 TEST_F(PeerConnectionInterfaceTest, AddedStreamsPresentInOffer) { | 948 TEST_F(PeerConnectionInterfaceTest, AddedStreamsPresentInOffer) { |
| 950 CreatePeerConnection(); | 949 CreatePeerConnection(); |
| 951 AddAudioVideoStream(kStreamLabel1, "audio_track", "video_track"); | 950 AddAudioVideoStream(kStreamLabel1, "audio_track", "video_track"); |
| 952 scoped_ptr<SessionDescriptionInterface> offer; | 951 scoped_ptr<SessionDescriptionInterface> offer; |
| 953 ASSERT_TRUE(DoCreateOffer(offer.accept(), nullptr)); | 952 ASSERT_TRUE(DoCreateOffer(&offer, nullptr)); |
| 954 | 953 |
| 955 const cricket::ContentInfo* audio_content = | 954 const cricket::ContentInfo* audio_content = |
| 956 cricket::GetFirstAudioContent(offer->description()); | 955 cricket::GetFirstAudioContent(offer->description()); |
| 957 const cricket::AudioContentDescription* audio_desc = | 956 const cricket::AudioContentDescription* audio_desc = |
| 958 static_cast<const cricket::AudioContentDescription*>( | 957 static_cast<const cricket::AudioContentDescription*>( |
| 959 audio_content->description); | 958 audio_content->description); |
| 960 EXPECT_TRUE( | 959 EXPECT_TRUE( |
| 961 ContainsTrack(audio_desc->streams(), kStreamLabel1, "audio_track")); | 960 ContainsTrack(audio_desc->streams(), kStreamLabel1, "audio_track")); |
| 962 | 961 |
| 963 const cricket::ContentInfo* video_content = | 962 const cricket::ContentInfo* video_content = |
| 964 cricket::GetFirstVideoContent(offer->description()); | 963 cricket::GetFirstVideoContent(offer->description()); |
| 965 const cricket::VideoContentDescription* video_desc = | 964 const cricket::VideoContentDescription* video_desc = |
| 966 static_cast<const cricket::VideoContentDescription*>( | 965 static_cast<const cricket::VideoContentDescription*>( |
| 967 video_content->description); | 966 video_content->description); |
| 968 EXPECT_TRUE( | 967 EXPECT_TRUE( |
| 969 ContainsTrack(video_desc->streams(), kStreamLabel1, "video_track")); | 968 ContainsTrack(video_desc->streams(), kStreamLabel1, "video_track")); |
| 970 | 969 |
| 971 // Add another stream and ensure the offer includes both the old and new | 970 // Add another stream and ensure the offer includes both the old and new |
| 972 // streams. | 971 // streams. |
| 973 AddAudioVideoStream(kStreamLabel2, "audio_track2", "video_track2"); | 972 AddAudioVideoStream(kStreamLabel2, "audio_track2", "video_track2"); |
| 974 ASSERT_TRUE(DoCreateOffer(offer.accept(), nullptr)); | 973 ASSERT_TRUE(DoCreateOffer(&offer, nullptr)); |
| 975 | 974 |
| 976 audio_content = cricket::GetFirstAudioContent(offer->description()); | 975 audio_content = cricket::GetFirstAudioContent(offer->description()); |
| 977 audio_desc = static_cast<const cricket::AudioContentDescription*>( | 976 audio_desc = static_cast<const cricket::AudioContentDescription*>( |
| 978 audio_content->description); | 977 audio_content->description); |
| 979 EXPECT_TRUE( | 978 EXPECT_TRUE( |
| 980 ContainsTrack(audio_desc->streams(), kStreamLabel1, "audio_track")); | 979 ContainsTrack(audio_desc->streams(), kStreamLabel1, "audio_track")); |
| 981 EXPECT_TRUE( | 980 EXPECT_TRUE( |
| 982 ContainsTrack(audio_desc->streams(), kStreamLabel2, "audio_track2")); | 981 ContainsTrack(audio_desc->streams(), kStreamLabel2, "audio_track2")); |
| 983 | 982 |
| 984 video_content = cricket::GetFirstVideoContent(offer->description()); | 983 video_content = cricket::GetFirstVideoContent(offer->description()); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1017 auto video_sender = pc_->AddTrack(video_track, stream_list); | 1016 auto video_sender = pc_->AddTrack(video_track, stream_list); |
| 1018 EXPECT_EQ(kStreamLabel1, audio_sender->stream_id()); | 1017 EXPECT_EQ(kStreamLabel1, audio_sender->stream_id()); |
| 1019 EXPECT_EQ("audio_track", audio_sender->id()); | 1018 EXPECT_EQ("audio_track", audio_sender->id()); |
| 1020 EXPECT_EQ(audio_track, audio_sender->track()); | 1019 EXPECT_EQ(audio_track, audio_sender->track()); |
| 1021 EXPECT_EQ(kStreamLabel1, video_sender->stream_id()); | 1020 EXPECT_EQ(kStreamLabel1, video_sender->stream_id()); |
| 1022 EXPECT_EQ("video_track", video_sender->id()); | 1021 EXPECT_EQ("video_track", video_sender->id()); |
| 1023 EXPECT_EQ(video_track, video_sender->track()); | 1022 EXPECT_EQ(video_track, video_sender->track()); |
| 1024 | 1023 |
| 1025 // Now create an offer and check for the senders. | 1024 // Now create an offer and check for the senders. |
| 1026 scoped_ptr<SessionDescriptionInterface> offer; | 1025 scoped_ptr<SessionDescriptionInterface> offer; |
| 1027 ASSERT_TRUE(DoCreateOffer(offer.accept(), nullptr)); | 1026 ASSERT_TRUE(DoCreateOffer(&offer, nullptr)); |
| 1028 | 1027 |
| 1029 const cricket::ContentInfo* audio_content = | 1028 const cricket::ContentInfo* audio_content = |
| 1030 cricket::GetFirstAudioContent(offer->description()); | 1029 cricket::GetFirstAudioContent(offer->description()); |
| 1031 const cricket::AudioContentDescription* audio_desc = | 1030 const cricket::AudioContentDescription* audio_desc = |
| 1032 static_cast<const cricket::AudioContentDescription*>( | 1031 static_cast<const cricket::AudioContentDescription*>( |
| 1033 audio_content->description); | 1032 audio_content->description); |
| 1034 EXPECT_TRUE( | 1033 EXPECT_TRUE( |
| 1035 ContainsTrack(audio_desc->streams(), kStreamLabel1, "audio_track")); | 1034 ContainsTrack(audio_desc->streams(), kStreamLabel1, "audio_track")); |
| 1036 | 1035 |
| 1037 const cricket::ContentInfo* video_content = | 1036 const cricket::ContentInfo* video_content = |
| 1038 cricket::GetFirstVideoContent(offer->description()); | 1037 cricket::GetFirstVideoContent(offer->description()); |
| 1039 const cricket::VideoContentDescription* video_desc = | 1038 const cricket::VideoContentDescription* video_desc = |
| 1040 static_cast<const cricket::VideoContentDescription*>( | 1039 static_cast<const cricket::VideoContentDescription*>( |
| 1041 video_content->description); | 1040 video_content->description); |
| 1042 EXPECT_TRUE( | 1041 EXPECT_TRUE( |
| 1043 ContainsTrack(video_desc->streams(), kStreamLabel1, "video_track")); | 1042 ContainsTrack(video_desc->streams(), kStreamLabel1, "video_track")); |
| 1044 | 1043 |
| 1045 EXPECT_TRUE(DoSetLocalDescription(offer.release())); | 1044 EXPECT_TRUE(DoSetLocalDescription(offer.release())); |
| 1046 | 1045 |
| 1047 // Now try removing the tracks. | 1046 // Now try removing the tracks. |
| 1048 EXPECT_TRUE(pc_->RemoveTrack(audio_sender)); | 1047 EXPECT_TRUE(pc_->RemoveTrack(audio_sender)); |
| 1049 EXPECT_TRUE(pc_->RemoveTrack(video_sender)); | 1048 EXPECT_TRUE(pc_->RemoveTrack(video_sender)); |
| 1050 | 1049 |
| 1051 // Create a new offer and ensure it doesn't contain the removed senders. | 1050 // Create a new offer and ensure it doesn't contain the removed senders. |
| 1052 ASSERT_TRUE(DoCreateOffer(offer.accept(), nullptr)); | 1051 ASSERT_TRUE(DoCreateOffer(&offer, nullptr)); |
| 1053 | 1052 |
| 1054 audio_content = cricket::GetFirstAudioContent(offer->description()); | 1053 audio_content = cricket::GetFirstAudioContent(offer->description()); |
| 1055 audio_desc = static_cast<const cricket::AudioContentDescription*>( | 1054 audio_desc = static_cast<const cricket::AudioContentDescription*>( |
| 1056 audio_content->description); | 1055 audio_content->description); |
| 1057 EXPECT_FALSE( | 1056 EXPECT_FALSE( |
| 1058 ContainsTrack(audio_desc->streams(), kStreamLabel1, "audio_track")); | 1057 ContainsTrack(audio_desc->streams(), kStreamLabel1, "audio_track")); |
| 1059 | 1058 |
| 1060 video_content = cricket::GetFirstVideoContent(offer->description()); | 1059 video_content = cricket::GetFirstVideoContent(offer->description()); |
| 1061 video_desc = static_cast<const cricket::VideoContentDescription*>( | 1060 video_desc = static_cast<const cricket::VideoContentDescription*>( |
| 1062 video_content->description); | 1061 video_content->description); |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1153 CreateOfferReceiveAnswer(); | 1152 CreateOfferReceiveAnswer(); |
| 1154 EXPECT_EQ(0u, pc_->remote_streams()->count()); | 1153 EXPECT_EQ(0u, pc_->remote_streams()->count()); |
| 1155 } | 1154 } |
| 1156 | 1155 |
| 1157 // Test that candidates are generated and that we can parse our own candidates. | 1156 // Test that candidates are generated and that we can parse our own candidates. |
| 1158 TEST_F(PeerConnectionInterfaceTest, IceCandidates) { | 1157 TEST_F(PeerConnectionInterfaceTest, IceCandidates) { |
| 1159 CreatePeerConnection(); | 1158 CreatePeerConnection(); |
| 1160 | 1159 |
| 1161 EXPECT_FALSE(pc_->AddIceCandidate(observer_.last_candidate_.get())); | 1160 EXPECT_FALSE(pc_->AddIceCandidate(observer_.last_candidate_.get())); |
| 1162 // SetRemoteDescription takes ownership of offer. | 1161 // SetRemoteDescription takes ownership of offer. |
| 1163 SessionDescriptionInterface* offer = NULL; | 1162 rtc::scoped_ptr<SessionDescriptionInterface> offer; |
| 1164 AddVideoStream(kStreamLabel1); | 1163 AddVideoStream(kStreamLabel1); |
| 1165 EXPECT_TRUE(DoCreateOffer(&offer, nullptr)); | 1164 EXPECT_TRUE(DoCreateOffer(&offer, nullptr)); |
| 1166 EXPECT_TRUE(DoSetRemoteDescription(offer)); | 1165 EXPECT_TRUE(DoSetRemoteDescription(offer.release())); |
| 1167 | 1166 |
| 1168 // SetLocalDescription takes ownership of answer. | 1167 // SetLocalDescription takes ownership of answer. |
| 1169 SessionDescriptionInterface* answer = NULL; | 1168 rtc::scoped_ptr<SessionDescriptionInterface> answer; |
| 1170 EXPECT_TRUE(DoCreateAnswer(&answer, nullptr)); | 1169 EXPECT_TRUE(DoCreateAnswer(&answer, nullptr)); |
| 1171 EXPECT_TRUE(DoSetLocalDescription(answer)); | 1170 EXPECT_TRUE(DoSetLocalDescription(answer.release())); |
| 1172 | 1171 |
| 1173 EXPECT_TRUE_WAIT(observer_.last_candidate_.get() != NULL, kTimeout); | 1172 EXPECT_TRUE_WAIT(observer_.last_candidate_.get() != NULL, kTimeout); |
| 1174 EXPECT_TRUE_WAIT(observer_.ice_complete_, kTimeout); | 1173 EXPECT_TRUE_WAIT(observer_.ice_complete_, kTimeout); |
| 1175 | 1174 |
| 1176 EXPECT_TRUE(pc_->AddIceCandidate(observer_.last_candidate_.get())); | 1175 EXPECT_TRUE(pc_->AddIceCandidate(observer_.last_candidate_.get())); |
| 1177 } | 1176 } |
| 1178 | 1177 |
| 1179 // Test that CreateOffer and CreateAnswer will fail if the track labels are | 1178 // Test that CreateOffer and CreateAnswer will fail if the track labels are |
| 1180 // not unique. | 1179 // not unique. |
| 1181 TEST_F(PeerConnectionInterfaceTest, CreateOfferAnswerWithInvalidStream) { | 1180 TEST_F(PeerConnectionInterfaceTest, CreateOfferAnswerWithInvalidStream) { |
| 1182 CreatePeerConnection(); | 1181 CreatePeerConnection(); |
| 1183 // Create a regular offer for the CreateAnswer test later. | 1182 // Create a regular offer for the CreateAnswer test later. |
| 1184 SessionDescriptionInterface* offer = NULL; | 1183 rtc::scoped_ptr<SessionDescriptionInterface> offer; |
| 1185 EXPECT_TRUE(DoCreateOffer(&offer, nullptr)); | 1184 EXPECT_TRUE(DoCreateOffer(&offer, nullptr)); |
| 1186 EXPECT_TRUE(offer != NULL); | 1185 EXPECT_TRUE(offer); |
| 1187 delete offer; | 1186 offer.reset(); |
| 1188 offer = NULL; | |
| 1189 | 1187 |
| 1190 // Create a local stream with audio&video tracks having same label. | 1188 // Create a local stream with audio&video tracks having same label. |
| 1191 AddAudioVideoStream(kStreamLabel1, "track_label", "track_label"); | 1189 AddAudioVideoStream(kStreamLabel1, "track_label", "track_label"); |
| 1192 | 1190 |
| 1193 // Test CreateOffer | 1191 // Test CreateOffer |
| 1194 EXPECT_FALSE(DoCreateOffer(&offer, nullptr)); | 1192 EXPECT_FALSE(DoCreateOffer(&offer, nullptr)); |
| 1195 | 1193 |
| 1196 // Test CreateAnswer | 1194 // Test CreateAnswer |
| 1197 SessionDescriptionInterface* answer = NULL; | 1195 rtc::scoped_ptr<SessionDescriptionInterface> answer; |
| 1198 EXPECT_FALSE(DoCreateAnswer(&answer, nullptr)); | 1196 EXPECT_FALSE(DoCreateAnswer(&answer, nullptr)); |
| 1199 } | 1197 } |
| 1200 | 1198 |
| 1201 // Test that we will get different SSRCs for each tracks in the offer and answer | 1199 // Test that we will get different SSRCs for each tracks in the offer and answer |
| 1202 // we created. | 1200 // we created. |
| 1203 TEST_F(PeerConnectionInterfaceTest, SsrcInOfferAnswer) { | 1201 TEST_F(PeerConnectionInterfaceTest, SsrcInOfferAnswer) { |
| 1204 CreatePeerConnection(); | 1202 CreatePeerConnection(); |
| 1205 // Create a local stream with audio&video tracks having different labels. | 1203 // Create a local stream with audio&video tracks having different labels. |
| 1206 AddAudioVideoStream(kStreamLabel1, "audio_label", "video_label"); | 1204 AddAudioVideoStream(kStreamLabel1, "audio_label", "video_label"); |
| 1207 | 1205 |
| 1208 // Test CreateOffer | 1206 // Test CreateOffer |
| 1209 scoped_ptr<SessionDescriptionInterface> offer; | 1207 scoped_ptr<SessionDescriptionInterface> offer; |
| 1210 ASSERT_TRUE(DoCreateOffer(offer.use(), nullptr)); | 1208 ASSERT_TRUE(DoCreateOffer(&offer, nullptr)); |
| 1211 int audio_ssrc = 0; | 1209 int audio_ssrc = 0; |
| 1212 int video_ssrc = 0; | 1210 int video_ssrc = 0; |
| 1213 EXPECT_TRUE(GetFirstSsrc(GetFirstAudioContent(offer->description()), | 1211 EXPECT_TRUE(GetFirstSsrc(GetFirstAudioContent(offer->description()), |
| 1214 &audio_ssrc)); | 1212 &audio_ssrc)); |
| 1215 EXPECT_TRUE(GetFirstSsrc(GetFirstVideoContent(offer->description()), | 1213 EXPECT_TRUE(GetFirstSsrc(GetFirstVideoContent(offer->description()), |
| 1216 &video_ssrc)); | 1214 &video_ssrc)); |
| 1217 EXPECT_NE(audio_ssrc, video_ssrc); | 1215 EXPECT_NE(audio_ssrc, video_ssrc); |
| 1218 | 1216 |
| 1219 // Test CreateAnswer | 1217 // Test CreateAnswer |
| 1220 EXPECT_TRUE(DoSetRemoteDescription(offer.release())); | 1218 EXPECT_TRUE(DoSetRemoteDescription(offer.release())); |
| 1221 scoped_ptr<SessionDescriptionInterface> answer; | 1219 scoped_ptr<SessionDescriptionInterface> answer; |
| 1222 ASSERT_TRUE(DoCreateAnswer(answer.use(), nullptr)); | 1220 ASSERT_TRUE(DoCreateAnswer(&answer, nullptr)); |
| 1223 audio_ssrc = 0; | 1221 audio_ssrc = 0; |
| 1224 video_ssrc = 0; | 1222 video_ssrc = 0; |
| 1225 EXPECT_TRUE(GetFirstSsrc(GetFirstAudioContent(answer->description()), | 1223 EXPECT_TRUE(GetFirstSsrc(GetFirstAudioContent(answer->description()), |
| 1226 &audio_ssrc)); | 1224 &audio_ssrc)); |
| 1227 EXPECT_TRUE(GetFirstSsrc(GetFirstVideoContent(answer->description()), | 1225 EXPECT_TRUE(GetFirstSsrc(GetFirstVideoContent(answer->description()), |
| 1228 &video_ssrc)); | 1226 &video_ssrc)); |
| 1229 EXPECT_NE(audio_ssrc, video_ssrc); | 1227 EXPECT_NE(audio_ssrc, video_ssrc); |
| 1230 } | 1228 } |
| 1231 | 1229 |
| 1232 // Test that it's possible to call AddTrack on a MediaStream after adding | 1230 // Test that it's possible to call AddTrack on a MediaStream after adding |
| 1233 // the stream to a PeerConnection. | 1231 // the stream to a PeerConnection. |
| 1234 // TODO(deadbeef): Remove this test once this behavior is no longer supported. | 1232 // TODO(deadbeef): Remove this test once this behavior is no longer supported. |
| 1235 TEST_F(PeerConnectionInterfaceTest, AddTrackAfterAddStream) { | 1233 TEST_F(PeerConnectionInterfaceTest, AddTrackAfterAddStream) { |
| 1236 CreatePeerConnection(); | 1234 CreatePeerConnection(); |
| 1237 // Create audio stream and add to PeerConnection. | 1235 // Create audio stream and add to PeerConnection. |
| 1238 AddVoiceStream(kStreamLabel1); | 1236 AddVoiceStream(kStreamLabel1); |
| 1239 MediaStreamInterface* stream = pc_->local_streams()->at(0); | 1237 MediaStreamInterface* stream = pc_->local_streams()->at(0); |
| 1240 | 1238 |
| 1241 // Add video track to the audio-only stream. | 1239 // Add video track to the audio-only stream. |
| 1242 scoped_refptr<VideoTrackInterface> video_track( | 1240 scoped_refptr<VideoTrackInterface> video_track( |
| 1243 pc_factory_->CreateVideoTrack("video_label", nullptr)); | 1241 pc_factory_->CreateVideoTrack("video_label", nullptr)); |
| 1244 stream->AddTrack(video_track.get()); | 1242 stream->AddTrack(video_track.get()); |
| 1245 | 1243 |
| 1246 scoped_ptr<SessionDescriptionInterface> offer; | 1244 scoped_ptr<SessionDescriptionInterface> offer; |
| 1247 ASSERT_TRUE(DoCreateOffer(offer.use(), nullptr)); | 1245 ASSERT_TRUE(DoCreateOffer(&offer, nullptr)); |
| 1248 | 1246 |
| 1249 const cricket::MediaContentDescription* video_desc = | 1247 const cricket::MediaContentDescription* video_desc = |
| 1250 cricket::GetFirstVideoContentDescription(offer->description()); | 1248 cricket::GetFirstVideoContentDescription(offer->description()); |
| 1251 EXPECT_TRUE(video_desc != nullptr); | 1249 EXPECT_TRUE(video_desc != nullptr); |
| 1252 } | 1250 } |
| 1253 | 1251 |
| 1254 // Test that it's possible to call RemoveTrack on a MediaStream after adding | 1252 // Test that it's possible to call RemoveTrack on a MediaStream after adding |
| 1255 // the stream to a PeerConnection. | 1253 // the stream to a PeerConnection. |
| 1256 // TODO(deadbeef): Remove this test once this behavior is no longer supported. | 1254 // TODO(deadbeef): Remove this test once this behavior is no longer supported. |
| 1257 TEST_F(PeerConnectionInterfaceTest, RemoveTrackAfterAddStream) { | 1255 TEST_F(PeerConnectionInterfaceTest, RemoveTrackAfterAddStream) { |
| 1258 CreatePeerConnection(); | 1256 CreatePeerConnection(); |
| 1259 // Create audio/video stream and add to PeerConnection. | 1257 // Create audio/video stream and add to PeerConnection. |
| 1260 AddAudioVideoStream(kStreamLabel1, "audio_label", "video_label"); | 1258 AddAudioVideoStream(kStreamLabel1, "audio_label", "video_label"); |
| 1261 MediaStreamInterface* stream = pc_->local_streams()->at(0); | 1259 MediaStreamInterface* stream = pc_->local_streams()->at(0); |
| 1262 | 1260 |
| 1263 // Remove the video track. | 1261 // Remove the video track. |
| 1264 stream->RemoveTrack(stream->GetVideoTracks()[0]); | 1262 stream->RemoveTrack(stream->GetVideoTracks()[0]); |
| 1265 | 1263 |
| 1266 scoped_ptr<SessionDescriptionInterface> offer; | 1264 scoped_ptr<SessionDescriptionInterface> offer; |
| 1267 ASSERT_TRUE(DoCreateOffer(offer.use(), nullptr)); | 1265 ASSERT_TRUE(DoCreateOffer(&offer, nullptr)); |
| 1268 | 1266 |
| 1269 const cricket::MediaContentDescription* video_desc = | 1267 const cricket::MediaContentDescription* video_desc = |
| 1270 cricket::GetFirstVideoContentDescription(offer->description()); | 1268 cricket::GetFirstVideoContentDescription(offer->description()); |
| 1271 EXPECT_TRUE(video_desc == nullptr); | 1269 EXPECT_TRUE(video_desc == nullptr); |
| 1272 } | 1270 } |
| 1273 | 1271 |
| 1274 // Test creating a sender with a stream ID, and ensure the ID is populated | 1272 // Test creating a sender with a stream ID, and ensure the ID is populated |
| 1275 // in the offer. | 1273 // in the offer. |
| 1276 TEST_F(PeerConnectionInterfaceTest, CreateSenderWithStream) { | 1274 TEST_F(PeerConnectionInterfaceTest, CreateSenderWithStream) { |
| 1277 CreatePeerConnection(); | 1275 CreatePeerConnection(); |
| 1278 pc_->CreateSender("video", kStreamLabel1); | 1276 pc_->CreateSender("video", kStreamLabel1); |
| 1279 | 1277 |
| 1280 scoped_ptr<SessionDescriptionInterface> offer; | 1278 scoped_ptr<SessionDescriptionInterface> offer; |
| 1281 ASSERT_TRUE(DoCreateOffer(offer.use(), nullptr)); | 1279 ASSERT_TRUE(DoCreateOffer(&offer, nullptr)); |
| 1282 | 1280 |
| 1283 const cricket::MediaContentDescription* video_desc = | 1281 const cricket::MediaContentDescription* video_desc = |
| 1284 cricket::GetFirstVideoContentDescription(offer->description()); | 1282 cricket::GetFirstVideoContentDescription(offer->description()); |
| 1285 ASSERT_TRUE(video_desc != nullptr); | 1283 ASSERT_TRUE(video_desc != nullptr); |
| 1286 ASSERT_EQ(1u, video_desc->streams().size()); | 1284 ASSERT_EQ(1u, video_desc->streams().size()); |
| 1287 EXPECT_EQ(kStreamLabel1, video_desc->streams()[0].sync_label); | 1285 EXPECT_EQ(kStreamLabel1, video_desc->streams()[0].sync_label); |
| 1288 } | 1286 } |
| 1289 | 1287 |
| 1290 // Test that we can specify a certain track that we want statistics about. | 1288 // Test that we can specify a certain track that we want statistics about. |
| 1291 TEST_F(PeerConnectionInterfaceTest, GetStatsForSpecificTrack) { | 1289 TEST_F(PeerConnectionInterfaceTest, GetStatsForSpecificTrack) { |
| (...skipping 437 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1729 TEST_F(PeerConnectionInterfaceTest, CreateSubsequentRecvOnlyOffer) { | 1727 TEST_F(PeerConnectionInterfaceTest, CreateSubsequentRecvOnlyOffer) { |
| 1730 FakeConstraints constraints; | 1728 FakeConstraints constraints; |
| 1731 constraints.AddMandatory(webrtc::MediaConstraintsInterface::kEnableDtlsSrtp, | 1729 constraints.AddMandatory(webrtc::MediaConstraintsInterface::kEnableDtlsSrtp, |
| 1732 true); | 1730 true); |
| 1733 CreatePeerConnection(&constraints); | 1731 CreatePeerConnection(&constraints); |
| 1734 CreateAndSetRemoteOffer(kSdpStringWithStream1); | 1732 CreateAndSetRemoteOffer(kSdpStringWithStream1); |
| 1735 CreateAnswerAsLocalDescription(); | 1733 CreateAnswerAsLocalDescription(); |
| 1736 | 1734 |
| 1737 // At this point we should be receiving stream 1, but not sending anything. | 1735 // At this point we should be receiving stream 1, but not sending anything. |
| 1738 // A new offer should be recvonly. | 1736 // A new offer should be recvonly. |
| 1739 SessionDescriptionInterface* offer; | 1737 rtc::scoped_ptr<SessionDescriptionInterface> offer; |
| 1740 DoCreateOffer(&offer, nullptr); | 1738 DoCreateOffer(&offer, nullptr); |
| 1741 | 1739 |
| 1742 const cricket::ContentInfo* video_content = | 1740 const cricket::ContentInfo* video_content = |
| 1743 cricket::GetFirstVideoContent(offer->description()); | 1741 cricket::GetFirstVideoContent(offer->description()); |
| 1744 const cricket::VideoContentDescription* video_desc = | 1742 const cricket::VideoContentDescription* video_desc = |
| 1745 static_cast<const cricket::VideoContentDescription*>( | 1743 static_cast<const cricket::VideoContentDescription*>( |
| 1746 video_content->description); | 1744 video_content->description); |
| 1747 ASSERT_EQ(cricket::MD_RECVONLY, video_desc->direction()); | 1745 ASSERT_EQ(cricket::MD_RECVONLY, video_desc->direction()); |
| 1748 | 1746 |
| 1749 const cricket::ContentInfo* audio_content = | 1747 const cricket::ContentInfo* audio_content = |
| (...skipping 11 matching lines...) Expand all Loading... |
| 1761 FakeConstraints constraints; | 1759 FakeConstraints constraints; |
| 1762 constraints.AddMandatory(webrtc::MediaConstraintsInterface::kEnableDtlsSrtp, | 1760 constraints.AddMandatory(webrtc::MediaConstraintsInterface::kEnableDtlsSrtp, |
| 1763 true); | 1761 true); |
| 1764 CreatePeerConnection(&constraints); | 1762 CreatePeerConnection(&constraints); |
| 1765 CreateAndSetRemoteOffer(kSdpStringWithStream1); | 1763 CreateAndSetRemoteOffer(kSdpStringWithStream1); |
| 1766 CreateAnswerAsLocalDescription(); | 1764 CreateAnswerAsLocalDescription(); |
| 1767 | 1765 |
| 1768 // At this point we should be receiving stream 1, but not sending anything. | 1766 // At this point we should be receiving stream 1, but not sending anything. |
| 1769 // A new offer would be recvonly, but we'll set the "no receive" constraints | 1767 // A new offer would be recvonly, but we'll set the "no receive" constraints |
| 1770 // to make it inactive. | 1768 // to make it inactive. |
| 1771 SessionDescriptionInterface* offer; | 1769 rtc::scoped_ptr<SessionDescriptionInterface> offer; |
| 1772 FakeConstraints offer_constraints; | 1770 FakeConstraints offer_constraints; |
| 1773 offer_constraints.AddMandatory( | 1771 offer_constraints.AddMandatory( |
| 1774 webrtc::MediaConstraintsInterface::kOfferToReceiveVideo, false); | 1772 webrtc::MediaConstraintsInterface::kOfferToReceiveVideo, false); |
| 1775 offer_constraints.AddMandatory( | 1773 offer_constraints.AddMandatory( |
| 1776 webrtc::MediaConstraintsInterface::kOfferToReceiveAudio, false); | 1774 webrtc::MediaConstraintsInterface::kOfferToReceiveAudio, false); |
| 1777 DoCreateOffer(&offer, &offer_constraints); | 1775 DoCreateOffer(&offer, &offer_constraints); |
| 1778 | 1776 |
| 1779 const cricket::ContentInfo* video_content = | 1777 const cricket::ContentInfo* video_content = |
| 1780 cricket::GetFirstVideoContent(offer->description()); | 1778 cricket::GetFirstVideoContent(offer->description()); |
| 1781 const cricket::VideoContentDescription* video_desc = | 1779 const cricket::VideoContentDescription* video_desc = |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1856 rtc::scoped_refptr<webrtc::DtmfSenderInterface> dtmf_sender( | 1854 rtc::scoped_refptr<webrtc::DtmfSenderInterface> dtmf_sender( |
| 1857 pc_->CreateDtmfSender(local_stream->GetAudioTracks()[0])); | 1855 pc_->CreateDtmfSender(local_stream->GetAudioTracks()[0])); |
| 1858 EXPECT_TRUE(NULL == dtmf_sender); // local stream has been removed. | 1856 EXPECT_TRUE(NULL == dtmf_sender); // local stream has been removed. |
| 1859 | 1857 |
| 1860 EXPECT_TRUE(pc_->CreateDataChannel("test", NULL) == NULL); | 1858 EXPECT_TRUE(pc_->CreateDataChannel("test", NULL) == NULL); |
| 1861 | 1859 |
| 1862 EXPECT_TRUE(pc_->local_description() != NULL); | 1860 EXPECT_TRUE(pc_->local_description() != NULL); |
| 1863 EXPECT_TRUE(pc_->remote_description() != NULL); | 1861 EXPECT_TRUE(pc_->remote_description() != NULL); |
| 1864 | 1862 |
| 1865 rtc::scoped_ptr<SessionDescriptionInterface> offer; | 1863 rtc::scoped_ptr<SessionDescriptionInterface> offer; |
| 1866 EXPECT_TRUE(DoCreateOffer(offer.use(), nullptr)); | 1864 EXPECT_TRUE(DoCreateOffer(&offer, nullptr)); |
| 1867 rtc::scoped_ptr<SessionDescriptionInterface> answer; | 1865 rtc::scoped_ptr<SessionDescriptionInterface> answer; |
| 1868 EXPECT_TRUE(DoCreateAnswer(answer.use(), nullptr)); | 1866 EXPECT_TRUE(DoCreateAnswer(&answer, nullptr)); |
| 1869 | 1867 |
| 1870 std::string sdp; | 1868 std::string sdp; |
| 1871 ASSERT_TRUE(pc_->remote_description()->ToString(&sdp)); | 1869 ASSERT_TRUE(pc_->remote_description()->ToString(&sdp)); |
| 1872 SessionDescriptionInterface* remote_offer = | 1870 SessionDescriptionInterface* remote_offer = |
| 1873 webrtc::CreateSessionDescription(SessionDescriptionInterface::kOffer, | 1871 webrtc::CreateSessionDescription(SessionDescriptionInterface::kOffer, |
| 1874 sdp, NULL); | 1872 sdp, NULL); |
| 1875 EXPECT_FALSE(DoSetRemoteDescription(remote_offer)); | 1873 EXPECT_FALSE(DoSetRemoteDescription(remote_offer)); |
| 1876 | 1874 |
| 1877 ASSERT_TRUE(pc_->local_description()->ToString(&sdp)); | 1875 ASSERT_TRUE(pc_->local_description()->ToString(&sdp)); |
| 1878 SessionDescriptionInterface* local_offer = | 1876 SessionDescriptionInterface* local_offer = |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1918 } | 1916 } |
| 1919 | 1917 |
| 1920 // This test verifies that when remote tracks are added/removed from SDP, the | 1918 // This test verifies that when remote tracks are added/removed from SDP, the |
| 1921 // created remote streams are updated appropriately. | 1919 // created remote streams are updated appropriately. |
| 1922 TEST_F(PeerConnectionInterfaceTest, | 1920 TEST_F(PeerConnectionInterfaceTest, |
| 1923 AddRemoveTrackFromExistingRemoteMediaStream) { | 1921 AddRemoveTrackFromExistingRemoteMediaStream) { |
| 1924 FakeConstraints constraints; | 1922 FakeConstraints constraints; |
| 1925 constraints.AddMandatory(webrtc::MediaConstraintsInterface::kEnableDtlsSrtp, | 1923 constraints.AddMandatory(webrtc::MediaConstraintsInterface::kEnableDtlsSrtp, |
| 1926 true); | 1924 true); |
| 1927 CreatePeerConnection(&constraints); | 1925 CreatePeerConnection(&constraints); |
| 1928 rtc::scoped_ptr<SessionDescriptionInterface> desc_ms1; | 1926 rtc::scoped_ptr<SessionDescriptionInterface> desc_ms1 = |
| 1929 CreateSessionDescriptionAndReference(1, 1, desc_ms1.accept()); | 1927 CreateSessionDescriptionAndReference(1, 1); |
| 1930 EXPECT_TRUE(DoSetRemoteDescription(desc_ms1.release())); | 1928 EXPECT_TRUE(DoSetRemoteDescription(desc_ms1.release())); |
| 1931 EXPECT_TRUE(CompareStreamCollections(observer_.remote_streams(), | 1929 EXPECT_TRUE(CompareStreamCollections(observer_.remote_streams(), |
| 1932 reference_collection_)); | 1930 reference_collection_)); |
| 1933 | 1931 |
| 1934 // Add extra audio and video tracks to the same MediaStream. | 1932 // Add extra audio and video tracks to the same MediaStream. |
| 1935 rtc::scoped_ptr<SessionDescriptionInterface> desc_ms1_two_tracks; | 1933 rtc::scoped_ptr<SessionDescriptionInterface> desc_ms1_two_tracks = |
| 1936 CreateSessionDescriptionAndReference(2, 2, desc_ms1_two_tracks.accept()); | 1934 CreateSessionDescriptionAndReference(2, 2); |
| 1937 EXPECT_TRUE(DoSetRemoteDescription(desc_ms1_two_tracks.release())); | 1935 EXPECT_TRUE(DoSetRemoteDescription(desc_ms1_two_tracks.release())); |
| 1938 EXPECT_TRUE(CompareStreamCollections(observer_.remote_streams(), | 1936 EXPECT_TRUE(CompareStreamCollections(observer_.remote_streams(), |
| 1939 reference_collection_)); | 1937 reference_collection_)); |
| 1940 | 1938 |
| 1941 // Remove the extra audio and video tracks. | 1939 // Remove the extra audio and video tracks. |
| 1942 rtc::scoped_ptr<SessionDescriptionInterface> desc_ms2; | 1940 rtc::scoped_ptr<SessionDescriptionInterface> desc_ms2 = |
| 1943 CreateSessionDescriptionAndReference(1, 1, desc_ms2.accept()); | 1941 CreateSessionDescriptionAndReference(1, 1); |
| 1944 EXPECT_TRUE(DoSetRemoteDescription(desc_ms2.release())); | 1942 EXPECT_TRUE(DoSetRemoteDescription(desc_ms2.release())); |
| 1945 EXPECT_TRUE(CompareStreamCollections(observer_.remote_streams(), | 1943 EXPECT_TRUE(CompareStreamCollections(observer_.remote_streams(), |
| 1946 reference_collection_)); | 1944 reference_collection_)); |
| 1947 } | 1945 } |
| 1948 | 1946 |
| 1949 // This tests that remote tracks are ended if a local session description is set | 1947 // This tests that remote tracks are ended if a local session description is set |
| 1950 // that rejects the media content type. | 1948 // that rejects the media content type. |
| 1951 TEST_F(PeerConnectionInterfaceTest, RejectMediaContent) { | 1949 TEST_F(PeerConnectionInterfaceTest, RejectMediaContent) { |
| 1952 FakeConstraints constraints; | 1950 FakeConstraints constraints; |
| 1953 constraints.AddMandatory(webrtc::MediaConstraintsInterface::kEnableDtlsSrtp, | 1951 constraints.AddMandatory(webrtc::MediaConstraintsInterface::kEnableDtlsSrtp, |
| 1954 true); | 1952 true); |
| 1955 CreatePeerConnection(&constraints); | 1953 CreatePeerConnection(&constraints); |
| 1956 // First create and set a remote offer, then reject its video content in our | 1954 // First create and set a remote offer, then reject its video content in our |
| 1957 // answer. | 1955 // answer. |
| 1958 CreateAndSetRemoteOffer(kSdpStringWithStream1); | 1956 CreateAndSetRemoteOffer(kSdpStringWithStream1); |
| 1959 ASSERT_EQ(1u, observer_.remote_streams()->count()); | 1957 ASSERT_EQ(1u, observer_.remote_streams()->count()); |
| 1960 MediaStreamInterface* remote_stream = observer_.remote_streams()->at(0); | 1958 MediaStreamInterface* remote_stream = observer_.remote_streams()->at(0); |
| 1961 ASSERT_EQ(1u, remote_stream->GetVideoTracks().size()); | 1959 ASSERT_EQ(1u, remote_stream->GetVideoTracks().size()); |
| 1962 ASSERT_EQ(1u, remote_stream->GetAudioTracks().size()); | 1960 ASSERT_EQ(1u, remote_stream->GetAudioTracks().size()); |
| 1963 | 1961 |
| 1964 rtc::scoped_refptr<webrtc::VideoTrackInterface> remote_video = | 1962 rtc::scoped_refptr<webrtc::VideoTrackInterface> remote_video = |
| 1965 remote_stream->GetVideoTracks()[0]; | 1963 remote_stream->GetVideoTracks()[0]; |
| 1966 EXPECT_EQ(webrtc::MediaStreamTrackInterface::kLive, remote_video->state()); | 1964 EXPECT_EQ(webrtc::MediaStreamTrackInterface::kLive, remote_video->state()); |
| 1967 rtc::scoped_refptr<webrtc::AudioTrackInterface> remote_audio = | 1965 rtc::scoped_refptr<webrtc::AudioTrackInterface> remote_audio = |
| 1968 remote_stream->GetAudioTracks()[0]; | 1966 remote_stream->GetAudioTracks()[0]; |
| 1969 EXPECT_EQ(webrtc::MediaStreamTrackInterface::kLive, remote_audio->state()); | 1967 EXPECT_EQ(webrtc::MediaStreamTrackInterface::kLive, remote_audio->state()); |
| 1970 | 1968 |
| 1971 rtc::scoped_ptr<SessionDescriptionInterface> local_answer; | 1969 rtc::scoped_ptr<SessionDescriptionInterface> local_answer; |
| 1972 EXPECT_TRUE(DoCreateAnswer(local_answer.accept(), nullptr)); | 1970 EXPECT_TRUE(DoCreateAnswer(&local_answer, nullptr)); |
| 1973 cricket::ContentInfo* video_info = | 1971 cricket::ContentInfo* video_info = |
| 1974 local_answer->description()->GetContentByName("video"); | 1972 local_answer->description()->GetContentByName("video"); |
| 1975 video_info->rejected = true; | 1973 video_info->rejected = true; |
| 1976 EXPECT_TRUE(DoSetLocalDescription(local_answer.release())); | 1974 EXPECT_TRUE(DoSetLocalDescription(local_answer.release())); |
| 1977 EXPECT_EQ(webrtc::MediaStreamTrackInterface::kEnded, remote_video->state()); | 1975 EXPECT_EQ(webrtc::MediaStreamTrackInterface::kEnded, remote_video->state()); |
| 1978 EXPECT_EQ(webrtc::MediaStreamTrackInterface::kLive, remote_audio->state()); | 1976 EXPECT_EQ(webrtc::MediaStreamTrackInterface::kLive, remote_audio->state()); |
| 1979 | 1977 |
| 1980 // Now create an offer where we reject both video and audio. | 1978 // Now create an offer where we reject both video and audio. |
| 1981 rtc::scoped_ptr<SessionDescriptionInterface> local_offer; | 1979 rtc::scoped_ptr<SessionDescriptionInterface> local_offer; |
| 1982 EXPECT_TRUE(DoCreateOffer(local_offer.accept(), nullptr)); | 1980 EXPECT_TRUE(DoCreateOffer(&local_offer, nullptr)); |
| 1983 video_info = local_offer->description()->GetContentByName("video"); | 1981 video_info = local_offer->description()->GetContentByName("video"); |
| 1984 ASSERT_TRUE(video_info != nullptr); | 1982 ASSERT_TRUE(video_info != nullptr); |
| 1985 video_info->rejected = true; | 1983 video_info->rejected = true; |
| 1986 cricket::ContentInfo* audio_info = | 1984 cricket::ContentInfo* audio_info = |
| 1987 local_offer->description()->GetContentByName("audio"); | 1985 local_offer->description()->GetContentByName("audio"); |
| 1988 ASSERT_TRUE(audio_info != nullptr); | 1986 ASSERT_TRUE(audio_info != nullptr); |
| 1989 audio_info->rejected = true; | 1987 audio_info->rejected = true; |
| 1990 EXPECT_TRUE(DoSetLocalDescription(local_offer.release())); | 1988 EXPECT_TRUE(DoSetLocalDescription(local_offer.release())); |
| 1991 EXPECT_EQ(webrtc::MediaStreamTrackInterface::kEnded, remote_video->state()); | 1989 EXPECT_EQ(webrtc::MediaStreamTrackInterface::kEnded, remote_video->state()); |
| 1992 EXPECT_EQ(webrtc::MediaStreamTrackInterface::kEnded, remote_audio->state()); | 1990 EXPECT_EQ(webrtc::MediaStreamTrackInterface::kEnded, remote_audio->state()); |
| (...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2171 // TODO(deadbeef): This test and the one below it need to be updated when | 2169 // TODO(deadbeef): This test and the one below it need to be updated when |
| 2172 // an RtpSender's lifetime isn't determined by when a local description is set. | 2170 // an RtpSender's lifetime isn't determined by when a local description is set. |
| 2173 TEST_F(PeerConnectionInterfaceTest, LocalDescriptionChanged) { | 2171 TEST_F(PeerConnectionInterfaceTest, LocalDescriptionChanged) { |
| 2174 FakeConstraints constraints; | 2172 FakeConstraints constraints; |
| 2175 constraints.AddMandatory(webrtc::MediaConstraintsInterface::kEnableDtlsSrtp, | 2173 constraints.AddMandatory(webrtc::MediaConstraintsInterface::kEnableDtlsSrtp, |
| 2176 true); | 2174 true); |
| 2177 CreatePeerConnection(&constraints); | 2175 CreatePeerConnection(&constraints); |
| 2178 // Create an offer just to ensure we have an identity before we manually | 2176 // Create an offer just to ensure we have an identity before we manually |
| 2179 // call SetLocalDescription. | 2177 // call SetLocalDescription. |
| 2180 rtc::scoped_ptr<SessionDescriptionInterface> throwaway; | 2178 rtc::scoped_ptr<SessionDescriptionInterface> throwaway; |
| 2181 ASSERT_TRUE(DoCreateOffer(throwaway.accept(), nullptr)); | 2179 ASSERT_TRUE(DoCreateOffer(&throwaway, nullptr)); |
| 2182 | 2180 |
| 2183 rtc::scoped_ptr<SessionDescriptionInterface> desc_1; | 2181 rtc::scoped_ptr<SessionDescriptionInterface> desc_1 = |
| 2184 CreateSessionDescriptionAndReference(2, 2, desc_1.accept()); | 2182 CreateSessionDescriptionAndReference(2, 2); |
| 2185 | 2183 |
| 2186 pc_->AddStream(reference_collection_->at(0)); | 2184 pc_->AddStream(reference_collection_->at(0)); |
| 2187 EXPECT_TRUE(DoSetLocalDescription(desc_1.release())); | 2185 EXPECT_TRUE(DoSetLocalDescription(desc_1.release())); |
| 2188 auto senders = pc_->GetSenders(); | 2186 auto senders = pc_->GetSenders(); |
| 2189 EXPECT_EQ(4u, senders.size()); | 2187 EXPECT_EQ(4u, senders.size()); |
| 2190 EXPECT_TRUE(ContainsSender(senders, kAudioTracks[0])); | 2188 EXPECT_TRUE(ContainsSender(senders, kAudioTracks[0])); |
| 2191 EXPECT_TRUE(ContainsSender(senders, kVideoTracks[0])); | 2189 EXPECT_TRUE(ContainsSender(senders, kVideoTracks[0])); |
| 2192 EXPECT_TRUE(ContainsSender(senders, kAudioTracks[1])); | 2190 EXPECT_TRUE(ContainsSender(senders, kAudioTracks[1])); |
| 2193 EXPECT_TRUE(ContainsSender(senders, kVideoTracks[1])); | 2191 EXPECT_TRUE(ContainsSender(senders, kVideoTracks[1])); |
| 2194 | 2192 |
| 2195 // Remove an audio and video track. | 2193 // Remove an audio and video track. |
| 2196 pc_->RemoveStream(reference_collection_->at(0)); | 2194 pc_->RemoveStream(reference_collection_->at(0)); |
| 2197 rtc::scoped_ptr<SessionDescriptionInterface> desc_2; | 2195 rtc::scoped_ptr<SessionDescriptionInterface> desc_2 = |
| 2198 CreateSessionDescriptionAndReference(1, 1, desc_2.accept()); | 2196 CreateSessionDescriptionAndReference(1, 1); |
| 2199 pc_->AddStream(reference_collection_->at(0)); | 2197 pc_->AddStream(reference_collection_->at(0)); |
| 2200 EXPECT_TRUE(DoSetLocalDescription(desc_2.release())); | 2198 EXPECT_TRUE(DoSetLocalDescription(desc_2.release())); |
| 2201 senders = pc_->GetSenders(); | 2199 senders = pc_->GetSenders(); |
| 2202 EXPECT_EQ(2u, senders.size()); | 2200 EXPECT_EQ(2u, senders.size()); |
| 2203 EXPECT_TRUE(ContainsSender(senders, kAudioTracks[0])); | 2201 EXPECT_TRUE(ContainsSender(senders, kAudioTracks[0])); |
| 2204 EXPECT_TRUE(ContainsSender(senders, kVideoTracks[0])); | 2202 EXPECT_TRUE(ContainsSender(senders, kVideoTracks[0])); |
| 2205 EXPECT_FALSE(ContainsSender(senders, kAudioTracks[1])); | 2203 EXPECT_FALSE(ContainsSender(senders, kAudioTracks[1])); |
| 2206 EXPECT_FALSE(ContainsSender(senders, kVideoTracks[1])); | 2204 EXPECT_FALSE(ContainsSender(senders, kVideoTracks[1])); |
| 2207 } | 2205 } |
| 2208 | 2206 |
| 2209 // This tests that an RtpSender is created when the local description is set | 2207 // This tests that an RtpSender is created when the local description is set |
| 2210 // before adding a local stream. | 2208 // before adding a local stream. |
| 2211 TEST_F(PeerConnectionInterfaceTest, | 2209 TEST_F(PeerConnectionInterfaceTest, |
| 2212 AddLocalStreamAfterLocalDescriptionChanged) { | 2210 AddLocalStreamAfterLocalDescriptionChanged) { |
| 2213 FakeConstraints constraints; | 2211 FakeConstraints constraints; |
| 2214 constraints.AddMandatory(webrtc::MediaConstraintsInterface::kEnableDtlsSrtp, | 2212 constraints.AddMandatory(webrtc::MediaConstraintsInterface::kEnableDtlsSrtp, |
| 2215 true); | 2213 true); |
| 2216 CreatePeerConnection(&constraints); | 2214 CreatePeerConnection(&constraints); |
| 2217 // Create an offer just to ensure we have an identity before we manually | 2215 // Create an offer just to ensure we have an identity before we manually |
| 2218 // call SetLocalDescription. | 2216 // call SetLocalDescription. |
| 2219 rtc::scoped_ptr<SessionDescriptionInterface> throwaway; | 2217 rtc::scoped_ptr<SessionDescriptionInterface> throwaway; |
| 2220 ASSERT_TRUE(DoCreateOffer(throwaway.accept(), nullptr)); | 2218 ASSERT_TRUE(DoCreateOffer(&throwaway, nullptr)); |
| 2221 | 2219 |
| 2222 rtc::scoped_ptr<SessionDescriptionInterface> desc_1; | 2220 rtc::scoped_ptr<SessionDescriptionInterface> desc_1 = |
| 2223 CreateSessionDescriptionAndReference(2, 2, desc_1.accept()); | 2221 CreateSessionDescriptionAndReference(2, 2); |
| 2224 | 2222 |
| 2225 EXPECT_TRUE(DoSetLocalDescription(desc_1.release())); | 2223 EXPECT_TRUE(DoSetLocalDescription(desc_1.release())); |
| 2226 auto senders = pc_->GetSenders(); | 2224 auto senders = pc_->GetSenders(); |
| 2227 EXPECT_EQ(0u, senders.size()); | 2225 EXPECT_EQ(0u, senders.size()); |
| 2228 | 2226 |
| 2229 pc_->AddStream(reference_collection_->at(0)); | 2227 pc_->AddStream(reference_collection_->at(0)); |
| 2230 senders = pc_->GetSenders(); | 2228 senders = pc_->GetSenders(); |
| 2231 EXPECT_EQ(4u, senders.size()); | 2229 EXPECT_EQ(4u, senders.size()); |
| 2232 EXPECT_TRUE(ContainsSender(senders, kAudioTracks[0])); | 2230 EXPECT_TRUE(ContainsSender(senders, kAudioTracks[0])); |
| 2233 EXPECT_TRUE(ContainsSender(senders, kVideoTracks[0])); | 2231 EXPECT_TRUE(ContainsSender(senders, kVideoTracks[0])); |
| 2234 EXPECT_TRUE(ContainsSender(senders, kAudioTracks[1])); | 2232 EXPECT_TRUE(ContainsSender(senders, kAudioTracks[1])); |
| 2235 EXPECT_TRUE(ContainsSender(senders, kVideoTracks[1])); | 2233 EXPECT_TRUE(ContainsSender(senders, kVideoTracks[1])); |
| 2236 } | 2234 } |
| 2237 | 2235 |
| 2238 // This tests that the expected behavior occurs if the SSRC on a local track is | 2236 // This tests that the expected behavior occurs if the SSRC on a local track is |
| 2239 // changed when SetLocalDescription is called. | 2237 // changed when SetLocalDescription is called. |
| 2240 TEST_F(PeerConnectionInterfaceTest, | 2238 TEST_F(PeerConnectionInterfaceTest, |
| 2241 ChangeSsrcOnTrackInLocalSessionDescription) { | 2239 ChangeSsrcOnTrackInLocalSessionDescription) { |
| 2242 FakeConstraints constraints; | 2240 FakeConstraints constraints; |
| 2243 constraints.AddMandatory(webrtc::MediaConstraintsInterface::kEnableDtlsSrtp, | 2241 constraints.AddMandatory(webrtc::MediaConstraintsInterface::kEnableDtlsSrtp, |
| 2244 true); | 2242 true); |
| 2245 CreatePeerConnection(&constraints); | 2243 CreatePeerConnection(&constraints); |
| 2246 // Create an offer just to ensure we have an identity before we manually | 2244 // Create an offer just to ensure we have an identity before we manually |
| 2247 // call SetLocalDescription. | 2245 // call SetLocalDescription. |
| 2248 rtc::scoped_ptr<SessionDescriptionInterface> throwaway; | 2246 rtc::scoped_ptr<SessionDescriptionInterface> throwaway; |
| 2249 ASSERT_TRUE(DoCreateOffer(throwaway.accept(), nullptr)); | 2247 ASSERT_TRUE(DoCreateOffer(&throwaway, nullptr)); |
| 2250 | 2248 |
| 2251 rtc::scoped_ptr<SessionDescriptionInterface> desc; | 2249 rtc::scoped_ptr<SessionDescriptionInterface> desc = |
| 2252 CreateSessionDescriptionAndReference(1, 1, desc.accept()); | 2250 CreateSessionDescriptionAndReference(1, 1); |
| 2253 std::string sdp; | 2251 std::string sdp; |
| 2254 desc->ToString(&sdp); | 2252 desc->ToString(&sdp); |
| 2255 | 2253 |
| 2256 pc_->AddStream(reference_collection_->at(0)); | 2254 pc_->AddStream(reference_collection_->at(0)); |
| 2257 EXPECT_TRUE(DoSetLocalDescription(desc.release())); | 2255 EXPECT_TRUE(DoSetLocalDescription(desc.release())); |
| 2258 auto senders = pc_->GetSenders(); | 2256 auto senders = pc_->GetSenders(); |
| 2259 EXPECT_EQ(2u, senders.size()); | 2257 EXPECT_EQ(2u, senders.size()); |
| 2260 EXPECT_TRUE(ContainsSender(senders, kAudioTracks[0])); | 2258 EXPECT_TRUE(ContainsSender(senders, kAudioTracks[0])); |
| 2261 EXPECT_TRUE(ContainsSender(senders, kVideoTracks[0])); | 2259 EXPECT_TRUE(ContainsSender(senders, kVideoTracks[0])); |
| 2262 | 2260 |
| (...skipping 22 matching lines...) Expand all Loading... |
| 2285 // This tests that the expected behavior occurs if a new session description is | 2283 // This tests that the expected behavior occurs if a new session description is |
| 2286 // set with the same tracks, but on a different MediaStream. | 2284 // set with the same tracks, but on a different MediaStream. |
| 2287 TEST_F(PeerConnectionInterfaceTest, SignalSameTracksInSeparateMediaStream) { | 2285 TEST_F(PeerConnectionInterfaceTest, SignalSameTracksInSeparateMediaStream) { |
| 2288 FakeConstraints constraints; | 2286 FakeConstraints constraints; |
| 2289 constraints.AddMandatory(webrtc::MediaConstraintsInterface::kEnableDtlsSrtp, | 2287 constraints.AddMandatory(webrtc::MediaConstraintsInterface::kEnableDtlsSrtp, |
| 2290 true); | 2288 true); |
| 2291 CreatePeerConnection(&constraints); | 2289 CreatePeerConnection(&constraints); |
| 2292 // Create an offer just to ensure we have an identity before we manually | 2290 // Create an offer just to ensure we have an identity before we manually |
| 2293 // call SetLocalDescription. | 2291 // call SetLocalDescription. |
| 2294 rtc::scoped_ptr<SessionDescriptionInterface> throwaway; | 2292 rtc::scoped_ptr<SessionDescriptionInterface> throwaway; |
| 2295 ASSERT_TRUE(DoCreateOffer(throwaway.accept(), nullptr)); | 2293 ASSERT_TRUE(DoCreateOffer(&throwaway, nullptr)); |
| 2296 | 2294 |
| 2297 rtc::scoped_ptr<SessionDescriptionInterface> desc; | 2295 rtc::scoped_ptr<SessionDescriptionInterface> desc = |
| 2298 CreateSessionDescriptionAndReference(1, 1, desc.accept()); | 2296 CreateSessionDescriptionAndReference(1, 1); |
| 2299 std::string sdp; | 2297 std::string sdp; |
| 2300 desc->ToString(&sdp); | 2298 desc->ToString(&sdp); |
| 2301 | 2299 |
| 2302 pc_->AddStream(reference_collection_->at(0)); | 2300 pc_->AddStream(reference_collection_->at(0)); |
| 2303 EXPECT_TRUE(DoSetLocalDescription(desc.release())); | 2301 EXPECT_TRUE(DoSetLocalDescription(desc.release())); |
| 2304 auto senders = pc_->GetSenders(); | 2302 auto senders = pc_->GetSenders(); |
| 2305 EXPECT_EQ(2u, senders.size()); | 2303 EXPECT_EQ(2u, senders.size()); |
| 2306 EXPECT_TRUE(ContainsSender(senders, kAudioTracks[0])); | 2304 EXPECT_TRUE(ContainsSender(senders, kAudioTracks[0])); |
| 2307 EXPECT_TRUE(ContainsSender(senders, kVideoTracks[0])); | 2305 EXPECT_TRUE(ContainsSender(senders, kVideoTracks[0])); |
| 2308 | 2306 |
| (...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2607 FakeConstraints updated_answer_c; | 2605 FakeConstraints updated_answer_c; |
| 2608 answer_c.SetMandatoryReceiveAudio(false); | 2606 answer_c.SetMandatoryReceiveAudio(false); |
| 2609 answer_c.SetMandatoryReceiveVideo(false); | 2607 answer_c.SetMandatoryReceiveVideo(false); |
| 2610 | 2608 |
| 2611 cricket::MediaSessionOptions updated_answer_options; | 2609 cricket::MediaSessionOptions updated_answer_options; |
| 2612 EXPECT_TRUE( | 2610 EXPECT_TRUE( |
| 2613 ParseConstraintsForAnswer(&updated_answer_c, &updated_answer_options)); | 2611 ParseConstraintsForAnswer(&updated_answer_c, &updated_answer_options)); |
| 2614 EXPECT_TRUE(updated_answer_options.has_audio()); | 2612 EXPECT_TRUE(updated_answer_options.has_audio()); |
| 2615 EXPECT_TRUE(updated_answer_options.has_video()); | 2613 EXPECT_TRUE(updated_answer_options.has_video()); |
| 2616 } | 2614 } |
| OLD | NEW |