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 #include "webrtc/video/send_statistics_proxy.h" | 11 #include "webrtc/video/send_statistics_proxy.h" |
12 | 12 |
13 #include <map> | 13 #include <map> |
14 | 14 |
15 #include "webrtc/base/checks.h" | 15 #include "webrtc/base/checks.h" |
16 | 16 |
17 #include "webrtc/system_wrappers/interface/critical_section_wrapper.h" | 17 #include "webrtc/system_wrappers/interface/critical_section_wrapper.h" |
18 #include "webrtc/system_wrappers/interface/logging.h" | 18 #include "webrtc/system_wrappers/interface/logging.h" |
| 19 #include "webrtc/system_wrappers/interface/metrics.h" |
19 | 20 |
20 namespace webrtc { | 21 namespace webrtc { |
21 | 22 |
22 const int SendStatisticsProxy::kStatsTimeoutMs = 5000; | 23 const int SendStatisticsProxy::kStatsTimeoutMs = 5000; |
23 | 24 |
24 SendStatisticsProxy::SendStatisticsProxy(Clock* clock, | 25 SendStatisticsProxy::SendStatisticsProxy(Clock* clock, |
25 const VideoSendStream::Config& config) | 26 const VideoSendStream::Config& config) |
26 : clock_(clock), | 27 : clock_(clock), config_(config), last_sent_frame_timestamp_(0) { |
27 config_(config) { | |
28 } | 28 } |
29 | 29 |
30 SendStatisticsProxy::~SendStatisticsProxy() {} | 30 SendStatisticsProxy::~SendStatisticsProxy() { |
| 31 UpdateHistograms(); |
| 32 } |
| 33 |
| 34 void SendStatisticsProxy::UpdateHistograms() { |
| 35 int input_fps = |
| 36 static_cast<int>(input_frame_rate_tracker_total_.units_second()); |
| 37 int sent_fps = |
| 38 static_cast<int>(sent_frame_rate_tracker_total_.units_second()); |
| 39 |
| 40 if (input_fps > 0) |
| 41 RTC_HISTOGRAM_COUNTS_100("WebRTC.Video.InputFramesPerSecond", input_fps); |
| 42 if (sent_fps > 0) |
| 43 RTC_HISTOGRAM_COUNTS_100("WebRTC.Video.SentFramesPerSecond", sent_fps); |
| 44 } |
31 | 45 |
32 void SendStatisticsProxy::OutgoingRate(const int video_channel, | 46 void SendStatisticsProxy::OutgoingRate(const int video_channel, |
33 const unsigned int framerate, | 47 const unsigned int framerate, |
34 const unsigned int bitrate) { | 48 const unsigned int bitrate) { |
35 rtc::CritScope lock(&crit_); | 49 rtc::CritScope lock(&crit_); |
36 stats_.encode_frame_rate = framerate; | 50 stats_.encode_frame_rate = framerate; |
37 stats_.media_bitrate_bps = bitrate; | 51 stats_.media_bitrate_bps = bitrate; |
38 } | 52 } |
39 | 53 |
40 void SendStatisticsProxy::CpuOveruseMetricsUpdated( | 54 void SendStatisticsProxy::CpuOveruseMetricsUpdated( |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
118 uint32_t ssrc = config_.rtp.ssrcs[simulcast_idx]; | 132 uint32_t ssrc = config_.rtp.ssrcs[simulcast_idx]; |
119 | 133 |
120 rtc::CritScope lock(&crit_); | 134 rtc::CritScope lock(&crit_); |
121 VideoSendStream::StreamStats* stats = GetStatsEntry(ssrc); | 135 VideoSendStream::StreamStats* stats = GetStatsEntry(ssrc); |
122 if (stats == nullptr) | 136 if (stats == nullptr) |
123 return; | 137 return; |
124 | 138 |
125 stats->width = encoded_image._encodedWidth; | 139 stats->width = encoded_image._encodedWidth; |
126 stats->height = encoded_image._encodedHeight; | 140 stats->height = encoded_image._encodedHeight; |
127 update_times_[ssrc].resolution_update_ms = clock_->TimeInMilliseconds(); | 141 update_times_[ssrc].resolution_update_ms = clock_->TimeInMilliseconds(); |
| 142 if (encoded_image._timeStamp != last_sent_frame_timestamp_) { |
| 143 last_sent_frame_timestamp_ = encoded_image._timeStamp; |
| 144 sent_frame_rate_tracker_total_.Update(1); |
| 145 } |
128 } | 146 } |
129 | 147 |
130 void SendStatisticsProxy::OnIncomingFrame() { | 148 void SendStatisticsProxy::OnIncomingFrame() { |
131 rtc::CritScope lock(&crit_); | 149 rtc::CritScope lock(&crit_); |
132 input_frame_rate_tracker_.Update(1); | 150 input_frame_rate_tracker_.Update(1); |
| 151 input_frame_rate_tracker_total_.Update(1); |
133 } | 152 } |
134 | 153 |
135 void SendStatisticsProxy::RtcpPacketTypesCounterUpdated( | 154 void SendStatisticsProxy::RtcpPacketTypesCounterUpdated( |
136 uint32_t ssrc, | 155 uint32_t ssrc, |
137 const RtcpPacketTypeCounter& packet_counter) { | 156 const RtcpPacketTypeCounter& packet_counter) { |
138 rtc::CritScope lock(&crit_); | 157 rtc::CritScope lock(&crit_); |
139 VideoSendStream::StreamStats* stats = GetStatsEntry(ssrc); | 158 VideoSendStream::StreamStats* stats = GetStatsEntry(ssrc); |
140 if (stats == nullptr) | 159 if (stats == nullptr) |
141 return; | 160 return; |
142 | 161 |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
194 uint32_t ssrc) { | 213 uint32_t ssrc) { |
195 rtc::CritScope lock(&crit_); | 214 rtc::CritScope lock(&crit_); |
196 VideoSendStream::StreamStats* stats = GetStatsEntry(ssrc); | 215 VideoSendStream::StreamStats* stats = GetStatsEntry(ssrc); |
197 if (stats == nullptr) | 216 if (stats == nullptr) |
198 return; | 217 return; |
199 stats->avg_delay_ms = avg_delay_ms; | 218 stats->avg_delay_ms = avg_delay_ms; |
200 stats->max_delay_ms = max_delay_ms; | 219 stats->max_delay_ms = max_delay_ms; |
201 } | 220 } |
202 | 221 |
203 } // namespace webrtc | 222 } // namespace webrtc |
OLD | NEW |