Bug 1027350 - Allow loopback addresses for ICE in signaling unit test. r=bwc

--HG--
extra : rebase_source : 3e73f02aa1c889f331c8326f17bb5e245204b780
This commit is contained in:
EKR 2014-10-03 15:50:40 -07:00
parent d004d664c2
commit a67889b98e
5 changed files with 21 additions and 10 deletions

View File

@ -260,6 +260,7 @@ PeerConnectionImpl::PeerConnectionImpl(const GlobalObject* aGlobal)
, mIdentity(nullptr)
, mPrivacyRequested(false)
, mSTSThread(nullptr)
, mAllowIceLoopback(false)
, mMedia(nullptr)
, mNumAudioStreams(0)
, mNumVideoStreams(0)
@ -609,6 +610,7 @@ PeerConnectionImpl::Initialize(PeerConnectionObserver& aObserver,
}
mMedia = new PeerConnectionMedia(this);
mMedia->SetAllowIceLoopback(mAllowIceLoopback);
// Connect ICE slots.
mMedia->SignalIceGatheringStateChange.connect(

View File

@ -259,6 +259,9 @@ public:
return mMedia;
}
// Configure the ability to use localhost.
void SetAllowIceLoopback(bool val) { mAllowIceLoopback = val; }
// Handle system to allow weak references to be passed through C code
virtual const std::string& GetHandle();
@ -729,6 +732,7 @@ private:
nsRefPtr<mozilla::DataChannelConnection> mDataConnection;
#endif
bool mAllowIceLoopback;
nsRefPtr<PeerConnectionMedia> mMedia;
#ifdef MOZILLA_INTERNAL_API

View File

@ -196,27 +196,26 @@ PeerConnectionImpl* PeerConnectionImpl::CreatePeerConnection()
PeerConnectionMedia::PeerConnectionMedia(PeerConnectionImpl *parent)
: mParent(parent),
mParentHandle(parent->GetHandle()),
mAllowIceLoopback(false),
mIceCtx(nullptr),
mDNSResolver(new mozilla::NrIceResolver()),
mMainThread(mParent->GetMainThread()),
mSTSThread(mParent->GetSTSThread()) {}
mSTSThread(mParent->GetSTSThread()) {
#ifdef MOZILLA_INTERNAL_API
mAllowIceLoopback = Preferences::GetBool(
"media.peerconnection.ice.loopback", false);
#endif
}
nsresult PeerConnectionMedia::Init(const std::vector<NrIceStunServer>& stun_servers,
const std::vector<NrIceTurnServer>& turn_servers)
{
#ifdef MOZILLA_INTERNAL_API
bool allow_loopback = Preferences::GetBool(
"media.peerconnection.ice.loopback", false);
#else
bool allow_loopback = false;
#endif
// TODO(ekr@rtfm.com): need some way to set not offerer later
// Looks like a bug in the NrIceCtx API.
mIceCtx = NrIceCtx::Create("PC:" + mParent->GetName(),
true, // Offerer
true, // Trickle
allow_loopback);
mAllowIceLoopback);
if(!mIceCtx) {
CSFLogError(logTag, "%s: Failed to create Ice Context", __FUNCTION__);
return NS_ERROR_FAILURE;

View File

@ -296,6 +296,9 @@ class PeerConnectionMedia : public sigslot::has_slots<> {
// WARNING: This destroys the object!
void SelfDestruct();
// Configure the ability to use localhost.
void SetAllowIceLoopback(bool val) { mAllowIceLoopback = val; }
mozilla::RefPtr<mozilla::NrIceCtx> ice_ctx() const { return mIceCtx; }
mozilla::RefPtr<mozilla::NrIceMediaStream> ice_media_stream(size_t i) const {
@ -443,6 +446,9 @@ class PeerConnectionMedia : public sigslot::has_slots<> {
// This is only accessed on the main thread (with one special exception)
nsTArray<nsRefPtr<RemoteSourceStreamInfo> > mRemoteSourceStreams;
// Allow loopback for ICE.
bool mAllowIceLoopback;
// ICE objects
mozilla::RefPtr<mozilla::NrIceCtx> mIceCtx;
std::vector<mozilla::RefPtr<mozilla::NrIceMediaStream> > mIceStreams;

View File

@ -947,7 +947,7 @@ class SignalingAgent {
sipcc::PeerConnectionImpl *pcImpl =
sipcc::PeerConnectionImpl::CreatePeerConnection();
EXPECT_TRUE(pcImpl);
pcImpl->SetAllowIceLoopback(true);
pc = new PCDispatchWrapper(pcImpl);
}