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