| OLD | NEW |
| 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 Loading... |
| 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 | |
| 154 size_t JsepSessionDescription::number_of_mediasections() const { | 140 size_t JsepSessionDescription::number_of_mediasections() const { |
| 155 if (!description_) | 141 if (!description_) |
| 156 return 0; | 142 return 0; |
| 157 return description_->contents().size(); | 143 return description_->contents().size(); |
| 158 } | 144 } |
| 159 | 145 |
| 160 const IceCandidateCollection* JsepSessionDescription::candidates( | 146 const IceCandidateCollection* JsepSessionDescription::candidates( |
| 161 size_t mediasection_index) const { | 147 size_t mediasection_index) const { |
| 162 if (mediasection_index >= candidate_collection_.size()) | 148 if (mediasection_index >= candidate_collection_.size()) |
| 163 return NULL; | 149 return NULL; |
| (...skipping 27 matching lines...) Expand all Loading... |
| 191 } | 177 } |
| 192 if (!found) { | 178 if (!found) { |
| 193 // If the sdp_mid is presented but we can't find a match, we consider | 179 // If the sdp_mid is presented but we can't find a match, we consider |
| 194 // this as an error. | 180 // this as an error. |
| 195 return false; | 181 return false; |
| 196 } | 182 } |
| 197 } | 183 } |
| 198 return true; | 184 return true; |
| 199 } | 185 } |
| 200 | 186 |
| 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 | |
| 213 } // namespace webrtc | 187 } // namespace webrtc |
| OLD | NEW |