Bug 1239870 - Part 2: Split out NrIceCtx initialization. r=bwc
☠☠ backed out by 22424f6eeb30 ☠ ☠
authorEric Rahm <erahm@mozilla.com>
Wed, 24 Feb 2016 18:37:18 -0800
changeset 324137 ba077a3afbc702e15fe5a727dc00aabfc4f1becc
parent 324136 eb99ab06414dd713fb54f428c54d1a958cdd32ac
child 324138 8574075bf42f47cde9692541b5e345ff6844c073
push id1128
push userjlund@mozilla.com
push dateWed, 01 Jun 2016 01:31:59 +0000
treeherdermozilla-release@fe0d30de989d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbwc
bugs1239870
milestone47.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1239870 - Part 2: Split out NrIceCtx initialization. r=bwc This splits NrIceCtx initialization into its own function so that the tests can initialize without having to create a dummy instance.
media/mtransport/nricectx.cpp
media/mtransport/nricectx.h
--- a/media/mtransport/nricectx.cpp
+++ b/media/mtransport/nricectx.cpp
@@ -391,25 +391,20 @@ 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::Init(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);
     nr_crypto_vtbl = &nr_ice_crypto_nss_vtbl;
     initialized = true;
 
     // Set the priorites for candidate type preferences.
     // These numbers come from RFC 5245 S. 4.1.2.2
@@ -472,16 +467,29 @@ 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()));
     }
   }
+}
+
+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);
+
+  // Initialize the crypto callbacks and logging stuff
+  Init(allow_loopback, tcp_enabled, allow_link_local);
 
   // Create the ICE context
   int r;
 
   UINT4 flags = offerer ? NR_ICE_CTX_FLAGS_OFFERER:
       NR_ICE_CTX_FLAGS_ANSWERER;
   flags |= NR_ICE_CTX_FLAGS_AGGRESSIVE_NOMINATION;
   if (policy == ICE_POLICY_RELAY) {
--- a/media/mtransport/nricectx.h
+++ b/media/mtransport/nricectx.h
@@ -210,16 +210,20 @@ class NrIceCtx {
                      ICE_CONTROLLED
   };
 
   enum Policy { ICE_POLICY_NONE,
                 ICE_POLICY_RELAY,
                 ICE_POLICY_ALL
   };
 
+  static void Init(bool allow_loopback = false,
+                   bool tcp_enabled = true,
+                   bool allow_link_local = false);
+
   // 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);