Bug 1290948 - Part 8: Don't cause ICE to fail if there's no streams to establish. r+drno
MozReview-Commit-ID: 4wxlK9w3sL6
--- 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