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 567 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
578 ice_complete_ = new_state == PeerConnectionInterface::kIceGatheringComplete; | 578 ice_complete_ = new_state == PeerConnectionInterface::kIceGatheringComplete; |
579 callback_triggered_ = true; | 579 callback_triggered_ = true; |
580 } | 580 } |
581 void OnIceCandidate(const webrtc::IceCandidateInterface* candidate) override { | 581 void OnIceCandidate(const webrtc::IceCandidateInterface* candidate) override { |
582 EXPECT_NE(PeerConnectionInterface::kIceGatheringNew, | 582 EXPECT_NE(PeerConnectionInterface::kIceGatheringNew, |
583 pc_->ice_gathering_state()); | 583 pc_->ice_gathering_state()); |
584 | 584 |
585 std::string sdp; | 585 std::string sdp; |
586 EXPECT_TRUE(candidate->ToString(&sdp)); | 586 EXPECT_TRUE(candidate->ToString(&sdp)); |
587 EXPECT_LT(0u, sdp.size()); | 587 EXPECT_LT(0u, sdp.size()); |
588 last_candidate_.reset(webrtc::CreateIceCandidate(candidate->sdp_mid(), | 588 last_candidate_.reset(webrtc::CreateIceCandidate( |
589 candidate->sdp_mline_index(), sdp, NULL)); | 589 candidate->sdp_mid(), candidate->sdp_mline_index(), sdp, nullptr)); |
590 EXPECT_TRUE(last_candidate_.get() != NULL); | 590 EXPECT_TRUE(last_candidate_.get() != nullptr); |
591 callback_triggered_ = true; | 591 callback_triggered_ = true; |
592 } | 592 } |
593 | 593 |
594 void OnIceCandidatesRemoved( | 594 void OnIceCandidatesRemoved( |
595 const std::vector<cricket::Candidate>& candidates) override { | 595 const std::vector<cricket::Candidate>& candidates) override { |
596 callback_triggered_ = true; | 596 callback_triggered_ = true; |
597 } | 597 } |
598 | 598 |
599 void OnIceConnectionReceivingChange(bool receiving) override { | 599 void OnIceConnectionReceivingChange(bool receiving) override { |
600 callback_triggered_ = true; | 600 callback_triggered_ = true; |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
744 if (FindConstraint(constraints, | 744 if (FindConstraint(constraints, |
745 webrtc::MediaConstraintsInterface::kEnableDtlsSrtp, | 745 webrtc::MediaConstraintsInterface::kEnableDtlsSrtp, |
746 &dtls, | 746 &dtls, |
747 nullptr) && dtls) { | 747 nullptr) && dtls) { |
748 fake_certificate_generator_ = new FakeRTCCertificateGenerator(); | 748 fake_certificate_generator_ = new FakeRTCCertificateGenerator(); |
749 cert_generator.reset(fake_certificate_generator_); | 749 cert_generator.reset(fake_certificate_generator_); |
750 } | 750 } |
751 pc_ = pc_factory_->CreatePeerConnection( | 751 pc_ = pc_factory_->CreatePeerConnection( |
752 config, constraints, std::move(port_allocator), | 752 config, constraints, std::move(port_allocator), |
753 std::move(cert_generator), &observer_); | 753 std::move(cert_generator), &observer_); |
754 ASSERT_TRUE(pc_.get() != NULL); | 754 ASSERT_TRUE(pc_.get() != nullptr); |
755 observer_.SetPeerConnectionInterface(pc_.get()); | 755 observer_.SetPeerConnectionInterface(pc_.get()); |
756 EXPECT_EQ(PeerConnectionInterface::kStable, observer_.state_); | 756 EXPECT_EQ(PeerConnectionInterface::kStable, observer_.state_); |
757 } | 757 } |
758 | 758 |
759 void CreatePeerConnectionExpectFail(const std::string& uri) { | 759 void CreatePeerConnectionExpectFail(const std::string& uri) { |
760 PeerConnectionInterface::RTCConfiguration config; | 760 PeerConnectionInterface::RTCConfiguration config; |
761 PeerConnectionInterface::IceServer server; | 761 PeerConnectionInterface::IceServer server; |
762 server.uri = uri; | 762 server.uri = uri; |
763 config.servers.push_back(server); | 763 config.servers.push_back(server); |
764 | 764 |
(...skipping 20 matching lines...) Expand all Loading... |
785 EXPECT_EQ(1u, port_allocator_->turn_servers().size()); | 785 EXPECT_EQ(1u, port_allocator_->turn_servers().size()); |
786 EXPECT_EQ(kTurnUsername, | 786 EXPECT_EQ(kTurnUsername, |
787 port_allocator_->turn_servers()[0].credentials.username); | 787 port_allocator_->turn_servers()[0].credentials.username); |
788 EXPECT_EQ(kTurnPassword, | 788 EXPECT_EQ(kTurnPassword, |
789 port_allocator_->turn_servers()[0].credentials.password); | 789 port_allocator_->turn_servers()[0].credentials.password); |
790 EXPECT_EQ(kTurnHostname, | 790 EXPECT_EQ(kTurnHostname, |
791 port_allocator_->turn_servers()[0].ports[0].address.hostname()); | 791 port_allocator_->turn_servers()[0].ports[0].address.hostname()); |
792 } | 792 } |
793 | 793 |
794 void ReleasePeerConnection() { | 794 void ReleasePeerConnection() { |
795 pc_ = NULL; | 795 pc_ = nullptr; |
796 observer_.SetPeerConnectionInterface(NULL); | 796 observer_.SetPeerConnectionInterface(nullptr); |
797 } | 797 } |
798 | 798 |
799 void AddVideoStream(const std::string& label) { | 799 void AddVideoStream(const std::string& label) { |
800 // Create a local stream. | 800 // Create a local stream. |
801 rtc::scoped_refptr<MediaStreamInterface> stream( | 801 rtc::scoped_refptr<MediaStreamInterface> stream( |
802 pc_factory_->CreateLocalMediaStream(label)); | 802 pc_factory_->CreateLocalMediaStream(label)); |
803 rtc::scoped_refptr<VideoTrackSourceInterface> video_source( | 803 rtc::scoped_refptr<VideoTrackSourceInterface> video_source( |
804 pc_factory_->CreateVideoSource(new cricket::FakeVideoCapturer(), NULL)); | 804 pc_factory_->CreateVideoSource(new cricket::FakeVideoCapturer(), |
| 805 nullptr)); |
805 rtc::scoped_refptr<VideoTrackInterface> video_track( | 806 rtc::scoped_refptr<VideoTrackInterface> video_track( |
806 pc_factory_->CreateVideoTrack(label + "v0", video_source)); | 807 pc_factory_->CreateVideoTrack(label + "v0", video_source)); |
807 stream->AddTrack(video_track.get()); | 808 stream->AddTrack(video_track.get()); |
808 EXPECT_TRUE(pc_->AddStream(stream)); | 809 EXPECT_TRUE(pc_->AddStream(stream)); |
809 EXPECT_TRUE_WAIT(observer_.renegotiation_needed_, kTimeout); | 810 EXPECT_TRUE_WAIT(observer_.renegotiation_needed_, kTimeout); |
810 observer_.renegotiation_needed_ = false; | 811 observer_.renegotiation_needed_ = false; |
811 } | 812 } |
812 | 813 |
813 void AddVoiceStream(const std::string& label) { | 814 void AddVoiceStream(const std::string& label) { |
814 // Create a local stream. | 815 // Create a local stream. |
815 rtc::scoped_refptr<MediaStreamInterface> stream( | 816 rtc::scoped_refptr<MediaStreamInterface> stream( |
816 pc_factory_->CreateLocalMediaStream(label)); | 817 pc_factory_->CreateLocalMediaStream(label)); |
817 rtc::scoped_refptr<AudioTrackInterface> audio_track( | 818 rtc::scoped_refptr<AudioTrackInterface> audio_track( |
818 pc_factory_->CreateAudioTrack(label + "a0", NULL)); | 819 pc_factory_->CreateAudioTrack(label + "a0", nullptr)); |
819 stream->AddTrack(audio_track.get()); | 820 stream->AddTrack(audio_track.get()); |
820 EXPECT_TRUE(pc_->AddStream(stream)); | 821 EXPECT_TRUE(pc_->AddStream(stream)); |
821 EXPECT_TRUE_WAIT(observer_.renegotiation_needed_, kTimeout); | 822 EXPECT_TRUE_WAIT(observer_.renegotiation_needed_, kTimeout); |
822 observer_.renegotiation_needed_ = false; | 823 observer_.renegotiation_needed_ = false; |
823 } | 824 } |
824 | 825 |
825 void AddAudioVideoStream(const std::string& stream_label, | 826 void AddAudioVideoStream(const std::string& stream_label, |
826 const std::string& audio_track_label, | 827 const std::string& audio_track_label, |
827 const std::string& video_track_label) { | 828 const std::string& video_track_label) { |
828 // Create a local stream. | 829 // Create a local stream. |
829 rtc::scoped_refptr<MediaStreamInterface> stream( | 830 rtc::scoped_refptr<MediaStreamInterface> stream( |
830 pc_factory_->CreateLocalMediaStream(stream_label)); | 831 pc_factory_->CreateLocalMediaStream(stream_label)); |
831 rtc::scoped_refptr<AudioTrackInterface> audio_track( | 832 rtc::scoped_refptr<AudioTrackInterface> audio_track( |
832 pc_factory_->CreateAudioTrack( | 833 pc_factory_->CreateAudioTrack( |
833 audio_track_label, static_cast<AudioSourceInterface*>(NULL))); | 834 audio_track_label, static_cast<AudioSourceInterface*>(nullptr))); |
834 stream->AddTrack(audio_track.get()); | 835 stream->AddTrack(audio_track.get()); |
835 rtc::scoped_refptr<VideoTrackInterface> video_track( | 836 rtc::scoped_refptr<VideoTrackInterface> video_track( |
836 pc_factory_->CreateVideoTrack( | 837 pc_factory_->CreateVideoTrack( |
837 video_track_label, | 838 video_track_label, |
838 pc_factory_->CreateVideoSource(new cricket::FakeVideoCapturer()))); | 839 pc_factory_->CreateVideoSource(new cricket::FakeVideoCapturer()))); |
839 stream->AddTrack(video_track.get()); | 840 stream->AddTrack(video_track.get()); |
840 EXPECT_TRUE(pc_->AddStream(stream)); | 841 EXPECT_TRUE(pc_->AddStream(stream)); |
841 EXPECT_TRUE_WAIT(observer_.renegotiation_needed_, kTimeout); | 842 EXPECT_TRUE_WAIT(observer_.renegotiation_needed_, kTimeout); |
842 observer_.renegotiation_needed_ = false; | 843 observer_.renegotiation_needed_ = false; |
843 } | 844 } |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
909 // Create a local stream with audio&video tracks. | 910 // Create a local stream with audio&video tracks. |
910 AddAudioVideoStream(kStreamLabel1, "audio_label", "video_label"); | 911 AddAudioVideoStream(kStreamLabel1, "audio_label", "video_label"); |
911 CreateOfferReceiveAnswer(); | 912 CreateOfferReceiveAnswer(); |
912 } | 913 } |
913 | 914 |
914 // Verify that RTP Header extensions has been negotiated for audio and video. | 915 // Verify that RTP Header extensions has been negotiated for audio and video. |
915 void VerifyRemoteRtpHeaderExtensions() { | 916 void VerifyRemoteRtpHeaderExtensions() { |
916 const cricket::MediaContentDescription* desc = | 917 const cricket::MediaContentDescription* desc = |
917 cricket::GetFirstAudioContentDescription( | 918 cricket::GetFirstAudioContentDescription( |
918 pc_->remote_description()->description()); | 919 pc_->remote_description()->description()); |
919 ASSERT_TRUE(desc != NULL); | 920 ASSERT_TRUE(desc != nullptr); |
920 EXPECT_GT(desc->rtp_header_extensions().size(), 0u); | 921 EXPECT_GT(desc->rtp_header_extensions().size(), 0u); |
921 | 922 |
922 desc = cricket::GetFirstVideoContentDescription( | 923 desc = cricket::GetFirstVideoContentDescription( |
923 pc_->remote_description()->description()); | 924 pc_->remote_description()->description()); |
924 ASSERT_TRUE(desc != NULL); | 925 ASSERT_TRUE(desc != nullptr); |
925 EXPECT_GT(desc->rtp_header_extensions().size(), 0u); | 926 EXPECT_GT(desc->rtp_header_extensions().size(), 0u); |
926 } | 927 } |
927 | 928 |
928 void CreateOfferAsRemoteDescription() { | 929 void CreateOfferAsRemoteDescription() { |
929 std::unique_ptr<SessionDescriptionInterface> offer; | 930 std::unique_ptr<SessionDescriptionInterface> offer; |
930 ASSERT_TRUE(DoCreateOffer(&offer, nullptr)); | 931 ASSERT_TRUE(DoCreateOffer(&offer, nullptr)); |
931 std::string sdp; | 932 std::string sdp; |
932 EXPECT_TRUE(offer->ToString(&sdp)); | 933 EXPECT_TRUE(offer->ToString(&sdp)); |
933 SessionDescriptionInterface* remote_offer = | 934 SessionDescriptionInterface* remote_offer = |
934 webrtc::CreateSessionDescription(SessionDescriptionInterface::kOffer, | 935 webrtc::CreateSessionDescription(SessionDescriptionInterface::kOffer, |
935 sdp, NULL); | 936 sdp, nullptr); |
936 EXPECT_TRUE(DoSetRemoteDescription(remote_offer)); | 937 EXPECT_TRUE(DoSetRemoteDescription(remote_offer)); |
937 EXPECT_EQ(PeerConnectionInterface::kHaveRemoteOffer, observer_.state_); | 938 EXPECT_EQ(PeerConnectionInterface::kHaveRemoteOffer, observer_.state_); |
938 } | 939 } |
939 | 940 |
940 void CreateAndSetRemoteOffer(const std::string& sdp) { | 941 void CreateAndSetRemoteOffer(const std::string& sdp) { |
941 SessionDescriptionInterface* remote_offer = | 942 SessionDescriptionInterface* remote_offer = |
942 webrtc::CreateSessionDescription(SessionDescriptionInterface::kOffer, | 943 webrtc::CreateSessionDescription(SessionDescriptionInterface::kOffer, |
943 sdp, nullptr); | 944 sdp, nullptr); |
944 EXPECT_TRUE(DoSetRemoteDescription(remote_offer)); | 945 EXPECT_TRUE(DoSetRemoteDescription(remote_offer)); |
945 EXPECT_EQ(PeerConnectionInterface::kHaveRemoteOffer, observer_.state_); | 946 EXPECT_EQ(PeerConnectionInterface::kHaveRemoteOffer, observer_.state_); |
946 } | 947 } |
947 | 948 |
948 void CreateAnswerAsLocalDescription() { | 949 void CreateAnswerAsLocalDescription() { |
949 std::unique_ptr<SessionDescriptionInterface> answer; | 950 std::unique_ptr<SessionDescriptionInterface> answer; |
950 ASSERT_TRUE(DoCreateAnswer(&answer, nullptr)); | 951 ASSERT_TRUE(DoCreateAnswer(&answer, nullptr)); |
951 | 952 |
952 // TODO(perkj): Currently SetLocalDescription fails if any parameters in an | 953 // TODO(perkj): Currently SetLocalDescription fails if any parameters in an |
953 // audio codec change, even if the parameter has nothing to do with | 954 // audio codec change, even if the parameter has nothing to do with |
954 // receiving. Not all parameters are serialized to SDP. | 955 // receiving. Not all parameters are serialized to SDP. |
955 // Since CreatePrAnswerAsLocalDescription serialize/deserialize | 956 // Since CreatePrAnswerAsLocalDescription serialize/deserialize |
956 // the SessionDescription, it is necessary to do that here to in order to | 957 // the SessionDescription, it is necessary to do that here to in order to |
957 // get ReceiveOfferCreatePrAnswerAndAnswer and RenegotiateAudioOnly to pass. | 958 // get ReceiveOfferCreatePrAnswerAndAnswer and RenegotiateAudioOnly to pass. |
958 // https://code.google.com/p/webrtc/issues/detail?id=1356 | 959 // https://code.google.com/p/webrtc/issues/detail?id=1356 |
959 std::string sdp; | 960 std::string sdp; |
960 EXPECT_TRUE(answer->ToString(&sdp)); | 961 EXPECT_TRUE(answer->ToString(&sdp)); |
961 SessionDescriptionInterface* new_answer = | 962 SessionDescriptionInterface* new_answer = webrtc::CreateSessionDescription( |
962 webrtc::CreateSessionDescription(SessionDescriptionInterface::kAnswer, | 963 SessionDescriptionInterface::kAnswer, sdp, nullptr); |
963 sdp, NULL); | |
964 EXPECT_TRUE(DoSetLocalDescription(new_answer)); | 964 EXPECT_TRUE(DoSetLocalDescription(new_answer)); |
965 EXPECT_EQ(PeerConnectionInterface::kStable, observer_.state_); | 965 EXPECT_EQ(PeerConnectionInterface::kStable, observer_.state_); |
966 } | 966 } |
967 | 967 |
968 void CreatePrAnswerAsLocalDescription() { | 968 void CreatePrAnswerAsLocalDescription() { |
969 std::unique_ptr<SessionDescriptionInterface> answer; | 969 std::unique_ptr<SessionDescriptionInterface> answer; |
970 ASSERT_TRUE(DoCreateAnswer(&answer, nullptr)); | 970 ASSERT_TRUE(DoCreateAnswer(&answer, nullptr)); |
971 | 971 |
972 std::string sdp; | 972 std::string sdp; |
973 EXPECT_TRUE(answer->ToString(&sdp)); | 973 EXPECT_TRUE(answer->ToString(&sdp)); |
974 SessionDescriptionInterface* pr_answer = | 974 SessionDescriptionInterface* pr_answer = webrtc::CreateSessionDescription( |
975 webrtc::CreateSessionDescription(SessionDescriptionInterface::kPrAnswer, | 975 SessionDescriptionInterface::kPrAnswer, sdp, nullptr); |
976 sdp, NULL); | |
977 EXPECT_TRUE(DoSetLocalDescription(pr_answer)); | 976 EXPECT_TRUE(DoSetLocalDescription(pr_answer)); |
978 EXPECT_EQ(PeerConnectionInterface::kHaveLocalPrAnswer, observer_.state_); | 977 EXPECT_EQ(PeerConnectionInterface::kHaveLocalPrAnswer, observer_.state_); |
979 } | 978 } |
980 | 979 |
981 void CreateOfferReceiveAnswer() { | 980 void CreateOfferReceiveAnswer() { |
982 CreateOfferAsLocalDescription(); | 981 CreateOfferAsLocalDescription(); |
983 std::string sdp; | 982 std::string sdp; |
984 EXPECT_TRUE(pc_->local_description()->ToString(&sdp)); | 983 EXPECT_TRUE(pc_->local_description()->ToString(&sdp)); |
985 CreateAnswerAsRemoteDescription(sdp); | 984 CreateAnswerAsRemoteDescription(sdp); |
986 } | 985 } |
987 | 986 |
988 void CreateOfferAsLocalDescription() { | 987 void CreateOfferAsLocalDescription() { |
989 std::unique_ptr<SessionDescriptionInterface> offer; | 988 std::unique_ptr<SessionDescriptionInterface> offer; |
990 ASSERT_TRUE(DoCreateOffer(&offer, nullptr)); | 989 ASSERT_TRUE(DoCreateOffer(&offer, nullptr)); |
991 // TODO(perkj): Currently SetLocalDescription fails if any parameters in an | 990 // TODO(perkj): Currently SetLocalDescription fails if any parameters in an |
992 // audio codec change, even if the parameter has nothing to do with | 991 // audio codec change, even if the parameter has nothing to do with |
993 // receiving. Not all parameters are serialized to SDP. | 992 // receiving. Not all parameters are serialized to SDP. |
994 // Since CreatePrAnswerAsLocalDescription serialize/deserialize | 993 // Since CreatePrAnswerAsLocalDescription serialize/deserialize |
995 // the SessionDescription, it is necessary to do that here to in order to | 994 // the SessionDescription, it is necessary to do that here to in order to |
996 // get ReceiveOfferCreatePrAnswerAndAnswer and RenegotiateAudioOnly to pass. | 995 // get ReceiveOfferCreatePrAnswerAndAnswer and RenegotiateAudioOnly to pass. |
997 // https://code.google.com/p/webrtc/issues/detail?id=1356 | 996 // https://code.google.com/p/webrtc/issues/detail?id=1356 |
998 std::string sdp; | 997 std::string sdp; |
999 EXPECT_TRUE(offer->ToString(&sdp)); | 998 EXPECT_TRUE(offer->ToString(&sdp)); |
1000 SessionDescriptionInterface* new_offer = | 999 SessionDescriptionInterface* new_offer = webrtc::CreateSessionDescription( |
1001 webrtc::CreateSessionDescription( | 1000 SessionDescriptionInterface::kOffer, sdp, nullptr); |
1002 SessionDescriptionInterface::kOffer, | |
1003 sdp, NULL); | |
1004 | 1001 |
1005 EXPECT_TRUE(DoSetLocalDescription(new_offer)); | 1002 EXPECT_TRUE(DoSetLocalDescription(new_offer)); |
1006 EXPECT_EQ(PeerConnectionInterface::kHaveLocalOffer, observer_.state_); | 1003 EXPECT_EQ(PeerConnectionInterface::kHaveLocalOffer, observer_.state_); |
1007 // Wait for the ice_complete message, so that SDP will have candidates. | 1004 // Wait for the ice_complete message, so that SDP will have candidates. |
1008 EXPECT_TRUE_WAIT(observer_.ice_complete_, kTimeout); | 1005 EXPECT_TRUE_WAIT(observer_.ice_complete_, kTimeout); |
1009 } | 1006 } |
1010 | 1007 |
1011 void CreateAnswerAsRemoteDescription(const std::string& sdp) { | 1008 void CreateAnswerAsRemoteDescription(const std::string& sdp) { |
1012 webrtc::JsepSessionDescription* answer = new webrtc::JsepSessionDescription( | 1009 webrtc::JsepSessionDescription* answer = new webrtc::JsepSessionDescription( |
1013 SessionDescriptionInterface::kAnswer); | 1010 SessionDescriptionInterface::kAnswer); |
1014 EXPECT_TRUE(answer->Initialize(sdp, NULL)); | 1011 EXPECT_TRUE(answer->Initialize(sdp, nullptr)); |
1015 EXPECT_TRUE(DoSetRemoteDescription(answer)); | 1012 EXPECT_TRUE(DoSetRemoteDescription(answer)); |
1016 EXPECT_EQ(PeerConnectionInterface::kStable, observer_.state_); | 1013 EXPECT_EQ(PeerConnectionInterface::kStable, observer_.state_); |
1017 } | 1014 } |
1018 | 1015 |
1019 void CreatePrAnswerAndAnswerAsRemoteDescription(const std::string& sdp) { | 1016 void CreatePrAnswerAndAnswerAsRemoteDescription(const std::string& sdp) { |
1020 webrtc::JsepSessionDescription* pr_answer = | 1017 webrtc::JsepSessionDescription* pr_answer = |
1021 new webrtc::JsepSessionDescription( | 1018 new webrtc::JsepSessionDescription( |
1022 SessionDescriptionInterface::kPrAnswer); | 1019 SessionDescriptionInterface::kPrAnswer); |
1023 EXPECT_TRUE(pr_answer->Initialize(sdp, NULL)); | 1020 EXPECT_TRUE(pr_answer->Initialize(sdp, nullptr)); |
1024 EXPECT_TRUE(DoSetRemoteDescription(pr_answer)); | 1021 EXPECT_TRUE(DoSetRemoteDescription(pr_answer)); |
1025 EXPECT_EQ(PeerConnectionInterface::kHaveRemotePrAnswer, observer_.state_); | 1022 EXPECT_EQ(PeerConnectionInterface::kHaveRemotePrAnswer, observer_.state_); |
1026 webrtc::JsepSessionDescription* answer = | 1023 webrtc::JsepSessionDescription* answer = |
1027 new webrtc::JsepSessionDescription( | 1024 new webrtc::JsepSessionDescription( |
1028 SessionDescriptionInterface::kAnswer); | 1025 SessionDescriptionInterface::kAnswer); |
1029 EXPECT_TRUE(answer->Initialize(sdp, NULL)); | 1026 EXPECT_TRUE(answer->Initialize(sdp, nullptr)); |
1030 EXPECT_TRUE(DoSetRemoteDescription(answer)); | 1027 EXPECT_TRUE(DoSetRemoteDescription(answer)); |
1031 EXPECT_EQ(PeerConnectionInterface::kStable, observer_.state_); | 1028 EXPECT_EQ(PeerConnectionInterface::kStable, observer_.state_); |
1032 } | 1029 } |
1033 | 1030 |
1034 // Help function used for waiting until a the last signaled remote stream has | 1031 // Help function used for waiting until a the last signaled remote stream has |
1035 // the same label as |stream_label|. In a few of the tests in this file we | 1032 // the same label as |stream_label|. In a few of the tests in this file we |
1036 // answer with the same session description as we offer and thus we can | 1033 // answer with the same session description as we offer and thus we can |
1037 // check if OnAddStream have been called with the same stream as we offer to | 1034 // check if OnAddStream have been called with the same stream as we offer to |
1038 // send. | 1035 // send. |
1039 void WaitAndVerifyOnAddStream(const std::string& stream_label) { | 1036 void WaitAndVerifyOnAddStream(const std::string& stream_label) { |
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1291 TEST_F(PeerConnectionInterfaceTest, AddStreams) { | 1288 TEST_F(PeerConnectionInterfaceTest, AddStreams) { |
1292 CreatePeerConnectionWithoutDtls(); | 1289 CreatePeerConnectionWithoutDtls(); |
1293 AddVideoStream(kStreamLabel1); | 1290 AddVideoStream(kStreamLabel1); |
1294 AddVoiceStream(kStreamLabel2); | 1291 AddVoiceStream(kStreamLabel2); |
1295 ASSERT_EQ(2u, pc_->local_streams()->count()); | 1292 ASSERT_EQ(2u, pc_->local_streams()->count()); |
1296 | 1293 |
1297 // Test we can add multiple local streams to one peerconnection. | 1294 // Test we can add multiple local streams to one peerconnection. |
1298 rtc::scoped_refptr<MediaStreamInterface> stream( | 1295 rtc::scoped_refptr<MediaStreamInterface> stream( |
1299 pc_factory_->CreateLocalMediaStream(kStreamLabel3)); | 1296 pc_factory_->CreateLocalMediaStream(kStreamLabel3)); |
1300 rtc::scoped_refptr<AudioTrackInterface> audio_track( | 1297 rtc::scoped_refptr<AudioTrackInterface> audio_track( |
1301 pc_factory_->CreateAudioTrack(kStreamLabel3, | 1298 pc_factory_->CreateAudioTrack( |
1302 static_cast<AudioSourceInterface*>(NULL))); | 1299 kStreamLabel3, static_cast<AudioSourceInterface*>(nullptr))); |
1303 stream->AddTrack(audio_track.get()); | 1300 stream->AddTrack(audio_track.get()); |
1304 EXPECT_TRUE(pc_->AddStream(stream)); | 1301 EXPECT_TRUE(pc_->AddStream(stream)); |
1305 EXPECT_EQ(3u, pc_->local_streams()->count()); | 1302 EXPECT_EQ(3u, pc_->local_streams()->count()); |
1306 | 1303 |
1307 // Remove the third stream. | 1304 // Remove the third stream. |
1308 pc_->RemoveStream(pc_->local_streams()->at(2)); | 1305 pc_->RemoveStream(pc_->local_streams()->at(2)); |
1309 EXPECT_EQ(2u, pc_->local_streams()->count()); | 1306 EXPECT_EQ(2u, pc_->local_streams()->count()); |
1310 | 1307 |
1311 // Remove the second stream. | 1308 // Remove the second stream. |
1312 pc_->RemoveStream(pc_->local_streams()->at(1)); | 1309 pc_->RemoveStream(pc_->local_streams()->at(1)); |
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1541 std::unique_ptr<SessionDescriptionInterface> offer; | 1538 std::unique_ptr<SessionDescriptionInterface> offer; |
1542 AddVideoStream(kStreamLabel1); | 1539 AddVideoStream(kStreamLabel1); |
1543 EXPECT_TRUE(DoCreateOffer(&offer, nullptr)); | 1540 EXPECT_TRUE(DoCreateOffer(&offer, nullptr)); |
1544 EXPECT_TRUE(DoSetRemoteDescription(offer.release())); | 1541 EXPECT_TRUE(DoSetRemoteDescription(offer.release())); |
1545 | 1542 |
1546 // SetLocalDescription takes ownership of answer. | 1543 // SetLocalDescription takes ownership of answer. |
1547 std::unique_ptr<SessionDescriptionInterface> answer; | 1544 std::unique_ptr<SessionDescriptionInterface> answer; |
1548 EXPECT_TRUE(DoCreateAnswer(&answer, nullptr)); | 1545 EXPECT_TRUE(DoCreateAnswer(&answer, nullptr)); |
1549 EXPECT_TRUE(DoSetLocalDescription(answer.release())); | 1546 EXPECT_TRUE(DoSetLocalDescription(answer.release())); |
1550 | 1547 |
1551 EXPECT_TRUE_WAIT(observer_.last_candidate_.get() != NULL, kTimeout); | 1548 EXPECT_TRUE_WAIT(observer_.last_candidate_.get() != nullptr, kTimeout); |
1552 EXPECT_TRUE_WAIT(observer_.ice_complete_, kTimeout); | 1549 EXPECT_TRUE_WAIT(observer_.ice_complete_, kTimeout); |
1553 | 1550 |
1554 EXPECT_TRUE(pc_->AddIceCandidate(observer_.last_candidate_.get())); | 1551 EXPECT_TRUE(pc_->AddIceCandidate(observer_.last_candidate_.get())); |
1555 } | 1552 } |
1556 | 1553 |
1557 // Test that CreateOffer and CreateAnswer will fail if the track labels are | 1554 // Test that CreateOffer and CreateAnswer will fail if the track labels are |
1558 // not unique. | 1555 // not unique. |
1559 TEST_F(PeerConnectionInterfaceTest, CreateOfferAnswerWithInvalidStream) { | 1556 TEST_F(PeerConnectionInterfaceTest, CreateOfferAnswerWithInvalidStream) { |
1560 CreatePeerConnectionWithoutDtls(); | 1557 CreatePeerConnectionWithoutDtls(); |
1561 // Create a regular offer for the CreateAnswer test later. | 1558 // Create a regular offer for the CreateAnswer test later. |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1695 ASSERT_LT(0u, pc_->remote_streams()->at(0)->GetVideoTracks().size()); | 1692 ASSERT_LT(0u, pc_->remote_streams()->at(0)->GetVideoTracks().size()); |
1696 rtc::scoped_refptr<MediaStreamTrackInterface> remote_video = | 1693 rtc::scoped_refptr<MediaStreamTrackInterface> remote_video = |
1697 pc_->remote_streams()->at(0)->GetVideoTracks()[0]; | 1694 pc_->remote_streams()->at(0)->GetVideoTracks()[0]; |
1698 EXPECT_TRUE(DoGetStats(remote_video)); | 1695 EXPECT_TRUE(DoGetStats(remote_video)); |
1699 } | 1696 } |
1700 | 1697 |
1701 // Test that we don't get statistics for an invalid track. | 1698 // Test that we don't get statistics for an invalid track. |
1702 TEST_F(PeerConnectionInterfaceTest, GetStatsForInvalidTrack) { | 1699 TEST_F(PeerConnectionInterfaceTest, GetStatsForInvalidTrack) { |
1703 InitiateCall(); | 1700 InitiateCall(); |
1704 rtc::scoped_refptr<AudioTrackInterface> unknown_audio_track( | 1701 rtc::scoped_refptr<AudioTrackInterface> unknown_audio_track( |
1705 pc_factory_->CreateAudioTrack("unknown track", NULL)); | 1702 pc_factory_->CreateAudioTrack("unknown track", nullptr)); |
1706 EXPECT_FALSE(DoGetStats(unknown_audio_track)); | 1703 EXPECT_FALSE(DoGetStats(unknown_audio_track)); |
1707 } | 1704 } |
1708 | 1705 |
1709 // This test setup two RTP data channels in loop back. | 1706 // This test setup two RTP data channels in loop back. |
1710 TEST_F(PeerConnectionInterfaceTest, TestDataChannel) { | 1707 TEST_F(PeerConnectionInterfaceTest, TestDataChannel) { |
1711 FakeConstraints constraints; | 1708 FakeConstraints constraints; |
1712 constraints.SetAllowRtpDataChannels(); | 1709 constraints.SetAllowRtpDataChannels(); |
1713 CreatePeerConnection(&constraints); | 1710 CreatePeerConnection(&constraints); |
1714 rtc::scoped_refptr<DataChannelInterface> data1 = | 1711 rtc::scoped_refptr<DataChannelInterface> data1 = |
1715 pc_->CreateDataChannel("test1", NULL); | 1712 pc_->CreateDataChannel("test1", nullptr); |
1716 rtc::scoped_refptr<DataChannelInterface> data2 = | 1713 rtc::scoped_refptr<DataChannelInterface> data2 = |
1717 pc_->CreateDataChannel("test2", NULL); | 1714 pc_->CreateDataChannel("test2", nullptr); |
1718 ASSERT_TRUE(data1 != NULL); | 1715 ASSERT_TRUE(data1 != nullptr); |
1719 std::unique_ptr<MockDataChannelObserver> observer1( | 1716 std::unique_ptr<MockDataChannelObserver> observer1( |
1720 new MockDataChannelObserver(data1)); | 1717 new MockDataChannelObserver(data1)); |
1721 std::unique_ptr<MockDataChannelObserver> observer2( | 1718 std::unique_ptr<MockDataChannelObserver> observer2( |
1722 new MockDataChannelObserver(data2)); | 1719 new MockDataChannelObserver(data2)); |
1723 | 1720 |
1724 EXPECT_EQ(DataChannelInterface::kConnecting, data1->state()); | 1721 EXPECT_EQ(DataChannelInterface::kConnecting, data1->state()); |
1725 EXPECT_EQ(DataChannelInterface::kConnecting, data2->state()); | 1722 EXPECT_EQ(DataChannelInterface::kConnecting, data2->state()); |
1726 std::string data_to_send1 = "testing testing"; | 1723 std::string data_to_send1 = "testing testing"; |
1727 std::string data_to_send2 = "testing something else"; | 1724 std::string data_to_send2 = "testing something else"; |
1728 EXPECT_FALSE(data1->Send(DataBuffer(data_to_send1))); | 1725 EXPECT_FALSE(data1->Send(DataBuffer(data_to_send1))); |
(...skipping 23 matching lines...) Expand all Loading... |
1752 EXPECT_EQ_WAIT(data_to_send2, observer2->last_message(), kTimeout); | 1749 EXPECT_EQ_WAIT(data_to_send2, observer2->last_message(), kTimeout); |
1753 } | 1750 } |
1754 | 1751 |
1755 // This test verifies that sendnig binary data over RTP data channels should | 1752 // This test verifies that sendnig binary data over RTP data channels should |
1756 // fail. | 1753 // fail. |
1757 TEST_F(PeerConnectionInterfaceTest, TestSendBinaryOnRtpDataChannel) { | 1754 TEST_F(PeerConnectionInterfaceTest, TestSendBinaryOnRtpDataChannel) { |
1758 FakeConstraints constraints; | 1755 FakeConstraints constraints; |
1759 constraints.SetAllowRtpDataChannels(); | 1756 constraints.SetAllowRtpDataChannels(); |
1760 CreatePeerConnection(&constraints); | 1757 CreatePeerConnection(&constraints); |
1761 rtc::scoped_refptr<DataChannelInterface> data1 = | 1758 rtc::scoped_refptr<DataChannelInterface> data1 = |
1762 pc_->CreateDataChannel("test1", NULL); | 1759 pc_->CreateDataChannel("test1", nullptr); |
1763 rtc::scoped_refptr<DataChannelInterface> data2 = | 1760 rtc::scoped_refptr<DataChannelInterface> data2 = |
1764 pc_->CreateDataChannel("test2", NULL); | 1761 pc_->CreateDataChannel("test2", nullptr); |
1765 ASSERT_TRUE(data1 != NULL); | 1762 ASSERT_TRUE(data1 != nullptr); |
1766 std::unique_ptr<MockDataChannelObserver> observer1( | 1763 std::unique_ptr<MockDataChannelObserver> observer1( |
1767 new MockDataChannelObserver(data1)); | 1764 new MockDataChannelObserver(data1)); |
1768 std::unique_ptr<MockDataChannelObserver> observer2( | 1765 std::unique_ptr<MockDataChannelObserver> observer2( |
1769 new MockDataChannelObserver(data2)); | 1766 new MockDataChannelObserver(data2)); |
1770 | 1767 |
1771 EXPECT_EQ(DataChannelInterface::kConnecting, data1->state()); | 1768 EXPECT_EQ(DataChannelInterface::kConnecting, data1->state()); |
1772 EXPECT_EQ(DataChannelInterface::kConnecting, data2->state()); | 1769 EXPECT_EQ(DataChannelInterface::kConnecting, data2->state()); |
1773 | 1770 |
1774 CreateOfferReceiveAnswer(); | 1771 CreateOfferReceiveAnswer(); |
1775 EXPECT_TRUE_WAIT(observer1->IsOpen(), kTimeout); | 1772 EXPECT_TRUE_WAIT(observer1->IsOpen(), kTimeout); |
1776 EXPECT_TRUE_WAIT(observer2->IsOpen(), kTimeout); | 1773 EXPECT_TRUE_WAIT(observer2->IsOpen(), kTimeout); |
1777 | 1774 |
1778 EXPECT_EQ(DataChannelInterface::kOpen, data1->state()); | 1775 EXPECT_EQ(DataChannelInterface::kOpen, data1->state()); |
1779 EXPECT_EQ(DataChannelInterface::kOpen, data2->state()); | 1776 EXPECT_EQ(DataChannelInterface::kOpen, data2->state()); |
1780 | 1777 |
1781 rtc::CopyOnWriteBuffer buffer("test", 4); | 1778 rtc::CopyOnWriteBuffer buffer("test", 4); |
1782 EXPECT_FALSE(data1->Send(DataBuffer(buffer, true))); | 1779 EXPECT_FALSE(data1->Send(DataBuffer(buffer, true))); |
1783 } | 1780 } |
1784 | 1781 |
1785 // This test setup a RTP data channels in loop back and test that a channel is | 1782 // This test setup a RTP data channels in loop back and test that a channel is |
1786 // opened even if the remote end answer with a zero SSRC. | 1783 // opened even if the remote end answer with a zero SSRC. |
1787 TEST_F(PeerConnectionInterfaceTest, TestSendOnlyDataChannel) { | 1784 TEST_F(PeerConnectionInterfaceTest, TestSendOnlyDataChannel) { |
1788 FakeConstraints constraints; | 1785 FakeConstraints constraints; |
1789 constraints.SetAllowRtpDataChannels(); | 1786 constraints.SetAllowRtpDataChannels(); |
1790 CreatePeerConnection(&constraints); | 1787 CreatePeerConnection(&constraints); |
1791 rtc::scoped_refptr<DataChannelInterface> data1 = | 1788 rtc::scoped_refptr<DataChannelInterface> data1 = |
1792 pc_->CreateDataChannel("test1", NULL); | 1789 pc_->CreateDataChannel("test1", nullptr); |
1793 std::unique_ptr<MockDataChannelObserver> observer1( | 1790 std::unique_ptr<MockDataChannelObserver> observer1( |
1794 new MockDataChannelObserver(data1)); | 1791 new MockDataChannelObserver(data1)); |
1795 | 1792 |
1796 CreateOfferReceiveAnswerWithoutSsrc(); | 1793 CreateOfferReceiveAnswerWithoutSsrc(); |
1797 | 1794 |
1798 EXPECT_TRUE_WAIT(observer1->IsOpen(), kTimeout); | 1795 EXPECT_TRUE_WAIT(observer1->IsOpen(), kTimeout); |
1799 | 1796 |
1800 data1->Close(); | 1797 data1->Close(); |
1801 EXPECT_EQ(DataChannelInterface::kClosing, data1->state()); | 1798 EXPECT_EQ(DataChannelInterface::kClosing, data1->state()); |
1802 CreateOfferReceiveAnswerWithoutSsrc(); | 1799 CreateOfferReceiveAnswerWithoutSsrc(); |
1803 EXPECT_EQ(DataChannelInterface::kClosed, data1->state()); | 1800 EXPECT_EQ(DataChannelInterface::kClosed, data1->state()); |
1804 EXPECT_FALSE(observer1->IsOpen()); | 1801 EXPECT_FALSE(observer1->IsOpen()); |
1805 } | 1802 } |
1806 | 1803 |
1807 // This test that if a data channel is added in an answer a receive only channel | 1804 // This test that if a data channel is added in an answer a receive only channel |
1808 // channel is created. | 1805 // channel is created. |
1809 TEST_F(PeerConnectionInterfaceTest, TestReceiveOnlyDataChannel) { | 1806 TEST_F(PeerConnectionInterfaceTest, TestReceiveOnlyDataChannel) { |
1810 FakeConstraints constraints; | 1807 FakeConstraints constraints; |
1811 constraints.SetAllowRtpDataChannels(); | 1808 constraints.SetAllowRtpDataChannels(); |
1812 CreatePeerConnection(&constraints); | 1809 CreatePeerConnection(&constraints); |
1813 | 1810 |
1814 std::string offer_label = "offer_channel"; | 1811 std::string offer_label = "offer_channel"; |
1815 rtc::scoped_refptr<DataChannelInterface> offer_channel = | 1812 rtc::scoped_refptr<DataChannelInterface> offer_channel = |
1816 pc_->CreateDataChannel(offer_label, NULL); | 1813 pc_->CreateDataChannel(offer_label, nullptr); |
1817 | 1814 |
1818 CreateOfferAsLocalDescription(); | 1815 CreateOfferAsLocalDescription(); |
1819 | 1816 |
1820 // Replace the data channel label in the offer and apply it as an answer. | 1817 // Replace the data channel label in the offer and apply it as an answer. |
1821 std::string receive_label = "answer_channel"; | 1818 std::string receive_label = "answer_channel"; |
1822 std::string sdp; | 1819 std::string sdp; |
1823 EXPECT_TRUE(pc_->local_description()->ToString(&sdp)); | 1820 EXPECT_TRUE(pc_->local_description()->ToString(&sdp)); |
1824 rtc::replace_substrs(offer_label.c_str(), offer_label.length(), | 1821 rtc::replace_substrs(offer_label.c_str(), offer_label.length(), |
1825 receive_label.c_str(), receive_label.length(), | 1822 receive_label.c_str(), receive_label.length(), |
1826 &sdp); | 1823 &sdp); |
1827 CreateAnswerAsRemoteDescription(sdp); | 1824 CreateAnswerAsRemoteDescription(sdp); |
1828 | 1825 |
1829 // Verify that a new incoming data channel has been created and that | 1826 // Verify that a new incoming data channel has been created and that |
1830 // it is open but can't we written to. | 1827 // it is open but can't we written to. |
1831 ASSERT_TRUE(observer_.last_datachannel_ != NULL); | 1828 ASSERT_TRUE(observer_.last_datachannel_ != nullptr); |
1832 DataChannelInterface* received_channel = observer_.last_datachannel_; | 1829 DataChannelInterface* received_channel = observer_.last_datachannel_; |
1833 EXPECT_EQ(DataChannelInterface::kConnecting, received_channel->state()); | 1830 EXPECT_EQ(DataChannelInterface::kConnecting, received_channel->state()); |
1834 EXPECT_EQ(receive_label, received_channel->label()); | 1831 EXPECT_EQ(receive_label, received_channel->label()); |
1835 EXPECT_FALSE(received_channel->Send(DataBuffer("something"))); | 1832 EXPECT_FALSE(received_channel->Send(DataBuffer("something"))); |
1836 | 1833 |
1837 // Verify that the channel we initially offered has been rejected. | 1834 // Verify that the channel we initially offered has been rejected. |
1838 EXPECT_EQ(DataChannelInterface::kClosed, offer_channel->state()); | 1835 EXPECT_EQ(DataChannelInterface::kClosed, offer_channel->state()); |
1839 | 1836 |
1840 // Do another offer / answer exchange and verify that the data channel is | 1837 // Do another offer / answer exchange and verify that the data channel is |
1841 // opened. | 1838 // opened. |
1842 CreateOfferReceiveAnswer(); | 1839 CreateOfferReceiveAnswer(); |
1843 EXPECT_EQ_WAIT(DataChannelInterface::kOpen, received_channel->state(), | 1840 EXPECT_EQ_WAIT(DataChannelInterface::kOpen, received_channel->state(), |
1844 kTimeout); | 1841 kTimeout); |
1845 } | 1842 } |
1846 | 1843 |
1847 // This test that no data channel is returned if a reliable channel is | 1844 // This test that no data channel is returned if a reliable channel is |
1848 // requested. | 1845 // requested. |
1849 // TODO(perkj): Remove this test once reliable channels are implemented. | 1846 // TODO(perkj): Remove this test once reliable channels are implemented. |
1850 TEST_F(PeerConnectionInterfaceTest, CreateReliableRtpDataChannelShouldFail) { | 1847 TEST_F(PeerConnectionInterfaceTest, CreateReliableRtpDataChannelShouldFail) { |
1851 FakeConstraints constraints; | 1848 FakeConstraints constraints; |
1852 constraints.SetAllowRtpDataChannels(); | 1849 constraints.SetAllowRtpDataChannels(); |
1853 CreatePeerConnection(&constraints); | 1850 CreatePeerConnection(&constraints); |
1854 | 1851 |
1855 std::string label = "test"; | 1852 std::string label = "test"; |
1856 webrtc::DataChannelInit config; | 1853 webrtc::DataChannelInit config; |
1857 config.reliable = true; | 1854 config.reliable = true; |
1858 rtc::scoped_refptr<DataChannelInterface> channel = | 1855 rtc::scoped_refptr<DataChannelInterface> channel = |
1859 pc_->CreateDataChannel(label, &config); | 1856 pc_->CreateDataChannel(label, &config); |
1860 EXPECT_TRUE(channel == NULL); | 1857 EXPECT_TRUE(channel == nullptr); |
1861 } | 1858 } |
1862 | 1859 |
1863 // Verifies that duplicated label is not allowed for RTP data channel. | 1860 // Verifies that duplicated label is not allowed for RTP data channel. |
1864 TEST_F(PeerConnectionInterfaceTest, RtpDuplicatedLabelNotAllowed) { | 1861 TEST_F(PeerConnectionInterfaceTest, RtpDuplicatedLabelNotAllowed) { |
1865 FakeConstraints constraints; | 1862 FakeConstraints constraints; |
1866 constraints.SetAllowRtpDataChannels(); | 1863 constraints.SetAllowRtpDataChannels(); |
1867 CreatePeerConnection(&constraints); | 1864 CreatePeerConnection(&constraints); |
1868 | 1865 |
1869 std::string label = "test"; | 1866 std::string label = "test"; |
1870 rtc::scoped_refptr<DataChannelInterface> channel = | 1867 rtc::scoped_refptr<DataChannelInterface> channel = |
1871 pc_->CreateDataChannel(label, nullptr); | 1868 pc_->CreateDataChannel(label, nullptr); |
1872 EXPECT_NE(channel, nullptr); | 1869 EXPECT_NE(channel, nullptr); |
1873 | 1870 |
1874 rtc::scoped_refptr<DataChannelInterface> dup_channel = | 1871 rtc::scoped_refptr<DataChannelInterface> dup_channel = |
1875 pc_->CreateDataChannel(label, nullptr); | 1872 pc_->CreateDataChannel(label, nullptr); |
1876 EXPECT_EQ(dup_channel, nullptr); | 1873 EXPECT_EQ(dup_channel, nullptr); |
1877 } | 1874 } |
1878 | 1875 |
1879 // This tests that a SCTP data channel is returned using different | 1876 // This tests that a SCTP data channel is returned using different |
1880 // DataChannelInit configurations. | 1877 // DataChannelInit configurations. |
1881 TEST_F(PeerConnectionInterfaceTest, CreateSctpDataChannel) { | 1878 TEST_F(PeerConnectionInterfaceTest, CreateSctpDataChannel) { |
1882 FakeConstraints constraints; | 1879 FakeConstraints constraints; |
1883 constraints.SetAllowDtlsSctpDataChannels(); | 1880 constraints.SetAllowDtlsSctpDataChannels(); |
1884 CreatePeerConnection(&constraints); | 1881 CreatePeerConnection(&constraints); |
1885 | 1882 |
1886 webrtc::DataChannelInit config; | 1883 webrtc::DataChannelInit config; |
1887 | 1884 |
1888 rtc::scoped_refptr<DataChannelInterface> channel = | 1885 rtc::scoped_refptr<DataChannelInterface> channel = |
1889 pc_->CreateDataChannel("1", &config); | 1886 pc_->CreateDataChannel("1", &config); |
1890 EXPECT_TRUE(channel != NULL); | 1887 EXPECT_TRUE(channel != nullptr); |
1891 EXPECT_TRUE(channel->reliable()); | 1888 EXPECT_TRUE(channel->reliable()); |
1892 EXPECT_TRUE(observer_.renegotiation_needed_); | 1889 EXPECT_TRUE(observer_.renegotiation_needed_); |
1893 observer_.renegotiation_needed_ = false; | 1890 observer_.renegotiation_needed_ = false; |
1894 | 1891 |
1895 config.ordered = false; | 1892 config.ordered = false; |
1896 channel = pc_->CreateDataChannel("2", &config); | 1893 channel = pc_->CreateDataChannel("2", &config); |
1897 EXPECT_TRUE(channel != NULL); | 1894 EXPECT_TRUE(channel != nullptr); |
1898 EXPECT_TRUE(channel->reliable()); | 1895 EXPECT_TRUE(channel->reliable()); |
1899 EXPECT_FALSE(observer_.renegotiation_needed_); | 1896 EXPECT_FALSE(observer_.renegotiation_needed_); |
1900 | 1897 |
1901 config.ordered = true; | 1898 config.ordered = true; |
1902 config.maxRetransmits = 0; | 1899 config.maxRetransmits = 0; |
1903 channel = pc_->CreateDataChannel("3", &config); | 1900 channel = pc_->CreateDataChannel("3", &config); |
1904 EXPECT_TRUE(channel != NULL); | 1901 EXPECT_TRUE(channel != nullptr); |
1905 EXPECT_FALSE(channel->reliable()); | 1902 EXPECT_FALSE(channel->reliable()); |
1906 EXPECT_FALSE(observer_.renegotiation_needed_); | 1903 EXPECT_FALSE(observer_.renegotiation_needed_); |
1907 | 1904 |
1908 config.maxRetransmits = -1; | 1905 config.maxRetransmits = -1; |
1909 config.maxRetransmitTime = 0; | 1906 config.maxRetransmitTime = 0; |
1910 channel = pc_->CreateDataChannel("4", &config); | 1907 channel = pc_->CreateDataChannel("4", &config); |
1911 EXPECT_TRUE(channel != NULL); | 1908 EXPECT_TRUE(channel != nullptr); |
1912 EXPECT_FALSE(channel->reliable()); | 1909 EXPECT_FALSE(channel->reliable()); |
1913 EXPECT_FALSE(observer_.renegotiation_needed_); | 1910 EXPECT_FALSE(observer_.renegotiation_needed_); |
1914 } | 1911 } |
1915 | 1912 |
1916 // This tests that no data channel is returned if both maxRetransmits and | 1913 // This tests that no data channel is returned if both maxRetransmits and |
1917 // maxRetransmitTime are set for SCTP data channels. | 1914 // maxRetransmitTime are set for SCTP data channels. |
1918 TEST_F(PeerConnectionInterfaceTest, | 1915 TEST_F(PeerConnectionInterfaceTest, |
1919 CreateSctpDataChannelShouldFailForInvalidConfig) { | 1916 CreateSctpDataChannelShouldFailForInvalidConfig) { |
1920 FakeConstraints constraints; | 1917 FakeConstraints constraints; |
1921 constraints.SetAllowDtlsSctpDataChannels(); | 1918 constraints.SetAllowDtlsSctpDataChannels(); |
1922 CreatePeerConnection(&constraints); | 1919 CreatePeerConnection(&constraints); |
1923 | 1920 |
1924 std::string label = "test"; | 1921 std::string label = "test"; |
1925 webrtc::DataChannelInit config; | 1922 webrtc::DataChannelInit config; |
1926 config.maxRetransmits = 0; | 1923 config.maxRetransmits = 0; |
1927 config.maxRetransmitTime = 0; | 1924 config.maxRetransmitTime = 0; |
1928 | 1925 |
1929 rtc::scoped_refptr<DataChannelInterface> channel = | 1926 rtc::scoped_refptr<DataChannelInterface> channel = |
1930 pc_->CreateDataChannel(label, &config); | 1927 pc_->CreateDataChannel(label, &config); |
1931 EXPECT_TRUE(channel == NULL); | 1928 EXPECT_TRUE(channel == nullptr); |
1932 } | 1929 } |
1933 | 1930 |
1934 // The test verifies that creating a SCTP data channel with an id already in use | 1931 // The test verifies that creating a SCTP data channel with an id already in use |
1935 // or out of range should fail. | 1932 // or out of range should fail. |
1936 TEST_F(PeerConnectionInterfaceTest, | 1933 TEST_F(PeerConnectionInterfaceTest, |
1937 CreateSctpDataChannelWithInvalidIdShouldFail) { | 1934 CreateSctpDataChannelWithInvalidIdShouldFail) { |
1938 FakeConstraints constraints; | 1935 FakeConstraints constraints; |
1939 constraints.SetAllowDtlsSctpDataChannels(); | 1936 constraints.SetAllowDtlsSctpDataChannels(); |
1940 CreatePeerConnection(&constraints); | 1937 CreatePeerConnection(&constraints); |
1941 | 1938 |
1942 webrtc::DataChannelInit config; | 1939 webrtc::DataChannelInit config; |
1943 rtc::scoped_refptr<DataChannelInterface> channel; | 1940 rtc::scoped_refptr<DataChannelInterface> channel; |
1944 | 1941 |
1945 config.id = 1; | 1942 config.id = 1; |
1946 channel = pc_->CreateDataChannel("1", &config); | 1943 channel = pc_->CreateDataChannel("1", &config); |
1947 EXPECT_TRUE(channel != NULL); | 1944 EXPECT_TRUE(channel != nullptr); |
1948 EXPECT_EQ(1, channel->id()); | 1945 EXPECT_EQ(1, channel->id()); |
1949 | 1946 |
1950 channel = pc_->CreateDataChannel("x", &config); | 1947 channel = pc_->CreateDataChannel("x", &config); |
1951 EXPECT_TRUE(channel == NULL); | 1948 EXPECT_TRUE(channel == nullptr); |
1952 | 1949 |
1953 config.id = cricket::kMaxSctpSid; | 1950 config.id = cricket::kMaxSctpSid; |
1954 channel = pc_->CreateDataChannel("max", &config); | 1951 channel = pc_->CreateDataChannel("max", &config); |
1955 EXPECT_TRUE(channel != NULL); | 1952 EXPECT_TRUE(channel != nullptr); |
1956 EXPECT_EQ(config.id, channel->id()); | 1953 EXPECT_EQ(config.id, channel->id()); |
1957 | 1954 |
1958 config.id = cricket::kMaxSctpSid + 1; | 1955 config.id = cricket::kMaxSctpSid + 1; |
1959 channel = pc_->CreateDataChannel("x", &config); | 1956 channel = pc_->CreateDataChannel("x", &config); |
1960 EXPECT_TRUE(channel == NULL); | 1957 EXPECT_TRUE(channel == nullptr); |
1961 } | 1958 } |
1962 | 1959 |
1963 // Verifies that duplicated label is allowed for SCTP data channel. | 1960 // Verifies that duplicated label is allowed for SCTP data channel. |
1964 TEST_F(PeerConnectionInterfaceTest, SctpDuplicatedLabelAllowed) { | 1961 TEST_F(PeerConnectionInterfaceTest, SctpDuplicatedLabelAllowed) { |
1965 FakeConstraints constraints; | 1962 FakeConstraints constraints; |
1966 constraints.AddMandatory(webrtc::MediaConstraintsInterface::kEnableDtlsSrtp, | 1963 constraints.AddMandatory(webrtc::MediaConstraintsInterface::kEnableDtlsSrtp, |
1967 true); | 1964 true); |
1968 CreatePeerConnection(&constraints); | 1965 CreatePeerConnection(&constraints); |
1969 | 1966 |
1970 std::string label = "test"; | 1967 std::string label = "test"; |
1971 rtc::scoped_refptr<DataChannelInterface> channel = | 1968 rtc::scoped_refptr<DataChannelInterface> channel = |
1972 pc_->CreateDataChannel(label, nullptr); | 1969 pc_->CreateDataChannel(label, nullptr); |
1973 EXPECT_NE(channel, nullptr); | 1970 EXPECT_NE(channel, nullptr); |
1974 | 1971 |
1975 rtc::scoped_refptr<DataChannelInterface> dup_channel = | 1972 rtc::scoped_refptr<DataChannelInterface> dup_channel = |
1976 pc_->CreateDataChannel(label, nullptr); | 1973 pc_->CreateDataChannel(label, nullptr); |
1977 EXPECT_NE(dup_channel, nullptr); | 1974 EXPECT_NE(dup_channel, nullptr); |
1978 } | 1975 } |
1979 | 1976 |
1980 // This test verifies that OnRenegotiationNeeded is fired for every new RTP | 1977 // This test verifies that OnRenegotiationNeeded is fired for every new RTP |
1981 // DataChannel. | 1978 // DataChannel. |
1982 TEST_F(PeerConnectionInterfaceTest, RenegotiationNeededForNewRtpDataChannel) { | 1979 TEST_F(PeerConnectionInterfaceTest, RenegotiationNeededForNewRtpDataChannel) { |
1983 FakeConstraints constraints; | 1980 FakeConstraints constraints; |
1984 constraints.SetAllowRtpDataChannels(); | 1981 constraints.SetAllowRtpDataChannels(); |
1985 CreatePeerConnection(&constraints); | 1982 CreatePeerConnection(&constraints); |
1986 | 1983 |
1987 rtc::scoped_refptr<DataChannelInterface> dc1 = | 1984 rtc::scoped_refptr<DataChannelInterface> dc1 = |
1988 pc_->CreateDataChannel("test1", NULL); | 1985 pc_->CreateDataChannel("test1", nullptr); |
1989 EXPECT_TRUE(observer_.renegotiation_needed_); | 1986 EXPECT_TRUE(observer_.renegotiation_needed_); |
1990 observer_.renegotiation_needed_ = false; | 1987 observer_.renegotiation_needed_ = false; |
1991 | 1988 |
1992 rtc::scoped_refptr<DataChannelInterface> dc2 = | 1989 rtc::scoped_refptr<DataChannelInterface> dc2 = |
1993 pc_->CreateDataChannel("test2", NULL); | 1990 pc_->CreateDataChannel("test2", nullptr); |
1994 EXPECT_TRUE(observer_.renegotiation_needed_); | 1991 EXPECT_TRUE(observer_.renegotiation_needed_); |
1995 } | 1992 } |
1996 | 1993 |
1997 // This test that a data channel closes when a PeerConnection is deleted/closed. | 1994 // This test that a data channel closes when a PeerConnection is deleted/closed. |
1998 TEST_F(PeerConnectionInterfaceTest, DataChannelCloseWhenPeerConnectionClose) { | 1995 TEST_F(PeerConnectionInterfaceTest, DataChannelCloseWhenPeerConnectionClose) { |
1999 FakeConstraints constraints; | 1996 FakeConstraints constraints; |
2000 constraints.SetAllowRtpDataChannels(); | 1997 constraints.SetAllowRtpDataChannels(); |
2001 CreatePeerConnection(&constraints); | 1998 CreatePeerConnection(&constraints); |
2002 | 1999 |
2003 rtc::scoped_refptr<DataChannelInterface> data1 = | 2000 rtc::scoped_refptr<DataChannelInterface> data1 = |
2004 pc_->CreateDataChannel("test1", NULL); | 2001 pc_->CreateDataChannel("test1", nullptr); |
2005 rtc::scoped_refptr<DataChannelInterface> data2 = | 2002 rtc::scoped_refptr<DataChannelInterface> data2 = |
2006 pc_->CreateDataChannel("test2", NULL); | 2003 pc_->CreateDataChannel("test2", nullptr); |
2007 ASSERT_TRUE(data1 != NULL); | 2004 ASSERT_TRUE(data1 != nullptr); |
2008 std::unique_ptr<MockDataChannelObserver> observer1( | 2005 std::unique_ptr<MockDataChannelObserver> observer1( |
2009 new MockDataChannelObserver(data1)); | 2006 new MockDataChannelObserver(data1)); |
2010 std::unique_ptr<MockDataChannelObserver> observer2( | 2007 std::unique_ptr<MockDataChannelObserver> observer2( |
2011 new MockDataChannelObserver(data2)); | 2008 new MockDataChannelObserver(data2)); |
2012 | 2009 |
2013 CreateOfferReceiveAnswer(); | 2010 CreateOfferReceiveAnswer(); |
2014 EXPECT_TRUE_WAIT(observer1->IsOpen(), kTimeout); | 2011 EXPECT_TRUE_WAIT(observer1->IsOpen(), kTimeout); |
2015 EXPECT_TRUE_WAIT(observer2->IsOpen(), kTimeout); | 2012 EXPECT_TRUE_WAIT(observer2->IsOpen(), kTimeout); |
2016 | 2013 |
2017 ReleasePeerConnection(); | 2014 ReleasePeerConnection(); |
2018 EXPECT_EQ(DataChannelInterface::kClosed, data1->state()); | 2015 EXPECT_EQ(DataChannelInterface::kClosed, data1->state()); |
2019 EXPECT_EQ(DataChannelInterface::kClosed, data2->state()); | 2016 EXPECT_EQ(DataChannelInterface::kClosed, data2->state()); |
2020 } | 2017 } |
2021 | 2018 |
2022 // This test that data channels can be rejected in an answer. | 2019 // This test that data channels can be rejected in an answer. |
2023 TEST_F(PeerConnectionInterfaceTest, TestRejectDataChannelInAnswer) { | 2020 TEST_F(PeerConnectionInterfaceTest, TestRejectDataChannelInAnswer) { |
2024 FakeConstraints constraints; | 2021 FakeConstraints constraints; |
2025 constraints.SetAllowRtpDataChannels(); | 2022 constraints.SetAllowRtpDataChannels(); |
2026 CreatePeerConnection(&constraints); | 2023 CreatePeerConnection(&constraints); |
2027 | 2024 |
2028 rtc::scoped_refptr<DataChannelInterface> offer_channel( | 2025 rtc::scoped_refptr<DataChannelInterface> offer_channel( |
2029 pc_->CreateDataChannel("offer_channel", NULL)); | 2026 pc_->CreateDataChannel("offer_channel", nullptr)); |
2030 | 2027 |
2031 CreateOfferAsLocalDescription(); | 2028 CreateOfferAsLocalDescription(); |
2032 | 2029 |
2033 // Create an answer where the m-line for data channels are rejected. | 2030 // Create an answer where the m-line for data channels are rejected. |
2034 std::string sdp; | 2031 std::string sdp; |
2035 EXPECT_TRUE(pc_->local_description()->ToString(&sdp)); | 2032 EXPECT_TRUE(pc_->local_description()->ToString(&sdp)); |
2036 webrtc::JsepSessionDescription* answer = new webrtc::JsepSessionDescription( | 2033 webrtc::JsepSessionDescription* answer = new webrtc::JsepSessionDescription( |
2037 SessionDescriptionInterface::kAnswer); | 2034 SessionDescriptionInterface::kAnswer); |
2038 EXPECT_TRUE(answer->Initialize(sdp, NULL)); | 2035 EXPECT_TRUE(answer->Initialize(sdp, nullptr)); |
2039 cricket::ContentInfo* data_info = | 2036 cricket::ContentInfo* data_info = |
2040 answer->description()->GetContentByName("data"); | 2037 answer->description()->GetContentByName("data"); |
2041 data_info->rejected = true; | 2038 data_info->rejected = true; |
2042 | 2039 |
2043 DoSetRemoteDescription(answer); | 2040 DoSetRemoteDescription(answer); |
2044 EXPECT_EQ(DataChannelInterface::kClosed, offer_channel->state()); | 2041 EXPECT_EQ(DataChannelInterface::kClosed, offer_channel->state()); |
2045 } | 2042 } |
2046 | 2043 |
2047 // Test that we can create a session description from an SDP string from | 2044 // Test that we can create a session description from an SDP string from |
2048 // FireFox, use it as a remote session description, generate an answer and use | 2045 // FireFox, use it as a remote session description, generate an answer and use |
2049 // the answer as a local description. | 2046 // the answer as a local description. |
2050 TEST_F(PeerConnectionInterfaceTest, ReceiveFireFoxOffer) { | 2047 TEST_F(PeerConnectionInterfaceTest, ReceiveFireFoxOffer) { |
2051 FakeConstraints constraints; | 2048 FakeConstraints constraints; |
2052 constraints.AddMandatory(webrtc::MediaConstraintsInterface::kEnableDtlsSrtp, | 2049 constraints.AddMandatory(webrtc::MediaConstraintsInterface::kEnableDtlsSrtp, |
2053 true); | 2050 true); |
2054 CreatePeerConnection(&constraints); | 2051 CreatePeerConnection(&constraints); |
2055 AddAudioVideoStream(kStreamLabel1, "audio_label", "video_label"); | 2052 AddAudioVideoStream(kStreamLabel1, "audio_label", "video_label"); |
2056 SessionDescriptionInterface* desc = | 2053 SessionDescriptionInterface* desc = |
2057 webrtc::CreateSessionDescription(SessionDescriptionInterface::kOffer, | 2054 webrtc::CreateSessionDescription(SessionDescriptionInterface::kOffer, |
2058 webrtc::kFireFoxSdpOffer, nullptr); | 2055 webrtc::kFireFoxSdpOffer, nullptr); |
2059 EXPECT_TRUE(DoSetSessionDescription(desc, false)); | 2056 EXPECT_TRUE(DoSetSessionDescription(desc, false)); |
2060 CreateAnswerAsLocalDescription(); | 2057 CreateAnswerAsLocalDescription(); |
2061 ASSERT_TRUE(pc_->local_description() != NULL); | 2058 ASSERT_TRUE(pc_->local_description() != nullptr); |
2062 ASSERT_TRUE(pc_->remote_description() != NULL); | 2059 ASSERT_TRUE(pc_->remote_description() != nullptr); |
2063 | 2060 |
2064 const cricket::ContentInfo* content = | 2061 const cricket::ContentInfo* content = |
2065 cricket::GetFirstAudioContent(pc_->local_description()->description()); | 2062 cricket::GetFirstAudioContent(pc_->local_description()->description()); |
2066 ASSERT_TRUE(content != NULL); | 2063 ASSERT_TRUE(content != nullptr); |
2067 EXPECT_FALSE(content->rejected); | 2064 EXPECT_FALSE(content->rejected); |
2068 | 2065 |
2069 content = | 2066 content = |
2070 cricket::GetFirstVideoContent(pc_->local_description()->description()); | 2067 cricket::GetFirstVideoContent(pc_->local_description()->description()); |
2071 ASSERT_TRUE(content != NULL); | 2068 ASSERT_TRUE(content != nullptr); |
2072 EXPECT_FALSE(content->rejected); | 2069 EXPECT_FALSE(content->rejected); |
2073 #ifdef HAVE_SCTP | 2070 #ifdef HAVE_SCTP |
2074 content = | 2071 content = |
2075 cricket::GetFirstDataContent(pc_->local_description()->description()); | 2072 cricket::GetFirstDataContent(pc_->local_description()->description()); |
2076 ASSERT_TRUE(content != NULL); | 2073 ASSERT_TRUE(content != nullptr); |
2077 EXPECT_TRUE(content->rejected); | 2074 EXPECT_TRUE(content->rejected); |
2078 #endif | 2075 #endif |
2079 } | 2076 } |
2080 | 2077 |
2081 // Test that an offer can be received which offers DTLS with SDES fallback. | 2078 // Test that an offer can be received which offers DTLS with SDES fallback. |
2082 // Regression test for issue: | 2079 // Regression test for issue: |
2083 // https://bugs.chromium.org/p/webrtc/issues/detail?id=6972 | 2080 // https://bugs.chromium.org/p/webrtc/issues/detail?id=6972 |
2084 TEST_F(PeerConnectionInterfaceTest, ReceiveDtlsSdesFallbackOffer) { | 2081 TEST_F(PeerConnectionInterfaceTest, ReceiveDtlsSdesFallbackOffer) { |
2085 FakeConstraints constraints; | 2082 FakeConstraints constraints; |
2086 constraints.AddMandatory(webrtc::MediaConstraintsInterface::kEnableDtlsSrtp, | 2083 constraints.AddMandatory(webrtc::MediaConstraintsInterface::kEnableDtlsSrtp, |
(...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2402 pc_->local_streams()->at(0); | 2399 pc_->local_streams()->at(0); |
2403 | 2400 |
2404 pc_->Close(); | 2401 pc_->Close(); |
2405 | 2402 |
2406 pc_->RemoveStream(local_stream); | 2403 pc_->RemoveStream(local_stream); |
2407 EXPECT_FALSE(pc_->AddStream(local_stream)); | 2404 EXPECT_FALSE(pc_->AddStream(local_stream)); |
2408 | 2405 |
2409 ASSERT_FALSE(local_stream->GetAudioTracks().empty()); | 2406 ASSERT_FALSE(local_stream->GetAudioTracks().empty()); |
2410 rtc::scoped_refptr<webrtc::DtmfSenderInterface> dtmf_sender( | 2407 rtc::scoped_refptr<webrtc::DtmfSenderInterface> dtmf_sender( |
2411 pc_->CreateDtmfSender(local_stream->GetAudioTracks()[0])); | 2408 pc_->CreateDtmfSender(local_stream->GetAudioTracks()[0])); |
2412 EXPECT_TRUE(NULL == dtmf_sender); // local stream has been removed. | 2409 EXPECT_TRUE(nullptr == dtmf_sender); // local stream has been removed. |
2413 | 2410 |
2414 EXPECT_TRUE(pc_->CreateDataChannel("test", NULL) == NULL); | 2411 EXPECT_TRUE(pc_->CreateDataChannel("test", nullptr) == nullptr); |
2415 | 2412 |
2416 EXPECT_TRUE(pc_->local_description() != NULL); | 2413 EXPECT_TRUE(pc_->local_description() != nullptr); |
2417 EXPECT_TRUE(pc_->remote_description() != NULL); | 2414 EXPECT_TRUE(pc_->remote_description() != nullptr); |
2418 | 2415 |
2419 std::unique_ptr<SessionDescriptionInterface> offer; | 2416 std::unique_ptr<SessionDescriptionInterface> offer; |
2420 EXPECT_TRUE(DoCreateOffer(&offer, nullptr)); | 2417 EXPECT_TRUE(DoCreateOffer(&offer, nullptr)); |
2421 std::unique_ptr<SessionDescriptionInterface> answer; | 2418 std::unique_ptr<SessionDescriptionInterface> answer; |
2422 EXPECT_TRUE(DoCreateAnswer(&answer, nullptr)); | 2419 EXPECT_TRUE(DoCreateAnswer(&answer, nullptr)); |
2423 | 2420 |
2424 std::string sdp; | 2421 std::string sdp; |
2425 ASSERT_TRUE(pc_->remote_description()->ToString(&sdp)); | 2422 ASSERT_TRUE(pc_->remote_description()->ToString(&sdp)); |
2426 SessionDescriptionInterface* remote_offer = | 2423 SessionDescriptionInterface* remote_offer = webrtc::CreateSessionDescription( |
2427 webrtc::CreateSessionDescription(SessionDescriptionInterface::kOffer, | 2424 SessionDescriptionInterface::kOffer, sdp, nullptr); |
2428 sdp, NULL); | |
2429 EXPECT_FALSE(DoSetRemoteDescription(remote_offer)); | 2425 EXPECT_FALSE(DoSetRemoteDescription(remote_offer)); |
2430 | 2426 |
2431 ASSERT_TRUE(pc_->local_description()->ToString(&sdp)); | 2427 ASSERT_TRUE(pc_->local_description()->ToString(&sdp)); |
2432 SessionDescriptionInterface* local_offer = | 2428 SessionDescriptionInterface* local_offer = webrtc::CreateSessionDescription( |
2433 webrtc::CreateSessionDescription(SessionDescriptionInterface::kOffer, | 2429 SessionDescriptionInterface::kOffer, sdp, nullptr); |
2434 sdp, NULL); | |
2435 EXPECT_FALSE(DoSetLocalDescription(local_offer)); | 2430 EXPECT_FALSE(DoSetLocalDescription(local_offer)); |
2436 } | 2431 } |
2437 | 2432 |
2438 // Test that GetStats can still be called after PeerConnection::Close. | 2433 // Test that GetStats can still be called after PeerConnection::Close. |
2439 TEST_F(PeerConnectionInterfaceTest, CloseAndGetStats) { | 2434 TEST_F(PeerConnectionInterfaceTest, CloseAndGetStats) { |
2440 InitiateCall(); | 2435 InitiateCall(); |
2441 pc_->Close(); | 2436 pc_->Close(); |
2442 DoGetStats(NULL); | 2437 DoGetStats(nullptr); |
2443 } | 2438 } |
2444 | 2439 |
2445 // NOTE: The series of tests below come from what used to be | 2440 // NOTE: The series of tests below come from what used to be |
2446 // mediastreamsignaling_unittest.cc, and are mostly aimed at testing that | 2441 // mediastreamsignaling_unittest.cc, and are mostly aimed at testing that |
2447 // setting a remote or local description has the expected effects. | 2442 // setting a remote or local description has the expected effects. |
2448 | 2443 |
2449 // This test verifies that the remote MediaStreams corresponding to a received | 2444 // This test verifies that the remote MediaStreams corresponding to a received |
2450 // SDP string is created. In this test the two separate MediaStreams are | 2445 // SDP string is created. In this test the two separate MediaStreams are |
2451 // signaled. | 2446 // signaled. |
2452 TEST_F(PeerConnectionInterfaceTest, UpdateRemoteStreams) { | 2447 TEST_F(PeerConnectionInterfaceTest, UpdateRemoteStreams) { |
(...skipping 379 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2832 EXPECT_TRUE(DoSetLocalDescription(offer.release())); | 2827 EXPECT_TRUE(DoSetLocalDescription(offer.release())); |
2833 | 2828 |
2834 auto senders = pc_->GetSenders(); | 2829 auto senders = pc_->GetSenders(); |
2835 EXPECT_EQ(2u, senders.size()); | 2830 EXPECT_EQ(2u, senders.size()); |
2836 EXPECT_TRUE(ContainsSender(senders, kAudioTracks[0])); | 2831 EXPECT_TRUE(ContainsSender(senders, kAudioTracks[0])); |
2837 EXPECT_TRUE(ContainsSender(senders, kVideoTracks[0])); | 2832 EXPECT_TRUE(ContainsSender(senders, kVideoTracks[0])); |
2838 | 2833 |
2839 // Change the ssrc of the audio and video track. | 2834 // Change the ssrc of the audio and video track. |
2840 cricket::MediaContentDescription* desc = | 2835 cricket::MediaContentDescription* desc = |
2841 cricket::GetFirstAudioContentDescription(modified_offer->description()); | 2836 cricket::GetFirstAudioContentDescription(modified_offer->description()); |
2842 ASSERT_TRUE(desc != NULL); | 2837 ASSERT_TRUE(desc != nullptr); |
2843 for (StreamParams& stream : desc->mutable_streams()) { | 2838 for (StreamParams& stream : desc->mutable_streams()) { |
2844 for (unsigned int& ssrc : stream.ssrcs) { | 2839 for (unsigned int& ssrc : stream.ssrcs) { |
2845 ++ssrc; | 2840 ++ssrc; |
2846 } | 2841 } |
2847 } | 2842 } |
2848 | 2843 |
2849 desc = | 2844 desc = |
2850 cricket::GetFirstVideoContentDescription(modified_offer->description()); | 2845 cricket::GetFirstVideoContentDescription(modified_offer->description()); |
2851 ASSERT_TRUE(desc != NULL); | 2846 ASSERT_TRUE(desc != nullptr); |
2852 for (StreamParams& stream : desc->mutable_streams()) { | 2847 for (StreamParams& stream : desc->mutable_streams()) { |
2853 for (unsigned int& ssrc : stream.ssrcs) { | 2848 for (unsigned int& ssrc : stream.ssrcs) { |
2854 ++ssrc; | 2849 ++ssrc; |
2855 } | 2850 } |
2856 } | 2851 } |
2857 | 2852 |
2858 EXPECT_TRUE(DoSetLocalDescription(modified_offer.release())); | 2853 EXPECT_TRUE(DoSetLocalDescription(modified_offer.release())); |
2859 senders = pc_->GetSenders(); | 2854 senders = pc_->GetSenders(); |
2860 EXPECT_EQ(2u, senders.size()); | 2855 EXPECT_EQ(2u, senders.size()); |
2861 EXPECT_TRUE(ContainsSender(senders, kAudioTracks[0])); | 2856 EXPECT_TRUE(ContainsSender(senders, kAudioTracks[0])); |
(...skipping 547 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3409 EXPECT_NE(a, f); | 3404 EXPECT_NE(a, f); |
3410 | 3405 |
3411 PeerConnectionInterface::RTCConfiguration g; | 3406 PeerConnectionInterface::RTCConfiguration g; |
3412 g.disable_ipv6 = true; | 3407 g.disable_ipv6 = true; |
3413 EXPECT_NE(a, g); | 3408 EXPECT_NE(a, g); |
3414 | 3409 |
3415 PeerConnectionInterface::RTCConfiguration h( | 3410 PeerConnectionInterface::RTCConfiguration h( |
3416 PeerConnectionInterface::RTCConfigurationType::kAggressive); | 3411 PeerConnectionInterface::RTCConfigurationType::kAggressive); |
3417 EXPECT_NE(a, h); | 3412 EXPECT_NE(a, h); |
3418 } | 3413 } |
OLD | NEW |