Wiring down config from video engine until video coding and remote bitrate estimator modules instantiation.

R=mflodman@webrtc.org

Review URL: https://webrtc-codereview.appspot.com/1450008

git-svn-id: http://webrtc.googlecode.com/svn/trunk@4007 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
andresp@webrtc.org 2013-05-13 10:50:50 +00:00
parent 7a5615bc84
commit 7707d060bb
20 changed files with 107 additions and 56 deletions

View File

@ -10,15 +10,16 @@
// This file includes unit tests for EncoderStateFeedback.
#include "video_engine/encoder_state_feedback.h"
#include "webrtc/video_engine/encoder_state_feedback.h"
#include <gmock/gmock.h>
#include <gtest/gtest.h>
#include "modules/rtp_rtcp/interface/rtp_rtcp_defines.h"
#include "modules/utility/interface/process_thread.h"
#include "system_wrappers/interface/scoped_ptr.h"
#include "video_engine/vie_encoder.h"
#include "webrtc/common.h"
#include "webrtc/modules/rtp_rtcp/interface/rtp_rtcp_defines.h"
#include "webrtc/modules/utility/interface/process_thread.h"
#include "webrtc/system_wrappers/interface/scoped_ptr.h"
#include "webrtc/video_engine/vie_encoder.h"
namespace webrtc {
@ -36,7 +37,7 @@ class TestProcessThread : public ProcessThread {
class MockVieEncoder : public ViEEncoder {
public:
explicit MockVieEncoder(TestProcessThread* process_thread)
: ViEEncoder(1, 1, 1, *process_thread, NULL) {}
: ViEEncoder(1, 1, 1, config_, *process_thread, NULL) {}
~MockVieEncoder() {}
MOCK_METHOD1(OnReceivedIntraFrameRequest,
@ -47,6 +48,8 @@ class MockVieEncoder : public ViEEncoder {
void(uint32_t ssrc, uint64_t picture_id));
MOCK_METHOD2(OnLocalSsrcChanged,
void(uint32_t old_ssrc, uint32_t new_ssrc));
const Config config_;
};
class VieKeyRequestTest : public ::testing::Test {

View File

@ -23,12 +23,14 @@
namespace webrtc {
class Config;
class VoiceEngine;
class WEBRTC_DLLEXPORT VideoEngine {
public:
// Creates a VideoEngine object, which can then be used to acquire subAPIs.
static VideoEngine* Create();
static VideoEngine* Create(const Config& config);
// Deletes a VideoEngine instance.
static bool Delete(VideoEngine*& video_engine);

View File

@ -59,7 +59,8 @@ int ViEBaseImpl::Release() {
return ref_count;
}
ViEBaseImpl::ViEBaseImpl() {
ViEBaseImpl::ViEBaseImpl(const Config& config)
: shared_data_(config) {
WEBRTC_TRACE(kTraceMemory, kTraceVideo, shared_data_.instance_id(),
"ViEBaseImpl::ViEBaseImpl() Ctor");
}

View File

@ -18,6 +18,7 @@
namespace webrtc {
class Config;
class Module;
class VoiceEngine;
@ -47,7 +48,7 @@ class ViEBaseImpl
virtual int LastError();
protected:
ViEBaseImpl();
ViEBaseImpl(const Config& config);
virtual ~ViEBaseImpl();
ViESharedData* shared_data() { return &shared_data_; }

View File

@ -32,6 +32,7 @@ const int kMaxDeliverWaitTime = 500;
ViECapturer::ViECapturer(int capture_id,
int engine_id,
const Config& config,
ProcessThread& module_process_thread)
: ViEFrameProviderBase(capture_id, engine_id),
capture_cs_(CriticalSectionWrapper::CreateCriticalSection()),
@ -128,9 +129,10 @@ ViECapturer::~ViECapturer() {
ViECapturer* ViECapturer::CreateViECapture(
int capture_id,
int engine_id,
const Config& config,
VideoCaptureModule* capture_module,
ProcessThread& module_process_thread) {
ViECapturer* capture = new ViECapturer(capture_id, engine_id,
ViECapturer* capture = new ViECapturer(capture_id, engine_id, config,
module_process_thread);
if (!capture || capture->Init(capture_module) != 0) {
delete capture;
@ -154,10 +156,11 @@ int32_t ViECapturer::Init(VideoCaptureModule* capture_module) {
ViECapturer* ViECapturer::CreateViECapture(
int capture_id,
int engine_id,
const Config& config,
const char* device_unique_idUTF8,
const uint32_t device_unique_idUTF8Length,
ProcessThread& module_process_thread) {
ViECapturer* capture = new ViECapturer(capture_id, engine_id,
ViECapturer* capture = new ViECapturer(capture_id, engine_id, config,
module_process_thread);
if (!capture ||
capture->Init(device_unique_idUTF8, device_unique_idUTF8Length) != 0) {

View File

@ -27,6 +27,7 @@
namespace webrtc {
class Config;
class CriticalSectionWrapper;
class EventWrapper;
class ProcessThread;
@ -45,12 +46,14 @@ class ViECapturer
public:
static ViECapturer* CreateViECapture(int capture_id,
int engine_id,
const Config& config,
VideoCaptureModule* capture_module,
ProcessThread& module_process_thread);
static ViECapturer* CreateViECapture(
int capture_id,
int engine_id,
const Config& config,
const char* device_unique_idUTF8,
uint32_t device_unique_idUTF8Length,
ProcessThread& module_process_thread);
@ -108,6 +111,7 @@ class ViECapturer
protected:
ViECapturer(int capture_id,
int engine_id,
const Config& config,
ProcessThread& module_process_thread);
int32_t Init(VideoCaptureModule* capture_module);

View File

@ -55,6 +55,7 @@ class ChannelStatsObserver : public CallStatsObserver {
ViEChannel::ViEChannel(int32_t channel_id,
int32_t engine_id,
uint32_t number_of_cores,
const Config& config,
ProcessThread& module_process_thread,
RtcpIntraFrameObserver* intra_frame_observer,
RtcpBandwidthObserver* bandwidth_observer,

View File

@ -32,21 +32,22 @@ namespace webrtc {
class CallStatsObserver;
class ChannelStatsObserver;
class Config;
class CriticalSectionWrapper;
class Encryption;
class PacedSender;
class ProcessThread;
class RtpRtcp;
class RtcpRttObserver;
class RtpRtcp;
class ThreadWrapper;
class VideoCodingModule;
class VideoDecoder;
class VideoRenderCallback;
class ViEDecoderObserver;
class ViEEffectFilter;
class ViENetworkObserver;
class ViERTCPObserver;
class ViERTPObserver;
class VideoCodingModule;
class VideoDecoder;
class VideoRenderCallback;
class VoEVideoSync;
class ViEChannel
@ -64,6 +65,7 @@ class ViEChannel
ViEChannel(int32_t channel_id,
int32_t engine_id,
uint32_t number_of_cores,
const Config& config,
ProcessThread& module_process_thread,
RtcpIntraFrameObserver* intra_frame_observer,
RtcpBandwidthObserver* bandwidth_observer,

View File

@ -24,7 +24,8 @@ namespace webrtc {
ChannelGroup::ChannelGroup(ProcessThread* process_thread,
const OverUseDetectorOptions& options,
RemoteBitrateEstimator::EstimationMode mode)
RemoteBitrateEstimator::EstimationMode mode,
const Config& config)
: remb_(new VieRemb()),
bitrate_controller_(BitrateController::CreateBitrateController()),
call_stats_(new CallStats()),

View File

@ -20,6 +20,7 @@ namespace webrtc {
class BitrateController;
class CallStats;
class Config;
class EncoderStateFeedback;
struct OverUseDetectorOptions;
class ProcessThread;
@ -33,7 +34,8 @@ class ChannelGroup {
public:
ChannelGroup(ProcessThread* process_thread,
const OverUseDetectorOptions& options,
RemoteBitrateEstimator::EstimationMode mode);
RemoteBitrateEstimator::EstimationMode mode,
const Config& config);
~ChannelGroup();
void AddChannel(int channel_id);

View File

@ -29,7 +29,8 @@ namespace webrtc {
ViEChannelManager::ViEChannelManager(
int engine_id,
int number_of_cores,
const OverUseDetectorOptions& options)
const OverUseDetectorOptions& options,
const Config& config)
: channel_id_critsect_(CriticalSectionWrapper::CreateCriticalSection()),
engine_id_(engine_id),
number_of_cores_(number_of_cores),
@ -39,7 +40,8 @@ ViEChannelManager::ViEChannelManager(
voice_engine_(NULL),
module_process_thread_(NULL),
over_use_detector_options_(options),
bwe_mode_(RemoteBitrateEstimator::kSingleStreamEstimation) {
bwe_mode_(RemoteBitrateEstimator::kSingleStreamEstimation),
config_(config) {
WEBRTC_TRACE(kTraceMemory, kTraceVideo, ViEId(engine_id),
"ViEChannelManager::ViEChannelManager(engine_id: %d)",
engine_id);
@ -93,10 +95,12 @@ int ViEChannelManager::CreateChannel(int* channel_id) {
// Create a new channel group and add this channel.
ChannelGroup* group = new ChannelGroup(module_process_thread_,
over_use_detector_options_,
bwe_mode_);
bwe_mode_,
config_);
BitrateController* bitrate_controller = group->GetBitrateController();
ViEEncoder* vie_encoder = new ViEEncoder(engine_id_, new_channel_id,
number_of_cores_,
config_,
*module_process_thread_,
bitrate_controller);
@ -165,6 +169,7 @@ int ViEChannelManager::CreateChannel(int* channel_id,
if (sender) {
// We need to create a new ViEEncoder.
vie_encoder = new ViEEncoder(engine_id_, new_channel_id, number_of_cores_,
config_,
*module_process_thread_,
bitrate_controller);
if (!(vie_encoder->Init() &&
@ -423,6 +428,7 @@ bool ViEChannelManager::CreateChannelObject(
ViEChannel* vie_channel = new ViEChannel(channel_id, engine_id_,
number_of_cores_,
config_,
*module_process_thread_,
intra_frame_observer,
bandwidth_observer,

View File

@ -25,6 +25,7 @@
namespace webrtc {
class Config;
class CriticalSectionWrapper;
class MapWrapper;
class ProcessThread;
@ -44,7 +45,8 @@ class ViEChannelManager: private ViEManagerBase {
public:
ViEChannelManager(int engine_id,
int number_of_cores,
const OverUseDetectorOptions& options);
const OverUseDetectorOptions& options,
const Config& config);
~ViEChannelManager();
void SetModuleProcessThread(ProcessThread* module_process_thread);
@ -137,6 +139,7 @@ class ViEChannelManager: private ViEManagerBase {
ProcessThread* module_process_thread_;
const OverUseDetectorOptions& over_use_detector_options_;
RemoteBitrateEstimator::EstimationMode bwe_mode_;
const Config& config_;
};
class ViEChannelManagerScoped: private ViEManagerScopedBase {

View File

@ -101,6 +101,7 @@ class ViEPacedSenderCallback : public PacedSender::Callback {
ViEEncoder::ViEEncoder(int32_t engine_id,
int32_t channel_id,
uint32_t number_of_cores,
const Config& config,
ProcessThread& module_process_thread,
BitrateController* bitrate_controller)
: engine_id_(engine_id),

View File

@ -28,6 +28,7 @@
namespace webrtc {
class CriticalSectionWrapper;
class Config;
class PacedSender;
class ProcessThread;
class QMVideoSettingsCallback;
@ -51,6 +52,7 @@ class ViEEncoder
ViEEncoder(int32_t engine_id,
int32_t channel_id,
uint32_t number_of_cores,
const Config& config,
ProcessThread& module_process_thread,
BitrateController* bitrate_controller);
~ViEEncoder();

View File

@ -8,8 +8,10 @@
* be found in the AUTHORS file in the root of the source tree.
*/
#include "video_engine/vie_impl.h"
#include "system_wrappers/interface/trace.h"
#include "webrtc/video_engine/vie_impl.h"
#include "webrtc/common.h"
#include "webrtc/system_wrappers/interface/trace.h"
#ifdef WEBRTC_ANDROID
#include "webrtc/modules/video_capture/include/video_capture_factory.h"
@ -21,7 +23,11 @@ namespace webrtc {
enum { kModuleId = 0 };
VideoEngine* VideoEngine::Create() {
return new VideoEngineImpl();
return new VideoEngineImpl(new Config(), true /* owns_config */);
}
VideoEngine* VideoEngine::Create(const Config& config) {
return new VideoEngineImpl(&config, false /* owns_config */);
}
bool VideoEngine::Delete(VideoEngine*& video_engine) {

View File

@ -11,35 +11,37 @@
#ifndef WEBRTC_VIDEO_ENGINE_VIE_IMPL_H_
#define WEBRTC_VIDEO_ENGINE_VIE_IMPL_H_
#include "engine_configurations.h" // NOLINT
#include "video_engine/vie_defines.h"
#include "webrtc/common.h"
#include "webrtc/engine_configurations.h"
#include "webrtc/video_engine/vie_defines.h"
#include "webrtc/system_wrappers/interface/scoped_ptr.h"
#include "video_engine/vie_base_impl.h"
#include "webrtc/video_engine/vie_base_impl.h"
#ifdef WEBRTC_VIDEO_ENGINE_CAPTURE_API
#include "video_engine/vie_capture_impl.h"
#include "webrtc/video_engine/vie_capture_impl.h"
#endif
#ifdef WEBRTC_VIDEO_ENGINE_CODEC_API
#include "video_engine/vie_codec_impl.h"
#include "webrtc/video_engine/vie_codec_impl.h"
#endif
#ifdef WEBRTC_VIDEO_ENGINE_ENCRYPTION_API
#include "video_engine/vie_encryption_impl.h"
#include "webrtc/video_engine/vie_encryption_impl.h"
#endif
#ifdef WEBRTC_VIDEO_ENGINE_FILE_API
#include "video_engine/vie_file_impl.h"
#include "webrtc/video_engine/vie_file_impl.h"
#endif
#ifdef WEBRTC_VIDEO_ENGINE_IMAGE_PROCESS_API
#include "video_engine/vie_image_process_impl.h"
#include "webrtc/video_engine/vie_image_process_impl.h"
#endif
#include "video_engine/vie_network_impl.h"
#include "webrtc/video_engine/vie_network_impl.h"
#ifdef WEBRTC_VIDEO_ENGINE_RENDER_API
#include "video_engine/vie_render_impl.h"
#include "webrtc/video_engine/vie_render_impl.h"
#endif
#ifdef WEBRTC_VIDEO_ENGINE_RTP_RTCP_API
#include "video_engine/vie_rtp_rtcp_impl.h"
#include "webrtc/video_engine/vie_rtp_rtcp_impl.h"
#endif
#ifdef WEBRTC_VIDEO_ENGINE_EXTERNAL_CODEC_API
#include "video_engine/vie_external_codec_impl.h"
#include "webrtc/video_engine/vie_external_codec_impl.h"
#endif
namespace webrtc {
@ -74,35 +76,40 @@ class VideoEngineImpl
public VideoEngine
{ // NOLINT
public:
VideoEngineImpl()
:
VideoEngineImpl(const Config* config, bool owns_config)
: ViEBaseImpl(*config),
#ifdef WEBRTC_VIDEO_ENGINE_CODEC_API
ViECodecImpl(ViEBaseImpl::shared_data())
ViECodecImpl(ViEBaseImpl::shared_data()),
#endif
#ifdef WEBRTC_VIDEO_ENGINE_CAPTURE_API
, ViECaptureImpl(ViEBaseImpl::shared_data())
ViECaptureImpl(ViEBaseImpl::shared_data()),
#endif
#ifdef WEBRTC_VIDEO_ENGINE_ENCRYPTION_API
, ViEEncryptionImpl(ViEBaseImpl::shared_data())
ViEEncryptionImpl(ViEBaseImpl::shared_data()),
#endif
#ifdef WEBRTC_VIDEO_ENGINE_FILE_API
, ViEFileImpl(ViEBaseImpl::shared_data())
ViEFileImpl(ViEBaseImpl::shared_data()),
#endif
#ifdef WEBRTC_VIDEO_ENGINE_IMAGE_PROCESS_API
, ViEImageProcessImpl(ViEBaseImpl::shared_data())
ViEImageProcessImpl(ViEBaseImpl::shared_data()),
#endif
, ViENetworkImpl(ViEBaseImpl::shared_data())
ViENetworkImpl(ViEBaseImpl::shared_data()),
#ifdef WEBRTC_VIDEO_ENGINE_RENDER_API
, ViERenderImpl(ViEBaseImpl::shared_data())
ViERenderImpl(ViEBaseImpl::shared_data()),
#endif
#ifdef WEBRTC_VIDEO_ENGINE_RTP_RTCP_API
, ViERTP_RTCPImpl(ViEBaseImpl::shared_data())
ViERTP_RTCPImpl(ViEBaseImpl::shared_data()),
#endif
#ifdef WEBRTC_VIDEO_ENGINE_EXTERNAL_CODEC_API
, ViEExternalCodecImpl(ViEBaseImpl::shared_data())
ViEExternalCodecImpl(ViEBaseImpl::shared_data()),
#endif
own_config_(owns_config ? config : NULL)
{}
virtual ~VideoEngineImpl() {}
private:
// Placeholder for the case where this owns the config.
scoped_ptr<const Config> own_config_;
};
} // namespace webrtc

View File

@ -26,8 +26,9 @@
namespace webrtc {
ViEInputManager::ViEInputManager(const int engine_id)
: engine_id_(engine_id),
ViEInputManager::ViEInputManager(const int engine_id, const Config& config)
: config_(config),
engine_id_(engine_id),
map_cs_(CriticalSectionWrapper::CreateCriticalSection()),
device_info_cs_(CriticalSectionWrapper::CreateCriticalSection()),
vie_frame_provider_map_(),
@ -260,7 +261,7 @@ int ViEInputManager::CreateCaptureDevice(
return kViECaptureDeviceMaxNoDevicesAllocated;
}
ViECapturer* vie_capture = ViECapturer::CreateViECapture(
newcapture_id, engine_id_, device_unique_idUTF8,
newcapture_id, engine_id_, config_, device_unique_idUTF8,
device_unique_idUTF8Length, *module_process_thread_);
if (!vie_capture) {
ReturnCaptureId(newcapture_id);
@ -299,7 +300,8 @@ int ViEInputManager::CreateCaptureDevice(VideoCaptureModule* capture_module,
}
ViECapturer* vie_capture = ViECapturer::CreateViECapture(
newcapture_id, engine_id_, capture_module, *module_process_thread_);
newcapture_id, engine_id_, config_,
capture_module, *module_process_thread_);
if (!vie_capture) {
ReturnCaptureId(newcapture_id);
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceVideo, ViEId(engine_id_),
@ -369,7 +371,7 @@ int ViEInputManager::CreateExternalCaptureDevice(
}
ViECapturer* vie_capture = ViECapturer::CreateViECapture(
newcapture_id, engine_id_, NULL, 0, *module_process_thread_);
newcapture_id, engine_id_, config_, NULL, 0, *module_process_thread_);
if (!vie_capture) {
ReturnCaptureId(newcapture_id);
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceVideo, ViEId(engine_id_),

View File

@ -22,6 +22,7 @@
namespace webrtc {
class Config;
class CriticalSectionWrapper;
class ProcessThread;
class RWLockWrapper;
@ -33,7 +34,7 @@ class VoiceEngine;
class ViEInputManager : private ViEManagerBase {
friend class ViEInputManagerScoped;
public:
explicit ViEInputManager(int engine_id);
ViEInputManager(int engine_id, const Config& config);
~ViEInputManager();
void SetModuleProcessThread(ProcessThread* module_process_thread);
@ -109,6 +110,7 @@ class ViEInputManager : private ViEManagerBase {
// Gets the ViEFilePlayer for this file_id.
ViEFilePlayer* ViEFilePlayerPtr(int file_id) const;
const Config& config_;
int engine_id_;
scoped_ptr<CriticalSectionWrapper> map_cs_;
scoped_ptr<CriticalSectionWrapper> device_info_cs_;

View File

@ -22,14 +22,15 @@ namespace webrtc {
// Active instance counter
int ViESharedData::instance_counter_ = 0;
ViESharedData::ViESharedData()
ViESharedData::ViESharedData(const Config& config)
: instance_id_(++instance_counter_),
initialized_(false),
number_cores_(CpuInfo::DetectNumberOfCores()),
over_use_detector_options_(),
channel_manager_(*new ViEChannelManager(instance_id_, number_cores_,
over_use_detector_options_)),
input_manager_(*new ViEInputManager(instance_id_)),
over_use_detector_options_,
config)),
input_manager_(*new ViEInputManager(instance_id_, config)),
render_manager_(*new ViERenderManager(instance_id_)),
module_process_thread_(ProcessThread::CreateProcessThread()),
last_error_(0) {

View File

@ -18,6 +18,7 @@
namespace webrtc {
class Config;
class ProcessThread;
class ViEChannelManager;
class ViEInputManager;
@ -25,7 +26,7 @@ class ViERenderManager;
class ViESharedData {
public:
ViESharedData();
ViESharedData(const Config& config);
~ViESharedData();
bool Initialized() const;