(Auto)update libjingle 66106643-> 66138442

git-svn-id: http://webrtc.googlecode.com/svn/trunk@6049 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
buildbot@webrtc.org 2014-05-03 05:39:45 +00:00
parent b235c56017
commit 41451d4e55
10 changed files with 213 additions and 102 deletions

View File

@ -60,7 +60,6 @@ class MediaConstraintsInterface {
virtual const Constraints& GetMandatory() const = 0;
virtual const Constraints& GetOptional() const = 0;
// Constraint keys used by a local video source.
// Specified by draft-alvestrand-constraints-resolution-00b
static const char kMinAspectRatio[]; // minAspectRatio

View File

@ -37,6 +37,7 @@
#include "talk/app/webrtc/streamcollection.h"
#include "talk/base/logging.h"
#include "talk/base/stringencode.h"
#include "talk/p2p/client/basicportallocator.h"
#include "talk/session/media/channelmanager.h"
namespace {
@ -314,22 +315,23 @@ PeerConnection::~PeerConnection() {
}
bool PeerConnection::Initialize(
const PeerConnectionInterface::IceServers& configuration,
const PeerConnectionInterface::RTCConfiguration& configuration,
const MediaConstraintsInterface* constraints,
PortAllocatorFactoryInterface* allocator_factory,
DTLSIdentityServiceInterface* dtls_identity_service,
PeerConnectionObserver* observer) {
std::vector<PortAllocatorFactoryInterface::StunConfiguration> stun_config;
std::vector<PortAllocatorFactoryInterface::TurnConfiguration> turn_config;
if (!ParseIceServers(configuration, &stun_config, &turn_config)) {
if (!ParseIceServers(configuration.servers, &stun_config, &turn_config)) {
return false;
}
return DoInitialize(stun_config, turn_config, constraints,
return DoInitialize(configuration.type, stun_config, turn_config, constraints,
allocator_factory, dtls_identity_service, observer);
}
bool PeerConnection::DoInitialize(
IceTransportsType type,
const StunConfigurations& stun_config,
const TurnConfigurations& turn_config,
const MediaConstraintsInterface* constraints,
@ -374,7 +376,7 @@ bool PeerConnection::DoInitialize(
// Initialize the WebRtcSession. It creates transport channels etc.
if (!session_->Initialize(factory_->options(), constraints,
dtls_identity_service))
dtls_identity_service, type))
return false;
// Register PeerConnection as receiver of local ice candidates.
@ -568,11 +570,50 @@ void PeerConnection::PostSetSessionDescriptionFailure(
bool PeerConnection::UpdateIce(const IceServers& configuration,
const MediaConstraintsInterface* constraints) {
// TODO(ronghuawu): Implement UpdateIce.
LOG(LS_ERROR) << "UpdateIce is not implemented.";
return false;
}
bool PeerConnection::UpdateIce(const RTCConfiguration& config) {
if (port_allocator_) {
std::vector<PortAllocatorFactoryInterface::StunConfiguration> stuns;
std::vector<PortAllocatorFactoryInterface::TurnConfiguration> turns;
if (!ParseIceServers(config.servers, &stuns, &turns)) {
return false;
}
std::vector<talk_base::SocketAddress> stun_hosts;
typedef std::vector<StunConfiguration>::const_iterator StunIt;
for (StunIt stun_it = stuns.begin(); stun_it != stuns.end(); ++stun_it) {
stun_hosts.push_back(stun_it->server);
}
talk_base::SocketAddress stun_addr;
if (!stun_hosts.empty()) {
stun_addr = stun_hosts.front();
LOG(LS_INFO) << "UpdateIce: StunServer Address: " << stun_addr.ToString();
}
for (size_t i = 0; i < turns.size(); ++i) {
cricket::RelayCredentials credentials(turns[i].username,
turns[i].password);
cricket::RelayServerConfig relay_server(cricket::RELAY_TURN);
cricket::ProtocolType protocol;
if (cricket::StringToProto(turns[i].transport_type.c_str(), &protocol)) {
relay_server.ports.push_back(cricket::ProtocolAddress(
turns[i].server, protocol, turns[i].secure));
relay_server.credentials = credentials;
LOG(LS_INFO) << "UpdateIce: TurnServer Address: "
<< turns[i].server.ToString();
} else {
LOG(LS_WARNING) << "Ignoring TURN server " << turns[i].server << ". "
<< "Reason= Incorrect " << turns[i].transport_type
<< " transport parameter.";
}
}
}
return session_->UpdateIce(config.type);
}
bool PeerConnection::AddIceCandidate(
const IceCandidateInterface* ice_candidate) {
return session_->ProcessIceMessage(ice_candidate);

View File

@ -57,11 +57,12 @@ class PeerConnection : public PeerConnectionInterface,
public:
explicit PeerConnection(PeerConnectionFactory* factory);
bool Initialize(const PeerConnectionInterface::IceServers& configuration,
const MediaConstraintsInterface* constraints,
PortAllocatorFactoryInterface* allocator_factory,
DTLSIdentityServiceInterface* dtls_identity_service,
PeerConnectionObserver* observer);
bool Initialize(
const PeerConnectionInterface::RTCConfiguration& configuration,
const MediaConstraintsInterface* constraints,
PortAllocatorFactoryInterface* allocator_factory,
DTLSIdentityServiceInterface* dtls_identity_service,
PeerConnectionObserver* observer);
virtual talk_base::scoped_refptr<StreamCollectionInterface> local_streams();
virtual talk_base::scoped_refptr<StreamCollectionInterface> remote_streams();
virtual bool AddStream(MediaStreamInterface* local_stream,
@ -97,8 +98,11 @@ class PeerConnection : public PeerConnectionInterface,
SessionDescriptionInterface* desc);
virtual void SetRemoteDescription(SetSessionDescriptionObserver* observer,
SessionDescriptionInterface* desc);
// TODO(mallinath) : Deprecated version, remove after all clients are updated.
virtual bool UpdateIce(const IceServers& configuration,
const MediaConstraintsInterface* constraints);
virtual bool UpdateIce(
const PeerConnectionInterface::RTCConfiguration& config);
virtual bool AddIceCandidate(const IceCandidateInterface* candidate);
virtual void Close();
@ -152,7 +156,8 @@ class PeerConnection : public PeerConnectionInterface,
cricket::BaseSession::State state);
void ChangeSignalingState(SignalingState signaling_state);
bool DoInitialize(const StunConfigurations& stun_config,
bool DoInitialize(IceTransportsType type,
const StunConfigurations& stun_config,
const TurnConfigurations& turn_config,
const MediaConstraintsInterface* constraints,
PortAllocatorFactoryInterface* allocator_factory,

View File

@ -51,7 +51,7 @@ typedef talk_base::TypedMessageData<bool> InitMessageData;
struct CreatePeerConnectionParams : public talk_base::MessageData {
CreatePeerConnectionParams(
const webrtc::PeerConnectionInterface::IceServers& configuration,
const webrtc::PeerConnectionInterface::RTCConfiguration& configuration,
const webrtc::MediaConstraintsInterface* constraints,
webrtc::PortAllocatorFactoryInterface* allocator_factory,
webrtc::DTLSIdentityServiceInterface* dtls_identity_service,
@ -63,28 +63,13 @@ struct CreatePeerConnectionParams : public talk_base::MessageData {
observer(observer) {
}
scoped_refptr<webrtc::PeerConnectionInterface> peerconnection;
const webrtc::PeerConnectionInterface::IceServers& configuration;
const webrtc::PeerConnectionInterface::RTCConfiguration& configuration;
const webrtc::MediaConstraintsInterface* constraints;
scoped_refptr<webrtc::PortAllocatorFactoryInterface> allocator_factory;
webrtc::DTLSIdentityServiceInterface* dtls_identity_service;
webrtc::PeerConnectionObserver* observer;
};
struct CreatePeerConnectionParamsDeprecated : public talk_base::MessageData {
CreatePeerConnectionParamsDeprecated(
const std::string& configuration,
webrtc::PortAllocatorFactoryInterface* allocator_factory,
webrtc::PeerConnectionObserver* observer)
: configuration(configuration),
allocator_factory(allocator_factory),
observer(observer) {
}
scoped_refptr<webrtc::PeerConnectionInterface> peerconnection;
const std::string& configuration;
scoped_refptr<webrtc::PortAllocatorFactoryInterface> allocator_factory;
webrtc::PeerConnectionObserver* observer;
};
struct CreateAudioSourceParams : public talk_base::MessageData {
explicit CreateAudioSourceParams(
const webrtc::MediaConstraintsInterface* constraints)
@ -295,7 +280,7 @@ bool PeerConnectionFactory::StartAecDump_s(talk_base::PlatformFile file) {
scoped_refptr<PeerConnectionInterface>
PeerConnectionFactory::CreatePeerConnection(
const PeerConnectionInterface::IceServers& configuration,
const PeerConnectionInterface::RTCConfiguration& configuration,
const MediaConstraintsInterface* constraints,
PortAllocatorFactoryInterface* allocator_factory,
DTLSIdentityServiceInterface* dtls_identity_service,
@ -303,23 +288,14 @@ PeerConnectionFactory::CreatePeerConnection(
CreatePeerConnectionParams params(configuration, constraints,
allocator_factory, dtls_identity_service,
observer);
signaling_thread_->Send(this, MSG_CREATE_PEERCONNECTION, &params);
signaling_thread_->Send(
this, MSG_CREATE_PEERCONNECTION, &params);
return params.peerconnection;
}
scoped_refptr<PeerConnectionInterface>
PeerConnectionFactory::CreatePeerConnection(
const PeerConnectionInterface::IceServers& configuration,
const MediaConstraintsInterface* constraints,
DTLSIdentityServiceInterface* dtls_identity_service,
PeerConnectionObserver* observer) {
return CreatePeerConnection(
configuration, constraints, NULL, dtls_identity_service, observer);
}
talk_base::scoped_refptr<PeerConnectionInterface>
PeerConnectionFactory::CreatePeerConnection_s(
const PeerConnectionInterface::IceServers& configuration,
const PeerConnectionInterface::RTCConfiguration& configuration,
const MediaConstraintsInterface* constraints,
PortAllocatorFactoryInterface* allocator_factory,
DTLSIdentityServiceInterface* dtls_identity_service,

View File

@ -46,18 +46,12 @@ class PeerConnectionFactory : public PeerConnectionFactoryInterface,
virtual talk_base::scoped_refptr<PeerConnectionInterface>
CreatePeerConnection(
const PeerConnectionInterface::IceServers& configuration,
const MediaConstraintsInterface* constraints,
DTLSIdentityServiceInterface* dtls_identity_service,
PeerConnectionObserver* observer);
virtual talk_base::scoped_refptr<PeerConnectionInterface>
CreatePeerConnection(
const PeerConnectionInterface::IceServers& configuration,
const PeerConnectionInterface::RTCConfiguration& configuration,
const MediaConstraintsInterface* constraints,
PortAllocatorFactoryInterface* allocator_factory,
DTLSIdentityServiceInterface* dtls_identity_service,
PeerConnectionObserver* observer);
bool Initialize();
virtual talk_base::scoped_refptr<MediaStreamInterface>
@ -103,12 +97,14 @@ class PeerConnectionFactory : public PeerConnectionFactoryInterface,
talk_base::scoped_refptr<VideoSourceInterface> CreateVideoSource_s(
cricket::VideoCapturer* capturer,
const MediaConstraintsInterface* constraints);
talk_base::scoped_refptr<PeerConnectionInterface> CreatePeerConnection_s(
const PeerConnectionInterface::IceServers& configuration,
const PeerConnectionInterface::RTCConfiguration& configuration,
const MediaConstraintsInterface* constraints,
PortAllocatorFactoryInterface* allocator_factory,
DTLSIdentityServiceInterface* dtls_identity_service,
PeerConnectionObserver* observer);
bool StartAecDump_s(talk_base::PlatformFile file);
// Implements talk_base::MessageHandler.

View File

@ -156,7 +156,7 @@ TEST(PeerConnectionFactoryTestInternal, CreatePCUsingInternalModules) {
webrtc::PeerConnectionInterface::IceServers servers;
talk_base::scoped_refptr<PeerConnectionInterface> pc(
factory->CreatePeerConnection(servers, NULL, NULL, &observer));
factory->CreatePeerConnection(servers, NULL, NULL, NULL, &observer));
EXPECT_TRUE(pc.get() != NULL);
}
@ -164,6 +164,42 @@ TEST(PeerConnectionFactoryTestInternal, CreatePCUsingInternalModules) {
// 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) {
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;
config.servers.push_back(ice_server);
talk_base::scoped_refptr<PeerConnectionInterface> pc(
factory_->CreatePeerConnection(config, NULL,
allocator_factory_.get(),
NULL,
&observer_));
EXPECT_TRUE(pc.get() != NULL);
StunConfigurations stun_configs;
webrtc::PortAllocatorFactoryInterface::StunConfiguration stun1(
"stun.l.google.com", 19302);
stun_configs.push_back(stun1);
VerifyStunConfigurations(stun_configs);
TurnConfigurations turn_configs;
webrtc::PortAllocatorFactoryInterface::TurnConfiguration turn1(
"test.com", 1234, "test@hello.com", kTurnPassword, "udp", false);
turn_configs.push_back(turn1);
webrtc::PortAllocatorFactoryInterface::TurnConfiguration turn2(
"hello.com", kDefaultStunPort, "test", kTurnPassword, "tcp", false);
turn_configs.push_back(turn2);
VerifyTurnConfigurations(turn_configs);
}
// This test verifies creation of PeerConnection with valid STUN and TURN
// configuration. Also verifies the URL's parsed correctly as expected.
// This version doesn't use RTCConfiguration.
// TODO(mallinath) - Remove this method after clients start using RTCConfig.
TEST_F(PeerConnectionFactoryTest, CreatePCUsingIceServersOldSignature) {
webrtc::PeerConnectionInterface::IceServers ice_servers;
webrtc::PeerConnectionInterface::IceServer ice_server;
ice_server.uri = kStunIceServer;
@ -196,16 +232,16 @@ TEST_F(PeerConnectionFactoryTest, CreatePCUsingIceServers) {
}
TEST_F(PeerConnectionFactoryTest, CreatePCUsingNoUsernameInUri) {
webrtc::PeerConnectionInterface::IceServers ice_servers;
PeerConnectionInterface::RTCConfiguration config;
webrtc::PeerConnectionInterface::IceServer ice_server;
ice_server.uri = kStunIceServer;
ice_servers.push_back(ice_server);
config.servers.push_back(ice_server);
ice_server.uri = kTurnIceServerWithNoUsernameInUri;
ice_server.username = kTurnUsername;
ice_server.password = kTurnPassword;
ice_servers.push_back(ice_server);
config.servers.push_back(ice_server);
talk_base::scoped_refptr<PeerConnectionInterface> pc(
factory_->CreatePeerConnection(ice_servers, NULL,
factory_->CreatePeerConnection(config, NULL,
allocator_factory_.get(),
NULL,
&observer_));
@ -220,13 +256,13 @@ TEST_F(PeerConnectionFactoryTest, CreatePCUsingNoUsernameInUri) {
// This test verifies the PeerConnection created properly with TURN url which
// has transport parameter in it.
TEST_F(PeerConnectionFactoryTest, CreatePCUsingTurnUrlWithTransportParam) {
webrtc::PeerConnectionInterface::IceServers ice_servers;
PeerConnectionInterface::RTCConfiguration config;
webrtc::PeerConnectionInterface::IceServer ice_server;
ice_server.uri = kTurnIceServerWithTransport;
ice_server.password = kTurnPassword;
ice_servers.push_back(ice_server);
config.servers.push_back(ice_server);
talk_base::scoped_refptr<PeerConnectionInterface> pc(
factory_->CreatePeerConnection(ice_servers, NULL,
factory_->CreatePeerConnection(config, NULL,
allocator_factory_.get(),
NULL,
&observer_));
@ -239,19 +275,19 @@ TEST_F(PeerConnectionFactoryTest, CreatePCUsingTurnUrlWithTransportParam) {
}
TEST_F(PeerConnectionFactoryTest, CreatePCUsingSecureTurnUrl) {
webrtc::PeerConnectionInterface::IceServers ice_servers;
PeerConnectionInterface::RTCConfiguration config;
webrtc::PeerConnectionInterface::IceServer ice_server;
ice_server.uri = kSecureTurnIceServer;
ice_server.password = kTurnPassword;
ice_servers.push_back(ice_server);
config.servers.push_back(ice_server);
ice_server.uri = kSecureTurnIceServerWithoutTransportParam;
ice_server.password = kTurnPassword;
ice_servers.push_back(ice_server);
config.servers.push_back(ice_server);
ice_server.uri = kSecureTurnIceServerWithoutTransportAndPortParam;
ice_server.password = kTurnPassword;
ice_servers.push_back(ice_server);
config.servers.push_back(ice_server);
talk_base::scoped_refptr<PeerConnectionInterface> pc(
factory_->CreatePeerConnection(ice_servers, NULL,
factory_->CreatePeerConnection(config, NULL,
allocator_factory_.get(),
NULL,
&observer_));
@ -272,23 +308,23 @@ TEST_F(PeerConnectionFactoryTest, CreatePCUsingSecureTurnUrl) {
}
TEST_F(PeerConnectionFactoryTest, CreatePCUsingIPLiteralAddress) {
webrtc::PeerConnectionInterface::IceServers ice_servers;
PeerConnectionInterface::RTCConfiguration config;
webrtc::PeerConnectionInterface::IceServer ice_server;
ice_server.uri = kStunIceServerWithIPv4Address;
ice_servers.push_back(ice_server);
config.servers.push_back(ice_server);
ice_server.uri = kStunIceServerWithIPv4AddressWithoutPort;
ice_servers.push_back(ice_server);
config.servers.push_back(ice_server);
ice_server.uri = kStunIceServerWithIPv6Address;
ice_servers.push_back(ice_server);
config.servers.push_back(ice_server);
ice_server.uri = kStunIceServerWithIPv6AddressWithoutPort;
ice_servers.push_back(ice_server);
config.servers.push_back(ice_server);
ice_server.uri = kStunIceServerWithInvalidIPv6Address;
ice_servers.push_back(ice_server);
config.servers.push_back(ice_server);
ice_server.uri = kTurnIceServerWithIPv6Address;
ice_server.password = kTurnPassword;
ice_servers.push_back(ice_server);
config.servers.push_back(ice_server);
talk_base::scoped_refptr<PeerConnectionInterface> pc(
factory_->CreatePeerConnection(ice_servers, NULL,
factory_->CreatePeerConnection(config, NULL,
allocator_factory_.get(),
NULL,
&observer_));

View File

@ -166,6 +166,21 @@ class PeerConnectionInterface : public talk_base::RefCountInterface {
};
typedef std::vector<IceServer> IceServers;
enum IceTransportsType {
kNone,
kRelay,
kNoHost,
kAll
};
struct RTCConfiguration {
IceTransportsType type;
IceServers servers;
RTCConfiguration() : type(kAll) {}
explicit RTCConfiguration(IceTransportsType type) : type(type) {}
};
// Used by GetStats to decide which stats to include in the stats reports.
// |kStatsOutputLevelStandard| includes the standard stats for Javascript API;
// |kStatsOutputLevelDebug| includes both the standard stats and additional
@ -412,19 +427,34 @@ class PeerConnectionFactoryInterface : public talk_base::RefCountInterface {
};
virtual void SetOptions(const Options& options) = 0;
virtual talk_base::scoped_refptr<PeerConnectionInterface>
CreatePeerConnection(
const PeerConnectionInterface::IceServers& configuration,
const MediaConstraintsInterface* constraints,
DTLSIdentityServiceInterface* dtls_identity_service,
PeerConnectionObserver* observer) = 0;
virtual talk_base::scoped_refptr<PeerConnectionInterface>
CreatePeerConnection(
const PeerConnectionInterface::RTCConfiguration& configuration,
const MediaConstraintsInterface* constraints,
PortAllocatorFactoryInterface* allocator_factory,
DTLSIdentityServiceInterface* dtls_identity_service,
PeerConnectionObserver* observer) = 0;
// TODO(mallinath) : Remove below versions after clients are updated
// to above method.
// In latest W3C WebRTC draft, PC constructor will take RTCConfiguration,
// and not IceServers. RTCConfiguration is made up of ice servers and
// ice transport type.
// http://dev.w3.org/2011/webrtc/editor/webrtc.html
inline talk_base::scoped_refptr<PeerConnectionInterface>
CreatePeerConnection(
const PeerConnectionInterface::IceServers& configuration,
const MediaConstraintsInterface* constraints,
PortAllocatorFactoryInterface* allocator_factory,
DTLSIdentityServiceInterface* dtls_identity_service,
PeerConnectionObserver* observer) = 0;
PeerConnectionObserver* observer) {
PeerConnectionInterface::RTCConfiguration rtc_config;
rtc_config.servers = configuration;
return CreatePeerConnection(rtc_config, constraints, allocator_factory,
dtls_identity_service, observer);
}
virtual talk_base::scoped_refptr<MediaStreamInterface>
CreateLocalMediaStream(const std::string& label) = 0;

View File

@ -41,6 +41,7 @@
#include "talk/base/helpers.h"
#include "talk/base/logging.h"
#include "talk/base/stringencode.h"
#include "talk/base/stringutils.h"
#include "talk/media/base/constants.h"
#include "talk/media/base/videocapturer.h"
#include "talk/session/media/channel.h"
@ -485,8 +486,9 @@ WebRtcSession::~WebRtcSession() {
bool WebRtcSession::Initialize(
const PeerConnectionFactoryInterface::Options& options,
const MediaConstraintsInterface* constraints,
DTLSIdentityServiceInterface* dtls_identity_service) {
const MediaConstraintsInterface* constraints,
DTLSIdentityServiceInterface* dtls_identity_service,
PeerConnectionInterface::IceTransportsType ice_transport) {
// TODO(perkj): Take |constraints| into consideration. Return false if not all
// mandatory constraints can be fulfilled. Note that |constraints|
// can be null.
@ -923,6 +925,10 @@ bool WebRtcSession::ProcessIceMessage(const IceCandidateInterface* candidate) {
return UseCandidate(candidate);
}
bool WebRtcSession::UpdateIce(PeerConnectionInterface::IceTransportsType type) {
return false;
}
bool WebRtcSession::GetTrackIdBySsrc(uint32 ssrc, std::string* id) {
if (GetLocalTrackId(ssrc, id)) {
if (GetRemoteTrackId(ssrc, id)) {

View File

@ -55,7 +55,9 @@ class VoiceChannel;
} // namespace cricket
namespace webrtc {
class IceRestartAnswerLatch;
class JsepIceCandidate;
class MediaStreamSignaling;
class WebRtcSessionDescriptionFactory;
@ -112,7 +114,8 @@ class WebRtcSession : public cricket::BaseSession,
bool Initialize(const PeerConnectionFactoryInterface::Options& options,
const MediaConstraintsInterface* constraints,
DTLSIdentityServiceInterface* dtls_identity_service);
DTLSIdentityServiceInterface* dtls_identity_service,
PeerConnectionInterface::IceTransportsType ice_transport);
// Deletes the voice, video and data channel and changes the session state
// to STATE_RECEIVEDTERMINATE.
void Terminate();
@ -152,6 +155,9 @@ class WebRtcSession : public cricket::BaseSession,
bool SetRemoteDescription(SessionDescriptionInterface* desc,
std::string* err_desc);
bool ProcessIceMessage(const IceCandidateInterface* ice_candidate);
bool UpdateIce(PeerConnectionInterface::IceTransportsType type);
const SessionDescriptionInterface* local_description() const {
return local_desc_.get();
}

View File

@ -53,6 +53,7 @@
#include "talk/media/devices/fakedevicemanager.h"
#include "talk/p2p/base/stunserver.h"
#include "talk/p2p/base/teststunserver.h"
#include "talk/p2p/base/testturnserver.h"
#include "talk/p2p/client/basicportallocator.h"
#include "talk/session/media/channelmanager.h"
#include "talk/session/media/mediasession.h"
@ -72,6 +73,7 @@ using cricket::NS_JINGLE_ICE_UDP;
using cricket::TransportInfo;
using talk_base::SocketAddress;
using talk_base::scoped_ptr;
using talk_base::Thread;
using webrtc::CreateSessionDescription;
using webrtc::CreateSessionDescriptionObserver;
using webrtc::CreateSessionDescriptionRequest;
@ -101,6 +103,10 @@ static const int kClientAddrPort = 0;
static const char kClientAddrHost1[] = "11.11.11.11";
static const char kClientAddrHost2[] = "22.22.22.22";
static const char kStunAddrHost[] = "99.99.99.1";
static const SocketAddress kTurnUdpIntAddr("99.99.99.4", 3478);
static const SocketAddress kTurnUdpExtAddr("99.99.99.6", 0);
static const char kTurnUsername[] = "test";
static const char kTurnPassword[] = "test";
static const char kSessionVersion[] = "1";
@ -294,16 +300,20 @@ class WebRtcSessionTest : public testing::Test {
ss_scope_(fss_.get()),
stun_socket_addr_(talk_base::SocketAddress(kStunAddrHost,
cricket::STUN_SERVER_PORT)),
stun_server_(talk_base::Thread::Current(), stun_socket_addr_),
allocator_(&network_manager_, stun_socket_addr_,
SocketAddress(), SocketAddress(), SocketAddress()),
mediastream_signaling_(channel_manager_.get()) {
stun_server_(Thread::Current(), stun_socket_addr_),
turn_server_(Thread::Current(), kTurnUdpIntAddr, kTurnUdpExtAddr),
allocator_(new cricket::BasicPortAllocator(
&network_manager_, stun_socket_addr_,
SocketAddress(), SocketAddress(), SocketAddress())),
mediastream_signaling_(channel_manager_.get()),
ice_type_(PeerConnectionInterface::kAll) {
tdesc_factory_->set_protocol(cricket::ICEPROTO_HYBRID);
allocator_.set_flags(cricket::PORTALLOCATOR_DISABLE_TCP |
allocator_->set_flags(cricket::PORTALLOCATOR_DISABLE_TCP |
cricket::PORTALLOCATOR_DISABLE_RELAY |
cricket::PORTALLOCATOR_ENABLE_BUNDLE);
EXPECT_TRUE(channel_manager_->Init());
desc_factory_->set_add_legacy_streams(false);
allocator_->set_step_delay(cricket::kMinimumStepDelay);
}
static void SetUpTestCase() {
@ -318,11 +328,15 @@ class WebRtcSessionTest : public testing::Test {
network_manager_.AddInterface(addr);
}
void SetIceTransportType(PeerConnectionInterface::IceTransportsType type) {
ice_type_ = type;
}
void Init(DTLSIdentityServiceInterface* identity_service) {
ASSERT_TRUE(session_.get() == NULL);
session_.reset(new WebRtcSessionForTest(
channel_manager_.get(), talk_base::Thread::Current(),
talk_base::Thread::Current(), &allocator_,
talk_base::Thread::Current(), allocator_.get(),
&observer_,
&mediastream_signaling_));
@ -332,7 +346,7 @@ class WebRtcSessionTest : public testing::Test {
observer_.ice_gathering_state_);
EXPECT_TRUE(session_->Initialize(options_, constraints_.get(),
identity_service));
identity_service, ice_type_));
}
void InitWithDtmfCodec() {
@ -1009,8 +1023,9 @@ class WebRtcSessionTest : public testing::Test {
talk_base::SocketServerScope ss_scope_;
talk_base::SocketAddress stun_socket_addr_;
cricket::TestStunServer stun_server_;
cricket::TestTurnServer turn_server_;
talk_base::FakeNetworkManager network_manager_;
cricket::BasicPortAllocator allocator_;
talk_base::scoped_ptr<cricket::BasicPortAllocator> allocator_;
PeerConnectionFactoryInterface::Options options_;
talk_base::scoped_ptr<FakeConstraints> constraints_;
FakeMediaStreamSignaling mediastream_signaling_;
@ -1018,6 +1033,7 @@ class WebRtcSessionTest : public testing::Test {
MockIceObserver observer_;
cricket::FakeVideoMediaChannel* video_channel_;
cricket::FakeVoiceMediaChannel* voice_channel_;
PeerConnectionInterface::IceTransportsType ice_type_;
};
TEST_F(WebRtcSessionTest, TestInitializeWithDtls) {
@ -2237,8 +2253,8 @@ TEST_F(WebRtcSessionTest, VerifyBundleFlagInPA) {
// local description is removed by the application, BUNDLE flag should be
// disabled in PortAllocator. By default BUNDLE is enabled in the WebRtc.
Init(NULL);
EXPECT_TRUE((cricket::PORTALLOCATOR_ENABLE_BUNDLE & allocator_.flags()) ==
cricket::PORTALLOCATOR_ENABLE_BUNDLE);
EXPECT_TRUE((cricket::PORTALLOCATOR_ENABLE_BUNDLE &
allocator_->flags()) == cricket::PORTALLOCATOR_ENABLE_BUNDLE);
talk_base::scoped_ptr<SessionDescriptionInterface> offer(
CreateOffer(NULL));
cricket::SessionDescription* offer_copy =
@ -2249,14 +2265,14 @@ TEST_F(WebRtcSessionTest, VerifyBundleFlagInPA) {
modified_offer->Initialize(offer_copy, "1", "1");
SetLocalDescriptionWithoutError(modified_offer);
EXPECT_FALSE(allocator_.flags() & cricket::PORTALLOCATOR_ENABLE_BUNDLE);
EXPECT_FALSE(allocator_->flags() & cricket::PORTALLOCATOR_ENABLE_BUNDLE);
}
TEST_F(WebRtcSessionTest, TestDisabledBundleInAnswer) {
Init(NULL);
mediastream_signaling_.SendAudioVideoStream1();
EXPECT_TRUE((cricket::PORTALLOCATOR_ENABLE_BUNDLE & allocator_.flags()) ==
cricket::PORTALLOCATOR_ENABLE_BUNDLE);
EXPECT_TRUE((cricket::PORTALLOCATOR_ENABLE_BUNDLE &
allocator_->flags()) == cricket::PORTALLOCATOR_ENABLE_BUNDLE);
FakeConstraints constraints;
constraints.SetMandatoryUseRtpMux(true);
SessionDescriptionInterface* offer = CreateOffer(&constraints);
@ -2270,8 +2286,8 @@ TEST_F(WebRtcSessionTest, TestDisabledBundleInAnswer) {
new JsepSessionDescription(JsepSessionDescription::kAnswer);
modified_answer->Initialize(answer_copy, "1", "1");
SetRemoteDescriptionWithoutError(modified_answer);
EXPECT_TRUE((cricket::PORTALLOCATOR_ENABLE_BUNDLE & allocator_.flags()) ==
cricket::PORTALLOCATOR_ENABLE_BUNDLE);
EXPECT_TRUE((cricket::PORTALLOCATOR_ENABLE_BUNDLE &
allocator_->flags()) == cricket::PORTALLOCATOR_ENABLE_BUNDLE);
video_channel_ = media_engine_->GetVideoChannel(0);
voice_channel_ = media_engine_->GetVoiceChannel(0);
@ -2293,8 +2309,8 @@ TEST_F(WebRtcSessionTest, TestDisabledBundleInAnswer) {
TEST_F(WebRtcSessionTest, TestDisabledRtcpMuxWithBundleEnabled) {
WebRtcSessionTest::Init(NULL);
mediastream_signaling_.SendAudioVideoStream1();
EXPECT_TRUE((cricket::PORTALLOCATOR_ENABLE_BUNDLE & allocator_.flags()) ==
cricket::PORTALLOCATOR_ENABLE_BUNDLE);
EXPECT_TRUE((cricket::PORTALLOCATOR_ENABLE_BUNDLE &
allocator_->flags()) == cricket::PORTALLOCATOR_ENABLE_BUNDLE);
FakeConstraints constraints;
constraints.SetMandatoryUseRtpMux(true);
SessionDescriptionInterface* offer = CreateOffer(&constraints);
@ -2816,7 +2832,7 @@ TEST_F(WebRtcSessionTest, TestSessionContentError) {
// Runs the loopback call test with BUNDLE and STUN disabled.
TEST_F(WebRtcSessionTest, TestIceStatesBasic) {
// Lets try with only UDP ports.
allocator_.set_flags(cricket::PORTALLOCATOR_ENABLE_SHARED_UFRAG |
allocator_->set_flags(cricket::PORTALLOCATOR_ENABLE_SHARED_UFRAG |
cricket::PORTALLOCATOR_DISABLE_TCP |
cricket::PORTALLOCATOR_DISABLE_STUN |
cricket::PORTALLOCATOR_DISABLE_RELAY);
@ -2825,7 +2841,7 @@ TEST_F(WebRtcSessionTest, TestIceStatesBasic) {
// Runs the loopback call test with BUNDLE and STUN enabled.
TEST_F(WebRtcSessionTest, TestIceStatesBundle) {
allocator_.set_flags(cricket::PORTALLOCATOR_ENABLE_SHARED_UFRAG |
allocator_->set_flags(cricket::PORTALLOCATOR_ENABLE_SHARED_UFRAG |
cricket::PORTALLOCATOR_ENABLE_BUNDLE |
cricket::PORTALLOCATOR_DISABLE_TCP |
cricket::PORTALLOCATOR_DISABLE_RELAY);