Remove static initializer from WebRtcVideoEngine2.

BUG=
R=pliard@google.com, pthatcher@webrtc.org, pliard@chromium.org

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

git-svn-id: http://webrtc.googlecode.com/svn/trunk@6338 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
pbos@webrtc.org 2014-06-05 09:10:55 +00:00
parent aafd7a88c5
commit 0d523eea83
3 changed files with 13 additions and 9 deletions

View File

@ -192,6 +192,9 @@ static std::vector<VideoCodec> DefaultVideoCodecs() {
return codecs;
}
WebRtcVideoEncoderFactory2::~WebRtcVideoEncoderFactory2() {
}
class DefaultVideoEncoderFactory : public WebRtcVideoEncoderFactory2 {
public:
virtual bool CreateEncoderSettings(
@ -239,7 +242,7 @@ class DefaultVideoEncoderFactory : public WebRtcVideoEncoderFactory2 {
virtual bool SupportsCodec(const VideoCodec& codec) OVERRIDE {
return _stricmp(codec.name.c_str(), kVp8PayloadName) == 0;
}
} default_encoder_factory;
};
WebRtcVideoEngine2::WebRtcVideoEngine2() {
// Construct without a factory or voice engine.
@ -265,6 +268,7 @@ void WebRtcVideoEngine2::Construct(WebRtcVideoChannelFactory* channel_factory,
video_codecs_ = DefaultVideoCodecs();
default_codec_format_ = VideoFormat(kDefaultVideoFormat);
default_video_encoder_factory_.reset(new DefaultVideoEncoderFactory());
}
WebRtcVideoEngine2::~WebRtcVideoEngine2() {
@ -328,7 +332,7 @@ WebRtcVideoChannel2* WebRtcVideoEngine2::CreateChannel(
channel_factory_ != NULL
? channel_factory_->Create(this, voice_channel)
: new WebRtcVideoChannel2(
this, voice_channel, GetDefaultVideoEncoderFactory());
this, voice_channel, GetVideoEncoderFactory());
if (!channel->Init()) {
delete channel;
return NULL;
@ -463,9 +467,8 @@ bool WebRtcVideoEngine2::ShouldIgnoreTrace(const std::string& trace) {
return false;
}
WebRtcVideoEncoderFactory2* WebRtcVideoEngine2::GetDefaultVideoEncoderFactory()
const {
return &default_encoder_factory;
WebRtcVideoEncoderFactory2* WebRtcVideoEngine2::GetVideoEncoderFactory() const {
return default_video_encoder_factory_.get();
}
// Thin map between cricket::VideoFrame and an existing webrtc::I420VideoFrame

View File

@ -82,6 +82,7 @@ class WebRtcVideoChannel2;
class WebRtcVideoEncoderFactory2 {
public:
virtual ~WebRtcVideoEncoderFactory2();
virtual bool CreateEncoderSettings(
webrtc::VideoSendStream::Config::EncoderSettings* encoder_settings,
const VideoOptions& options,
@ -139,7 +140,7 @@ class WebRtcVideoEngine2 : public sigslot::has_slots<> {
talk_base::CpuMonitor* cpu_monitor() { return cpu_monitor_.get(); }
virtual WebRtcVideoEncoderFactory2* GetDefaultVideoEncoderFactory() const;
virtual WebRtcVideoEncoderFactory2* GetVideoEncoderFactory() const;
private:
void Construct(WebRtcVideoChannelFactory* channel_factory,
@ -162,6 +163,8 @@ class WebRtcVideoEngine2 : public sigslot::has_slots<> {
talk_base::scoped_ptr<talk_base::CpuMonitor> cpu_monitor_;
WebRtcVideoChannelFactory* channel_factory_;
talk_base::scoped_ptr<WebRtcVideoEncoderFactory2>
default_video_encoder_factory_;
};
// Adapter between webrtc::VideoRenderer and cricket::VideoRenderer.

View File

@ -243,9 +243,7 @@ class FakeWebRtcVideoChannel2 : public WebRtcVideoChannel2 {
FakeWebRtcVideoChannel2(FakeCall* call,
WebRtcVideoEngine2* engine,
VoiceMediaChannel* voice_channel)
: WebRtcVideoChannel2(call,
engine,
engine->GetDefaultVideoEncoderFactory()),
: WebRtcVideoChannel2(call, engine, engine->GetVideoEncoderFactory()),
fake_call_(call),
voice_channel_(voice_channel) {}