--- a/media/mtransport/common.build
+++ b/media/mtransport/common.build
@@ -4,16 +4,17 @@
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
mtransport_lcppsrcs = [
'dtlsidentity.cpp',
'nr_socket_prsock.cpp',
'nr_timer.cpp',
'nricectx.cpp',
+ 'nricectxhandler.cpp',
'nricemediastream.cpp',
'nriceresolver.cpp',
'nriceresolverfake.cpp',
'nrinterfaceprioritizer.cpp',
'rlogringbuffer.cpp',
'simpletokenbucket.cpp',
'stun_udp_socket_filter.cpp',
'test_nr_socket.cpp',
--- a/media/mtransport/nricectx.cpp
+++ b/media/mtransport/nricectx.cpp
@@ -371,25 +371,21 @@ void NrIceCtx::trickle_cb(void *arg, nr_
return;
MOZ_MTLOG(ML_INFO, "NrIceCtx(" << ctx->name_ << "): trickling candidate "
<< candidate_str);
s->SignalCandidate(s, candidate_str);
}
-RefPtr<NrIceCtx> NrIceCtx::Create(const std::string& name,
- bool offerer,
- bool allow_loopback,
- bool tcp_enabled,
- bool allow_link_local,
- bool hide_non_default,
- Policy policy) {
- RefPtr<NrIceCtx> ctx = new NrIceCtx(name, offerer, policy);
+void
+NrIceCtx::InitializeCryptoAndLogging(bool allow_loopback,
+ bool tcp_enabled,
+ bool allow_link_local) {
// Initialize the crypto callbacks and logging stuff
if (!initialized) {
NR_reg_init(NR_REG_MODE_LOCAL);
RLogRingBuffer::CreateInstance();
nr_crypto_vtbl = &nr_ice_crypto_nss_vtbl;
initialized = true;
// Set the priorites for candidate type preferences.
@@ -453,54 +449,60 @@ RefPtr<NrIceCtx> NrIceCtx::Create(const
NR_reg_set_char((char *)NR_STUN_REG_PREF_ALLOW_LINK_LOCAL_ADDRS, 1);
}
if (force_net_interface.Length() > 0) {
// Stupid cast.... but needed
const nsCString& flat = PromiseFlatCString(static_cast<nsACString&>(force_net_interface));
NR_reg_set_string((char *)NR_ICE_REG_PREF_FORCE_INTERFACE_NAME, const_cast<char*>(flat.get()));
}
}
+}
+bool
+NrIceCtx::Initialize(NrIceCtx* ctx,
+ bool hide_non_default)
+{
// Create the ICE context
int r;
- UINT4 flags = offerer ? NR_ICE_CTX_FLAGS_OFFERER:
+ UINT4 flags = ctx->offerer_ ? NR_ICE_CTX_FLAGS_OFFERER:
NR_ICE_CTX_FLAGS_ANSWERER;
flags |= NR_ICE_CTX_FLAGS_AGGRESSIVE_NOMINATION;
- if (policy == ICE_POLICY_RELAY) {
+ if (ctx->policy_ == ICE_POLICY_RELAY) {
flags |= NR_ICE_CTX_FLAGS_RELAY_ONLY;
}
if (hide_non_default)
flags |= NR_ICE_CTX_FLAGS_ONLY_DEFAULT_ADDRS;
- r = nr_ice_ctx_create(const_cast<char *>(name.c_str()), flags,
+ r = nr_ice_ctx_create(const_cast<char *>(ctx->name_.c_str()),
+ flags,
&ctx->ctx_);
if (r) {
- MOZ_MTLOG(ML_ERROR, "Couldn't create ICE ctx for '" << name << "'");
- return nullptr;
+ MOZ_MTLOG(ML_ERROR, "Couldn't create ICE ctx for '" << ctx->name_ << "'");
+ return false;
}
nr_interface_prioritizer *prioritizer = CreateInterfacePrioritizer();
if (!prioritizer) {
MOZ_MTLOG(LogLevel::Error, "Couldn't create interface prioritizer.");
- return nullptr;
+ return false;
}
r = nr_ice_ctx_set_interface_prioritizer(ctx->ctx_, prioritizer);
if (r) {
MOZ_MTLOG(LogLevel::Error, "Couldn't set interface prioritizer.");
- return nullptr;
+ return false;
}
if (ctx->generating_trickle()) {
r = nr_ice_ctx_set_trickle_cb(ctx->ctx_, &NrIceCtx::trickle_cb, ctx);
if (r) {
- MOZ_MTLOG(ML_ERROR, "Couldn't set trickle cb for '" << name << "'");
- return nullptr;
+ MOZ_MTLOG(ML_ERROR, "Couldn't set trickle cb for '" << ctx->name_ << "'");
+ return false;
}
}
// Create the handler objects
ctx->ice_handler_vtbl_ = new nr_ice_handler_vtbl();
ctx->ice_handler_vtbl_->select_pair = &NrIceCtx::select_pair;
ctx->ice_handler_vtbl_->stream_ready = &NrIceCtx::stream_ready;
ctx->ice_handler_vtbl_->stream_failed = &NrIceCtx::stream_failed;
@@ -509,32 +511,32 @@ RefPtr<NrIceCtx> NrIceCtx::Create(const
ctx->ice_handler_vtbl_->ice_checking = &NrIceCtx::ice_checking;
ctx->ice_handler_ = new nr_ice_handler();
ctx->ice_handler_->vtbl = ctx->ice_handler_vtbl_;
ctx->ice_handler_->obj = ctx;
// Create the peer ctx. Because we do not support parallel forking, we
// only have one peer ctx.
- std::string peer_name = name + ":default";
+ std::string peer_name = ctx->name_ + ":default";
r = nr_ice_peer_ctx_create(ctx->ctx_, ctx->ice_handler_,
const_cast<char *>(peer_name.c_str()),
&ctx->peer_);
if (r) {
- MOZ_MTLOG(ML_ERROR, "Couldn't create ICE peer ctx for '" << name << "'");
- return nullptr;
+ MOZ_MTLOG(ML_ERROR, "Couldn't create ICE peer ctx for '" << ctx->name_ << "'");
+ return false;
}
nsresult rv;
ctx->sts_target_ = do_GetService(NS_SOCKETTRANSPORTSERVICE_CONTRACTID, &rv);
if (!NS_SUCCEEDED(rv))
- return nullptr;
+ return false;
- return ctx;
+ return true;
}
// ONLY USE THIS FOR TESTING. Will cause totally unpredictable and possibly very
// bad effects if ICE is still live.
void NrIceCtx::internal_DeinitializeGlobal() {
NR_reg_del((char *)"stun");
NR_reg_del((char *)"ice");
RLogRingBuffer::DestroyInstance();
@@ -545,21 +547,16 @@ void NrIceCtx::internal_DeinitializeGlob
NrIceCtx::~NrIceCtx() {
MOZ_MTLOG(ML_DEBUG, "Destroying ICE ctx '" << name_ <<"'");
nr_ice_peer_ctx_destroy(&peer_);
nr_ice_ctx_destroy(&ctx_);
delete ice_handler_vtbl_;
delete ice_handler_;
}
-RefPtr<NrIceMediaStream>
-NrIceCtx::CreateStream(const std::string& name, int components) {
- return NrIceMediaStream::Create(this, name, components);
-}
-
void
NrIceCtx::SetStream(size_t index, NrIceMediaStream* stream) {
if (index >= streams_.size()) {
streams_.resize(index + 1);
}
RefPtr<NrIceMediaStream> oldStream(streams_[index]);
streams_[index] = stream;
--- a/media/mtransport/nricectx.h
+++ b/media/mtransport/nricectx.h
@@ -209,39 +209,33 @@ class NrIceCtx {
ICE_CONTROLLED
};
enum Policy { ICE_POLICY_NONE,
ICE_POLICY_RELAY,
ICE_POLICY_ALL
};
- // TODO(ekr@rtfm.com): Too many bools here. Bug 1193437.
- static RefPtr<NrIceCtx> Create(const std::string& name,
- bool offerer,
- bool allow_loopback = false,
- bool tcp_enabled = true,
- bool allow_link_local = false,
- bool hide_non_default = false,
- Policy policy = ICE_POLICY_ALL);
+ static void InitializeCryptoAndLogging(bool allow_loopback,
+ bool tcp_enabled,
+ bool allow_link_local);
+
+ static bool Initialize(NrIceCtx* ice_ctx,
+ bool hide_non_default);
// Deinitialize all ICE global state. Used only for testing.
static void internal_DeinitializeGlobal();
nr_ice_ctx *ctx() { return ctx_; }
nr_ice_peer_ctx *peer() { return peer_; }
// Testing only.
void destroy_peer_ctx();
- // Create a media stream
- RefPtr<NrIceMediaStream> CreateStream(const std::string& name,
- int components);
-
void SetStream(size_t index, NrIceMediaStream* stream);
RefPtr<NrIceMediaStream> GetStream(size_t index) {
if (index < streams_.size()) {
return streams_[index];
}
return nullptr;
}
@@ -324,17 +318,19 @@ class NrIceCtx {
sigslot::signal2<NrIceCtx*, NrIceCtx::ConnectionState>
SignalConnectionStateChange;
// The thread to direct method calls to
nsCOMPtr<nsIEventTarget> thread() { return sts_target_; }
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(NrIceCtx)
- private:
+ protected:
+ virtual ~NrIceCtx();
+
NrIceCtx(const std::string& name,
bool offerer,
Policy policy)
: connection_state_(ICE_CTX_INIT),
gathering_state_(ICE_CTX_GATHER_INIT),
name_(name),
offerer_(offerer),
streams_(),
@@ -343,18 +339,17 @@ class NrIceCtx {
ice_handler_vtbl_(nullptr),
ice_handler_(nullptr),
trickle_(true),
policy_(policy) {
// XXX: offerer_ will be used eventually; placate clang in the meantime.
(void)offerer_;
}
- virtual ~NrIceCtx();
-
+ private:
DISALLOW_COPY_ASSIGN(NrIceCtx);
// Callbacks for nICEr
static void gather_cb(NR_SOCKET s, int h, void *arg); // ICE gather complete
// Handler implementation
static int select_pair(void *obj,nr_ice_media_stream *stream,
int component_id, nr_ice_cand_pair **potentials,
@@ -373,16 +368,17 @@ class NrIceCtx {
RefPtr<NrIceMediaStream> FindStream(nr_ice_media_stream *stream);
// Set the state
void SetConnectionState(ConnectionState state);
// Set the state
void SetGatheringState(GatheringState state);
+protected:
ConnectionState connection_state_;
GatheringState gathering_state_;
const std::string name_;
bool offerer_;
std::vector<RefPtr<NrIceMediaStream> > streams_;
nr_ice_ctx *ctx_;
nr_ice_peer_ctx *peer_;
nr_ice_handler_vtbl* ice_handler_vtbl_; // Must be pointer
new file mode 100644
--- /dev/null
+++ b/media/mtransport/nricectxhandler.cpp
@@ -0,0 +1,52 @@
+#include <sstream>
+
+// nICEr includes
+extern "C" {
+#include "nr_api.h"
+#include "ice_ctx.h"
+}
+
+// Local includes
+#include "nricectxhandler.h"
+#include "nricemediastream.h"
+
+namespace mozilla {
+
+NrIceCtxHandler::~NrIceCtxHandler()
+{
+}
+
+
+RefPtr<NrIceCtxHandler>
+NrIceCtxHandler::Create(const std::string& name,
+ bool offerer,
+ bool allow_loopback,
+ bool tcp_enabled,
+ bool allow_link_local,
+ bool hide_non_default,
+ Policy policy)
+{
+ // InitializeCryptoAndLogging only executes once
+ NrIceCtx::InitializeCryptoAndLogging(allow_loopback,
+ tcp_enabled,
+ allow_link_local);
+
+ RefPtr<NrIceCtxHandler> ctx = new NrIceCtxHandler(name, offerer, policy);
+
+ if (!NrIceCtx::Initialize(ctx,
+ hide_non_default)) {
+ return nullptr;
+ }
+
+ return ctx;
+}
+
+
+RefPtr<NrIceMediaStream>
+NrIceCtxHandler::CreateStream(const std::string& name, int components)
+{
+ return NrIceMediaStream::Create(this, name, components);
+}
+
+
+} // close namespace
new file mode 100644
--- /dev/null
+++ b/media/mtransport/nricectxhandler.h
@@ -0,0 +1,36 @@
+#ifndef nricectxhandler_h__
+#define nricectxhandler_h__
+
+#include "nricectx.h"
+
+namespace mozilla {
+
+class NrIceCtxHandler : public NrIceCtx {
+public:
+ // TODO(ekr@rtfm.com): Too many bools here. Bug 1193437.
+ static RefPtr<NrIceCtxHandler> Create(const std::string& name,
+ bool offerer,
+ bool allow_loopback = false,
+ bool tcp_enabled = true,
+ bool allow_link_local = false,
+ bool hide_non_default = false,
+ Policy policy = ICE_POLICY_ALL);
+
+ // Create a media stream
+ RefPtr<NrIceMediaStream> CreateStream(const std::string& name,
+ int components);
+
+protected:
+ NrIceCtxHandler(const std::string& name,
+ bool offerer,
+ Policy policy)
+ : NrIceCtx(name, offerer, policy)
+ {}
+
+ NrIceCtxHandler(); // disable
+ virtual ~NrIceCtxHandler();
+};
+
+} // close namespace
+
+#endif // nricectxhandler_h__
--- a/media/mtransport/nricemediastream.cpp
+++ b/media/mtransport/nricemediastream.cpp
@@ -180,29 +180,44 @@ static NrIceCandidate* MakeNrIceCandidat
// NrIceMediaStream
RefPtr<NrIceMediaStream>
NrIceMediaStream::Create(NrIceCtx *ctx,
const std::string& name,
int components) {
RefPtr<NrIceMediaStream> stream =
new NrIceMediaStream(ctx, name, components);
+ MOZ_ASSERT(stream->ctx_ == ctx->ctx());
int r = nr_ice_add_media_stream(ctx->ctx(),
const_cast<char *>(name.c_str()),
components, &stream->stream_);
if (r) {
MOZ_MTLOG(ML_ERROR, "Couldn't create ICE media stream for '"
<< name << "'");
return nullptr;
}
return stream;
}
+NrIceMediaStream::NrIceMediaStream(NrIceCtx *ctx,
+ const std::string& name,
+ size_t components) :
+ state_(ICE_CONNECTING),
+ ctx_(ctx->ctx()),
+ ctx_peer_(ctx->peer()),
+ name_(name),
+ components_(components),
+ stream_(nullptr),
+ level_(0),
+ has_parsed_attrs_(false)
+{
+}
+
NrIceMediaStream::~NrIceMediaStream() {
// We do not need to destroy anything. All major resources
// are attached to the ice ctx.
}
nsresult NrIceMediaStream::ParseAttributes(std::vector<std::string>&
attributes) {
if (!stream_)
@@ -210,17 +225,17 @@ nsresult NrIceMediaStream::ParseAttribut
std::vector<char *> attributes_in;
for (size_t i=0; i<attributes.size(); ++i) {
attributes_in.push_back(const_cast<char *>(attributes[i].c_str()));
}
// Still need to call nr_ice_ctx_parse_stream_attributes.
- int r = nr_ice_peer_ctx_parse_stream_attributes(ctx_->peer(),
+ int r = nr_ice_peer_ctx_parse_stream_attributes(ctx_peer_,
stream_,
attributes_in.size() ?
&attributes_in[0] : nullptr,
attributes_in.size());
if (r) {
MOZ_MTLOG(ML_ERROR, "Couldn't parse attributes for stream "
<< name_ << "'");
return NS_ERROR_FAILURE;
@@ -229,20 +244,20 @@ nsresult NrIceMediaStream::ParseAttribut
has_parsed_attrs_ = true;
return NS_OK;
}
// Parse trickle ICE candidate
nsresult NrIceMediaStream::ParseTrickleCandidate(const std::string& candidate) {
int r;
- MOZ_MTLOG(ML_DEBUG, "NrIceCtx(" << ctx_->name() << ")/STREAM(" <<
+ MOZ_MTLOG(ML_DEBUG, "NrIceCtx(" << ctx_->label << ")/STREAM(" <<
name() << ") : parsing trickle candidate " << candidate);
- r = nr_ice_peer_ctx_parse_trickle_candidate(ctx_->peer(),
+ r = nr_ice_peer_ctx_parse_trickle_candidate(ctx_peer_,
stream_,
const_cast<char *>(
candidate.c_str())
);
if (r) {
if (r == R_ALREADY) {
MOZ_MTLOG(ML_ERROR, "Trickle candidates are redundant for stream '"
<< name_ << "' because it is completed");
@@ -264,17 +279,17 @@ nsresult NrIceMediaStream::GetActivePair
int r;
nr_ice_candidate *local_int;
nr_ice_candidate *remote_int;
if (!stream_) {
return NS_ERROR_NOT_AVAILABLE;
}
- r = nr_ice_media_stream_get_active(ctx_->peer(),
+ r = nr_ice_media_stream_get_active(ctx_peer_,
stream_,
component,
&local_int, &remote_int);
// If result is R_REJECTED then component is unpaired or disabled.
if (r == R_REJECTED)
return NS_ERROR_NOT_AVAILABLE;
if (r)
@@ -302,24 +317,24 @@ nsresult NrIceMediaStream::GetActivePair
nsresult NrIceMediaStream::GetCandidatePairs(std::vector<NrIceCandidatePair>*
out_pairs) const {
MOZ_ASSERT(out_pairs);
if (!stream_) {
return NS_ERROR_NOT_AVAILABLE;
}
// If we haven't at least started checking then there is nothing to report
- if (ctx_->peer()->state != NR_ICE_PEER_STATE_PAIRED) {
+ if (ctx_peer_->state != NR_ICE_PEER_STATE_PAIRED) {
return NS_OK;
}
// Get the check_list on the peer stream (this is where the check_list
// actually lives, not in stream_)
nr_ice_media_stream* peer_stream;
- int r = nr_ice_peer_ctx_find_pstream(ctx_->peer(), stream_, &peer_stream);
+ int r = nr_ice_peer_ctx_find_pstream(ctx_peer_, stream_, &peer_stream);
if (r != 0) {
return NS_ERROR_FAILURE;
}
nr_ice_cand_pair *p1, *p2;
out_pairs->clear();
TAILQ_FOREACH(p1, &peer_stream->check_list, check_queue_entry) {
@@ -484,22 +499,22 @@ nsresult NrIceMediaStream::GetLocalCandi
nsresult NrIceMediaStream::GetRemoteCandidates(
std::vector<NrIceCandidate>* candidates) const {
if (!stream_) {
return NS_ERROR_NOT_AVAILABLE;
}
// If we haven't at least started checking then there is nothing to report
- if (ctx_->peer()->state != NR_ICE_PEER_STATE_PAIRED) {
+ if (ctx_peer_->state != NR_ICE_PEER_STATE_PAIRED) {
return NS_OK;
}
nr_ice_media_stream* peer_stream;
- int r = nr_ice_peer_ctx_find_pstream(ctx_->peer(), stream_, &peer_stream);
+ int r = nr_ice_peer_ctx_find_pstream(ctx_peer_, stream_, &peer_stream);
if (r != 0) {
return NS_ERROR_FAILURE;
}
return GetCandidatesFromStream(peer_stream, candidates);
}
@@ -519,17 +534,17 @@ nsresult NrIceMediaStream::DisableCompon
}
nsresult NrIceMediaStream::SendPacket(int component_id,
const unsigned char *data,
size_t len) {
if (!stream_)
return NS_ERROR_FAILURE;
- int r = nr_ice_media_stream_send(ctx_->peer(), stream_,
+ int r = nr_ice_media_stream_send(ctx_peer_, stream_,
component_id,
const_cast<unsigned char *>(data), len);
if (r) {
MOZ_MTLOG(ML_ERROR, "Couldn't send media on '" << name_ << "'");
if (r == R_WOULDBLOCK) {
return NS_BASE_STREAM_WOULD_BLOCK;
}
@@ -552,15 +567,15 @@ void NrIceMediaStream::Ready() {
MOZ_MTLOG(ML_DEBUG, "Stream ready callback fired again for '" << name_ << "'");
}
}
void NrIceMediaStream::Close() {
MOZ_MTLOG(ML_DEBUG, "Marking stream closed '" << name_ << "'");
state_ = ICE_CLOSED;
- int r = nr_ice_remove_media_stream(ctx_->ctx(), &stream_);
+ int r = nr_ice_remove_media_stream(ctx_, &stream_);
if (r) {
MOZ_ASSERT(false, "Failed to remove stream");
MOZ_MTLOG(ML_ERROR, "Failed to remove stream, error=" << r);
}
}
} // close namespace
--- a/media/mtransport/nricemediastream.h
+++ b/media/mtransport/nricemediastream.h
@@ -55,16 +55,18 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE
#include "nsIEventTarget.h"
#include "nsITimer.h"
#include "m_cpp_utils.h"
namespace mozilla {
+typedef struct nr_ice_ctx_ nr_ice_ctx;
+typedef struct nr_ice_peer_ctx_ nr_ice_peer_ctx;
typedef struct nr_ice_media_stream_ nr_ice_media_stream;
class NrIceCtx;
struct NrIceAddr {
std::string host;
uint16_t port;
std::string transport;
@@ -193,32 +195,27 @@ class NrIceMediaStream {
sigslot::signal1<NrIceMediaStream *> SignalReady; // Candidate pair ready.
sigslot::signal1<NrIceMediaStream *> SignalFailed; // Candidate pair failed.
sigslot::signal4<NrIceMediaStream *, int, const unsigned char *, int>
SignalPacketReceived; // Incoming packet
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(NrIceMediaStream)
private:
- NrIceMediaStream(NrIceCtx *ctx, const std::string& name,
- size_t components) :
- state_(ICE_CONNECTING),
- ctx_(ctx),
- name_(name),
- components_(components),
- stream_(nullptr),
- level_(0),
- has_parsed_attrs_(false) {}
+ NrIceMediaStream(NrIceCtx *ctx,
+ const std::string& name,
+ size_t components);
~NrIceMediaStream();
DISALLOW_COPY_ASSIGN(NrIceMediaStream);
State state_;
- NrIceCtx *ctx_;
+ nr_ice_ctx *ctx_;
+ nr_ice_peer_ctx *ctx_peer_;
const std::string name_;
const size_t components_;
nr_ice_media_stream *stream_;
uint16_t level_;
bool has_parsed_attrs_;
};
--- a/media/mtransport/test/ice_unittest.cpp
+++ b/media/mtransport/test/ice_unittest.cpp
@@ -20,17 +20,17 @@
#include "nspr.h"
#include "nss.h"
#include "ssl.h"
#include "mozilla/Scoped.h"
#include "nsThreadUtils.h"
#include "nsXPCOM.h"
-#include "nricectx.h"
+#include "nricectxhandler.h"
#include "nricemediastream.h"
#include "nriceresolverfake.h"
#include "nriceresolver.h"
#include "nrinterfaceprioritizer.h"
#include "mtransport_test_utils.h"
#include "gtest_ringbuffer_dumper.h"
#include "rlogringbuffer.h"
#include "runnable_utils.h"
@@ -283,18 +283,18 @@ class SchedulableTrickleCandidate {
class IceTestPeer : public sigslot::has_slots<> {
public:
// TODO(ekr@rtfm.com): Convert to flags when NrIceCtx::Create() does.
// Bug 1193437.
IceTestPeer(const std::string& name, bool offerer,
bool allow_loopback = false, bool enable_tcp = true,
bool allow_link_local = false, bool hide_non_default = false) :
name_(name),
- ice_ctx_(NrIceCtx::Create(name, offerer, allow_loopback,
- enable_tcp, allow_link_local, hide_non_default)),
+ ice_ctx_(NrIceCtxHandler::Create(name, offerer, allow_loopback,
+ enable_tcp, allow_link_local, hide_non_default)),
candidates_(),
gathering_complete_(false),
ready_ct_(0),
ice_complete_(false),
ice_reached_checking_(false),
received_(0),
sent_(0),
fake_resolver_(),
@@ -1161,17 +1161,17 @@ class IceTestPeer : public sigslot::has_
}
nsresult GetDefaultCandidate_s(unsigned int stream, NrIceCandidate* cand) {
return ice_ctx_->GetStream(stream)->GetDefaultCandidate(1, cand);
}
private:
std::string name_;
- RefPtr<NrIceCtx> ice_ctx_;
+ RefPtr<NrIceCtxHandler> ice_ctx_;
std::map<std::string, std::vector<std::string> > candidates_;
// Maps from stream id to list of remote trickle candidates
std::map<size_t, std::vector<SchedulableTrickleCandidate*> >
controlled_trickle_candidates_;
bool gathering_complete_;
int ready_ct_;
bool ice_complete_;
bool ice_reached_checking_;
@@ -1733,17 +1733,17 @@ class PrioritizerTest : public ::testing
};
class PacketFilterTest : public ::testing::Test {
public:
PacketFilterTest(): filter_(nullptr) {}
void SetUp() {
// Set up enough of the ICE ctx to allow the packet filter to work
- ice_ctx_ = NrIceCtx::Create("test", true);
+ ice_ctx_ = NrIceCtxHandler::Create("test", true);
nsCOMPtr<nsIUDPSocketFilterHandler> handler =
do_GetService(NS_STUN_UDP_SOCKET_FILTER_HANDLER_CONTRACTID);
handler->NewFilter(getter_AddRefs(filter_));
}
void TearDown() {
test_utils->sts_target()->Dispatch(WrapRunnable(this,
@@ -1785,17 +1785,17 @@ class PacketFilterTest : public ::testin
void MakeNetAddr(mozilla::net::NetAddr* net_addr,
uint8_t last_digit, uint16_t port) {
net_addr->inet.family = AF_INET;
net_addr->inet.ip = 192 << 24 | 168 << 16 | 1 << 8 | last_digit;
net_addr->inet.port = port;
}
nsCOMPtr<nsIUDPSocketFilter> filter_;
- RefPtr<NrIceCtx> ice_ctx_;
+ RefPtr<NrIceCtxHandler> ice_ctx_;
};
} // end namespace
TEST_F(IceGatherTest, TestGatherFakeStunServerHostnameNoResolver) {
if (g_stun_server_hostname.empty()) {
return;
}
--- a/media/mtransport/test/multi_tcp_socket_unittest.cpp
+++ b/media/mtransport/test/multi_tcp_socket_unittest.cpp
@@ -26,34 +26,34 @@ extern "C" {
#include "nr_socket_prsock.h"
#include "stunserver.h"
// TODO(bcampen@mozilla.com): Big fat hack since the build system doesn't give
// us a clean way to add object files to a single executable.
#include "stunserver.cpp"
-#include "nricectx.h"
+#include "nricectxhandler.h"
#include "nricemediastream.h"
#define GTEST_HAS_RTTI 0
#include "gtest/gtest.h"
#include "gtest_utils.h"
using namespace mozilla;
MtransportTestUtils *test_utils;
namespace {
class MultiTcpSocketTest : public ::testing::Test {
public:
MultiTcpSocketTest()
:socks(3,nullptr),
readable(false),
- ice_ctx_(NrIceCtx::Create("stun", true))
+ ice_ctx_(NrIceCtxHandler::Create("stun", true))
{}
~MultiTcpSocketTest() {
test_utils->sts_target()->Dispatch(
WrapRunnable(
this, &MultiTcpSocketTest::Shutdown_s),
NS_DISPATCH_SYNC);
}
--- a/media/mtransport/test/transport_unittests.cpp
+++ b/media/mtransport/test/transport_unittests.cpp
@@ -21,17 +21,17 @@
#include "ssl.h"
#include "sslproto.h"
#include "nsThreadUtils.h"
#include "nsXPCOM.h"
#include "databuffer.h"
#include "dtlsidentity.h"
-#include "nricectx.h"
+#include "nricectxhandler.h"
#include "nricemediastream.h"
#include "transportflow.h"
#include "transportlayer.h"
#include "transportlayerdtls.h"
#include "transportlayerice.h"
#include "transportlayerlog.h"
#include "transportlayerloopback.h"
@@ -441,20 +441,20 @@ class TransportTestPeer : public sigslot
TransportTestPeer(nsCOMPtr<nsIEventTarget> target, std::string name)
: name_(name), target_(target),
received_(0), flow_(new TransportFlow(name)),
loopback_(new TransportLayerLoopback()),
logging_(new TransportLayerLogging()),
lossy_(new TransportLayerLossy()),
dtls_(new TransportLayerDtls()),
identity_(DtlsIdentity::Generate()),
- ice_ctx_(NrIceCtx::Create(name,
- name == "P2" ?
- TransportLayerDtls::CLIENT :
- TransportLayerDtls::SERVER)),
+ ice_ctx_(NrIceCtxHandler::Create(name,
+ name == "P2" ?
+ TransportLayerDtls::CLIENT :
+ TransportLayerDtls::SERVER)),
streams_(), candidates_(),
peer_(nullptr),
gathering_complete_(false),
enabled_cipersuites_(),
disabled_cipersuites_(),
reuse_dhe_key_(false) {
std::vector<NrIceStunServer> stun_servers;
UniquePtr<NrIceStunServer> server(NrIceStunServer::Create(
@@ -801,17 +801,17 @@ class TransportTestPeer : public sigslot
size_t received_;
RefPtr<TransportFlow> flow_;
TransportLayerLoopback *loopback_;
TransportLayerLogging *logging_;
TransportLayerLossy *lossy_;
TransportLayerDtls *dtls_;
TransportLayerIce *ice_;
RefPtr<DtlsIdentity> identity_;
- RefPtr<NrIceCtx> ice_ctx_;
+ RefPtr<NrIceCtxHandler> ice_ctx_;
std::vector<RefPtr<NrIceMediaStream> > streams_;
std::map<std::string, std::vector<std::string> > candidates_;
TransportTestPeer *peer_;
bool gathering_complete_;
unsigned char fingerprint_[TransportLayerDtls::kMaxDigestLength];
size_t fingerprint_len_;
std::vector<uint16_t> enabled_cipersuites_;
std::vector<uint16_t> disabled_cipersuites_;
--- a/media/mtransport/test/turn_unittest.cpp
+++ b/media/mtransport/test/turn_unittest.cpp
@@ -74,17 +74,17 @@ extern "C" {
#include "nr_socket.h"
#include "nr_socket_local.h"
#include "nr_socket_buffered_stun.h"
#include "stun_client_ctx.h"
#include "turn_client_ctx.h"
}
#include "nricemediastream.h"
-#include "nricectx.h"
+#include "nricectxhandler.h"
MtransportTestUtils *test_utils;
using namespace mozilla;
std::string g_turn_server;
std::string g_turn_user;
@@ -498,17 +498,17 @@ int main(int argc, char **argv)
test_utils = new MtransportTestUtils();
NSS_NoDB_Init(nullptr);
NSS_SetDomesticPolicy();
// Set up the ICE registry, etc.
// TODO(ekr@rtfm.com): Clean up
std::string dummy("dummy");
RUN_ON_THREAD(test_utils->sts_target(),
- WrapRunnableNM(&NrIceCtx::Create,
+ WrapRunnableNM(&NrIceCtxHandler::Create,
dummy, false, false, false, false, false,
NrIceCtx::ICE_POLICY_ALL),
NS_DISPATCH_SYNC);
// Start the tests
::testing::InitGoogleTest(&argc, argv);
int rv = RUN_ALL_TESTS();
--- a/media/webrtc/signaling/src/peerconnection/PeerConnectionMedia.cpp
+++ b/media/webrtc/signaling/src/peerconnection/PeerConnectionMedia.cpp
@@ -319,23 +319,23 @@ nsresult PeerConnectionMedia::Init(const
#else
bool ice_tcp = false;
bool default_address_only = 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:" + mParentName,
- true, // Offerer
- mParent->GetAllowIceLoopback(),
- ice_tcp,
- mParent->GetAllowIceLinkLocal(),
- default_address_only,
- policy);
+ mIceCtx = NrIceCtxHandler::Create("PC:" + mParentName,
+ true, // Offerer
+ mParent->GetAllowIceLoopback(),
+ ice_tcp,
+ mParent->GetAllowIceLinkLocal(),
+ default_address_only,
+ policy);
if(!mIceCtx) {
CSFLogError(logTag, "%s: Failed to create Ice Context", __FUNCTION__);
return NS_ERROR_FAILURE;
}
if (NS_FAILED(rv = mIceCtx->SetStunServers(stun_servers))) {
CSFLogError(logTag, "%s: Failed to set stun servers", __FUNCTION__);
return rv;
--- a/media/webrtc/signaling/src/peerconnection/PeerConnectionMedia.h
+++ b/media/webrtc/signaling/src/peerconnection/PeerConnectionMedia.h
@@ -44,17 +44,17 @@ class DataChannel;
class PeerIdentity;
class MediaPipelineFactory;
namespace dom {
struct RTCInboundRTPStreamStats;
struct RTCOutboundRTPStreamStats;
}
}
-#include "nricectx.h"
+#include "nricectxhandler.h"
#include "nriceresolver.h"
#include "nricemediastream.h"
#include "MediaPipeline.h"
namespace mozilla {
class PeerConnectionImpl;
class PeerConnectionMedia;
@@ -228,17 +228,17 @@ class PeerConnectionMedia : public sigsl
PeerConnectionImpl* GetPC() { return mParent; }
nsresult Init(const std::vector<NrIceStunServer>& stun_servers,
const std::vector<NrIceTurnServer>& turn_servers,
NrIceCtx::Policy policy);
// WARNING: This destroys the object!
void SelfDestruct();
- RefPtr<NrIceCtx> ice_ctx() const { return mIceCtx; }
+ RefPtr<NrIceCtxHandler> ice_ctx() const { return mIceCtx; }
RefPtr<NrIceMediaStream> ice_media_stream(size_t i) const {
return mIceCtx->GetStream(i);
}
size_t num_ice_media_streams() const {
return mIceCtx->GetStreamCount();
}
@@ -495,17 +495,17 @@ class PeerConnectionMedia : public sigsl
// A list of streams provided by the other side
// This is only accessed on the main thread (with one special exception)
nsTArray<RefPtr<RemoteSourceStreamInfo> > mRemoteSourceStreams;
std::map<size_t, std::pair<bool, RefPtr<MediaSessionConduit>>> mConduits;
// ICE objects
- RefPtr<NrIceCtx> mIceCtx;
+ RefPtr<NrIceCtxHandler> mIceCtx;
// DNS
RefPtr<NrIceResolver> mDNSResolver;
// Transport flows: even is RTP, odd is RTCP
std::map<int, RefPtr<TransportFlow> > mTransportFlows;
// UUID Generator