Home | History | Annotate | Download | only in video
      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 
     11 #ifndef WEBRTC_VIDEO_REPORT_BLOCK_STATS_H_
     12 #define WEBRTC_VIDEO_REPORT_BLOCK_STATS_H_
     13 
     14 #include <map>
     15 #include <vector>
     16 
     17 #include "webrtc/common_types.h"
     18 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp_defines.h"
     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 
     39   // Returns the total fraction of lost packets (or -1 if less than two report
     40   // blocks have been stored).
     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 
     61 #endif  // WEBRTC_VIDEO_REPORT_BLOCK_STATS_H_
     62 
     63