blob: 033ba7deb54c9c4bd8556bc38b48ce56f343763d [file] [log] [blame]
asapersson@webrtc.org823c9b82015-01-08 07:50:56 +00001/*
2 * Copyright (c) 2014 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 VIDEO_REPORT_BLOCK_STATS_H_
12#define VIDEO_REPORT_BLOCK_STATS_H_
asapersson@webrtc.org823c9b82015-01-08 07:50:56 +000013
14#include <map>
15#include <vector>
16
Mirko Bonadei71207422017-09-15 13:58:09 +020017#include "common_types.h" // NOLINT(build/include)
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020018#include "modules/rtp_rtcp/include/rtp_rtcp_defines.h"
asapersson@webrtc.org823c9b82015-01-08 07:50:56 +000019
20namespace webrtc {
21
22// Helper class for rtcp statistics.
23class ReportBlockStats {
24 public:
25 typedef std::map<uint32_t, RTCPReportBlock> ReportBlockMap;
26 typedef std::vector<RTCPReportBlock> ReportBlockVector;
27 ReportBlockStats();
28 ~ReportBlockStats() {}
29
30 // Updates stats and stores report blocks.
31 // Returns an aggregate of the |report_blocks|.
32 RTCPReportBlock AggregateAndStore(const ReportBlockVector& report_blocks);
33
34 // Updates stats and stores report block.
35 void Store(const RtcpStatistics& rtcp_stats,
36 uint32_t remote_ssrc,
37 uint32_t source_ssrc);
38
asapersson@webrtc.orge7358ea2015-01-21 09:00:19 +000039 // Returns the total fraction of lost packets (or -1 if less than two report
40 // blocks have been stored).
asapersson@webrtc.org823c9b82015-01-08 07:50:56 +000041 int FractionLostInPercent() const;
42
43 private:
44 // Updates the total number of packets/lost packets.
45 // Stores the report block.
46 // Returns the number of packets/lost packets since previous report block.
47 void StoreAndAddPacketIncrement(const RTCPReportBlock& report_block,
48 uint32_t* num_sequence_numbers,
49 uint32_t* num_lost_sequence_numbers);
50
51 // The total number of packets/lost packets.
52 uint32_t num_sequence_numbers_;
53 uint32_t num_lost_sequence_numbers_;
54
55 // Map holding the last stored report block (mapped by the source SSRC).
56 ReportBlockMap prev_report_blocks_;
57};
58
59} // namespace webrtc
60
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020061#endif // VIDEO_REPORT_BLOCK_STATS_H_
asapersson@webrtc.org823c9b82015-01-08 07:50:56 +000062