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

Side by Side Diff: webrtc/api/peerconnection_unittest.cc

Issue 1930463002: Replace scoped_ptr with unique_ptr in webrtc/api/ (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 4 years, 7 months 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
« no previous file with comments | « webrtc/api/peerconnection.cc ('k') | webrtc/api/peerconnectionendtoend_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
11 #include <stdio.h> 11 #include <stdio.h>
12 12
13 #include <algorithm> 13 #include <algorithm>
14 #include <list> 14 #include <list>
15 #include <map> 15 #include <map>
16 #include <memory>
16 #include <utility> 17 #include <utility>
17 #include <vector> 18 #include <vector>
18 19
19 #include "webrtc/api/dtmfsender.h" 20 #include "webrtc/api/dtmfsender.h"
20 #include "webrtc/api/fakemetricsobserver.h" 21 #include "webrtc/api/fakemetricsobserver.h"
21 #include "webrtc/api/localaudiosource.h" 22 #include "webrtc/api/localaudiosource.h"
22 #include "webrtc/api/mediastreaminterface.h" 23 #include "webrtc/api/mediastreaminterface.h"
23 #include "webrtc/api/peerconnection.h" 24 #include "webrtc/api/peerconnection.h"
24 #include "webrtc/api/peerconnectionfactory.h" 25 #include "webrtc/api/peerconnectionfactory.h"
25 #include "webrtc/api/peerconnectioninterface.h" 26 #include "webrtc/api/peerconnectioninterface.h"
26 #include "webrtc/api/test/fakeaudiocapturemodule.h" 27 #include "webrtc/api/test/fakeaudiocapturemodule.h"
27 #include "webrtc/api/test/fakeconstraints.h" 28 #include "webrtc/api/test/fakeconstraints.h"
28 #include "webrtc/api/test/fakedtlsidentitystore.h" 29 #include "webrtc/api/test/fakedtlsidentitystore.h"
29 #include "webrtc/api/test/fakeperiodicvideocapturer.h" 30 #include "webrtc/api/test/fakeperiodicvideocapturer.h"
30 #include "webrtc/api/test/fakevideotrackrenderer.h" 31 #include "webrtc/api/test/fakevideotrackrenderer.h"
31 #include "webrtc/api/test/mockpeerconnectionobservers.h" 32 #include "webrtc/api/test/mockpeerconnectionobservers.h"
32 #include "webrtc/base/gunit.h" 33 #include "webrtc/base/gunit.h"
33 #include "webrtc/base/physicalsocketserver.h" 34 #include "webrtc/base/physicalsocketserver.h"
34 #include "webrtc/base/scoped_ptr.h"
35 #include "webrtc/base/ssladapter.h" 35 #include "webrtc/base/ssladapter.h"
36 #include "webrtc/base/sslstreamadapter.h" 36 #include "webrtc/base/sslstreamadapter.h"
37 #include "webrtc/base/thread.h" 37 #include "webrtc/base/thread.h"
38 #include "webrtc/base/virtualsocketserver.h" 38 #include "webrtc/base/virtualsocketserver.h"
39 #include "webrtc/media/engine/fakewebrtcvideoengine.h" 39 #include "webrtc/media/engine/fakewebrtcvideoengine.h"
40 #include "webrtc/p2p/base/p2pconstants.h" 40 #include "webrtc/p2p/base/p2pconstants.h"
41 #include "webrtc/p2p/base/sessiondescription.h" 41 #include "webrtc/p2p/base/sessiondescription.h"
42 #include "webrtc/p2p/client/fakeportallocator.h" 42 #include "webrtc/p2p/client/fakeportallocator.h"
43 #include "webrtc/pc/mediasession.h" 43 #include "webrtc/pc/mediasession.h"
44 44
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 }; 147 };
148 148
149 class PeerConnectionTestClient : public webrtc::PeerConnectionObserver, 149 class PeerConnectionTestClient : public webrtc::PeerConnectionObserver,
150 public SignalingMessageReceiver, 150 public SignalingMessageReceiver,
151 public ObserverInterface { 151 public ObserverInterface {
152 public: 152 public:
153 static PeerConnectionTestClient* CreateClientWithDtlsIdentityStore( 153 static PeerConnectionTestClient* CreateClientWithDtlsIdentityStore(
154 const std::string& id, 154 const std::string& id,
155 const MediaConstraintsInterface* constraints, 155 const MediaConstraintsInterface* constraints,
156 const PeerConnectionFactory::Options* options, 156 const PeerConnectionFactory::Options* options,
157 rtc::scoped_ptr<webrtc::DtlsIdentityStoreInterface> dtls_identity_store, 157 std::unique_ptr<webrtc::DtlsIdentityStoreInterface> dtls_identity_store,
158 bool prefer_constraint_apis, 158 bool prefer_constraint_apis,
159 rtc::Thread* worker_thread) { 159 rtc::Thread* worker_thread) {
160 PeerConnectionTestClient* client(new PeerConnectionTestClient(id)); 160 PeerConnectionTestClient* client(new PeerConnectionTestClient(id));
161 if (!client->Init(constraints, options, std::move(dtls_identity_store), 161 if (!client->Init(constraints, options, std::move(dtls_identity_store),
162 prefer_constraint_apis, worker_thread)) { 162 prefer_constraint_apis, worker_thread)) {
163 delete client; 163 delete client;
164 return nullptr; 164 return nullptr;
165 } 165 }
166 return client; 166 return client;
167 } 167 }
168 168
169 static PeerConnectionTestClient* CreateClient( 169 static PeerConnectionTestClient* CreateClient(
170 const std::string& id, 170 const std::string& id,
171 const MediaConstraintsInterface* constraints, 171 const MediaConstraintsInterface* constraints,
172 const PeerConnectionFactory::Options* options, 172 const PeerConnectionFactory::Options* options,
173 rtc::Thread* worker_thread) { 173 rtc::Thread* worker_thread) {
174 rtc::scoped_ptr<FakeDtlsIdentityStore> dtls_identity_store( 174 std::unique_ptr<FakeDtlsIdentityStore> dtls_identity_store(
175 rtc::SSLStreamAdapter::HaveDtlsSrtp() ? new FakeDtlsIdentityStore() 175 rtc::SSLStreamAdapter::HaveDtlsSrtp() ? new FakeDtlsIdentityStore()
176 : nullptr); 176 : nullptr);
177 177
178 return CreateClientWithDtlsIdentityStore(id, constraints, options, 178 return CreateClientWithDtlsIdentityStore(id, constraints, options,
179 std::move(dtls_identity_store), 179 std::move(dtls_identity_store),
180 true, worker_thread); 180 true, worker_thread);
181 } 181 }
182 182
183 static PeerConnectionTestClient* CreateClientPreferNoConstraints( 183 static PeerConnectionTestClient* CreateClientPreferNoConstraints(
184 const std::string& id, 184 const std::string& id,
185 const PeerConnectionFactory::Options* options, 185 const PeerConnectionFactory::Options* options,
186 rtc::Thread* worker_thread) { 186 rtc::Thread* worker_thread) {
187 rtc::scoped_ptr<FakeDtlsIdentityStore> dtls_identity_store( 187 std::unique_ptr<FakeDtlsIdentityStore> dtls_identity_store(
188 rtc::SSLStreamAdapter::HaveDtlsSrtp() ? new FakeDtlsIdentityStore() 188 rtc::SSLStreamAdapter::HaveDtlsSrtp() ? new FakeDtlsIdentityStore()
189 : nullptr); 189 : nullptr);
190 190
191 return CreateClientWithDtlsIdentityStore(id, nullptr, options, 191 return CreateClientWithDtlsIdentityStore(id, nullptr, options,
192 std::move(dtls_identity_store), 192 std::move(dtls_identity_store),
193 false, worker_thread); 193 false, worker_thread);
194 } 194 }
195 195
196 ~PeerConnectionTestClient() { 196 ~PeerConnectionTestClient() {
197 } 197 }
198 198
199 void Negotiate() { Negotiate(true, true); } 199 void Negotiate() { Negotiate(true, true); }
200 200
201 void Negotiate(bool audio, bool video) { 201 void Negotiate(bool audio, bool video) {
202 rtc::scoped_ptr<SessionDescriptionInterface> offer; 202 std::unique_ptr<SessionDescriptionInterface> offer;
203 ASSERT_TRUE(DoCreateOffer(&offer)); 203 ASSERT_TRUE(DoCreateOffer(&offer));
204 204
205 if (offer->description()->GetContentByName("audio")) { 205 if (offer->description()->GetContentByName("audio")) {
206 offer->description()->GetContentByName("audio")->rejected = !audio; 206 offer->description()->GetContentByName("audio")->rejected = !audio;
207 } 207 }
208 if (offer->description()->GetContentByName("video")) { 208 if (offer->description()->GetContentByName("video")) {
209 offer->description()->GetContentByName("video")->rejected = !video; 209 offer->description()->GetContentByName("video")->rejected = !video;
210 } 210 }
211 211
212 std::string sdp; 212 std::string sdp;
(...skipping 11 matching lines...) Expand all
224 } else { 224 } else {
225 HandleIncomingAnswer(msg); 225 HandleIncomingAnswer(msg);
226 } 226 }
227 } 227 }
228 228
229 // SignalingMessageReceiver callback. 229 // SignalingMessageReceiver callback.
230 void ReceiveIceMessage(const std::string& sdp_mid, 230 void ReceiveIceMessage(const std::string& sdp_mid,
231 int sdp_mline_index, 231 int sdp_mline_index,
232 const std::string& msg) override { 232 const std::string& msg) override {
233 LOG(INFO) << id_ << "ReceiveIceMessage"; 233 LOG(INFO) << id_ << "ReceiveIceMessage";
234 rtc::scoped_ptr<webrtc::IceCandidateInterface> candidate( 234 std::unique_ptr<webrtc::IceCandidateInterface> candidate(
235 webrtc::CreateIceCandidate(sdp_mid, sdp_mline_index, msg, nullptr)); 235 webrtc::CreateIceCandidate(sdp_mid, sdp_mline_index, msg, nullptr));
236 EXPECT_TRUE(pc()->AddIceCandidate(candidate.get())); 236 EXPECT_TRUE(pc()->AddIceCandidate(candidate.get()));
237 } 237 }
238 238
239 // PeerConnectionObserver callbacks. 239 // PeerConnectionObserver callbacks.
240 void OnSignalingChange( 240 void OnSignalingChange(
241 webrtc::PeerConnectionInterface::SignalingState new_state) override { 241 webrtc::PeerConnectionInterface::SignalingState new_state) override {
242 EXPECT_EQ(pc()->signaling_state(), new_state); 242 EXPECT_EQ(pc()->signaling_state(), new_state);
243 } 243 }
244 void OnAddStream(MediaStreamInterface* media_stream) override { 244 void OnAddStream(MediaStreamInterface* media_stream) override {
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after
542 } 542 }
543 for (const auto& renderer : removed_fake_video_renderers_) { 543 for (const auto& renderer : removed_fake_video_renderers_) {
544 total += renderer->num_rendered_frames(); 544 total += renderer->num_rendered_frames();
545 } 545 }
546 } 546 }
547 return total; 547 return total;
548 } 548 }
549 549
550 // Verify the CreateDtmfSender interface 550 // Verify the CreateDtmfSender interface
551 void VerifyDtmf() { 551 void VerifyDtmf() {
552 rtc::scoped_ptr<DummyDtmfObserver> observer(new DummyDtmfObserver()); 552 std::unique_ptr<DummyDtmfObserver> observer(new DummyDtmfObserver());
553 rtc::scoped_refptr<DtmfSenderInterface> dtmf_sender; 553 rtc::scoped_refptr<DtmfSenderInterface> dtmf_sender;
554 554
555 // We can't create a DTMF sender with an invalid audio track or a non local 555 // We can't create a DTMF sender with an invalid audio track or a non local
556 // track. 556 // track.
557 EXPECT_TRUE(peer_connection_->CreateDtmfSender(nullptr) == nullptr); 557 EXPECT_TRUE(peer_connection_->CreateDtmfSender(nullptr) == nullptr);
558 rtc::scoped_refptr<webrtc::AudioTrackInterface> non_localtrack( 558 rtc::scoped_refptr<webrtc::AudioTrackInterface> non_localtrack(
559 peer_connection_factory_->CreateAudioTrack("dummy_track", nullptr)); 559 peer_connection_factory_->CreateAudioTrack("dummy_track", nullptr));
560 EXPECT_TRUE(peer_connection_->CreateDtmfSender(non_localtrack) == nullptr); 560 EXPECT_TRUE(peer_connection_->CreateDtmfSender(non_localtrack) == nullptr);
561 561
562 // We should be able to create a DTMF sender from a local track. 562 // We should be able to create a DTMF sender from a local track.
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after
797 private: 797 private:
798 bool completed_; 798 bool completed_;
799 std::vector<std::string> tones_; 799 std::vector<std::string> tones_;
800 }; 800 };
801 801
802 explicit PeerConnectionTestClient(const std::string& id) : id_(id) {} 802 explicit PeerConnectionTestClient(const std::string& id) : id_(id) {}
803 803
804 bool Init( 804 bool Init(
805 const MediaConstraintsInterface* constraints, 805 const MediaConstraintsInterface* constraints,
806 const PeerConnectionFactory::Options* options, 806 const PeerConnectionFactory::Options* options,
807 rtc::scoped_ptr<webrtc::DtlsIdentityStoreInterface> dtls_identity_store, 807 std::unique_ptr<webrtc::DtlsIdentityStoreInterface> dtls_identity_store,
808 bool prefer_constraint_apis, 808 bool prefer_constraint_apis,
809 rtc::Thread* worker_thread) { 809 rtc::Thread* worker_thread) {
810 EXPECT_TRUE(!peer_connection_); 810 EXPECT_TRUE(!peer_connection_);
811 EXPECT_TRUE(!peer_connection_factory_); 811 EXPECT_TRUE(!peer_connection_factory_);
812 if (!prefer_constraint_apis) { 812 if (!prefer_constraint_apis) {
813 EXPECT_TRUE(!constraints); 813 EXPECT_TRUE(!constraints);
814 } 814 }
815 prefer_constraint_apis_ = prefer_constraint_apis; 815 prefer_constraint_apis_ = prefer_constraint_apis;
816 816
817 rtc::scoped_ptr<cricket::PortAllocator> port_allocator( 817 std::unique_ptr<cricket::PortAllocator> port_allocator(
818 new cricket::FakePortAllocator(worker_thread, nullptr)); 818 new cricket::FakePortAllocator(worker_thread, nullptr));
819 fake_audio_capture_module_ = FakeAudioCaptureModule::Create(); 819 fake_audio_capture_module_ = FakeAudioCaptureModule::Create();
820 820
821 if (fake_audio_capture_module_ == nullptr) { 821 if (fake_audio_capture_module_ == nullptr) {
822 return false; 822 return false;
823 } 823 }
824 fake_video_decoder_factory_ = new FakeWebRtcVideoDecoderFactory(); 824 fake_video_decoder_factory_ = new FakeWebRtcVideoDecoderFactory();
825 fake_video_encoder_factory_ = new FakeWebRtcVideoEncoderFactory(); 825 fake_video_encoder_factory_ = new FakeWebRtcVideoEncoderFactory();
826 peer_connection_factory_ = webrtc::CreatePeerConnectionFactory( 826 peer_connection_factory_ = webrtc::CreatePeerConnectionFactory(
827 worker_thread, rtc::Thread::Current(), fake_audio_capture_module_, 827 worker_thread, rtc::Thread::Current(), fake_audio_capture_module_,
828 fake_video_encoder_factory_, fake_video_decoder_factory_); 828 fake_video_encoder_factory_, fake_video_decoder_factory_);
829 if (!peer_connection_factory_) { 829 if (!peer_connection_factory_) {
830 return false; 830 return false;
831 } 831 }
832 if (options) { 832 if (options) {
833 peer_connection_factory_->SetOptions(*options); 833 peer_connection_factory_->SetOptions(*options);
834 } 834 }
835 peer_connection_ = CreatePeerConnection( 835 peer_connection_ = CreatePeerConnection(
836 std::move(port_allocator), constraints, std::move(dtls_identity_store)); 836 std::move(port_allocator), constraints, std::move(dtls_identity_store));
837 return peer_connection_.get() != nullptr; 837 return peer_connection_.get() != nullptr;
838 } 838 }
839 839
840 rtc::scoped_refptr<webrtc::PeerConnectionInterface> CreatePeerConnection( 840 rtc::scoped_refptr<webrtc::PeerConnectionInterface> CreatePeerConnection(
841 rtc::scoped_ptr<cricket::PortAllocator> port_allocator, 841 std::unique_ptr<cricket::PortAllocator> port_allocator,
842 const MediaConstraintsInterface* constraints, 842 const MediaConstraintsInterface* constraints,
843 rtc::scoped_ptr<webrtc::DtlsIdentityStoreInterface> dtls_identity_store) { 843 std::unique_ptr<webrtc::DtlsIdentityStoreInterface> dtls_identity_store) {
844 // CreatePeerConnection with RTCConfiguration. 844 // CreatePeerConnection with RTCConfiguration.
845 webrtc::PeerConnectionInterface::RTCConfiguration config; 845 webrtc::PeerConnectionInterface::RTCConfiguration config;
846 webrtc::PeerConnectionInterface::IceServer ice_server; 846 webrtc::PeerConnectionInterface::IceServer ice_server;
847 ice_server.uri = "stun:stun.l.google.com:19302"; 847 ice_server.uri = "stun:stun.l.google.com:19302";
848 config.servers.push_back(ice_server); 848 config.servers.push_back(ice_server);
849 849
850 return peer_connection_factory_->CreatePeerConnection( 850 return peer_connection_factory_->CreatePeerConnection(
851 config, constraints, std::move(port_allocator), 851 config, constraints, std::move(port_allocator),
852 std::move(dtls_identity_store), this); 852 std::move(dtls_identity_store), this);
853 } 853 }
854 854
855 void HandleIncomingOffer(const std::string& msg) { 855 void HandleIncomingOffer(const std::string& msg) {
856 LOG(INFO) << id_ << "HandleIncomingOffer "; 856 LOG(INFO) << id_ << "HandleIncomingOffer ";
857 if (NumberOfLocalMediaStreams() == 0 && auto_add_stream_) { 857 if (NumberOfLocalMediaStreams() == 0 && auto_add_stream_) {
858 // If we are not sending any streams ourselves it is time to add some. 858 // If we are not sending any streams ourselves it is time to add some.
859 AddMediaStream(true, true); 859 AddMediaStream(true, true);
860 } 860 }
861 rtc::scoped_ptr<SessionDescriptionInterface> desc( 861 std::unique_ptr<SessionDescriptionInterface> desc(
862 webrtc::CreateSessionDescription("offer", msg, nullptr)); 862 webrtc::CreateSessionDescription("offer", msg, nullptr));
863 EXPECT_TRUE(DoSetRemoteDescription(desc.release())); 863 EXPECT_TRUE(DoSetRemoteDescription(desc.release()));
864 rtc::scoped_ptr<SessionDescriptionInterface> answer; 864 std::unique_ptr<SessionDescriptionInterface> answer;
865 EXPECT_TRUE(DoCreateAnswer(&answer)); 865 EXPECT_TRUE(DoCreateAnswer(&answer));
866 std::string sdp; 866 std::string sdp;
867 EXPECT_TRUE(answer->ToString(&sdp)); 867 EXPECT_TRUE(answer->ToString(&sdp));
868 EXPECT_TRUE(DoSetLocalDescription(answer.release())); 868 EXPECT_TRUE(DoSetLocalDescription(answer.release()));
869 if (signaling_message_receiver_) { 869 if (signaling_message_receiver_) {
870 signaling_message_receiver_->ReceiveSdpMessage( 870 signaling_message_receiver_->ReceiveSdpMessage(
871 webrtc::SessionDescriptionInterface::kAnswer, sdp); 871 webrtc::SessionDescriptionInterface::kAnswer, sdp);
872 } 872 }
873 } 873 }
874 874
875 void HandleIncomingAnswer(const std::string& msg) { 875 void HandleIncomingAnswer(const std::string& msg) {
876 LOG(INFO) << id_ << "HandleIncomingAnswer"; 876 LOG(INFO) << id_ << "HandleIncomingAnswer";
877 rtc::scoped_ptr<SessionDescriptionInterface> desc( 877 std::unique_ptr<SessionDescriptionInterface> desc(
878 webrtc::CreateSessionDescription("answer", msg, nullptr)); 878 webrtc::CreateSessionDescription("answer", msg, nullptr));
879 EXPECT_TRUE(DoSetRemoteDescription(desc.release())); 879 EXPECT_TRUE(DoSetRemoteDescription(desc.release()));
880 } 880 }
881 881
882 bool DoCreateOfferAnswer(rtc::scoped_ptr<SessionDescriptionInterface>* desc, 882 bool DoCreateOfferAnswer(std::unique_ptr<SessionDescriptionInterface>* desc,
883 bool offer) { 883 bool offer) {
884 rtc::scoped_refptr<MockCreateSessionDescriptionObserver> 884 rtc::scoped_refptr<MockCreateSessionDescriptionObserver>
885 observer(new rtc::RefCountedObject< 885 observer(new rtc::RefCountedObject<
886 MockCreateSessionDescriptionObserver>()); 886 MockCreateSessionDescriptionObserver>());
887 if (prefer_constraint_apis_) { 887 if (prefer_constraint_apis_) {
888 if (offer) { 888 if (offer) {
889 pc()->CreateOffer(observer, &offer_answer_constraints_); 889 pc()->CreateOffer(observer, &offer_answer_constraints_);
890 } else { 890 } else {
891 pc()->CreateAnswer(observer, &offer_answer_constraints_); 891 pc()->CreateAnswer(observer, &offer_answer_constraints_);
892 } 892 }
893 } else { 893 } else {
894 if (offer) { 894 if (offer) {
895 pc()->CreateOffer(observer, offer_answer_options_); 895 pc()->CreateOffer(observer, offer_answer_options_);
896 } else { 896 } else {
897 pc()->CreateAnswer(observer, offer_answer_options_); 897 pc()->CreateAnswer(observer, offer_answer_options_);
898 } 898 }
899 } 899 }
900 EXPECT_EQ_WAIT(true, observer->called(), kMaxWaitMs); 900 EXPECT_EQ_WAIT(true, observer->called(), kMaxWaitMs);
901 desc->reset(observer->release_desc()); 901 desc->reset(observer->release_desc());
902 if (observer->result() && ExpectIceRestart()) { 902 if (observer->result() && ExpectIceRestart()) {
903 EXPECT_EQ(0u, (*desc)->candidates(0)->count()); 903 EXPECT_EQ(0u, (*desc)->candidates(0)->count());
904 } 904 }
905 return observer->result(); 905 return observer->result();
906 } 906 }
907 907
908 bool DoCreateOffer(rtc::scoped_ptr<SessionDescriptionInterface>* desc) { 908 bool DoCreateOffer(std::unique_ptr<SessionDescriptionInterface>* desc) {
909 return DoCreateOfferAnswer(desc, true); 909 return DoCreateOfferAnswer(desc, true);
910 } 910 }
911 911
912 bool DoCreateAnswer(rtc::scoped_ptr<SessionDescriptionInterface>* desc) { 912 bool DoCreateAnswer(std::unique_ptr<SessionDescriptionInterface>* desc) {
913 return DoCreateOfferAnswer(desc, false); 913 return DoCreateOfferAnswer(desc, false);
914 } 914 }
915 915
916 bool DoSetLocalDescription(SessionDescriptionInterface* desc) { 916 bool DoSetLocalDescription(SessionDescriptionInterface* desc) {
917 rtc::scoped_refptr<MockSetSessionDescriptionObserver> 917 rtc::scoped_refptr<MockSetSessionDescriptionObserver>
918 observer(new rtc::RefCountedObject< 918 observer(new rtc::RefCountedObject<
919 MockSetSessionDescriptionObserver>()); 919 MockSetSessionDescriptionObserver>());
920 LOG(INFO) << id_ << "SetLocalDescription "; 920 LOG(INFO) << id_ << "SetLocalDescription ";
921 pc()->SetLocalDescription(observer, desc); 921 pc()->SetLocalDescription(observer, desc);
922 // Ignore the observer result. If we wait for the result with 922 // Ignore the observer result. If we wait for the result with
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
975 bool prefer_constraint_apis_ = true; 975 bool prefer_constraint_apis_ = true;
976 bool auto_add_stream_ = true; 976 bool auto_add_stream_ = true;
977 977
978 typedef std::pair<std::string, std::string> IceUfragPwdPair; 978 typedef std::pair<std::string, std::string> IceUfragPwdPair;
979 std::map<int, IceUfragPwdPair> ice_ufrag_pwd_; 979 std::map<int, IceUfragPwdPair> ice_ufrag_pwd_;
980 bool expect_ice_restart_ = false; 980 bool expect_ice_restart_ = false;
981 981
982 // Needed to keep track of number of frames sent. 982 // Needed to keep track of number of frames sent.
983 rtc::scoped_refptr<FakeAudioCaptureModule> fake_audio_capture_module_; 983 rtc::scoped_refptr<FakeAudioCaptureModule> fake_audio_capture_module_;
984 // Needed to keep track of number of frames received. 984 // Needed to keep track of number of frames received.
985 std::map<std::string, rtc::scoped_ptr<webrtc::FakeVideoTrackRenderer>> 985 std::map<std::string, std::unique_ptr<webrtc::FakeVideoTrackRenderer>>
986 fake_video_renderers_; 986 fake_video_renderers_;
987 // Needed to ensure frames aren't received for removed tracks. 987 // Needed to ensure frames aren't received for removed tracks.
988 std::vector<rtc::scoped_ptr<webrtc::FakeVideoTrackRenderer>> 988 std::vector<std::unique_ptr<webrtc::FakeVideoTrackRenderer>>
989 removed_fake_video_renderers_; 989 removed_fake_video_renderers_;
990 // Needed to keep track of number of frames received when external decoder 990 // Needed to keep track of number of frames received when external decoder
991 // used. 991 // used.
992 FakeWebRtcVideoDecoderFactory* fake_video_decoder_factory_ = nullptr; 992 FakeWebRtcVideoDecoderFactory* fake_video_decoder_factory_ = nullptr;
993 FakeWebRtcVideoEncoderFactory* fake_video_encoder_factory_ = nullptr; 993 FakeWebRtcVideoEncoderFactory* fake_video_encoder_factory_ = nullptr;
994 bool video_decoder_factory_enabled_ = false; 994 bool video_decoder_factory_enabled_ = false;
995 webrtc::FakeConstraints video_constraints_; 995 webrtc::FakeConstraints video_constraints_;
996 996
997 // For remote peer communication. 997 // For remote peer communication.
998 SignalingMessageReceiver* signaling_message_receiver_ = nullptr; 998 SignalingMessageReceiver* signaling_message_receiver_ = nullptr;
999 999
1000 // Store references to the video capturers we've created, so that we can stop 1000 // Store references to the video capturers we've created, so that we can stop
1001 // them, if required. 1001 // them, if required.
1002 std::vector<cricket::FakeVideoCapturer*> video_capturers_; 1002 std::vector<cricket::FakeVideoCapturer*> video_capturers_;
1003 webrtc::VideoRotation capture_rotation_ = webrtc::kVideoRotation_0; 1003 webrtc::VideoRotation capture_rotation_ = webrtc::kVideoRotation_0;
1004 // |local_video_renderer_| attached to the first created local video track. 1004 // |local_video_renderer_| attached to the first created local video track.
1005 rtc::scoped_ptr<webrtc::FakeVideoTrackRenderer> local_video_renderer_; 1005 std::unique_ptr<webrtc::FakeVideoTrackRenderer> local_video_renderer_;
1006 1006
1007 webrtc::FakeConstraints offer_answer_constraints_; 1007 webrtc::FakeConstraints offer_answer_constraints_;
1008 PeerConnectionInterface::RTCOfferAnswerOptions offer_answer_options_; 1008 PeerConnectionInterface::RTCOfferAnswerOptions offer_answer_options_;
1009 bool remove_msid_ = false; // True if MSID should be removed in received SDP. 1009 bool remove_msid_ = false; // True if MSID should be removed in received SDP.
1010 bool remove_bundle_ = 1010 bool remove_bundle_ =
1011 false; // True if bundle should be removed in received SDP. 1011 false; // True if bundle should be removed in received SDP.
1012 bool remove_sdes_ = 1012 bool remove_sdes_ =
1013 false; // True if a=crypto should be removed in received SDP. 1013 false; // True if a=crypto should be removed in received SDP.
1014 // |remove_cvo_| is true if extension urn:3gpp:video-orientation should be 1014 // |remove_cvo_| is true if extension urn:3gpp:video-orientation should be
1015 // removed in the received SDP. 1015 // removed in the received SDP.
1016 bool remove_cvo_ = false; 1016 bool remove_cvo_ = false;
1017 1017
1018 rtc::scoped_refptr<DataChannelInterface> data_channel_; 1018 rtc::scoped_refptr<DataChannelInterface> data_channel_;
1019 rtc::scoped_ptr<MockDataChannelObserver> data_observer_; 1019 std::unique_ptr<MockDataChannelObserver> data_observer_;
1020 }; 1020 };
1021 1021
1022 class P2PTestConductor : public testing::Test { 1022 class P2PTestConductor : public testing::Test {
1023 public: 1023 public:
1024 P2PTestConductor() 1024 P2PTestConductor()
1025 : pss_(new rtc::PhysicalSocketServer), 1025 : pss_(new rtc::PhysicalSocketServer),
1026 ss_(new rtc::VirtualSocketServer(pss_.get())), 1026 ss_(new rtc::VirtualSocketServer(pss_.get())),
1027 ss_scope_(ss_.get()) { 1027 ss_scope_(ss_.get()) {
1028 RTC_CHECK(worker_thread_.Start()); 1028 RTC_CHECK(worker_thread_.Start());
1029 } 1029 }
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
1246 ASSERT_TRUE(CreateTestClients(&setup_constraints, &setup_constraints)); 1246 ASSERT_TRUE(CreateTestClients(&setup_constraints, &setup_constraints));
1247 LocalP2PTest(); 1247 LocalP2PTest();
1248 VerifyRenderedSize(640, 480); 1248 VerifyRenderedSize(640, 480);
1249 } 1249 }
1250 1250
1251 PeerConnectionTestClient* CreateDtlsClientWithAlternateKey() { 1251 PeerConnectionTestClient* CreateDtlsClientWithAlternateKey() {
1252 FakeConstraints setup_constraints; 1252 FakeConstraints setup_constraints;
1253 setup_constraints.AddMandatory(MediaConstraintsInterface::kEnableDtlsSrtp, 1253 setup_constraints.AddMandatory(MediaConstraintsInterface::kEnableDtlsSrtp,
1254 true); 1254 true);
1255 1255
1256 rtc::scoped_ptr<FakeDtlsIdentityStore> dtls_identity_store( 1256 std::unique_ptr<FakeDtlsIdentityStore> dtls_identity_store(
1257 rtc::SSLStreamAdapter::HaveDtlsSrtp() ? new FakeDtlsIdentityStore() 1257 rtc::SSLStreamAdapter::HaveDtlsSrtp() ? new FakeDtlsIdentityStore()
1258 : nullptr); 1258 : nullptr);
1259 dtls_identity_store->use_alternate_key(); 1259 dtls_identity_store->use_alternate_key();
1260 1260
1261 // Make sure the new client is using a different certificate. 1261 // Make sure the new client is using a different certificate.
1262 return PeerConnectionTestClient::CreateClientWithDtlsIdentityStore( 1262 return PeerConnectionTestClient::CreateClientWithDtlsIdentityStore(
1263 "New Peer: ", &setup_constraints, nullptr, 1263 "New Peer: ", &setup_constraints, nullptr,
1264 std::move(dtls_identity_store), prefer_constraint_apis_, 1264 std::move(dtls_identity_store), prefer_constraint_apis_,
1265 &worker_thread_); 1265 &worker_thread_);
1266 } 1266 }
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
1298 PeerConnectionTestClient* client) { 1298 PeerConnectionTestClient* client) {
1299 PeerConnectionTestClient* old = receiving_client_.release(); 1299 PeerConnectionTestClient* old = receiving_client_.release();
1300 receiving_client_.reset(client); 1300 receiving_client_.reset(client);
1301 return old; 1301 return old;
1302 } 1302 }
1303 1303
1304 private: 1304 private:
1305 // |worker_thread_| is used by both |initiating_client_| and 1305 // |worker_thread_| is used by both |initiating_client_| and
1306 // |receiving_client_|. Must be destroyed last. 1306 // |receiving_client_|. Must be destroyed last.
1307 rtc::Thread worker_thread_; 1307 rtc::Thread worker_thread_;
1308 rtc::scoped_ptr<rtc::PhysicalSocketServer> pss_; 1308 std::unique_ptr<rtc::PhysicalSocketServer> pss_;
1309 rtc::scoped_ptr<rtc::VirtualSocketServer> ss_; 1309 std::unique_ptr<rtc::VirtualSocketServer> ss_;
1310 rtc::SocketServerScope ss_scope_; 1310 rtc::SocketServerScope ss_scope_;
1311 rtc::scoped_ptr<PeerConnectionTestClient> initiating_client_; 1311 std::unique_ptr<PeerConnectionTestClient> initiating_client_;
1312 rtc::scoped_ptr<PeerConnectionTestClient> receiving_client_; 1312 std::unique_ptr<PeerConnectionTestClient> receiving_client_;
1313 bool prefer_constraint_apis_ = true; 1313 bool prefer_constraint_apis_ = true;
1314 }; 1314 };
1315 1315
1316 // Disable for TSan v2, see 1316 // Disable for TSan v2, see
1317 // https://code.google.com/p/webrtc/issues/detail?id=1205 for details. 1317 // https://code.google.com/p/webrtc/issues/detail?id=1205 for details.
1318 #if !defined(THREAD_SANITIZER) 1318 #if !defined(THREAD_SANITIZER)
1319 1319
1320 // This test sets up a Jsep call between two parties and test Dtmf. 1320 // This test sets up a Jsep call between two parties and test Dtmf.
1321 // TODO(holmer): Disabled due to sometimes crashing on buildbots. 1321 // TODO(holmer): Disabled due to sometimes crashing on buildbots.
1322 // See issue webrtc/2378. 1322 // See issue webrtc/2378.
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
1398 } 1398 }
1399 1399
1400 // This test sets up a call transfer to a new caller with a different DTLS 1400 // This test sets up a call transfer to a new caller with a different DTLS
1401 // fingerprint. 1401 // fingerprint.
1402 TEST_F(P2PTestConductor, LocalP2PTestDtlsTransferCallee) { 1402 TEST_F(P2PTestConductor, LocalP2PTestDtlsTransferCallee) {
1403 MAYBE_SKIP_TEST(rtc::SSLStreamAdapter::HaveDtlsSrtp); 1403 MAYBE_SKIP_TEST(rtc::SSLStreamAdapter::HaveDtlsSrtp);
1404 SetupAndVerifyDtlsCall(); 1404 SetupAndVerifyDtlsCall();
1405 1405
1406 // Keeping the original peer around which will still send packets to the 1406 // Keeping the original peer around which will still send packets to the
1407 // receiving client. These SRTP packets will be dropped. 1407 // receiving client. These SRTP packets will be dropped.
1408 rtc::scoped_ptr<PeerConnectionTestClient> original_peer( 1408 std::unique_ptr<PeerConnectionTestClient> original_peer(
1409 set_initializing_client(CreateDtlsClientWithAlternateKey())); 1409 set_initializing_client(CreateDtlsClientWithAlternateKey()));
1410 original_peer->pc()->Close(); 1410 original_peer->pc()->Close();
1411 1411
1412 SetSignalingReceivers(); 1412 SetSignalingReceivers();
1413 receiving_client()->SetExpectIceRestart(true); 1413 receiving_client()->SetExpectIceRestart(true);
1414 LocalP2PTest(); 1414 LocalP2PTest();
1415 VerifyRenderedSize(640, 480); 1415 VerifyRenderedSize(640, 480);
1416 } 1416 }
1417 1417
1418 // This test sets up a non-bundle call and apply bundle during ICE restart. When 1418 // This test sets up a non-bundle call and apply bundle during ICE restart. When
(...skipping 17 matching lines...) Expand all
1436 } 1436 }
1437 1437
1438 // This test sets up a call transfer to a new callee with a different DTLS 1438 // This test sets up a call transfer to a new callee with a different DTLS
1439 // fingerprint. 1439 // fingerprint.
1440 TEST_F(P2PTestConductor, LocalP2PTestDtlsTransferCaller) { 1440 TEST_F(P2PTestConductor, LocalP2PTestDtlsTransferCaller) {
1441 MAYBE_SKIP_TEST(rtc::SSLStreamAdapter::HaveDtlsSrtp); 1441 MAYBE_SKIP_TEST(rtc::SSLStreamAdapter::HaveDtlsSrtp);
1442 SetupAndVerifyDtlsCall(); 1442 SetupAndVerifyDtlsCall();
1443 1443
1444 // Keeping the original peer around which will still send packets to the 1444 // Keeping the original peer around which will still send packets to the
1445 // receiving client. These SRTP packets will be dropped. 1445 // receiving client. These SRTP packets will be dropped.
1446 rtc::scoped_ptr<PeerConnectionTestClient> original_peer( 1446 std::unique_ptr<PeerConnectionTestClient> original_peer(
1447 set_receiving_client(CreateDtlsClientWithAlternateKey())); 1447 set_receiving_client(CreateDtlsClientWithAlternateKey()));
1448 original_peer->pc()->Close(); 1448 original_peer->pc()->Close();
1449 1449
1450 SetSignalingReceivers(); 1450 SetSignalingReceivers();
1451 initializing_client()->IceRestart(); 1451 initializing_client()->IceRestart();
1452 LocalP2PTest(); 1452 LocalP2PTest();
1453 VerifyRenderedSize(640, 480); 1453 VerifyRenderedSize(640, 480);
1454 } 1454 }
1455 1455
1456 TEST_F(P2PTestConductor, LocalP2PTestCVO) { 1456 TEST_F(P2PTestConductor, LocalP2PTestCVO) {
(...skipping 742 matching lines...) Expand 10 before | Expand all | Expand 10 after
2199 server.urls.push_back("turn:hostname2"); 2199 server.urls.push_back("turn:hostname2");
2200 servers.push_back(server); 2200 servers.push_back(server);
2201 EXPECT_TRUE(webrtc::ParseIceServers(servers, &stun_servers_, &turn_servers_)); 2201 EXPECT_TRUE(webrtc::ParseIceServers(servers, &stun_servers_, &turn_servers_));
2202 EXPECT_EQ(2U, turn_servers_.size()); 2202 EXPECT_EQ(2U, turn_servers_.size());
2203 EXPECT_NE(turn_servers_[0].priority, turn_servers_[1].priority); 2203 EXPECT_NE(turn_servers_[0].priority, turn_servers_[1].priority);
2204 } 2204 }
2205 2205
2206 #endif // if !defined(THREAD_SANITIZER) 2206 #endif // if !defined(THREAD_SANITIZER)
2207 2207
2208 } // namespace 2208 } // namespace
OLDNEW
« no previous file with comments | « webrtc/api/peerconnection.cc ('k') | webrtc/api/peerconnectionendtoend_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698