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 | |
Peter Boström | 7623ce4 | 2015-12-09 12:13:30 +0100 | [diff] [blame] | 11 | #ifndef WEBRTC_VIDEO_REPORT_BLOCK_STATS_H_ |
| 12 | #define WEBRTC_VIDEO_REPORT_BLOCK_STATS_H_ |
asapersson@webrtc.org | 823c9b8 | 2015-01-08 07:50:56 +0000 | [diff] [blame] | 13 | |
| 14 | #include <map> |
| 15 | #include <vector> |
| 16 | |
| 17 | #include "webrtc/common_types.h" |
Henrik Kjellander | ff761fb | 2015-11-04 08:31:52 +0100 | [diff] [blame] | 18 | #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp_defines.h" |
asapersson@webrtc.org | 823c9b8 | 2015-01-08 07:50:56 +0000 | [diff] [blame] | 19 | |
| 20 | namespace webrtc { |
| 21 | |
| 22 | // Helper class for rtcp statistics. |
| 23 | class 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.org | e7358ea | 2015-01-21 09:00:19 +0000 | [diff] [blame] | 39 | // Returns the total fraction of lost packets (or -1 if less than two report |
| 40 | // blocks have been stored). |
asapersson@webrtc.org | 823c9b8 | 2015-01-08 07:50:56 +0000 | [diff] [blame] | 41 | 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öm | 7623ce4 | 2015-12-09 12:13:30 +0100 | [diff] [blame] | 61 | #endif // WEBRTC_VIDEO_REPORT_BLOCK_STATS_H_ |
asapersson@webrtc.org | 823c9b8 | 2015-01-08 07:50:56 +0000 | [diff] [blame] | 62 | |