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 |
(...skipping 13 matching lines...) Expand all Loading... | |
24 namespace { | 24 namespace { |
25 // Used by histograms. Values of entries should not be changed. | 25 // Used by histograms. Values of entries should not be changed. |
26 enum HistogramCodecType { | 26 enum HistogramCodecType { |
27 kVideoUnknown = 0, | 27 kVideoUnknown = 0, |
28 kVideoVp8 = 1, | 28 kVideoVp8 = 1, |
29 kVideoVp9 = 2, | 29 kVideoVp9 = 2, |
30 kVideoH264 = 3, | 30 kVideoH264 = 3, |
31 kVideoMax = 64, | 31 kVideoMax = 64, |
32 }; | 32 }; |
33 | 33 |
34 const char* kRealtimePrefix = "WebRTC.Video."; | |
35 const char* kScreensharePrefix = "WebRTC.Video.Screenshare."; | |
36 | |
34 HistogramCodecType PayloadNameToHistogramCodecType( | 37 HistogramCodecType PayloadNameToHistogramCodecType( |
35 const std::string& payload_name) { | 38 const std::string& payload_name) { |
36 if (payload_name == "VP8") { | 39 if (payload_name == "VP8") { |
37 return kVideoVp8; | 40 return kVideoVp8; |
38 } else if (payload_name == "VP9") { | 41 } else if (payload_name == "VP9") { |
39 return kVideoVp9; | 42 return kVideoVp9; |
40 } else if (payload_name == "H264") { | 43 } else if (payload_name == "H264") { |
41 return kVideoH264; | 44 return kVideoH264; |
42 } else { | 45 } else { |
43 return kVideoUnknown; | 46 return kVideoUnknown; |
44 } | 47 } |
45 } | 48 } |
46 | 49 |
47 void UpdateCodecTypeHistogram(const std::string& payload_name) { | 50 void UpdateCodecTypeHistogram(const std::string& payload_name) { |
48 RTC_HISTOGRAM_ENUMERATION("WebRTC.Video.Encoder.CodecType", | 51 RTC_HISTOGRAM_ENUMERATION("WebRTC.Video.Encoder.CodecType", |
49 PayloadNameToHistogramCodecType(payload_name), kVideoMax); | 52 PayloadNameToHistogramCodecType(payload_name), kVideoMax); |
50 } | 53 } |
51 } // namespace | 54 } // namespace |
52 | 55 |
53 | 56 |
54 const int SendStatisticsProxy::kStatsTimeoutMs = 5000; | 57 const int SendStatisticsProxy::kStatsTimeoutMs = 5000; |
55 | 58 |
56 SendStatisticsProxy::SendStatisticsProxy(Clock* clock, | 59 SendStatisticsProxy::SendStatisticsProxy(Clock* clock, |
57 const VideoSendStream::Config& config) | 60 const VideoSendStream::Config& config) |
58 : clock_(clock), | 61 : clock_(clock), |
59 config_(config), | 62 config_(config), |
63 codec_mode_(kRealtimeVideo), | |
64 uma_container_(new UmaSamplesContainer(kRealtimePrefix)) { | |
65 UpdateCodecTypeHistogram(config_.encoder_settings.payload_name); | |
66 } | |
67 | |
68 SendStatisticsProxy::~SendStatisticsProxy() { | |
69 uma_container_->UpdateHistograms(); | |
70 } | |
71 | |
72 SendStatisticsProxy::UmaSamplesContainer::UmaSamplesContainer( | |
73 const char* prefix) | |
74 : uma_prefix_(prefix), | |
60 input_frame_rate_tracker_(100u, 10u), | 75 input_frame_rate_tracker_(100u, 10u), |
61 sent_frame_rate_tracker_(100u, 10u), | 76 sent_frame_rate_tracker_(100u, 10u), |
62 last_sent_frame_timestamp_(0), | 77 last_sent_frame_timestamp_(0), |
63 max_sent_width_per_timestamp_(0), | 78 max_sent_width_per_timestamp_(0), |
64 max_sent_height_per_timestamp_(0) { | 79 max_sent_height_per_timestamp_(0) {} |
65 UpdateCodecTypeHistogram(config_.encoder_settings.payload_name); | |
66 } | |
67 | 80 |
68 SendStatisticsProxy::~SendStatisticsProxy() { | 81 void SendStatisticsProxy::UmaSamplesContainer::UpdateHistograms() { |
69 UpdateHistograms(); | 82 const int kMinRequiredSamples = 200; |
70 } | 83 if (input_frame_rate_tracker_.TotalSampleCount() >= kMinRequiredSamples) { |
84 int input_fps = round(input_frame_rate_tracker_.ComputeTotalRate()); | |
85 if (input_fps > 0) | |
86 RTC_HISTOGRAM_COUNTS_100(uma_prefix_ + "InputFramesPerSecond", input_fps); | |
87 } | |
88 if (sent_frame_rate_tracker_.TotalSampleCount() >= kMinRequiredSamples) { | |
89 int sent_fps = round(sent_frame_rate_tracker_.ComputeTotalRate()); | |
90 if (sent_fps > 0) | |
91 RTC_HISTOGRAM_COUNTS_100(uma_prefix_ + "SentFramesPerSecond", sent_fps); | |
92 } | |
71 | 93 |
72 void SendStatisticsProxy::UpdateHistograms() { | |
73 int input_fps = | |
74 round(input_frame_rate_tracker_.ComputeTotalRate()); | |
75 if (input_fps > 0) | |
76 RTC_HISTOGRAM_COUNTS_100("WebRTC.Video.InputFramesPerSecond", input_fps); | |
77 int sent_fps = | |
78 round(sent_frame_rate_tracker_.ComputeTotalRate()); | |
79 if (sent_fps > 0) | |
80 RTC_HISTOGRAM_COUNTS_100("WebRTC.Video.SentFramesPerSecond", sent_fps); | |
81 | |
82 const int kMinRequiredSamples = 200; | |
83 int in_width = input_width_counter_.Avg(kMinRequiredSamples); | 94 int in_width = input_width_counter_.Avg(kMinRequiredSamples); |
84 int in_height = input_height_counter_.Avg(kMinRequiredSamples); | 95 int in_height = input_height_counter_.Avg(kMinRequiredSamples); |
85 if (in_width != -1) { | 96 if (in_width != -1) { |
86 RTC_HISTOGRAM_COUNTS_10000("WebRTC.Video.InputWidthInPixels", in_width); | 97 RTC_HISTOGRAM_COUNTS_10000(uma_prefix_ + "InputWidthInPixels", in_width); |
87 RTC_HISTOGRAM_COUNTS_10000("WebRTC.Video.InputHeightInPixels", in_height); | 98 RTC_HISTOGRAM_COUNTS_10000(uma_prefix_ + "InputHeightInPixels", in_height); |
88 } | 99 } |
89 int sent_width = sent_width_counter_.Avg(kMinRequiredSamples); | 100 int sent_width = sent_width_counter_.Avg(kMinRequiredSamples); |
90 int sent_height = sent_height_counter_.Avg(kMinRequiredSamples); | 101 int sent_height = sent_height_counter_.Avg(kMinRequiredSamples); |
91 if (sent_width != -1) { | 102 if (sent_width != -1) { |
92 RTC_HISTOGRAM_COUNTS_10000("WebRTC.Video.SentWidthInPixels", sent_width); | 103 RTC_HISTOGRAM_COUNTS_10000(uma_prefix_ + "SentWidthInPixels", sent_width); |
93 RTC_HISTOGRAM_COUNTS_10000("WebRTC.Video.SentHeightInPixels", sent_height); | 104 RTC_HISTOGRAM_COUNTS_10000(uma_prefix_ + "SentHeightInPixels", sent_height); |
94 } | 105 } |
95 int encode_ms = encode_time_counter_.Avg(kMinRequiredSamples); | 106 int encode_ms = encode_time_counter_.Avg(kMinRequiredSamples); |
96 if (encode_ms != -1) | 107 if (encode_ms != -1) |
97 RTC_HISTOGRAM_COUNTS_1000("WebRTC.Video.EncodeTimeInMs", encode_ms); | 108 RTC_HISTOGRAM_COUNTS_1000(uma_prefix_ + "EncodeTimeInMs", encode_ms); |
98 | 109 |
99 int key_frames_permille = key_frame_counter_.Permille(kMinRequiredSamples); | 110 int key_frames_permille = key_frame_counter_.Permille(kMinRequiredSamples); |
100 if (key_frames_permille != -1) { | 111 if (key_frames_permille != -1) { |
101 RTC_HISTOGRAM_COUNTS_1000("WebRTC.Video.KeyFramesSentInPermille", | 112 RTC_HISTOGRAM_COUNTS_1000(uma_prefix_ + "KeyFramesSentInPermille", |
102 key_frames_permille); | 113 key_frames_permille); |
103 } | 114 } |
104 int quality_limited = | 115 int quality_limited = |
105 quality_limited_frame_counter_.Percent(kMinRequiredSamples); | 116 quality_limited_frame_counter_.Percent(kMinRequiredSamples); |
106 if (quality_limited != -1) { | 117 if (quality_limited != -1) { |
107 RTC_HISTOGRAM_PERCENTAGE("WebRTC.Video.QualityLimitedResolutionInPercent", | 118 RTC_HISTOGRAM_PERCENTAGE(uma_prefix_ + "QualityLimitedResolutionInPercent", |
108 quality_limited); | 119 quality_limited); |
109 } | 120 } |
110 int downscales = quality_downscales_counter_.Avg(kMinRequiredSamples); | 121 int downscales = quality_downscales_counter_.Avg(kMinRequiredSamples); |
111 if (downscales != -1) { | 122 if (downscales != -1) { |
112 RTC_HISTOGRAM_ENUMERATION("WebRTC.Video.QualityLimitedResolutionDownscales", | 123 RTC_HISTOGRAM_ENUMERATION( |
113 downscales, 20); | 124 uma_prefix_ + "QualityLimitedResolutionDownscales", downscales, 20); |
114 } | 125 } |
115 int bw_limited = bw_limited_frame_counter_.Percent(kMinRequiredSamples); | 126 int bw_limited = bw_limited_frame_counter_.Percent(kMinRequiredSamples); |
116 if (bw_limited != -1) { | 127 if (bw_limited != -1) { |
117 RTC_HISTOGRAM_PERCENTAGE("WebRTC.Video.BandwidthLimitedResolutionInPercent", | 128 RTC_HISTOGRAM_PERCENTAGE( |
118 bw_limited); | 129 uma_prefix_ + "BandwidthLimitedResolutionInPercent", bw_limited); |
119 } | 130 } |
120 int num_disabled = bw_resolutions_disabled_counter_.Avg(kMinRequiredSamples); | 131 int num_disabled = bw_resolutions_disabled_counter_.Avg(kMinRequiredSamples); |
121 if (num_disabled != -1) { | 132 if (num_disabled != -1) { |
122 RTC_HISTOGRAM_ENUMERATION( | 133 RTC_HISTOGRAM_ENUMERATION( |
123 "WebRTC.Video.BandwidthLimitedResolutionsDisabled", num_disabled, 10); | 134 uma_prefix_ + "BandwidthLimitedResolutionsDisabled", num_disabled, 10); |
124 } | 135 } |
125 int delay_ms = delay_counter_.Avg(kMinRequiredSamples); | 136 int delay_ms = delay_counter_.Avg(kMinRequiredSamples); |
126 if (delay_ms != -1) | 137 if (delay_ms != -1) |
127 RTC_HISTOGRAM_COUNTS_100000("WebRTC.Video.SendSideDelayInMs", delay_ms); | 138 RTC_HISTOGRAM_COUNTS_100000(uma_prefix_ + "SendSideDelayInMs", delay_ms); |
128 | 139 |
129 int max_delay_ms = max_delay_counter_.Avg(kMinRequiredSamples); | 140 int max_delay_ms = max_delay_counter_.Avg(kMinRequiredSamples); |
130 if (max_delay_ms != -1) { | 141 if (max_delay_ms != -1) { |
131 RTC_HISTOGRAM_COUNTS_100000( | 142 RTC_HISTOGRAM_COUNTS_100000(uma_prefix_ + "SendSideDelayMaxInMs", |
132 "WebRTC.Video.SendSideDelayMaxInMs", max_delay_ms); | 143 max_delay_ms); |
133 } | 144 } |
134 } | 145 } |
135 | 146 |
136 void SendStatisticsProxy::OnOutgoingRate(uint32_t framerate, uint32_t bitrate) { | 147 void SendStatisticsProxy::OnOutgoingRate(uint32_t framerate, uint32_t bitrate) { |
137 rtc::CritScope lock(&crit_); | 148 rtc::CritScope lock(&crit_); |
138 stats_.encode_frame_rate = framerate; | 149 stats_.encode_frame_rate = framerate; |
139 stats_.media_bitrate_bps = bitrate; | 150 stats_.media_bitrate_bps = bitrate; |
140 } | 151 } |
141 | 152 |
142 void SendStatisticsProxy::CpuOveruseMetricsUpdated( | 153 void SendStatisticsProxy::CpuOveruseMetricsUpdated( |
143 const CpuOveruseMetrics& metrics) { | 154 const CpuOveruseMetrics& metrics) { |
144 rtc::CritScope lock(&crit_); | 155 rtc::CritScope lock(&crit_); |
145 // TODO(asapersson): Change to use OnEncodedFrame() for avg_encode_time_ms. | 156 // TODO(asapersson): Change to use OnEncodedFrame() for avg_encode_time_ms. |
146 stats_.avg_encode_time_ms = metrics.avg_encode_time_ms; | 157 stats_.avg_encode_time_ms = metrics.avg_encode_time_ms; |
147 stats_.encode_usage_percent = metrics.encode_usage_percent; | 158 stats_.encode_usage_percent = metrics.encode_usage_percent; |
148 } | 159 } |
149 | 160 |
150 void SendStatisticsProxy::OnSuspendChange(bool is_suspended) { | 161 void SendStatisticsProxy::OnSuspendChange(bool is_suspended) { |
151 rtc::CritScope lock(&crit_); | 162 rtc::CritScope lock(&crit_); |
152 stats_.suspended = is_suspended; | 163 stats_.suspended = is_suspended; |
153 } | 164 } |
154 | 165 |
155 VideoSendStream::Stats SendStatisticsProxy::GetStats() { | 166 VideoSendStream::Stats SendStatisticsProxy::GetStats() { |
156 rtc::CritScope lock(&crit_); | 167 rtc::CritScope lock(&crit_); |
157 PurgeOldStats(); | 168 PurgeOldStats(); |
158 stats_.input_frame_rate = | 169 stats_.input_frame_rate = |
159 round(input_frame_rate_tracker_.ComputeRate()); | 170 round(uma_container_->input_frame_rate_tracker_.ComputeRate()); |
160 return stats_; | 171 return stats_; |
161 } | 172 } |
162 | 173 |
163 void SendStatisticsProxy::PurgeOldStats() { | 174 void SendStatisticsProxy::PurgeOldStats() { |
164 int64_t old_stats_ms = clock_->TimeInMilliseconds() - kStatsTimeoutMs; | 175 int64_t old_stats_ms = clock_->TimeInMilliseconds() - kStatsTimeoutMs; |
165 for (std::map<uint32_t, VideoSendStream::StreamStats>::iterator it = | 176 for (std::map<uint32_t, VideoSendStream::StreamStats>::iterator it = |
166 stats_.substreams.begin(); | 177 stats_.substreams.begin(); |
167 it != stats_.substreams.end(); ++it) { | 178 it != stats_.substreams.end(); ++it) { |
168 uint32_t ssrc = it->first; | 179 uint32_t ssrc = it->first; |
169 if (update_times_[ssrc].resolution_update_ms <= old_stats_ms) { | 180 if (uma_container_->update_times_[ssrc].resolution_update_ms <= |
181 old_stats_ms) { | |
170 it->second.width = 0; | 182 it->second.width = 0; |
171 it->second.height = 0; | 183 it->second.height = 0; |
172 } | 184 } |
173 } | 185 } |
174 } | 186 } |
175 | 187 |
176 VideoSendStream::StreamStats* SendStatisticsProxy::GetStatsEntry( | 188 VideoSendStream::StreamStats* SendStatisticsProxy::GetStatsEntry( |
177 uint32_t ssrc) { | 189 uint32_t ssrc) { |
178 std::map<uint32_t, VideoSendStream::StreamStats>::iterator it = | 190 std::map<uint32_t, VideoSendStream::StreamStats>::iterator it = |
179 stats_.substreams.find(ssrc); | 191 stats_.substreams.find(ssrc); |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
220 } | 232 } |
221 uint32_t ssrc = config_.rtp.ssrcs[simulcast_idx]; | 233 uint32_t ssrc = config_.rtp.ssrcs[simulcast_idx]; |
222 | 234 |
223 rtc::CritScope lock(&crit_); | 235 rtc::CritScope lock(&crit_); |
224 VideoSendStream::StreamStats* stats = GetStatsEntry(ssrc); | 236 VideoSendStream::StreamStats* stats = GetStatsEntry(ssrc); |
225 if (stats == nullptr) | 237 if (stats == nullptr) |
226 return; | 238 return; |
227 | 239 |
228 stats->width = encoded_image._encodedWidth; | 240 stats->width = encoded_image._encodedWidth; |
229 stats->height = encoded_image._encodedHeight; | 241 stats->height = encoded_image._encodedHeight; |
230 update_times_[ssrc].resolution_update_ms = clock_->TimeInMilliseconds(); | 242 uma_container_->update_times_[ssrc].resolution_update_ms = |
243 clock_->TimeInMilliseconds(); | |
231 | 244 |
232 key_frame_counter_.Add(encoded_image._frameType == kVideoFrameKey); | 245 uma_container_->key_frame_counter_.Add(encoded_image._frameType == |
246 kVideoFrameKey); | |
233 | 247 |
234 if (encoded_image.adapt_reason_.quality_resolution_downscales != -1) { | 248 if (encoded_image.adapt_reason_.quality_resolution_downscales != -1) { |
235 bool downscaled = | 249 bool downscaled = |
236 encoded_image.adapt_reason_.quality_resolution_downscales > 0; | 250 encoded_image.adapt_reason_.quality_resolution_downscales > 0; |
237 quality_limited_frame_counter_.Add(downscaled); | 251 uma_container_->quality_limited_frame_counter_.Add(downscaled); |
238 if (downscaled) { | 252 if (downscaled) { |
239 quality_downscales_counter_.Add( | 253 uma_container_->quality_downscales_counter_.Add( |
240 encoded_image.adapt_reason_.quality_resolution_downscales); | 254 encoded_image.adapt_reason_.quality_resolution_downscales); |
241 } | 255 } |
242 } | 256 } |
243 if (encoded_image.adapt_reason_.bw_resolutions_disabled != -1) { | 257 if (encoded_image.adapt_reason_.bw_resolutions_disabled != -1) { |
244 bool bw_limited = encoded_image.adapt_reason_.bw_resolutions_disabled > 0; | 258 bool bw_limited = encoded_image.adapt_reason_.bw_resolutions_disabled > 0; |
245 bw_limited_frame_counter_.Add(bw_limited); | 259 uma_container_->bw_limited_frame_counter_.Add(bw_limited); |
246 if (bw_limited) { | 260 if (bw_limited) { |
247 bw_resolutions_disabled_counter_.Add( | 261 uma_container_->bw_resolutions_disabled_counter_.Add( |
248 encoded_image.adapt_reason_.bw_resolutions_disabled); | 262 encoded_image.adapt_reason_.bw_resolutions_disabled); |
249 } | 263 } |
250 } | 264 } |
251 | 265 |
252 // TODO(asapersson): This is incorrect if simulcast layers are encoded on | 266 // TODO(asapersson): This is incorrect if simulcast layers are encoded on |
253 // different threads and there is no guarantee that one frame of all layers | 267 // different threads and there is no guarantee that one frame of all layers |
254 // are encoded before the next start. | 268 // are encoded before the next start. |
255 if (last_sent_frame_timestamp_ > 0 && | 269 if (uma_container_->last_sent_frame_timestamp_ > 0 && |
256 encoded_image._timeStamp != last_sent_frame_timestamp_) { | 270 encoded_image._timeStamp != uma_container_->last_sent_frame_timestamp_) { |
257 sent_frame_rate_tracker_.AddSamples(1); | 271 uma_container_->sent_frame_rate_tracker_.AddSamples(1); |
258 sent_width_counter_.Add(max_sent_width_per_timestamp_); | 272 uma_container_->sent_width_counter_.Add( |
259 sent_height_counter_.Add(max_sent_height_per_timestamp_); | 273 uma_container_->max_sent_width_per_timestamp_); |
260 max_sent_width_per_timestamp_ = 0; | 274 uma_container_->sent_height_counter_.Add( |
261 max_sent_height_per_timestamp_ = 0; | 275 uma_container_->max_sent_height_per_timestamp_); |
276 uma_container_->max_sent_width_per_timestamp_ = 0; | |
277 uma_container_->max_sent_height_per_timestamp_ = 0; | |
262 } | 278 } |
263 last_sent_frame_timestamp_ = encoded_image._timeStamp; | 279 uma_container_->last_sent_frame_timestamp_ = encoded_image._timeStamp; |
264 max_sent_width_per_timestamp_ = | 280 uma_container_->max_sent_width_per_timestamp_ = |
265 std::max(max_sent_width_per_timestamp_, | 281 std::max(uma_container_->max_sent_width_per_timestamp_, |
266 static_cast<int>(encoded_image._encodedWidth)); | 282 static_cast<int>(encoded_image._encodedWidth)); |
267 max_sent_height_per_timestamp_ = | 283 uma_container_->max_sent_height_per_timestamp_ = |
268 std::max(max_sent_height_per_timestamp_, | 284 std::max(uma_container_->max_sent_height_per_timestamp_, |
269 static_cast<int>(encoded_image._encodedHeight)); | 285 static_cast<int>(encoded_image._encodedHeight)); |
270 } | 286 } |
271 | 287 |
272 void SendStatisticsProxy::OnIncomingFrame(int width, int height) { | 288 void SendStatisticsProxy::OnIncomingFrame(int width, int height) { |
273 rtc::CritScope lock(&crit_); | 289 rtc::CritScope lock(&crit_); |
274 input_frame_rate_tracker_.AddSamples(1); | 290 uma_container_->input_frame_rate_tracker_.AddSamples(1); |
275 input_width_counter_.Add(width); | 291 uma_container_->input_width_counter_.Add(width); |
276 input_height_counter_.Add(height); | 292 uma_container_->input_height_counter_.Add(height); |
277 } | 293 } |
278 | 294 |
279 void SendStatisticsProxy::OnEncodedFrame(int encode_time_ms) { | 295 void SendStatisticsProxy::OnEncodedFrame(int encode_time_ms) { |
280 rtc::CritScope lock(&crit_); | 296 rtc::CritScope lock(&crit_); |
281 encode_time_counter_.Add(encode_time_ms); | 297 uma_container_->encode_time_counter_.Add(encode_time_ms); |
282 } | 298 } |
283 | 299 |
284 void SendStatisticsProxy::RtcpPacketTypesCounterUpdated( | 300 void SendStatisticsProxy::RtcpPacketTypesCounterUpdated( |
285 uint32_t ssrc, | 301 uint32_t ssrc, |
286 const RtcpPacketTypeCounter& packet_counter) { | 302 const RtcpPacketTypeCounter& packet_counter) { |
287 rtc::CritScope lock(&crit_); | 303 rtc::CritScope lock(&crit_); |
288 VideoSendStream::StreamStats* stats = GetStatsEntry(ssrc); | 304 VideoSendStream::StreamStats* stats = GetStatsEntry(ssrc); |
289 if (stats == nullptr) | 305 if (stats == nullptr) |
290 return; | 306 return; |
291 | 307 |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
341 void SendStatisticsProxy::SendSideDelayUpdated(int avg_delay_ms, | 357 void SendStatisticsProxy::SendSideDelayUpdated(int avg_delay_ms, |
342 int max_delay_ms, | 358 int max_delay_ms, |
343 uint32_t ssrc) { | 359 uint32_t ssrc) { |
344 rtc::CritScope lock(&crit_); | 360 rtc::CritScope lock(&crit_); |
345 VideoSendStream::StreamStats* stats = GetStatsEntry(ssrc); | 361 VideoSendStream::StreamStats* stats = GetStatsEntry(ssrc); |
346 if (stats == nullptr) | 362 if (stats == nullptr) |
347 return; | 363 return; |
348 stats->avg_delay_ms = avg_delay_ms; | 364 stats->avg_delay_ms = avg_delay_ms; |
349 stats->max_delay_ms = max_delay_ms; | 365 stats->max_delay_ms = max_delay_ms; |
350 | 366 |
351 delay_counter_.Add(avg_delay_ms); | 367 uma_container_->delay_counter_.Add(avg_delay_ms); |
352 max_delay_counter_.Add(max_delay_ms); | 368 uma_container_->max_delay_counter_.Add(max_delay_ms); |
353 } | 369 } |
354 | 370 |
355 void SendStatisticsProxy::SampleCounter::Add(int sample) { | 371 void SendStatisticsProxy::SampleCounter::Add(int sample) { |
356 sum += sample; | 372 sum += sample; |
357 ++num_samples; | 373 ++num_samples; |
358 } | 374 } |
359 | 375 |
360 int SendStatisticsProxy::SampleCounter::Avg(int min_required_samples) const { | 376 int SendStatisticsProxy::SampleCounter::Avg(int min_required_samples) const { |
361 if (num_samples < min_required_samples || num_samples == 0) | 377 if (num_samples < min_required_samples || num_samples == 0) |
362 return -1; | 378 return -1; |
(...skipping 16 matching lines...) Expand all Loading... | |
379 return Fraction(min_required_samples, 1000.0f); | 395 return Fraction(min_required_samples, 1000.0f); |
380 } | 396 } |
381 | 397 |
382 int SendStatisticsProxy::BoolSampleCounter::Fraction( | 398 int SendStatisticsProxy::BoolSampleCounter::Fraction( |
383 int min_required_samples, float multiplier) const { | 399 int min_required_samples, float multiplier) const { |
384 if (num_samples < min_required_samples || num_samples == 0) | 400 if (num_samples < min_required_samples || num_samples == 0) |
385 return -1; | 401 return -1; |
386 return static_cast<int>((sum * multiplier / num_samples) + 0.5f); | 402 return static_cast<int>((sum * multiplier / num_samples) + 0.5f); |
387 } | 403 } |
388 | 404 |
405 void SendStatisticsProxy::SetCodecMode(VideoCodecMode mode) { | |
406 rtc::CritScope lock(&crit_); | |
407 if (codec_mode_ != mode) { | |
pbos-webrtc
2015/11/12 13:54:44
This is racy since pending frames might not have b
| |
408 uma_container_->UpdateHistograms(); | |
409 uma_container_.reset(new UmaSamplesContainer( | |
410 mode == kRealtimeVideo ? kRealtimePrefix : kScreensharePrefix)); | |
411 codec_mode_ = mode; | |
412 } | |
413 } | |
414 | |
389 } // namespace webrtc | 415 } // namespace webrtc |
OLD | NEW |