| OLD | NEW |
| 1 /* | 1 /* |
| 2 * libjingle | 2 * libjingle |
| 3 * Copyright 2012 Google Inc. | 3 * Copyright 2012 Google Inc. |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions are met: | 6 * modification, are permitted provided that the following conditions are met: |
| 7 * | 7 * |
| 8 * 1. Redistributions of source code must retain the above copyright notice, | 8 * 1. Redistributions of source code must retain the above copyright notice, |
| 9 * this list of conditions and the following disclaimer. | 9 * this list of conditions and the following disclaimer. |
| 10 * 2. Redistributions in binary form must reproduce the above copyright notice, | 10 * 2. Redistributions in binary form must reproduce the above copyright notice, |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR | 23 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR |
| 24 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF | 24 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF |
| 25 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 25 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 26 */ | 26 */ |
| 27 | 27 |
| 28 #include <stdio.h> | 28 #include <stdio.h> |
| 29 | 29 |
| 30 #include <algorithm> | 30 #include <algorithm> |
| 31 #include <list> | 31 #include <list> |
| 32 #include <map> | 32 #include <map> |
| 33 #include <utility> |
| 33 #include <vector> | 34 #include <vector> |
| 34 | 35 |
| 35 #include "talk/app/webrtc/dtmfsender.h" | 36 #include "talk/app/webrtc/dtmfsender.h" |
| 36 #include "talk/app/webrtc/fakemetricsobserver.h" | 37 #include "talk/app/webrtc/fakemetricsobserver.h" |
| 37 #include "talk/app/webrtc/fakeportallocatorfactory.h" | 38 #include "talk/app/webrtc/fakeportallocatorfactory.h" |
| 38 #include "talk/app/webrtc/localaudiosource.h" | 39 #include "talk/app/webrtc/localaudiosource.h" |
| 39 #include "talk/app/webrtc/mediastreaminterface.h" | 40 #include "talk/app/webrtc/mediastreaminterface.h" |
| 40 #include "talk/app/webrtc/peerconnection.h" | 41 #include "talk/app/webrtc/peerconnection.h" |
| 41 #include "talk/app/webrtc/peerconnectionfactory.h" | 42 #include "talk/app/webrtc/peerconnectionfactory.h" |
| 42 #include "talk/app/webrtc/peerconnectioninterface.h" | 43 #include "talk/app/webrtc/peerconnectioninterface.h" |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 144 class PeerConnectionTestClient : public webrtc::PeerConnectionObserver, | 145 class PeerConnectionTestClient : public webrtc::PeerConnectionObserver, |
| 145 public SignalingMessageReceiver, | 146 public SignalingMessageReceiver, |
| 146 public ObserverInterface { | 147 public ObserverInterface { |
| 147 public: | 148 public: |
| 148 static PeerConnectionTestClient* CreateClientWithDtlsIdentityStore( | 149 static PeerConnectionTestClient* CreateClientWithDtlsIdentityStore( |
| 149 const std::string& id, | 150 const std::string& id, |
| 150 const MediaConstraintsInterface* constraints, | 151 const MediaConstraintsInterface* constraints, |
| 151 const PeerConnectionFactory::Options* options, | 152 const PeerConnectionFactory::Options* options, |
| 152 rtc::scoped_ptr<webrtc::DtlsIdentityStoreInterface> dtls_identity_store) { | 153 rtc::scoped_ptr<webrtc::DtlsIdentityStoreInterface> dtls_identity_store) { |
| 153 PeerConnectionTestClient* client(new PeerConnectionTestClient(id)); | 154 PeerConnectionTestClient* client(new PeerConnectionTestClient(id)); |
| 154 if (!client->Init(constraints, options, dtls_identity_store.Pass())) { | 155 if (!client->Init(constraints, options, std::move(dtls_identity_store))) { |
| 155 delete client; | 156 delete client; |
| 156 return nullptr; | 157 return nullptr; |
| 157 } | 158 } |
| 158 return client; | 159 return client; |
| 159 } | 160 } |
| 160 | 161 |
| 161 static PeerConnectionTestClient* CreateClient( | 162 static PeerConnectionTestClient* CreateClient( |
| 162 const std::string& id, | 163 const std::string& id, |
| 163 const MediaConstraintsInterface* constraints, | 164 const MediaConstraintsInterface* constraints, |
| 164 const PeerConnectionFactory::Options* options) { | 165 const PeerConnectionFactory::Options* options) { |
| 165 rtc::scoped_ptr<FakeDtlsIdentityStore> dtls_identity_store( | 166 rtc::scoped_ptr<FakeDtlsIdentityStore> dtls_identity_store( |
| 166 rtc::SSLStreamAdapter::HaveDtlsSrtp() ? new FakeDtlsIdentityStore() | 167 rtc::SSLStreamAdapter::HaveDtlsSrtp() ? new FakeDtlsIdentityStore() |
| 167 : nullptr); | 168 : nullptr); |
| 168 | 169 |
| 169 return CreateClientWithDtlsIdentityStore(id, constraints, options, | 170 return CreateClientWithDtlsIdentityStore(id, constraints, options, |
| 170 dtls_identity_store.Pass()); | 171 std::move(dtls_identity_store)); |
| 171 } | 172 } |
| 172 | 173 |
| 173 ~PeerConnectionTestClient() { | 174 ~PeerConnectionTestClient() { |
| 174 } | 175 } |
| 175 | 176 |
| 176 void Negotiate() { Negotiate(true, true); } | 177 void Negotiate() { Negotiate(true, true); } |
| 177 | 178 |
| 178 void Negotiate(bool audio, bool video) { | 179 void Negotiate(bool audio, bool video) { |
| 179 rtc::scoped_ptr<SessionDescriptionInterface> offer; | 180 rtc::scoped_ptr<SessionDescriptionInterface> offer; |
| 180 ASSERT_TRUE(DoCreateOffer(offer.use())); | 181 ASSERT_TRUE(DoCreateOffer(offer.use())); |
| (...skipping 573 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 754 rtc::Thread::Current(), rtc::Thread::Current(), | 755 rtc::Thread::Current(), rtc::Thread::Current(), |
| 755 fake_audio_capture_module_, fake_video_encoder_factory_, | 756 fake_audio_capture_module_, fake_video_encoder_factory_, |
| 756 fake_video_decoder_factory_); | 757 fake_video_decoder_factory_); |
| 757 if (!peer_connection_factory_) { | 758 if (!peer_connection_factory_) { |
| 758 return false; | 759 return false; |
| 759 } | 760 } |
| 760 if (options) { | 761 if (options) { |
| 761 peer_connection_factory_->SetOptions(*options); | 762 peer_connection_factory_->SetOptions(*options); |
| 762 } | 763 } |
| 763 peer_connection_ = CreatePeerConnection( | 764 peer_connection_ = CreatePeerConnection( |
| 764 allocator_factory_.get(), constraints, dtls_identity_store.Pass()); | 765 allocator_factory_.get(), constraints, std::move(dtls_identity_store)); |
| 765 return peer_connection_.get() != nullptr; | 766 return peer_connection_.get() != nullptr; |
| 766 } | 767 } |
| 767 | 768 |
| 768 rtc::scoped_refptr<webrtc::PeerConnectionInterface> CreatePeerConnection( | 769 rtc::scoped_refptr<webrtc::PeerConnectionInterface> CreatePeerConnection( |
| 769 webrtc::PortAllocatorFactoryInterface* factory, | 770 webrtc::PortAllocatorFactoryInterface* factory, |
| 770 const MediaConstraintsInterface* constraints, | 771 const MediaConstraintsInterface* constraints, |
| 771 rtc::scoped_ptr<webrtc::DtlsIdentityStoreInterface> dtls_identity_store) { | 772 rtc::scoped_ptr<webrtc::DtlsIdentityStoreInterface> dtls_identity_store) { |
| 772 // CreatePeerConnection with IceServers. | 773 // CreatePeerConnection with IceServers. |
| 773 webrtc::PeerConnectionInterface::IceServers ice_servers; | 774 webrtc::PeerConnectionInterface::IceServers ice_servers; |
| 774 webrtc::PeerConnectionInterface::IceServer ice_server; | 775 webrtc::PeerConnectionInterface::IceServer ice_server; |
| 775 ice_server.uri = "stun:stun.l.google.com:19302"; | 776 ice_server.uri = "stun:stun.l.google.com:19302"; |
| 776 ice_servers.push_back(ice_server); | 777 ice_servers.push_back(ice_server); |
| 777 | 778 |
| 778 return peer_connection_factory_->CreatePeerConnection( | 779 return peer_connection_factory_->CreatePeerConnection( |
| 779 ice_servers, constraints, factory, dtls_identity_store.Pass(), this); | 780 ice_servers, constraints, factory, std::move(dtls_identity_store), |
| 781 this); |
| 780 } | 782 } |
| 781 | 783 |
| 782 void HandleIncomingOffer(const std::string& msg) { | 784 void HandleIncomingOffer(const std::string& msg) { |
| 783 LOG(INFO) << id_ << "HandleIncomingOffer "; | 785 LOG(INFO) << id_ << "HandleIncomingOffer "; |
| 784 if (NumberOfLocalMediaStreams() == 0 && auto_add_stream_) { | 786 if (NumberOfLocalMediaStreams() == 0 && auto_add_stream_) { |
| 785 // If we are not sending any streams ourselves it is time to add some. | 787 // If we are not sending any streams ourselves it is time to add some. |
| 786 AddMediaStream(true, true); | 788 AddMediaStream(true, true); |
| 787 } | 789 } |
| 788 rtc::scoped_ptr<SessionDescriptionInterface> desc( | 790 rtc::scoped_ptr<SessionDescriptionInterface> desc( |
| 789 webrtc::CreateSessionDescription("offer", msg, nullptr)); | 791 webrtc::CreateSessionDescription("offer", msg, nullptr)); |
| (...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1122 setup_constraints.AddMandatory(MediaConstraintsInterface::kEnableDtlsSrtp, | 1124 setup_constraints.AddMandatory(MediaConstraintsInterface::kEnableDtlsSrtp, |
| 1123 true); | 1125 true); |
| 1124 | 1126 |
| 1125 rtc::scoped_ptr<FakeDtlsIdentityStore> dtls_identity_store( | 1127 rtc::scoped_ptr<FakeDtlsIdentityStore> dtls_identity_store( |
| 1126 rtc::SSLStreamAdapter::HaveDtlsSrtp() ? new FakeDtlsIdentityStore() | 1128 rtc::SSLStreamAdapter::HaveDtlsSrtp() ? new FakeDtlsIdentityStore() |
| 1127 : nullptr); | 1129 : nullptr); |
| 1128 dtls_identity_store->use_alternate_key(); | 1130 dtls_identity_store->use_alternate_key(); |
| 1129 | 1131 |
| 1130 // Make sure the new client is using a different certificate. | 1132 // Make sure the new client is using a different certificate. |
| 1131 return PeerConnectionTestClient::CreateClientWithDtlsIdentityStore( | 1133 return PeerConnectionTestClient::CreateClientWithDtlsIdentityStore( |
| 1132 "New Peer: ", &setup_constraints, nullptr, dtls_identity_store.Pass()); | 1134 "New Peer: ", &setup_constraints, nullptr, |
| 1135 std::move(dtls_identity_store)); |
| 1133 } | 1136 } |
| 1134 | 1137 |
| 1135 void SendRtpData(webrtc::DataChannelInterface* dc, const std::string& data) { | 1138 void SendRtpData(webrtc::DataChannelInterface* dc, const std::string& data) { |
| 1136 // Messages may get lost on the unreliable DataChannel, so we send multiple | 1139 // Messages may get lost on the unreliable DataChannel, so we send multiple |
| 1137 // times to avoid test flakiness. | 1140 // times to avoid test flakiness. |
| 1138 static const size_t kSendAttempts = 5; | 1141 static const size_t kSendAttempts = 5; |
| 1139 | 1142 |
| 1140 for (size_t i = 0; i < kSendAttempts; ++i) { | 1143 for (size_t i = 0; i < kSendAttempts; ++i) { |
| 1141 dc->Send(DataBuffer(data)); | 1144 dc->Send(DataBuffer(data)); |
| 1142 } | 1145 } |
| (...skipping 844 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1987 server.urls.push_back("stun:hostname"); | 1990 server.urls.push_back("stun:hostname"); |
| 1988 server.urls.push_back("turn:hostname"); | 1991 server.urls.push_back("turn:hostname"); |
| 1989 servers.push_back(server); | 1992 servers.push_back(server); |
| 1990 EXPECT_TRUE(webrtc::ParseIceServers(servers, &stun_configurations_, | 1993 EXPECT_TRUE(webrtc::ParseIceServers(servers, &stun_configurations_, |
| 1991 &turn_configurations_)); | 1994 &turn_configurations_)); |
| 1992 EXPECT_EQ(1U, stun_configurations_.size()); | 1995 EXPECT_EQ(1U, stun_configurations_.size()); |
| 1993 EXPECT_EQ(1U, turn_configurations_.size()); | 1996 EXPECT_EQ(1U, turn_configurations_.size()); |
| 1994 } | 1997 } |
| 1995 | 1998 |
| 1996 #endif // if !defined(THREAD_SANITIZER) | 1999 #endif // if !defined(THREAD_SANITIZER) |
| OLD | NEW |