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 #ifndef WEBRTC_MODULES_RTP_RTCP_INCLUDE_RECEIVE_STATISTICS_H_ | 11 #ifndef WEBRTC_MODULES_RTP_RTCP_INCLUDE_RECEIVE_STATISTICS_H_ |
12 #define WEBRTC_MODULES_RTP_RTCP_INCLUDE_RECEIVE_STATISTICS_H_ | 12 #define WEBRTC_MODULES_RTP_RTCP_INCLUDE_RECEIVE_STATISTICS_H_ |
13 | 13 |
14 #include <map> | 14 #include <map> |
| 15 #include <vector> |
15 | 16 |
16 #include "webrtc/modules/include/module.h" | 17 #include "webrtc/modules/include/module.h" |
17 #include "webrtc/modules/include/module_common_types.h" | 18 #include "webrtc/modules/include/module_common_types.h" |
| 19 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/report_block.h" |
18 #include "webrtc/typedefs.h" | 20 #include "webrtc/typedefs.h" |
19 | 21 |
20 namespace webrtc { | 22 namespace webrtc { |
21 | 23 |
22 class Clock; | 24 class Clock; |
23 | 25 |
| 26 class ReceiveStatisticsReporter { |
| 27 public: |
| 28 // Fill in statistic fields of the rtcp report blocks for the active ssrcs. |
| 29 // (i.e. everything except last_sr/delay_since_last_sr fields) |
| 30 virtual std::vector<rtcp::ReportBlock> GetActiveStatistics() = 0; |
| 31 |
| 32 protected: |
| 33 ~ReceiveStatisticsReporter() = default; |
| 34 }; |
| 35 |
24 class StreamStatistician { | 36 class StreamStatistician { |
25 public: | 37 public: |
26 virtual ~StreamStatistician(); | 38 virtual ~StreamStatistician(); |
27 | 39 |
28 virtual bool GetStatistics(RtcpStatistics* statistics, bool reset) = 0; | 40 virtual bool GetStatistics(RtcpStatistics* statistics, bool reset) = 0; |
29 virtual void GetDataCounters(size_t* bytes_received, | 41 virtual void GetDataCounters(size_t* bytes_received, |
30 uint32_t* packets_received) const = 0; | 42 uint32_t* packets_received) const = 0; |
31 | 43 |
32 // Gets received stream data counters (includes reset counter values). | 44 // Gets received stream data counters (includes reset counter values). |
33 virtual void GetReceiveStreamDataCounters( | 45 virtual void GetReceiveStreamDataCounters( |
34 StreamDataCounters* data_counters) const = 0; | 46 StreamDataCounters* data_counters) const = 0; |
35 | 47 |
36 virtual uint32_t BitrateReceived() const = 0; | 48 virtual uint32_t BitrateReceived() const = 0; |
37 | 49 |
38 // Returns true if the packet with RTP header |header| is likely to be a | 50 // Returns true if the packet with RTP header |header| is likely to be a |
39 // retransmitted packet, false otherwise. | 51 // retransmitted packet, false otherwise. |
40 virtual bool IsRetransmitOfOldPacket(const RTPHeader& header, | 52 virtual bool IsRetransmitOfOldPacket(const RTPHeader& header, |
41 int64_t min_rtt) const = 0; | 53 int64_t min_rtt) const = 0; |
42 | 54 |
43 // Returns true if |sequence_number| is received in order, false otherwise. | 55 // Returns true if |sequence_number| is received in order, false otherwise. |
44 virtual bool IsPacketInOrder(uint16_t sequence_number) const = 0; | 56 virtual bool IsPacketInOrder(uint16_t sequence_number) const = 0; |
45 }; | 57 }; |
46 | 58 |
47 typedef std::map<uint32_t, StreamStatistician*> StatisticianMap; | 59 typedef std::map<uint32_t, StreamStatistician*> StatisticianMap; |
48 | 60 |
49 class ReceiveStatistics { | 61 class ReceiveStatistics : public ReceiveStatisticsReporter { |
50 public: | 62 public: |
51 virtual ~ReceiveStatistics() {} | 63 virtual ~ReceiveStatistics() {} |
52 | 64 |
53 static ReceiveStatistics* Create(Clock* clock); | 65 static ReceiveStatistics* Create(Clock* clock); |
54 | 66 |
55 // Updates the receive statistics with this packet. | 67 // Updates the receive statistics with this packet. |
56 virtual void IncomingPacket(const RTPHeader& rtp_header, | 68 virtual void IncomingPacket(const RTPHeader& rtp_header, |
57 size_t packet_length, | 69 size_t packet_length, |
58 bool retransmitted) = 0; | 70 bool retransmitted) = 0; |
59 | 71 |
(...skipping 11 matching lines...) Expand all Loading... |
71 // Sets the max reordering threshold in number of packets. | 83 // Sets the max reordering threshold in number of packets. |
72 virtual void SetMaxReorderingThreshold(int max_reordering_threshold) = 0; | 84 virtual void SetMaxReorderingThreshold(int max_reordering_threshold) = 0; |
73 | 85 |
74 // Called on new RTCP stats creation. | 86 // Called on new RTCP stats creation. |
75 virtual void RegisterRtcpStatisticsCallback( | 87 virtual void RegisterRtcpStatisticsCallback( |
76 RtcpStatisticsCallback* callback) = 0; | 88 RtcpStatisticsCallback* callback) = 0; |
77 | 89 |
78 // Called on new RTP stats creation. | 90 // Called on new RTP stats creation. |
79 virtual void RegisterRtpStatisticsCallback( | 91 virtual void RegisterRtpStatisticsCallback( |
80 StreamDataCountersCallback* callback) = 0; | 92 StreamDataCountersCallback* callback) = 0; |
| 93 |
| 94 // TODO(danilchap): Remove other accessors and make this one pure virtual. |
| 95 std::vector<rtcp::ReportBlock> GetActiveStatistics() override; |
81 }; | 96 }; |
82 | 97 |
83 class NullReceiveStatistics : public ReceiveStatistics { | 98 class NullReceiveStatistics : public ReceiveStatistics { |
84 public: | 99 public: |
85 void IncomingPacket(const RTPHeader& rtp_header, | 100 void IncomingPacket(const RTPHeader& rtp_header, |
86 size_t packet_length, | 101 size_t packet_length, |
87 bool retransmitted) override; | 102 bool retransmitted) override; |
88 void FecPacketReceived(const RTPHeader& header, | 103 void FecPacketReceived(const RTPHeader& header, |
89 size_t packet_length) override; | 104 size_t packet_length) override; |
90 StatisticianMap GetActiveStatisticians() const override; | 105 StatisticianMap GetActiveStatisticians() const override; |
91 StreamStatistician* GetStatistician(uint32_t ssrc) const override; | 106 StreamStatistician* GetStatistician(uint32_t ssrc) const override; |
92 void SetMaxReorderingThreshold(int max_reordering_threshold) override; | 107 void SetMaxReorderingThreshold(int max_reordering_threshold) override; |
93 void RegisterRtcpStatisticsCallback( | 108 void RegisterRtcpStatisticsCallback( |
94 RtcpStatisticsCallback* callback) override; | 109 RtcpStatisticsCallback* callback) override; |
95 void RegisterRtpStatisticsCallback( | 110 void RegisterRtpStatisticsCallback( |
96 StreamDataCountersCallback* callback) override; | 111 StreamDataCountersCallback* callback) override; |
97 }; | 112 }; |
98 | 113 |
99 } // namespace webrtc | 114 } // namespace webrtc |
100 #endif // WEBRTC_MODULES_RTP_RTCP_INCLUDE_RECEIVE_STATISTICS_H_ | 115 #endif // WEBRTC_MODULES_RTP_RTCP_INCLUDE_RECEIVE_STATISTICS_H_ |
OLD | NEW |