#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"
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;
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";
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() {
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_));
observer_.ice_gathering_state_);
EXPECT_TRUE(session_->Initialize(options_, constraints_.get(),
- identity_service));
+ identity_service, ice_type_));
}
void InitWithDtmfCodec() {
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_;
MockIceObserver observer_;
cricket::FakeVideoMediaChannel* video_channel_;
cricket::FakeVoiceMediaChannel* voice_channel_;
+ PeerConnectionInterface::IceTransportsType ice_type_;
};
TEST_F(WebRtcSessionTest, TestInitializeWithDtls) {
// 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 =
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);
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);
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);
answer->session_version()));
SetRemoteDescriptionAnswerExpectError(kMlineMismatch, modified_answer);
- // Modifying content names.
+ // Different content names.
std::string sdp;
EXPECT_TRUE(answer->ToString(&sdp));
const std::string kAudioMid = "a=mid:audio";
const std::string kAudioMidReplaceStr = "a=mid:audio_content_name";
-
- // Replacing |audio| with |audio_content_name|.
talk_base::replace_substrs(kAudioMid.c_str(), kAudioMid.length(),
kAudioMidReplaceStr.c_str(),
kAudioMidReplaceStr.length(),
&sdp);
-
SessionDescriptionInterface* modified_answer1 =
CreateSessionDescription(JsepSessionDescription::kAnswer, sdp, NULL);
SetRemoteDescriptionAnswerExpectError(kMlineMismatch, modified_answer1);
+ // Different media types.
+ EXPECT_TRUE(answer->ToString(&sdp));
+ const std::string kAudioMline = "m=audio";
+ const std::string kAudioMlineReplaceStr = "m=video";
+ talk_base::replace_substrs(kAudioMline.c_str(), kAudioMline.length(),
+ kAudioMlineReplaceStr.c_str(),
+ kAudioMlineReplaceStr.length(),
+ &sdp);
+ SessionDescriptionInterface* modified_answer2 =
+ CreateSessionDescription(JsepSessionDescription::kAnswer, sdp, NULL);
+ SetRemoteDescriptionAnswerExpectError(kMlineMismatch, modified_answer2);
+
SetRemoteDescriptionWithoutError(answer.release());
}
// 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);
// 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);