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 | |
| 11 | #ifndef WEBRTC_MODULES_RTP_RTCP_INCLUDE_RECEIVE_STATISTICS_H_ |
| 12 | #define WEBRTC_MODULES_RTP_RTCP_INCLUDE_RECEIVE_STATISTICS_H_ |
| 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 | |
| 17 | #include "webrtc/modules/include/module.h" |
| 18 | #include "webrtc/modules/include/module_common_types.h" |
danilchap | f5f793c | 2017-07-27 04:44:18 -0700 | [diff] [blame] | 19 | #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/report_block.h" |
Henrik Kjellander | ff761fb | 2015-11-04 08:31:52 +0100 | [diff] [blame] | 20 | #include "webrtc/typedefs.h" |
| 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 | |
| 58 | typedef std::map<uint32_t, StreamStatistician*> StatisticianMap; |
| 59 | |
danilchap | f5f793c | 2017-07-27 04:44:18 -0700 | [diff] [blame] | 60 | class ReceiveStatistics : public ReceiveStatisticsProvider { |
Henrik Kjellander | ff761fb | 2015-11-04 08:31:52 +0100 | [diff] [blame] | 61 | public: |
danilchap | f5f793c | 2017-07-27 04:44:18 -0700 | [diff] [blame] | 62 | ~ReceiveStatistics() override = default; |
Henrik Kjellander | ff761fb | 2015-11-04 08:31:52 +0100 | [diff] [blame] | 63 | |
| 64 | static ReceiveStatistics* Create(Clock* clock); |
| 65 | |
| 66 | // Updates the receive statistics with this packet. |
| 67 | virtual void IncomingPacket(const RTPHeader& rtp_header, |
| 68 | size_t packet_length, |
| 69 | bool retransmitted) = 0; |
| 70 | |
| 71 | // Increment counter for number of FEC packets received. |
| 72 | virtual void FecPacketReceived(const RTPHeader& header, |
| 73 | size_t packet_length) = 0; |
| 74 | |
| 75 | // Returns a map of all statisticians which have seen an incoming packet |
| 76 | // during the last two seconds. |
| 77 | virtual StatisticianMap GetActiveStatisticians() const = 0; |
| 78 | |
| 79 | // Returns a pointer to the statistician of an ssrc. |
| 80 | virtual StreamStatistician* GetStatistician(uint32_t ssrc) const = 0; |
| 81 | |
| 82 | // Sets the max reordering threshold in number of packets. |
| 83 | virtual void SetMaxReorderingThreshold(int max_reordering_threshold) = 0; |
| 84 | |
| 85 | // Called on new RTCP stats creation. |
| 86 | virtual void RegisterRtcpStatisticsCallback( |
| 87 | RtcpStatisticsCallback* callback) = 0; |
| 88 | |
| 89 | // Called on new RTP stats creation. |
| 90 | virtual void RegisterRtpStatisticsCallback( |
| 91 | StreamDataCountersCallback* callback) = 0; |
| 92 | }; |
| 93 | |
Henrik Kjellander | ff761fb | 2015-11-04 08:31:52 +0100 | [diff] [blame] | 94 | } // namespace webrtc |
| 95 | #endif // WEBRTC_MODULES_RTP_RTCP_INCLUDE_RECEIVE_STATISTICS_H_ |