OLD | NEW |
1 /* | 1 /* |
2 * libjingle | 2 * libjingle |
3 * Copyright 2012 Google Inc. | 3 * Copyright 2012 Google Inc. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions are met: | 6 * modification, are permitted provided that the following conditions are met: |
7 * | 7 * |
8 * 1. Redistributions of source code must retain the above copyright notice, | 8 * 1. Redistributions of source code must retain the above copyright notice, |
9 * this list of conditions and the following disclaimer. | 9 * this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright notice, | 10 * 2. Redistributions in binary form must reproduce the above copyright notice, |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
147 static_cast<int>(mediasection_index), | 147 static_cast<int>(mediasection_index), |
148 updated_candidate)); | 148 updated_candidate)); |
149 if (!candidate_collection_[mediasection_index].HasCandidate( | 149 if (!candidate_collection_[mediasection_index].HasCandidate( |
150 updated_candidate_wrapper.get())) | 150 updated_candidate_wrapper.get())) |
151 candidate_collection_[mediasection_index].add( | 151 candidate_collection_[mediasection_index].add( |
152 updated_candidate_wrapper.release()); | 152 updated_candidate_wrapper.release()); |
153 | 153 |
154 return true; | 154 return true; |
155 } | 155 } |
156 | 156 |
| 157 bool JsepSessionDescription::RemoveCandidate( |
| 158 const IceCandidateInterface* candidate) { |
| 159 if (!candidate || candidate->sdp_mline_index() < 0 || |
| 160 candidate->candidate().priority() != 0) { |
| 161 return false; |
| 162 } |
| 163 size_t mediasection_index = 0; |
| 164 if (!GetMediasectionIndex(candidate, &mediasection_index) || |
| 165 mediasection_index >= number_of_mediasections()) { |
| 166 return false; |
| 167 } |
| 168 int num_removed = candidate_collection_[mediasection_index].remove(candidate); |
| 169 ASSERT(num_removed <= 1); |
| 170 return num_removed > 0; |
| 171 } |
| 172 |
157 size_t JsepSessionDescription::number_of_mediasections() const { | 173 size_t JsepSessionDescription::number_of_mediasections() const { |
158 if (!description_) | 174 if (!description_) |
159 return 0; | 175 return 0; |
160 return description_->contents().size(); | 176 return description_->contents().size(); |
161 } | 177 } |
162 | 178 |
163 const IceCandidateCollection* JsepSessionDescription::candidates( | 179 const IceCandidateCollection* JsepSessionDescription::candidates( |
164 size_t mediasection_index) const { | 180 size_t mediasection_index) const { |
165 if (mediasection_index >= candidate_collection_.size()) | 181 if (mediasection_index >= candidate_collection_.size()) |
166 return NULL; | 182 return NULL; |
(...skipping 27 matching lines...) Expand all Loading... |
194 if (!found) { | 210 if (!found) { |
195 // If the sdp_mid is presented but we can't find a match, we consider | 211 // If the sdp_mid is presented but we can't find a match, we consider |
196 // this as an error. | 212 // this as an error. |
197 return false; | 213 return false; |
198 } | 214 } |
199 } | 215 } |
200 return true; | 216 return true; |
201 } | 217 } |
202 | 218 |
203 } // namespace webrtc | 219 } // namespace webrtc |
OLD | NEW |