Switching some interfaces to use std::unique_ptr<>.
This helps show where ownership is transfered between objects. Specifically, this CL wraps cricket::VideoCapturer, MediaEngineInterface and DataEngineInterface in unique_ptr. BUG=None TBR=magjed@webrtc.org Review-Url: https://codereview.webrtc.org/2685093002 Cr-Commit-Position: refs/heads/master@{#16548}
This commit is contained in:
@ -8,6 +8,8 @@
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "webrtc/base/gunit.h"
|
||||
#include "webrtc/base/logging.h"
|
||||
#include "webrtc/base/thread.h"
|
||||
@ -40,34 +42,28 @@ class ChannelManagerTest : public testing::Test {
|
||||
ChannelManagerTest()
|
||||
: fme_(new cricket::FakeMediaEngine()),
|
||||
fdme_(new cricket::FakeDataEngine()),
|
||||
cm_(new cricket::ChannelManager(fme_, fdme_, rtc::Thread::Current())),
|
||||
cm_(new cricket::ChannelManager(
|
||||
std::unique_ptr<MediaEngineInterface>(fme_),
|
||||
std::unique_ptr<DataEngineInterface>(fdme_),
|
||||
rtc::Thread::Current())),
|
||||
fake_call_(webrtc::Call::Config(&event_log_)),
|
||||
fake_mc_(cm_, &fake_call_),
|
||||
fake_mc_(cm_.get(), &fake_call_),
|
||||
transport_controller_(
|
||||
new cricket::FakeTransportController(ICEROLE_CONTROLLING)) {}
|
||||
|
||||
virtual void SetUp() {
|
||||
new cricket::FakeTransportController(ICEROLE_CONTROLLING)) {
|
||||
fme_->SetAudioCodecs(MAKE_VECTOR(kAudioCodecs));
|
||||
fme_->SetVideoCodecs(MAKE_VECTOR(kVideoCodecs));
|
||||
}
|
||||
|
||||
virtual void TearDown() {
|
||||
delete transport_controller_;
|
||||
delete cm_;
|
||||
cm_ = NULL;
|
||||
fdme_ = NULL;
|
||||
fme_ = NULL;
|
||||
}
|
||||
|
||||
webrtc::RtcEventLogNullImpl event_log_;
|
||||
rtc::Thread network_;
|
||||
rtc::Thread worker_;
|
||||
// |fme_| and |fdme_| are actually owned by |cm_|.
|
||||
cricket::FakeMediaEngine* fme_;
|
||||
cricket::FakeDataEngine* fdme_;
|
||||
cricket::ChannelManager* cm_;
|
||||
std::unique_ptr<cricket::ChannelManager> cm_;
|
||||
cricket::FakeCall fake_call_;
|
||||
cricket::FakeMediaController fake_mc_;
|
||||
cricket::FakeTransportController* transport_controller_;
|
||||
std::unique_ptr<cricket::FakeTransportController> transport_controller_;
|
||||
};
|
||||
|
||||
// Test that we startup/shutdown properly.
|
||||
@ -133,9 +129,8 @@ TEST_F(ChannelManagerTest, CreateDestroyChannelsOnThread) {
|
||||
EXPECT_TRUE(cm_->set_worker_thread(&worker_));
|
||||
EXPECT_TRUE(cm_->set_network_thread(&network_));
|
||||
EXPECT_TRUE(cm_->Init());
|
||||
delete transport_controller_;
|
||||
transport_controller_ =
|
||||
new cricket::FakeTransportController(&network_, ICEROLE_CONTROLLING);
|
||||
transport_controller_.reset(
|
||||
new cricket::FakeTransportController(&network_, ICEROLE_CONTROLLING));
|
||||
cricket::DtlsTransportInternal* rtp_transport =
|
||||
transport_controller_->CreateDtlsTransport(
|
||||
cricket::CN_AUDIO, cricket::ICE_CANDIDATE_COMPONENT_RTP);
|
||||
|
||||
Reference in New Issue
Block a user