OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 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 193 matching lines...) Loading... |
204 } | 204 } |
205 } | 205 } |
206 return true; | 206 return true; |
207 } | 207 } |
208 | 208 |
209 TelephoneEventHandler* RtpReceiverImpl::GetTelephoneEventHandler() { | 209 TelephoneEventHandler* RtpReceiverImpl::GetTelephoneEventHandler() { |
210 return rtp_media_receiver_->GetTelephoneEventHandler(); | 210 return rtp_media_receiver_->GetTelephoneEventHandler(); |
211 } | 211 } |
212 | 212 |
213 std::vector<RtpSource> RtpReceiverImpl::GetSources() const { | 213 std::vector<RtpSource> RtpReceiverImpl::GetSources() const { |
| 214 rtc::CritScope lock(&critical_section_rtp_receiver_); |
| 215 |
214 int64_t now_ms = clock_->TimeInMilliseconds(); | 216 int64_t now_ms = clock_->TimeInMilliseconds(); |
215 std::vector<RtpSource> sources; | 217 std::vector<RtpSource> sources; |
216 | 218 |
217 { | 219 RTC_DCHECK(std::is_sorted(ssrc_sources_.begin(), ssrc_sources_.end(), |
218 rtc::CritScope lock(&critical_section_rtp_receiver_); | 220 [](const RtpSource& lhs, const RtpSource& rhs) { |
| 221 return lhs.timestamp_ms() < rhs.timestamp_ms(); |
| 222 })); |
| 223 RTC_DCHECK(std::is_sorted(csrc_sources_.begin(), csrc_sources_.end(), |
| 224 [](const RtpSource& lhs, const RtpSource& rhs) { |
| 225 return lhs.timestamp_ms() < rhs.timestamp_ms(); |
| 226 })); |
219 | 227 |
220 RTC_DCHECK(std::is_sorted(ssrc_sources_.begin(), ssrc_sources_.end(), | 228 std::set<uint32_t> selected_ssrcs; |
221 [](const RtpSource& lhs, const RtpSource& rhs) { | 229 for (auto rit = ssrc_sources_.rbegin(); rit != ssrc_sources_.rend(); ++rit) { |
222 return lhs.timestamp_ms() < rhs.timestamp_ms(); | 230 if ((now_ms - rit->timestamp_ms()) > kGetSourcesTimeoutMs) { |
223 })); | 231 break; |
224 RTC_DCHECK(std::is_sorted(csrc_sources_.begin(), csrc_sources_.end(), | |
225 [](const RtpSource& lhs, const RtpSource& rhs) { | |
226 return lhs.timestamp_ms() < rhs.timestamp_ms(); | |
227 })); | |
228 | |
229 std::set<uint32_t> selected_ssrcs; | |
230 for (auto rit = ssrc_sources_.rbegin(); rit != ssrc_sources_.rend(); | |
231 ++rit) { | |
232 if ((now_ms - rit->timestamp_ms()) > kGetSourcesTimeoutMs) { | |
233 break; | |
234 } | |
235 if (selected_ssrcs.insert(rit->source_id()).second) { | |
236 sources.push_back(*rit); | |
237 } | |
238 } | 232 } |
239 | 233 if (selected_ssrcs.insert(rit->source_id()).second) { |
240 for (auto rit = csrc_sources_.rbegin(); rit != csrc_sources_.rend(); | |
241 ++rit) { | |
242 if ((now_ms - rit->timestamp_ms()) > kGetSourcesTimeoutMs) { | |
243 break; | |
244 } | |
245 sources.push_back(*rit); | 234 sources.push_back(*rit); |
246 } | 235 } |
247 } // End critsect. | 236 } |
248 | 237 |
| 238 for (auto rit = csrc_sources_.rbegin(); rit != csrc_sources_.rend(); ++rit) { |
| 239 if ((now_ms - rit->timestamp_ms()) > kGetSourcesTimeoutMs) { |
| 240 break; |
| 241 } |
| 242 sources.push_back(*rit); |
| 243 } |
249 return sources; | 244 return sources; |
250 } | 245 } |
251 | 246 |
252 bool RtpReceiverImpl::Timestamp(uint32_t* timestamp) const { | 247 bool RtpReceiverImpl::Timestamp(uint32_t* timestamp) const { |
253 rtc::CritScope lock(&critical_section_rtp_receiver_); | 248 rtc::CritScope lock(&critical_section_rtp_receiver_); |
254 if (!HaveReceivedFrame()) | 249 if (!HaveReceivedFrame()) |
255 return false; | 250 return false; |
256 *timestamp = last_received_timestamp_; | 251 *timestamp = last_received_timestamp_; |
257 return true; | 252 return true; |
258 } | 253 } |
(...skipping 292 matching lines...) Loading... |
551 for (vec_it = ssrc_sources_.begin(); vec_it != ssrc_sources_.end(); | 546 for (vec_it = ssrc_sources_.begin(); vec_it != ssrc_sources_.end(); |
552 ++vec_it) { | 547 ++vec_it) { |
553 if ((now_ms - vec_it->timestamp_ms()) <= kGetSourcesTimeoutMs) { | 548 if ((now_ms - vec_it->timestamp_ms()) <= kGetSourcesTimeoutMs) { |
554 break; | 549 break; |
555 } | 550 } |
556 } | 551 } |
557 ssrc_sources_.erase(ssrc_sources_.begin(), vec_it); | 552 ssrc_sources_.erase(ssrc_sources_.begin(), vec_it); |
558 } | 553 } |
559 | 554 |
560 } // namespace webrtc | 555 } // namespace webrtc |
OLD | NEW |