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 28 matching lines...) Expand all Loading... |
39 void SendStatisticsProxy::UpdateHistograms() { | 39 void SendStatisticsProxy::UpdateHistograms() { |
40 int input_fps = | 40 int input_fps = |
41 static_cast<int>(input_frame_rate_tracker_total_.units_second()); | 41 static_cast<int>(input_frame_rate_tracker_total_.units_second()); |
42 if (input_fps > 0) | 42 if (input_fps > 0) |
43 RTC_HISTOGRAM_COUNTS_100("WebRTC.Video.InputFramesPerSecond", input_fps); | 43 RTC_HISTOGRAM_COUNTS_100("WebRTC.Video.InputFramesPerSecond", input_fps); |
44 int sent_fps = | 44 int sent_fps = |
45 static_cast<int>(sent_frame_rate_tracker_total_.units_second()); | 45 static_cast<int>(sent_frame_rate_tracker_total_.units_second()); |
46 if (sent_fps > 0) | 46 if (sent_fps > 0) |
47 RTC_HISTOGRAM_COUNTS_100("WebRTC.Video.SentFramesPerSecond", sent_fps); | 47 RTC_HISTOGRAM_COUNTS_100("WebRTC.Video.SentFramesPerSecond", sent_fps); |
48 | 48 |
49 const int kMinRequiredSamples = 100; | 49 const int kMinRequiredSamples = 200; |
50 int in_width = input_width_counter_.Avg(kMinRequiredSamples); | 50 int in_width = input_width_counter_.Avg(kMinRequiredSamples); |
51 int in_height = input_height_counter_.Avg(kMinRequiredSamples); | 51 int in_height = input_height_counter_.Avg(kMinRequiredSamples); |
52 if (in_width != -1) { | 52 if (in_width != -1) { |
53 RTC_HISTOGRAM_COUNTS_10000("WebRTC.Video.InputWidthInPixels", in_width); | 53 RTC_HISTOGRAM_COUNTS_10000("WebRTC.Video.InputWidthInPixels", in_width); |
54 RTC_HISTOGRAM_COUNTS_10000("WebRTC.Video.InputHeightInPixels", in_height); | 54 RTC_HISTOGRAM_COUNTS_10000("WebRTC.Video.InputHeightInPixels", in_height); |
55 } | 55 } |
56 int sent_width = sent_width_counter_.Avg(kMinRequiredSamples); | 56 int sent_width = sent_width_counter_.Avg(kMinRequiredSamples); |
57 int sent_height = sent_height_counter_.Avg(kMinRequiredSamples); | 57 int sent_height = sent_height_counter_.Avg(kMinRequiredSamples); |
58 if (sent_width != -1) { | 58 if (sent_width != -1) { |
59 RTC_HISTOGRAM_COUNTS_10000("WebRTC.Video.SentWidthInPixels", sent_width); | 59 RTC_HISTOGRAM_COUNTS_10000("WebRTC.Video.SentWidthInPixels", sent_width); |
60 RTC_HISTOGRAM_COUNTS_10000("WebRTC.Video.SentHeightInPixels", sent_height); | 60 RTC_HISTOGRAM_COUNTS_10000("WebRTC.Video.SentHeightInPixels", sent_height); |
61 } | 61 } |
| 62 int encode_ms = encode_time_counter_.Avg(kMinRequiredSamples); |
| 63 if (encode_ms != -1) |
| 64 RTC_HISTOGRAM_COUNTS_1000("WebRTC.Video.EncodeTimeInMs", encode_ms); |
62 } | 65 } |
63 | 66 |
64 void SendStatisticsProxy::OutgoingRate(const int video_channel, | 67 void SendStatisticsProxy::OutgoingRate(const int video_channel, |
65 const unsigned int framerate, | 68 const unsigned int framerate, |
66 const unsigned int bitrate) { | 69 const unsigned int bitrate) { |
67 rtc::CritScope lock(&crit_); | 70 rtc::CritScope lock(&crit_); |
68 stats_.encode_frame_rate = framerate; | 71 stats_.encode_frame_rate = framerate; |
69 stats_.media_bitrate_bps = bitrate; | 72 stats_.media_bitrate_bps = bitrate; |
70 } | 73 } |
71 | 74 |
72 void SendStatisticsProxy::CpuOveruseMetricsUpdated( | 75 void SendStatisticsProxy::CpuOveruseMetricsUpdated( |
73 const CpuOveruseMetrics& metrics) { | 76 const CpuOveruseMetrics& metrics) { |
74 rtc::CritScope lock(&crit_); | 77 rtc::CritScope lock(&crit_); |
| 78 // TODO(asapersson): Change to use OnEncodedFrame() for avg_encode_time_ms. |
75 stats_.avg_encode_time_ms = metrics.avg_encode_time_ms; | 79 stats_.avg_encode_time_ms = metrics.avg_encode_time_ms; |
76 stats_.encode_usage_percent = metrics.encode_usage_percent; | 80 stats_.encode_usage_percent = metrics.encode_usage_percent; |
77 } | 81 } |
78 | 82 |
79 void SendStatisticsProxy::SuspendChange(int video_channel, bool is_suspended) { | 83 void SendStatisticsProxy::SuspendChange(int video_channel, bool is_suspended) { |
80 rtc::CritScope lock(&crit_); | 84 rtc::CritScope lock(&crit_); |
81 stats_.suspended = is_suspended; | 85 stats_.suspended = is_suspended; |
82 } | 86 } |
83 | 87 |
84 VideoSendStream::Stats SendStatisticsProxy::GetStats() { | 88 VideoSendStream::Stats SendStatisticsProxy::GetStats() { |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
179 } | 183 } |
180 | 184 |
181 void SendStatisticsProxy::OnIncomingFrame(int width, int height) { | 185 void SendStatisticsProxy::OnIncomingFrame(int width, int height) { |
182 rtc::CritScope lock(&crit_); | 186 rtc::CritScope lock(&crit_); |
183 input_frame_rate_tracker_.Update(1); | 187 input_frame_rate_tracker_.Update(1); |
184 input_frame_rate_tracker_total_.Update(1); | 188 input_frame_rate_tracker_total_.Update(1); |
185 input_width_counter_.Add(width); | 189 input_width_counter_.Add(width); |
186 input_height_counter_.Add(height); | 190 input_height_counter_.Add(height); |
187 } | 191 } |
188 | 192 |
| 193 void SendStatisticsProxy::OnEncodedFrame(int encode_time_ms) { |
| 194 rtc::CritScope lock(&crit_); |
| 195 encode_time_counter_.Add(encode_time_ms); |
| 196 } |
| 197 |
189 void SendStatisticsProxy::RtcpPacketTypesCounterUpdated( | 198 void SendStatisticsProxy::RtcpPacketTypesCounterUpdated( |
190 uint32_t ssrc, | 199 uint32_t ssrc, |
191 const RtcpPacketTypeCounter& packet_counter) { | 200 const RtcpPacketTypeCounter& packet_counter) { |
192 rtc::CritScope lock(&crit_); | 201 rtc::CritScope lock(&crit_); |
193 VideoSendStream::StreamStats* stats = GetStatsEntry(ssrc); | 202 VideoSendStream::StreamStats* stats = GetStatsEntry(ssrc); |
194 if (stats == nullptr) | 203 if (stats == nullptr) |
195 return; | 204 return; |
196 | 205 |
197 stats->rtcp_packet_type_counts = packet_counter; | 206 stats->rtcp_packet_type_counts = packet_counter; |
198 } | 207 } |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
259 ++num_samples; | 268 ++num_samples; |
260 } | 269 } |
261 | 270 |
262 int SendStatisticsProxy::SampleCounter::Avg(int min_required_samples) const { | 271 int SendStatisticsProxy::SampleCounter::Avg(int min_required_samples) const { |
263 if (num_samples < min_required_samples || num_samples == 0) | 272 if (num_samples < min_required_samples || num_samples == 0) |
264 return -1; | 273 return -1; |
265 return sum / num_samples; | 274 return sum / num_samples; |
266 } | 275 } |
267 | 276 |
268 } // namespace webrtc | 277 } // namespace webrtc |
OLD | NEW |