Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(763)

Side by Side Diff: webrtc/api/jsepsessiondescription.cc

Issue 1648813004: Remove candidates when doing continual gathering (Closed) Base URL: https://chromium.googlesource.com/external/webrtc@master
Patch Set: Address Alex's comments Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « webrtc/api/jsepsessiondescription.h ('k') | webrtc/api/jsepsessiondescription_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2012 The WebRTC project authors. All Rights Reserved. 2 * Copyright 2012 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 static_cast<int>(mediasection_index), 130 static_cast<int>(mediasection_index),
131 updated_candidate)); 131 updated_candidate));
132 if (!candidate_collection_[mediasection_index].HasCandidate( 132 if (!candidate_collection_[mediasection_index].HasCandidate(
133 updated_candidate_wrapper.get())) 133 updated_candidate_wrapper.get()))
134 candidate_collection_[mediasection_index].add( 134 candidate_collection_[mediasection_index].add(
135 updated_candidate_wrapper.release()); 135 updated_candidate_wrapper.release());
136 136
137 return true; 137 return true;
138 } 138 }
139 139
140 size_t JsepSessionDescription::RemoveCandidates(
141 const std::vector<cricket::Candidate>& candidates) {
142 size_t num_removed = 0;
143 for (auto& candidate : candidates) {
144 int mediasection_index = GetMediasectionIndex(candidate);
145 if (mediasection_index < 0) {
146 // Not found.
147 continue;
148 }
149 num_removed += candidate_collection_[mediasection_index].remove(candidate);
150 }
151 return num_removed;
152 }
153
140 size_t JsepSessionDescription::number_of_mediasections() const { 154 size_t JsepSessionDescription::number_of_mediasections() const {
141 if (!description_) 155 if (!description_)
142 return 0; 156 return 0;
143 return description_->contents().size(); 157 return description_->contents().size();
144 } 158 }
145 159
146 const IceCandidateCollection* JsepSessionDescription::candidates( 160 const IceCandidateCollection* JsepSessionDescription::candidates(
147 size_t mediasection_index) const { 161 size_t mediasection_index) const {
148 if (mediasection_index >= candidate_collection_.size()) 162 if (mediasection_index >= candidate_collection_.size())
149 return NULL; 163 return NULL;
(...skipping 27 matching lines...) Expand all
177 } 191 }
178 if (!found) { 192 if (!found) {
179 // If the sdp_mid is presented but we can't find a match, we consider 193 // If the sdp_mid is presented but we can't find a match, we consider
180 // this as an error. 194 // this as an error.
181 return false; 195 return false;
182 } 196 }
183 } 197 }
184 return true; 198 return true;
185 } 199 }
186 200
201 int JsepSessionDescription::GetMediasectionIndex(
202 const cricket::Candidate& candidate) {
203 // Find the description with a matching transport name of the candidate.
204 const std::string& transport_name = candidate.transport_name();
205 for (size_t i = 0; i < description_->contents().size(); ++i) {
206 if (transport_name == description_->contents().at(i).name) {
207 return static_cast<int>(i);
208 }
209 }
210 return -1;
211 }
212
187 } // namespace webrtc 213 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/api/jsepsessiondescription.h ('k') | webrtc/api/jsepsessiondescription_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698