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::GetActiveStatistics() { |
| 498 std::vector<rtcp::ReportBlock> result; |
| 499 for (auto& statistician : GetActiveStatisticians()) { |
| 500 rtcp::ReportBlock block; |
| 501 block.SetMediaSsrc(statistician.first); |
| 502 RtcpStatistics stats; |
| 503 if (!statistician.second->GetStatistics(&stats, true)) |
| 504 continue; |
| 505 block.SetFractionLost(stats.fraction_lost); |
| 506 if (!block.SetCumulativeLost(stats.cumulative_lost)) { |
| 507 LOG(LS_WARNING) << "Cumulative lost is oversized."; |
| 508 continue; |
| 509 } |
| 510 block.SetExtHighestSeqNum(stats.extended_max_sequence_number); |
| 511 block.SetJitter(stats.jitter); |
| 512 result.push_back(block); |
| 513 } |
| 514 return result; |
| 515 } |
| 516 |
495 void NullReceiveStatistics::IncomingPacket(const RTPHeader& rtp_header, | 517 void NullReceiveStatistics::IncomingPacket(const RTPHeader& rtp_header, |
496 size_t packet_length, | 518 size_t packet_length, |
497 bool retransmitted) {} | 519 bool retransmitted) {} |
498 | 520 |
499 void NullReceiveStatistics::FecPacketReceived(const RTPHeader& header, | 521 void NullReceiveStatistics::FecPacketReceived(const RTPHeader& header, |
500 size_t packet_length) {} | 522 size_t packet_length) {} |
501 | 523 |
502 StatisticianMap NullReceiveStatistics::GetActiveStatisticians() const { | 524 StatisticianMap NullReceiveStatistics::GetActiveStatisticians() const { |
503 return StatisticianMap(); | 525 return StatisticianMap(); |
504 } | 526 } |
505 | 527 |
506 StreamStatistician* NullReceiveStatistics::GetStatistician( | 528 StreamStatistician* NullReceiveStatistics::GetStatistician( |
507 uint32_t ssrc) const { | 529 uint32_t ssrc) const { |
508 return NULL; | 530 return NULL; |
509 } | 531 } |
510 | 532 |
511 void NullReceiveStatistics::SetMaxReorderingThreshold( | 533 void NullReceiveStatistics::SetMaxReorderingThreshold( |
512 int max_reordering_threshold) {} | 534 int max_reordering_threshold) {} |
513 | 535 |
514 void NullReceiveStatistics::RegisterRtcpStatisticsCallback( | 536 void NullReceiveStatistics::RegisterRtcpStatisticsCallback( |
515 RtcpStatisticsCallback* callback) {} | 537 RtcpStatisticsCallback* callback) {} |
516 | 538 |
517 void NullReceiveStatistics::RegisterRtpStatisticsCallback( | 539 void NullReceiveStatistics::RegisterRtpStatisticsCallback( |
518 StreamDataCountersCallback* callback) {} | 540 StreamDataCountersCallback* callback) {} |
519 | 541 |
520 } // namespace webrtc | 542 } // namespace webrtc |
OLD | NEW |