blob: 331c0b6cf137ad76f2904b1f5676bea4d922ab4c [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
Yves Gerey3e707812018-11-28 16:47:49 +010014#include <stdint.h>
asapersson@webrtc.org823c9b82015-01-08 07:50:56 +000015#include <map>
16#include <vector>
17
Niels Möller53382cb2018-11-27 14:05:08 +010018#include "modules/rtp_rtcp/include/rtcp_statistics.h"
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020019#include "modules/rtp_rtcp/include/rtp_rtcp_defines.h"
asapersson@webrtc.org823c9b82015-01-08 07:50:56 +000020
21namespace webrtc {
22
23// Helper class for rtcp statistics.
24class ReportBlockStats {
25 public:
26 typedef std::map<uint32_t, RTCPReportBlock> ReportBlockMap;
27 typedef std::vector<RTCPReportBlock> ReportBlockVector;
28 ReportBlockStats();
Stefan Holmerdbdb3a02018-07-17 16:03:46 +020029 ~ReportBlockStats();
asapersson@webrtc.org823c9b82015-01-08 07:50:56 +000030
31 // Updates stats and stores report blocks.
32 // Returns an aggregate of the |report_blocks|.
33 RTCPReportBlock AggregateAndStore(const ReportBlockVector& report_blocks);
34
35 // Updates stats and stores report block.
36 void Store(const RtcpStatistics& rtcp_stats,
37 uint32_t remote_ssrc,
38 uint32_t source_ssrc);
39
asapersson@webrtc.orge7358ea2015-01-21 09:00:19 +000040 // Returns the total fraction of lost packets (or -1 if less than two report
41 // blocks have been stored).
asapersson@webrtc.org823c9b82015-01-08 07:50:56 +000042 int FractionLostInPercent() const;
43
44 private:
45 // Updates the total number of packets/lost packets.
46 // Stores the report block.
47 // Returns the number of packets/lost packets since previous report block.
48 void StoreAndAddPacketIncrement(const RTCPReportBlock& report_block,
49 uint32_t* num_sequence_numbers,
50 uint32_t* num_lost_sequence_numbers);
51
52 // The total number of packets/lost packets.
53 uint32_t num_sequence_numbers_;
54 uint32_t num_lost_sequence_numbers_;
55
56 // Map holding the last stored report block (mapped by the source SSRC).
57 ReportBlockMap prev_report_blocks_;
58};
59
60} // namespace webrtc
61
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020062#endif // VIDEO_REPORT_BLOCK_STATS_H_