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 59 matching lines...) Loading... | |
70 | 70 |
71 SendStatisticsProxy::SendStatisticsProxy( | 71 SendStatisticsProxy::SendStatisticsProxy( |
72 Clock* clock, | 72 Clock* clock, |
73 const VideoSendStream::Config& config, | 73 const VideoSendStream::Config& config, |
74 VideoEncoderConfig::ContentType content_type) | 74 VideoEncoderConfig::ContentType content_type) |
75 : clock_(clock), | 75 : clock_(clock), |
76 config_(config), | 76 config_(config), |
77 content_type_(content_type), | 77 content_type_(content_type), |
78 last_sent_frame_timestamp_(0), | 78 last_sent_frame_timestamp_(0), |
79 encode_time_(kEncodeTimeWeigthFactor), | 79 encode_time_(kEncodeTimeWeigthFactor), |
80 uma_container_(new UmaSamplesContainer(GetUmaPrefix(content_type_))) { | 80 uma_container_( |
81 new UmaSamplesContainer(GetUmaPrefix(content_type_), stats_, clock)) { | |
81 UpdateCodecTypeHistogram(config_.encoder_settings.payload_name); | 82 UpdateCodecTypeHistogram(config_.encoder_settings.payload_name); |
82 } | 83 } |
83 | 84 |
84 SendStatisticsProxy::~SendStatisticsProxy() {} | 85 SendStatisticsProxy::~SendStatisticsProxy() { |
86 rtc::CritScope lock(&crit_); | |
87 uma_container_->UpdateHistograms(config_, stats_); | |
88 } | |
85 | 89 |
86 SendStatisticsProxy::UmaSamplesContainer::UmaSamplesContainer( | 90 SendStatisticsProxy::UmaSamplesContainer::UmaSamplesContainer( |
87 const char* prefix) | 91 const char* prefix, |
92 const VideoSendStream::Stats& stats, | |
93 Clock* const clock) | |
88 : uma_prefix_(prefix), | 94 : uma_prefix_(prefix), |
89 max_sent_width_per_timestamp_(0), | 95 max_sent_width_per_timestamp_(0), |
90 max_sent_height_per_timestamp_(0), | 96 max_sent_height_per_timestamp_(0), |
91 input_frame_rate_tracker_(100u, 10u), | 97 input_frame_rate_tracker_(100u, 10u), |
92 sent_frame_rate_tracker_(100u, 10u), | 98 sent_frame_rate_tracker_(100u, 10u), |
93 first_rtcp_stats_time_ms_(-1) {} | 99 clock_(clock), |
100 first_rtcp_stats_time_ms_(-1), | |
101 start_stats_(stats) {} | |
94 | 102 |
95 SendStatisticsProxy::UmaSamplesContainer::~UmaSamplesContainer() { | 103 SendStatisticsProxy::UmaSamplesContainer::~UmaSamplesContainer() {} |
96 UpdateHistograms(); | |
97 } | |
98 | 104 |
99 void SendStatisticsProxy::UmaSamplesContainer::UpdateHistograms() { | 105 void SendStatisticsProxy::UmaSamplesContainer::UpdateHistograms( |
106 const VideoSendStream::Config& config, | |
107 const VideoSendStream::Stats& current_stats) { | |
100 RTC_DCHECK(uma_prefix_ == kRealtimePrefix || uma_prefix_ == kScreenPrefix); | 108 RTC_DCHECK(uma_prefix_ == kRealtimePrefix || uma_prefix_ == kScreenPrefix); |
101 const int kIndex = uma_prefix_ == kScreenPrefix ? 1 : 0; | 109 const int kIndex = uma_prefix_ == kScreenPrefix ? 1 : 0; |
102 const int kMinRequiredSamples = 200; | 110 const int kMinRequiredSamples = 200; |
103 int in_width = input_width_counter_.Avg(kMinRequiredSamples); | 111 int in_width = input_width_counter_.Avg(kMinRequiredSamples); |
104 int in_height = input_height_counter_.Avg(kMinRequiredSamples); | 112 int in_height = input_height_counter_.Avg(kMinRequiredSamples); |
105 int in_fps = round(input_frame_rate_tracker_.ComputeTotalRate()); | 113 int in_fps = round(input_frame_rate_tracker_.ComputeTotalRate()); |
106 if (in_width != -1) { | 114 if (in_width != -1) { |
107 RTC_HISTOGRAMS_COUNTS_10000(kIndex, uma_prefix_ + "InputWidthInPixels", | 115 RTC_HISTOGRAMS_COUNTS_10000(kIndex, uma_prefix_ + "InputWidthInPixels", |
108 in_width); | 116 in_width); |
109 RTC_HISTOGRAMS_COUNTS_10000(kIndex, uma_prefix_ + "InputHeightInPixels", | 117 RTC_HISTOGRAMS_COUNTS_10000(kIndex, uma_prefix_ + "InputHeightInPixels", |
(...skipping 50 matching lines...) Loading... | |
160 int delay_ms = delay_counter_.Avg(kMinRequiredSamples); | 168 int delay_ms = delay_counter_.Avg(kMinRequiredSamples); |
161 if (delay_ms != -1) | 169 if (delay_ms != -1) |
162 RTC_HISTOGRAMS_COUNTS_100000(kIndex, uma_prefix_ + "SendSideDelayInMs", | 170 RTC_HISTOGRAMS_COUNTS_100000(kIndex, uma_prefix_ + "SendSideDelayInMs", |
163 delay_ms); | 171 delay_ms); |
164 | 172 |
165 int max_delay_ms = max_delay_counter_.Avg(kMinRequiredSamples); | 173 int max_delay_ms = max_delay_counter_.Avg(kMinRequiredSamples); |
166 if (max_delay_ms != -1) { | 174 if (max_delay_ms != -1) { |
167 RTC_HISTOGRAMS_COUNTS_100000(kIndex, uma_prefix_ + "SendSideDelayMaxInMs", | 175 RTC_HISTOGRAMS_COUNTS_100000(kIndex, uma_prefix_ + "SendSideDelayMaxInMs", |
168 max_delay_ms); | 176 max_delay_ms); |
169 } | 177 } |
178 | |
170 int fraction_lost = report_block_stats_.FractionLostInPercent(); | 179 int fraction_lost = report_block_stats_.FractionLostInPercent(); |
171 if (first_rtcp_stats_time_ms_ != -1) { | 180 if (first_rtcp_stats_time_ms_ != -1) { |
172 int64_t elapsed_time_ms = Clock::GetRealTimeClock()->TimeInMilliseconds() - | 181 int64_t elapsed_sec = |
173 first_rtcp_stats_time_ms_; | 182 (clock_->TimeInMilliseconds() - first_rtcp_stats_time_ms_) / 1000; |
174 if (elapsed_time_ms / 1000 >= metrics::kMinRunTimeInSeconds && | 183 if (elapsed_sec >= metrics::kMinRunTimeInSeconds) { |
175 fraction_lost != -1) { | 184 if (fraction_lost != -1) { |
176 RTC_HISTOGRAMS_PERCENTAGE( | 185 RTC_HISTOGRAMS_PERCENTAGE( |
177 kIndex, uma_prefix_ + "SentPacketsLostInPercent", fraction_lost); | 186 kIndex, uma_prefix_ + "SentPacketsLostInPercent", fraction_lost); |
187 } | |
188 | |
189 RtcpPacketTypeCounter counters; | |
190 for (uint32_t ssrc : config.rtp.ssrcs) { | |
191 auto it = current_stats.substreams.find(ssrc); | |
192 if (it == current_stats.substreams.end()) | |
193 continue; | |
194 | |
195 RtcpPacketTypeCounter stream_counters = | |
pbos-webrtc
2016/02/23 15:15:26
Comment here please.
sprang
2016/02/23 16:42:09
Done.
| |
196 it->second.rtcp_packet_type_counts; | |
197 it = start_stats_.substreams.find(ssrc); | |
pbos-webrtc
2016/02/23 15:15:26
kv =
sprang
2016/02/23 16:42:09
Done.
| |
198 if (it != start_stats_.substreams.end()) | |
199 stream_counters.Subtract(it->second.rtcp_packet_type_counts); | |
200 | |
201 counters.Add(stream_counters); | |
202 } | |
203 RTC_HISTOGRAMS_COUNTS_10000(kIndex, | |
204 uma_prefix_ + "NackPacketsReceivedPerMinute", | |
205 counters.nack_packets * 60 / elapsed_sec); | |
206 RTC_HISTOGRAMS_COUNTS_10000(kIndex, | |
207 uma_prefix_ + "FirPacketsReceivedPerMinute", | |
208 counters.fir_packets * 60 / elapsed_sec); | |
209 RTC_HISTOGRAMS_COUNTS_10000(kIndex, | |
210 uma_prefix_ + "PliPacketsReceivedPerMinute", | |
211 counters.pli_packets * 60 / elapsed_sec); | |
212 if (counters.nack_requests > 0) { | |
213 RTC_HISTOGRAMS_PERCENTAGE( | |
214 kIndex, uma_prefix_ + "UniqueNackRequestsReceivedInPercent", | |
215 counters.UniqueNackRequestsInPercent()); | |
216 } | |
178 } | 217 } |
179 } | 218 } |
180 } | 219 } |
181 | 220 |
182 void SendStatisticsProxy::SetContentType( | 221 void SendStatisticsProxy::SetContentType( |
183 VideoEncoderConfig::ContentType content_type) { | 222 VideoEncoderConfig::ContentType content_type) { |
184 rtc::CritScope lock(&crit_); | 223 rtc::CritScope lock(&crit_); |
185 if (content_type_ != content_type) { | 224 if (content_type_ != content_type) { |
186 uma_container_.reset(new UmaSamplesContainer(GetUmaPrefix(content_type))); | 225 uma_container_->UpdateHistograms(config_, stats_); |
226 uma_container_.reset( | |
227 new UmaSamplesContainer(GetUmaPrefix(content_type), stats_, clock_)); | |
187 content_type_ = content_type; | 228 content_type_ = content_type; |
188 } | 229 } |
189 } | 230 } |
190 | 231 |
191 void SendStatisticsProxy::OnEncoderImplementationName( | 232 void SendStatisticsProxy::OnEncoderImplementationName( |
192 const char* implementation_name) { | 233 const char* implementation_name) { |
193 rtc::CritScope lock(&crit_); | 234 rtc::CritScope lock(&crit_); |
194 stats_.encoder_implementation_name = implementation_name; | 235 stats_.encoder_implementation_name = implementation_name; |
195 } | 236 } |
196 | 237 |
(...skipping 249 matching lines...) Loading... | |
446 return Fraction(min_required_samples, 1000.0f); | 487 return Fraction(min_required_samples, 1000.0f); |
447 } | 488 } |
448 | 489 |
449 int SendStatisticsProxy::BoolSampleCounter::Fraction( | 490 int SendStatisticsProxy::BoolSampleCounter::Fraction( |
450 int min_required_samples, float multiplier) const { | 491 int min_required_samples, float multiplier) const { |
451 if (num_samples < min_required_samples || num_samples == 0) | 492 if (num_samples < min_required_samples || num_samples == 0) |
452 return -1; | 493 return -1; |
453 return static_cast<int>((sum * multiplier / num_samples) + 0.5f); | 494 return static_cast<int>((sum * multiplier / num_samples) + 0.5f); |
454 } | 495 } |
455 } // namespace webrtc | 496 } // namespace webrtc |
OLD | NEW |