Bug 1269486: allow setting ICE controller only once. r=bwc
MozReview-Commit-ID: AXyNyTZH1Jt
--- 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_;