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