OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2011 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 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
245 }; | 245 }; |
246 | 246 |
247 template <class Condition> | 247 template <class Condition> |
248 const StreamParams* GetStream(const StreamParamsVec& streams, | 248 const StreamParams* GetStream(const StreamParamsVec& streams, |
249 Condition condition) { | 249 Condition condition) { |
250 StreamParamsVec::const_iterator found = | 250 StreamParamsVec::const_iterator found = |
251 std::find_if(streams.begin(), streams.end(), condition); | 251 std::find_if(streams.begin(), streams.end(), condition); |
252 return found == streams.end() ? nullptr : &(*found); | 252 return found == streams.end() ? nullptr : &(*found); |
253 } | 253 } |
254 | 254 |
| 255 template <class Condition> |
| 256 StreamParams* GetStream(StreamParamsVec& streams, Condition condition) { |
| 257 StreamParamsVec::iterator found = |
| 258 std::find_if(streams.begin(), streams.end(), condition); |
| 259 return found == streams.end() ? nullptr : &(*found); |
| 260 } |
| 261 |
255 inline const StreamParams* GetStreamBySsrc(const StreamParamsVec& streams, | 262 inline const StreamParams* GetStreamBySsrc(const StreamParamsVec& streams, |
256 uint32_t ssrc) { | 263 uint32_t ssrc) { |
257 return GetStream(streams, | 264 return GetStream(streams, |
258 [&ssrc](const StreamParams& sp) { return sp.has_ssrc(ssrc); }); | 265 [&ssrc](const StreamParams& sp) { return sp.has_ssrc(ssrc); }); |
259 } | 266 } |
260 | 267 |
261 inline const StreamParams* GetStreamByIds(const StreamParamsVec& streams, | 268 inline const StreamParams* GetStreamByIds(const StreamParamsVec& streams, |
262 const std::string& groupid, | 269 const std::string& groupid, |
263 const std::string& id) { | 270 const std::string& id) { |
| 271 return GetStream(streams, [&groupid, &id](const StreamParams& sp) { |
| 272 return sp.groupid == groupid && sp.id == id; |
| 273 }); |
| 274 } |
| 275 |
| 276 inline StreamParams* GetStreamByIds(StreamParamsVec& streams, |
| 277 const std::string& groupid, |
| 278 const std::string& id) { |
264 return GetStream(streams, | 279 return GetStream(streams, |
265 [&groupid, &id](const StreamParams& sp) { | 280 [&groupid, &id](const StreamParams& sp) { |
266 return sp.groupid == groupid && sp.id == id; | 281 return sp.groupid == groupid && sp.id == id; |
267 }); | 282 }); |
268 } | 283 } |
269 | 284 |
270 inline const StreamParams* GetStream(const StreamParamsVec& streams, | 285 inline const StreamParams* GetStream(const StreamParamsVec& streams, |
271 const StreamSelector& selector) { | 286 const StreamSelector& selector) { |
272 return GetStream(streams, | 287 return GetStream(streams, |
273 [&selector](const StreamParams& sp) { return selector.Matches(sp); }); | 288 [&selector](const StreamParams& sp) { return selector.Matches(sp); }); |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
308 bool IsOneSsrcStream(const StreamParams& sp); | 323 bool IsOneSsrcStream(const StreamParams& sp); |
309 | 324 |
310 // Checks if |sp| defines parameters for one Simulcast stream. There may be RTX | 325 // Checks if |sp| defines parameters for one Simulcast stream. There may be RTX |
311 // streams associated with the simulcast streams. Leaving as non-static so we | 326 // streams associated with the simulcast streams. Leaving as non-static so we |
312 // can test this function. | 327 // can test this function. |
313 bool IsSimulcastStream(const StreamParams& sp); | 328 bool IsSimulcastStream(const StreamParams& sp); |
314 | 329 |
315 } // namespace cricket | 330 } // namespace cricket |
316 | 331 |
317 #endif // WEBRTC_MEDIA_BASE_STREAMPARAMS_H_ | 332 #endif // WEBRTC_MEDIA_BASE_STREAMPARAMS_H_ |
OLD | NEW |