Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(138)

Side by Side Diff: talk/app/webrtc/peerconnectioninterface_unittest.cc

Issue 1406803004: Fixing some issues with the direction attribute of m-lines in offers. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Fixing a comment. Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * libjingle 2 * libjingle
3 * Copyright 2012 Google Inc. 3 * Copyright 2012 Google Inc.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met: 6 * modification, are permitted provided that the following conditions are met:
7 * 7 *
8 * 1. Redistributions of source code must retain the above copyright notice, 8 * 1. Redistributions of source code must retain the above copyright notice,
9 * this list of conditions and the following disclaimer. 9 * this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright notice, 10 * 2. Redistributions in binary form must reproduce the above copyright notice,
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after
237 using rtc::scoped_ptr; 237 using rtc::scoped_ptr;
238 using rtc::scoped_refptr; 238 using rtc::scoped_refptr;
239 using webrtc::AudioSourceInterface; 239 using webrtc::AudioSourceInterface;
240 using webrtc::AudioTrack; 240 using webrtc::AudioTrack;
241 using webrtc::AudioTrackInterface; 241 using webrtc::AudioTrackInterface;
242 using webrtc::DataBuffer; 242 using webrtc::DataBuffer;
243 using webrtc::DataChannelInterface; 243 using webrtc::DataChannelInterface;
244 using webrtc::FakeConstraints; 244 using webrtc::FakeConstraints;
245 using webrtc::FakePortAllocatorFactory; 245 using webrtc::FakePortAllocatorFactory;
246 using webrtc::IceCandidateInterface; 246 using webrtc::IceCandidateInterface;
247 using webrtc::MediaConstraintsInterface;
247 using webrtc::MediaStream; 248 using webrtc::MediaStream;
248 using webrtc::MediaStreamInterface; 249 using webrtc::MediaStreamInterface;
249 using webrtc::MediaStreamTrackInterface; 250 using webrtc::MediaStreamTrackInterface;
250 using webrtc::MockCreateSessionDescriptionObserver; 251 using webrtc::MockCreateSessionDescriptionObserver;
251 using webrtc::MockDataChannelObserver; 252 using webrtc::MockDataChannelObserver;
252 using webrtc::MockSetSessionDescriptionObserver; 253 using webrtc::MockSetSessionDescriptionObserver;
253 using webrtc::MockStatsObserver; 254 using webrtc::MockStatsObserver;
254 using webrtc::PeerConnectionInterface; 255 using webrtc::PeerConnectionInterface;
255 using webrtc::PeerConnectionObserver; 256 using webrtc::PeerConnectionObserver;
256 using webrtc::PortAllocatorFactoryInterface; 257 using webrtc::PortAllocatorFactoryInterface;
(...skipping 378 matching lines...) Expand 10 before | Expand all | Expand 10 after
635 audio_track_label, static_cast<AudioSourceInterface*>(NULL))); 636 audio_track_label, static_cast<AudioSourceInterface*>(NULL)));
636 stream->AddTrack(audio_track.get()); 637 stream->AddTrack(audio_track.get());
637 scoped_refptr<VideoTrackInterface> video_track( 638 scoped_refptr<VideoTrackInterface> video_track(
638 pc_factory_->CreateVideoTrack(video_track_label, NULL)); 639 pc_factory_->CreateVideoTrack(video_track_label, NULL));
639 stream->AddTrack(video_track.get()); 640 stream->AddTrack(video_track.get());
640 EXPECT_TRUE(pc_->AddStream(stream)); 641 EXPECT_TRUE(pc_->AddStream(stream));
641 EXPECT_TRUE_WAIT(observer_.renegotiation_needed_, kTimeout); 642 EXPECT_TRUE_WAIT(observer_.renegotiation_needed_, kTimeout);
642 observer_.renegotiation_needed_ = false; 643 observer_.renegotiation_needed_ = false;
643 } 644 }
644 645
645 bool DoCreateOfferAnswer(SessionDescriptionInterface** desc, bool offer) { 646 bool DoCreateOfferAnswer(SessionDescriptionInterface** desc,
647 bool offer,
648 MediaConstraintsInterface* constraints) {
646 rtc::scoped_refptr<MockCreateSessionDescriptionObserver> 649 rtc::scoped_refptr<MockCreateSessionDescriptionObserver>
647 observer(new rtc::RefCountedObject< 650 observer(new rtc::RefCountedObject<
648 MockCreateSessionDescriptionObserver>()); 651 MockCreateSessionDescriptionObserver>());
649 if (offer) { 652 if (offer) {
650 pc_->CreateOffer(observer, NULL); 653 pc_->CreateOffer(observer, constraints);
651 } else { 654 } else {
652 pc_->CreateAnswer(observer, NULL); 655 pc_->CreateAnswer(observer, constraints);
653 } 656 }
654 EXPECT_EQ_WAIT(true, observer->called(), kTimeout); 657 EXPECT_EQ_WAIT(true, observer->called(), kTimeout);
655 *desc = observer->release_desc(); 658 *desc = observer->release_desc();
656 return observer->result(); 659 return observer->result();
657 } 660 }
658 661
659 bool DoCreateOffer(SessionDescriptionInterface** desc) { 662 bool DoCreateOffer(SessionDescriptionInterface** desc,
660 return DoCreateOfferAnswer(desc, true); 663 MediaConstraintsInterface* constraints) {
664 return DoCreateOfferAnswer(desc, true, constraints);
661 } 665 }
662 666
663 bool DoCreateAnswer(SessionDescriptionInterface** desc) { 667 bool DoCreateAnswer(SessionDescriptionInterface** desc,
664 return DoCreateOfferAnswer(desc, false); 668 MediaConstraintsInterface* constraints) {
669 return DoCreateOfferAnswer(desc, false, constraints);
665 } 670 }
666 671
667 bool DoSetSessionDescription(SessionDescriptionInterface* desc, bool local) { 672 bool DoSetSessionDescription(SessionDescriptionInterface* desc, bool local) {
668 rtc::scoped_refptr<MockSetSessionDescriptionObserver> 673 rtc::scoped_refptr<MockSetSessionDescriptionObserver>
669 observer(new rtc::RefCountedObject< 674 observer(new rtc::RefCountedObject<
670 MockSetSessionDescriptionObserver>()); 675 MockSetSessionDescriptionObserver>());
671 if (local) { 676 if (local) {
672 pc_->SetLocalDescription(observer, desc); 677 pc_->SetLocalDescription(observer, desc);
673 } else { 678 } else {
674 pc_->SetRemoteDescription(observer, desc); 679 pc_->SetRemoteDescription(observer, desc);
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
714 EXPECT_GT(desc->rtp_header_extensions().size(), 0u); 719 EXPECT_GT(desc->rtp_header_extensions().size(), 0u);
715 720
716 desc = cricket::GetFirstVideoContentDescription( 721 desc = cricket::GetFirstVideoContentDescription(
717 pc_->remote_description()->description()); 722 pc_->remote_description()->description());
718 ASSERT_TRUE(desc != NULL); 723 ASSERT_TRUE(desc != NULL);
719 EXPECT_GT(desc->rtp_header_extensions().size(), 0u); 724 EXPECT_GT(desc->rtp_header_extensions().size(), 0u);
720 } 725 }
721 726
722 void CreateOfferAsRemoteDescription() { 727 void CreateOfferAsRemoteDescription() {
723 rtc::scoped_ptr<SessionDescriptionInterface> offer; 728 rtc::scoped_ptr<SessionDescriptionInterface> offer;
724 ASSERT_TRUE(DoCreateOffer(offer.use())); 729 ASSERT_TRUE(DoCreateOffer(offer.use(), nullptr));
725 std::string sdp; 730 std::string sdp;
726 EXPECT_TRUE(offer->ToString(&sdp)); 731 EXPECT_TRUE(offer->ToString(&sdp));
727 SessionDescriptionInterface* remote_offer = 732 SessionDescriptionInterface* remote_offer =
728 webrtc::CreateSessionDescription(SessionDescriptionInterface::kOffer, 733 webrtc::CreateSessionDescription(SessionDescriptionInterface::kOffer,
729 sdp, NULL); 734 sdp, NULL);
730 EXPECT_TRUE(DoSetRemoteDescription(remote_offer)); 735 EXPECT_TRUE(DoSetRemoteDescription(remote_offer));
731 EXPECT_EQ(PeerConnectionInterface::kHaveRemoteOffer, observer_.state_); 736 EXPECT_EQ(PeerConnectionInterface::kHaveRemoteOffer, observer_.state_);
732 } 737 }
733 738
734 void CreateAndSetRemoteOffer(const std::string& sdp) { 739 void CreateAndSetRemoteOffer(const std::string& sdp) {
735 SessionDescriptionInterface* remote_offer = 740 SessionDescriptionInterface* remote_offer =
736 webrtc::CreateSessionDescription(SessionDescriptionInterface::kOffer, 741 webrtc::CreateSessionDescription(SessionDescriptionInterface::kOffer,
737 sdp, nullptr); 742 sdp, nullptr);
738 EXPECT_TRUE(DoSetRemoteDescription(remote_offer)); 743 EXPECT_TRUE(DoSetRemoteDescription(remote_offer));
739 EXPECT_EQ(PeerConnectionInterface::kHaveRemoteOffer, observer_.state_); 744 EXPECT_EQ(PeerConnectionInterface::kHaveRemoteOffer, observer_.state_);
740 } 745 }
741 746
742 void CreateAnswerAsLocalDescription() { 747 void CreateAnswerAsLocalDescription() {
743 scoped_ptr<SessionDescriptionInterface> answer; 748 scoped_ptr<SessionDescriptionInterface> answer;
744 ASSERT_TRUE(DoCreateAnswer(answer.use())); 749 ASSERT_TRUE(DoCreateAnswer(answer.use(), nullptr));
745 750
746 // TODO(perkj): Currently SetLocalDescription fails if any parameters in an 751 // TODO(perkj): Currently SetLocalDescription fails if any parameters in an
747 // audio codec change, even if the parameter has nothing to do with 752 // audio codec change, even if the parameter has nothing to do with
748 // receiving. Not all parameters are serialized to SDP. 753 // receiving. Not all parameters are serialized to SDP.
749 // Since CreatePrAnswerAsLocalDescription serialize/deserialize 754 // Since CreatePrAnswerAsLocalDescription serialize/deserialize
750 // the SessionDescription, it is necessary to do that here to in order to 755 // the SessionDescription, it is necessary to do that here to in order to
751 // get ReceiveOfferCreatePrAnswerAndAnswer and RenegotiateAudioOnly to pass. 756 // get ReceiveOfferCreatePrAnswerAndAnswer and RenegotiateAudioOnly to pass.
752 // https://code.google.com/p/webrtc/issues/detail?id=1356 757 // https://code.google.com/p/webrtc/issues/detail?id=1356
753 std::string sdp; 758 std::string sdp;
754 EXPECT_TRUE(answer->ToString(&sdp)); 759 EXPECT_TRUE(answer->ToString(&sdp));
755 SessionDescriptionInterface* new_answer = 760 SessionDescriptionInterface* new_answer =
756 webrtc::CreateSessionDescription(SessionDescriptionInterface::kAnswer, 761 webrtc::CreateSessionDescription(SessionDescriptionInterface::kAnswer,
757 sdp, NULL); 762 sdp, NULL);
758 EXPECT_TRUE(DoSetLocalDescription(new_answer)); 763 EXPECT_TRUE(DoSetLocalDescription(new_answer));
759 EXPECT_EQ(PeerConnectionInterface::kStable, observer_.state_); 764 EXPECT_EQ(PeerConnectionInterface::kStable, observer_.state_);
760 } 765 }
761 766
762 void CreatePrAnswerAsLocalDescription() { 767 void CreatePrAnswerAsLocalDescription() {
763 scoped_ptr<SessionDescriptionInterface> answer; 768 scoped_ptr<SessionDescriptionInterface> answer;
764 ASSERT_TRUE(DoCreateAnswer(answer.use())); 769 ASSERT_TRUE(DoCreateAnswer(answer.use(), nullptr));
765 770
766 std::string sdp; 771 std::string sdp;
767 EXPECT_TRUE(answer->ToString(&sdp)); 772 EXPECT_TRUE(answer->ToString(&sdp));
768 SessionDescriptionInterface* pr_answer = 773 SessionDescriptionInterface* pr_answer =
769 webrtc::CreateSessionDescription(SessionDescriptionInterface::kPrAnswer, 774 webrtc::CreateSessionDescription(SessionDescriptionInterface::kPrAnswer,
770 sdp, NULL); 775 sdp, NULL);
771 EXPECT_TRUE(DoSetLocalDescription(pr_answer)); 776 EXPECT_TRUE(DoSetLocalDescription(pr_answer));
772 EXPECT_EQ(PeerConnectionInterface::kHaveLocalPrAnswer, observer_.state_); 777 EXPECT_EQ(PeerConnectionInterface::kHaveLocalPrAnswer, observer_.state_);
773 } 778 }
774 779
775 void CreateOfferReceiveAnswer() { 780 void CreateOfferReceiveAnswer() {
776 CreateOfferAsLocalDescription(); 781 CreateOfferAsLocalDescription();
777 std::string sdp; 782 std::string sdp;
778 EXPECT_TRUE(pc_->local_description()->ToString(&sdp)); 783 EXPECT_TRUE(pc_->local_description()->ToString(&sdp));
779 CreateAnswerAsRemoteDescription(sdp); 784 CreateAnswerAsRemoteDescription(sdp);
780 } 785 }
781 786
782 void CreateOfferAsLocalDescription() { 787 void CreateOfferAsLocalDescription() {
783 rtc::scoped_ptr<SessionDescriptionInterface> offer; 788 rtc::scoped_ptr<SessionDescriptionInterface> offer;
784 ASSERT_TRUE(DoCreateOffer(offer.use())); 789 ASSERT_TRUE(DoCreateOffer(offer.use(), nullptr));
785 // TODO(perkj): Currently SetLocalDescription fails if any parameters in an 790 // TODO(perkj): Currently SetLocalDescription fails if any parameters in an
786 // audio codec change, even if the parameter has nothing to do with 791 // audio codec change, even if the parameter has nothing to do with
787 // receiving. Not all parameters are serialized to SDP. 792 // receiving. Not all parameters are serialized to SDP.
788 // Since CreatePrAnswerAsLocalDescription serialize/deserialize 793 // Since CreatePrAnswerAsLocalDescription serialize/deserialize
789 // the SessionDescription, it is necessary to do that here to in order to 794 // the SessionDescription, it is necessary to do that here to in order to
790 // get ReceiveOfferCreatePrAnswerAndAnswer and RenegotiateAudioOnly to pass. 795 // get ReceiveOfferCreatePrAnswerAndAnswer and RenegotiateAudioOnly to pass.
791 // https://code.google.com/p/webrtc/issues/detail?id=1356 796 // https://code.google.com/p/webrtc/issues/detail?id=1356
792 std::string sdp; 797 std::string sdp;
793 EXPECT_TRUE(offer->ToString(&sdp)); 798 EXPECT_TRUE(offer->ToString(&sdp));
794 SessionDescriptionInterface* new_offer = 799 SessionDescriptionInterface* new_offer =
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
944 // Remove the first stream. 949 // Remove the first stream.
945 pc_->RemoveStream(pc_->local_streams()->at(0)); 950 pc_->RemoveStream(pc_->local_streams()->at(0));
946 EXPECT_EQ(0u, pc_->local_streams()->count()); 951 EXPECT_EQ(0u, pc_->local_streams()->count());
947 } 952 }
948 953
949 // Test that the created offer includes streams we added. 954 // Test that the created offer includes streams we added.
950 TEST_F(PeerConnectionInterfaceTest, AddedStreamsPresentInOffer) { 955 TEST_F(PeerConnectionInterfaceTest, AddedStreamsPresentInOffer) {
951 CreatePeerConnection(); 956 CreatePeerConnection();
952 AddAudioVideoStream(kStreamLabel1, "audio_track", "video_track"); 957 AddAudioVideoStream(kStreamLabel1, "audio_track", "video_track");
953 scoped_ptr<SessionDescriptionInterface> offer; 958 scoped_ptr<SessionDescriptionInterface> offer;
954 ASSERT_TRUE(DoCreateOffer(offer.accept())); 959 ASSERT_TRUE(DoCreateOffer(offer.accept(), nullptr));
955 960
956 const cricket::ContentInfo* audio_content = 961 const cricket::ContentInfo* audio_content =
957 cricket::GetFirstAudioContent(offer->description()); 962 cricket::GetFirstAudioContent(offer->description());
958 const cricket::AudioContentDescription* audio_desc = 963 const cricket::AudioContentDescription* audio_desc =
959 static_cast<const cricket::AudioContentDescription*>( 964 static_cast<const cricket::AudioContentDescription*>(
960 audio_content->description); 965 audio_content->description);
961 EXPECT_TRUE( 966 EXPECT_TRUE(
962 ContainsTrack(audio_desc->streams(), kStreamLabel1, "audio_track")); 967 ContainsTrack(audio_desc->streams(), kStreamLabel1, "audio_track"));
963 968
964 const cricket::ContentInfo* video_content = 969 const cricket::ContentInfo* video_content =
965 cricket::GetFirstVideoContent(offer->description()); 970 cricket::GetFirstVideoContent(offer->description());
966 const cricket::VideoContentDescription* video_desc = 971 const cricket::VideoContentDescription* video_desc =
967 static_cast<const cricket::VideoContentDescription*>( 972 static_cast<const cricket::VideoContentDescription*>(
968 video_content->description); 973 video_content->description);
969 EXPECT_TRUE( 974 EXPECT_TRUE(
970 ContainsTrack(video_desc->streams(), kStreamLabel1, "video_track")); 975 ContainsTrack(video_desc->streams(), kStreamLabel1, "video_track"));
971 976
972 // Add another stream and ensure the offer includes both the old and new 977 // Add another stream and ensure the offer includes both the old and new
973 // streams. 978 // streams.
974 AddAudioVideoStream(kStreamLabel2, "audio_track2", "video_track2"); 979 AddAudioVideoStream(kStreamLabel2, "audio_track2", "video_track2");
975 ASSERT_TRUE(DoCreateOffer(offer.accept())); 980 ASSERT_TRUE(DoCreateOffer(offer.accept(), nullptr));
976 981
977 audio_content = cricket::GetFirstAudioContent(offer->description()); 982 audio_content = cricket::GetFirstAudioContent(offer->description());
978 audio_desc = static_cast<const cricket::AudioContentDescription*>( 983 audio_desc = static_cast<const cricket::AudioContentDescription*>(
979 audio_content->description); 984 audio_content->description);
980 EXPECT_TRUE( 985 EXPECT_TRUE(
981 ContainsTrack(audio_desc->streams(), kStreamLabel1, "audio_track")); 986 ContainsTrack(audio_desc->streams(), kStreamLabel1, "audio_track"));
982 EXPECT_TRUE( 987 EXPECT_TRUE(
983 ContainsTrack(audio_desc->streams(), kStreamLabel2, "audio_track2")); 988 ContainsTrack(audio_desc->streams(), kStreamLabel2, "audio_track2"));
984 989
985 video_content = cricket::GetFirstVideoContent(offer->description()); 990 video_content = cricket::GetFirstVideoContent(offer->description());
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
1061 } 1066 }
1062 1067
1063 // Test that candidates are generated and that we can parse our own candidates. 1068 // Test that candidates are generated and that we can parse our own candidates.
1064 TEST_F(PeerConnectionInterfaceTest, IceCandidates) { 1069 TEST_F(PeerConnectionInterfaceTest, IceCandidates) {
1065 CreatePeerConnection(); 1070 CreatePeerConnection();
1066 1071
1067 EXPECT_FALSE(pc_->AddIceCandidate(observer_.last_candidate_.get())); 1072 EXPECT_FALSE(pc_->AddIceCandidate(observer_.last_candidate_.get()));
1068 // SetRemoteDescription takes ownership of offer. 1073 // SetRemoteDescription takes ownership of offer.
1069 SessionDescriptionInterface* offer = NULL; 1074 SessionDescriptionInterface* offer = NULL;
1070 AddVideoStream(kStreamLabel1); 1075 AddVideoStream(kStreamLabel1);
1071 EXPECT_TRUE(DoCreateOffer(&offer)); 1076 EXPECT_TRUE(DoCreateOffer(&offer, nullptr));
1072 EXPECT_TRUE(DoSetRemoteDescription(offer)); 1077 EXPECT_TRUE(DoSetRemoteDescription(offer));
1073 1078
1074 // SetLocalDescription takes ownership of answer. 1079 // SetLocalDescription takes ownership of answer.
1075 SessionDescriptionInterface* answer = NULL; 1080 SessionDescriptionInterface* answer = NULL;
1076 EXPECT_TRUE(DoCreateAnswer(&answer)); 1081 EXPECT_TRUE(DoCreateAnswer(&answer, nullptr));
1077 EXPECT_TRUE(DoSetLocalDescription(answer)); 1082 EXPECT_TRUE(DoSetLocalDescription(answer));
1078 1083
1079 EXPECT_TRUE_WAIT(observer_.last_candidate_.get() != NULL, kTimeout); 1084 EXPECT_TRUE_WAIT(observer_.last_candidate_.get() != NULL, kTimeout);
1080 EXPECT_TRUE_WAIT(observer_.ice_complete_, kTimeout); 1085 EXPECT_TRUE_WAIT(observer_.ice_complete_, kTimeout);
1081 1086
1082 EXPECT_TRUE(pc_->AddIceCandidate(observer_.last_candidate_.get())); 1087 EXPECT_TRUE(pc_->AddIceCandidate(observer_.last_candidate_.get()));
1083 } 1088 }
1084 1089
1085 // Test that CreateOffer and CreateAnswer will fail if the track labels are 1090 // Test that CreateOffer and CreateAnswer will fail if the track labels are
1086 // not unique. 1091 // not unique.
1087 TEST_F(PeerConnectionInterfaceTest, CreateOfferAnswerWithInvalidStream) { 1092 TEST_F(PeerConnectionInterfaceTest, CreateOfferAnswerWithInvalidStream) {
1088 CreatePeerConnection(); 1093 CreatePeerConnection();
1089 // Create a regular offer for the CreateAnswer test later. 1094 // Create a regular offer for the CreateAnswer test later.
1090 SessionDescriptionInterface* offer = NULL; 1095 SessionDescriptionInterface* offer = NULL;
1091 EXPECT_TRUE(DoCreateOffer(&offer)); 1096 EXPECT_TRUE(DoCreateOffer(&offer, nullptr));
1092 EXPECT_TRUE(offer != NULL); 1097 EXPECT_TRUE(offer != NULL);
1093 delete offer; 1098 delete offer;
1094 offer = NULL; 1099 offer = NULL;
1095 1100
1096 // Create a local stream with audio&video tracks having same label. 1101 // Create a local stream with audio&video tracks having same label.
1097 AddAudioVideoStream(kStreamLabel1, "track_label", "track_label"); 1102 AddAudioVideoStream(kStreamLabel1, "track_label", "track_label");
1098 1103
1099 // Test CreateOffer 1104 // Test CreateOffer
1100 EXPECT_FALSE(DoCreateOffer(&offer)); 1105 EXPECT_FALSE(DoCreateOffer(&offer, nullptr));
1101 1106
1102 // Test CreateAnswer 1107 // Test CreateAnswer
1103 SessionDescriptionInterface* answer = NULL; 1108 SessionDescriptionInterface* answer = NULL;
1104 EXPECT_FALSE(DoCreateAnswer(&answer)); 1109 EXPECT_FALSE(DoCreateAnswer(&answer, nullptr));
1105 } 1110 }
1106 1111
1107 // Test that we will get different SSRCs for each tracks in the offer and answer 1112 // Test that we will get different SSRCs for each tracks in the offer and answer
1108 // we created. 1113 // we created.
1109 TEST_F(PeerConnectionInterfaceTest, SsrcInOfferAnswer) { 1114 TEST_F(PeerConnectionInterfaceTest, SsrcInOfferAnswer) {
1110 CreatePeerConnection(); 1115 CreatePeerConnection();
1111 // Create a local stream with audio&video tracks having different labels. 1116 // Create a local stream with audio&video tracks having different labels.
1112 AddAudioVideoStream(kStreamLabel1, "audio_label", "video_label"); 1117 AddAudioVideoStream(kStreamLabel1, "audio_label", "video_label");
1113 1118
1114 // Test CreateOffer 1119 // Test CreateOffer
1115 scoped_ptr<SessionDescriptionInterface> offer; 1120 scoped_ptr<SessionDescriptionInterface> offer;
1116 ASSERT_TRUE(DoCreateOffer(offer.use())); 1121 ASSERT_TRUE(DoCreateOffer(offer.use(), nullptr));
1117 int audio_ssrc = 0; 1122 int audio_ssrc = 0;
1118 int video_ssrc = 0; 1123 int video_ssrc = 0;
1119 EXPECT_TRUE(GetFirstSsrc(GetFirstAudioContent(offer->description()), 1124 EXPECT_TRUE(GetFirstSsrc(GetFirstAudioContent(offer->description()),
1120 &audio_ssrc)); 1125 &audio_ssrc));
1121 EXPECT_TRUE(GetFirstSsrc(GetFirstVideoContent(offer->description()), 1126 EXPECT_TRUE(GetFirstSsrc(GetFirstVideoContent(offer->description()),
1122 &video_ssrc)); 1127 &video_ssrc));
1123 EXPECT_NE(audio_ssrc, video_ssrc); 1128 EXPECT_NE(audio_ssrc, video_ssrc);
1124 1129
1125 // Test CreateAnswer 1130 // Test CreateAnswer
1126 EXPECT_TRUE(DoSetRemoteDescription(offer.release())); 1131 EXPECT_TRUE(DoSetRemoteDescription(offer.release()));
1127 scoped_ptr<SessionDescriptionInterface> answer; 1132 scoped_ptr<SessionDescriptionInterface> answer;
1128 ASSERT_TRUE(DoCreateAnswer(answer.use())); 1133 ASSERT_TRUE(DoCreateAnswer(answer.use(), nullptr));
1129 audio_ssrc = 0; 1134 audio_ssrc = 0;
1130 video_ssrc = 0; 1135 video_ssrc = 0;
1131 EXPECT_TRUE(GetFirstSsrc(GetFirstAudioContent(answer->description()), 1136 EXPECT_TRUE(GetFirstSsrc(GetFirstAudioContent(answer->description()),
1132 &audio_ssrc)); 1137 &audio_ssrc));
1133 EXPECT_TRUE(GetFirstSsrc(GetFirstVideoContent(answer->description()), 1138 EXPECT_TRUE(GetFirstSsrc(GetFirstVideoContent(answer->description()),
1134 &video_ssrc)); 1139 &video_ssrc));
1135 EXPECT_NE(audio_ssrc, video_ssrc); 1140 EXPECT_NE(audio_ssrc, video_ssrc);
1136 } 1141 }
1137 1142
1138 // Test that we can specify a certain track that we want statistics about. 1143 // Test that we can specify a certain track that we want statistics about.
(...skipping 426 matching lines...) Expand 10 before | Expand all | Expand 10 after
1565 EXPECT_TRUE(DoSetSessionDescription(answer, false)); 1570 EXPECT_TRUE(DoSetSessionDescription(answer, false));
1566 1571
1567 SessionDescriptionInterface* updated_offer = 1572 SessionDescriptionInterface* updated_offer =
1568 webrtc::CreateSessionDescription(SessionDescriptionInterface::kOffer, 1573 webrtc::CreateSessionDescription(SessionDescriptionInterface::kOffer,
1569 webrtc::kAudioSdpWithUnsupportedCodecs, 1574 webrtc::kAudioSdpWithUnsupportedCodecs,
1570 nullptr); 1575 nullptr);
1571 EXPECT_TRUE(DoSetSessionDescription(updated_offer, false)); 1576 EXPECT_TRUE(DoSetSessionDescription(updated_offer, false));
1572 CreateAnswerAsLocalDescription(); 1577 CreateAnswerAsLocalDescription();
1573 } 1578 }
1574 1579
1580 // Test that if we're receiving (but not sending) a track, subsequent offers
1581 // will have m-lines with a=recvonly.
1582 TEST_F(PeerConnectionInterfaceTest, CreateSubsequentRecvOnlyOffer) {
1583 FakeConstraints constraints;
1584 constraints.AddMandatory(webrtc::MediaConstraintsInterface::kEnableDtlsSrtp,
1585 true);
1586 CreatePeerConnection(&constraints);
1587 CreateAndSetRemoteOffer(kSdpStringWithStream1);
1588 CreateAnswerAsLocalDescription();
1589
1590 // At this point we should be receiving stream 1, but not sending anything.
1591 // A new offer should be recvonly.
1592 SessionDescriptionInterface* offer;
1593 DoCreateOffer(&offer, nullptr);
1594
1595 const cricket::ContentInfo* video_content =
1596 cricket::GetFirstVideoContent(offer->description());
1597 const cricket::VideoContentDescription* video_desc =
1598 static_cast<const cricket::VideoContentDescription*>(
1599 video_content->description);
1600 ASSERT_EQ(cricket::MD_RECVONLY, video_desc->direction());
1601
1602 const cricket::ContentInfo* audio_content =
1603 cricket::GetFirstAudioContent(offer->description());
1604 const cricket::AudioContentDescription* audio_desc =
1605 static_cast<const cricket::AudioContentDescription*>(
1606 audio_content->description);
1607 ASSERT_EQ(cricket::MD_RECVONLY, audio_desc->direction());
1608 }
1609
1610 // Test that if we're receiving (but not sending) a track, and the
1611 // offerToReceiveVideo/offerToReceiveAudio constraints are explicitly set to
1612 // false, the generated m-lines will be a=inactive.
1613 TEST_F(PeerConnectionInterfaceTest, CreateSubsequentInactiveOffer) {
1614 FakeConstraints constraints;
1615 constraints.AddMandatory(webrtc::MediaConstraintsInterface::kEnableDtlsSrtp,
1616 true);
1617 CreatePeerConnection(&constraints);
1618 CreateAndSetRemoteOffer(kSdpStringWithStream1);
1619 CreateAnswerAsLocalDescription();
1620
1621 // At this point we should be receiving stream 1, but not sending anything.
1622 // A new offer would be recvonly, but we'll set the "no receive" constraints
1623 // to make it inactive.
1624 SessionDescriptionInterface* offer;
1625 FakeConstraints offer_constraints;
1626 offer_constraints.AddMandatory(
1627 webrtc::MediaConstraintsInterface::kOfferToReceiveVideo, false);
1628 offer_constraints.AddMandatory(
1629 webrtc::MediaConstraintsInterface::kOfferToReceiveAudio, false);
1630 DoCreateOffer(&offer, &offer_constraints);
1631
1632 const cricket::ContentInfo* video_content =
1633 cricket::GetFirstVideoContent(offer->description());
1634 const cricket::VideoContentDescription* video_desc =
1635 static_cast<const cricket::VideoContentDescription*>(
1636 video_content->description);
1637 ASSERT_EQ(cricket::MD_INACTIVE, video_desc->direction());
1638
1639 const cricket::ContentInfo* audio_content =
1640 cricket::GetFirstAudioContent(offer->description());
1641 const cricket::AudioContentDescription* audio_desc =
1642 static_cast<const cricket::AudioContentDescription*>(
1643 audio_content->description);
1644 ASSERT_EQ(cricket::MD_INACTIVE, audio_desc->direction());
1645 }
1646
1575 // Test that PeerConnection::Close changes the states to closed and all remote 1647 // Test that PeerConnection::Close changes the states to closed and all remote
1576 // tracks change state to ended. 1648 // tracks change state to ended.
1577 TEST_F(PeerConnectionInterfaceTest, CloseAndTestStreamsAndStates) { 1649 TEST_F(PeerConnectionInterfaceTest, CloseAndTestStreamsAndStates) {
1578 // Initialize a PeerConnection and negotiate local and remote session 1650 // Initialize a PeerConnection and negotiate local and remote session
1579 // description. 1651 // description.
1580 InitiateCall(); 1652 InitiateCall();
1581 ASSERT_EQ(1u, pc_->local_streams()->count()); 1653 ASSERT_EQ(1u, pc_->local_streams()->count());
1582 ASSERT_EQ(1u, pc_->remote_streams()->count()); 1654 ASSERT_EQ(1u, pc_->remote_streams()->count());
1583 1655
1584 pc_->Close(); 1656 pc_->Close();
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
1621 rtc::scoped_refptr<webrtc::DtmfSenderInterface> dtmf_sender( 1693 rtc::scoped_refptr<webrtc::DtmfSenderInterface> dtmf_sender(
1622 pc_->CreateDtmfSender(local_stream->GetAudioTracks()[0])); 1694 pc_->CreateDtmfSender(local_stream->GetAudioTracks()[0]));
1623 EXPECT_TRUE(NULL == dtmf_sender); // local stream has been removed. 1695 EXPECT_TRUE(NULL == dtmf_sender); // local stream has been removed.
1624 1696
1625 EXPECT_TRUE(pc_->CreateDataChannel("test", NULL) == NULL); 1697 EXPECT_TRUE(pc_->CreateDataChannel("test", NULL) == NULL);
1626 1698
1627 EXPECT_TRUE(pc_->local_description() != NULL); 1699 EXPECT_TRUE(pc_->local_description() != NULL);
1628 EXPECT_TRUE(pc_->remote_description() != NULL); 1700 EXPECT_TRUE(pc_->remote_description() != NULL);
1629 1701
1630 rtc::scoped_ptr<SessionDescriptionInterface> offer; 1702 rtc::scoped_ptr<SessionDescriptionInterface> offer;
1631 EXPECT_TRUE(DoCreateOffer(offer.use())); 1703 EXPECT_TRUE(DoCreateOffer(offer.use(), nullptr));
1632 rtc::scoped_ptr<SessionDescriptionInterface> answer; 1704 rtc::scoped_ptr<SessionDescriptionInterface> answer;
1633 EXPECT_TRUE(DoCreateAnswer(answer.use())); 1705 EXPECT_TRUE(DoCreateAnswer(answer.use(), nullptr));
1634 1706
1635 std::string sdp; 1707 std::string sdp;
1636 ASSERT_TRUE(pc_->remote_description()->ToString(&sdp)); 1708 ASSERT_TRUE(pc_->remote_description()->ToString(&sdp));
1637 SessionDescriptionInterface* remote_offer = 1709 SessionDescriptionInterface* remote_offer =
1638 webrtc::CreateSessionDescription(SessionDescriptionInterface::kOffer, 1710 webrtc::CreateSessionDescription(SessionDescriptionInterface::kOffer,
1639 sdp, NULL); 1711 sdp, NULL);
1640 EXPECT_FALSE(DoSetRemoteDescription(remote_offer)); 1712 EXPECT_FALSE(DoSetRemoteDescription(remote_offer));
1641 1713
1642 ASSERT_TRUE(pc_->local_description()->ToString(&sdp)); 1714 ASSERT_TRUE(pc_->local_description()->ToString(&sdp));
1643 SessionDescriptionInterface* local_offer = 1715 SessionDescriptionInterface* local_offer =
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
1727 ASSERT_EQ(1u, remote_stream->GetAudioTracks().size()); 1799 ASSERT_EQ(1u, remote_stream->GetAudioTracks().size());
1728 1800
1729 rtc::scoped_refptr<webrtc::VideoTrackInterface> remote_video = 1801 rtc::scoped_refptr<webrtc::VideoTrackInterface> remote_video =
1730 remote_stream->GetVideoTracks()[0]; 1802 remote_stream->GetVideoTracks()[0];
1731 EXPECT_EQ(webrtc::MediaStreamTrackInterface::kLive, remote_video->state()); 1803 EXPECT_EQ(webrtc::MediaStreamTrackInterface::kLive, remote_video->state());
1732 rtc::scoped_refptr<webrtc::AudioTrackInterface> remote_audio = 1804 rtc::scoped_refptr<webrtc::AudioTrackInterface> remote_audio =
1733 remote_stream->GetAudioTracks()[0]; 1805 remote_stream->GetAudioTracks()[0];
1734 EXPECT_EQ(webrtc::MediaStreamTrackInterface::kLive, remote_audio->state()); 1806 EXPECT_EQ(webrtc::MediaStreamTrackInterface::kLive, remote_audio->state());
1735 1807
1736 rtc::scoped_ptr<SessionDescriptionInterface> local_answer; 1808 rtc::scoped_ptr<SessionDescriptionInterface> local_answer;
1737 EXPECT_TRUE(DoCreateAnswer(local_answer.accept())); 1809 EXPECT_TRUE(DoCreateAnswer(local_answer.accept(), nullptr));
1738 cricket::ContentInfo* video_info = 1810 cricket::ContentInfo* video_info =
1739 local_answer->description()->GetContentByName("video"); 1811 local_answer->description()->GetContentByName("video");
1740 video_info->rejected = true; 1812 video_info->rejected = true;
1741 EXPECT_TRUE(DoSetLocalDescription(local_answer.release())); 1813 EXPECT_TRUE(DoSetLocalDescription(local_answer.release()));
1742 EXPECT_EQ(webrtc::MediaStreamTrackInterface::kEnded, remote_video->state()); 1814 EXPECT_EQ(webrtc::MediaStreamTrackInterface::kEnded, remote_video->state());
1743 EXPECT_EQ(webrtc::MediaStreamTrackInterface::kLive, remote_audio->state()); 1815 EXPECT_EQ(webrtc::MediaStreamTrackInterface::kLive, remote_audio->state());
1744 1816
1745 // Now create an offer where we reject both video and audio. 1817 // Now create an offer where we reject both video and audio.
1746 rtc::scoped_ptr<SessionDescriptionInterface> local_offer; 1818 rtc::scoped_ptr<SessionDescriptionInterface> local_offer;
1747 EXPECT_TRUE(DoCreateOffer(local_offer.accept())); 1819 EXPECT_TRUE(DoCreateOffer(local_offer.accept(), nullptr));
1748 video_info = local_offer->description()->GetContentByName("video"); 1820 video_info = local_offer->description()->GetContentByName("video");
1749 ASSERT_TRUE(video_info != nullptr); 1821 ASSERT_TRUE(video_info != nullptr);
1750 video_info->rejected = true; 1822 video_info->rejected = true;
1751 cricket::ContentInfo* audio_info = 1823 cricket::ContentInfo* audio_info =
1752 local_offer->description()->GetContentByName("audio"); 1824 local_offer->description()->GetContentByName("audio");
1753 ASSERT_TRUE(audio_info != nullptr); 1825 ASSERT_TRUE(audio_info != nullptr);
1754 audio_info->rejected = true; 1826 audio_info->rejected = true;
1755 EXPECT_TRUE(DoSetLocalDescription(local_offer.release())); 1827 EXPECT_TRUE(DoSetLocalDescription(local_offer.release()));
1756 EXPECT_EQ(webrtc::MediaStreamTrackInterface::kEnded, remote_video->state()); 1828 EXPECT_EQ(webrtc::MediaStreamTrackInterface::kEnded, remote_video->state());
1757 EXPECT_EQ(webrtc::MediaStreamTrackInterface::kEnded, remote_audio->state()); 1829 EXPECT_EQ(webrtc::MediaStreamTrackInterface::kEnded, remote_audio->state());
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
1893 // TODO(deadbeef): This test and the one below it need to be updated when 1965 // TODO(deadbeef): This test and the one below it need to be updated when
1894 // an RtpSender's lifetime isn't determined by when a local description is set. 1966 // an RtpSender's lifetime isn't determined by when a local description is set.
1895 TEST_F(PeerConnectionInterfaceTest, LocalDescriptionChanged) { 1967 TEST_F(PeerConnectionInterfaceTest, LocalDescriptionChanged) {
1896 FakeConstraints constraints; 1968 FakeConstraints constraints;
1897 constraints.AddMandatory(webrtc::MediaConstraintsInterface::kEnableDtlsSrtp, 1969 constraints.AddMandatory(webrtc::MediaConstraintsInterface::kEnableDtlsSrtp,
1898 true); 1970 true);
1899 CreatePeerConnection(&constraints); 1971 CreatePeerConnection(&constraints);
1900 // Create an offer just to ensure we have an identity before we manually 1972 // Create an offer just to ensure we have an identity before we manually
1901 // call SetLocalDescription. 1973 // call SetLocalDescription.
1902 rtc::scoped_ptr<SessionDescriptionInterface> throwaway; 1974 rtc::scoped_ptr<SessionDescriptionInterface> throwaway;
1903 ASSERT_TRUE(DoCreateOffer(throwaway.accept())); 1975 ASSERT_TRUE(DoCreateOffer(throwaway.accept(), nullptr));
1904 1976
1905 rtc::scoped_ptr<SessionDescriptionInterface> desc_1; 1977 rtc::scoped_ptr<SessionDescriptionInterface> desc_1;
1906 CreateSessionDescriptionAndReference(2, 2, desc_1.accept()); 1978 CreateSessionDescriptionAndReference(2, 2, desc_1.accept());
1907 1979
1908 pc_->AddStream(reference_collection_->at(0)); 1980 pc_->AddStream(reference_collection_->at(0));
1909 EXPECT_TRUE(DoSetLocalDescription(desc_1.release())); 1981 EXPECT_TRUE(DoSetLocalDescription(desc_1.release()));
1910 auto senders = pc_->GetSenders(); 1982 auto senders = pc_->GetSenders();
1911 EXPECT_EQ(4u, senders.size()); 1983 EXPECT_EQ(4u, senders.size());
1912 EXPECT_TRUE(ContainsSender(senders, kAudioTracks[0])); 1984 EXPECT_TRUE(ContainsSender(senders, kAudioTracks[0]));
1913 EXPECT_TRUE(ContainsSender(senders, kVideoTracks[0])); 1985 EXPECT_TRUE(ContainsSender(senders, kVideoTracks[0]));
(...skipping 16 matching lines...) Expand all
1930 // before adding a local stream. 2002 // before adding a local stream.
1931 TEST_F(PeerConnectionInterfaceTest, 2003 TEST_F(PeerConnectionInterfaceTest,
1932 AddLocalStreamAfterLocalDescriptionChanged) { 2004 AddLocalStreamAfterLocalDescriptionChanged) {
1933 FakeConstraints constraints; 2005 FakeConstraints constraints;
1934 constraints.AddMandatory(webrtc::MediaConstraintsInterface::kEnableDtlsSrtp, 2006 constraints.AddMandatory(webrtc::MediaConstraintsInterface::kEnableDtlsSrtp,
1935 true); 2007 true);
1936 CreatePeerConnection(&constraints); 2008 CreatePeerConnection(&constraints);
1937 // Create an offer just to ensure we have an identity before we manually 2009 // Create an offer just to ensure we have an identity before we manually
1938 // call SetLocalDescription. 2010 // call SetLocalDescription.
1939 rtc::scoped_ptr<SessionDescriptionInterface> throwaway; 2011 rtc::scoped_ptr<SessionDescriptionInterface> throwaway;
1940 ASSERT_TRUE(DoCreateOffer(throwaway.accept())); 2012 ASSERT_TRUE(DoCreateOffer(throwaway.accept(), nullptr));
1941 2013
1942 rtc::scoped_ptr<SessionDescriptionInterface> desc_1; 2014 rtc::scoped_ptr<SessionDescriptionInterface> desc_1;
1943 CreateSessionDescriptionAndReference(2, 2, desc_1.accept()); 2015 CreateSessionDescriptionAndReference(2, 2, desc_1.accept());
1944 2016
1945 EXPECT_TRUE(DoSetLocalDescription(desc_1.release())); 2017 EXPECT_TRUE(DoSetLocalDescription(desc_1.release()));
1946 auto senders = pc_->GetSenders(); 2018 auto senders = pc_->GetSenders();
1947 EXPECT_EQ(0u, senders.size()); 2019 EXPECT_EQ(0u, senders.size());
1948 2020
1949 pc_->AddStream(reference_collection_->at(0)); 2021 pc_->AddStream(reference_collection_->at(0));
1950 senders = pc_->GetSenders(); 2022 senders = pc_->GetSenders();
1951 EXPECT_EQ(4u, senders.size()); 2023 EXPECT_EQ(4u, senders.size());
1952 EXPECT_TRUE(ContainsSender(senders, kAudioTracks[0])); 2024 EXPECT_TRUE(ContainsSender(senders, kAudioTracks[0]));
1953 EXPECT_TRUE(ContainsSender(senders, kVideoTracks[0])); 2025 EXPECT_TRUE(ContainsSender(senders, kVideoTracks[0]));
1954 EXPECT_TRUE(ContainsSender(senders, kAudioTracks[1])); 2026 EXPECT_TRUE(ContainsSender(senders, kAudioTracks[1]));
1955 EXPECT_TRUE(ContainsSender(senders, kVideoTracks[1])); 2027 EXPECT_TRUE(ContainsSender(senders, kVideoTracks[1]));
1956 } 2028 }
1957 2029
1958 // This tests that the expected behavior occurs if the SSRC on a local track is 2030 // This tests that the expected behavior occurs if the SSRC on a local track is
1959 // changed when SetLocalDescription is called. 2031 // changed when SetLocalDescription is called.
1960 TEST_F(PeerConnectionInterfaceTest, 2032 TEST_F(PeerConnectionInterfaceTest,
1961 ChangeSsrcOnTrackInLocalSessionDescription) { 2033 ChangeSsrcOnTrackInLocalSessionDescription) {
1962 FakeConstraints constraints; 2034 FakeConstraints constraints;
1963 constraints.AddMandatory(webrtc::MediaConstraintsInterface::kEnableDtlsSrtp, 2035 constraints.AddMandatory(webrtc::MediaConstraintsInterface::kEnableDtlsSrtp,
1964 true); 2036 true);
1965 CreatePeerConnection(&constraints); 2037 CreatePeerConnection(&constraints);
1966 // Create an offer just to ensure we have an identity before we manually 2038 // Create an offer just to ensure we have an identity before we manually
1967 // call SetLocalDescription. 2039 // call SetLocalDescription.
1968 rtc::scoped_ptr<SessionDescriptionInterface> throwaway; 2040 rtc::scoped_ptr<SessionDescriptionInterface> throwaway;
1969 ASSERT_TRUE(DoCreateOffer(throwaway.accept())); 2041 ASSERT_TRUE(DoCreateOffer(throwaway.accept(), nullptr));
1970 2042
1971 rtc::scoped_ptr<SessionDescriptionInterface> desc; 2043 rtc::scoped_ptr<SessionDescriptionInterface> desc;
1972 CreateSessionDescriptionAndReference(1, 1, desc.accept()); 2044 CreateSessionDescriptionAndReference(1, 1, desc.accept());
1973 std::string sdp; 2045 std::string sdp;
1974 desc->ToString(&sdp); 2046 desc->ToString(&sdp);
1975 2047
1976 pc_->AddStream(reference_collection_->at(0)); 2048 pc_->AddStream(reference_collection_->at(0));
1977 EXPECT_TRUE(DoSetLocalDescription(desc.release())); 2049 EXPECT_TRUE(DoSetLocalDescription(desc.release()));
1978 auto senders = pc_->GetSenders(); 2050 auto senders = pc_->GetSenders();
1979 EXPECT_EQ(2u, senders.size()); 2051 EXPECT_EQ(2u, senders.size());
(...skipping 25 matching lines...) Expand all
2005 // This tests that the expected behavior occurs if a new session description is 2077 // This tests that the expected behavior occurs if a new session description is
2006 // set with the same tracks, but on a different MediaStream. 2078 // set with the same tracks, but on a different MediaStream.
2007 TEST_F(PeerConnectionInterfaceTest, SignalSameTracksInSeparateMediaStream) { 2079 TEST_F(PeerConnectionInterfaceTest, SignalSameTracksInSeparateMediaStream) {
2008 FakeConstraints constraints; 2080 FakeConstraints constraints;
2009 constraints.AddMandatory(webrtc::MediaConstraintsInterface::kEnableDtlsSrtp, 2081 constraints.AddMandatory(webrtc::MediaConstraintsInterface::kEnableDtlsSrtp,
2010 true); 2082 true);
2011 CreatePeerConnection(&constraints); 2083 CreatePeerConnection(&constraints);
2012 // Create an offer just to ensure we have an identity before we manually 2084 // Create an offer just to ensure we have an identity before we manually
2013 // call SetLocalDescription. 2085 // call SetLocalDescription.
2014 rtc::scoped_ptr<SessionDescriptionInterface> throwaway; 2086 rtc::scoped_ptr<SessionDescriptionInterface> throwaway;
2015 ASSERT_TRUE(DoCreateOffer(throwaway.accept())); 2087 ASSERT_TRUE(DoCreateOffer(throwaway.accept(), nullptr));
2016 2088
2017 rtc::scoped_ptr<SessionDescriptionInterface> desc; 2089 rtc::scoped_ptr<SessionDescriptionInterface> desc;
2018 CreateSessionDescriptionAndReference(1, 1, desc.accept()); 2090 CreateSessionDescriptionAndReference(1, 1, desc.accept());
2019 std::string sdp; 2091 std::string sdp;
2020 desc->ToString(&sdp); 2092 desc->ToString(&sdp);
2021 2093
2022 pc_->AddStream(reference_collection_->at(0)); 2094 pc_->AddStream(reference_collection_->at(0));
2023 EXPECT_TRUE(DoSetLocalDescription(desc.release())); 2095 EXPECT_TRUE(DoSetLocalDescription(desc.release()));
2024 auto senders = pc_->GetSenders(); 2096 auto senders = pc_->GetSenders();
2025 EXPECT_EQ(2u, senders.size()); 2097 EXPECT_EQ(2u, senders.size());
(...skipping 16 matching lines...) Expand all
2042 nullptr)); 2114 nullptr));
2043 2115
2044 EXPECT_TRUE(DoSetLocalDescription(updated_desc.release())); 2116 EXPECT_TRUE(DoSetLocalDescription(updated_desc.release()));
2045 senders = pc_->GetSenders(); 2117 senders = pc_->GetSenders();
2046 EXPECT_EQ(2u, senders.size()); 2118 EXPECT_EQ(2u, senders.size());
2047 EXPECT_TRUE(ContainsSender(senders, kAudioTracks[0])); 2119 EXPECT_TRUE(ContainsSender(senders, kAudioTracks[0]));
2048 EXPECT_TRUE(ContainsSender(senders, kVideoTracks[0])); 2120 EXPECT_TRUE(ContainsSender(senders, kVideoTracks[0]));
2049 } 2121 }
2050 2122
2051 // The following tests verify that session options are created correctly. 2123 // The following tests verify that session options are created correctly.
2124 // TODO(deadbeef): Convert these tests to be more end-to-end. Instead of
2125 // "verify options are converted correctly", should be "pass options into
2126 // CreateOffer and verify the correct offer is produced."
2052 2127
2053 TEST(CreateSessionOptionsTest, GetOptionsForOfferWithInvalidAudioOption) { 2128 TEST(CreateSessionOptionsTest, GetOptionsForOfferWithInvalidAudioOption) {
2054 RTCOfferAnswerOptions rtc_options; 2129 RTCOfferAnswerOptions rtc_options;
2055 rtc_options.offer_to_receive_audio = RTCOfferAnswerOptions::kUndefined - 1; 2130 rtc_options.offer_to_receive_audio = RTCOfferAnswerOptions::kUndefined - 1;
2056 2131
2057 cricket::MediaSessionOptions options; 2132 cricket::MediaSessionOptions options;
2058 EXPECT_FALSE(ConvertRtcOptionsForOffer(rtc_options, &options)); 2133 EXPECT_FALSE(ConvertRtcOptionsForOffer(rtc_options, &options));
2059 2134
2060 rtc_options.offer_to_receive_audio = 2135 rtc_options.offer_to_receive_audio =
2061 RTCOfferAnswerOptions::kMaxOfferToReceiveMedia + 1; 2136 RTCOfferAnswerOptions::kMaxOfferToReceiveMedia + 1;
2062 EXPECT_FALSE(ConvertRtcOptionsForOffer(rtc_options, &options)); 2137 EXPECT_FALSE(ConvertRtcOptionsForOffer(rtc_options, &options));
2063 } 2138 }
2064 2139
2065 TEST(CreateSessionOptionsTest, GetOptionsForOfferWithInvalidVideoOption) { 2140 TEST(CreateSessionOptionsTest, GetOptionsForOfferWithInvalidVideoOption) {
2066 RTCOfferAnswerOptions rtc_options; 2141 RTCOfferAnswerOptions rtc_options;
2067 rtc_options.offer_to_receive_video = RTCOfferAnswerOptions::kUndefined - 1; 2142 rtc_options.offer_to_receive_video = RTCOfferAnswerOptions::kUndefined - 1;
2068 2143
2069 cricket::MediaSessionOptions options; 2144 cricket::MediaSessionOptions options;
2070 EXPECT_FALSE(ConvertRtcOptionsForOffer(rtc_options, &options)); 2145 EXPECT_FALSE(ConvertRtcOptionsForOffer(rtc_options, &options));
2071 2146
2072 rtc_options.offer_to_receive_video = 2147 rtc_options.offer_to_receive_video =
2073 RTCOfferAnswerOptions::kMaxOfferToReceiveMedia + 1; 2148 RTCOfferAnswerOptions::kMaxOfferToReceiveMedia + 1;
2074 EXPECT_FALSE(ConvertRtcOptionsForOffer(rtc_options, &options)); 2149 EXPECT_FALSE(ConvertRtcOptionsForOffer(rtc_options, &options));
2075 } 2150 }
2076 2151
2077 // Test that a MediaSessionOptions is created for an offer if 2152 // Test that a MediaSessionOptions is created for an offer if
2078 // OfferToReceiveAudio and OfferToReceiveVideo options are set but no 2153 // OfferToReceiveAudio and OfferToReceiveVideo options are set.
2079 // MediaStreams are sent.
2080 TEST(CreateSessionOptionsTest, GetMediaSessionOptionsForOfferWithAudioVideo) { 2154 TEST(CreateSessionOptionsTest, GetMediaSessionOptionsForOfferWithAudioVideo) {
2081 RTCOfferAnswerOptions rtc_options; 2155 RTCOfferAnswerOptions rtc_options;
2082 rtc_options.offer_to_receive_audio = 1; 2156 rtc_options.offer_to_receive_audio = 1;
2083 rtc_options.offer_to_receive_video = 1; 2157 rtc_options.offer_to_receive_video = 1;
2084 2158
2085 cricket::MediaSessionOptions options; 2159 cricket::MediaSessionOptions options;
2086 EXPECT_TRUE(ConvertRtcOptionsForOffer(rtc_options, &options)); 2160 EXPECT_TRUE(ConvertRtcOptionsForOffer(rtc_options, &options));
2087 EXPECT_TRUE(options.has_audio()); 2161 EXPECT_TRUE(options.has_audio());
2088 EXPECT_TRUE(options.has_video()); 2162 EXPECT_TRUE(options.has_video());
2089 EXPECT_TRUE(options.bundle_enabled); 2163 EXPECT_TRUE(options.bundle_enabled);
2090 } 2164 }
2091 2165
2092 // Test that a correct MediaSessionOptions is created for an offer if 2166 // Test that a correct MediaSessionOptions is created for an offer if
2093 // OfferToReceiveAudio is set but no MediaStreams are sent. 2167 // OfferToReceiveAudio is set.
2094 TEST(CreateSessionOptionsTest, GetMediaSessionOptionsForOfferWithAudio) { 2168 TEST(CreateSessionOptionsTest, GetMediaSessionOptionsForOfferWithAudio) {
2095 RTCOfferAnswerOptions rtc_options; 2169 RTCOfferAnswerOptions rtc_options;
2096 rtc_options.offer_to_receive_audio = 1; 2170 rtc_options.offer_to_receive_audio = 1;
2097 2171
2098 cricket::MediaSessionOptions options; 2172 cricket::MediaSessionOptions options;
2099 EXPECT_TRUE(ConvertRtcOptionsForOffer(rtc_options, &options)); 2173 EXPECT_TRUE(ConvertRtcOptionsForOffer(rtc_options, &options));
2100 EXPECT_TRUE(options.has_audio()); 2174 EXPECT_TRUE(options.has_audio());
2101 EXPECT_FALSE(options.has_video()); 2175 EXPECT_FALSE(options.has_video());
2102 EXPECT_TRUE(options.bundle_enabled); 2176 EXPECT_TRUE(options.bundle_enabled);
2103 } 2177 }
2104 2178
2105 // Test that a correct MediaSessionOptions is created for an offer if 2179 // Test that a correct MediaSessionOptions is created for an offer if
2106 // the default OfferOptons is used or MediaStreams are sent. 2180 // the default OfferOptions are used.
2107 TEST(CreateSessionOptionsTest, GetDefaultMediaSessionOptionsForOffer) { 2181 TEST(CreateSessionOptionsTest, GetDefaultMediaSessionOptionsForOffer) {
2108 RTCOfferAnswerOptions rtc_options; 2182 RTCOfferAnswerOptions rtc_options;
2109 2183
2110 cricket::MediaSessionOptions options; 2184 cricket::MediaSessionOptions options;
2111 EXPECT_TRUE(ConvertRtcOptionsForOffer(rtc_options, &options)); 2185 EXPECT_TRUE(ConvertRtcOptionsForOffer(rtc_options, &options));
2112 EXPECT_FALSE(options.has_audio()); 2186 EXPECT_TRUE(options.has_audio());
2113 EXPECT_FALSE(options.has_video()); 2187 EXPECT_FALSE(options.has_video());
2114 EXPECT_FALSE(options.bundle_enabled); 2188 EXPECT_TRUE(options.bundle_enabled);
2115 EXPECT_TRUE(options.vad_enabled); 2189 EXPECT_TRUE(options.vad_enabled);
2116 EXPECT_FALSE(options.transport_options.ice_restart); 2190 EXPECT_FALSE(options.transport_options.ice_restart);
2117 } 2191 }
2118 2192
2119 // Test that a correct MediaSessionOptions is created for an offer if 2193 // Test that a correct MediaSessionOptions is created for an offer if
2120 // OfferToReceiveVideo is set but no MediaStreams are sent. 2194 // OfferToReceiveVideo is set.
2121 TEST(CreateSessionOptionsTest, GetMediaSessionOptionsForOfferWithVideo) { 2195 TEST(CreateSessionOptionsTest, GetMediaSessionOptionsForOfferWithVideo) {
2122 RTCOfferAnswerOptions rtc_options; 2196 RTCOfferAnswerOptions rtc_options;
2123 rtc_options.offer_to_receive_audio = 0; 2197 rtc_options.offer_to_receive_audio = 0;
2124 rtc_options.offer_to_receive_video = 1; 2198 rtc_options.offer_to_receive_video = 1;
2125 2199
2126 cricket::MediaSessionOptions options; 2200 cricket::MediaSessionOptions options;
2127 EXPECT_TRUE(ConvertRtcOptionsForOffer(rtc_options, &options)); 2201 EXPECT_TRUE(ConvertRtcOptionsForOffer(rtc_options, &options));
2128 EXPECT_FALSE(options.has_audio()); 2202 EXPECT_FALSE(options.has_audio());
2129 EXPECT_TRUE(options.has_video()); 2203 EXPECT_TRUE(options.has_video());
2130 EXPECT_TRUE(options.bundle_enabled); 2204 EXPECT_TRUE(options.bundle_enabled);
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
2169 TEST(CreateSessionOptionsTest, MediaConstraintsInAnswer) { 2243 TEST(CreateSessionOptionsTest, MediaConstraintsInAnswer) {
2170 FakeConstraints answer_c; 2244 FakeConstraints answer_c;
2171 answer_c.SetMandatoryReceiveAudio(true); 2245 answer_c.SetMandatoryReceiveAudio(true);
2172 answer_c.SetMandatoryReceiveVideo(true); 2246 answer_c.SetMandatoryReceiveVideo(true);
2173 2247
2174 cricket::MediaSessionOptions answer_options; 2248 cricket::MediaSessionOptions answer_options;
2175 EXPECT_TRUE(ParseConstraintsForAnswer(&answer_c, &answer_options)); 2249 EXPECT_TRUE(ParseConstraintsForAnswer(&answer_c, &answer_options));
2176 EXPECT_TRUE(answer_options.has_audio()); 2250 EXPECT_TRUE(answer_options.has_audio());
2177 EXPECT_TRUE(answer_options.has_video()); 2251 EXPECT_TRUE(answer_options.has_video());
2178 2252
2179 RTCOfferAnswerOptions rtc_offer_optoins; 2253 RTCOfferAnswerOptions rtc_offer_options;
2180 2254
2181 cricket::MediaSessionOptions offer_options; 2255 cricket::MediaSessionOptions offer_options;
2182 EXPECT_TRUE(ConvertRtcOptionsForOffer(rtc_offer_optoins, &offer_options)); 2256 EXPECT_TRUE(ConvertRtcOptionsForOffer(rtc_offer_options, &offer_options));
2183 EXPECT_FALSE(offer_options.has_audio()); 2257 EXPECT_TRUE(offer_options.has_audio());
2184 EXPECT_FALSE(offer_options.has_video()); 2258 EXPECT_FALSE(offer_options.has_video());
2185 2259
2186 RTCOfferAnswerOptions updated_rtc_offer_optoins; 2260 RTCOfferAnswerOptions updated_rtc_offer_options;
2187 updated_rtc_offer_optoins.offer_to_receive_audio = 1; 2261 updated_rtc_offer_options.offer_to_receive_audio = 1;
2188 updated_rtc_offer_optoins.offer_to_receive_video = 1; 2262 updated_rtc_offer_options.offer_to_receive_video = 1;
2189 2263
2190 cricket::MediaSessionOptions updated_offer_options; 2264 cricket::MediaSessionOptions updated_offer_options;
2191 EXPECT_TRUE(ConvertRtcOptionsForOffer(updated_rtc_offer_optoins, 2265 EXPECT_TRUE(ConvertRtcOptionsForOffer(updated_rtc_offer_options,
2192 &updated_offer_options)); 2266 &updated_offer_options));
2193 EXPECT_TRUE(updated_offer_options.has_audio()); 2267 EXPECT_TRUE(updated_offer_options.has_audio());
2194 EXPECT_TRUE(updated_offer_options.has_video()); 2268 EXPECT_TRUE(updated_offer_options.has_video());
2195 2269
2196 // Since an offer has been created with both audio and video, subsequent 2270 // Since an offer has been created with both audio and video, subsequent
2197 // offers and answers should contain both audio and video. 2271 // offers and answers should contain both audio and video.
2198 // Answers will only contain the media types that exist in the offer 2272 // Answers will only contain the media types that exist in the offer
2199 // regardless of the value of |updated_answer_options.has_audio| and 2273 // regardless of the value of |updated_answer_options.has_audio| and
2200 // |updated_answer_options.has_video|. 2274 // |updated_answer_options.has_video|.
2201 FakeConstraints updated_answer_c; 2275 FakeConstraints updated_answer_c;
2202 answer_c.SetMandatoryReceiveAudio(false); 2276 answer_c.SetMandatoryReceiveAudio(false);
2203 answer_c.SetMandatoryReceiveVideo(false); 2277 answer_c.SetMandatoryReceiveVideo(false);
2204 2278
2205 cricket::MediaSessionOptions updated_answer_options; 2279 cricket::MediaSessionOptions updated_answer_options;
2206 EXPECT_TRUE( 2280 EXPECT_TRUE(
2207 ParseConstraintsForAnswer(&updated_answer_c, &updated_answer_options)); 2281 ParseConstraintsForAnswer(&updated_answer_c, &updated_answer_options));
2208 EXPECT_TRUE(updated_answer_options.has_audio()); 2282 EXPECT_TRUE(updated_answer_options.has_audio());
2209 EXPECT_TRUE(updated_answer_options.has_video()); 2283 EXPECT_TRUE(updated_answer_options.has_video());
2210
2211 RTCOfferAnswerOptions default_rtc_options;
2212 EXPECT_TRUE(
2213 ConvertRtcOptionsForOffer(default_rtc_options, &updated_offer_options));
2214 // By default, |has_audio| or |has_video| are false if there is no media
2215 // track.
2216 EXPECT_FALSE(updated_offer_options.has_audio());
2217 EXPECT_FALSE(updated_offer_options.has_video());
2218 } 2284 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698