Henrik Kjellander | ff761fb | 2015-11-04 08:31:52 +0100 | [diff] [blame] | 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 | |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 11 | #ifndef MODULES_RTP_RTCP_INCLUDE_RECEIVE_STATISTICS_H_ |
| 12 | #define MODULES_RTP_RTCP_INCLUDE_RECEIVE_STATISTICS_H_ |
Henrik Kjellander | ff761fb | 2015-11-04 08:31:52 +0100 | [diff] [blame] | 13 | |
| 14 | #include <map> |
danilchap | f5f793c | 2017-07-27 04:44:18 -0700 | [diff] [blame] | 15 | #include <vector> |
Henrik Kjellander | ff761fb | 2015-11-04 08:31:52 +0100 | [diff] [blame] | 16 | |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 17 | #include "modules/include/module.h" |
| 18 | #include "modules/include/module_common_types.h" |
| 19 | #include "modules/rtp_rtcp/source/rtcp_packet/report_block.h" |
Mirko Bonadei | 7120742 | 2017-09-15 13:58:09 +0200 | [diff] [blame] | 20 | #include "typedefs.h" // NOLINT(build/include) |
Henrik Kjellander | ff761fb | 2015-11-04 08:31:52 +0100 | [diff] [blame] | 21 | |
| 22 | namespace webrtc { |
| 23 | |
| 24 | class Clock; |
| 25 | |
danilchap | f5f793c | 2017-07-27 04:44:18 -0700 | [diff] [blame] | 26 | class ReceiveStatisticsProvider { |
| 27 | public: |
| 28 | virtual ~ReceiveStatisticsProvider() = default; |
| 29 | // Collects receive statistic in a form of rtcp report blocks. |
| 30 | // Returns at most |max_blocks| report blocks. |
| 31 | virtual std::vector<rtcp::ReportBlock> RtcpReportBlocks( |
| 32 | size_t max_blocks) = 0; |
| 33 | }; |
| 34 | |
Henrik Kjellander | ff761fb | 2015-11-04 08:31:52 +0100 | [diff] [blame] | 35 | class StreamStatistician { |
| 36 | public: |
| 37 | virtual ~StreamStatistician(); |
| 38 | |
| 39 | virtual bool GetStatistics(RtcpStatistics* statistics, bool reset) = 0; |
| 40 | virtual void GetDataCounters(size_t* bytes_received, |
| 41 | uint32_t* packets_received) const = 0; |
| 42 | |
| 43 | // Gets received stream data counters (includes reset counter values). |
| 44 | virtual void GetReceiveStreamDataCounters( |
| 45 | StreamDataCounters* data_counters) const = 0; |
| 46 | |
| 47 | virtual uint32_t BitrateReceived() const = 0; |
| 48 | |
| 49 | // Returns true if the packet with RTP header |header| is likely to be a |
| 50 | // retransmitted packet, false otherwise. |
| 51 | virtual bool IsRetransmitOfOldPacket(const RTPHeader& header, |
| 52 | int64_t min_rtt) const = 0; |
| 53 | |
| 54 | // Returns true if |sequence_number| is received in order, false otherwise. |
| 55 | virtual bool IsPacketInOrder(uint16_t sequence_number) const = 0; |
| 56 | }; |
| 57 | |
danilchap | f5f793c | 2017-07-27 04:44:18 -0700 | [diff] [blame] | 58 | class ReceiveStatistics : public ReceiveStatisticsProvider { |
Henrik Kjellander | ff761fb | 2015-11-04 08:31:52 +0100 | [diff] [blame] | 59 | public: |
danilchap | f5f793c | 2017-07-27 04:44:18 -0700 | [diff] [blame] | 60 | ~ReceiveStatistics() override = default; |
Henrik Kjellander | ff761fb | 2015-11-04 08:31:52 +0100 | [diff] [blame] | 61 | |
| 62 | static ReceiveStatistics* Create(Clock* clock); |
| 63 | |
| 64 | // Updates the receive statistics with this packet. |
| 65 | virtual void IncomingPacket(const RTPHeader& rtp_header, |
| 66 | size_t packet_length, |
| 67 | bool retransmitted) = 0; |
| 68 | |
| 69 | // Increment counter for number of FEC packets received. |
| 70 | virtual void FecPacketReceived(const RTPHeader& header, |
| 71 | size_t packet_length) = 0; |
| 72 | |
Henrik Kjellander | ff761fb | 2015-11-04 08:31:52 +0100 | [diff] [blame] | 73 | // Returns a pointer to the statistician of an ssrc. |
| 74 | virtual StreamStatistician* GetStatistician(uint32_t ssrc) const = 0; |
| 75 | |
| 76 | // Sets the max reordering threshold in number of packets. |
| 77 | virtual void SetMaxReorderingThreshold(int max_reordering_threshold) = 0; |
| 78 | |
| 79 | // Called on new RTCP stats creation. |
| 80 | virtual void RegisterRtcpStatisticsCallback( |
| 81 | RtcpStatisticsCallback* callback) = 0; |
| 82 | |
| 83 | // Called on new RTP stats creation. |
| 84 | virtual void RegisterRtpStatisticsCallback( |
| 85 | StreamDataCountersCallback* callback) = 0; |
| 86 | }; |
| 87 | |
Henrik Kjellander | ff761fb | 2015-11-04 08:31:52 +0100 | [diff] [blame] | 88 | } // namespace webrtc |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 89 | #endif // MODULES_RTP_RTCP_INCLUDE_RECEIVE_STATISTICS_H_ |