Added ViE API for getting overuse measure.
R=mflodman@webrtc.org Review URL: https://webrtc-codereview.appspot.com/3129005 git-svn-id: http://webrtc.googlecode.com/svn/trunk@5141 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
parent
d29d4e9c08
commit
b24d33565c
@ -120,6 +120,11 @@ class WEBRTC_DLLEXPORT ViEBase {
|
||||
virtual int RegisterCpuOveruseObserver(int channel,
|
||||
CpuOveruseObserver* observer) = 0;
|
||||
|
||||
// Gets the last cpu overuse measure.
|
||||
// TODO(asapersson): Remove default implementation.
|
||||
virtual int CpuOveruseMeasure(int channel,
|
||||
int* capture_jitter_ms) { return -1; }
|
||||
|
||||
// Specifies the VoiceEngine and VideoEngine channel pair to use for
|
||||
// audio/video synchronization.
|
||||
virtual int ConnectAudioChannel(const int video_channel,
|
||||
|
@ -116,7 +116,8 @@ OveruseFrameDetector::OveruseFrameDetector(Clock* clock,
|
||||
last_rampup_time_(0),
|
||||
in_quick_rampup_(false),
|
||||
current_rampup_delay_ms_(kStandardRampUpDelayMs),
|
||||
num_pixels_(0) {}
|
||||
num_pixels_(0),
|
||||
last_capture_jitter_ms_(-1) {}
|
||||
|
||||
OveruseFrameDetector::~OveruseFrameDetector() {
|
||||
}
|
||||
@ -144,6 +145,11 @@ void OveruseFrameDetector::FrameCaptured(int width, int height) {
|
||||
last_capture_time_ = time;
|
||||
}
|
||||
|
||||
int OveruseFrameDetector::last_capture_jitter_ms() {
|
||||
CriticalSectionScoped cs(crit_.get());
|
||||
return last_capture_jitter_ms_;
|
||||
}
|
||||
|
||||
int32_t OveruseFrameDetector::TimeUntilNextProcess() {
|
||||
CriticalSectionScoped cs(crit_.get());
|
||||
return next_process_time_ - clock_->TimeInMilliseconds();
|
||||
@ -208,6 +214,7 @@ int32_t OveruseFrameDetector::Process() {
|
||||
overuse_stddev_ms_,
|
||||
normaluse_stddev_ms_);
|
||||
|
||||
last_capture_jitter_ms_ = static_cast<int>(capture_deltas_.StdDev());
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -71,6 +71,8 @@ class OveruseFrameDetector : public Module {
|
||||
// Called for each captured frame.
|
||||
void FrameCaptured(int width, int height);
|
||||
|
||||
int last_capture_jitter_ms();
|
||||
|
||||
// Implements Module.
|
||||
virtual int32_t TimeUntilNextProcess() OVERRIDE;
|
||||
virtual int32_t Process() OVERRIDE;
|
||||
@ -105,6 +107,8 @@ class OveruseFrameDetector : public Module {
|
||||
// Number of pixels of last captured frame.
|
||||
int num_pixels_;
|
||||
|
||||
int last_capture_jitter_ms_;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(OveruseFrameDetector);
|
||||
};
|
||||
|
||||
|
@ -95,4 +95,10 @@ TEST_F(OveruseFrameDetectorTest, ConstantOveruseGivesNoNormalUsage) {
|
||||
TriggerOveruse();
|
||||
}
|
||||
|
||||
TEST_F(OveruseFrameDetectorTest, LastCaptureJitter) {
|
||||
EXPECT_EQ(-1, overuse_detector_->last_capture_jitter_ms());
|
||||
TriggerOveruse();
|
||||
EXPECT_GT(overuse_detector_->last_capture_jitter_ms(), 0);
|
||||
}
|
||||
|
||||
} // namespace webrtc
|
||||
|
@ -117,6 +117,34 @@ int ViEBaseImpl::RegisterCpuOveruseObserver(int video_channel,
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ViEBaseImpl::CpuOveruseMeasure(int video_channel, int* capture_jitter_ms) {
|
||||
ViEChannelManagerScoped cs(*(shared_data_.channel_manager()));
|
||||
ViEChannel* vie_channel = cs.Channel(video_channel);
|
||||
if (!vie_channel) {
|
||||
WEBRTC_TRACE(kTraceError,
|
||||
kTraceVideo,
|
||||
ViEId(shared_data_.instance_id()),
|
||||
"%s: channel %d doesn't exist",
|
||||
__FUNCTION__,
|
||||
video_channel);
|
||||
shared_data_.SetLastError(kViEBaseInvalidChannelId);
|
||||
return -1;
|
||||
}
|
||||
ViEEncoder* vie_encoder = cs.Encoder(video_channel);
|
||||
assert(vie_encoder);
|
||||
|
||||
ViEInputManagerScoped is(*(shared_data_.input_manager()));
|
||||
ViEFrameProviderBase* provider = is.FrameProvider(vie_encoder);
|
||||
if (provider) {
|
||||
ViECapturer* capturer = is.Capture(provider->Id());
|
||||
if (capturer) {
|
||||
*capture_jitter_ms = capturer->CpuOveruseMeasure();
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
int ViEBaseImpl::CreateChannel(int& video_channel) { // NOLINT
|
||||
WEBRTC_TRACE(kTraceApiCall, kTraceVideo, ViEId(shared_data_.instance_id()),
|
||||
"%s", __FUNCTION__);
|
||||
|
@ -33,6 +33,7 @@ class ViEBaseImpl
|
||||
virtual int SetVoiceEngine(VoiceEngine* voice_engine);
|
||||
virtual int RegisterCpuOveruseObserver(int channel,
|
||||
CpuOveruseObserver* observer);
|
||||
virtual int CpuOveruseMeasure(int channel, int* capture_jitter_ms);
|
||||
virtual int CreateChannel(int& video_channel); // NOLINT
|
||||
virtual int CreateChannel(int& video_channel, // NOLINT
|
||||
int original_channel);
|
||||
|
@ -266,6 +266,10 @@ void ViECapturer::RegisterCpuOveruseObserver(CpuOveruseObserver* observer) {
|
||||
overuse_detector_->SetObserver(observer);
|
||||
}
|
||||
|
||||
int ViECapturer::CpuOveruseMeasure() {
|
||||
return overuse_detector_->last_capture_jitter_ms();
|
||||
}
|
||||
|
||||
int32_t ViECapturer::SetCaptureDelay(int32_t delay_ms) {
|
||||
return capture_module_->SetCaptureDelay(delay_ms);
|
||||
}
|
||||
|
@ -104,6 +104,8 @@ class ViECapturer
|
||||
|
||||
void RegisterCpuOveruseObserver(CpuOveruseObserver* observer);
|
||||
|
||||
int CpuOveruseMeasure();
|
||||
|
||||
protected:
|
||||
ViECapturer(int capture_id,
|
||||
int engine_id,
|
||||
|
Loading…
x
Reference in New Issue
Block a user