| 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 int JsepSessionDescription::RemoveCandidate( |
| 141 const IceCandidateInterface* candidate) { |
| 142 if (!candidate || candidate->sdp_mline_index() < 0) { |
| 143 return 0; |
| 144 } |
| 145 size_t mediasection_index = 0; |
| 146 if (!GetMediasectionIndex(candidate, &mediasection_index) || |
| 147 mediasection_index >= number_of_mediasections()) { |
| 148 return 0; |
| 149 } |
| 150 return candidate_collection_[mediasection_index].remove(candidate); |
| 151 } |
| 152 |
| 153 int JsepSessionDescription::RemoveCandidates( |
| 154 const std::vector<IceCandidateInterfaceRefPtr>& candidates) { |
| 155 int num_removed = 0; |
| 156 for (auto candidate : candidates) { |
| 157 num_removed += RemoveCandidate(candidate.get()); |
| 158 } |
| 159 return num_removed; |
| 160 } |
| 161 |
| 140 size_t JsepSessionDescription::number_of_mediasections() const { | 162 size_t JsepSessionDescription::number_of_mediasections() const { |
| 141 if (!description_) | 163 if (!description_) |
| 142 return 0; | 164 return 0; |
| 143 return description_->contents().size(); | 165 return description_->contents().size(); |
| 144 } | 166 } |
| 145 | 167 |
| 146 const IceCandidateCollection* JsepSessionDescription::candidates( | 168 const IceCandidateCollection* JsepSessionDescription::candidates( |
| 147 size_t mediasection_index) const { | 169 size_t mediasection_index) const { |
| 148 if (mediasection_index >= candidate_collection_.size()) | 170 if (mediasection_index >= candidate_collection_.size()) |
| 149 return NULL; | 171 return NULL; |
| (...skipping 28 matching lines...) Expand all Loading... |
| 178 if (!found) { | 200 if (!found) { |
| 179 // If the sdp_mid is presented but we can't find a match, we consider | 201 // If the sdp_mid is presented but we can't find a match, we consider |
| 180 // this as an error. | 202 // this as an error. |
| 181 return false; | 203 return false; |
| 182 } | 204 } |
| 183 } | 205 } |
| 184 return true; | 206 return true; |
| 185 } | 207 } |
| 186 | 208 |
| 187 } // namespace webrtc | 209 } // namespace webrtc |
| OLD | NEW |