Removed ViEBaseObserver.
BUG=1037 TEST=Still compiles and ViE autotest passes. Review URL: https://webrtc-codereview.appspot.com/929012 git-svn-id: http://webrtc.googlecode.com/svn/trunk@3052 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
parent
8d0cef3bd2
commit
6e9890d1aa
@ -25,17 +25,6 @@ namespace webrtc {
|
||||
|
||||
class VoiceEngine;
|
||||
|
||||
// Class used for all callbacks from ViEBase.
|
||||
class WEBRTC_DLLEXPORT ViEBaseObserver {
|
||||
public:
|
||||
// This method will be called periodically if the average system CPU usage
|
||||
// exceeds 75%.
|
||||
virtual void PerformanceAlarm(const unsigned int cpu_load) = 0;
|
||||
|
||||
protected:
|
||||
virtual ~ViEBaseObserver() {}
|
||||
};
|
||||
|
||||
class WEBRTC_DLLEXPORT VideoEngine {
|
||||
public:
|
||||
// Creates a VideoEngine object, which can then be used to acquire sub‐APIs.
|
||||
@ -126,13 +115,6 @@ class WEBRTC_DLLEXPORT ViEBase {
|
||||
// Stops receiving incoming RTP and RTCP packets on the specified channel.
|
||||
virtual int StopReceive(const int video_channel) = 0;
|
||||
|
||||
// Registers an instance of a user implementation of the ViEBase
|
||||
// observer.
|
||||
virtual int RegisterObserver(ViEBaseObserver& observer) = 0;
|
||||
|
||||
// Removes an already registered instance of ViEBaseObserver.
|
||||
virtual int DeregisterObserver() = 0;
|
||||
|
||||
// Retrieves the version information for VideoEngine and its components.
|
||||
virtual int GetVersion(char version[1024]) = 0;
|
||||
|
||||
|
@ -15,17 +15,6 @@
|
||||
#include "video_engine/test/auto_test/primitives/general_primitives.h"
|
||||
#include "video_engine/test/libvietest/include/tb_interfaces.h"
|
||||
|
||||
class BaseObserver : public webrtc::ViEBaseObserver {
|
||||
public:
|
||||
BaseObserver()
|
||||
: cpu_load_(0) {}
|
||||
|
||||
virtual void PerformanceAlarm(const unsigned int cpu_load) {
|
||||
cpu_load_ = cpu_load;
|
||||
}
|
||||
unsigned int cpu_load_;
|
||||
};
|
||||
|
||||
void ViEAutoTest::ViEBaseStandardTest() {
|
||||
// ***************************************************************
|
||||
// Begin create/initialize WebRTC Video Engine for testing
|
||||
@ -100,18 +89,6 @@ void ViEAutoTest::ViEBaseExtendedTest() {
|
||||
// Start with standard test
|
||||
ViEBaseAPITest();
|
||||
ViEBaseStandardTest();
|
||||
|
||||
// ***************************************************************
|
||||
// Test BaseObserver
|
||||
// ***************************************************************
|
||||
// TODO(mflodman) Add test for base observer. Cpu load must be over 75%.
|
||||
// BaseObserver base_observer;
|
||||
// EXPECT_EQ(vie_base->RegisterObserver(base_observer), 0);
|
||||
//
|
||||
// AutoTestSleep(KAutoTestSleepTimeMs);
|
||||
//
|
||||
// EXPECT_EQ(vie_base->DeregisterObserver(), 0);
|
||||
// EXPECT_GT(base_observer.cpu_load, 0);
|
||||
}
|
||||
|
||||
void ViEAutoTest::ViEBaseAPITest() {
|
||||
|
@ -95,7 +95,6 @@
|
||||
'vie_frame_provider_base.h',
|
||||
'vie_input_manager.h',
|
||||
'vie_manager_base.h',
|
||||
'vie_performance_monitor.h',
|
||||
'vie_receiver.h',
|
||||
'vie_renderer.h',
|
||||
'vie_render_manager.h',
|
||||
@ -129,7 +128,6 @@
|
||||
'vie_frame_provider_base.cc',
|
||||
'vie_input_manager.cc',
|
||||
'vie_manager_base.cc',
|
||||
'vie_performance_monitor.cc',
|
||||
'vie_receiver.cc',
|
||||
'vie_remb.cc',
|
||||
'vie_renderer.cc',
|
||||
|
@ -27,7 +27,6 @@
|
||||
#include "video_engine/include/vie_errors.h"
|
||||
#include "video_engine/vie_impl.h"
|
||||
#include "video_engine/vie_input_manager.h"
|
||||
#include "video_engine/vie_performance_monitor.h"
|
||||
#include "video_engine/vie_shared_data.h"
|
||||
|
||||
namespace webrtc {
|
||||
@ -362,30 +361,6 @@ int ViEBaseImpl::StopReceive(const int video_channel) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ViEBaseImpl::RegisterObserver(ViEBaseObserver& observer) { // NOLINT
|
||||
WEBRTC_TRACE(kTraceApiCall, kTraceVideo, ViEId(shared_data_.instance_id()),
|
||||
"%s", __FUNCTION__);
|
||||
if (shared_data_.vie_performance_monitor()->ViEBaseObserverRegistered()) {
|
||||
shared_data_.SetLastError(kViEBaseObserverAlreadyRegistered);
|
||||
return -1;
|
||||
}
|
||||
return shared_data_.vie_performance_monitor()->Init(&observer);
|
||||
}
|
||||
|
||||
int ViEBaseImpl::DeregisterObserver() {
|
||||
WEBRTC_TRACE(kTraceApiCall, kTraceVideo, ViEId(shared_data_.instance_id()),
|
||||
"%s", __FUNCTION__);
|
||||
|
||||
if (!shared_data_.vie_performance_monitor()->ViEBaseObserverRegistered()) {
|
||||
shared_data_.SetLastError(kViEBaseObserverNotRegistered);
|
||||
WEBRTC_TRACE(kTraceError, kTraceVideo, shared_data_.instance_id(),
|
||||
"%s No observer registered.", __FUNCTION__);
|
||||
return -1;
|
||||
}
|
||||
shared_data_.vie_performance_monitor()->Terminate();
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ViEBaseImpl::GetVersion(char version[1024]) {
|
||||
WEBRTC_TRACE(kTraceApiCall, kTraceVideo, ViEId(shared_data_.instance_id()),
|
||||
"GetVersion(version=?)");
|
||||
|
@ -43,8 +43,6 @@ class ViEBaseImpl
|
||||
virtual int StopSend(const int video_channel);
|
||||
virtual int StartReceive(const int video_channel);
|
||||
virtual int StopReceive(const int video_channel);
|
||||
virtual int RegisterObserver(ViEBaseObserver& observer); // NOLINT
|
||||
virtual int DeregisterObserver();
|
||||
virtual int GetVersion(char version[1024]);
|
||||
virtual int LastError();
|
||||
|
||||
|
@ -28,7 +28,6 @@ namespace webrtc {
|
||||
ViEChannelManager::ViEChannelManager(
|
||||
int engine_id,
|
||||
int number_of_cores,
|
||||
ViEPerformanceMonitor* vie_performance_monitor,
|
||||
const OverUseDetectorOptions& options)
|
||||
: channel_id_critsect_(CriticalSectionWrapper::CreateCriticalSection()),
|
||||
engine_id_(engine_id),
|
||||
|
@ -30,7 +30,6 @@ class MapWrapper;
|
||||
class ProcessThread;
|
||||
class ViEChannel;
|
||||
class ViEEncoder;
|
||||
class ViEPerformanceMonitor;
|
||||
class VoEVideoSync;
|
||||
class VoiceEngine;
|
||||
|
||||
@ -44,7 +43,6 @@ class ViEChannelManager: private ViEManagerBase {
|
||||
public:
|
||||
ViEChannelManager(int engine_id,
|
||||
int number_of_cores,
|
||||
ViEPerformanceMonitor* vie_performance_monitor,
|
||||
const OverUseDetectorOptions& options);
|
||||
~ViEChannelManager();
|
||||
|
||||
|
@ -1,139 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license
|
||||
* that can be found in the LICENSE file in the root of the source
|
||||
* tree. An additional intellectual property rights grant can be found
|
||||
* in the file PATENTS. All contributing project authors may
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
#include "video_engine/vie_performance_monitor.h"
|
||||
|
||||
#include "system_wrappers/interface/cpu_wrapper.h"
|
||||
#include "system_wrappers/interface/critical_section_wrapper.h"
|
||||
#include "system_wrappers/interface/event_wrapper.h"
|
||||
#include "system_wrappers/interface/thread_wrapper.h"
|
||||
#include "system_wrappers/interface/tick_util.h"
|
||||
#include "system_wrappers/interface/trace.h"
|
||||
#include "video_engine/include/vie_base.h"
|
||||
#include "video_engine/vie_defines.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
enum { kVieMonitorPeriodMs = 975 };
|
||||
|
||||
ViEPerformanceMonitor::ViEPerformanceMonitor(int engine_id)
|
||||
: engine_id_(engine_id),
|
||||
pointer_cs_(CriticalSectionWrapper::CreateCriticalSection()),
|
||||
monitor_thread_(NULL),
|
||||
monitor_event_(*EventWrapper::Create()),
|
||||
cpu_(NULL),
|
||||
vie_base_observer_(NULL) {
|
||||
}
|
||||
|
||||
ViEPerformanceMonitor::~ViEPerformanceMonitor() {
|
||||
Terminate();
|
||||
delete pointer_cs_;
|
||||
delete &monitor_event_;
|
||||
}
|
||||
|
||||
int ViEPerformanceMonitor::Init(ViEBaseObserver* vie_base_observer) {
|
||||
WEBRTC_TRACE(webrtc::kTraceInfo, webrtc::kTraceVideo, ViEId(engine_id_),
|
||||
"%s", __FUNCTION__);
|
||||
|
||||
CriticalSectionScoped cs(pointer_cs_);
|
||||
if (!vie_base_observer || vie_base_observer_) {
|
||||
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceVideo, ViEId(engine_id_),
|
||||
"%s: Bad input argument or observer already set",
|
||||
__FUNCTION__);
|
||||
return -1;
|
||||
}
|
||||
|
||||
cpu_ = CpuWrapper::CreateCpu();
|
||||
if (cpu_ == NULL) {
|
||||
// Performance monitoring not supported
|
||||
WEBRTC_TRACE(webrtc::kTraceWarning, webrtc::kTraceVideo,
|
||||
ViEId(engine_id_), "%s: Not supported", __FUNCTION__);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (monitor_thread_ == NULL) {
|
||||
monitor_event_.StartTimer(true, kVieMonitorPeriodMs);
|
||||
monitor_thread_ = ThreadWrapper::CreateThread(ViEMonitorThreadFunction,
|
||||
this, kNormalPriority,
|
||||
"ViEPerformanceMonitor");
|
||||
unsigned int t_id = 0;
|
||||
if (monitor_thread_->Start(t_id)) {
|
||||
WEBRTC_TRACE(webrtc::kTraceInfo, webrtc::kTraceVideo, ViEId(engine_id_),
|
||||
"%s: Performance monitor thread started %u",
|
||||
__FUNCTION__, t_id);
|
||||
} else {
|
||||
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceVideo, ViEId(engine_id_),
|
||||
"%s: Could not start performance monitor", __FUNCTION__);
|
||||
monitor_event_.StopTimer();
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
vie_base_observer_ = vie_base_observer;
|
||||
return 0;
|
||||
}
|
||||
|
||||
void ViEPerformanceMonitor::Terminate() {
|
||||
WEBRTC_TRACE(webrtc::kTraceInfo, webrtc::kTraceVideo, ViEId(engine_id_),
|
||||
"%s", __FUNCTION__);
|
||||
|
||||
pointer_cs_->Enter();
|
||||
if (!vie_base_observer_) {
|
||||
pointer_cs_->Leave();
|
||||
return;
|
||||
}
|
||||
|
||||
vie_base_observer_ = NULL;
|
||||
monitor_event_.StopTimer();
|
||||
if (monitor_thread_) {
|
||||
ThreadWrapper* tmp_thread = monitor_thread_;
|
||||
monitor_thread_ = NULL;
|
||||
monitor_event_.Set();
|
||||
pointer_cs_->Leave();
|
||||
if (tmp_thread->Stop()) {
|
||||
pointer_cs_->Enter();
|
||||
delete tmp_thread;
|
||||
tmp_thread = NULL;
|
||||
delete cpu_;
|
||||
}
|
||||
cpu_ = NULL;
|
||||
}
|
||||
pointer_cs_->Leave();
|
||||
}
|
||||
|
||||
bool ViEPerformanceMonitor::ViEBaseObserverRegistered() {
|
||||
CriticalSectionScoped cs(pointer_cs_);
|
||||
return vie_base_observer_ != NULL;
|
||||
}
|
||||
|
||||
bool ViEPerformanceMonitor::ViEMonitorThreadFunction(void* obj) {
|
||||
return static_cast<ViEPerformanceMonitor*>(obj)->ViEMonitorProcess();
|
||||
}
|
||||
|
||||
bool ViEPerformanceMonitor::ViEMonitorProcess() {
|
||||
// Periodically triggered with time KViEMonitorPeriodMs
|
||||
monitor_event_.Wait(kVieMonitorPeriodMs);
|
||||
if (monitor_thread_ == NULL) {
|
||||
// Thread removed, exit
|
||||
return false;
|
||||
}
|
||||
|
||||
CriticalSectionScoped cs(pointer_cs_);
|
||||
if (cpu_) {
|
||||
int cpu_load = cpu_->CpuUsage();
|
||||
if (cpu_load > 75) {
|
||||
if (vie_base_observer_) {
|
||||
vie_base_observer_->PerformanceAlarm(cpu_load);
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace webrtc
|
@ -1,54 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license
|
||||
* that can be found in the LICENSE file in the root of the source
|
||||
* tree. An additional intellectual property rights grant can be found
|
||||
* in the file PATENTS. All contributing project authors may
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
// ViEPerformanceMonitor is used to check the current CPU usage and triggers a
|
||||
// callback when getting over a specified threshold.
|
||||
|
||||
#ifndef WEBRTC_VIDEO_ENGINE_VIE_PERFORMANCE_MONITOR_H_
|
||||
#define WEBRTC_VIDEO_ENGINE_VIE_PERFORMANCE_MONITOR_H_
|
||||
|
||||
#include "system_wrappers/interface/scoped_ptr.h"
|
||||
#include "typedefs.h" // NOLINT
|
||||
#include "video_engine/vie_defines.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
class CpuWrapper;
|
||||
class CriticalSectionWrapper;
|
||||
class EventWrapper;
|
||||
class ThreadWrapper;
|
||||
class ViEBaseObserver;
|
||||
|
||||
class ViEPerformanceMonitor {
|
||||
public:
|
||||
explicit ViEPerformanceMonitor(int engine_id);
|
||||
~ViEPerformanceMonitor();
|
||||
|
||||
int Init(ViEBaseObserver* vie_base_observer);
|
||||
void Terminate();
|
||||
bool ViEBaseObserverRegistered();
|
||||
|
||||
protected:
|
||||
static bool ViEMonitorThreadFunction(void* obj);
|
||||
bool ViEMonitorProcess();
|
||||
|
||||
private:
|
||||
const int engine_id_;
|
||||
// TODO(mfldoman) Make this one scoped_ptr.
|
||||
CriticalSectionWrapper* pointer_cs_;
|
||||
ThreadWrapper* monitor_thread_;
|
||||
EventWrapper& monitor_event_;
|
||||
CpuWrapper* cpu_;
|
||||
ViEBaseObserver* vie_base_observer_;
|
||||
};
|
||||
|
||||
} // namespace webrtc
|
||||
|
||||
#endif // WEBRTC_VIDEO_ENGINE_VIE_PERFORMANCE_MONITOR_H_
|
@ -27,9 +27,7 @@ ViESharedData::ViESharedData()
|
||||
initialized_(false),
|
||||
number_cores_(CpuInfo::DetectNumberOfCores()),
|
||||
over_use_detector_options_(),
|
||||
vie_performance_monitor_(ViEPerformanceMonitor(instance_id_)),
|
||||
channel_manager_(*new ViEChannelManager(instance_id_, number_cores_,
|
||||
&vie_performance_monitor_,
|
||||
over_use_detector_options_)),
|
||||
input_manager_(*new ViEInputManager(instance_id_)),
|
||||
render_manager_(*new ViERenderManager(instance_id_)),
|
||||
|
@ -15,7 +15,6 @@
|
||||
#define WEBRTC_VIDEO_ENGINE_VIE_SHARED_DATA_H_
|
||||
|
||||
#include "video_engine/vie_defines.h"
|
||||
#include "video_engine/vie_performance_monitor.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
@ -38,8 +37,6 @@ class ViESharedData {
|
||||
int NumberOfCores() const;
|
||||
|
||||
int instance_id() { return instance_id_;}
|
||||
ViEPerformanceMonitor* vie_performance_monitor() {
|
||||
return &vie_performance_monitor_; }
|
||||
ViEChannelManager* channel_manager() { return &channel_manager_; }
|
||||
ViEInputManager* input_manager() { return &input_manager_; }
|
||||
ViERenderManager* render_manager() { return &render_manager_; }
|
||||
@ -51,7 +48,6 @@ class ViESharedData {
|
||||
const int number_cores_;
|
||||
|
||||
OverUseDetectorOptions over_use_detector_options_;
|
||||
ViEPerformanceMonitor vie_performance_monitor_;
|
||||
ViEChannelManager& channel_manager_;
|
||||
ViEInputManager& input_manager_;
|
||||
ViERenderManager& render_manager_;
|
||||
|
Loading…
x
Reference in New Issue
Block a user