2013-07-10 00:45:36 +00:00
|
|
|
/*
|
2016-02-10 07:54:43 -08:00
|
|
|
* Copyright 2012 The WebRTC project authors. All Rights Reserved.
|
2013-07-10 00:45:36 +00:00
|
|
|
*
|
2016-02-10 07:54:43 -08:00
|
|
|
* Use of this source code is governed by a BSD-style license
|
|
|
|
|
* that can be found in the LICENSE file in the root of the source
|
|
|
|
|
* tree. An additional intellectual property rights grant can be found
|
|
|
|
|
* in the file PATENTS. All contributing project authors may
|
|
|
|
|
* be found in the AUTHORS file in the root of the source tree.
|
2013-07-10 00:45:36 +00:00
|
|
|
*/
|
|
|
|
|
|
2016-04-27 06:47:29 -07:00
|
|
|
#include <memory>
|
2013-07-10 00:45:36 +00:00
|
|
|
#include <string>
|
2015-12-17 03:04:15 -08:00
|
|
|
#include <utility>
|
2013-07-10 00:45:36 +00:00
|
|
|
|
2016-02-10 10:53:12 +01:00
|
|
|
#include "webrtc/api/mediastreaminterface.h"
|
|
|
|
|
#include "webrtc/api/peerconnectionfactory.h"
|
2016-01-08 05:04:57 -08:00
|
|
|
#ifdef WEBRTC_ANDROID
|
2016-02-10 10:53:12 +01:00
|
|
|
#include "webrtc/api/test/androidtestinitializer.h"
|
2016-01-08 05:04:57 -08:00
|
|
|
#endif
|
2016-02-10 10:53:12 +01:00
|
|
|
#include "webrtc/api/test/fakedtlsidentitystore.h"
|
|
|
|
|
#include "webrtc/api/test/fakevideotrackrenderer.h"
|
2014-08-13 17:26:08 +00:00
|
|
|
#include "webrtc/base/gunit.h"
|
|
|
|
|
#include "webrtc/base/thread.h"
|
Move talk/media to webrtc/media
I removed the 'libjingle' target in talk/libjingle.gyp and replaced
all users of it with base/base.gyp:rtc_base. It seems the jsoncpp
and expat dependencies were not used by it's previous references.
The files in talk/media/testdata were uploaded to Google Storage and
added .sha1 files in resources/media instead of simply moving them.
The previously disabled warnings that were inherited from
talk/build/common.gypi are now replaced by target-specific disabling
of only the failing warnings. Additional disabling was needed since the stricter
compilation warnings that applies to code in webrtc/.
License headers will be updated in a follow-up CL in order to not
break Git history.
Other modifications:
* Updated the header guards.
* Sorted the includes using chromium/src/tools/sort-headers.py
except for these files:
talk/app/webrtc/peerconnectionendtoend_unittest.cc
talk/app/webrtc/java/jni/androidmediadecoder_jni.cc
talk/app/webrtc/java/jni/androidmediaencoder_jni.cc
webrtc/media/devices/win32devicemanager.cc.
* Unused GYP reference to libjingle_tests_additional_deps was removed.
* Removed duplicated GYP entries of
webrtc/base/testutils.cc
webrtc/base/testutils.h
The HAVE_WEBRTC_VIDEO and HAVE_WEBRTC_VOICE defines were used by only talk/media,
so they were moved to the media.gyp.
I also checked that none of
EXPAT_RELATIVE_PATH,
FEATURE_ENABLE_VOICEMAIL,
GTEST_RELATIVE_PATH,
JSONCPP_RELATIVE_PATH,
LOGGING=1,
SRTP_RELATIVE_PATH,
FEATURE_ENABLE_SSL,
FEATURE_ENABLE_VOICEMAIL,
FEATURE_ENABLE_PSTN,
HAVE_SCTP,
HAVE_SRTP,
are used by the talk/media code.
For Chromium, the following changes will need to be applied to the roll CL that updates the
DEPS for WebRTC and libjingle: https://codereview.chromium.org/1604303002/
BUG=webrtc:5420
NOPRESUBMIT=True
TBR=tommi@webrtc.org
Review URL: https://codereview.webrtc.org/1587193006
Cr-Commit-Position: refs/heads/master@{#11495}
2016-02-04 23:52:28 -08:00
|
|
|
#include "webrtc/media/base/fakevideocapturer.h"
|
2016-02-12 06:39:40 +01:00
|
|
|
#include "webrtc/media/engine/webrtccommon.h"
|
|
|
|
|
#include "webrtc/media/engine/webrtcvoe.h"
|
2016-05-13 08:15:11 -07:00
|
|
|
#include "webrtc/p2p/base/fakeportallocator.h"
|
2013-07-10 00:45:36 +00:00
|
|
|
|
2014-11-04 11:31:29 +00:00
|
|
|
using webrtc::DataChannelInterface;
|
2015-08-11 10:33:13 +02:00
|
|
|
using webrtc::DtlsIdentityStoreInterface;
|
|
|
|
|
using webrtc::FakeVideoTrackRenderer;
|
2013-07-10 00:45:36 +00:00
|
|
|
using webrtc::MediaStreamInterface;
|
|
|
|
|
using webrtc::PeerConnectionFactoryInterface;
|
|
|
|
|
using webrtc::PeerConnectionInterface;
|
|
|
|
|
using webrtc::PeerConnectionObserver;
|
2016-03-08 01:27:48 +01:00
|
|
|
using webrtc::VideoTrackSourceInterface;
|
2013-07-10 00:45:36 +00:00
|
|
|
using webrtc::VideoTrackInterface;
|
|
|
|
|
|
|
|
|
|
namespace {
|
|
|
|
|
|
|
|
|
|
static const char kStunIceServer[] = "stun:stun.l.google.com:19302";
|
|
|
|
|
static const char kTurnIceServer[] = "turn:test%40hello.com@test.com:1234";
|
|
|
|
|
static const char kTurnIceServerWithTransport[] =
|
|
|
|
|
"turn:test@hello.com?transport=tcp";
|
|
|
|
|
static const char kSecureTurnIceServer[] =
|
|
|
|
|
"turns:test@hello.com?transport=tcp";
|
2013-10-07 23:32:02 +00:00
|
|
|
static const char kSecureTurnIceServerWithoutTransportParam[] =
|
2013-12-05 00:24:06 +00:00
|
|
|
"turns:test_no_transport@hello.com:443";
|
|
|
|
|
static const char kSecureTurnIceServerWithoutTransportAndPortParam[] =
|
2013-10-07 23:32:02 +00:00
|
|
|
"turns:test_no_transport@hello.com";
|
2013-07-10 00:45:36 +00:00
|
|
|
static const char kTurnIceServerWithNoUsernameInUri[] =
|
|
|
|
|
"turn:test.com:1234";
|
|
|
|
|
static const char kTurnPassword[] = "turnpassword";
|
2013-08-10 07:18:04 +00:00
|
|
|
static const int kDefaultStunPort = 3478;
|
|
|
|
|
static const int kDefaultStunTlsPort = 5349;
|
2013-07-10 00:45:36 +00:00
|
|
|
static const char kTurnUsername[] = "test";
|
2013-11-13 22:48:52 +00:00
|
|
|
static const char kStunIceServerWithIPv4Address[] = "stun:1.2.3.4:1234";
|
|
|
|
|
static const char kStunIceServerWithIPv4AddressWithoutPort[] = "stun:1.2.3.4";
|
|
|
|
|
static const char kStunIceServerWithIPv6Address[] = "stun:[2401:fa00:4::]:1234";
|
|
|
|
|
static const char kStunIceServerWithIPv6AddressWithoutPort[] =
|
|
|
|
|
"stun:[2401:fa00:4::]";
|
|
|
|
|
static const char kTurnIceServerWithIPv6Address[] =
|
|
|
|
|
"turn:test@[2401:fa00:4::]:1234";
|
2013-07-10 00:45:36 +00:00
|
|
|
|
|
|
|
|
class NullPeerConnectionObserver : public PeerConnectionObserver {
|
|
|
|
|
public:
|
2016-05-12 08:10:52 +02:00
|
|
|
virtual ~NullPeerConnectionObserver() = default;
|
2013-07-10 00:45:36 +00:00
|
|
|
virtual void OnMessage(const std::string& msg) {}
|
|
|
|
|
virtual void OnSignalingMessage(const std::string& msg) {}
|
|
|
|
|
virtual void OnSignalingChange(
|
|
|
|
|
PeerConnectionInterface::SignalingState new_state) {}
|
2016-05-31 13:02:21 -07:00
|
|
|
virtual void OnAddStream(rtc::scoped_refptr<MediaStreamInterface> stream) {}
|
|
|
|
|
virtual void OnRemoveStream(rtc::scoped_refptr<MediaStreamInterface> stream) {
|
|
|
|
|
}
|
|
|
|
|
virtual void OnDataChannel(
|
|
|
|
|
rtc::scoped_refptr<DataChannelInterface> data_channel) {}
|
2013-07-10 00:45:36 +00:00
|
|
|
virtual void OnRenegotiationNeeded() {}
|
|
|
|
|
virtual void OnIceConnectionChange(
|
|
|
|
|
PeerConnectionInterface::IceConnectionState new_state) {}
|
|
|
|
|
virtual void OnIceGatheringChange(
|
|
|
|
|
PeerConnectionInterface::IceGatheringState new_state) {}
|
|
|
|
|
virtual void OnIceCandidate(const webrtc::IceCandidateInterface* candidate) {}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // namespace
|
|
|
|
|
|
|
|
|
|
class PeerConnectionFactoryTest : public testing::Test {
|
|
|
|
|
void SetUp() {
|
2016-01-08 05:04:57 -08:00
|
|
|
#ifdef WEBRTC_ANDROID
|
|
|
|
|
webrtc::InitializeAndroidObjects();
|
|
|
|
|
#endif
|
2016-05-17 01:52:02 -07:00
|
|
|
factory_ = webrtc::CreatePeerConnectionFactory(
|
|
|
|
|
rtc::Thread::Current(), rtc::Thread::Current(), rtc::Thread::Current(),
|
|
|
|
|
nullptr, nullptr, nullptr);
|
2013-07-10 00:45:36 +00:00
|
|
|
|
|
|
|
|
ASSERT_TRUE(factory_.get() != NULL);
|
2015-12-29 14:14:52 -08:00
|
|
|
port_allocator_.reset(
|
|
|
|
|
new cricket::FakePortAllocator(rtc::Thread::Current(), nullptr));
|
|
|
|
|
raw_port_allocator_ = port_allocator_.get();
|
2013-07-10 00:45:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected:
|
2015-12-29 14:14:52 -08:00
|
|
|
void VerifyStunServers(cricket::ServerAddresses stun_servers) {
|
|
|
|
|
EXPECT_EQ(stun_servers, raw_port_allocator_->stun_servers());
|
2013-07-10 00:45:36 +00:00
|
|
|
}
|
|
|
|
|
|
2015-12-29 14:14:52 -08:00
|
|
|
void VerifyTurnServers(std::vector<cricket::RelayServerConfig> turn_servers) {
|
|
|
|
|
EXPECT_EQ(turn_servers.size(), raw_port_allocator_->turn_servers().size());
|
|
|
|
|
for (size_t i = 0; i < turn_servers.size(); ++i) {
|
|
|
|
|
ASSERT_EQ(1u, turn_servers[i].ports.size());
|
|
|
|
|
EXPECT_EQ(1u, raw_port_allocator_->turn_servers()[i].ports.size());
|
|
|
|
|
EXPECT_EQ(
|
|
|
|
|
turn_servers[i].ports[0].address.ToString(),
|
|
|
|
|
raw_port_allocator_->turn_servers()[i].ports[0].address.ToString());
|
|
|
|
|
EXPECT_EQ(turn_servers[i].ports[0].proto,
|
|
|
|
|
raw_port_allocator_->turn_servers()[i].ports[0].proto);
|
|
|
|
|
EXPECT_EQ(turn_servers[i].credentials.username,
|
|
|
|
|
raw_port_allocator_->turn_servers()[i].credentials.username);
|
|
|
|
|
EXPECT_EQ(turn_servers[i].credentials.password,
|
|
|
|
|
raw_port_allocator_->turn_servers()[i].credentials.password);
|
2013-07-10 00:45:36 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2014-07-29 17:36:52 +00:00
|
|
|
rtc::scoped_refptr<PeerConnectionFactoryInterface> factory_;
|
2013-07-10 00:45:36 +00:00
|
|
|
NullPeerConnectionObserver observer_;
|
2016-04-27 06:47:29 -07:00
|
|
|
std::unique_ptr<cricket::FakePortAllocator> port_allocator_;
|
2015-12-29 14:14:52 -08:00
|
|
|
// Since the PC owns the port allocator after it's been initialized,
|
|
|
|
|
// this should only be used when known to be safe.
|
|
|
|
|
cricket::FakePortAllocator* raw_port_allocator_;
|
2013-07-10 00:45:36 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// Verify creation of PeerConnection using internal ADM, video factory and
|
|
|
|
|
// internal libjingle threads.
|
|
|
|
|
TEST(PeerConnectionFactoryTestInternal, CreatePCUsingInternalModules) {
|
2016-01-08 05:04:57 -08:00
|
|
|
#ifdef WEBRTC_ANDROID
|
|
|
|
|
webrtc::InitializeAndroidObjects();
|
|
|
|
|
#endif
|
|
|
|
|
|
2014-07-29 17:36:52 +00:00
|
|
|
rtc::scoped_refptr<PeerConnectionFactoryInterface> factory(
|
2013-07-10 00:45:36 +00:00
|
|
|
webrtc::CreatePeerConnectionFactory());
|
|
|
|
|
|
|
|
|
|
NullPeerConnectionObserver observer;
|
2015-12-29 14:14:52 -08:00
|
|
|
webrtc::PeerConnectionInterface::RTCConfiguration config;
|
2013-07-10 00:45:36 +00:00
|
|
|
|
2016-04-27 06:47:29 -07:00
|
|
|
std::unique_ptr<FakeDtlsIdentityStore> dtls_identity_store(
|
2015-08-11 10:33:13 +02:00
|
|
|
new FakeDtlsIdentityStore());
|
Replacing DtlsIdentityStoreInterface with RTCCertificateGeneratorInterface.
The store was used in WebRtcSessionDescriptionFactory to generate certificates,
now a generator is used instead (new API). PeerConnection[Factory][Interface],
and WebRtcSession are updated to pass generators all the way down to the
WebRtcSessionDescriptionFactory instead of stores.
The webrtc implementation of a generator, RTCCertificateGenerator, is used as
the default generator (peerconnectionfactory.cc:189) instead of the webrtc
implementation of a store, DtlsIdentityStoreImpl.
The generator is fully parameterized and does not generate RSA-1024 unless you
ask for it (which makes sense not to do beforehand since ECDSA is now default).
The store was not fully parameterized (known filed bug).
The "top" layer, PeerConnectionFactoryInterface::CreatePeerConneciton, is
updated to take a generator instead of a store.
Many unittests still use a store, to allow them to continue to do so the
factory gets CreatePeerConnectionWithStore which uses the old function
signature (and invokes the new signature by wrapping the store in an
RTCCertificateGeneratorStoreWrapper). As soon as the FakeDtlsIdentityStore is
turned into a certificate generator instead of a store, the unittests will be
updated and we can remove CreatePeerConnectionWithStore.
This is a reupload of https://codereview.webrtc.org/2013523002/ with minor
changes.
BUG=webrtc:5707, webrtc:5708
R=tommi@webrtc.org
Review URL: https://codereview.webrtc.org/2017943002 .
Cr-Commit-Position: refs/heads/master@{#12984}
2016-06-01 11:44:18 +02:00
|
|
|
rtc::scoped_refptr<PeerConnectionInterface> pc(
|
|
|
|
|
factory->CreatePeerConnectionWithStore(
|
|
|
|
|
config, nullptr, nullptr, std::move(dtls_identity_store), &observer));
|
2013-07-10 00:45:36 +00:00
|
|
|
|
2015-08-11 10:33:13 +02:00
|
|
|
EXPECT_TRUE(pc.get() != nullptr);
|
2013-07-10 00:45:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// This test verifies creation of PeerConnection with valid STUN and TURN
|
|
|
|
|
// configuration. Also verifies the URL's parsed correctly as expected.
|
|
|
|
|
TEST_F(PeerConnectionFactoryTest, CreatePCUsingIceServers) {
|
2014-05-03 05:39:45 +00:00
|
|
|
PeerConnectionInterface::RTCConfiguration config;
|
|
|
|
|
webrtc::PeerConnectionInterface::IceServer ice_server;
|
|
|
|
|
ice_server.uri = kStunIceServer;
|
|
|
|
|
config.servers.push_back(ice_server);
|
|
|
|
|
ice_server.uri = kTurnIceServer;
|
|
|
|
|
ice_server.password = kTurnPassword;
|
|
|
|
|
config.servers.push_back(ice_server);
|
|
|
|
|
ice_server.uri = kTurnIceServerWithTransport;
|
|
|
|
|
ice_server.password = kTurnPassword;
|
2015-05-28 23:06:30 +02:00
|
|
|
config.servers.push_back(ice_server);
|
2016-04-27 06:47:29 -07:00
|
|
|
std::unique_ptr<DtlsIdentityStoreInterface> dtls_identity_store(
|
2015-08-11 10:33:13 +02:00
|
|
|
new FakeDtlsIdentityStore());
|
Replacing DtlsIdentityStoreInterface with RTCCertificateGeneratorInterface.
The store was used in WebRtcSessionDescriptionFactory to generate certificates,
now a generator is used instead (new API). PeerConnection[Factory][Interface],
and WebRtcSession are updated to pass generators all the way down to the
WebRtcSessionDescriptionFactory instead of stores.
The webrtc implementation of a generator, RTCCertificateGenerator, is used as
the default generator (peerconnectionfactory.cc:189) instead of the webrtc
implementation of a store, DtlsIdentityStoreImpl.
The generator is fully parameterized and does not generate RSA-1024 unless you
ask for it (which makes sense not to do beforehand since ECDSA is now default).
The store was not fully parameterized (known filed bug).
The "top" layer, PeerConnectionFactoryInterface::CreatePeerConneciton, is
updated to take a generator instead of a store.
Many unittests still use a store, to allow them to continue to do so the
factory gets CreatePeerConnectionWithStore which uses the old function
signature (and invokes the new signature by wrapping the store in an
RTCCertificateGeneratorStoreWrapper). As soon as the FakeDtlsIdentityStore is
turned into a certificate generator instead of a store, the unittests will be
updated and we can remove CreatePeerConnectionWithStore.
This is a reupload of https://codereview.webrtc.org/2013523002/ with minor
changes.
BUG=webrtc:5707, webrtc:5708
R=tommi@webrtc.org
Review URL: https://codereview.webrtc.org/2017943002 .
Cr-Commit-Position: refs/heads/master@{#12984}
2016-06-01 11:44:18 +02:00
|
|
|
rtc::scoped_refptr<PeerConnectionInterface> pc(
|
|
|
|
|
factory_->CreatePeerConnectionWithStore(
|
|
|
|
|
config, nullptr, std::move(port_allocator_),
|
|
|
|
|
std::move(dtls_identity_store), &observer_));
|
2015-12-29 14:14:52 -08:00
|
|
|
ASSERT_TRUE(pc.get() != NULL);
|
|
|
|
|
cricket::ServerAddresses stun_servers;
|
|
|
|
|
rtc::SocketAddress stun1("stun.l.google.com", 19302);
|
|
|
|
|
stun_servers.insert(stun1);
|
|
|
|
|
VerifyStunServers(stun_servers);
|
|
|
|
|
std::vector<cricket::RelayServerConfig> turn_servers;
|
|
|
|
|
cricket::RelayServerConfig turn1("test.com", 1234, "test@hello.com",
|
|
|
|
|
kTurnPassword, cricket::PROTO_UDP, false);
|
|
|
|
|
turn_servers.push_back(turn1);
|
|
|
|
|
cricket::RelayServerConfig turn2("hello.com", kDefaultStunPort, "test",
|
|
|
|
|
kTurnPassword, cricket::PROTO_TCP, false);
|
|
|
|
|
turn_servers.push_back(turn2);
|
|
|
|
|
VerifyTurnServers(turn_servers);
|
2015-05-28 23:06:30 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// This test verifies creation of PeerConnection with valid STUN and TURN
|
|
|
|
|
// configuration. Also verifies the list of URL's parsed correctly as expected.
|
|
|
|
|
TEST_F(PeerConnectionFactoryTest, CreatePCUsingIceServersUrls) {
|
|
|
|
|
PeerConnectionInterface::RTCConfiguration config;
|
|
|
|
|
webrtc::PeerConnectionInterface::IceServer ice_server;
|
|
|
|
|
ice_server.urls.push_back(kStunIceServer);
|
|
|
|
|
ice_server.urls.push_back(kTurnIceServer);
|
|
|
|
|
ice_server.urls.push_back(kTurnIceServerWithTransport);
|
|
|
|
|
ice_server.password = kTurnPassword;
|
2014-05-03 05:39:45 +00:00
|
|
|
config.servers.push_back(ice_server);
|
2016-04-27 06:47:29 -07:00
|
|
|
std::unique_ptr<DtlsIdentityStoreInterface> dtls_identity_store(
|
2015-08-11 10:33:13 +02:00
|
|
|
new FakeDtlsIdentityStore());
|
Replacing DtlsIdentityStoreInterface with RTCCertificateGeneratorInterface.
The store was used in WebRtcSessionDescriptionFactory to generate certificates,
now a generator is used instead (new API). PeerConnection[Factory][Interface],
and WebRtcSession are updated to pass generators all the way down to the
WebRtcSessionDescriptionFactory instead of stores.
The webrtc implementation of a generator, RTCCertificateGenerator, is used as
the default generator (peerconnectionfactory.cc:189) instead of the webrtc
implementation of a store, DtlsIdentityStoreImpl.
The generator is fully parameterized and does not generate RSA-1024 unless you
ask for it (which makes sense not to do beforehand since ECDSA is now default).
The store was not fully parameterized (known filed bug).
The "top" layer, PeerConnectionFactoryInterface::CreatePeerConneciton, is
updated to take a generator instead of a store.
Many unittests still use a store, to allow them to continue to do so the
factory gets CreatePeerConnectionWithStore which uses the old function
signature (and invokes the new signature by wrapping the store in an
RTCCertificateGeneratorStoreWrapper). As soon as the FakeDtlsIdentityStore is
turned into a certificate generator instead of a store, the unittests will be
updated and we can remove CreatePeerConnectionWithStore.
This is a reupload of https://codereview.webrtc.org/2013523002/ with minor
changes.
BUG=webrtc:5707, webrtc:5708
R=tommi@webrtc.org
Review URL: https://codereview.webrtc.org/2017943002 .
Cr-Commit-Position: refs/heads/master@{#12984}
2016-06-01 11:44:18 +02:00
|
|
|
rtc::scoped_refptr<PeerConnectionInterface> pc(
|
|
|
|
|
factory_->CreatePeerConnectionWithStore(
|
|
|
|
|
config, nullptr, std::move(port_allocator_),
|
|
|
|
|
std::move(dtls_identity_store), &observer_));
|
2015-12-29 14:14:52 -08:00
|
|
|
ASSERT_TRUE(pc.get() != NULL);
|
|
|
|
|
cricket::ServerAddresses stun_servers;
|
|
|
|
|
rtc::SocketAddress stun1("stun.l.google.com", 19302);
|
|
|
|
|
stun_servers.insert(stun1);
|
|
|
|
|
VerifyStunServers(stun_servers);
|
|
|
|
|
std::vector<cricket::RelayServerConfig> turn_servers;
|
|
|
|
|
cricket::RelayServerConfig turn1("test.com", 1234, "test@hello.com",
|
|
|
|
|
kTurnPassword, cricket::PROTO_UDP, false);
|
|
|
|
|
turn_servers.push_back(turn1);
|
|
|
|
|
cricket::RelayServerConfig turn2("hello.com", kDefaultStunPort, "test",
|
|
|
|
|
kTurnPassword, cricket::PROTO_TCP, false);
|
|
|
|
|
turn_servers.push_back(turn2);
|
|
|
|
|
VerifyTurnServers(turn_servers);
|
2013-07-10 00:45:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TEST_F(PeerConnectionFactoryTest, CreatePCUsingNoUsernameInUri) {
|
2014-05-03 05:39:45 +00:00
|
|
|
PeerConnectionInterface::RTCConfiguration config;
|
2013-07-10 00:45:36 +00:00
|
|
|
webrtc::PeerConnectionInterface::IceServer ice_server;
|
|
|
|
|
ice_server.uri = kStunIceServer;
|
2014-05-03 05:39:45 +00:00
|
|
|
config.servers.push_back(ice_server);
|
2013-07-10 00:45:36 +00:00
|
|
|
ice_server.uri = kTurnIceServerWithNoUsernameInUri;
|
|
|
|
|
ice_server.username = kTurnUsername;
|
|
|
|
|
ice_server.password = kTurnPassword;
|
2014-05-03 05:39:45 +00:00
|
|
|
config.servers.push_back(ice_server);
|
2016-04-27 06:47:29 -07:00
|
|
|
std::unique_ptr<DtlsIdentityStoreInterface> dtls_identity_store(
|
2015-08-11 10:33:13 +02:00
|
|
|
new FakeDtlsIdentityStore());
|
Replacing DtlsIdentityStoreInterface with RTCCertificateGeneratorInterface.
The store was used in WebRtcSessionDescriptionFactory to generate certificates,
now a generator is used instead (new API). PeerConnection[Factory][Interface],
and WebRtcSession are updated to pass generators all the way down to the
WebRtcSessionDescriptionFactory instead of stores.
The webrtc implementation of a generator, RTCCertificateGenerator, is used as
the default generator (peerconnectionfactory.cc:189) instead of the webrtc
implementation of a store, DtlsIdentityStoreImpl.
The generator is fully parameterized and does not generate RSA-1024 unless you
ask for it (which makes sense not to do beforehand since ECDSA is now default).
The store was not fully parameterized (known filed bug).
The "top" layer, PeerConnectionFactoryInterface::CreatePeerConneciton, is
updated to take a generator instead of a store.
Many unittests still use a store, to allow them to continue to do so the
factory gets CreatePeerConnectionWithStore which uses the old function
signature (and invokes the new signature by wrapping the store in an
RTCCertificateGeneratorStoreWrapper). As soon as the FakeDtlsIdentityStore is
turned into a certificate generator instead of a store, the unittests will be
updated and we can remove CreatePeerConnectionWithStore.
This is a reupload of https://codereview.webrtc.org/2013523002/ with minor
changes.
BUG=webrtc:5707, webrtc:5708
R=tommi@webrtc.org
Review URL: https://codereview.webrtc.org/2017943002 .
Cr-Commit-Position: refs/heads/master@{#12984}
2016-06-01 11:44:18 +02:00
|
|
|
rtc::scoped_refptr<PeerConnectionInterface> pc(
|
|
|
|
|
factory_->CreatePeerConnectionWithStore(
|
|
|
|
|
config, nullptr, std::move(port_allocator_),
|
|
|
|
|
std::move(dtls_identity_store), &observer_));
|
2015-12-29 14:14:52 -08:00
|
|
|
ASSERT_TRUE(pc.get() != NULL);
|
|
|
|
|
std::vector<cricket::RelayServerConfig> turn_servers;
|
|
|
|
|
cricket::RelayServerConfig turn("test.com", 1234, kTurnUsername,
|
|
|
|
|
kTurnPassword, cricket::PROTO_UDP, false);
|
|
|
|
|
turn_servers.push_back(turn);
|
|
|
|
|
VerifyTurnServers(turn_servers);
|
2013-07-10 00:45:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// This test verifies the PeerConnection created properly with TURN url which
|
|
|
|
|
// has transport parameter in it.
|
|
|
|
|
TEST_F(PeerConnectionFactoryTest, CreatePCUsingTurnUrlWithTransportParam) {
|
2014-05-03 05:39:45 +00:00
|
|
|
PeerConnectionInterface::RTCConfiguration config;
|
2013-07-10 00:45:36 +00:00
|
|
|
webrtc::PeerConnectionInterface::IceServer ice_server;
|
|
|
|
|
ice_server.uri = kTurnIceServerWithTransport;
|
|
|
|
|
ice_server.password = kTurnPassword;
|
2014-05-03 05:39:45 +00:00
|
|
|
config.servers.push_back(ice_server);
|
2016-04-27 06:47:29 -07:00
|
|
|
std::unique_ptr<DtlsIdentityStoreInterface> dtls_identity_store(
|
2015-08-11 10:33:13 +02:00
|
|
|
new FakeDtlsIdentityStore());
|
Replacing DtlsIdentityStoreInterface with RTCCertificateGeneratorInterface.
The store was used in WebRtcSessionDescriptionFactory to generate certificates,
now a generator is used instead (new API). PeerConnection[Factory][Interface],
and WebRtcSession are updated to pass generators all the way down to the
WebRtcSessionDescriptionFactory instead of stores.
The webrtc implementation of a generator, RTCCertificateGenerator, is used as
the default generator (peerconnectionfactory.cc:189) instead of the webrtc
implementation of a store, DtlsIdentityStoreImpl.
The generator is fully parameterized and does not generate RSA-1024 unless you
ask for it (which makes sense not to do beforehand since ECDSA is now default).
The store was not fully parameterized (known filed bug).
The "top" layer, PeerConnectionFactoryInterface::CreatePeerConneciton, is
updated to take a generator instead of a store.
Many unittests still use a store, to allow them to continue to do so the
factory gets CreatePeerConnectionWithStore which uses the old function
signature (and invokes the new signature by wrapping the store in an
RTCCertificateGeneratorStoreWrapper). As soon as the FakeDtlsIdentityStore is
turned into a certificate generator instead of a store, the unittests will be
updated and we can remove CreatePeerConnectionWithStore.
This is a reupload of https://codereview.webrtc.org/2013523002/ with minor
changes.
BUG=webrtc:5707, webrtc:5708
R=tommi@webrtc.org
Review URL: https://codereview.webrtc.org/2017943002 .
Cr-Commit-Position: refs/heads/master@{#12984}
2016-06-01 11:44:18 +02:00
|
|
|
rtc::scoped_refptr<PeerConnectionInterface> pc(
|
|
|
|
|
factory_->CreatePeerConnectionWithStore(
|
|
|
|
|
config, nullptr, std::move(port_allocator_),
|
|
|
|
|
std::move(dtls_identity_store), &observer_));
|
2015-12-29 14:14:52 -08:00
|
|
|
ASSERT_TRUE(pc.get() != NULL);
|
|
|
|
|
std::vector<cricket::RelayServerConfig> turn_servers;
|
|
|
|
|
cricket::RelayServerConfig turn("hello.com", kDefaultStunPort, "test",
|
|
|
|
|
kTurnPassword, cricket::PROTO_TCP, false);
|
|
|
|
|
turn_servers.push_back(turn);
|
|
|
|
|
VerifyTurnServers(turn_servers);
|
2013-07-10 00:45:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TEST_F(PeerConnectionFactoryTest, CreatePCUsingSecureTurnUrl) {
|
2014-05-03 05:39:45 +00:00
|
|
|
PeerConnectionInterface::RTCConfiguration config;
|
2013-07-10 00:45:36 +00:00
|
|
|
webrtc::PeerConnectionInterface::IceServer ice_server;
|
|
|
|
|
ice_server.uri = kSecureTurnIceServer;
|
|
|
|
|
ice_server.password = kTurnPassword;
|
2014-05-03 05:39:45 +00:00
|
|
|
config.servers.push_back(ice_server);
|
2013-10-07 23:32:02 +00:00
|
|
|
ice_server.uri = kSecureTurnIceServerWithoutTransportParam;
|
|
|
|
|
ice_server.password = kTurnPassword;
|
2014-05-03 05:39:45 +00:00
|
|
|
config.servers.push_back(ice_server);
|
2013-12-05 00:24:06 +00:00
|
|
|
ice_server.uri = kSecureTurnIceServerWithoutTransportAndPortParam;
|
|
|
|
|
ice_server.password = kTurnPassword;
|
2014-05-03 05:39:45 +00:00
|
|
|
config.servers.push_back(ice_server);
|
2016-04-27 06:47:29 -07:00
|
|
|
std::unique_ptr<DtlsIdentityStoreInterface> dtls_identity_store(
|
2015-08-11 10:33:13 +02:00
|
|
|
new FakeDtlsIdentityStore());
|
Replacing DtlsIdentityStoreInterface with RTCCertificateGeneratorInterface.
The store was used in WebRtcSessionDescriptionFactory to generate certificates,
now a generator is used instead (new API). PeerConnection[Factory][Interface],
and WebRtcSession are updated to pass generators all the way down to the
WebRtcSessionDescriptionFactory instead of stores.
The webrtc implementation of a generator, RTCCertificateGenerator, is used as
the default generator (peerconnectionfactory.cc:189) instead of the webrtc
implementation of a store, DtlsIdentityStoreImpl.
The generator is fully parameterized and does not generate RSA-1024 unless you
ask for it (which makes sense not to do beforehand since ECDSA is now default).
The store was not fully parameterized (known filed bug).
The "top" layer, PeerConnectionFactoryInterface::CreatePeerConneciton, is
updated to take a generator instead of a store.
Many unittests still use a store, to allow them to continue to do so the
factory gets CreatePeerConnectionWithStore which uses the old function
signature (and invokes the new signature by wrapping the store in an
RTCCertificateGeneratorStoreWrapper). As soon as the FakeDtlsIdentityStore is
turned into a certificate generator instead of a store, the unittests will be
updated and we can remove CreatePeerConnectionWithStore.
This is a reupload of https://codereview.webrtc.org/2013523002/ with minor
changes.
BUG=webrtc:5707, webrtc:5708
R=tommi@webrtc.org
Review URL: https://codereview.webrtc.org/2017943002 .
Cr-Commit-Position: refs/heads/master@{#12984}
2016-06-01 11:44:18 +02:00
|
|
|
rtc::scoped_refptr<PeerConnectionInterface> pc(
|
|
|
|
|
factory_->CreatePeerConnectionWithStore(
|
|
|
|
|
config, nullptr, std::move(port_allocator_),
|
|
|
|
|
std::move(dtls_identity_store), &observer_));
|
2015-12-29 14:14:52 -08:00
|
|
|
ASSERT_TRUE(pc.get() != NULL);
|
|
|
|
|
std::vector<cricket::RelayServerConfig> turn_servers;
|
|
|
|
|
cricket::RelayServerConfig turn1("hello.com", kDefaultStunTlsPort, "test",
|
|
|
|
|
kTurnPassword, cricket::PROTO_TCP, true);
|
|
|
|
|
turn_servers.push_back(turn1);
|
2013-10-07 23:32:02 +00:00
|
|
|
// TURNS with transport param should be default to tcp.
|
2015-12-29 14:14:52 -08:00
|
|
|
cricket::RelayServerConfig turn2("hello.com", 443, "test_no_transport",
|
|
|
|
|
kTurnPassword, cricket::PROTO_TCP, true);
|
|
|
|
|
turn_servers.push_back(turn2);
|
|
|
|
|
cricket::RelayServerConfig turn3("hello.com", kDefaultStunTlsPort,
|
|
|
|
|
"test_no_transport", kTurnPassword,
|
|
|
|
|
cricket::PROTO_TCP, true);
|
|
|
|
|
turn_servers.push_back(turn3);
|
|
|
|
|
VerifyTurnServers(turn_servers);
|
2013-11-13 22:48:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TEST_F(PeerConnectionFactoryTest, CreatePCUsingIPLiteralAddress) {
|
2014-05-03 05:39:45 +00:00
|
|
|
PeerConnectionInterface::RTCConfiguration config;
|
2013-11-13 22:48:52 +00:00
|
|
|
webrtc::PeerConnectionInterface::IceServer ice_server;
|
|
|
|
|
ice_server.uri = kStunIceServerWithIPv4Address;
|
2014-05-03 05:39:45 +00:00
|
|
|
config.servers.push_back(ice_server);
|
2013-11-13 22:48:52 +00:00
|
|
|
ice_server.uri = kStunIceServerWithIPv4AddressWithoutPort;
|
2014-05-03 05:39:45 +00:00
|
|
|
config.servers.push_back(ice_server);
|
2013-11-13 22:48:52 +00:00
|
|
|
ice_server.uri = kStunIceServerWithIPv6Address;
|
2014-05-03 05:39:45 +00:00
|
|
|
config.servers.push_back(ice_server);
|
2013-11-13 22:48:52 +00:00
|
|
|
ice_server.uri = kStunIceServerWithIPv6AddressWithoutPort;
|
2014-05-03 05:39:45 +00:00
|
|
|
config.servers.push_back(ice_server);
|
2013-11-13 22:48:52 +00:00
|
|
|
ice_server.uri = kTurnIceServerWithIPv6Address;
|
|
|
|
|
ice_server.password = kTurnPassword;
|
2014-05-03 05:39:45 +00:00
|
|
|
config.servers.push_back(ice_server);
|
2016-04-27 06:47:29 -07:00
|
|
|
std::unique_ptr<DtlsIdentityStoreInterface> dtls_identity_store(
|
2015-08-11 10:33:13 +02:00
|
|
|
new FakeDtlsIdentityStore());
|
Replacing DtlsIdentityStoreInterface with RTCCertificateGeneratorInterface.
The store was used in WebRtcSessionDescriptionFactory to generate certificates,
now a generator is used instead (new API). PeerConnection[Factory][Interface],
and WebRtcSession are updated to pass generators all the way down to the
WebRtcSessionDescriptionFactory instead of stores.
The webrtc implementation of a generator, RTCCertificateGenerator, is used as
the default generator (peerconnectionfactory.cc:189) instead of the webrtc
implementation of a store, DtlsIdentityStoreImpl.
The generator is fully parameterized and does not generate RSA-1024 unless you
ask for it (which makes sense not to do beforehand since ECDSA is now default).
The store was not fully parameterized (known filed bug).
The "top" layer, PeerConnectionFactoryInterface::CreatePeerConneciton, is
updated to take a generator instead of a store.
Many unittests still use a store, to allow them to continue to do so the
factory gets CreatePeerConnectionWithStore which uses the old function
signature (and invokes the new signature by wrapping the store in an
RTCCertificateGeneratorStoreWrapper). As soon as the FakeDtlsIdentityStore is
turned into a certificate generator instead of a store, the unittests will be
updated and we can remove CreatePeerConnectionWithStore.
This is a reupload of https://codereview.webrtc.org/2013523002/ with minor
changes.
BUG=webrtc:5707, webrtc:5708
R=tommi@webrtc.org
Review URL: https://codereview.webrtc.org/2017943002 .
Cr-Commit-Position: refs/heads/master@{#12984}
2016-06-01 11:44:18 +02:00
|
|
|
rtc::scoped_refptr<PeerConnectionInterface> pc(
|
|
|
|
|
factory_->CreatePeerConnectionWithStore(
|
|
|
|
|
config, nullptr, std::move(port_allocator_),
|
|
|
|
|
std::move(dtls_identity_store), &observer_));
|
2015-12-29 14:14:52 -08:00
|
|
|
ASSERT_TRUE(pc.get() != NULL);
|
|
|
|
|
cricket::ServerAddresses stun_servers;
|
|
|
|
|
rtc::SocketAddress stun1("1.2.3.4", 1234);
|
|
|
|
|
stun_servers.insert(stun1);
|
|
|
|
|
rtc::SocketAddress stun2("1.2.3.4", 3478);
|
|
|
|
|
stun_servers.insert(stun2); // Default port
|
|
|
|
|
rtc::SocketAddress stun3("2401:fa00:4::", 1234);
|
|
|
|
|
stun_servers.insert(stun3);
|
|
|
|
|
rtc::SocketAddress stun4("2401:fa00:4::", 3478);
|
|
|
|
|
stun_servers.insert(stun4); // Default port
|
|
|
|
|
VerifyStunServers(stun_servers);
|
2014-04-14 16:06:21 +00:00
|
|
|
|
2015-12-29 14:14:52 -08:00
|
|
|
std::vector<cricket::RelayServerConfig> turn_servers;
|
|
|
|
|
cricket::RelayServerConfig turn1("2401:fa00:4::", 1234, "test", kTurnPassword,
|
|
|
|
|
cricket::PROTO_UDP, false);
|
|
|
|
|
turn_servers.push_back(turn1);
|
|
|
|
|
VerifyTurnServers(turn_servers);
|
2013-07-10 00:45:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// This test verifies the captured stream is rendered locally using a
|
|
|
|
|
// local video track.
|
|
|
|
|
TEST_F(PeerConnectionFactoryTest, LocalRendering) {
|
|
|
|
|
cricket::FakeVideoCapturer* capturer = new cricket::FakeVideoCapturer();
|
|
|
|
|
// The source take ownership of |capturer|.
|
2016-03-08 01:27:48 +01:00
|
|
|
rtc::scoped_refptr<VideoTrackSourceInterface> source(
|
2013-07-10 00:45:36 +00:00
|
|
|
factory_->CreateVideoSource(capturer, NULL));
|
|
|
|
|
ASSERT_TRUE(source.get() != NULL);
|
2014-07-29 17:36:52 +00:00
|
|
|
rtc::scoped_refptr<VideoTrackInterface> track(
|
2013-07-10 00:45:36 +00:00
|
|
|
factory_->CreateVideoTrack("testlabel", source));
|
|
|
|
|
ASSERT_TRUE(track.get() != NULL);
|
|
|
|
|
FakeVideoTrackRenderer local_renderer(track);
|
|
|
|
|
|
|
|
|
|
EXPECT_EQ(0, local_renderer.num_rendered_frames());
|
|
|
|
|
EXPECT_TRUE(capturer->CaptureFrame());
|
|
|
|
|
EXPECT_EQ(1, local_renderer.num_rendered_frames());
|
2016-01-19 00:23:24 -08:00
|
|
|
EXPECT_FALSE(local_renderer.black_frame());
|
2013-07-10 00:45:36 +00:00
|
|
|
|
|
|
|
|
track->set_enabled(false);
|
|
|
|
|
EXPECT_TRUE(capturer->CaptureFrame());
|
2016-01-19 00:23:24 -08:00
|
|
|
EXPECT_EQ(2, local_renderer.num_rendered_frames());
|
|
|
|
|
EXPECT_TRUE(local_renderer.black_frame());
|
2013-07-10 00:45:36 +00:00
|
|
|
|
|
|
|
|
track->set_enabled(true);
|
|
|
|
|
EXPECT_TRUE(capturer->CaptureFrame());
|
2016-01-19 00:23:24 -08:00
|
|
|
EXPECT_EQ(3, local_renderer.num_rendered_frames());
|
|
|
|
|
EXPECT_FALSE(local_renderer.black_frame());
|
2013-07-10 00:45:36 +00:00
|
|
|
}
|