asapersson@webrtc.org | 823c9b8 | 2015-01-08 07:50:56 +0000 | [diff] [blame] | 1 | /* |
| 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 Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 11 | #ifndef VIDEO_REPORT_BLOCK_STATS_H_ |
| 12 | #define VIDEO_REPORT_BLOCK_STATS_H_ |
asapersson@webrtc.org | 823c9b8 | 2015-01-08 07:50:56 +0000 | [diff] [blame] | 13 | |
Yves Gerey | 3e70781 | 2018-11-28 16:47:49 +0100 | [diff] [blame] | 14 | #include <stdint.h> |
asapersson@webrtc.org | 823c9b8 | 2015-01-08 07:50:56 +0000 | [diff] [blame] | 15 | #include <map> |
| 16 | #include <vector> |
| 17 | |
Niels Möller | 53382cb | 2018-11-27 14:05:08 +0100 | [diff] [blame] | 18 | #include "modules/rtp_rtcp/include/rtcp_statistics.h" |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 19 | #include "modules/rtp_rtcp/include/rtp_rtcp_defines.h" |
asapersson@webrtc.org | 823c9b8 | 2015-01-08 07:50:56 +0000 | [diff] [blame] | 20 | |
| 21 | namespace webrtc { |
| 22 | |
| 23 | // Helper class for rtcp statistics. |
| 24 | class ReportBlockStats { |
| 25 | public: |
| 26 | typedef std::map<uint32_t, RTCPReportBlock> ReportBlockMap; |
| 27 | typedef std::vector<RTCPReportBlock> ReportBlockVector; |
| 28 | ReportBlockStats(); |
Stefan Holmer | dbdb3a0 | 2018-07-17 16:03:46 +0200 | [diff] [blame] | 29 | ~ReportBlockStats(); |
asapersson@webrtc.org | 823c9b8 | 2015-01-08 07:50:56 +0000 | [diff] [blame] | 30 | |
| 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.org | e7358ea | 2015-01-21 09:00:19 +0000 | [diff] [blame] | 40 | // Returns the total fraction of lost packets (or -1 if less than two report |
| 41 | // blocks have been stored). |
asapersson@webrtc.org | 823c9b8 | 2015-01-08 07:50:56 +0000 | [diff] [blame] | 42 | 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 Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 62 | #endif // VIDEO_REPORT_BLOCK_STATS_H_ |