1 /* 2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. 3 * 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 6 * tree. An additional intellectual property rights grant can be found 7 * in the file PATENTS. All contributing project authors may 8 * be found in the AUTHORS file in the root of the source tree. 9 */ 10 11 #ifndef MODULES_RTP_RTCP_INCLUDE_RECEIVE_STATISTICS_H_ 12 #define MODULES_RTP_RTCP_INCLUDE_RECEIVE_STATISTICS_H_ 13 14 #include <map> 15 #include <memory> 16 #include <vector> 17 18 #include "absl/types/optional.h" 19 #include "call/rtp_packet_sink_interface.h" 20 #include "modules/include/module.h" 21 #include "modules/rtp_rtcp/include/rtcp_statistics.h" 22 #include "modules/rtp_rtcp/include/rtp_rtcp_defines.h" 23 #include "modules/rtp_rtcp/source/rtcp_packet/report_block.h" 24 #include "rtc_base/deprecation.h" 25 26 namespace webrtc { 27 28 class Clock; 29 30 class ReceiveStatisticsProvider { 31 public: 32 virtual ~ReceiveStatisticsProvider() = default; 33 // Collects receive statistic in a form of rtcp report blocks. 34 // Returns at most |max_blocks| report blocks. 35 virtual std::vector<rtcp::ReportBlock> RtcpReportBlocks( 36 size_t max_blocks) = 0; 37 }; 38 39 class StreamStatistician { 40 public: 41 virtual ~StreamStatistician(); 42 43 virtual RtpReceiveStats GetStats() const = 0; 44 45 // Returns average over the stream life time. 46 virtual absl::optional<int> GetFractionLostInPercent() const = 0; 47 48 // TODO(nisse): Delete, migrate users to the above the GetStats method. 49 // Gets received stream data counters (includes reset counter values). 50 virtual StreamDataCounters GetReceiveStreamDataCounters() const = 0; 51 52 virtual uint32_t BitrateReceived() const = 0; 53 }; 54 55 class ReceiveStatistics : public ReceiveStatisticsProvider, 56 public RtpPacketSinkInterface { 57 public: 58 ~ReceiveStatistics() override = default; 59 60 static std::unique_ptr<ReceiveStatistics> Create(Clock* clock); 61 62 // Returns a pointer to the statistician of an ssrc. 63 virtual StreamStatistician* GetStatistician(uint32_t ssrc) const = 0; 64 65 // TODO(bugs.webrtc.org/10669): Deprecated, delete as soon as downstream 66 // projects are updated. This method sets the max reordering threshold of all 67 // current and future streams. 68 virtual void SetMaxReorderingThreshold(int max_reordering_threshold) = 0; 69 70 // Sets the max reordering threshold in number of packets. 71 virtual void SetMaxReorderingThreshold(uint32_t ssrc, 72 int max_reordering_threshold) = 0; 73 // Detect retransmissions, enabling updates of the retransmitted counters. The 74 // default is false. 75 virtual void EnableRetransmitDetection(uint32_t ssrc, bool enable) = 0; 76 }; 77 78 } // namespace webrtc 79 #endif // MODULES_RTP_RTCP_INCLUDE_RECEIVE_STATISTICS_H_ 80