Bug 1318167 - Part 4: Incorporate remote end-of-candidates into SDP. r=mjf
authorByron Campen [:bwc] <docfaraday@gmail.com>
Tue, 19 Mar 2019 16:48:38 +0000
changeset 465096 151f1392f61900a67514478a8e48024cf5166462
parent 465095 b425ca25edc52da94ae2fc65a571ea054c46ac4f
child 465097 703b266e352982cfbb6120f424fe6162bbffca05
push id35732
push useropoprus@mozilla.com
push dateWed, 20 Mar 2019 10:52:37 +0000
treeherdermozilla-central@708979f9c3f3 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmjf
bugs1318167
milestone68.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 1318167 - Part 4: Incorporate remote end-of-candidates into SDP. r=mjf Differential Revision: https://phabricator.services.mozilla.com/D23220
media/webrtc/signaling/src/jsep/JsepSessionImpl.cpp
media/webrtc/signaling/src/sdp/SdpHelper.cpp
--- a/media/webrtc/signaling/src/jsep/JsepSessionImpl.cpp
+++ b/media/webrtc/signaling/src/jsep/JsepSessionImpl.cpp
@@ -2055,25 +2055,31 @@ nsresult JsepSessionImpl::AddRemoteIceCa
   mozilla::Sdp* sdp =
       GetParsedRemoteDescription(kJsepDescriptionPendingOrCurrent);
 
   if (!sdp) {
     JSEP_SET_ERROR("Cannot add ICE candidate in state " << GetStateStr(mState));
     return NS_ERROR_UNEXPECTED;
   }
 
-  JsepTransceiver* transceiver;
+  JsepTransceiver* transceiver = nullptr;
+  bool hasMidOrLevel = true;
   if (!mid.empty()) {
     transceiver = GetTransceiverForMid(mid);
   } else if (level.isSome()) {
     transceiver = GetTransceiverForLevel(level.value());
   } else {
-    JSEP_SET_ERROR("ICE candidate: \'" << candidate
-                                       << "\' is missing MID and MLineIndex");
-    return NS_ERROR_TYPE_ERR;
+    hasMidOrLevel = false;
+  }
+
+  if (candidate.empty() && !hasMidOrLevel) {
+    for (uint16_t i = 0; i < sdp->GetMediaSectionCount(); ++i) {
+      mSdpHelper.SetIceGatheringComplete(sdp, i);
+    }
+    return NS_OK;
   }
 
   if (!transceiver) {
     JSEP_SET_ERROR("Cannot set ICE candidate for level="
                    << level << " mid=" << mid << ": No such transceiver.");
     return NS_ERROR_INVALID_ARG;
   }
 
--- a/media/webrtc/signaling/src/sdp/SdpHelper.cpp
+++ b/media/webrtc/signaling/src/sdp/SdpHelper.cpp
@@ -272,16 +272,21 @@ nsresult SdpHelper::GetMidFromLevel(cons
 nsresult SdpHelper::AddCandidateToSdp(Sdp* sdp,
                                       const std::string& candidateUntrimmed,
                                       uint16_t level) {
   if (level >= sdp->GetMediaSectionCount()) {
     SDP_SET_ERROR("Index " << level << " out of range");
     return NS_ERROR_INVALID_ARG;
   }
 
+  if (candidateUntrimmed.empty()) {
+    SetIceGatheringComplete(sdp, level);
+    return NS_OK;
+  }
+
   // Trim off '[a=]candidate:'
   size_t begin = candidateUntrimmed.find(':');
   if (begin == std::string::npos) {
     SDP_SET_ERROR("Invalid candidate, no ':' (" << candidateUntrimmed << ")");
     return NS_ERROR_INVALID_ARG;
   }
   ++begin;