blob: 597a1740ca7ce1a5e5c4beb051260f79c025af9a [file] [log] [blame]
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001/*
2 * libjingle
jlmiller@webrtc.org5f93d0a2015-01-20 21:36:13 +00003 * Copyright 2012 Google Inc.
henrike@webrtc.org28e20752013-07-10 00:45:36 +00004 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 *
8 * 1. Redistributions of source code must retain the above copyright notice,
9 * this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright notice,
11 * this list of conditions and the following disclaimer in the documentation
12 * and/or other materials provided with the distribution.
13 * 3. The name of the author may not be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
17 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
18 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
fischman@webrtc.org33584f92013-07-25 16:43:30 +000019 * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
20 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
henrike@webrtc.org28e20752013-07-10 00:45:36 +000021 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
22 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
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
25 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28#include <string>
29
30#include "talk/app/webrtc/fakeportallocatorfactory.h"
31#include "talk/app/webrtc/mediastreaminterface.h"
32#include "talk/app/webrtc/peerconnectionfactory.h"
jiayl@webrtc.orgd83f4ef2015-03-13 21:26:12 +000033#include "talk/app/webrtc/test/fakedtlsidentityservice.h"
henrike@webrtc.org28e20752013-07-10 00:45:36 +000034#include "talk/app/webrtc/test/fakevideotrackrenderer.h"
buildbot@webrtc.orga09a9992014-08-13 17:26:08 +000035#include "talk/app/webrtc/videosourceinterface.h"
henrike@webrtc.org28e20752013-07-10 00:45:36 +000036#include "talk/media/base/fakevideocapturer.h"
37#include "talk/media/webrtc/webrtccommon.h"
38#include "talk/media/webrtc/webrtcvoe.h"
buildbot@webrtc.orga09a9992014-08-13 17:26:08 +000039#include "webrtc/base/gunit.h"
40#include "webrtc/base/scoped_ptr.h"
41#include "webrtc/base/thread.h"
henrike@webrtc.org28e20752013-07-10 00:45:36 +000042
43using webrtc::FakeVideoTrackRenderer;
perkj@webrtc.orgc2dd5ee2014-11-04 11:31:29 +000044using webrtc::DataChannelInterface;
henrike@webrtc.org28e20752013-07-10 00:45:36 +000045using webrtc::MediaStreamInterface;
46using webrtc::PeerConnectionFactoryInterface;
47using webrtc::PeerConnectionInterface;
48using webrtc::PeerConnectionObserver;
49using webrtc::PortAllocatorFactoryInterface;
50using webrtc::VideoSourceInterface;
51using webrtc::VideoTrackInterface;
52
53namespace {
54
55typedef std::vector<PortAllocatorFactoryInterface::StunConfiguration>
56 StunConfigurations;
57typedef std::vector<PortAllocatorFactoryInterface::TurnConfiguration>
58 TurnConfigurations;
59
60static const char kStunIceServer[] = "stun:stun.l.google.com:19302";
61static const char kTurnIceServer[] = "turn:test%40hello.com@test.com:1234";
62static const char kTurnIceServerWithTransport[] =
63 "turn:test@hello.com?transport=tcp";
64static const char kSecureTurnIceServer[] =
65 "turns:test@hello.com?transport=tcp";
wu@webrtc.org78187522013-10-07 23:32:02 +000066static const char kSecureTurnIceServerWithoutTransportParam[] =
sergeyu@chromium.org5bc25c42013-12-05 00:24:06 +000067 "turns:test_no_transport@hello.com:443";
68static const char kSecureTurnIceServerWithoutTransportAndPortParam[] =
wu@webrtc.org78187522013-10-07 23:32:02 +000069 "turns:test_no_transport@hello.com";
henrike@webrtc.org28e20752013-07-10 00:45:36 +000070static const char kTurnIceServerWithNoUsernameInUri[] =
71 "turn:test.com:1234";
72static const char kTurnPassword[] = "turnpassword";
wu@webrtc.org91053e72013-08-10 07:18:04 +000073static const int kDefaultStunPort = 3478;
74static const int kDefaultStunTlsPort = 5349;
henrike@webrtc.org28e20752013-07-10 00:45:36 +000075static const char kTurnUsername[] = "test";
sergeyu@chromium.orga23f0ca2013-11-13 22:48:52 +000076static const char kStunIceServerWithIPv4Address[] = "stun:1.2.3.4:1234";
77static const char kStunIceServerWithIPv4AddressWithoutPort[] = "stun:1.2.3.4";
78static const char kStunIceServerWithIPv6Address[] = "stun:[2401:fa00:4::]:1234";
79static const char kStunIceServerWithIPv6AddressWithoutPort[] =
80 "stun:[2401:fa00:4::]";
81static const char kStunIceServerWithInvalidIPv6Address[] =
82 "stun:[2401:fa00:4:::3478";
83static const char kTurnIceServerWithIPv6Address[] =
84 "turn:test@[2401:fa00:4::]:1234";
henrike@webrtc.org28e20752013-07-10 00:45:36 +000085
86class NullPeerConnectionObserver : public PeerConnectionObserver {
87 public:
henrike@webrtc.org28e20752013-07-10 00:45:36 +000088 virtual void OnMessage(const std::string& msg) {}
89 virtual void OnSignalingMessage(const std::string& msg) {}
90 virtual void OnSignalingChange(
91 PeerConnectionInterface::SignalingState new_state) {}
92 virtual void OnAddStream(MediaStreamInterface* stream) {}
93 virtual void OnRemoveStream(MediaStreamInterface* stream) {}
perkj@webrtc.orgc2dd5ee2014-11-04 11:31:29 +000094 virtual void OnDataChannel(DataChannelInterface* data_channel) {}
henrike@webrtc.org28e20752013-07-10 00:45:36 +000095 virtual void OnRenegotiationNeeded() {}
96 virtual void OnIceConnectionChange(
97 PeerConnectionInterface::IceConnectionState new_state) {}
98 virtual void OnIceGatheringChange(
99 PeerConnectionInterface::IceGatheringState new_state) {}
100 virtual void OnIceCandidate(const webrtc::IceCandidateInterface* candidate) {}
101};
102
103} // namespace
104
105class PeerConnectionFactoryTest : public testing::Test {
106 void SetUp() {
buildbot@webrtc.orgd4e598d2014-07-29 17:36:52 +0000107 factory_ = webrtc::CreatePeerConnectionFactory(rtc::Thread::Current(),
108 rtc::Thread::Current(),
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000109 NULL,
110 NULL,
111 NULL);
112
113 ASSERT_TRUE(factory_.get() != NULL);
114 allocator_factory_ = webrtc::FakePortAllocatorFactory::Create();
115 }
116
117 protected:
118 void VerifyStunConfigurations(StunConfigurations stun_config) {
119 webrtc::FakePortAllocatorFactory* allocator =
120 static_cast<webrtc::FakePortAllocatorFactory*>(
121 allocator_factory_.get());
122 ASSERT_TRUE(allocator != NULL);
123 EXPECT_EQ(stun_config.size(), allocator->stun_configs().size());
124 for (size_t i = 0; i < stun_config.size(); ++i) {
125 EXPECT_EQ(stun_config[i].server.ToString(),
126 allocator->stun_configs()[i].server.ToString());
127 }
128 }
129
130 void VerifyTurnConfigurations(TurnConfigurations turn_config) {
131 webrtc::FakePortAllocatorFactory* allocator =
132 static_cast<webrtc::FakePortAllocatorFactory*>(
133 allocator_factory_.get());
134 ASSERT_TRUE(allocator != NULL);
135 EXPECT_EQ(turn_config.size(), allocator->turn_configs().size());
136 for (size_t i = 0; i < turn_config.size(); ++i) {
137 EXPECT_EQ(turn_config[i].server.ToString(),
138 allocator->turn_configs()[i].server.ToString());
139 EXPECT_EQ(turn_config[i].username, allocator->turn_configs()[i].username);
140 EXPECT_EQ(turn_config[i].password, allocator->turn_configs()[i].password);
141 EXPECT_EQ(turn_config[i].transport_type,
142 allocator->turn_configs()[i].transport_type);
143 }
144 }
145
buildbot@webrtc.orgd4e598d2014-07-29 17:36:52 +0000146 rtc::scoped_refptr<PeerConnectionFactoryInterface> factory_;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000147 NullPeerConnectionObserver observer_;
buildbot@webrtc.orgd4e598d2014-07-29 17:36:52 +0000148 rtc::scoped_refptr<PortAllocatorFactoryInterface> allocator_factory_;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000149};
150
151// Verify creation of PeerConnection using internal ADM, video factory and
152// internal libjingle threads.
153TEST(PeerConnectionFactoryTestInternal, CreatePCUsingInternalModules) {
buildbot@webrtc.orgd4e598d2014-07-29 17:36:52 +0000154 rtc::scoped_refptr<PeerConnectionFactoryInterface> factory(
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000155 webrtc::CreatePeerConnectionFactory());
156
157 NullPeerConnectionObserver observer;
158 webrtc::PeerConnectionInterface::IceServers servers;
159
buildbot@webrtc.orgd4e598d2014-07-29 17:36:52 +0000160 rtc::scoped_refptr<PeerConnectionInterface> pc(
jiayl@webrtc.orgd83f4ef2015-03-13 21:26:12 +0000161 factory->CreatePeerConnection(
162 servers, NULL, NULL, new FakeIdentityService(), &observer));
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000163
164 EXPECT_TRUE(pc.get() != NULL);
165}
166
167// This test verifies creation of PeerConnection with valid STUN and TURN
168// configuration. Also verifies the URL's parsed correctly as expected.
169TEST_F(PeerConnectionFactoryTest, CreatePCUsingIceServers) {
buildbot@webrtc.org41451d42014-05-03 05:39:45 +0000170 PeerConnectionInterface::RTCConfiguration config;
171 webrtc::PeerConnectionInterface::IceServer ice_server;
172 ice_server.uri = kStunIceServer;
173 config.servers.push_back(ice_server);
174 ice_server.uri = kTurnIceServer;
175 ice_server.password = kTurnPassword;
176 config.servers.push_back(ice_server);
177 ice_server.uri = kTurnIceServerWithTransport;
178 ice_server.password = kTurnPassword;
179 config.servers.push_back(ice_server);
buildbot@webrtc.orgd4e598d2014-07-29 17:36:52 +0000180 rtc::scoped_refptr<PeerConnectionInterface> pc(
buildbot@webrtc.org41451d42014-05-03 05:39:45 +0000181 factory_->CreatePeerConnection(config, NULL,
182 allocator_factory_.get(),
jiayl@webrtc.orgd83f4ef2015-03-13 21:26:12 +0000183 new FakeIdentityService(),
buildbot@webrtc.org41451d42014-05-03 05:39:45 +0000184 &observer_));
185 EXPECT_TRUE(pc.get() != NULL);
186 StunConfigurations stun_configs;
187 webrtc::PortAllocatorFactoryInterface::StunConfiguration stun1(
188 "stun.l.google.com", 19302);
189 stun_configs.push_back(stun1);
190 VerifyStunConfigurations(stun_configs);
191 TurnConfigurations turn_configs;
192 webrtc::PortAllocatorFactoryInterface::TurnConfiguration turn1(
193 "test.com", 1234, "test@hello.com", kTurnPassword, "udp", false);
194 turn_configs.push_back(turn1);
195 webrtc::PortAllocatorFactoryInterface::TurnConfiguration turn2(
196 "hello.com", kDefaultStunPort, "test", kTurnPassword, "tcp", false);
197 turn_configs.push_back(turn2);
198 VerifyTurnConfigurations(turn_configs);
199}
200
201// This test verifies creation of PeerConnection with valid STUN and TURN
Joachim Bauch7c4e7452015-05-28 23:06:30 +0200202// configuration. Also verifies the list of URL's parsed correctly as expected.
203TEST_F(PeerConnectionFactoryTest, CreatePCUsingIceServersUrls) {
204 PeerConnectionInterface::RTCConfiguration config;
205 webrtc::PeerConnectionInterface::IceServer ice_server;
206 ice_server.urls.push_back(kStunIceServer);
207 ice_server.urls.push_back(kTurnIceServer);
208 ice_server.urls.push_back(kTurnIceServerWithTransport);
209 ice_server.password = kTurnPassword;
210 config.servers.push_back(ice_server);
211 rtc::scoped_refptr<PeerConnectionInterface> pc(
212 factory_->CreatePeerConnection(config, NULL,
213 allocator_factory_.get(),
214 new FakeIdentityService(),
215 &observer_));
216 EXPECT_TRUE(pc.get() != NULL);
217 StunConfigurations stun_configs;
218 webrtc::PortAllocatorFactoryInterface::StunConfiguration stun1(
219 "stun.l.google.com", 19302);
220 stun_configs.push_back(stun1);
221 VerifyStunConfigurations(stun_configs);
222 TurnConfigurations turn_configs;
223 webrtc::PortAllocatorFactoryInterface::TurnConfiguration turn1(
224 "test.com", 1234, "test@hello.com", kTurnPassword, "udp", false);
225 turn_configs.push_back(turn1);
226 webrtc::PortAllocatorFactoryInterface::TurnConfiguration turn2(
227 "hello.com", kDefaultStunPort, "test", kTurnPassword, "tcp", false);
228 turn_configs.push_back(turn2);
229 VerifyTurnConfigurations(turn_configs);
230}
231
232// This test verifies creation of PeerConnection with valid STUN and TURN
buildbot@webrtc.org41451d42014-05-03 05:39:45 +0000233// configuration. Also verifies the URL's parsed correctly as expected.
234// This version doesn't use RTCConfiguration.
235// TODO(mallinath) - Remove this method after clients start using RTCConfig.
236TEST_F(PeerConnectionFactoryTest, CreatePCUsingIceServersOldSignature) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000237 webrtc::PeerConnectionInterface::IceServers ice_servers;
238 webrtc::PeerConnectionInterface::IceServer ice_server;
239 ice_server.uri = kStunIceServer;
240 ice_servers.push_back(ice_server);
241 ice_server.uri = kTurnIceServer;
242 ice_server.password = kTurnPassword;
243 ice_servers.push_back(ice_server);
henrike@webrtc.org1e09a712013-07-26 19:17:59 +0000244 ice_server.uri = kTurnIceServerWithTransport;
245 ice_server.password = kTurnPassword;
246 ice_servers.push_back(ice_server);
buildbot@webrtc.orgd4e598d2014-07-29 17:36:52 +0000247 rtc::scoped_refptr<PeerConnectionInterface> pc(
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000248 factory_->CreatePeerConnection(ice_servers, NULL,
249 allocator_factory_.get(),
jiayl@webrtc.orgd83f4ef2015-03-13 21:26:12 +0000250 new FakeIdentityService(),
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000251 &observer_));
252 EXPECT_TRUE(pc.get() != NULL);
253 StunConfigurations stun_configs;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000254 webrtc::PortAllocatorFactoryInterface::StunConfiguration stun1(
henrike@webrtc.org1e09a712013-07-26 19:17:59 +0000255 "stun.l.google.com", 19302);
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000256 stun_configs.push_back(stun1);
257 VerifyStunConfigurations(stun_configs);
258 TurnConfigurations turn_configs;
henrike@webrtc.org1e09a712013-07-26 19:17:59 +0000259 webrtc::PortAllocatorFactoryInterface::TurnConfiguration turn1(
wu@webrtc.org91053e72013-08-10 07:18:04 +0000260 "test.com", 1234, "test@hello.com", kTurnPassword, "udp", false);
henrike@webrtc.org1e09a712013-07-26 19:17:59 +0000261 turn_configs.push_back(turn1);
262 webrtc::PortAllocatorFactoryInterface::TurnConfiguration turn2(
wu@webrtc.org91053e72013-08-10 07:18:04 +0000263 "hello.com", kDefaultStunPort, "test", kTurnPassword, "tcp", false);
henrike@webrtc.org1e09a712013-07-26 19:17:59 +0000264 turn_configs.push_back(turn2);
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000265 VerifyTurnConfigurations(turn_configs);
266}
267
268TEST_F(PeerConnectionFactoryTest, CreatePCUsingNoUsernameInUri) {
buildbot@webrtc.org41451d42014-05-03 05:39:45 +0000269 PeerConnectionInterface::RTCConfiguration config;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000270 webrtc::PeerConnectionInterface::IceServer ice_server;
271 ice_server.uri = kStunIceServer;
buildbot@webrtc.org41451d42014-05-03 05:39:45 +0000272 config.servers.push_back(ice_server);
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000273 ice_server.uri = kTurnIceServerWithNoUsernameInUri;
274 ice_server.username = kTurnUsername;
275 ice_server.password = kTurnPassword;
buildbot@webrtc.org41451d42014-05-03 05:39:45 +0000276 config.servers.push_back(ice_server);
buildbot@webrtc.orgd4e598d2014-07-29 17:36:52 +0000277 rtc::scoped_refptr<PeerConnectionInterface> pc(
buildbot@webrtc.org41451d42014-05-03 05:39:45 +0000278 factory_->CreatePeerConnection(config, NULL,
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000279 allocator_factory_.get(),
jiayl@webrtc.orgd83f4ef2015-03-13 21:26:12 +0000280 new FakeIdentityService(),
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000281 &observer_));
282 EXPECT_TRUE(pc.get() != NULL);
283 TurnConfigurations turn_configs;
284 webrtc::PortAllocatorFactoryInterface::TurnConfiguration turn(
wu@webrtc.org91053e72013-08-10 07:18:04 +0000285 "test.com", 1234, kTurnUsername, kTurnPassword, "udp", false);
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000286 turn_configs.push_back(turn);
287 VerifyTurnConfigurations(turn_configs);
288}
289
290// This test verifies the PeerConnection created properly with TURN url which
291// has transport parameter in it.
292TEST_F(PeerConnectionFactoryTest, CreatePCUsingTurnUrlWithTransportParam) {
buildbot@webrtc.org41451d42014-05-03 05:39:45 +0000293 PeerConnectionInterface::RTCConfiguration config;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000294 webrtc::PeerConnectionInterface::IceServer ice_server;
295 ice_server.uri = kTurnIceServerWithTransport;
296 ice_server.password = kTurnPassword;
buildbot@webrtc.org41451d42014-05-03 05:39:45 +0000297 config.servers.push_back(ice_server);
buildbot@webrtc.orgd4e598d2014-07-29 17:36:52 +0000298 rtc::scoped_refptr<PeerConnectionInterface> pc(
buildbot@webrtc.org41451d42014-05-03 05:39:45 +0000299 factory_->CreatePeerConnection(config, NULL,
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000300 allocator_factory_.get(),
jiayl@webrtc.orgd83f4ef2015-03-13 21:26:12 +0000301 new FakeIdentityService(),
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000302 &observer_));
303 EXPECT_TRUE(pc.get() != NULL);
304 TurnConfigurations turn_configs;
305 webrtc::PortAllocatorFactoryInterface::TurnConfiguration turn(
wu@webrtc.org91053e72013-08-10 07:18:04 +0000306 "hello.com", kDefaultStunPort, "test", kTurnPassword, "tcp", false);
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000307 turn_configs.push_back(turn);
308 VerifyTurnConfigurations(turn_configs);
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000309}
310
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000311TEST_F(PeerConnectionFactoryTest, CreatePCUsingSecureTurnUrl) {
buildbot@webrtc.org41451d42014-05-03 05:39:45 +0000312 PeerConnectionInterface::RTCConfiguration config;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000313 webrtc::PeerConnectionInterface::IceServer ice_server;
314 ice_server.uri = kSecureTurnIceServer;
315 ice_server.password = kTurnPassword;
buildbot@webrtc.org41451d42014-05-03 05:39:45 +0000316 config.servers.push_back(ice_server);
wu@webrtc.org78187522013-10-07 23:32:02 +0000317 ice_server.uri = kSecureTurnIceServerWithoutTransportParam;
318 ice_server.password = kTurnPassword;
buildbot@webrtc.org41451d42014-05-03 05:39:45 +0000319 config.servers.push_back(ice_server);
sergeyu@chromium.org5bc25c42013-12-05 00:24:06 +0000320 ice_server.uri = kSecureTurnIceServerWithoutTransportAndPortParam;
321 ice_server.password = kTurnPassword;
buildbot@webrtc.org41451d42014-05-03 05:39:45 +0000322 config.servers.push_back(ice_server);
buildbot@webrtc.orgd4e598d2014-07-29 17:36:52 +0000323 rtc::scoped_refptr<PeerConnectionInterface> pc(
buildbot@webrtc.org41451d42014-05-03 05:39:45 +0000324 factory_->CreatePeerConnection(config, NULL,
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000325 allocator_factory_.get(),
jiayl@webrtc.orgd83f4ef2015-03-13 21:26:12 +0000326 new FakeIdentityService(),
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000327 &observer_));
wu@webrtc.org91053e72013-08-10 07:18:04 +0000328 EXPECT_TRUE(pc.get() != NULL);
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000329 TurnConfigurations turn_configs;
wu@webrtc.org78187522013-10-07 23:32:02 +0000330 webrtc::PortAllocatorFactoryInterface::TurnConfiguration turn1(
wu@webrtc.org91053e72013-08-10 07:18:04 +0000331 "hello.com", kDefaultStunTlsPort, "test", kTurnPassword, "tcp", true);
wu@webrtc.org78187522013-10-07 23:32:02 +0000332 turn_configs.push_back(turn1);
333 // TURNS with transport param should be default to tcp.
334 webrtc::PortAllocatorFactoryInterface::TurnConfiguration turn2(
sergeyu@chromium.org5bc25c42013-12-05 00:24:06 +0000335 "hello.com", 443, "test_no_transport", kTurnPassword, "tcp", true);
336 turn_configs.push_back(turn2);
337 webrtc::PortAllocatorFactoryInterface::TurnConfiguration turn3(
wu@webrtc.org78187522013-10-07 23:32:02 +0000338 "hello.com", kDefaultStunTlsPort, "test_no_transport",
339 kTurnPassword, "tcp", true);
sergeyu@chromium.org5bc25c42013-12-05 00:24:06 +0000340 turn_configs.push_back(turn3);
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000341 VerifyTurnConfigurations(turn_configs);
342}
343
sergeyu@chromium.orga23f0ca2013-11-13 22:48:52 +0000344TEST_F(PeerConnectionFactoryTest, CreatePCUsingIPLiteralAddress) {
buildbot@webrtc.org41451d42014-05-03 05:39:45 +0000345 PeerConnectionInterface::RTCConfiguration config;
sergeyu@chromium.orga23f0ca2013-11-13 22:48:52 +0000346 webrtc::PeerConnectionInterface::IceServer ice_server;
347 ice_server.uri = kStunIceServerWithIPv4Address;
buildbot@webrtc.org41451d42014-05-03 05:39:45 +0000348 config.servers.push_back(ice_server);
sergeyu@chromium.orga23f0ca2013-11-13 22:48:52 +0000349 ice_server.uri = kStunIceServerWithIPv4AddressWithoutPort;
buildbot@webrtc.org41451d42014-05-03 05:39:45 +0000350 config.servers.push_back(ice_server);
sergeyu@chromium.orga23f0ca2013-11-13 22:48:52 +0000351 ice_server.uri = kStunIceServerWithIPv6Address;
buildbot@webrtc.org41451d42014-05-03 05:39:45 +0000352 config.servers.push_back(ice_server);
sergeyu@chromium.orga23f0ca2013-11-13 22:48:52 +0000353 ice_server.uri = kStunIceServerWithIPv6AddressWithoutPort;
buildbot@webrtc.org41451d42014-05-03 05:39:45 +0000354 config.servers.push_back(ice_server);
sergeyu@chromium.orga23f0ca2013-11-13 22:48:52 +0000355 ice_server.uri = kStunIceServerWithInvalidIPv6Address;
buildbot@webrtc.org41451d42014-05-03 05:39:45 +0000356 config.servers.push_back(ice_server);
sergeyu@chromium.orga23f0ca2013-11-13 22:48:52 +0000357 ice_server.uri = kTurnIceServerWithIPv6Address;
358 ice_server.password = kTurnPassword;
buildbot@webrtc.org41451d42014-05-03 05:39:45 +0000359 config.servers.push_back(ice_server);
buildbot@webrtc.orgd4e598d2014-07-29 17:36:52 +0000360 rtc::scoped_refptr<PeerConnectionInterface> pc(
buildbot@webrtc.org41451d42014-05-03 05:39:45 +0000361 factory_->CreatePeerConnection(config, NULL,
sergeyu@chromium.orga23f0ca2013-11-13 22:48:52 +0000362 allocator_factory_.get(),
jiayl@webrtc.orgd83f4ef2015-03-13 21:26:12 +0000363 new FakeIdentityService(),
sergeyu@chromium.orga23f0ca2013-11-13 22:48:52 +0000364 &observer_));
365 EXPECT_TRUE(pc.get() != NULL);
366 StunConfigurations stun_configs;
367 webrtc::PortAllocatorFactoryInterface::StunConfiguration stun1(
368 "1.2.3.4", 1234);
369 stun_configs.push_back(stun1);
370 webrtc::PortAllocatorFactoryInterface::StunConfiguration stun2(
371 "1.2.3.4", 3478);
372 stun_configs.push_back(stun2); // Default port
373 webrtc::PortAllocatorFactoryInterface::StunConfiguration stun3(
374 "2401:fa00:4::", 1234);
375 stun_configs.push_back(stun3);
376 webrtc::PortAllocatorFactoryInterface::StunConfiguration stun4(
377 "2401:fa00:4::", 3478);
378 stun_configs.push_back(stun4); // Default port
sergeyu@chromium.orga23f0ca2013-11-13 22:48:52 +0000379 VerifyStunConfigurations(stun_configs);
buildbot@webrtc.orgf875f152014-04-14 16:06:21 +0000380
sergeyu@chromium.orga23f0ca2013-11-13 22:48:52 +0000381 TurnConfigurations turn_configs;
382 webrtc::PortAllocatorFactoryInterface::TurnConfiguration turn1(
383 "2401:fa00:4::", 1234, "test", kTurnPassword, "udp", false);
384 turn_configs.push_back(turn1);
385 VerifyTurnConfigurations(turn_configs);
386}
387
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000388// This test verifies the captured stream is rendered locally using a
389// local video track.
390TEST_F(PeerConnectionFactoryTest, LocalRendering) {
391 cricket::FakeVideoCapturer* capturer = new cricket::FakeVideoCapturer();
392 // The source take ownership of |capturer|.
buildbot@webrtc.orgd4e598d2014-07-29 17:36:52 +0000393 rtc::scoped_refptr<VideoSourceInterface> source(
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000394 factory_->CreateVideoSource(capturer, NULL));
395 ASSERT_TRUE(source.get() != NULL);
buildbot@webrtc.orgd4e598d2014-07-29 17:36:52 +0000396 rtc::scoped_refptr<VideoTrackInterface> track(
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000397 factory_->CreateVideoTrack("testlabel", source));
398 ASSERT_TRUE(track.get() != NULL);
399 FakeVideoTrackRenderer local_renderer(track);
400
401 EXPECT_EQ(0, local_renderer.num_rendered_frames());
402 EXPECT_TRUE(capturer->CaptureFrame());
403 EXPECT_EQ(1, local_renderer.num_rendered_frames());
404
405 track->set_enabled(false);
406 EXPECT_TRUE(capturer->CaptureFrame());
407 EXPECT_EQ(1, local_renderer.num_rendered_frames());
408
409 track->set_enabled(true);
410 EXPECT_TRUE(capturer->CaptureFrame());
411 EXPECT_EQ(2, local_renderer.num_rendered_frames());
412}
jiayl@webrtc.orgd83f4ef2015-03-13 21:26:12 +0000413