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 <map> | 14 #include <map> |
15 #include <string> | 15 #include <string> |
16 | 16 |
17 #include "webrtc/base/criticalsection.h" | 17 #include "webrtc/base/criticalsection.h" |
18 #include "webrtc/base/rate_statistics.h" | 18 #include "webrtc/base/rate_statistics.h" |
19 #include "webrtc/base/ratetracker.h" | 19 #include "webrtc/base/ratetracker.h" |
20 #include "webrtc/base/thread_annotations.h" | 20 #include "webrtc/base/thread_annotations.h" |
21 #include "webrtc/common_types.h" | 21 #include "webrtc/common_types.h" |
22 #include "webrtc/common_video/include/frame_callback.h" | 22 #include "webrtc/common_video/include/frame_callback.h" |
23 #include "webrtc/modules/video_coding/include/video_coding_defines.h" | 23 #include "webrtc/modules/video_coding/include/video_coding_defines.h" |
| 24 #include "webrtc/video/quality_threshold.h" |
24 #include "webrtc/video/report_block_stats.h" | 25 #include "webrtc/video/report_block_stats.h" |
25 #include "webrtc/video/stats_counter.h" | 26 #include "webrtc/video/stats_counter.h" |
26 #include "webrtc/video/video_stream_decoder.h" | 27 #include "webrtc/video/video_stream_decoder.h" |
27 #include "webrtc/video_receive_stream.h" | 28 #include "webrtc/video_receive_stream.h" |
28 | 29 |
29 namespace webrtc { | 30 namespace webrtc { |
30 | 31 |
31 class Clock; | 32 class Clock; |
32 class ViECodec; | 33 class ViECodec; |
33 class ViEDecoderObserver; | 34 class ViEDecoderObserver; |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 const RtcpPacketTypeCounter& packet_counter) override; | 79 const RtcpPacketTypeCounter& packet_counter) override; |
79 // Overrides StreamDataCountersCallback. | 80 // Overrides StreamDataCountersCallback. |
80 void DataCountersUpdated(const webrtc::StreamDataCounters& counters, | 81 void DataCountersUpdated(const webrtc::StreamDataCounters& counters, |
81 uint32_t ssrc) override; | 82 uint32_t ssrc) override; |
82 | 83 |
83 private: | 84 private: |
84 struct SampleCounter { | 85 struct SampleCounter { |
85 SampleCounter() : sum(0), num_samples(0) {} | 86 SampleCounter() : sum(0), num_samples(0) {} |
86 void Add(int sample); | 87 void Add(int sample); |
87 int Avg(int min_required_samples) const; | 88 int Avg(int min_required_samples) const; |
| 89 void Reset(); |
88 | 90 |
89 private: | 91 private: |
90 int sum; | 92 int sum; |
91 int num_samples; | 93 int num_samples; |
92 }; | 94 }; |
93 struct QpCounters { | 95 struct QpCounters { |
94 SampleCounter vp8; | 96 SampleCounter vp8; |
95 }; | 97 }; |
96 | 98 |
97 void UpdateHistograms() EXCLUSIVE_LOCKS_REQUIRED(crit_); | 99 void UpdateHistograms() EXCLUSIVE_LOCKS_REQUIRED(crit_); |
98 | 100 |
| 101 void QualitySample() EXCLUSIVE_LOCKS_REQUIRED(crit_); |
| 102 |
99 Clock* const clock_; | 103 Clock* const clock_; |
100 // Ownership of this object lies with the owner of the ReceiveStatisticsProxy | 104 // Ownership of this object lies with the owner of the ReceiveStatisticsProxy |
101 // instance. Lifetime is guaranteed to outlive |this|. | 105 // instance. Lifetime is guaranteed to outlive |this|. |
102 // TODO(tommi): In practice the config_ reference is only used for accessing | 106 // TODO(tommi): In practice the config_ reference is only used for accessing |
103 // config_.rtp.ulpfec.ulpfec_payload_type. Instead of holding a pointer back, | 107 // config_.rtp.ulpfec.ulpfec_payload_type. Instead of holding a pointer back, |
104 // we could just store the value of ulpfec_payload_type and change the | 108 // we could just store the value of ulpfec_payload_type and change the |
105 // ReceiveStatisticsProxy() ctor to accept a const& of Config (since we'll | 109 // ReceiveStatisticsProxy() ctor to accept a const& of Config (since we'll |
106 // then no longer store a pointer to the object). | 110 // then no longer store a pointer to the object). |
107 const VideoReceiveStream::Config& config_; | 111 const VideoReceiveStream::Config& config_; |
108 const int64_t start_ms_; | 112 const int64_t start_ms_; |
109 | 113 |
110 rtc::CriticalSection crit_; | 114 rtc::CriticalSection crit_; |
| 115 uint64_t last_sample_time_ GUARDED_BY(crit_); |
| 116 QualityThreshold fps_threshold_ GUARDED_BY(crit_); |
| 117 QualityThreshold qp_threshold_ GUARDED_BY(crit_); |
| 118 QualityThreshold variance_threshold_ GUARDED_BY(crit_); |
| 119 SampleCounter qp_sample_ GUARDED_BY(crit_); |
111 VideoReceiveStream::Stats stats_ GUARDED_BY(crit_); | 120 VideoReceiveStream::Stats stats_ GUARDED_BY(crit_); |
112 RateStatistics decode_fps_estimator_ GUARDED_BY(crit_); | 121 RateStatistics decode_fps_estimator_ GUARDED_BY(crit_); |
113 RateStatistics renders_fps_estimator_ GUARDED_BY(crit_); | 122 RateStatistics renders_fps_estimator_ GUARDED_BY(crit_); |
114 rtc::RateTracker render_fps_tracker_ GUARDED_BY(crit_); | 123 rtc::RateTracker render_fps_tracker_ GUARDED_BY(crit_); |
115 rtc::RateTracker render_pixel_tracker_ GUARDED_BY(crit_); | 124 rtc::RateTracker render_pixel_tracker_ GUARDED_BY(crit_); |
116 SampleCounter render_width_counter_ GUARDED_BY(crit_); | 125 SampleCounter render_width_counter_ GUARDED_BY(crit_); |
117 SampleCounter render_height_counter_ GUARDED_BY(crit_); | 126 SampleCounter render_height_counter_ GUARDED_BY(crit_); |
118 SampleCounter sync_offset_counter_ GUARDED_BY(crit_); | 127 SampleCounter sync_offset_counter_ GUARDED_BY(crit_); |
119 SampleCounter decode_time_counter_ GUARDED_BY(crit_); | 128 SampleCounter decode_time_counter_ GUARDED_BY(crit_); |
120 SampleCounter jitter_buffer_delay_counter_ GUARDED_BY(crit_); | 129 SampleCounter jitter_buffer_delay_counter_ GUARDED_BY(crit_); |
121 SampleCounter target_delay_counter_ GUARDED_BY(crit_); | 130 SampleCounter target_delay_counter_ GUARDED_BY(crit_); |
122 SampleCounter current_delay_counter_ GUARDED_BY(crit_); | 131 SampleCounter current_delay_counter_ GUARDED_BY(crit_); |
123 SampleCounter delay_counter_ GUARDED_BY(crit_); | 132 SampleCounter delay_counter_ GUARDED_BY(crit_); |
124 SampleCounter e2e_delay_counter_ GUARDED_BY(crit_); | 133 SampleCounter e2e_delay_counter_ GUARDED_BY(crit_); |
125 MaxCounter freq_offset_counter_ GUARDED_BY(crit_); | 134 MaxCounter freq_offset_counter_ GUARDED_BY(crit_); |
126 ReportBlockStats report_block_stats_ GUARDED_BY(crit_); | 135 ReportBlockStats report_block_stats_ GUARDED_BY(crit_); |
127 QpCounters qp_counters_; // Only accessed on the decoding thread. | 136 QpCounters qp_counters_; // Only accessed on the decoding thread. |
128 std::map<uint32_t, StreamDataCounters> rtx_stats_ GUARDED_BY(crit_); | 137 std::map<uint32_t, StreamDataCounters> rtx_stats_ GUARDED_BY(crit_); |
129 }; | 138 }; |
130 | 139 |
131 } // namespace webrtc | 140 } // namespace webrtc |
132 #endif // WEBRTC_VIDEO_RECEIVE_STATISTICS_PROXY_H_ | 141 #endif // WEBRTC_VIDEO_RECEIVE_STATISTICS_PROXY_H_ |
OLD | NEW |