Remove test constructor in WebRtcVideoEngine2.

Removes the need for ::Construct().

BUG=1788
R=pthatcher@webrtc.org

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

git-svn-id: http://webrtc.googlecode.com/svn/trunk@6977 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
pbos@webrtc.org 2014-08-26 11:08:06 +00:00
parent 4f71e22bf9
commit b648b9d85c
4 changed files with 30 additions and 49 deletions

View File

@ -917,11 +917,11 @@ class DataChannelObserverWrapper : public DataChannelObserver {
DataChannelObserverWrapper(JNIEnv* jni, jobject j_observer) DataChannelObserverWrapper(JNIEnv* jni, jobject j_observer)
: j_observer_global_(jni, j_observer), : j_observer_global_(jni, j_observer),
j_observer_class_(jni, GetObjectClass(jni, j_observer)), j_observer_class_(jni, GetObjectClass(jni, j_observer)),
j_buffer_class_(jni, FindClass(jni, "org/webrtc/DataChannel$Buffer")),
j_on_state_change_mid_(GetMethodID(jni, *j_observer_class_, j_on_state_change_mid_(GetMethodID(jni, *j_observer_class_,
"onStateChange", "()V")), "onStateChange", "()V")),
j_on_message_mid_(GetMethodID(jni, *j_observer_class_, "onMessage", j_on_message_mid_(GetMethodID(jni, *j_observer_class_, "onMessage",
"(Lorg/webrtc/DataChannel$Buffer;)V")), "(Lorg/webrtc/DataChannel$Buffer;)V")),
j_buffer_class_(jni, FindClass(jni, "org/webrtc/DataChannel$Buffer")),
j_buffer_ctor_(GetMethodID(jni, *j_buffer_class_, j_buffer_ctor_(GetMethodID(jni, *j_buffer_class_,
"<init>", "(Ljava/nio/ByteBuffer;Z)V")) { "<init>", "(Ljava/nio/ByteBuffer;Z)V")) {
} }

View File

@ -283,37 +283,17 @@ void DefaultUnsignalledSsrcHandler::SetDefaultRenderer(
} }
WebRtcVideoEngine2::WebRtcVideoEngine2() WebRtcVideoEngine2::WebRtcVideoEngine2()
: default_codec_format_(kDefaultVideoCodecPref.width, : worker_thread_(NULL),
voice_engine_(NULL),
video_codecs_(DefaultVideoCodecs()),
default_codec_format_(kDefaultVideoCodecPref.width,
kDefaultVideoCodecPref.height, kDefaultVideoCodecPref.height,
FPS_TO_INTERVAL(kDefaultFramerate), FPS_TO_INTERVAL(kDefaultFramerate),
FOURCC_ANY) { FOURCC_ANY),
// Construct without a factory or voice engine. initialized_(false),
Construct(NULL, NULL, new rtc::CpuMonitor(NULL)); cpu_monitor_(new rtc::CpuMonitor(NULL)),
} channel_factory_(NULL) {
LOG(LS_INFO) << "WebRtcVideoEngine2::WebRtcVideoEngine2()";
WebRtcVideoEngine2::WebRtcVideoEngine2(
WebRtcVideoChannelFactory* channel_factory)
: default_codec_format_(kDefaultVideoCodecPref.width,
kDefaultVideoCodecPref.height,
FPS_TO_INTERVAL(kDefaultFramerate),
FOURCC_ANY) {
// Construct without a voice engine.
Construct(channel_factory, NULL, new rtc::CpuMonitor(NULL));
}
void WebRtcVideoEngine2::Construct(WebRtcVideoChannelFactory* channel_factory,
WebRtcVoiceEngine* voice_engine,
rtc::CpuMonitor* cpu_monitor) {
LOG(LS_INFO) << "WebRtcVideoEngine2::WebRtcVideoEngine2";
worker_thread_ = NULL;
voice_engine_ = voice_engine;
initialized_ = false;
capture_started_ = false;
cpu_monitor_.reset(cpu_monitor);
channel_factory_ = channel_factory;
video_codecs_ = DefaultVideoCodecs();
rtp_header_extensions_.push_back( rtp_header_extensions_.push_back(
RtpHeaderExtension(kRtpTimestampOffsetHeaderExtension, RtpHeaderExtension(kRtpTimestampOffsetHeaderExtension,
kRtpTimestampOffsetHeaderExtensionDefaultId)); kRtpTimestampOffsetHeaderExtensionDefaultId));
@ -322,6 +302,11 @@ void WebRtcVideoEngine2::Construct(WebRtcVideoChannelFactory* channel_factory,
kRtpAbsoluteSenderTimeHeaderExtensionDefaultId)); kRtpAbsoluteSenderTimeHeaderExtensionDefaultId));
} }
void WebRtcVideoEngine2::SetChannelFactory(
WebRtcVideoChannelFactory* channel_factory) {
channel_factory_ = channel_factory;
}
WebRtcVideoEngine2::~WebRtcVideoEngine2() { WebRtcVideoEngine2::~WebRtcVideoEngine2() {
LOG(LS_INFO) << "WebRtcVideoEngine2::~WebRtcVideoEngine2"; LOG(LS_INFO) << "WebRtcVideoEngine2::~WebRtcVideoEngine2";
@ -673,8 +658,8 @@ WebRtcVideoChannel2::WebRtcVideoChannel2(
WebRtcVideoEngine2* engine, WebRtcVideoEngine2* engine,
VoiceMediaChannel* voice_channel, VoiceMediaChannel* voice_channel,
WebRtcVideoEncoderFactory2* encoder_factory) WebRtcVideoEncoderFactory2* encoder_factory)
: encoder_factory_(encoder_factory), : unsignalled_ssrc_handler_(&default_unsignalled_ssrc_handler_),
unsignalled_ssrc_handler_(&default_unsignalled_ssrc_handler_) { encoder_factory_(encoder_factory) {
// TODO(pbos): Connect the video and audio with |voice_channel|. // TODO(pbos): Connect the video and audio with |voice_channel|.
webrtc::Call::Config config(this); webrtc::Call::Config config(this);
Construct(webrtc::Call::Create(config), engine); Construct(webrtc::Call::Create(config), engine);
@ -684,8 +669,8 @@ WebRtcVideoChannel2::WebRtcVideoChannel2(
webrtc::Call* call, webrtc::Call* call,
WebRtcVideoEngine2* engine, WebRtcVideoEngine2* engine,
WebRtcVideoEncoderFactory2* encoder_factory) WebRtcVideoEncoderFactory2* encoder_factory)
: encoder_factory_(encoder_factory), : unsignalled_ssrc_handler_(&default_unsignalled_ssrc_handler_),
unsignalled_ssrc_handler_(&default_unsignalled_ssrc_handler_) { encoder_factory_(encoder_factory) {
Construct(call, engine); Construct(call, engine);
} }
@ -1309,10 +1294,10 @@ WebRtcVideoChannel2::WebRtcVideoSendStream::WebRtcVideoSendStream(
const StreamParams& sp, const StreamParams& sp,
const std::vector<webrtc::RtpExtension>& rtp_extensions) const std::vector<webrtc::RtpExtension>& rtp_extensions)
: call_(call), : call_(call),
parameters_(webrtc::VideoSendStream::Config(), options, codec_settings),
encoder_factory_(encoder_factory), encoder_factory_(encoder_factory),
capturer_(NULL),
stream_(NULL), stream_(NULL),
parameters_(webrtc::VideoSendStream::Config(), options, codec_settings),
capturer_(NULL),
sending_(false), sending_(false),
muted_(false) { muted_(false) {
parameters_.config.rtp.max_packet_size = kVideoMtu; parameters_.config.rtp.max_packet_size = kVideoMtu;
@ -1684,11 +1669,11 @@ WebRtcVideoChannel2::WebRtcVideoReceiveStream::WebRtcVideoReceiveStream(
const webrtc::VideoReceiveStream::Config& config, const webrtc::VideoReceiveStream::Config& config,
const std::vector<VideoCodecSettings>& recv_codecs) const std::vector<VideoCodecSettings>& recv_codecs)
: call_(call), : call_(call),
config_(config),
stream_(NULL), stream_(NULL),
config_(config),
renderer_(NULL),
last_width_(-1), last_width_(-1),
last_height_(-1), last_height_(-1) {
renderer_(NULL) {
config_.renderer = this; config_.renderer = this;
// SetRecvCodecs will also reset (start) the VideoReceiveStream. // SetRecvCodecs will also reset (start) the VideoReceiveStream.
SetRecvCodecs(recv_codecs); SetRecvCodecs(recv_codecs);

View File

@ -134,9 +134,10 @@ class WebRtcVideoEngine2 : public sigslot::has_slots<> {
public: public:
// Creates the WebRtcVideoEngine2 with internal VideoCaptureModule. // Creates the WebRtcVideoEngine2 with internal VideoCaptureModule.
WebRtcVideoEngine2(); WebRtcVideoEngine2();
// Custom WebRtcVideoChannelFactory for testing purposes. virtual ~WebRtcVideoEngine2();
explicit WebRtcVideoEngine2(WebRtcVideoChannelFactory* channel_factory);
~WebRtcVideoEngine2(); // Use a custom WebRtcVideoChannelFactory (for testing purposes).
void SetChannelFactory(WebRtcVideoChannelFactory* channel_factory);
// Basic video engine implementation. // Basic video engine implementation.
bool Init(rtc::Thread* worker_thread); bool Init(rtc::Thread* worker_thread);
@ -179,10 +180,6 @@ class WebRtcVideoEngine2 : public sigslot::has_slots<> {
virtual WebRtcVideoEncoderFactory2* GetVideoEncoderFactory(); virtual WebRtcVideoEncoderFactory2* GetVideoEncoderFactory();
private: private:
void Construct(WebRtcVideoChannelFactory* channel_factory,
WebRtcVoiceEngine* voice_engine,
rtc::CpuMonitor* cpu_monitor);
rtc::Thread* worker_thread_; rtc::Thread* worker_thread_;
WebRtcVoiceEngine* voice_engine_; WebRtcVoiceEngine* voice_engine_;
std::vector<VideoCodec> video_codecs_; std::vector<VideoCodec> video_codecs_;
@ -191,8 +188,6 @@ class WebRtcVideoEngine2 : public sigslot::has_slots<> {
bool initialized_; bool initialized_;
bool capture_started_;
// Critical section to protect the media processor register/unregister // Critical section to protect the media processor register/unregister
// while processing a frame // while processing a frame
rtc::CriticalSection signal_media_critical_; rtc::CriticalSection signal_media_critical_;

View File

@ -309,7 +309,8 @@ WebRtcVideoChannel2* FakeWebRtcVideoMediaChannelFactory::Create(
class WebRtcVideoEngine2Test : public testing::Test { class WebRtcVideoEngine2Test : public testing::Test {
public: public:
WebRtcVideoEngine2Test() : engine_(&factory_) { WebRtcVideoEngine2Test() {
engine_.SetChannelFactory(&factory_);
std::vector<VideoCodec> engine_codecs = engine_.codecs(); std::vector<VideoCodec> engine_codecs = engine_.codecs();
assert(!engine_codecs.empty()); assert(!engine_codecs.empty());
bool codec_set = false; bool codec_set = false;