OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 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 | 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 | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
11 #ifndef WEBRTC_VIDEO_RECEIVE_STATISTICS_PROXY_H_ | 11 #ifndef WEBRTC_VIDEO_RECEIVE_STATISTICS_PROXY_H_ |
12 #define WEBRTC_VIDEO_RECEIVE_STATISTICS_PROXY_H_ | 12 #define WEBRTC_VIDEO_RECEIVE_STATISTICS_PROXY_H_ |
13 | 13 |
14 #include <deque> | |
14 #include <map> | 15 #include <map> |
15 #include <string> | 16 #include <string> |
17 #include <utility> | |
16 | 18 |
17 #include "webrtc/common_types.h" | 19 #include "webrtc/common_types.h" |
18 #include "webrtc/common_video/include/frame_callback.h" | 20 #include "webrtc/common_video/include/frame_callback.h" |
19 #include "webrtc/modules/video_coding/include/video_coding_defines.h" | 21 #include "webrtc/modules/video_coding/include/video_coding_defines.h" |
20 #include "webrtc/rtc_base/criticalsection.h" | 22 #include "webrtc/rtc_base/criticalsection.h" |
21 #include "webrtc/rtc_base/rate_statistics.h" | 23 #include "webrtc/rtc_base/rate_statistics.h" |
22 #include "webrtc/rtc_base/ratetracker.h" | 24 #include "webrtc/rtc_base/ratetracker.h" |
23 #include "webrtc/rtc_base/thread_annotations.h" | 25 #include "webrtc/rtc_base/thread_annotations.h" |
24 #include "webrtc/video/quality_threshold.h" | 26 #include "webrtc/video/quality_threshold.h" |
25 #include "webrtc/video/report_block_stats.h" | 27 #include "webrtc/video/report_block_stats.h" |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
96 int Avg(int64_t min_required_samples) const; | 98 int Avg(int64_t min_required_samples) const; |
97 void Reset(); | 99 void Reset(); |
98 | 100 |
99 private: | 101 private: |
100 int64_t sum; | 102 int64_t sum; |
101 int64_t num_samples; | 103 int64_t num_samples; |
102 }; | 104 }; |
103 struct QpCounters { | 105 struct QpCounters { |
104 SampleCounter vp8; | 106 SampleCounter vp8; |
105 }; | 107 }; |
108 // |time_ms| should never decrease in consecutive calls to Add and MovingMax | |
109 // as if it's local time. Not thread-safe. | |
110 class MovingMaxCounter { | |
111 public: | |
112 explicit MovingMaxCounter(int window_length_ms) : | |
113 window_length_ms_(window_length_ms) {} | |
114 void Add(int sample, int64_t time_ms); | |
115 // Returns max sample in window given current time. | |
116 // Can be sped-up in case when MovingMax is called many times in a row | |
117 // without new elements added (not likely case currently) by removing | |
118 // obsolete elements from the beginning of the deque instead of skipping | |
119 // them. In that case deque should be marked as mutable. | |
120 rtc::Optional<int> MovingMax(int64_t time_ms) const; | |
121 void Reset(); | |
122 private: | |
123 int window_length_ms_; | |
124 // Samples in the window are stored as pairs <time, sample> in this deque in | |
125 // chronological order. Samples what can't be maximum in any window are | |
126 // thrown out - deque always contain decreasing sequence of samples. | |
127 std::deque <std::pair<int64_t, int>> samples_; | |
128 }; | |
sprang_webrtc
2017/08/18 09:06:49
Interesting class. If no equivalent is available i
ilnik
2017/08/18 11:43:01
Done.
| |
106 | 129 |
107 void UpdateHistograms() EXCLUSIVE_LOCKS_REQUIRED(crit_); | 130 void UpdateHistograms() EXCLUSIVE_LOCKS_REQUIRED(crit_); |
108 | 131 |
109 void QualitySample() EXCLUSIVE_LOCKS_REQUIRED(crit_); | 132 void QualitySample() EXCLUSIVE_LOCKS_REQUIRED(crit_); |
110 | 133 |
111 // Removes info about old frames and then updates the framerate. | 134 // Removes info about old frames and then updates the framerate. |
112 void UpdateFramerate(int64_t now_ms) const EXCLUSIVE_LOCKS_REQUIRED(crit_); | 135 void UpdateFramerate(int64_t now_ms) const EXCLUSIVE_LOCKS_REQUIRED(crit_); |
113 | 136 |
114 Clock* const clock_; | 137 Clock* const clock_; |
115 // Ownership of this object lies with the owner of the ReceiveStatisticsProxy | 138 // Ownership of this object lies with the owner of the ReceiveStatisticsProxy |
(...skipping 29 matching lines...) Expand all Loading... | |
145 SampleCounter current_delay_counter_ GUARDED_BY(crit_); | 168 SampleCounter current_delay_counter_ GUARDED_BY(crit_); |
146 SampleCounter delay_counter_ GUARDED_BY(crit_); | 169 SampleCounter delay_counter_ GUARDED_BY(crit_); |
147 SampleCounter e2e_delay_counter_video_ GUARDED_BY(crit_); | 170 SampleCounter e2e_delay_counter_video_ GUARDED_BY(crit_); |
148 SampleCounter e2e_delay_counter_screenshare_ GUARDED_BY(crit_); | 171 SampleCounter e2e_delay_counter_screenshare_ GUARDED_BY(crit_); |
149 SampleCounter interframe_delay_counter_video_ GUARDED_BY(crit_); | 172 SampleCounter interframe_delay_counter_video_ GUARDED_BY(crit_); |
150 SampleCounter interframe_delay_counter_screenshare_ GUARDED_BY(crit_); | 173 SampleCounter interframe_delay_counter_screenshare_ GUARDED_BY(crit_); |
151 int64_t e2e_delay_max_ms_video_ GUARDED_BY(crit_); | 174 int64_t e2e_delay_max_ms_video_ GUARDED_BY(crit_); |
152 int64_t e2e_delay_max_ms_screenshare_ GUARDED_BY(crit_); | 175 int64_t e2e_delay_max_ms_screenshare_ GUARDED_BY(crit_); |
153 int64_t interframe_delay_max_ms_video_ GUARDED_BY(crit_); | 176 int64_t interframe_delay_max_ms_video_ GUARDED_BY(crit_); |
154 int64_t interframe_delay_max_ms_screenshare_ GUARDED_BY(crit_); | 177 int64_t interframe_delay_max_ms_screenshare_ GUARDED_BY(crit_); |
178 MovingMaxCounter interframe_delay_max_moving_ GUARDED_BY(crit_); | |
155 MaxCounter freq_offset_counter_ GUARDED_BY(crit_); | 179 MaxCounter freq_offset_counter_ GUARDED_BY(crit_); |
156 int64_t first_report_block_time_ms_ GUARDED_BY(crit_); | 180 int64_t first_report_block_time_ms_ GUARDED_BY(crit_); |
157 ReportBlockStats report_block_stats_ GUARDED_BY(crit_); | 181 ReportBlockStats report_block_stats_ GUARDED_BY(crit_); |
158 QpCounters qp_counters_; // Only accessed on the decoding thread. | 182 QpCounters qp_counters_; // Only accessed on the decoding thread. |
159 std::map<uint32_t, StreamDataCounters> rtx_stats_ GUARDED_BY(crit_); | 183 std::map<uint32_t, StreamDataCounters> rtx_stats_ GUARDED_BY(crit_); |
160 int64_t avg_rtt_ms_ GUARDED_BY(crit_); | 184 int64_t avg_rtt_ms_ GUARDED_BY(crit_); |
161 mutable std::map<int64_t, size_t> frame_window_ GUARDED_BY(&crit_); | 185 mutable std::map<int64_t, size_t> frame_window_ GUARDED_BY(&crit_); |
162 VideoContentType last_content_type_ GUARDED_BY(&crit_); | 186 VideoContentType last_content_type_ GUARDED_BY(&crit_); |
163 rtc::Optional<int64_t> last_decoded_frame_time_ms_; | 187 rtc::Optional<int64_t> last_decoded_frame_time_ms_; |
164 rtc::Optional<TimingFrameInfo> timing_frame_info_ GUARDED_BY(&crit_); | 188 rtc::Optional<TimingFrameInfo> timing_frame_info_ GUARDED_BY(&crit_); |
165 }; | 189 }; |
166 | 190 |
167 } // namespace webrtc | 191 } // namespace webrtc |
168 #endif // WEBRTC_VIDEO_RECEIVE_STATISTICS_PROXY_H_ | 192 #endif // WEBRTC_VIDEO_RECEIVE_STATISTICS_PROXY_H_ |
OLD | NEW |