Bug 1425956 - Part 3: Remove duplicate track ids on incoming SDP. r=drno
authorByron Campen [:bwc] <docfaraday@gmail.com>
Mon, 18 Dec 2017 17:52:44 -0600
changeset 448654 8e682e487ef12970f63169ac97045221ee1be2c9
parent 448653 a51a639d16c0ca62587b21ccf4018aeba97534ad
child 448655 366c25784d0a11f66d30ec90114636b46b30ff8f
push id8527
push userCallek@gmail.com
push dateThu, 11 Jan 2018 21:05:50 +0000
treeherdermozilla-beta@95342d212a7a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdrno
bugs1425956
milestone59.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 1425956 - Part 3: Remove duplicate track ids on incoming SDP. r=drno MozReview-Commit-ID: Ldac3oB5ocz
media/webrtc/signaling/src/jsep/JsepSessionImpl.cpp
--- a/media/webrtc/signaling/src/jsep/JsepSessionImpl.cpp
+++ b/media/webrtc/signaling/src/jsep/JsepSessionImpl.cpp
@@ -359,16 +359,20 @@ JsepSessionImpl::GetRemoteIds(const Sdp&
 nsresult
 JsepSessionImpl::RemoveDuplicateTrackIds(Sdp* sdp)
 {
   std::set<std::string> trackIds;
 
   for (size_t i = 0; i < sdp->GetMediaSectionCount(); ++i) {
     SdpMediaSection& msection(sdp->GetMediaSection(i));
 
+    if (mSdpHelper.MsectionIsDisabled(msection)) {
+      continue;
+    }
+
     std::vector<std::string> streamIds;
     std::string trackId;
     nsresult rv = mSdpHelper.GetIdsFromMsid(*sdp,
                                             msection,
                                             &streamIds,
                                             &trackId);
 
     if (NS_SUCCEEDED(rv)) {
@@ -385,16 +389,19 @@ JsepSessionImpl::RemoveDuplicateTrackIds
             new SdpMsidAttributeList(mediaAttrs.GetMsid()));
         for (auto& msid : newMsids->mMsids) {
           msid.appdata = trackId;
         }
 
         mediaAttrs.SetAttribute(newMsids.release());
       }
       trackIds.insert(trackId);
+    } else if (rv != NS_ERROR_NOT_AVAILABLE) {
+      // Error has already been set
+      return rv;
     }
   }
 
   return NS_OK;
 }
 
 nsresult
 JsepSessionImpl::CreateOffer(const JsepOfferOptions& options,
@@ -1308,28 +1315,16 @@ JsepSessionImpl::ParseSdp(const std::str
     if (mediaAttrs.HasAttribute(SdpAttribute::kSetupAttribute, true) &&
         mediaAttrs.GetSetup().mRole == SdpSetupAttribute::kHoldconn) {
       JSEP_SET_ERROR("Description has illegal setup attribute "
                      "\"holdconn\" in m-section at level "
                      << i);
       return NS_ERROR_INVALID_ARG;
     }
 
-    std::vector<std::string> streamIds;
-    std::string trackId;
-    nsresult rv = mSdpHelper.GetIdsFromMsid(*parsed,
-                                            parsed->GetMediaSection(i),
-                                            &streamIds,
-                                            &trackId);
-
-    if (NS_FAILED(rv) && (rv != NS_ERROR_NOT_AVAILABLE)) {
-      // Error has already been set
-      return rv;
-    }
-
     static const std::bitset<128> forbidden = GetForbiddenSdpPayloadTypes();
     if (msection.GetMediaType() == SdpMediaSection::kAudio ||
         msection.GetMediaType() == SdpMediaSection::kVideo) {
       // Sanity-check that payload type can work with RTP
       for (const std::string& fmt : msection.GetFormats()) {
         uint16_t payloadType;
         if (!SdpHelper::GetPtAsInt(fmt, &payloadType)) {
           JSEP_SET_ERROR("Payload type \"" << fmt <<
@@ -1345,16 +1340,19 @@ JsepSessionImpl::ParseSdp(const std::str
           JSEP_SET_ERROR("Illegal audio/video payload type \"" << fmt <<
                          "\" at level " << i);
           return NS_ERROR_INVALID_ARG;
         }
       }
     }
   }
 
+  nsresult rv = RemoveDuplicateTrackIds(parsed.get());
+  NS_ENSURE_SUCCESS(rv, rv);
+
   *parsedp = Move(parsed);
   return NS_OK;
 }
 
 nsresult
 JsepSessionImpl::SetRemoteDescriptionOffer(UniquePtr<Sdp> offer)
 {
   MOZ_ASSERT(mState == kJsepStateStable);