Index: webrtc/api/jsepsessiondescription.cc |
diff --git a/webrtc/api/jsepsessiondescription.cc b/webrtc/api/jsepsessiondescription.cc |
index b47114b9bcd052979f13a19bdea35d3faae6efc5..eb776c86fa7d9bfd3755adac93b4844ad34456d2 100644 |
--- a/webrtc/api/jsepsessiondescription.cc |
+++ b/webrtc/api/jsepsessiondescription.cc |
@@ -137,6 +137,20 @@ bool JsepSessionDescription::AddCandidate( |
return true; |
} |
+size_t JsepSessionDescription::RemoveCandidates( |
+ const std::vector<cricket::Candidate>& candidates) { |
+ size_t num_removed = 0; |
+ for (auto& candidate : candidates) { |
+ int mediasection_index = GetMediasectionIndex(candidate); |
+ if (mediasection_index < 0) { |
+ // Not found. |
+ continue; |
+ } |
+ num_removed += candidate_collection_[mediasection_index].remove(candidate); |
+ } |
+ return num_removed; |
+} |
+ |
size_t JsepSessionDescription::number_of_mediasections() const { |
if (!description_) |
return 0; |
@@ -184,4 +198,16 @@ bool JsepSessionDescription::GetMediasectionIndex( |
return true; |
} |
+int JsepSessionDescription::GetMediasectionIndex( |
+ const cricket::Candidate& candidate) { |
+ // Find the description with a matching transport name of the candidate. |
+ const std::string& transport_name = candidate.transport_name(); |
+ for (size_t i = 0; i < description_->contents().size(); ++i) { |
+ if (transport_name == description_->contents().at(i).name) { |
+ return static_cast<int>(i); |
+ } |
+ } |
+ return -1; |
+} |
+ |
} // namespace webrtc |