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}
This commit is contained in:
Niels Möller
2016-03-17 12:20:41 +01:00
parent 94a23f04af
commit 505945aed7
8 changed files with 16 additions and 81 deletions

View File

@ -35,6 +35,10 @@
@class RTCAVFoundationVideoCapturerInternal;
namespace rtc {
class Thread;
} // namespace rtc
namespace webrtc {
class AVFoundationVideoCapturer : public cricket::VideoCapturer {

View File

@ -28,6 +28,7 @@
#include "talk/app/webrtc/objc/avfoundationvideocapturer.h"
#include "webrtc/base/bind.h"
#include "webrtc/base/thread.h"
#import <AVFoundation/AVFoundation.h>
#import <Foundation/Foundation.h>

View File

@ -19,6 +19,10 @@
@class RTCAVFoundationVideoCapturerInternal;
namespace rtc {
class Thread;
} // namespace rtc
namespace webrtc {
class AVFoundationVideoCapturer : public cricket::VideoCapturer {

View File

@ -11,6 +11,7 @@
#include "webrtc/api/objc/avfoundationvideocapturer.h"
#include "webrtc/base/bind.h"
#include "webrtc/base/thread.h"
#import <AVFoundation/AVFoundation.h>
#import <Foundation/Foundation.h>

View File

@ -532,20 +532,6 @@ struct MediaSenderInfo {
std::vector<SsrcReceiverInfo> remote_stats;
};
template<class T>
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<int> adapt_frame_drops;
VariableInfo<int> effects_frame_drops;
VariableInfo<double> capturer_frame_time;
};
struct VideoReceiverInfo : public MediaReceiverInfo {

View File

@ -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<VideoFormat>* 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<int>* adapt_drops_stats,
VariableInfo<int>* effect_drops_stats,
VariableInfo<double>* 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<class T>
void VideoCapturer::GetVariableSnapshot(
const rtc::RollingAccumulator<T>& data,
VariableInfo<T>* stats) {
stats->max_val = data.ComputeMax();
stats->mean = data.ComputeMean();
stats->min_val = data.ComputeMin();
stats->variance = data.ComputeVariance();
}
} // namespace cricket

View File

@ -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<int>* adapt_drop_stats,
VariableInfo<int>* effect_drop_stats,
VariableInfo<double>* 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<cricket::VideoFrame>* 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<class T>
static void GetVariableSnapshot(
const rtc::RollingAccumulator<T>& data,
VariableInfo<T>* 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<int> adapt_frame_drops_data_;
double previous_frame_time_;
rtc::RollingAccumulator<double> frame_time_data_;
// The captured frame format before potential adapation.
VideoFormat last_captured_frame_format_;

View File

@ -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;
}