Chromium Code Reviews| 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...) Expand 10 before | Expand all | Expand 10 after 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 int64_t now_ms = clock_->TimeInMilliseconds(); | 214 rtc::CritScope lock(&critical_section_rtp_receiver_); |
| 215 std::vector<RtpSource> sources; | |
| 216 | 215 |
| 217 { | 216 int64_t now_ms = clock_->TimeInMilliseconds(); |
| 218 rtc::CritScope lock(&critical_section_rtp_receiver_); | 217 std::vector<RtpSource> sources; |
| 219 | 218 |
| 220 RTC_DCHECK(std::is_sorted(ssrc_sources_.begin(), ssrc_sources_.end(), | 219 RTC_DCHECK(std::is_sorted(ssrc_sources_.begin(), ssrc_sources_.end(), |
| 221 [](const RtpSource& lhs, const RtpSource& rhs) { | 220 [](const RtpSource& lhs, const RtpSource& rhs) { |
| 222 return lhs.timestamp_ms() < rhs.timestamp_ms(); | 221 return lhs.timestamp_ms() < rhs.timestamp_ms(); |
| 223 })); | 222 })); |
| 224 RTC_DCHECK(std::is_sorted(csrc_sources_.begin(), csrc_sources_.end(), | 223 RTC_DCHECK(std::is_sorted(csrc_sources_.begin(), csrc_sources_.end(), |
| 225 [](const RtpSource& lhs, const RtpSource& rhs) { | 224 [](const RtpSource& lhs, const RtpSource& rhs) { |
| 226 return lhs.timestamp_ms() < rhs.timestamp_ms(); | 225 return lhs.timestamp_ms() < rhs.timestamp_ms(); |
| 227 })); | 226 })); |
| 228 | 227 |
| 229 std::set<uint32_t> selected_ssrcs; | 228 std::set<uint32_t> selected_ssrcs; |
| 230 for (auto rit = ssrc_sources_.rbegin(); rit != ssrc_sources_.rend(); | 229 for (auto rit = ssrc_sources_.rbegin(); rit != ssrc_sources_.rend(); |
| 231 ++rit) { | 230 ++rit) { |
| 232 if ((now_ms - rit->timestamp_ms()) > kGetSourcesTimeoutMs) { | 231 if ((now_ms - rit->timestamp_ms()) > kGetSourcesTimeoutMs) { |
| 233 break; | 232 break; |
| 234 } | 233 } |
| 235 if (selected_ssrcs.insert(rit->source_id()).second) { | 234 if (selected_ssrcs.insert(rit->source_id()).second) { |
| 236 sources.push_back(*rit); | 235 sources.push_back(*rit); |
| 237 } | 236 } |
| 238 } | 237 } |
| 239 | 238 |
| 240 for (auto rit = csrc_sources_.rbegin(); rit != csrc_sources_.rend(); | 239 for (auto rit = csrc_sources_.rbegin(); rit != csrc_sources_.rend(); |
| 241 ++rit) { | 240 ++rit) { |
| 242 if ((now_ms - rit->timestamp_ms()) > kGetSourcesTimeoutMs) { | 241 if ((now_ms - rit->timestamp_ms()) > kGetSourcesTimeoutMs) { |
| 243 break; | 242 break; |
| 244 } | 243 } |
| 245 sources.push_back(*rit); | 244 sources.push_back(*rit); |
| 246 } | 245 } |
|
Taylor Brandstetter
2017/04/10 22:35:14
Can remove a level of indentation now.
| |
| 247 } // End critsect. | |
| 248 | |
| 249 return sources; | 246 return sources; |
| 250 } | 247 } |
| 251 | 248 |
| 252 bool RtpReceiverImpl::Timestamp(uint32_t* timestamp) const { | 249 bool RtpReceiverImpl::Timestamp(uint32_t* timestamp) const { |
| 253 rtc::CritScope lock(&critical_section_rtp_receiver_); | 250 rtc::CritScope lock(&critical_section_rtp_receiver_); |
| 254 if (!HaveReceivedFrame()) | 251 if (!HaveReceivedFrame()) |
| 255 return false; | 252 return false; |
| 256 *timestamp = last_received_timestamp_; | 253 *timestamp = last_received_timestamp_; |
| 257 return true; | 254 return true; |
| 258 } | 255 } |
| (...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 551 for (vec_it = ssrc_sources_.begin(); vec_it != ssrc_sources_.end(); | 548 for (vec_it = ssrc_sources_.begin(); vec_it != ssrc_sources_.end(); |
| 552 ++vec_it) { | 549 ++vec_it) { |
| 553 if ((now_ms - vec_it->timestamp_ms()) <= kGetSourcesTimeoutMs) { | 550 if ((now_ms - vec_it->timestamp_ms()) <= kGetSourcesTimeoutMs) { |
| 554 break; | 551 break; |
| 555 } | 552 } |
| 556 } | 553 } |
| 557 ssrc_sources_.erase(ssrc_sources_.begin(), vec_it); | 554 ssrc_sources_.erase(ssrc_sources_.begin(), vec_it); |
| 558 } | 555 } |
| 559 | 556 |
| 560 } // namespace webrtc | 557 } // namespace webrtc |
| OLD | NEW |