wu@webrtc.org | 822fbd8 | 2013-08-15 23:38:54 +0000 | [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_INTERFACE_RECEIVE_STATISTICS_H_ |
| 12 | #define WEBRTC_MODULES_RTP_RTCP_INTERFACE_RECEIVE_STATISTICS_H_ |
| 13 | |
stefan@webrtc.org | 286fe0b | 2013-08-21 20:58:21 +0000 | [diff] [blame] | 14 | #include <map> |
| 15 | |
wu@webrtc.org | 822fbd8 | 2013-08-15 23:38:54 +0000 | [diff] [blame] | 16 | #include "webrtc/modules/interface/module.h" |
| 17 | #include "webrtc/modules/interface/module_common_types.h" |
| 18 | #include "webrtc/typedefs.h" |
| 19 | |
| 20 | namespace webrtc { |
| 21 | |
| 22 | class Clock; |
| 23 | |
stefan@webrtc.org | 286fe0b | 2013-08-21 20:58:21 +0000 | [diff] [blame] | 24 | class StreamStatistician { |
wu@webrtc.org | 822fbd8 | 2013-08-15 23:38:54 +0000 | [diff] [blame] | 25 | public: |
stefan@webrtc.org | 286fe0b | 2013-08-21 20:58:21 +0000 | [diff] [blame] | 26 | virtual ~StreamStatistician(); |
| 27 | |
sprang@webrtc.org | 54ae4ff | 2013-12-19 13:26:02 +0000 | [diff] [blame] | 28 | virtual bool GetStatistics(RtcpStatistics* statistics, bool reset) = 0; |
stefan@webrtc.org | 286fe0b | 2013-08-21 20:58:21 +0000 | [diff] [blame] | 29 | virtual void GetDataCounters(uint32_t* bytes_received, |
| 30 | uint32_t* packets_received) const = 0; |
| 31 | virtual uint32_t BitrateReceived() const = 0; |
stefan@webrtc.org | 7bb8f02 | 2013-09-06 13:40:11 +0000 | [diff] [blame] | 32 | |
stefan@webrtc.org | 286fe0b | 2013-08-21 20:58:21 +0000 | [diff] [blame] | 33 | // Resets all statistics. |
| 34 | virtual void ResetStatistics() = 0; |
stefan@webrtc.org | 7bb8f02 | 2013-09-06 13:40:11 +0000 | [diff] [blame] | 35 | |
| 36 | // Returns true if the packet with RTP header |header| is likely to be a |
| 37 | // retransmitted packet, false otherwise. |
| 38 | virtual bool IsRetransmitOfOldPacket(const RTPHeader& header, |
| 39 | int min_rtt) const = 0; |
| 40 | |
| 41 | // Returns true if |sequence_number| is received in order, false otherwise. |
| 42 | virtual bool IsPacketInOrder(uint16_t sequence_number) const = 0; |
stefan@webrtc.org | 286fe0b | 2013-08-21 20:58:21 +0000 | [diff] [blame] | 43 | }; |
| 44 | |
| 45 | typedef std::map<uint32_t, StreamStatistician*> StatisticianMap; |
| 46 | |
| 47 | class ReceiveStatistics : public Module { |
| 48 | public: |
wu@webrtc.org | 822fbd8 | 2013-08-15 23:38:54 +0000 | [diff] [blame] | 49 | virtual ~ReceiveStatistics() {} |
| 50 | |
| 51 | static ReceiveStatistics* Create(Clock* clock); |
| 52 | |
stefan@webrtc.org | 286fe0b | 2013-08-21 20:58:21 +0000 | [diff] [blame] | 53 | // Updates the receive statistics with this packet. |
sprang@webrtc.org | 0e93257 | 2014-01-23 10:00:39 +0000 | [diff] [blame] | 54 | virtual void IncomingPacket(const RTPHeader& rtp_header, |
| 55 | size_t bytes, |
stefan@webrtc.org | 7bb8f02 | 2013-09-06 13:40:11 +0000 | [diff] [blame] | 56 | bool retransmitted) = 0; |
wu@webrtc.org | 822fbd8 | 2013-08-15 23:38:54 +0000 | [diff] [blame] | 57 | |
sprang@webrtc.org | 0e93257 | 2014-01-23 10:00:39 +0000 | [diff] [blame] | 58 | // Increment counter for number of FEC packets received. |
| 59 | virtual void FecPacketReceived(uint32_t ssrc) = 0; |
| 60 | |
stefan@webrtc.org | 286fe0b | 2013-08-21 20:58:21 +0000 | [diff] [blame] | 61 | // Returns a map of all statisticians which have seen an incoming packet |
| 62 | // during the last two seconds. |
| 63 | virtual StatisticianMap GetActiveStatisticians() const = 0; |
wu@webrtc.org | 822fbd8 | 2013-08-15 23:38:54 +0000 | [diff] [blame] | 64 | |
stefan@webrtc.org | 286fe0b | 2013-08-21 20:58:21 +0000 | [diff] [blame] | 65 | // Returns a pointer to the statistician of an ssrc. |
| 66 | virtual StreamStatistician* GetStatistician(uint32_t ssrc) const = 0; |
stefan@webrtc.org | 7bb8f02 | 2013-09-06 13:40:11 +0000 | [diff] [blame] | 67 | |
| 68 | // Sets the max reordering threshold in number of packets. |
| 69 | virtual void SetMaxReorderingThreshold(int max_reordering_threshold) = 0; |
sprang@webrtc.org | 54ae4ff | 2013-12-19 13:26:02 +0000 | [diff] [blame] | 70 | |
| 71 | // Called on new RTCP stats creation. |
| 72 | virtual void RegisterRtcpStatisticsCallback( |
| 73 | RtcpStatisticsCallback* callback) = 0; |
sprang@webrtc.org | 0e93257 | 2014-01-23 10:00:39 +0000 | [diff] [blame] | 74 | |
| 75 | // Called on new RTP stats creation. |
| 76 | virtual void RegisterRtpStatisticsCallback( |
| 77 | StreamDataCountersCallback* callback) = 0; |
wu@webrtc.org | 822fbd8 | 2013-08-15 23:38:54 +0000 | [diff] [blame] | 78 | }; |
stefan@webrtc.org | 286fe0b | 2013-08-21 20:58:21 +0000 | [diff] [blame] | 79 | |
| 80 | class NullReceiveStatistics : public ReceiveStatistics { |
| 81 | public: |
sprang@webrtc.org | 0e93257 | 2014-01-23 10:00:39 +0000 | [diff] [blame] | 82 | virtual void IncomingPacket(const RTPHeader& rtp_header, |
| 83 | size_t bytes, |
stefan@webrtc.org | 7bb8f02 | 2013-09-06 13:40:11 +0000 | [diff] [blame] | 84 | bool retransmitted) OVERRIDE; |
sprang@webrtc.org | 0e93257 | 2014-01-23 10:00:39 +0000 | [diff] [blame] | 85 | virtual void FecPacketReceived(uint32_t ssrc) OVERRIDE; |
stefan@webrtc.org | 286fe0b | 2013-08-21 20:58:21 +0000 | [diff] [blame] | 86 | virtual StatisticianMap GetActiveStatisticians() const OVERRIDE; |
| 87 | virtual StreamStatistician* GetStatistician(uint32_t ssrc) const OVERRIDE; |
| 88 | virtual int32_t TimeUntilNextProcess() OVERRIDE; |
| 89 | virtual int32_t Process() OVERRIDE; |
stefan@webrtc.org | 7bb8f02 | 2013-09-06 13:40:11 +0000 | [diff] [blame] | 90 | virtual void SetMaxReorderingThreshold(int max_reordering_threshold) OVERRIDE; |
sprang@webrtc.org | 54ae4ff | 2013-12-19 13:26:02 +0000 | [diff] [blame] | 91 | virtual void RegisterRtcpStatisticsCallback(RtcpStatisticsCallback* callback) |
| 92 | OVERRIDE; |
sprang@webrtc.org | 0e93257 | 2014-01-23 10:00:39 +0000 | [diff] [blame] | 93 | virtual void RegisterRtpStatisticsCallback( |
| 94 | StreamDataCountersCallback* callback) OVERRIDE; |
stefan@webrtc.org | 286fe0b | 2013-08-21 20:58:21 +0000 | [diff] [blame] | 95 | }; |
| 96 | |
wu@webrtc.org | 822fbd8 | 2013-08-15 23:38:54 +0000 | [diff] [blame] | 97 | } // namespace webrtc |
| 98 | #endif // WEBRTC_MODULES_RTP_RTCP_INTERFACE_RECEIVE_STATISTICS_H_ |