OLD | NEW |
1 /* | 1 /* |
2 * libjingle | 2 * libjingle |
3 * Copyright 2011 Google Inc. | 3 * Copyright 2011 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 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
93 bool MediaStreams::RemoveVideoStream( | 93 bool MediaStreams::RemoveVideoStream( |
94 const StreamSelector& selector) { | 94 const StreamSelector& selector) { |
95 return RemoveStream(&video_, selector); | 95 return RemoveStream(&video_, selector); |
96 } | 96 } |
97 | 97 |
98 bool MediaStreams::RemoveDataStream( | 98 bool MediaStreams::RemoveDataStream( |
99 const StreamSelector& selector) { | 99 const StreamSelector& selector) { |
100 return RemoveStream(&data_, selector); | 100 return RemoveStream(&data_, selector); |
101 } | 101 } |
102 | 102 |
103 static std::string SsrcsToString(const std::vector<uint32>& ssrcs) { | 103 static std::string SsrcsToString(const std::vector<uint32_t>& ssrcs) { |
104 std::ostringstream ost; | 104 std::ostringstream ost; |
105 ost << "ssrcs:["; | 105 ost << "ssrcs:["; |
106 for (std::vector<uint32>::const_iterator it = ssrcs.begin(); | 106 for (std::vector<uint32_t>::const_iterator it = ssrcs.begin(); |
107 it != ssrcs.end(); ++it) { | 107 it != ssrcs.end(); ++it) { |
108 if (it != ssrcs.begin()) { | 108 if (it != ssrcs.begin()) { |
109 ost << ","; | 109 ost << ","; |
110 } | 110 } |
111 ost << *it; | 111 ost << *it; |
112 } | 112 } |
113 ost << "]"; | 113 ost << "]"; |
114 return ost.str(); | 114 return ost.str(); |
115 } | 115 } |
116 | 116 |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
154 } | 154 } |
155 if (!cname.empty()) { | 155 if (!cname.empty()) { |
156 ost << "cname:" << cname << ";"; | 156 ost << "cname:" << cname << ";"; |
157 } | 157 } |
158 if (!sync_label.empty()) { | 158 if (!sync_label.empty()) { |
159 ost << "sync_label:" << sync_label; | 159 ost << "sync_label:" << sync_label; |
160 } | 160 } |
161 ost << "}"; | 161 ost << "}"; |
162 return ost.str(); | 162 return ost.str(); |
163 } | 163 } |
164 void StreamParams::GetPrimarySsrcs(std::vector<uint32>* ssrcs) const { | 164 void StreamParams::GetPrimarySsrcs(std::vector<uint32_t>* ssrcs) const { |
165 const SsrcGroup* sim_group = get_ssrc_group(kSimSsrcGroupSemantics); | 165 const SsrcGroup* sim_group = get_ssrc_group(kSimSsrcGroupSemantics); |
166 if (sim_group == NULL) { | 166 if (sim_group == NULL) { |
167 ssrcs->push_back(first_ssrc()); | 167 ssrcs->push_back(first_ssrc()); |
168 } else { | 168 } else { |
169 for (size_t i = 0; i < sim_group->ssrcs.size(); ++i) { | 169 for (size_t i = 0; i < sim_group->ssrcs.size(); ++i) { |
170 ssrcs->push_back(sim_group->ssrcs[i]); | 170 ssrcs->push_back(sim_group->ssrcs[i]); |
171 } | 171 } |
172 } | 172 } |
173 } | 173 } |
174 | 174 |
175 void StreamParams::GetFidSsrcs(const std::vector<uint32>& primary_ssrcs, | 175 void StreamParams::GetFidSsrcs(const std::vector<uint32_t>& primary_ssrcs, |
176 std::vector<uint32>* fid_ssrcs) const { | 176 std::vector<uint32_t>* fid_ssrcs) const { |
177 for (size_t i = 0; i < primary_ssrcs.size(); ++i) { | 177 for (size_t i = 0; i < primary_ssrcs.size(); ++i) { |
178 uint32 fid_ssrc; | 178 uint32_t fid_ssrc; |
179 if (GetFidSsrc(primary_ssrcs[i], &fid_ssrc)) { | 179 if (GetFidSsrc(primary_ssrcs[i], &fid_ssrc)) { |
180 fid_ssrcs->push_back(fid_ssrc); | 180 fid_ssrcs->push_back(fid_ssrc); |
181 } | 181 } |
182 } | 182 } |
183 } | 183 } |
184 | 184 |
185 bool StreamParams::AddSecondarySsrc(const std::string& semantics, | 185 bool StreamParams::AddSecondarySsrc(const std::string& semantics, |
186 uint32 primary_ssrc, | 186 uint32_t primary_ssrc, |
187 uint32 secondary_ssrc) { | 187 uint32_t secondary_ssrc) { |
188 if (!has_ssrc(primary_ssrc)) { | 188 if (!has_ssrc(primary_ssrc)) { |
189 return false; | 189 return false; |
190 } | 190 } |
191 | 191 |
192 ssrcs.push_back(secondary_ssrc); | 192 ssrcs.push_back(secondary_ssrc); |
193 std::vector<uint32> ssrc_vector; | 193 std::vector<uint32_t> ssrc_vector; |
194 ssrc_vector.push_back(primary_ssrc); | 194 ssrc_vector.push_back(primary_ssrc); |
195 ssrc_vector.push_back(secondary_ssrc); | 195 ssrc_vector.push_back(secondary_ssrc); |
196 SsrcGroup ssrc_group = SsrcGroup(semantics, ssrc_vector); | 196 SsrcGroup ssrc_group = SsrcGroup(semantics, ssrc_vector); |
197 ssrc_groups.push_back(ssrc_group); | 197 ssrc_groups.push_back(ssrc_group); |
198 return true; | 198 return true; |
199 } | 199 } |
200 | 200 |
201 bool StreamParams::GetSecondarySsrc(const std::string& semantics, | 201 bool StreamParams::GetSecondarySsrc(const std::string& semantics, |
202 uint32 primary_ssrc, | 202 uint32_t primary_ssrc, |
203 uint32* secondary_ssrc) const { | 203 uint32_t* secondary_ssrc) const { |
204 for (std::vector<SsrcGroup>::const_iterator it = ssrc_groups.begin(); | 204 for (std::vector<SsrcGroup>::const_iterator it = ssrc_groups.begin(); |
205 it != ssrc_groups.end(); ++it) { | 205 it != ssrc_groups.end(); ++it) { |
206 if (it->has_semantics(semantics) && | 206 if (it->has_semantics(semantics) && |
207 it->ssrcs.size() >= 2 && | 207 it->ssrcs.size() >= 2 && |
208 it->ssrcs[0] == primary_ssrc) { | 208 it->ssrcs[0] == primary_ssrc) { |
209 *secondary_ssrc = it->ssrcs[1]; | 209 *secondary_ssrc = it->ssrcs[1]; |
210 return true; | 210 return true; |
211 } | 211 } |
212 } | 212 } |
213 return false; | 213 return false; |
214 } | 214 } |
215 | 215 |
216 bool IsOneSsrcStream(const StreamParams& sp) { | 216 bool IsOneSsrcStream(const StreamParams& sp) { |
217 if (sp.ssrcs.size() == 1 && sp.ssrc_groups.empty()) { | 217 if (sp.ssrcs.size() == 1 && sp.ssrc_groups.empty()) { |
218 return true; | 218 return true; |
219 } | 219 } |
220 if (sp.ssrcs.size() == 2) { | 220 if (sp.ssrcs.size() == 2) { |
221 const SsrcGroup* fid_group = sp.get_ssrc_group(kFidSsrcGroupSemantics); | 221 const SsrcGroup* fid_group = sp.get_ssrc_group(kFidSsrcGroupSemantics); |
222 if (fid_group != NULL) { | 222 if (fid_group != NULL) { |
223 return (sp.ssrcs == fid_group->ssrcs); | 223 return (sp.ssrcs == fid_group->ssrcs); |
224 } | 224 } |
225 } | 225 } |
226 return false; | 226 return false; |
227 } | 227 } |
228 | 228 |
229 static void RemoveFirst(std::list<uint32>* ssrcs, uint32 value) { | 229 static void RemoveFirst(std::list<uint32_t>* ssrcs, uint32_t value) { |
230 std::list<uint32>::iterator it = | 230 std::list<uint32_t>::iterator it = |
231 std::find(ssrcs->begin(), ssrcs->end(), value); | 231 std::find(ssrcs->begin(), ssrcs->end(), value); |
232 if (it != ssrcs->end()) { | 232 if (it != ssrcs->end()) { |
233 ssrcs->erase(it); | 233 ssrcs->erase(it); |
234 } | 234 } |
235 } | 235 } |
236 | 236 |
237 bool IsSimulcastStream(const StreamParams& sp) { | 237 bool IsSimulcastStream(const StreamParams& sp) { |
238 const SsrcGroup* const sg = sp.get_ssrc_group(kSimSsrcGroupSemantics); | 238 const SsrcGroup* const sg = sp.get_ssrc_group(kSimSsrcGroupSemantics); |
239 if (sg == NULL || sg->ssrcs.size() < 2) { | 239 if (sg == NULL || sg->ssrcs.size() < 2) { |
240 return false; | 240 return false; |
241 } | 241 } |
242 // Start with all StreamParams SSRCs. Remove simulcast SSRCs (from sg) and | 242 // Start with all StreamParams SSRCs. Remove simulcast SSRCs (from sg) and |
243 // RTX SSRCs. If we still have SSRCs left, we don't know what they're for. | 243 // RTX SSRCs. If we still have SSRCs left, we don't know what they're for. |
244 // Also we remove first-found SSRCs only. So duplicates should lead to errors. | 244 // Also we remove first-found SSRCs only. So duplicates should lead to errors. |
245 std::list<uint32> sp_ssrcs(sp.ssrcs.begin(), sp.ssrcs.end()); | 245 std::list<uint32_t> sp_ssrcs(sp.ssrcs.begin(), sp.ssrcs.end()); |
246 for (size_t i = 0; i < sg->ssrcs.size(); ++i) { | 246 for (size_t i = 0; i < sg->ssrcs.size(); ++i) { |
247 RemoveFirst(&sp_ssrcs, sg->ssrcs[i]); | 247 RemoveFirst(&sp_ssrcs, sg->ssrcs[i]); |
248 } | 248 } |
249 for (size_t i = 0; i < sp.ssrc_groups.size(); ++i) { | 249 for (size_t i = 0; i < sp.ssrc_groups.size(); ++i) { |
250 const SsrcGroup& group = sp.ssrc_groups[i]; | 250 const SsrcGroup& group = sp.ssrc_groups[i]; |
251 if (group.semantics.compare(kFidSsrcGroupSemantics) != 0 || | 251 if (group.semantics.compare(kFidSsrcGroupSemantics) != 0 || |
252 group.ssrcs.size() != 2) { | 252 group.ssrcs.size() != 2) { |
253 continue; | 253 continue; |
254 } | 254 } |
255 RemoveFirst(&sp_ssrcs, group.ssrcs[1]); | 255 RemoveFirst(&sp_ssrcs, group.ssrcs[1]); |
256 } | 256 } |
257 // If there's SSRCs left that we don't know how to handle, we bail out. | 257 // If there's SSRCs left that we don't know how to handle, we bail out. |
258 return sp_ssrcs.size() == 0; | 258 return sp_ssrcs.size() == 0; |
259 } | 259 } |
260 | 260 |
261 } // namespace cricket | 261 } // namespace cricket |
OLD | NEW |