blob: ee7dbbbd8d3464ce28b38f3cc7f81d9748c40fda [file] [log] [blame]
Henrik Kjellanderff761fb2015-11-04 08:31:52 +01001/*
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 Bonadei92ea95e2017-09-15 06:47:31 +020011#ifndef MODULES_RTP_RTCP_INCLUDE_RECEIVE_STATISTICS_H_
12#define MODULES_RTP_RTCP_INCLUDE_RECEIVE_STATISTICS_H_
Henrik Kjellanderff761fb2015-11-04 08:31:52 +010013
14#include <map>
danilchapf5f793c2017-07-27 04:44:18 -070015#include <vector>
Henrik Kjellanderff761fb2015-11-04 08:31:52 +010016
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020017#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 Bonadei71207422017-09-15 13:58:09 +020020#include "typedefs.h" // NOLINT(build/include)
Henrik Kjellanderff761fb2015-11-04 08:31:52 +010021
22namespace webrtc {
23
24class Clock;
25
danilchapf5f793c2017-07-27 04:44:18 -070026class 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 Kjellanderff761fb2015-11-04 08:31:52 +010035class 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
danilchapf5f793c2017-07-27 04:44:18 -070058class ReceiveStatistics : public ReceiveStatisticsProvider {
Henrik Kjellanderff761fb2015-11-04 08:31:52 +010059 public:
danilchapf5f793c2017-07-27 04:44:18 -070060 ~ReceiveStatistics() override = default;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +010061
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 Kjellanderff761fb2015-11-04 08:31:52 +010073 // 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 Kjellanderff761fb2015-11-04 08:31:52 +010088} // namespace webrtc
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020089#endif // MODULES_RTP_RTCP_INCLUDE_RECEIVE_STATISTICS_H_