From 505945aed7dea44a35e88a715dbeffe27611449b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niels=20M=C3=B6ller?= Date: Thu, 17 Mar 2016 12:20:41 +0100 Subject: [PATCH] Delete unused VideoCapturer statistics. It appears that the adapt_frame_drops, effects_frame_drops, and capturer_frame_time statistics are never used. They are collected by cricket::VideoCapturer, and copied into VideoSenderInfo by the VideoMediaChannel::GetStats method. So delete the code to generate the statistics, and the VariableInfo template which had no other uses. BUG=webrtc:5426 R=pbos@webrtc.org, pthatcher@webrtc.org Review URL: https://codereview.webrtc.org/1804133003 . Cr-Commit-Position: refs/heads/master@{#12032} --- .../webrtc/objc/avfoundationvideocapturer.h | 4 ++ .../webrtc/objc/avfoundationvideocapturer.mm | 1 + webrtc/api/objc/avfoundationvideocapturer.h | 4 ++ webrtc/api/objc/avfoundationvideocapturer.mm | 1 + webrtc/media/base/mediachannel.h | 17 -------- webrtc/media/base/videocapturer.cc | 41 +------------------ webrtc/media/base/videocapturer.h | 25 ++--------- webrtc/media/engine/webrtcvideoengine2.cc | 4 +- 8 files changed, 16 insertions(+), 81 deletions(-) diff --git a/talk/app/webrtc/objc/avfoundationvideocapturer.h b/talk/app/webrtc/objc/avfoundationvideocapturer.h index 1c910a84b8..69ade5f1e0 100644 --- a/talk/app/webrtc/objc/avfoundationvideocapturer.h +++ b/talk/app/webrtc/objc/avfoundationvideocapturer.h @@ -35,6 +35,10 @@ @class RTCAVFoundationVideoCapturerInternal; +namespace rtc { +class Thread; +} // namespace rtc + namespace webrtc { class AVFoundationVideoCapturer : public cricket::VideoCapturer { diff --git a/talk/app/webrtc/objc/avfoundationvideocapturer.mm b/talk/app/webrtc/objc/avfoundationvideocapturer.mm index f984590189..fa1443d1da 100644 --- a/talk/app/webrtc/objc/avfoundationvideocapturer.mm +++ b/talk/app/webrtc/objc/avfoundationvideocapturer.mm @@ -28,6 +28,7 @@ #include "talk/app/webrtc/objc/avfoundationvideocapturer.h" #include "webrtc/base/bind.h" +#include "webrtc/base/thread.h" #import #import diff --git a/webrtc/api/objc/avfoundationvideocapturer.h b/webrtc/api/objc/avfoundationvideocapturer.h index 83ee70385e..dbc98e7262 100644 --- a/webrtc/api/objc/avfoundationvideocapturer.h +++ b/webrtc/api/objc/avfoundationvideocapturer.h @@ -19,6 +19,10 @@ @class RTCAVFoundationVideoCapturerInternal; +namespace rtc { +class Thread; +} // namespace rtc + namespace webrtc { class AVFoundationVideoCapturer : public cricket::VideoCapturer { diff --git a/webrtc/api/objc/avfoundationvideocapturer.mm b/webrtc/api/objc/avfoundationvideocapturer.mm index c466512bd0..54b06c0264 100644 --- a/webrtc/api/objc/avfoundationvideocapturer.mm +++ b/webrtc/api/objc/avfoundationvideocapturer.mm @@ -11,6 +11,7 @@ #include "webrtc/api/objc/avfoundationvideocapturer.h" #include "webrtc/base/bind.h" +#include "webrtc/base/thread.h" #import #import diff --git a/webrtc/media/base/mediachannel.h b/webrtc/media/base/mediachannel.h index f07c33a4ca..f92a732632 100644 --- a/webrtc/media/base/mediachannel.h +++ b/webrtc/media/base/mediachannel.h @@ -532,20 +532,6 @@ struct MediaSenderInfo { std::vector remote_stats; }; -template -struct VariableInfo { - VariableInfo() - : min_val(), - mean(0.0), - max_val(), - variance(0.0) { - } - T min_val; - double mean; - T max_val; - double variance; -}; - struct MediaReceiverInfo { MediaReceiverInfo() : bytes_rcvd(0), @@ -700,9 +686,6 @@ struct VideoSenderInfo : public MediaSenderInfo { int adapt_changes; int avg_encode_ms; int encode_usage_percent; - VariableInfo adapt_frame_drops; - VariableInfo effects_frame_drops; - VariableInfo capturer_frame_time; }; struct VideoReceiverInfo : public MediaReceiverInfo { diff --git a/webrtc/media/base/videocapturer.cc b/webrtc/media/base/videocapturer.cc index d598de3aa9..4923dddd96 100644 --- a/webrtc/media/base/videocapturer.cc +++ b/webrtc/media/base/videocapturer.cc @@ -32,10 +32,6 @@ static const int kYU12Penalty = 16; // Needs to be higher than MJPG index. #endif static const int kDefaultScreencastFps = 5; -// Limit stats data collections to ~20 seconds of 30fps data before dropping -// old data in case stats aren't reset for long periods of time. -static const size_t kMaxAccumulatorSize = 600; - } // namespace ///////////////////////////////////////////////////////////////////// @@ -64,10 +60,7 @@ bool CapturedFrame::GetDataSize(uint32_t* size) const { ///////////////////////////////////////////////////////////////////// // Implementation of class VideoCapturer ///////////////////////////////////////////////////////////////////// -VideoCapturer::VideoCapturer() - : adapt_frame_drops_data_(kMaxAccumulatorSize), - frame_time_data_(kMaxAccumulatorSize), - apply_rotation_(true) { +VideoCapturer::VideoCapturer() : apply_rotation_(true) { thread_checker_.DetachFromThread(); Construct(); } @@ -86,8 +79,6 @@ void VideoCapturer::Construct() { scaled_width_ = 0; scaled_height_ = 0; enable_video_adapter_ = true; - adapt_frame_drops_ = 0; - previous_frame_time_ = 0.0; // There are lots of video capturers out there that don't call // set_frame_factory. We can either go change all of them, or we // can set this default. @@ -102,7 +93,6 @@ const std::vector* VideoCapturer::GetSupportedFormats() const { bool VideoCapturer::StartCapturing(const VideoFormat& capture_format) { RTC_DCHECK(thread_checker_.CalledOnValidThread()); - previous_frame_time_ = frame_length_time_reporter_.TimerNow(); CaptureState result = Start(capture_format); const bool success = (result == CS_RUNNING) || (result == CS_STARTING); if (!success) { @@ -193,17 +183,9 @@ void VideoCapturer::set_frame_factory(VideoFrameFactory* frame_factory) { } } -void VideoCapturer::GetStats(VariableInfo* adapt_drops_stats, - VariableInfo* effect_drops_stats, - VariableInfo* frame_time_stats, - VideoFormat* last_captured_frame_format) { +void VideoCapturer::GetStats(VideoFormat* last_captured_frame_format) { rtc::CritScope cs(&frame_stats_crit_); - GetVariableSnapshot(adapt_frame_drops_data_, adapt_drops_stats); - GetVariableSnapshot(frame_time_data_, frame_time_stats); *last_captured_frame_format = last_captured_frame_format_; - - adapt_frame_drops_data_.Reset(); - frame_time_data_.Reset(); } void VideoCapturer::RemoveSink( @@ -388,7 +370,6 @@ void VideoCapturer::OnFrameCaptured(VideoCapturer*, video_adapter_.AdaptFrameResolution(cropped_width, cropped_height); if (adapted_format.IsSize0x0()) { // VideoAdapter dropped the frame. - ++adapt_frame_drops_; return; } adapted_width = adapted_format.width; @@ -568,24 +549,6 @@ void VideoCapturer::UpdateStats(const CapturedFrame* captured_frame) { // TODO(ronghuawu): Useful to report interval as well? last_captured_frame_format_.interval = 0; last_captured_frame_format_.fourcc = captured_frame->fourcc; - - double time_now = frame_length_time_reporter_.TimerNow(); - if (previous_frame_time_ != 0.0) { - adapt_frame_drops_data_.AddSample(adapt_frame_drops_); - frame_time_data_.AddSample(time_now - previous_frame_time_); - } - previous_frame_time_ = time_now; - adapt_frame_drops_ = 0; -} - -template -void VideoCapturer::GetVariableSnapshot( - const rtc::RollingAccumulator& data, - VariableInfo* stats) { - stats->max_val = data.ComputeMax(); - stats->mean = data.ComputeMean(); - stats->min_val = data.ComputeMin(); - stats->variance = data.ComputeVariance(); } } // namespace cricket diff --git a/webrtc/media/base/videocapturer.h b/webrtc/media/base/videocapturer.h index 84f896bc4f..ac2bee2b30 100644 --- a/webrtc/media/base/videocapturer.h +++ b/webrtc/media/base/videocapturer.h @@ -21,11 +21,8 @@ #include "webrtc/base/basictypes.h" #include "webrtc/base/criticalsection.h" #include "webrtc/media/base/videosourceinterface.h" -#include "webrtc/base/rollingaccumulator.h" #include "webrtc/base/sigslot.h" -#include "webrtc/base/timing.h" #include "webrtc/base/thread_checker.h" -#include "webrtc/media/base/mediachannel.h" #include "webrtc/media/base/videoadapter.h" #include "webrtc/media/base/videobroadcaster.h" #include "webrtc/media/base/videocommon.h" @@ -221,13 +218,9 @@ class VideoCapturer : public sigslot::has_slots<>, // Takes ownership. void set_frame_factory(VideoFrameFactory* frame_factory); - // Gets statistics for tracked variables recorded since the last call to - // GetStats. Note that calling GetStats resets any gathered data so it - // should be called only periodically to log statistics. - void GetStats(VariableInfo* adapt_drop_stats, - VariableInfo* effect_drop_stats, - VariableInfo* frame_time_stats, - VideoFormat* last_captured_frame_format); + // TODO(nisse): Rename function? Or pass the frame format before + // adaptation in some other way. + void GetStats(VideoFormat* last_captured_frame_format); // Implements VideoSourceInterface void AddOrUpdateSink(rtc::VideoSinkInterface* sink, @@ -298,13 +291,6 @@ class VideoCapturer : public sigslot::has_slots<>, void UpdateStats(const CapturedFrame* captured_frame); - // Helper function to save statistics on the current data from a - // RollingAccumulator into stats. - template - static void GetVariableSnapshot( - const rtc::RollingAccumulator& data, - VariableInfo* stats); - rtc::ThreadChecker thread_checker_; std::string id_; CaptureState capture_state_; @@ -325,13 +311,8 @@ class VideoCapturer : public sigslot::has_slots<>, bool enable_video_adapter_; CoordinatedVideoAdapter video_adapter_; - rtc::Timing frame_length_time_reporter_; rtc::CriticalSection frame_stats_crit_; - int adapt_frame_drops_; - rtc::RollingAccumulator adapt_frame_drops_data_; - double previous_frame_time_; - rtc::RollingAccumulator frame_time_data_; // The captured frame format before potential adapation. VideoFormat last_captured_frame_format_; diff --git a/webrtc/media/engine/webrtcvideoengine2.cc b/webrtc/media/engine/webrtcvideoengine2.cc index 5fe36c4386..e34056d905 100644 --- a/webrtc/media/engine/webrtcvideoengine2.cc +++ b/webrtc/media/engine/webrtcvideoengine2.cc @@ -2052,9 +2052,7 @@ WebRtcVideoChannel2::WebRtcVideoSendStream::GetVideoSenderInfo() { if (capturer_) { VideoFormat last_captured_frame_format; - capturer_->GetStats(&info.adapt_frame_drops, &info.effects_frame_drops, - &info.capturer_frame_time, - &last_captured_frame_format); + capturer_->GetStats(&last_captured_frame_format); info.input_frame_width = last_captured_frame_format.width; info.input_frame_height = last_captured_frame_format.height; }