report_block_stats.h 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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. #ifndef VIDEO_REPORT_BLOCK_STATS_H_
  11. #define VIDEO_REPORT_BLOCK_STATS_H_
  12. #include <stdint.h>
  13. #include <map>
  14. #include "modules/rtp_rtcp/include/rtcp_statistics.h"
  15. namespace webrtc {
  16. // TODO(nisse): Usefulness of this class is somewhat unclear. The inputs are
  17. // cumulative counters, from which we compute deltas, and then accumulate the
  18. // deltas. May be needed on the send side, to handle wraparound in the short
  19. // counters received over RTCP, but should not be needed on the receive side
  20. // where we can use large enough types for all counters we need.
  21. // Helper class for rtcp statistics.
  22. class ReportBlockStats {
  23. public:
  24. ReportBlockStats();
  25. ~ReportBlockStats();
  26. // Updates stats and stores report block.
  27. void Store(uint32_t ssrc, const RtcpStatistics& rtcp_stats);
  28. // Returns the total fraction of lost packets (or -1 if less than two report
  29. // blocks have been stored).
  30. int FractionLostInPercent() const;
  31. private:
  32. // The information from an RTCP report block that we need.
  33. struct Report {
  34. uint32_t extended_highest_sequence_number;
  35. int32_t packets_lost;
  36. };
  37. // Updates the total number of packets/lost packets.
  38. // Stores the report.
  39. void StoreAndAddPacketIncrement(uint32_t ssrc, const Report& report);
  40. // The total number of packets/lost packets.
  41. uint32_t num_sequence_numbers_;
  42. uint32_t num_lost_sequence_numbers_;
  43. // Map holding the last stored report (mapped by the source SSRC).
  44. std::map<uint32_t, Report> prev_reports_;
  45. };
  46. } // namespace webrtc
  47. #endif // VIDEO_REPORT_BLOCK_STATS_H_