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