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/talk@6977 4adac7df-926f-26a2-2b94-8c16560cd09d
diff --git a/app/webrtc/java/jni/peerconnection_jni.cc b/app/webrtc/java/jni/peerconnection_jni.cc
index 9b34fb5..0c26698 100644
--- a/app/webrtc/java/jni/peerconnection_jni.cc
+++ b/app/webrtc/java/jni/peerconnection_jni.cc
@@ -917,11 +917,11 @@
DataChannelObserverWrapper(JNIEnv* jni, jobject j_observer)
: j_observer_global_(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_,
"onStateChange", "()V")),
j_on_message_mid_(GetMethodID(jni, *j_observer_class_, "onMessage",
"(Lorg/webrtc/DataChannel$Buffer;)V")),
- j_buffer_class_(jni, FindClass(jni, "org/webrtc/DataChannel$Buffer")),
j_buffer_ctor_(GetMethodID(jni, *j_buffer_class_,
"<init>", "(Ljava/nio/ByteBuffer;Z)V")) {
}
diff --git a/media/webrtc/webrtcvideoengine2.cc b/media/webrtc/webrtcvideoengine2.cc
index a80e74e..efd3df4 100644
--- a/media/webrtc/webrtcvideoengine2.cc
+++ b/media/webrtc/webrtcvideoengine2.cc
@@ -283,37 +283,17 @@
}
WebRtcVideoEngine2::WebRtcVideoEngine2()
- : default_codec_format_(kDefaultVideoCodecPref.width,
+ : worker_thread_(NULL),
+ voice_engine_(NULL),
+ video_codecs_(DefaultVideoCodecs()),
+ default_codec_format_(kDefaultVideoCodecPref.width,
kDefaultVideoCodecPref.height,
FPS_TO_INTERVAL(kDefaultFramerate),
- FOURCC_ANY) {
- // Construct without a factory or voice engine.
- Construct(NULL, NULL, new rtc::CpuMonitor(NULL));
-}
-
-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();
-
+ FOURCC_ANY),
+ initialized_(false),
+ cpu_monitor_(new rtc::CpuMonitor(NULL)),
+ channel_factory_(NULL) {
+ LOG(LS_INFO) << "WebRtcVideoEngine2::WebRtcVideoEngine2()";
rtp_header_extensions_.push_back(
RtpHeaderExtension(kRtpTimestampOffsetHeaderExtension,
kRtpTimestampOffsetHeaderExtensionDefaultId));
@@ -322,6 +302,11 @@
kRtpAbsoluteSenderTimeHeaderExtensionDefaultId));
}
+void WebRtcVideoEngine2::SetChannelFactory(
+ WebRtcVideoChannelFactory* channel_factory) {
+ channel_factory_ = channel_factory;
+}
+
WebRtcVideoEngine2::~WebRtcVideoEngine2() {
LOG(LS_INFO) << "WebRtcVideoEngine2::~WebRtcVideoEngine2";
@@ -673,8 +658,8 @@
WebRtcVideoEngine2* engine,
VoiceMediaChannel* voice_channel,
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|.
webrtc::Call::Config config(this);
Construct(webrtc::Call::Create(config), engine);
@@ -684,8 +669,8 @@
webrtc::Call* call,
WebRtcVideoEngine2* engine,
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);
}
@@ -1309,10 +1294,10 @@
const StreamParams& sp,
const std::vector<webrtc::RtpExtension>& rtp_extensions)
: call_(call),
- parameters_(webrtc::VideoSendStream::Config(), options, codec_settings),
encoder_factory_(encoder_factory),
- capturer_(NULL),
stream_(NULL),
+ parameters_(webrtc::VideoSendStream::Config(), options, codec_settings),
+ capturer_(NULL),
sending_(false),
muted_(false) {
parameters_.config.rtp.max_packet_size = kVideoMtu;
@@ -1684,11 +1669,11 @@
const webrtc::VideoReceiveStream::Config& config,
const std::vector<VideoCodecSettings>& recv_codecs)
: call_(call),
- config_(config),
stream_(NULL),
+ config_(config),
+ renderer_(NULL),
last_width_(-1),
- last_height_(-1),
- renderer_(NULL) {
+ last_height_(-1) {
config_.renderer = this;
// SetRecvCodecs will also reset (start) the VideoReceiveStream.
SetRecvCodecs(recv_codecs);
diff --git a/media/webrtc/webrtcvideoengine2.h b/media/webrtc/webrtcvideoengine2.h
index f665cb0..c961bd5 100644
--- a/media/webrtc/webrtcvideoengine2.h
+++ b/media/webrtc/webrtcvideoengine2.h
@@ -134,9 +134,10 @@
public:
// Creates the WebRtcVideoEngine2 with internal VideoCaptureModule.
WebRtcVideoEngine2();
- // Custom WebRtcVideoChannelFactory for testing purposes.
- explicit WebRtcVideoEngine2(WebRtcVideoChannelFactory* channel_factory);
- ~WebRtcVideoEngine2();
+ virtual ~WebRtcVideoEngine2();
+
+ // Use a custom WebRtcVideoChannelFactory (for testing purposes).
+ void SetChannelFactory(WebRtcVideoChannelFactory* channel_factory);
// Basic video engine implementation.
bool Init(rtc::Thread* worker_thread);
@@ -179,10 +180,6 @@
virtual WebRtcVideoEncoderFactory2* GetVideoEncoderFactory();
private:
- void Construct(WebRtcVideoChannelFactory* channel_factory,
- WebRtcVoiceEngine* voice_engine,
- rtc::CpuMonitor* cpu_monitor);
-
rtc::Thread* worker_thread_;
WebRtcVoiceEngine* voice_engine_;
std::vector<VideoCodec> video_codecs_;
@@ -191,8 +188,6 @@
bool initialized_;
- bool capture_started_;
-
// Critical section to protect the media processor register/unregister
// while processing a frame
rtc::CriticalSection signal_media_critical_;
diff --git a/media/webrtc/webrtcvideoengine2_unittest.cc b/media/webrtc/webrtcvideoengine2_unittest.cc
index 9c313e6..6aaa7bd 100644
--- a/media/webrtc/webrtcvideoengine2_unittest.cc
+++ b/media/webrtc/webrtcvideoengine2_unittest.cc
@@ -309,7 +309,8 @@
class WebRtcVideoEngine2Test : public testing::Test {
public:
- WebRtcVideoEngine2Test() : engine_(&factory_) {
+ WebRtcVideoEngine2Test() {
+ engine_.SetChannelFactory(&factory_);
std::vector<VideoCodec> engine_codecs = engine_.codecs();
assert(!engine_codecs.empty());
bool codec_set = false;