diff options
author | Chih-hung Hsieh <chh@google.com> | 2016-01-20 17:50:13 +0000 |
---|---|---|
committer | android-build-merger <android-build-merger@google.com> | 2016-01-20 17:50:13 +0000 |
commit | b3cb8ab4ede8bb77f0bdef2715efc2c1e6267072 (patch) | |
tree | 28c4cf735dd5bd9cc8f1ccd06fff8a173b20d1cb /webrtc/video/send_statistics_proxy.cc | |
parent | a4acd9d6bc9b3b033d7d274316e75ee067df8d20 (diff) | |
parent | 9a337512d97e37afc142dee4fd50a41b741a87d2 (diff) | |
download | webrtc-b3cb8ab4ede8bb77f0bdef2715efc2c1e6267072.tar.gz |
Merge "Merge upstream SHA 04cb763"android-cts_7.1_r1android-cts-7.1_r9android-cts-7.1_r8android-cts-7.1_r7android-cts-7.1_r6android-cts-7.1_r5android-cts-7.1_r4android-cts-7.1_r3android-cts-7.1_r29android-cts-7.1_r28android-cts-7.1_r27android-cts-7.1_r26android-cts-7.1_r25android-cts-7.1_r24android-cts-7.1_r23android-cts-7.1_r22android-cts-7.1_r21android-cts-7.1_r20android-cts-7.1_r2android-cts-7.1_r19android-cts-7.1_r18android-cts-7.1_r17android-cts-7.1_r16android-cts-7.1_r15android-cts-7.1_r14android-cts-7.1_r13android-cts-7.1_r12android-cts-7.1_r11android-cts-7.1_r10android-cts-7.1_r1android-cts-7.0_r9android-cts-7.0_r8android-cts-7.0_r7android-cts-7.0_r6android-cts-7.0_r5android-cts-7.0_r4android-cts-7.0_r33android-cts-7.0_r32android-cts-7.0_r31android-cts-7.0_r30android-cts-7.0_r3android-cts-7.0_r29android-cts-7.0_r28android-cts-7.0_r27android-cts-7.0_r26android-cts-7.0_r25android-cts-7.0_r24android-cts-7.0_r23android-cts-7.0_r22android-cts-7.0_r21android-cts-7.0_r20android-cts-7.0_r2android-cts-7.0_r19android-cts-7.0_r18android-cts-7.0_r17android-cts-7.0_r16android-cts-7.0_r15android-cts-7.0_r14android-cts-7.0_r13android-cts-7.0_r12android-cts-7.0_r11android-cts-7.0_r10android-cts-7.0_r1android-7.1.2_r9android-7.1.2_r8android-7.1.2_r6android-7.1.2_r5android-7.1.2_r4android-7.1.2_r39android-7.1.2_r38android-7.1.2_r37android-7.1.2_r36android-7.1.2_r33android-7.1.2_r32android-7.1.2_r30android-7.1.2_r3android-7.1.2_r29android-7.1.2_r28android-7.1.2_r27android-7.1.2_r25android-7.1.2_r24android-7.1.2_r23android-7.1.2_r2android-7.1.2_r19android-7.1.2_r18android-7.1.2_r17android-7.1.2_r16android-7.1.2_r15android-7.1.2_r14android-7.1.2_r13android-7.1.2_r12android-7.1.2_r11android-7.1.2_r10android-7.1.2_r1android-7.1.1_r9android-7.1.1_r8android-7.1.1_r7android-7.1.1_r61android-7.1.1_r60android-7.1.1_r6android-7.1.1_r59android-7.1.1_r58android-7.1.1_r57android-7.1.1_r56android-7.1.1_r55android-7.1.1_r54android-7.1.1_r53android-7.1.1_r52android-7.1.1_r51android-7.1.1_r50android-7.1.1_r49android-7.1.1_r48android-7.1.1_r47android-7.1.1_r46android-7.1.1_r45android-7.1.1_r44android-7.1.1_r43android-7.1.1_r42android-7.1.1_r41android-7.1.1_r40android-7.1.1_r4android-7.1.1_r39android-7.1.1_r38android-7.1.1_r35android-7.1.1_r33android-7.1.1_r32android-7.1.1_r31android-7.1.1_r3android-7.1.1_r28android-7.1.1_r27android-7.1.1_r26android-7.1.1_r25android-7.1.1_r24android-7.1.1_r23android-7.1.1_r22android-7.1.1_r21android-7.1.1_r20android-7.1.1_r2android-7.1.1_r17android-7.1.1_r16android-7.1.1_r15android-7.1.1_r14android-7.1.1_r13android-7.1.1_r12android-7.1.1_r11android-7.1.1_r10android-7.1.1_r1android-7.1.0_r7android-7.1.0_r6android-7.1.0_r5android-7.1.0_r4android-7.1.0_r3android-7.1.0_r2android-7.1.0_r1android-7.0.0_r9android-7.0.0_r8android-7.0.0_r7android-7.0.0_r6android-7.0.0_r5android-7.0.0_r4android-7.0.0_r36android-7.0.0_r35android-7.0.0_r34android-7.0.0_r33android-7.0.0_r32android-7.0.0_r31android-7.0.0_r30android-7.0.0_r3android-7.0.0_r29android-7.0.0_r28android-7.0.0_r27android-7.0.0_r24android-7.0.0_r21android-7.0.0_r19android-7.0.0_r17android-7.0.0_r15android-7.0.0_r14android-7.0.0_r13android-7.0.0_r12android-7.0.0_r11android-7.0.0_r10android-7.0.0_r1nougat-releasenougat-mr2.3-releasenougat-mr2.2-releasenougat-mr2.1-releasenougat-mr2-security-releasenougat-mr2-releasenougat-mr2-pixel-releasenougat-mr2-devnougat-mr1.8-releasenougat-mr1.7-releasenougat-mr1.6-releasenougat-mr1.5-releasenougat-mr1.4-releasenougat-mr1.3-releasenougat-mr1.2-releasenougat-mr1.1-releasenougat-mr1-volantis-releasenougat-mr1-security-releasenougat-mr1-releasenougat-mr1-flounder-releasenougat-mr1-devnougat-mr1-cts-releasenougat-mr0.5-releasenougat-dr1-releasenougat-devnougat-cts-releasenougat-bugfix-release
am: 9a337512d9
* commit '9a337512d97e37afc142dee4fd50a41b741a87d2': (797 commits)
Add tests for verifying transport feedback for audio and video.
Eliminate defines in talk/
Revert of Update with new default boringssl no-aes cipher suites. Re-enable tests. (patchset #3 id:40001 of https://codereview.webrtc.org/1550773002/ )
Remove assert which was incorrectly added to TcpPort::OnSentPacket.
Reland Connect TurnPort and TCPPort to AsyncPacketSocket::SignalSentPacket.
Update with new default boringssl no-aes cipher suites. Re-enable tests.
Revert of Connect TurnPort and TCPPort to AsyncPacketSocket::SignalSentPacket. (patchset #3 id:40001 of https://codereview.webrtc.org/1577873003/ )
Re-land: "Use an explicit identifier in Config"
Connect TurnPort and TCPPort to AsyncPacketSocket::SignalSentPacket.
Revert of Delete remnants of non-square pixel support from cricket::VideoFrame. (patchset #1 id:1 of https://codereview.webrtc.org/1586613002/ )
Remove libfuzzer trybot from default trybot set.
Add ramp-up tests for transport sequence number with and w/o audio.
Delete remnants of non-square pixel support from cricket::VideoFrame.
Fix IPAddress::ToSensitiveString() to avoid dependency on inet_ntop().
Revert of Storing raw audio sink for default audio track. (patchset #7 id:120001 of https://codereview.chromium.org/1551813002/ )
Re-enable tests that failed under Linux_Msan.
Revert of Use an explicit identifier in Config (patchset #4 id:60001 of https://codereview.webrtc.org/1538643004/ )
Roll chromium_revision 346fea9..099be58 (369082:369139)
Disable WebRtcVideoChannel2BaseTest.SendManyResizeOnce for TSan
Add build_protobuf variable.
...
Diffstat (limited to 'webrtc/video/send_statistics_proxy.cc')
-rw-r--r-- | webrtc/video/send_statistics_proxy.cc | 173 |
1 files changed, 116 insertions, 57 deletions
diff --git a/webrtc/video/send_statistics_proxy.cc b/webrtc/video/send_statistics_proxy.cc index 5be9970583..d2964b21da 100644 --- a/webrtc/video/send_statistics_proxy.cc +++ b/webrtc/video/send_statistics_proxy.cc @@ -11,16 +11,18 @@ #include "webrtc/video/send_statistics_proxy.h" #include <algorithm> +#include <cmath> #include <map> #include "webrtc/base/checks.h" - #include "webrtc/base/logging.h" #include "webrtc/system_wrappers/include/critical_section_wrapper.h" #include "webrtc/system_wrappers/include/metrics.h" namespace webrtc { namespace { +const float kEncodeTimeWeigthFactor = 0.5f; + // Used by histograms. Values of entries should not be changed. enum HistogramCodecType { kVideoUnknown = 0, @@ -30,6 +32,17 @@ enum HistogramCodecType { kVideoMax = 64, }; +const char* GetUmaPrefix(VideoEncoderConfig::ContentType content_type) { + switch (content_type) { + case VideoEncoderConfig::ContentType::kRealtimeVideo: + return "WebRTC.Video."; + case VideoEncoderConfig::ContentType::kScreen: + return "WebRTC.Video.Screenshare."; + } + RTC_NOTREACHED(); + return nullptr; +} + HistogramCodecType PayloadNameToHistogramCodecType( const std::string& payload_name) { if (payload_name == "VP8") { @@ -44,7 +57,7 @@ HistogramCodecType PayloadNameToHistogramCodecType( } void UpdateCodecTypeHistogram(const std::string& payload_name) { - RTC_HISTOGRAM_ENUMERATION("WebRTC.Video.Encoder.CodecType", + RTC_HISTOGRAM_ENUMERATION_SPARSE("WebRTC.Video.Encoder.CodecType", PayloadNameToHistogramCodecType(payload_name), kVideoMax); } } // namespace @@ -52,77 +65,114 @@ void UpdateCodecTypeHistogram(const std::string& payload_name) { const int SendStatisticsProxy::kStatsTimeoutMs = 5000; -SendStatisticsProxy::SendStatisticsProxy(Clock* clock, - const VideoSendStream::Config& config) +SendStatisticsProxy::SendStatisticsProxy( + Clock* clock, + const VideoSendStream::Config& config, + VideoEncoderConfig::ContentType content_type) : clock_(clock), config_(config), - input_frame_rate_tracker_(100u, 10u), - sent_frame_rate_tracker_(100u, 10u), + content_type_(content_type), last_sent_frame_timestamp_(0), - max_sent_width_per_timestamp_(0), - max_sent_height_per_timestamp_(0) { + encode_time_(kEncodeTimeWeigthFactor), + uma_container_(new UmaSamplesContainer(GetUmaPrefix(content_type_))) { UpdateCodecTypeHistogram(config_.encoder_settings.payload_name); } -SendStatisticsProxy::~SendStatisticsProxy() { +SendStatisticsProxy::~SendStatisticsProxy() {} + +SendStatisticsProxy::UmaSamplesContainer::UmaSamplesContainer( + const char* prefix) + : uma_prefix_(prefix), + max_sent_width_per_timestamp_(0), + max_sent_height_per_timestamp_(0), + input_frame_rate_tracker_(100u, 10u), + sent_frame_rate_tracker_(100u, 10u) {} + +SendStatisticsProxy::UmaSamplesContainer::~UmaSamplesContainer() { UpdateHistograms(); } -void SendStatisticsProxy::UpdateHistograms() { - int input_fps = - static_cast<int>(input_frame_rate_tracker_.ComputeTotalRate()); - if (input_fps > 0) - RTC_HISTOGRAM_COUNTS_100("WebRTC.Video.InputFramesPerSecond", input_fps); - int sent_fps = - static_cast<int>(sent_frame_rate_tracker_.ComputeTotalRate()); - if (sent_fps > 0) - RTC_HISTOGRAM_COUNTS_100("WebRTC.Video.SentFramesPerSecond", sent_fps); - +void SendStatisticsProxy::UmaSamplesContainer::UpdateHistograms() { const int kMinRequiredSamples = 200; int in_width = input_width_counter_.Avg(kMinRequiredSamples); int in_height = input_height_counter_.Avg(kMinRequiredSamples); + int in_fps = round(input_frame_rate_tracker_.ComputeTotalRate()); if (in_width != -1) { - RTC_HISTOGRAM_COUNTS_10000("WebRTC.Video.InputWidthInPixels", in_width); - RTC_HISTOGRAM_COUNTS_10000("WebRTC.Video.InputHeightInPixels", in_height); + RTC_HISTOGRAM_COUNTS_SPARSE_10000(uma_prefix_ + "InputWidthInPixels", + in_width); + RTC_HISTOGRAM_COUNTS_SPARSE_10000(uma_prefix_ + "InputHeightInPixels", + in_height); + RTC_HISTOGRAM_COUNTS_SPARSE_100(uma_prefix_ + "InputFramesPerSecond", + in_fps); } int sent_width = sent_width_counter_.Avg(kMinRequiredSamples); int sent_height = sent_height_counter_.Avg(kMinRequiredSamples); + int sent_fps = round(sent_frame_rate_tracker_.ComputeTotalRate()); if (sent_width != -1) { - RTC_HISTOGRAM_COUNTS_10000("WebRTC.Video.SentWidthInPixels", sent_width); - RTC_HISTOGRAM_COUNTS_10000("WebRTC.Video.SentHeightInPixels", sent_height); + RTC_HISTOGRAM_COUNTS_SPARSE_10000(uma_prefix_ + "SentWidthInPixels", + sent_width); + RTC_HISTOGRAM_COUNTS_SPARSE_10000(uma_prefix_ + "SentHeightInPixels", + sent_height); + RTC_HISTOGRAM_COUNTS_SPARSE_100(uma_prefix_ + "SentFramesPerSecond", + sent_fps); } int encode_ms = encode_time_counter_.Avg(kMinRequiredSamples); if (encode_ms != -1) - RTC_HISTOGRAM_COUNTS_1000("WebRTC.Video.EncodeTimeInMs", encode_ms); + RTC_HISTOGRAM_COUNTS_SPARSE_1000(uma_prefix_ + "EncodeTimeInMs", encode_ms); int key_frames_permille = key_frame_counter_.Permille(kMinRequiredSamples); if (key_frames_permille != -1) { - RTC_HISTOGRAM_COUNTS_1000("WebRTC.Video.KeyFramesSentInPermille", - key_frames_permille); + RTC_HISTOGRAM_COUNTS_SPARSE_1000(uma_prefix_ + "KeyFramesSentInPermille", + key_frames_permille); } int quality_limited = quality_limited_frame_counter_.Percent(kMinRequiredSamples); if (quality_limited != -1) { - RTC_HISTOGRAM_PERCENTAGE("WebRTC.Video.QualityLimitedResolutionInPercent", - quality_limited); + RTC_HISTOGRAM_PERCENTAGE_SPARSE( + uma_prefix_ + "QualityLimitedResolutionInPercent", quality_limited); } int downscales = quality_downscales_counter_.Avg(kMinRequiredSamples); if (downscales != -1) { - RTC_HISTOGRAM_ENUMERATION("WebRTC.Video.QualityLimitedResolutionDownscales", - downscales, 20); + RTC_HISTOGRAM_ENUMERATION_SPARSE( + uma_prefix_ + "QualityLimitedResolutionDownscales", downscales, 20); } int bw_limited = bw_limited_frame_counter_.Percent(kMinRequiredSamples); if (bw_limited != -1) { - RTC_HISTOGRAM_PERCENTAGE("WebRTC.Video.BandwidthLimitedResolutionInPercent", - bw_limited); + RTC_HISTOGRAM_PERCENTAGE_SPARSE( + uma_prefix_ + "BandwidthLimitedResolutionInPercent", bw_limited); } int num_disabled = bw_resolutions_disabled_counter_.Avg(kMinRequiredSamples); if (num_disabled != -1) { - RTC_HISTOGRAM_ENUMERATION( - "WebRTC.Video.BandwidthLimitedResolutionsDisabled", num_disabled, 10); + RTC_HISTOGRAM_ENUMERATION_SPARSE( + uma_prefix_ + "BandwidthLimitedResolutionsDisabled", num_disabled, 10); + } + int delay_ms = delay_counter_.Avg(kMinRequiredSamples); + if (delay_ms != -1) + RTC_HISTOGRAM_COUNTS_SPARSE_100000(uma_prefix_ + "SendSideDelayInMs", + delay_ms); + + int max_delay_ms = max_delay_counter_.Avg(kMinRequiredSamples); + if (max_delay_ms != -1) { + RTC_HISTOGRAM_COUNTS_SPARSE_100000(uma_prefix_ + "SendSideDelayMaxInMs", + max_delay_ms); + } +} + +void SendStatisticsProxy::SetContentType( + VideoEncoderConfig::ContentType content_type) { + rtc::CritScope lock(&crit_); + if (content_type_ != content_type) { + uma_container_.reset(new UmaSamplesContainer(GetUmaPrefix(content_type))); + content_type_ = content_type; } } +void SendStatisticsProxy::OnEncoderImplementationName( + const char* implementation_name) { + rtc::CritScope lock(&crit_); + stats_.encoder_implementation_name = implementation_name; +} + void SendStatisticsProxy::OnOutgoingRate(uint32_t framerate, uint32_t bitrate) { rtc::CritScope lock(&crit_); stats_.encode_frame_rate = framerate; @@ -132,8 +182,6 @@ void SendStatisticsProxy::OnOutgoingRate(uint32_t framerate, uint32_t bitrate) { void SendStatisticsProxy::CpuOveruseMetricsUpdated( const CpuOveruseMetrics& metrics) { rtc::CritScope lock(&crit_); - // TODO(asapersson): Change to use OnEncodedFrame() for avg_encode_time_ms. - stats_.avg_encode_time_ms = metrics.avg_encode_time_ms; stats_.encode_usage_percent = metrics.encode_usage_percent; } @@ -146,7 +194,7 @@ VideoSendStream::Stats SendStatisticsProxy::GetStats() { rtc::CritScope lock(&crit_); PurgeOldStats(); stats_.input_frame_rate = - static_cast<int>(input_frame_rate_tracker_.ComputeRate()); + round(uma_container_->input_frame_rate_tracker_.ComputeRate()); return stats_; } @@ -219,23 +267,28 @@ void SendStatisticsProxy::OnSendEncodedImage( stats->height = encoded_image._encodedHeight; update_times_[ssrc].resolution_update_ms = clock_->TimeInMilliseconds(); - key_frame_counter_.Add(encoded_image._frameType == kVideoFrameKey); + uma_container_->key_frame_counter_.Add(encoded_image._frameType == + kVideoFrameKey); + + stats_.bw_limited_resolution = + encoded_image.adapt_reason_.quality_resolution_downscales > 0 || + encoded_image.adapt_reason_.bw_resolutions_disabled > 0; if (encoded_image.adapt_reason_.quality_resolution_downscales != -1) { bool downscaled = encoded_image.adapt_reason_.quality_resolution_downscales > 0; - quality_limited_frame_counter_.Add(downscaled); + uma_container_->quality_limited_frame_counter_.Add(downscaled); if (downscaled) { - quality_downscales_counter_.Add( + uma_container_->quality_downscales_counter_.Add( encoded_image.adapt_reason_.quality_resolution_downscales); } } if (encoded_image.adapt_reason_.bw_resolutions_disabled != -1) { bool bw_limited = encoded_image.adapt_reason_.bw_resolutions_disabled > 0; - bw_limited_frame_counter_.Add(bw_limited); + uma_container_->bw_limited_frame_counter_.Add(bw_limited); if (bw_limited) { - bw_resolutions_disabled_counter_.Add( - encoded_image.adapt_reason_.bw_resolutions_disabled); + uma_container_->bw_resolutions_disabled_counter_.Add( + encoded_image.adapt_reason_.bw_resolutions_disabled); } } @@ -244,31 +297,35 @@ void SendStatisticsProxy::OnSendEncodedImage( // are encoded before the next start. if (last_sent_frame_timestamp_ > 0 && encoded_image._timeStamp != last_sent_frame_timestamp_) { - sent_frame_rate_tracker_.AddSamples(1); - sent_width_counter_.Add(max_sent_width_per_timestamp_); - sent_height_counter_.Add(max_sent_height_per_timestamp_); - max_sent_width_per_timestamp_ = 0; - max_sent_height_per_timestamp_ = 0; + uma_container_->sent_frame_rate_tracker_.AddSamples(1); + uma_container_->sent_width_counter_.Add( + uma_container_->max_sent_width_per_timestamp_); + uma_container_->sent_height_counter_.Add( + uma_container_->max_sent_height_per_timestamp_); + uma_container_->max_sent_width_per_timestamp_ = 0; + uma_container_->max_sent_height_per_timestamp_ = 0; } last_sent_frame_timestamp_ = encoded_image._timeStamp; - max_sent_width_per_timestamp_ = - std::max(max_sent_width_per_timestamp_, + uma_container_->max_sent_width_per_timestamp_ = + std::max(uma_container_->max_sent_width_per_timestamp_, static_cast<int>(encoded_image._encodedWidth)); - max_sent_height_per_timestamp_ = - std::max(max_sent_height_per_timestamp_, + uma_container_->max_sent_height_per_timestamp_ = + std::max(uma_container_->max_sent_height_per_timestamp_, static_cast<int>(encoded_image._encodedHeight)); } void SendStatisticsProxy::OnIncomingFrame(int width, int height) { rtc::CritScope lock(&crit_); - input_frame_rate_tracker_.AddSamples(1); - input_width_counter_.Add(width); - input_height_counter_.Add(height); + uma_container_->input_frame_rate_tracker_.AddSamples(1); + uma_container_->input_width_counter_.Add(width); + uma_container_->input_height_counter_.Add(height); } void SendStatisticsProxy::OnEncodedFrame(int encode_time_ms) { rtc::CritScope lock(&crit_); - encode_time_counter_.Add(encode_time_ms); + uma_container_->encode_time_counter_.Add(encode_time_ms); + encode_time_.Apply(1.0f, encode_time_ms); + stats_.avg_encode_time_ms = round(encode_time_.filtered()); } void SendStatisticsProxy::RtcpPacketTypesCounterUpdated( @@ -337,6 +394,9 @@ void SendStatisticsProxy::SendSideDelayUpdated(int avg_delay_ms, return; stats->avg_delay_ms = avg_delay_ms; stats->max_delay_ms = max_delay_ms; + + uma_container_->delay_counter_.Add(avg_delay_ms); + uma_container_->max_delay_counter_.Add(max_delay_ms); } void SendStatisticsProxy::SampleCounter::Add(int sample) { @@ -372,5 +432,4 @@ int SendStatisticsProxy::BoolSampleCounter::Fraction( return -1; return static_cast<int>((sum * multiplier / num_samples) + 0.5f); } - } // namespace webrtc |