Bug 1290948 - Part 8: Don't cause ICE to fail if there's no streams to establish. r+drno draft
authorByron Campen [:bwc] <docfaraday@gmail.com>
Fri, 29 Sep 2017 09:16:14 -0500
changeset 704688 9f100b623b64ae55b4f33ddfe0601f39678a04b3
parent 704687 605e7742c7b187c254e76af6723ef0fe554ae032
child 704689 4930a45e24791bc921e69be338b4e61f8ae47eec
push id91202
push userbcampen@mozilla.com
push dateTue, 28 Nov 2017 19:52:00 +0000
bugs1290948
milestone59.0a1
Bug 1290948 - Part 8: Don't cause ICE to fail if there's no streams to establish. r+drno MozReview-Commit-ID: 4wxlK9w3sL6
media/mtransport/nricectx.cpp
media/mtransport/nricectx.h
--- a/media/mtransport/nricectx.cpp
+++ b/media/mtransport/nricectx.cpp
@@ -1038,18 +1038,31 @@ nsresult NrIceCtx::ParseGlobalAttributes
     MOZ_MTLOG(ML_ERROR, "Couldn't parse global attributes for "
               << name_ << "'");
     return NS_ERROR_FAILURE;
   }
 
   return NS_OK;
 }
 
+bool NrIceCtx::HasStreamsToConnect() const {
+  for (auto& stream : streams_) {
+    if (stream && stream->state() != NrIceMediaStream::ICE_CLOSED) {
+      return true;
+    }
+  }
+  return false;
+}
+
 nsresult NrIceCtx::StartChecks(bool offerer) {
   int r;
+  if (!HasStreamsToConnect()) {
+    // Nothing to do
+    return NS_OK;
+  }
 
   offerer_ = offerer;
   ice_start_time_ = TimeStamp::Now();
 
   r=nr_ice_peer_ctx_pair_candidates(peer_);
   if (r) {
     MOZ_MTLOG(ML_ERROR, "Couldn't pair candidates on "
               << name_ << "'");
--- a/media/mtransport/nricectx.h
+++ b/media/mtransport/nricectx.h
@@ -267,16 +267,18 @@ class NrIceCtx {
   }
 
   // Some might be null
   size_t GetStreamCount() const
   {
     return streams_.size();
   }
 
+  bool HasStreamsToConnect() const;
+
   // The name of the ctx
   const std::string& name() const { return name_; }
 
   // Get ufrag and password.
   std::string ufrag() const;
   std::string pwd() const;
 
   // Current state