performance_stats.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. /*
  2. * Copyright 2019 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 TEST_SCENARIO_PERFORMANCE_STATS_H_
  11. #define TEST_SCENARIO_PERFORMANCE_STATS_H_
  12. #include "api/units/data_rate.h"
  13. #include "api/units/time_delta.h"
  14. #include "api/units/timestamp.h"
  15. #include "api/video/video_frame_buffer.h"
  16. #include "rtc_base/numerics/event_rate_counter.h"
  17. #include "rtc_base/numerics/sample_stats.h"
  18. namespace webrtc {
  19. namespace test {
  20. struct VideoFramePair {
  21. rtc::scoped_refptr<VideoFrameBuffer> captured;
  22. rtc::scoped_refptr<VideoFrameBuffer> decoded;
  23. Timestamp capture_time = Timestamp::MinusInfinity();
  24. Timestamp decoded_time = Timestamp::PlusInfinity();
  25. Timestamp render_time = Timestamp::PlusInfinity();
  26. // A unique identifier for the spatial/temporal layer the decoded frame
  27. // belongs to. Note that this does not reflect the id as defined by the
  28. // underlying layer setup.
  29. int layer_id = 0;
  30. int capture_id = 0;
  31. int decode_id = 0;
  32. // Indicates the repeat count for the decoded frame. Meaning that the same
  33. // decoded frame has matched differend captured frames.
  34. int repeated = 0;
  35. };
  36. struct VideoFramesStats {
  37. int count = 0;
  38. SampleStats<double> pixels;
  39. SampleStats<double> resolution;
  40. EventRateCounter frames;
  41. void AddFrameInfo(const VideoFrameBuffer& frame, Timestamp at_time);
  42. void AddStats(const VideoFramesStats& other);
  43. };
  44. struct VideoQualityStats {
  45. int lost_count = 0;
  46. int freeze_count = 0;
  47. VideoFramesStats capture;
  48. VideoFramesStats render;
  49. // Time from frame was captured on device to time frame was delivered from
  50. // decoder.
  51. SampleStats<TimeDelta> capture_to_decoded_delay;
  52. // Time from frame was captured on device to time frame was displayed on
  53. // device.
  54. SampleStats<TimeDelta> end_to_end_delay;
  55. // PSNR for delivered frames. Note that this might go up for a worse
  56. // connection due to frame dropping.
  57. SampleStats<double> psnr;
  58. // PSNR for all frames, dropped or lost frames are compared to the last
  59. // successfully delivered frame
  60. SampleStats<double> psnr_with_freeze;
  61. // Frames skipped between two nearest.
  62. SampleStats<double> skipped_between_rendered;
  63. // In the next 2 metrics freeze is a pause that is longer, than maximum:
  64. // 1. 150ms
  65. // 2. 3 * average time between two sequential frames.
  66. // Item 1 will cover high fps video and is a duration, that is noticeable by
  67. // human eye. Item 2 will cover low fps video like screen sharing.
  68. SampleStats<TimeDelta> freeze_duration;
  69. // Mean time between one freeze end and next freeze start.
  70. SampleStats<TimeDelta> time_between_freezes;
  71. void AddStats(const VideoQualityStats& other);
  72. };
  73. struct CollectedCallStats {
  74. SampleStats<DataRate> target_rate;
  75. SampleStats<TimeDelta> pacer_delay;
  76. SampleStats<TimeDelta> round_trip_time;
  77. SampleStats<double> memory_usage;
  78. };
  79. struct CollectedAudioReceiveStats {
  80. SampleStats<double> expand_rate;
  81. SampleStats<double> accelerate_rate;
  82. SampleStats<TimeDelta> jitter_buffer;
  83. };
  84. struct CollectedVideoSendStats {
  85. SampleStats<double> encode_frame_rate;
  86. SampleStats<TimeDelta> encode_time;
  87. SampleStats<double> encode_usage;
  88. SampleStats<DataRate> media_bitrate;
  89. SampleStats<DataRate> fec_bitrate;
  90. };
  91. struct CollectedVideoReceiveStats {
  92. SampleStats<TimeDelta> decode_time;
  93. SampleStats<TimeDelta> decode_time_max;
  94. SampleStats<double> decode_pixels;
  95. SampleStats<double> resolution;
  96. };
  97. } // namespace test
  98. } // namespace webrtc
  99. #endif // TEST_SCENARIO_PERFORMANCE_STATS_H_