Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 |
| 11 #include "webrtc/modules/rtp_rtcp/source/receive_statistics_impl.h" | 11 #include "webrtc/modules/rtp_rtcp/source/receive_statistics_impl.h" |
| 12 | 12 |
| 13 #include <math.h> | 13 #include <math.h> |
| 14 | 14 |
| 15 #include <cstdlib> | 15 #include <cstdlib> |
| 16 #include <vector> | |
| 16 | 17 |
| 17 #include "webrtc/modules/remote_bitrate_estimator/test/bwe_test_logging.h" | 18 #include "webrtc/modules/remote_bitrate_estimator/test/bwe_test_logging.h" |
| 18 #include "webrtc/modules/rtp_rtcp/source/rtp_rtcp_config.h" | 19 #include "webrtc/modules/rtp_rtcp/source/rtp_rtcp_config.h" |
| 19 #include "webrtc/modules/rtp_rtcp/source/time_util.h" | 20 #include "webrtc/modules/rtp_rtcp/source/time_util.h" |
| 21 #include "webrtc/rtc_base/logging.h" | |
| 20 #include "webrtc/system_wrappers/include/clock.h" | 22 #include "webrtc/system_wrappers/include/clock.h" |
| 21 | 23 |
| 22 namespace webrtc { | 24 namespace webrtc { |
| 23 | 25 |
| 24 const int64_t kStatisticsTimeoutMs = 8000; | 26 const int64_t kStatisticsTimeoutMs = 8000; |
| 25 const int64_t kStatisticsProcessIntervalMs = 1000; | 27 const int64_t kStatisticsProcessIntervalMs = 1000; |
| 26 | 28 |
| 27 StreamStatistician::~StreamStatistician() {} | 29 StreamStatistician::~StreamStatistician() {} |
| 28 | 30 |
| 29 StreamStatisticianImpl::StreamStatisticianImpl( | 31 StreamStatisticianImpl::StreamStatisticianImpl( |
| (...skipping 455 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 485 } | 487 } |
| 486 | 488 |
| 487 void ReceiveStatisticsImpl::DataCountersUpdated(const StreamDataCounters& stats, | 489 void ReceiveStatisticsImpl::DataCountersUpdated(const StreamDataCounters& stats, |
| 488 uint32_t ssrc) { | 490 uint32_t ssrc) { |
| 489 rtc::CritScope cs(&receive_statistics_lock_); | 491 rtc::CritScope cs(&receive_statistics_lock_); |
| 490 if (rtp_stats_callback_) { | 492 if (rtp_stats_callback_) { |
| 491 rtp_stats_callback_->DataCountersUpdated(stats, ssrc); | 493 rtp_stats_callback_->DataCountersUpdated(stats, ssrc); |
| 492 } | 494 } |
| 493 } | 495 } |
| 494 | 496 |
| 497 std::vector<rtcp::ReportBlock> ReceiveStatistics::RtcpReportBlocks( | |
| 498 size_t max_blocks) { | |
| 499 StatisticianMap statisticians = GetActiveStatisticians(); | |
| 500 std::vector<rtcp::ReportBlock> result; | |
| 501 result.reserve(std::min(max_blocks, statisticians.size())); | |
| 502 for (auto& statistician : statisticians) { | |
| 503 // TODO(danilchap): Select statistician subset across multiple calls using | |
| 504 // round-robin, as described in rfc3550 section 6.4 when single | |
| 505 // rtcp_module/receive_statistics will be used for more rtp streams. | |
| 506 if (result.size() == max_blocks) | |
| 507 break; | |
| 508 | |
| 509 // Do we have receive statistics to send? | |
| 510 RtcpStatistics stats; | |
| 511 if (!statistician.second->GetStatistics(&stats, true)) | |
| 512 continue; | |
| 513 result.emplace_back(); | |
| 514 rtcp::ReportBlock& block = result.back(); | |
| 515 block.SetMediaSsrc(statistician.first); | |
| 516 block.SetFractionLost(stats.fraction_lost); | |
| 517 if (!block.SetCumulativeLost(stats.cumulative_lost)) { | |
| 518 LOG(LS_WARNING) << "Cumulative lost is oversized."; | |
|
eladalon
2017/07/27 09:07:31
Would logging the value be useful?
danilchap
2017/07/27 10:04:32
may be. I have a TODO in ReceiveStatistics to hand
| |
| 519 result.pop_back(); | |
| 520 continue; | |
| 521 } | |
| 522 block.SetExtHighestSeqNum(stats.extended_max_sequence_number); | |
| 523 block.SetJitter(stats.jitter); | |
| 524 } | |
| 525 return result; | |
| 526 } | |
| 527 | |
| 495 void NullReceiveStatistics::IncomingPacket(const RTPHeader& rtp_header, | 528 void NullReceiveStatistics::IncomingPacket(const RTPHeader& rtp_header, |
| 496 size_t packet_length, | 529 size_t packet_length, |
| 497 bool retransmitted) {} | 530 bool retransmitted) {} |
| 498 | 531 |
| 499 void NullReceiveStatistics::FecPacketReceived(const RTPHeader& header, | 532 void NullReceiveStatistics::FecPacketReceived(const RTPHeader& header, |
| 500 size_t packet_length) {} | 533 size_t packet_length) {} |
| 501 | 534 |
| 502 StatisticianMap NullReceiveStatistics::GetActiveStatisticians() const { | 535 StatisticianMap NullReceiveStatistics::GetActiveStatisticians() const { |
| 503 return StatisticianMap(); | 536 return StatisticianMap(); |
| 504 } | 537 } |
| 505 | 538 |
| 506 StreamStatistician* NullReceiveStatistics::GetStatistician( | 539 StreamStatistician* NullReceiveStatistics::GetStatistician( |
| 507 uint32_t ssrc) const { | 540 uint32_t ssrc) const { |
| 508 return NULL; | 541 return NULL; |
| 509 } | 542 } |
| 510 | 543 |
| 511 void NullReceiveStatistics::SetMaxReorderingThreshold( | 544 void NullReceiveStatistics::SetMaxReorderingThreshold( |
| 512 int max_reordering_threshold) {} | 545 int max_reordering_threshold) {} |
| 513 | 546 |
| 514 void NullReceiveStatistics::RegisterRtcpStatisticsCallback( | 547 void NullReceiveStatistics::RegisterRtcpStatisticsCallback( |
| 515 RtcpStatisticsCallback* callback) {} | 548 RtcpStatisticsCallback* callback) {} |
| 516 | 549 |
| 517 void NullReceiveStatistics::RegisterRtpStatisticsCallback( | 550 void NullReceiveStatistics::RegisterRtpStatisticsCallback( |
| 518 StreamDataCountersCallback* callback) {} | 551 StreamDataCountersCallback* callback) {} |
| 519 | 552 |
| 520 } // namespace webrtc | 553 } // namespace webrtc |
| OLD | NEW |