| 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 |
| 11 #include "webrtc/media/base/streamparams.h" | 11 #include "webrtc/media/base/streamparams.h" |
| 12 | 12 |
| 13 #include <list> | 13 #include <list> |
| 14 #include <sstream> | 14 #include <sstream> |
| 15 | 15 |
| 16 namespace cricket { | 16 namespace cricket { |
| 17 namespace { | 17 namespace { |
| 18 // NOTE: There is no check here for duplicate streams, so check before | 18 // NOTE: There is no check here for duplicate streams, so check before |
| 19 // adding. | 19 // adding. |
| 20 void AddStream(std::vector<StreamParams>* streams, const StreamParams& stream) { | 20 void AddStream(std::vector<StreamParams>* streams, const StreamParams& stream) { |
| 21 streams->push_back(stream); | 21 streams->push_back(stream); |
| 22 } | 22 } |
| 23 } | 23 } |
| 24 | 24 |
| 25 const char kFecSsrcGroupSemantics[] = "FEC"; | 25 const char kFecSsrcGroupSemantics[] = "FEC"; |
| 26 const char kFecFrSsrcGroupSemantics[] = "FEC-FR"; |
| 26 const char kFidSsrcGroupSemantics[] = "FID"; | 27 const char kFidSsrcGroupSemantics[] = "FID"; |
| 27 const char kSimSsrcGroupSemantics[] = "SIM"; | 28 const char kSimSsrcGroupSemantics[] = "SIM"; |
| 28 | 29 |
| 29 bool GetStream(const StreamParamsVec& streams, | 30 bool GetStream(const StreamParamsVec& streams, |
| 30 const StreamSelector& selector, | 31 const StreamSelector& selector, |
| 31 StreamParams* stream_out) { | 32 StreamParams* stream_out) { |
| 32 const StreamParams* found = GetStream(streams, selector); | 33 const StreamParams* found = GetStream(streams, selector); |
| 33 if (found && stream_out) | 34 if (found && stream_out) |
| 34 *stream_out = *found; | 35 *stream_out = *found; |
| 35 return found != nullptr; | 36 return found != nullptr; |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 193 return true; | 194 return true; |
| 194 } | 195 } |
| 195 } | 196 } |
| 196 return false; | 197 return false; |
| 197 } | 198 } |
| 198 | 199 |
| 199 bool IsOneSsrcStream(const StreamParams& sp) { | 200 bool IsOneSsrcStream(const StreamParams& sp) { |
| 200 if (sp.ssrcs.size() == 1 && sp.ssrc_groups.empty()) { | 201 if (sp.ssrcs.size() == 1 && sp.ssrc_groups.empty()) { |
| 201 return true; | 202 return true; |
| 202 } | 203 } |
| 204 const SsrcGroup* fid_group = sp.get_ssrc_group(kFidSsrcGroupSemantics); |
| 205 const SsrcGroup* fecfr_group = sp.get_ssrc_group(kFecFrSsrcGroupSemantics); |
| 203 if (sp.ssrcs.size() == 2) { | 206 if (sp.ssrcs.size() == 2) { |
| 204 const SsrcGroup* fid_group = sp.get_ssrc_group(kFidSsrcGroupSemantics); | 207 if (fid_group != nullptr && sp.ssrcs == fid_group->ssrcs) { |
| 205 if (fid_group != NULL) { | 208 return true; |
| 206 return (sp.ssrcs == fid_group->ssrcs); | 209 } |
| 210 if (fecfr_group != nullptr && sp.ssrcs == fecfr_group->ssrcs) { |
| 211 return true; |
| 212 } |
| 213 } |
| 214 if (sp.ssrcs.size() == 3) { |
| 215 if (fid_group == nullptr || fecfr_group == nullptr) { |
| 216 return false; |
| 217 } |
| 218 if (sp.ssrcs[0] != fid_group->ssrcs[0] || |
| 219 sp.ssrcs[0] != fecfr_group->ssrcs[0]) { |
| 220 return false; |
| 221 } |
| 222 // We do not check for FlexFEC over RTX, |
| 223 // as this combination is not supported. |
| 224 if (sp.ssrcs[1] == fid_group->ssrcs[1] && |
| 225 sp.ssrcs[2] == fecfr_group->ssrcs[1]) { |
| 226 return true; |
| 227 } |
| 228 if (sp.ssrcs[1] == fecfr_group->ssrcs[1] && |
| 229 sp.ssrcs[2] == fid_group->ssrcs[1]) { |
| 230 return true; |
| 207 } | 231 } |
| 208 } | 232 } |
| 209 return false; | 233 return false; |
| 210 } | 234 } |
| 211 | 235 |
| 212 static void RemoveFirst(std::list<uint32_t>* ssrcs, uint32_t value) { | 236 static void RemoveFirst(std::list<uint32_t>* ssrcs, uint32_t value) { |
| 213 std::list<uint32_t>::iterator it = | 237 std::list<uint32_t>::iterator it = |
| 214 std::find(ssrcs->begin(), ssrcs->end(), value); | 238 std::find(ssrcs->begin(), ssrcs->end(), value); |
| 215 if (it != ssrcs->end()) { | 239 if (it != ssrcs->end()) { |
| 216 ssrcs->erase(it); | 240 ssrcs->erase(it); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 235 group.ssrcs.size() != 2) { | 259 group.ssrcs.size() != 2) { |
| 236 continue; | 260 continue; |
| 237 } | 261 } |
| 238 RemoveFirst(&sp_ssrcs, group.ssrcs[1]); | 262 RemoveFirst(&sp_ssrcs, group.ssrcs[1]); |
| 239 } | 263 } |
| 240 // If there's SSRCs left that we don't know how to handle, we bail out. | 264 // If there's SSRCs left that we don't know how to handle, we bail out. |
| 241 return sp_ssrcs.size() == 0; | 265 return sp_ssrcs.size() == 0; |
| 242 } | 266 } |
| 243 | 267 |
| 244 } // namespace cricket | 268 } // namespace cricket |
| OLD | NEW |