Get rid of unnecessary Terminate() method and worker_thread_ from WebRtcVideoEngine2

BUG=
R=pthatcher@webrtc.org

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

Cr-Commit-Position: refs/heads/master@{#9258}
This commit is contained in:
Fredrik Solenberg 2015-05-22 09:04:09 +02:00
parent 5af6d47d26
commit 9a416bd14e
6 changed files with 16 additions and 42 deletions

View File

@ -711,9 +711,6 @@ class FakeBaseEngine {
: loglevel_(-1),
options_changed_(false),
fail_create_channel_(false) {}
bool Init(rtc::Thread* worker_thread) { return true; }
void Terminate() {}
void SetLogging(int level, const char* filter) {
loglevel_ = level;
logfilter_ = filter;
@ -751,6 +748,8 @@ class FakeVoiceEngine : public FakeBaseEngine {
// sanity checks against that.
codecs_.push_back(AudioCodec(101, "fake_audio_codec", 0, 0, 1, 0));
}
bool Init(rtc::Thread* worker_thread) { return true; }
void Terminate() {}
int GetCapabilities() { return AUDIO_SEND | AUDIO_RECV; }
AudioOptions GetAudioOptions() const {
return options_;
@ -861,6 +860,7 @@ class FakeVideoEngine : public FakeBaseEngine {
// sanity checks against that.
codecs_.push_back(VideoCodec(0, "fake_video_codec", 0, 0, 0, 0));
}
void Init() {}
bool GetOptions(VideoOptions* options) const {
*options = options_;
return true;

View File

@ -168,14 +168,10 @@ class CompositeMediaEngine : public MediaEngineInterface {
virtual bool Init(rtc::Thread* worker_thread) {
if (!voice_.Init(worker_thread))
return false;
if (!video_.Init(worker_thread)) {
voice_.Terminate();
return false;
}
video_.Init();
return true;
}
virtual void Terminate() {
video_.Terminate();
voice_.Terminate();
}

View File

@ -496,7 +496,7 @@ class VideoMediaChannelTest : public testing::Test,
virtual void SetUp() {
cricket::Device device("test", "device");
EXPECT_TRUE(engine_.Init(rtc::Thread::Current()));
engine_.Init();
channel_.reset(engine_.CreateChannel(cricket::VideoOptions(), NULL));
EXPECT_TRUE(channel_.get() != NULL);
ConnectVideoChannelError();
@ -551,7 +551,6 @@ class VideoMediaChannelTest : public testing::Test,
}
virtual void TearDown() {
channel_.reset();
engine_.Terminate();
}
void ConnectVideoChannelError() {
channel_->SignalMediaError.connect(this,

View File

@ -530,8 +530,7 @@ void DefaultUnsignalledSsrcHandler::SetDefaultRenderer(
}
WebRtcVideoEngine2::WebRtcVideoEngine2(WebRtcVoiceEngine* voice_engine)
: worker_thread_(NULL),
voice_engine_(voice_engine),
: voice_engine_(voice_engine),
initialized_(false),
call_factory_(&default_call_factory_),
external_decoder_factory_(NULL),
@ -551,10 +550,6 @@ WebRtcVideoEngine2::WebRtcVideoEngine2(WebRtcVoiceEngine* voice_engine)
WebRtcVideoEngine2::~WebRtcVideoEngine2() {
LOG(LS_INFO) << "WebRtcVideoEngine2::~WebRtcVideoEngine2";
if (initialized_) {
Terminate();
}
}
void WebRtcVideoEngine2::SetCallFactory(WebRtcCallFactory* call_factory) {
@ -562,19 +557,9 @@ void WebRtcVideoEngine2::SetCallFactory(WebRtcCallFactory* call_factory) {
call_factory_ = call_factory;
}
bool WebRtcVideoEngine2::Init(rtc::Thread* worker_thread) {
void WebRtcVideoEngine2::Init() {
LOG(LS_INFO) << "WebRtcVideoEngine2::Init";
worker_thread_ = worker_thread;
DCHECK(worker_thread_ != NULL);
initialized_ = true;
return true;
}
void WebRtcVideoEngine2::Terminate() {
LOG(LS_INFO) << "WebRtcVideoEngine2::Terminate";
initialized_ = false;
}
int WebRtcVideoEngine2::GetCapabilities() { return VIDEO_RECV | VIDEO_SEND; }

View File

@ -123,8 +123,7 @@ class WebRtcVideoEngine2 : public sigslot::has_slots<> {
void SetCallFactory(WebRtcCallFactory* call_factory);
// Basic video engine implementation.
bool Init(rtc::Thread* worker_thread);
void Terminate();
void Init();
int GetCapabilities();
bool SetDefaultEncoderConfig(const VideoEncoderConfig& config);
@ -158,7 +157,6 @@ class WebRtcVideoEngine2 : public sigslot::has_slots<> {
private:
std::vector<VideoCodec> GetSupportedCodecs() const;
rtc::Thread* worker_thread_;
WebRtcVoiceEngine* voice_engine_;
std::vector<VideoCodec> video_codecs_;
std::vector<RtpHeaderExtension> rtp_header_extensions_;

View File

@ -173,9 +173,8 @@ class WebRtcVideoEngine2VoiceTest : public WebRtcVideoEngine2Test {
TEST_F(WebRtcVideoEngine2VoiceTest, ConfiguresAvSyncForFirstReceiveChannel) {
FakeCallFactory call_factory;
engine_.SetCallFactory(&call_factory);
voice_engine_.Init(rtc::Thread::Current());
engine_.Init(rtc::Thread::Current());
engine_.Init();
rtc::scoped_ptr<VoiceMediaChannel> voice_channel(
voice_engine_.CreateChannel());
@ -386,7 +385,7 @@ TEST_F(WebRtcVideoEngine2Test, CVOSetHeaderExtensionAfterCapturer) {
}
TEST_F(WebRtcVideoEngine2Test, SetSendFailsBeforeSettingCodecs) {
engine_.Init(rtc::Thread::Current());
engine_.Init();
rtc::scoped_ptr<VideoMediaChannel> channel(
engine_.CreateChannel(cricket::VideoOptions(), NULL));
@ -399,7 +398,7 @@ TEST_F(WebRtcVideoEngine2Test, SetSendFailsBeforeSettingCodecs) {
}
TEST_F(WebRtcVideoEngine2Test, GetStatsWithoutSendCodecsSetDoesNotCrash) {
engine_.Init(rtc::Thread::Current());
engine_.Init();
rtc::scoped_ptr<VideoMediaChannel> channel(
engine_.CreateChannel(cricket::VideoOptions(), NULL));
EXPECT_TRUE(channel->AddSendStream(StreamParams::CreateLegacy(123)));
@ -461,7 +460,7 @@ VideoMediaChannel* WebRtcVideoEngine2Test::SetUpForExternalEncoderFactory(
cricket::WebRtcVideoEncoderFactory* encoder_factory,
const std::vector<VideoCodec>& codecs) {
engine_.SetExternalEncoderFactory(encoder_factory);
engine_.Init(rtc::Thread::Current());
engine_.Init();
VideoMediaChannel* channel =
engine_.CreateChannel(cricket::VideoOptions(), NULL);
@ -474,7 +473,7 @@ VideoMediaChannel* WebRtcVideoEngine2Test::SetUpForExternalDecoderFactory(
cricket::WebRtcVideoDecoderFactory* decoder_factory,
const std::vector<VideoCodec>& codecs) {
engine_.SetExternalDecoderFactory(decoder_factory);
engine_.Init(rtc::Thread::Current());
engine_.Init();
VideoMediaChannel* channel =
engine_.CreateChannel(cricket::VideoOptions(), NULL);
@ -623,8 +622,7 @@ TEST_F(WebRtcVideoEngine2Test, ReportSupportedExternalCodecs) {
cricket::FakeWebRtcVideoEncoderFactory encoder_factory;
encoder_factory.AddSupportedVideoCodecType(webrtc::kVideoCodecH264, "H264");
engine_.SetExternalEncoderFactory(&encoder_factory);
engine_.Init(rtc::Thread::Current());
engine_.Init();
std::vector<cricket::VideoCodec> codecs(engine_.codecs());
ASSERT_GE(codecs.size(), 2u);
@ -822,7 +820,7 @@ class WebRtcVideoChannel2Test : public WebRtcVideoEngine2Test,
WebRtcVideoChannel2Test() : fake_call_(NULL), last_ssrc_(0) {}
void SetUp() override {
engine_.SetCallFactory(this);
engine_.Init(rtc::Thread::Current());
engine_.Init();
channel_.reset(engine_.CreateChannel(cricket::VideoOptions(), NULL));
ASSERT_TRUE(fake_call_ != NULL) << "Call not created through factory.";
last_ssrc_ = 123;
@ -1586,8 +1584,6 @@ class Vp9SettingsTest : public WebRtcVideoChannel2Test {
void TearDown() override {
// Remove references to encoder_factory_ since this will be destroyed
// before channel_ and engine_.
engine_.Terminate();
engine_.SetExternalEncoderFactory(nullptr);
ASSERT_TRUE(channel_->SetSendCodecs(engine_.codecs()));
}
@ -2567,7 +2563,7 @@ class WebRtcVideoChannel2SimulcastTest : public WebRtcVideoEngine2SimulcastTest,
void SetUp() override {
engine_.SetCallFactory(this);
engine_.Init(rtc::Thread::Current());
engine_.Init();
channel_.reset(engine_.CreateChannel(VideoOptions(), NULL));
ASSERT_TRUE(fake_call_ != NULL) << "Call not created through factory.";
last_ssrc_ = 123;