You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

179 lines
5.3 KiB

​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  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/samples_stats_counter.h"
  17. namespace webrtc {
  18. namespace test {
  19. struct VideoFramePair {
  20. rtc::scoped_refptr<VideoFrameBuffer> captured;
  21. rtc::scoped_refptr<VideoFrameBuffer> decoded;
  22. Timestamp capture_time = Timestamp::MinusInfinity();
  23. Timestamp decoded_time = Timestamp::PlusInfinity();
  24. Timestamp render_time = Timestamp::PlusInfinity();
  25. // A unique identifier for the spatial/temporal layer the decoded frame
  26. // belongs to. Note that this does not reflect the id as defined by the
  27. // underlying layer setup.
  28. int layer_id = 0;
  29. int capture_id = 0;
  30. int decode_id = 0;
  31. // Indicates the repeat count for the decoded frame. Meaning that the same
  32. // decoded frame has matched differend captured frames.
  33. int repeated = 0;
  34. };
  35. template <typename T>
  36. class SampleStats;
  37. template <>
  38. class SampleStats<double> : public SamplesStatsCounter {
  39. public:
  40. double Max();
  41. double Mean();
  42. double Median();
  43. double Quantile(double quantile);
  44. double Min();
  45. double Variance();
  46. double StandardDeviation();
  47. int Count();
  48. };
  49. template <>
  50. class SampleStats<TimeDelta> {
  51. public:
  52. void AddSample(TimeDelta delta);
  53. void AddSampleMs(double delta_ms);
  54. void AddSamples(const SampleStats<TimeDelta>& other);
  55. bool IsEmpty();
  56. TimeDelta Max();
  57. TimeDelta Mean();
  58. TimeDelta Median();
  59. TimeDelta Quantile(double quantile);
  60. TimeDelta Min();
  61. TimeDelta Variance();
  62. TimeDelta StandardDeviation();
  63. int Count();
  64. private:
  65. SampleStats<double> stats_;
  66. };
  67. template <>
  68. class SampleStats<DataRate> {
  69. public:
  70. void AddSample(DataRate rate);
  71. void AddSampleBps(double rate_bps);
  72. void AddSamples(const SampleStats<DataRate>& other);
  73. bool IsEmpty();
  74. DataRate Max();
  75. DataRate Mean();
  76. DataRate Median();
  77. DataRate Quantile(double quantile);
  78. DataRate Min();
  79. DataRate Variance();
  80. DataRate StandardDeviation();
  81. int Count();
  82. private:
  83. SampleStats<double> stats_;
  84. };
  85. class EventRateCounter {
  86. public:
  87. void AddEvent(Timestamp event_time);
  88. void AddEvents(EventRateCounter other);
  89. bool IsEmpty() const;
  90. double Rate() const;
  91. SampleStats<TimeDelta>& interval() { return interval_; }
  92. TimeDelta TotalDuration() const;
  93. int Count() const { return event_count_; }
  94. private:
  95. Timestamp first_time_ = Timestamp::PlusInfinity();
  96. Timestamp last_time_ = Timestamp::MinusInfinity();
  97. int64_t event_count_ = 0;
  98. SampleStats<TimeDelta> interval_;
  99. };
  100. struct VideoFramesStats {
  101. int count = 0;
  102. SampleStats<double> pixels;
  103. SampleStats<double> resolution;
  104. EventRateCounter frames;
  105. void AddFrameInfo(const VideoFrameBuffer& frame, Timestamp at_time);
  106. void AddStats(const VideoFramesStats& other);
  107. };
  108. struct VideoQualityStats {
  109. int lost_count = 0;
  110. int freeze_count = 0;
  111. VideoFramesStats capture;
  112. VideoFramesStats render;
  113. // Time from frame was captured on device to time frame was delivered from
  114. // decoder.
  115. SampleStats<TimeDelta> capture_to_decoded_delay;
  116. // Time from frame was captured on device to time frame was displayed on
  117. // device.
  118. SampleStats<TimeDelta> end_to_end_delay;
  119. // PSNR for delivered frames. Note that this might go up for a worse
  120. // connection due to frame dropping.
  121. SampleStats<double> psnr;
  122. // PSNR for all frames, dropped or lost frames are compared to the last
  123. // successfully delivered frame
  124. SampleStats<double> psnr_with_freeze;
  125. // Frames skipped between two nearest.
  126. SampleStats<double> skipped_between_rendered;
  127. // In the next 2 metrics freeze is a pause that is longer, than maximum:
  128. // 1. 150ms
  129. // 2. 3 * average time between two sequential frames.
  130. // Item 1 will cover high fps video and is a duration, that is noticeable by
  131. // human eye. Item 2 will cover low fps video like screen sharing.
  132. SampleStats<TimeDelta> freeze_duration;
  133. // Mean time between one freeze end and next freeze start.
  134. SampleStats<TimeDelta> time_between_freezes;
  135. void AddStats(const VideoQualityStats& other);
  136. };
  137. struct CollectedCallStats {
  138. SampleStats<DataRate> target_rate;
  139. SampleStats<TimeDelta> pacer_delay;
  140. SampleStats<TimeDelta> round_trip_time;
  141. SampleStats<double> memory_usage;
  142. };
  143. struct CollectedAudioReceiveStats {
  144. SampleStats<double> expand_rate;
  145. SampleStats<double> accelerate_rate;
  146. SampleStats<TimeDelta> jitter_buffer;
  147. };
  148. struct CollectedVideoSendStats {
  149. SampleStats<double> encode_frame_rate;
  150. SampleStats<TimeDelta> encode_time;
  151. SampleStats<double> encode_usage;
  152. SampleStats<DataRate> media_bitrate;
  153. SampleStats<DataRate> fec_bitrate;
  154. };
  155. struct CollectedVideoReceiveStats {
  156. SampleStats<TimeDelta> decode_time;
  157. SampleStats<TimeDelta> decode_time_max;
  158. SampleStats<double> decode_pixels;
  159. SampleStats<double> resolution;
  160. };
  161. } // namespace test
  162. } // namespace webrtc
  163. #endif // TEST_SCENARIO_PERFORMANCE_STATS_H_