Bug 1269486: allow setting ICE controller only once. r=bwc draft
authorNils Ohlmeier [:drno] <drno@ohlmeier.org>
Tue, 03 May 2016 13:28:14 -0700
changeset 363179 d02dd8d76e08facdf64b552ed1487064a8dff1c8
parent 362985 0a81ad3bbff8796de1874ae32646f1f9cfc1a2b6
child 363439 bdde69a10dcd3d8db830ee33c2ae22b36727a6fd
push id17125
push userdrno@ohlmeier.org
push dateWed, 04 May 2016 04:39:36 +0000
reviewersbwc
bugs1269486
milestone49.0a1
Bug 1269486: allow setting ICE controller only once. r=bwc MozReview-Commit-ID: AXyNyTZH1Jt
media/mtransport/nricectx.cpp
media/mtransport/nricectx.h
--- a/media/mtransport/nricectx.cpp
+++ b/media/mtransport/nricectx.cpp
@@ -271,16 +271,17 @@ nsresult NrIceTurnServer::ToNicerTurnStr
 
 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),
+    ice_controlling_set_(false),
     streams_(),
     ctx_(nullptr),
     peer_(nullptr),
     ice_handler_vtbl_(nullptr),
     ice_handler_(nullptr),
     trickle_(true),
     policy_(policy),
     nat_ (nullptr) {
@@ -698,20 +699,23 @@ std::string NrIceCtx::pwd() const {
   return ctx_->pwd;
 }
 
 void NrIceCtx::destroy_peer_ctx() {
   nr_ice_peer_ctx_destroy(&peer_);
 }
 
 nsresult NrIceCtx::SetControlling(Controlling controlling) {
-  peer_->controlling = (controlling == ICE_CONTROLLING)? 1 : 0;
+  if (!ice_controlling_set_) {
+    peer_->controlling = (controlling == ICE_CONTROLLING)? 1 : 0;
+    ice_controlling_set_ = true;
 
-  MOZ_MTLOG(ML_DEBUG, "ICE ctx " << name_ << " setting controlling to" <<
-            controlling);
+    MOZ_MTLOG(ML_DEBUG, "ICE ctx " << name_ << " setting controlling to" <<
+              controlling);
+  }
   return NS_OK;
 }
 
 NrIceCtx::Controlling NrIceCtx::GetControlling() {
   return (peer_->controlling) ? ICE_CONTROLLING : ICE_CONTROLLED;
 }
 
 nsresult NrIceCtx::SetPolicy(Policy policy) {
--- a/media/mtransport/nricectx.h
+++ b/media/mtransport/nricectx.h
@@ -366,16 +366,17 @@ private:
 
   // Set the state
   void SetGatheringState(GatheringState state);
 
   ConnectionState connection_state_;
   GatheringState gathering_state_;
   const std::string name_;
   bool offerer_;
+  bool ice_controlling_set_;
   std::vector<RefPtr<NrIceMediaStream> > streams_;
   nr_ice_ctx *ctx_;
   nr_ice_peer_ctx *peer_;
   nr_ice_handler_vtbl* ice_handler_vtbl_;  // Must be pointer
   nr_ice_handler* ice_handler_;  // Must be pointer
   bool trickle_;
   nsCOMPtr<nsIEventTarget> sts_target_; // The thread to run on
   Policy policy_;