Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(74)

Side by Side Diff: webrtc/modules/rtp_rtcp/source/receive_statistics_impl.cc

Issue 2984973002: Shrink critical-section scope in ReceiveStatisticsImpl::GetActiveStatisticians() (Closed)
Patch Set: Created 3 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2013 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 404 matching lines...) Expand 10 before | Expand all | Expand 10 after
415 size_t packet_length) { 415 size_t packet_length) {
416 rtc::CritScope cs(&receive_statistics_lock_); 416 rtc::CritScope cs(&receive_statistics_lock_);
417 StatisticianImplMap::iterator it = statisticians_.find(header.ssrc); 417 StatisticianImplMap::iterator it = statisticians_.find(header.ssrc);
418 // Ignore FEC if it is the first packet. 418 // Ignore FEC if it is the first packet.
419 if (it != statisticians_.end()) { 419 if (it != statisticians_.end()) {
420 it->second->FecPacketReceived(header, packet_length); 420 it->second->FecPacketReceived(header, packet_length);
421 } 421 }
422 } 422 }
423 423
424 StatisticianMap ReceiveStatisticsImpl::GetActiveStatisticians() const { 424 StatisticianMap ReceiveStatisticsImpl::GetActiveStatisticians() const {
425 rtc::CritScope cs(&receive_statistics_lock_);
426 StatisticianMap active_statisticians; 425 StatisticianMap active_statisticians;
427 for (StatisticianImplMap::const_iterator it = statisticians_.begin(); 426
428 it != statisticians_.end(); ++it) { 427 {
danilchap 2017/07/25 14:05:41 I think extra indentation make it less readable. s
eladalon 2017/07/25 14:28:49 I'm not sure I don't need this - I am not familiar
429 uint32_t secs; 428 rtc::CritScope cs(&receive_statistics_lock_);
430 uint32_t frac; 429 for (StatisticianImplMap::const_iterator it = statisticians_.begin();
431 it->second->LastReceiveTimeNtp(&secs, &frac); 430 it != statisticians_.end(); ++it) {
432 if (clock_->CurrentNtpInMilliseconds() - 431 uint32_t secs;
433 Clock::NtpToMs(secs, frac) < kStatisticsTimeoutMs) { 432 uint32_t frac;
434 active_statisticians[it->first] = it->second; 433 it->second->LastReceiveTimeNtp(&secs, &frac);
434 if (clock_->CurrentNtpInMilliseconds() -
435 Clock::NtpToMs(secs, frac) < kStatisticsTimeoutMs) {
436 active_statisticians[it->first] = it->second;
437 }
435 } 438 }
436 } 439 }
440
437 return active_statisticians; 441 return active_statisticians;
438 } 442 }
439 443
440 StreamStatistician* ReceiveStatisticsImpl::GetStatistician( 444 StreamStatistician* ReceiveStatisticsImpl::GetStatistician(
441 uint32_t ssrc) const { 445 uint32_t ssrc) const {
442 rtc::CritScope cs(&receive_statistics_lock_); 446 rtc::CritScope cs(&receive_statistics_lock_);
443 StatisticianImplMap::const_iterator it = statisticians_.find(ssrc); 447 StatisticianImplMap::const_iterator it = statisticians_.find(ssrc);
444 if (it == statisticians_.end()) 448 if (it == statisticians_.end())
445 return NULL; 449 return NULL;
446 return it->second; 450 return it->second;
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
511 void NullReceiveStatistics::SetMaxReorderingThreshold( 515 void NullReceiveStatistics::SetMaxReorderingThreshold(
512 int max_reordering_threshold) {} 516 int max_reordering_threshold) {}
513 517
514 void NullReceiveStatistics::RegisterRtcpStatisticsCallback( 518 void NullReceiveStatistics::RegisterRtcpStatisticsCallback(
515 RtcpStatisticsCallback* callback) {} 519 RtcpStatisticsCallback* callback) {}
516 520
517 void NullReceiveStatistics::RegisterRtpStatisticsCallback( 521 void NullReceiveStatistics::RegisterRtpStatisticsCallback(
518 StreamDataCountersCallback* callback) {} 522 StreamDataCountersCallback* callback) {}
519 523
520 } // namespace webrtc 524 } // namespace webrtc
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698