blob: c54e4677f4f367ef59690ef8abba623976b3dee8 [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
Peter Boström7623ce42015-12-09 12:13:30 +010011#ifndef WEBRTC_VIDEO_REPORT_BLOCK_STATS_H_
12#define WEBRTC_VIDEO_REPORT_BLOCK_STATS_H_
asapersson@webrtc.org823c9b82015-01-08 07:50:56 +000013
14#include <map>
15#include <vector>
16
17#include "webrtc/common_types.h"
Henrik Kjellanderff761fb2015-11-04 08:31:52 +010018#include "webrtc/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
Peter Boström7623ce42015-12-09 12:13:30 +010061#endif // WEBRTC_VIDEO_REPORT_BLOCK_STATS_H_
asapersson@webrtc.org823c9b82015-01-08 07:50:56 +000062