Make the destructor of AudioCodingModule public.

This allows the type to be used with a scoped_ptr. Remove all calls to
the deprecated Destroy() from tests.

R=turaj@webrtc.org

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

git-svn-id: http://webrtc.googlecode.com/svn/trunk@4731 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
andrew@webrtc.org 2013-09-12 01:27:43 +00:00
parent 5eb997a2fd
commit 89df092807
24 changed files with 107 additions and 217 deletions

View File

@ -76,7 +76,6 @@ class ACMVQMonCallback {
class AudioCodingModule: public Module {
protected:
AudioCodingModule() {}
virtual ~AudioCodingModule() {}
public:
///////////////////////////////////////////////////////////////////////////
@ -88,7 +87,9 @@ class AudioCodingModule: public Module {
//
static AudioCodingModule* Create(const int32_t id);
static AudioCodingModule* Create(const int32_t id, Clock* clock);
virtual ~AudioCodingModule() {};
// TODO(ajm): Deprecated. Remove all calls to this unneeded method.
static void Destroy(AudioCodingModule* module);
///////////////////////////////////////////////////////////////////////////

View File

@ -55,8 +55,8 @@ void APITest::Wait(uint32_t waitLengthMs) {
}
APITest::APITest()
: _acmA(NULL),
_acmB(NULL),
: _acmA(AudioCodingModule::Create(1)),
_acmB(AudioCodingModule::Create(2)),
_channel_A2B(NULL),
_channel_B2A(NULL),
_writeToFile(true),
@ -111,9 +111,6 @@ APITest::APITest()
}
APITest::~APITest() {
DESTROY_ACM(_acmA);
DESTROY_ACM(_acmB);
DELETE_POINTER(_channel_A2B);
DELETE_POINTER(_channel_B2A);
@ -141,9 +138,6 @@ APITest::~APITest() {
}
int16_t APITest::SetUp() {
_acmA = AudioCodingModule::Create(1);
_acmB = AudioCodingModule::Create(2);
CodecInst dummyCodec;
int lastPayloadType = 0;

View File

@ -22,6 +22,7 @@
#include "webrtc/modules/audio_coding/main/interface/audio_coding_module.h"
#include "webrtc/modules/audio_coding/main/source/acm_common_defs.h"
#include "webrtc/modules/audio_coding/main/test/utility.h"
#include "webrtc/system_wrappers/interface/scoped_ptr.h"
#include "webrtc/system_wrappers/interface/trace.h"
#include "webrtc/test/testsupport/fileutils.h"
@ -269,7 +270,7 @@ void EncodeDecodeTest::Perform() {
codePars[1] = 0;
codePars[2] = 0;
AudioCodingModule* acm = AudioCodingModule::Create(0);
scoped_ptr<AudioCodingModule> acm(AudioCodingModule::Create(0));
struct CodecInst sendCodecTmp;
numCodecs = acm->NumberOfCodecs();
@ -309,15 +310,13 @@ void EncodeDecodeTest::Perform() {
_receiver.codeId = codeId;
rtpFile.ReadHeader();
_receiver.Setup(acm, &rtpFile);
_receiver.Setup(acm.get(), &rtpFile);
_receiver.Run();
_receiver.Teardown();
rtpFile.Close();
}
}
AudioCodingModule::Destroy(acm);
// End tracing.
if (_testMode == 1) {
Trace::ReturnTrace();
@ -326,7 +325,7 @@ void EncodeDecodeTest::Perform() {
void EncodeDecodeTest::EncodeToFile(int fileType, int codeId, int* codePars,
int testMode) {
AudioCodingModule* acm = AudioCodingModule::Create(1);
scoped_ptr<AudioCodingModule> acm(AudioCodingModule::Create(1));
RTPFile rtpFile;
std::string fileName = webrtc::test::OutputPath() + "outFile.rtp";
rtpFile.Open(fileName.c_str(), "wb+");
@ -336,14 +335,13 @@ void EncodeDecodeTest::EncodeToFile(int fileType, int codeId, int* codePars,
_sender.testMode = testMode;
_sender.codeId = codeId;
_sender.Setup(acm, &rtpFile);
_sender.Setup(acm.get(), &rtpFile);
struct CodecInst sendCodecInst;
if (acm->SendCodec(&sendCodecInst) >= 0) {
_sender.Run();
}
_sender.Teardown();
rtpFile.Close();
AudioCodingModule::Destroy(acm);
}
} // namespace webrtc

View File

@ -23,31 +23,27 @@ namespace webrtc {
#define NUM_PANN_COEFFS 10
SpatialAudio::SpatialAudio(int testMode) {
_testMode = testMode;
SpatialAudio::SpatialAudio(int testMode)
: _acmLeft(AudioCodingModule::Create(1)),
_acmRight(AudioCodingModule::Create(2)),
_acmReceiver(AudioCodingModule::Create(3)),
_testMode(testMode) {
}
SpatialAudio::~SpatialAudio() {
AudioCodingModule::Destroy(_acmLeft);
AudioCodingModule::Destroy(_acmRight);
AudioCodingModule::Destroy(_acmReceiver);
delete _channel;
_inFile.Close();
_outFile.Close();
}
int16_t SpatialAudio::Setup() {
// Create ACMs and the Channel;
_acmLeft = AudioCodingModule::Create(1);
_acmRight = AudioCodingModule::Create(2);
_acmReceiver = AudioCodingModule::Create(3);
_channel = new Channel;
// Register callback for the sender side.
CHECK_ERROR(_acmLeft->RegisterTransportCallback(_channel));
CHECK_ERROR(_acmRight->RegisterTransportCallback(_channel));
// Register the receiver ACM in channel
_channel->RegisterReceiverACM(_acmReceiver);
_channel->RegisterReceiverACM(_acmReceiver.get());
uint16_t sampFreqHz = 32000;

View File

@ -11,6 +11,7 @@
#ifndef ACM_TEST_SPATIAL_AUDIO_H
#define ACM_TEST_SPATIAL_AUDIO_H
#include "webrtc/system_wrappers/interface/scoped_ptr.h"
#include "ACMTest.h"
#include "Channel.h"
#include "PCMFile.h"
@ -32,9 +33,9 @@ class SpatialAudio : public ACMTest {
void EncodeDecode(double leftPanning, double rightPanning);
void EncodeDecode();
AudioCodingModule* _acmLeft;
AudioCodingModule* _acmRight;
AudioCodingModule* _acmReceiver;
scoped_ptr<AudioCodingModule> _acmLeft;
scoped_ptr<AudioCodingModule> _acmRight;
scoped_ptr<AudioCodingModule> _acmReceiver;
Channel* _channel;
PCMFile _inFile;
PCMFile _outFile;

View File

@ -100,8 +100,8 @@ void TestPack::reset_payload_size() {
}
TestAllCodecs::TestAllCodecs(int test_mode)
: acm_a_(NULL),
acm_b_(NULL),
: acm_a_(AudioCodingModule::Create(0)),
acm_b_(AudioCodingModule::Create(1)),
channel_a_to_b_(NULL),
test_count_(0),
packet_size_samples_(0),
@ -111,14 +111,6 @@ TestAllCodecs::TestAllCodecs(int test_mode)
}
TestAllCodecs::~TestAllCodecs() {
if (acm_a_ != NULL) {
AudioCodingModule::Destroy(acm_a_);
acm_a_ = NULL;
}
if (acm_b_ != NULL) {
AudioCodingModule::Destroy(acm_b_);
acm_b_ = NULL;
}
if (channel_a_to_b_ != NULL) {
delete channel_a_to_b_;
channel_a_to_b_ = NULL;
@ -135,9 +127,6 @@ void TestAllCodecs::Perform() {
"---------- TestAllCodecs ----------");
}
acm_a_ = AudioCodingModule::Create(0);
acm_b_ = AudioCodingModule::Create(1);
acm_a_->InitializeReceiver();
acm_b_->InitializeReceiver();
@ -154,7 +143,7 @@ void TestAllCodecs::Perform() {
// Create and connect the channel
channel_a_to_b_ = new TestPack;
acm_a_->RegisterTransportCallback(channel_a_to_b_);
channel_a_to_b_->RegisterReceiverACM(acm_b_);
channel_a_to_b_->RegisterReceiverACM(acm_b_.get());
// All codecs are tested for all allowed sampling frequencies, rates and
// packet sizes.
@ -736,11 +725,11 @@ void TestAllCodecs::RegisterSendCodec(char side, char* codec_name,
AudioCodingModule* my_acm = NULL;
switch (side) {
case 'A': {
my_acm = acm_a_;
my_acm = acm_a_.get();
break;
}
case 'B': {
my_acm = acm_b_;
my_acm = acm_b_.get();
break;
}
default: {

View File

@ -11,6 +11,7 @@
#ifndef WEBRTC_MODULES_AUDIO_CODING_MAIN_TEST_TEST_ALL_CODECS_H_
#define WEBRTC_MODULES_AUDIO_CODING_MAIN_TEST_TEST_ALL_CODECS_H_
#include "webrtc/system_wrappers/interface/scoped_ptr.h"
#include "ACMTest.h"
#include "Channel.h"
#include "PCMFile.h"
@ -64,8 +65,8 @@ class TestAllCodecs : public ACMTest {
void DisplaySendReceiveCodec();
int test_mode_;
AudioCodingModule* acm_a_;
AudioCodingModule* acm_b_;
scoped_ptr<AudioCodingModule> acm_a_;
scoped_ptr<AudioCodingModule> acm_b_;
TestPack* channel_a_to_b_;
PCMFile infile_a_;
PCMFile outfile_b_;

View File

@ -24,21 +24,13 @@
namespace webrtc {
TestFEC::TestFEC()
: _acmA(NULL),
_acmB(NULL),
: _acmA(AudioCodingModule::Create(0)),
_acmB(AudioCodingModule::Create(1)),
_channelA2B(NULL),
_testCntr(0) {
}
TestFEC::~TestFEC() {
if (_acmA != NULL) {
AudioCodingModule::Destroy(_acmA);
_acmA = NULL;
}
if (_acmB != NULL) {
AudioCodingModule::Destroy(_acmB);
_acmB = NULL;
}
if (_channelA2B != NULL) {
delete _channelA2B;
_channelA2B = NULL;
@ -50,9 +42,6 @@ void TestFEC::Perform() {
"audio_coding/testfile32kHz", "pcm");
_inFileA.Open(file_name, 32000, "rb");
_acmA = AudioCodingModule::Create(0);
_acmB = AudioCodingModule::Create(1);
ASSERT_EQ(0, _acmA->InitializeReceiver());
ASSERT_EQ(0, _acmB->InitializeReceiver());
@ -66,7 +55,7 @@ void TestFEC::Perform() {
// Create and connect the channel
_channelA2B = new Channel;
_acmA->RegisterTransportCallback(_channelA2B);
_channelA2B->RegisterReceiverACM(_acmB);
_channelA2B->RegisterReceiverACM(_acmB.get());
#ifndef WEBRTC_CODEC_G722
EXPECT_TRUE(false);
@ -217,11 +206,11 @@ int16_t TestFEC::RegisterSendCodec(char side, char* codecName,
AudioCodingModule* myACM;
switch (side) {
case 'A': {
myACM = _acmA;
myACM = _acmA.get();
break;
}
case 'B': {
myACM = _acmB;
myACM = _acmB.get();
break;
}
default:

View File

@ -11,6 +11,7 @@
#ifndef TEST_FEC_H
#define TEST_FEC_H
#include "webrtc/system_wrappers/interface/scoped_ptr.h"
#include "ACMTest.h"
#include "Channel.h"
#include "PCMFile.h"
@ -32,8 +33,8 @@ class TestFEC : public ACMTest {
void Run();
void OpenOutFile(int16_t testNumber);
int32_t SetVAD(bool enableDTX, bool enableVAD, ACMVADMode vadMode);
AudioCodingModule* _acmA;
AudioCodingModule* _acmB;
scoped_ptr<AudioCodingModule> _acmA;
scoped_ptr<AudioCodingModule> _acmB;
Channel* _channelA2B;

View File

@ -109,8 +109,8 @@ void TestPackStereo::set_lost_packet(bool lost) {
}
TestStereo::TestStereo(int test_mode)
: acm_a_(NULL),
acm_b_(NULL),
: acm_a_(AudioCodingModule::Create(0)),
acm_b_(AudioCodingModule::Create(1)),
channel_a2b_(NULL),
test_cntr_(0),
pack_size_samp_(0),
@ -132,14 +132,6 @@ TestStereo::TestStereo(int test_mode)
}
TestStereo::~TestStereo() {
if (acm_a_ != NULL) {
AudioCodingModule::Destroy(acm_a_);
acm_a_ = NULL;
}
if (acm_b_ != NULL) {
AudioCodingModule::Destroy(acm_b_);
acm_b_ = NULL;
}
if (channel_a2b_ != NULL) {
delete channel_a2b_;
channel_a2b_ = NULL;
@ -168,9 +160,7 @@ void TestStereo::Perform() {
in_file_mono_->ReadStereo(false);
// Create and initialize two ACMs, one for each side of a one-to-one call.
acm_a_ = AudioCodingModule::Create(0);
acm_b_ = AudioCodingModule::Create(1);
ASSERT_TRUE((acm_a_ != NULL) && (acm_b_ != NULL));
ASSERT_TRUE((acm_a_.get() != NULL) && (acm_b_.get() != NULL));
EXPECT_EQ(0, acm_a_->InitializeReceiver());
EXPECT_EQ(0, acm_b_->InitializeReceiver());
@ -197,7 +187,7 @@ void TestStereo::Perform() {
// Create and connect the channel.
channel_a2b_ = new TestPackStereo;
EXPECT_EQ(0, acm_a_->RegisterTransportCallback(channel_a2b_));
channel_a2b_->RegisterReceiverACM(acm_b_);
channel_a2b_->RegisterReceiverACM(acm_b_.get());
// Start with setting VAD/DTX, before we know we will send stereo.
// Continue with setting a stereo codec as send codec and verify that
@ -786,11 +776,11 @@ void TestStereo::RegisterSendCodec(char side, char* codec_name,
AudioCodingModule* my_acm = NULL;
switch (side) {
case 'A': {
my_acm = acm_a_;
my_acm = acm_a_.get();
break;
}
case 'B': {
my_acm = acm_b_;
my_acm = acm_b_.get();
break;
}
default:

View File

@ -13,6 +13,7 @@
#include <math.h>
#include "webrtc/system_wrappers/interface/scoped_ptr.h"
#include "ACMTest.h"
#include "Channel.h"
#include "PCMFile.h"
@ -83,8 +84,8 @@ class TestStereo : public ACMTest {
int test_mode_;
AudioCodingModule* acm_a_;
AudioCodingModule* acm_b_;
scoped_ptr<AudioCodingModule> acm_a_;
scoped_ptr<AudioCodingModule> acm_b_;
TestPackStereo* channel_a2b_;

View File

@ -23,20 +23,12 @@
namespace webrtc {
TestVADDTX::TestVADDTX()
: _acmA(NULL),
_acmB(NULL),
: _acmA(AudioCodingModule::Create(0)),
_acmB(AudioCodingModule::Create(1)),
_channelA2B(NULL) {
}
TestVADDTX::~TestVADDTX() {
if (_acmA != NULL) {
AudioCodingModule::Destroy(_acmA);
_acmA = NULL;
}
if (_acmB != NULL) {
AudioCodingModule::Destroy(_acmB);
_acmB = NULL;
}
if (_channelA2B != NULL) {
delete _channelA2B;
_channelA2B = NULL;
@ -48,9 +40,6 @@ void TestVADDTX::Perform() {
"audio_coding/testfile32kHz", "pcm");
_inFileA.Open(file_name, 32000, "rb");
_acmA = AudioCodingModule::Create(0);
_acmB = AudioCodingModule::Create(1);
EXPECT_EQ(0, _acmA->InitializeReceiver());
EXPECT_EQ(0, _acmB->InitializeReceiver());
@ -68,7 +57,7 @@ void TestVADDTX::Perform() {
// Create and connect the channel
_channelA2B = new Channel;
_acmA->RegisterTransportCallback(_channelA2B);
_channelA2B->RegisterReceiverACM(_acmB);
_channelA2B->RegisterReceiverACM(_acmB.get());
_acmA->RegisterVADCallback(&_monitor);
@ -207,11 +196,11 @@ int16_t TestVADDTX::RegisterSendCodec(char side, char* codecName,
AudioCodingModule* myACM;
switch (side) {
case 'A': {
myACM = _acmA;
myACM = _acmA.get();
break;
}
case 'B': {
myACM = _acmB;
myACM = _acmB.get();
break;
}
default:

View File

@ -11,6 +11,7 @@
#ifndef TEST_VAD_DTX_H
#define TEST_VAD_DTX_H
#include "webrtc/system_wrappers/interface/scoped_ptr.h"
#include "ACMTest.h"
#include "Channel.h"
#include "PCMFile.h"
@ -64,8 +65,8 @@ class TestVADDTX : public ACMTest {
void SetVAD(bool statusDTX, bool statusVAD, int16_t vadMode);
VADDTXstruct GetVAD();
int16_t VerifyTest();
AudioCodingModule* _acmA;
AudioCodingModule* _acmB;
scoped_ptr<AudioCodingModule> _acmA;
scoped_ptr<AudioCodingModule> _acmB;
Channel* _channelA2B;

View File

@ -30,16 +30,15 @@ namespace webrtc {
#define MAX_FILE_NAME_LENGTH_BYTE 500
TwoWayCommunication::TwoWayCommunication(int testMode) {
_testMode = testMode;
TwoWayCommunication::TwoWayCommunication(int testMode)
: _acmA(AudioCodingModule::Create(1)),
_acmB(AudioCodingModule::Create(2)),
_acmRefA(AudioCodingModule::Create(3)),
_acmRefB(AudioCodingModule::Create(4)),
_testMode(testMode) {
}
TwoWayCommunication::~TwoWayCommunication() {
AudioCodingModule::Destroy(_acmA);
AudioCodingModule::Destroy(_acmB);
AudioCodingModule::Destroy(_acmRefA);
AudioCodingModule::Destroy(_acmRefB);
delete _channel_A2B;
delete _channel_B2A;
delete _channelRef_A2B;
@ -62,7 +61,7 @@ TwoWayCommunication::~TwoWayCommunication() {
void TwoWayCommunication::ChooseCodec(uint8_t* codecID_A,
uint8_t* codecID_B) {
AudioCodingModule* tmpACM = AudioCodingModule::Create(0);
scoped_ptr<AudioCodingModule> tmpACM(AudioCodingModule::Create(0));
uint8_t noCodec = tmpACM->NumberOfCodecs();
CodecInst codecInst;
printf("List of Supported Codecs\n");
@ -80,17 +79,10 @@ void TwoWayCommunication::ChooseCodec(uint8_t* codecID_A,
EXPECT_TRUE(fgets(myStr, 10, stdin) != NULL);
*codecID_B = (uint8_t) atoi(myStr);
AudioCodingModule::Destroy(tmpACM);
printf("\n");
}
void TwoWayCommunication::SetUp() {
_acmA = AudioCodingModule::Create(1);
_acmB = AudioCodingModule::Create(2);
_acmRefA = AudioCodingModule::Create(3);
_acmRefB = AudioCodingModule::Create(4);
uint8_t codecID_A;
uint8_t codecID_B;
@ -164,20 +156,20 @@ void TwoWayCommunication::SetUp() {
//--- Set A-to-B channel
_channel_A2B = new Channel;
_acmA->RegisterTransportCallback(_channel_A2B);
_channel_A2B->RegisterReceiverACM(_acmB);
_channel_A2B->RegisterReceiverACM(_acmB.get());
//--- Do the same for the reference
_channelRef_A2B = new Channel;
_acmRefA->RegisterTransportCallback(_channelRef_A2B);
_channelRef_A2B->RegisterReceiverACM(_acmRefB);
_channelRef_A2B->RegisterReceiverACM(_acmRefB.get());
//--- Set B-to-A channel
_channel_B2A = new Channel;
_acmB->RegisterTransportCallback(_channel_B2A);
_channel_B2A->RegisterReceiverACM(_acmA);
_channel_B2A->RegisterReceiverACM(_acmA.get());
//--- Do the same for reference
_channelRef_B2A = new Channel;
_acmRefB->RegisterTransportCallback(_channelRef_B2A);
_channelRef_B2A->RegisterReceiverACM(_acmRefA);
_channelRef_B2A->RegisterReceiverACM(_acmRefA.get());
// The clicks will be more obvious when we
// are in FAX mode.
@ -186,12 +178,6 @@ void TwoWayCommunication::SetUp() {
}
void TwoWayCommunication::SetUpAutotest() {
_acmA = AudioCodingModule::Create(1);
_acmB = AudioCodingModule::Create(2);
_acmRefA = AudioCodingModule::Create(3);
_acmRefB = AudioCodingModule::Create(4);
CodecInst codecInst_A;
CodecInst codecInst_B;
CodecInst dummyCodec;
@ -252,20 +238,20 @@ void TwoWayCommunication::SetUpAutotest() {
//--- Set A-to-B channel
_channel_A2B = new Channel;
_acmA->RegisterTransportCallback(_channel_A2B);
_channel_A2B->RegisterReceiverACM(_acmB);
_channel_A2B->RegisterReceiverACM(_acmB.get());
//--- Do the same for the reference
_channelRef_A2B = new Channel;
_acmRefA->RegisterTransportCallback(_channelRef_A2B);
_channelRef_A2B->RegisterReceiverACM(_acmRefB);
_channelRef_A2B->RegisterReceiverACM(_acmRefB.get());
//--- Set B-to-A channel
_channel_B2A = new Channel;
_acmB->RegisterTransportCallback(_channel_B2A);
_channel_B2A->RegisterReceiverACM(_acmA);
_channel_B2A->RegisterReceiverACM(_acmA.get());
//--- Do the same for reference
_channelRef_B2A = new Channel;
_acmRefB->RegisterTransportCallback(_channelRef_B2A);
_channelRef_B2A->RegisterReceiverACM(_acmRefA);
_channelRef_B2A->RegisterReceiverACM(_acmRefA.get());
// The clicks will be more obvious when we
// are in FAX mode.

View File

@ -11,6 +11,7 @@
#ifndef TWO_WAY_COMMUNICATION_H
#define TWO_WAY_COMMUNICATION_H
#include "webrtc/system_wrappers/interface/scoped_ptr.h"
#include "ACMTest.h"
#include "Channel.h"
#include "PCMFile.h"
@ -30,11 +31,11 @@ class TwoWayCommunication : public ACMTest {
void SetUp();
void SetUpAutotest();
AudioCodingModule* _acmA;
AudioCodingModule* _acmB;
scoped_ptr<AudioCodingModule> _acmA;
scoped_ptr<AudioCodingModule> _acmB;
AudioCodingModule* _acmRefA;
AudioCodingModule* _acmRefB;
scoped_ptr<AudioCodingModule> _acmRefA;
scoped_ptr<AudioCodingModule> _acmRefB;
Channel* _channel_A2B;
Channel* _channel_B2A;

View File

@ -61,8 +61,8 @@ class DelayTest {
public:
DelayTest()
: acm_a_(NULL),
acm_b_(NULL),
: acm_a_(AudioCodingModule::Create(0)),
acm_b_(AudioCodingModule::Create(1)),
channel_a2b_(NULL),
test_cntr_(0),
encoding_sample_rate_hz_(8000) {}
@ -70,14 +70,6 @@ class DelayTest {
~DelayTest() {}
void TearDown() {
if (acm_a_ != NULL) {
AudioCodingModule::Destroy(acm_a_);
acm_a_ = NULL;
}
if (acm_b_ != NULL) {
AudioCodingModule::Destroy(acm_b_);
acm_b_ = NULL;
}
if (channel_a2b_ != NULL) {
delete channel_a2b_;
channel_a2b_ = NULL;
@ -91,8 +83,6 @@ class DelayTest {
if (FLAGS_input_file.size() > 0)
file_name = FLAGS_input_file;
in_file_a_.Open(file_name, 32000, "rb");
acm_a_ = AudioCodingModule::Create(0);
acm_b_ = AudioCodingModule::Create(1);
acm_a_->InitializeReceiver();
acm_b_->InitializeReceiver();
if (FLAGS_init_delay > 0) {
@ -122,7 +112,7 @@ class DelayTest {
// Create and connect the channel
channel_a2b_ = new Channel;
acm_a_->RegisterTransportCallback(channel_a2b_);
channel_a2b_->RegisterReceiverACM(acm_b_);
channel_a2b_->RegisterReceiverACM(acm_b_.get());
}
void Perform(const Config* config, size_t num_tests, int duration_sec,
@ -229,8 +219,8 @@ class DelayTest {
out_file_b_.Close();
}
AudioCodingModule* acm_a_;
AudioCodingModule* acm_b_;
scoped_ptr<AudioCodingModule> acm_a_;
scoped_ptr<AudioCodingModule> acm_b_;
Channel* channel_a2b_;
@ -256,9 +246,3 @@ void RunTest() {
}
} // namespace
} // namespace webrtc
int main(int argc, char* argv[]) {
using namespace webrtc;
google::ParseCommandLineFlags(&argc, &argv, true);
RunTest();
}

View File

@ -53,9 +53,9 @@ class DualStreamTest :
kMaxNumStreams
};
AudioCodingModule* acm_dual_stream_;
AudioCodingModule* acm_ref_primary_;
AudioCodingModule* acm_ref_secondary_;
scoped_ptr<AudioCodingModule> acm_dual_stream_;
scoped_ptr<AudioCodingModule> acm_ref_primary_;
scoped_ptr<AudioCodingModule> acm_ref_secondary_;
CodecInst primary_encoder_;
CodecInst secondary_encoder_;
@ -98,9 +98,6 @@ DualStreamTest::DualStreamTest()
}
DualStreamTest::~DualStreamTest() {
AudioCodingModule::Destroy(acm_dual_stream_);
AudioCodingModule::Destroy(acm_ref_primary_);
AudioCodingModule::Destroy(acm_ref_secondary_);
}
void DualStreamTest::PopulateCodecInstances(int frame_size_primary_ms,
@ -138,9 +135,9 @@ void DualStreamTest::PopulateCodecInstances(int frame_size_primary_ms,
void DualStreamTest::InitializeSender(int frame_size_primary_samples,
int num_channels_primary,
int sampling_rate) {
ASSERT_TRUE(acm_dual_stream_ != NULL);
ASSERT_TRUE(acm_ref_primary_ != NULL);
ASSERT_TRUE(acm_ref_secondary_ != NULL);
ASSERT_TRUE(acm_dual_stream_.get() != NULL);
ASSERT_TRUE(acm_ref_primary_.get() != NULL);
ASSERT_TRUE(acm_ref_secondary_.get() != NULL);
ASSERT_EQ(0, acm_dual_stream_->InitializeSender());
ASSERT_EQ(0, acm_ref_primary_->InitializeSender());

View File

@ -21,7 +21,7 @@
#else
#include <sys/time.h>
#include <time.h>
#endif
#endif
#include "webrtc/modules/audio_coding/main/source/acm_common_defs.h"
#include "webrtc/modules/audio_coding/main/test/utility.h"
@ -86,14 +86,13 @@ int16_t SetISAConfig(ACMTestISACConfig& isacConfig, AudioCodingModule* acm,
return 0;
}
ISACTest::ISACTest(int testMode) {
_testMode = testMode;
ISACTest::ISACTest(int testMode)
: _acmA(AudioCodingModule::Create(1)),
_acmB(AudioCodingModule::Create(2)),
_testMode(testMode) {
}
ISACTest::~ISACTest() {
AudioCodingModule::Destroy(_acmA);
AudioCodingModule::Destroy(_acmB);
delete _channel_A2B;
delete _channel_B2A;
}
@ -102,9 +101,6 @@ void ISACTest::Setup() {
int codecCntr;
CodecInst codecParam;
_acmA = AudioCodingModule::Create(1);
_acmB = AudioCodingModule::Create(2);
for (codecCntr = 0; codecCntr < AudioCodingModule::NumberOfCodecs();
codecCntr++) {
EXPECT_EQ(0, AudioCodingModule::Codec(codecCntr, &codecParam));

View File

@ -46,8 +46,8 @@ class InitialPlayoutDelayTest : public ::testing::Test {
protected:
InitialPlayoutDelayTest()
: acm_a_(NULL),
acm_b_(NULL),
: acm_a_(AudioCodingModule::Create(0)),
acm_b_(AudioCodingModule::Create(1)),
channel_a2b_(NULL) {
}
@ -55,14 +55,6 @@ class InitialPlayoutDelayTest : public ::testing::Test {
}
void TearDown() {
if (acm_a_ != NULL) {
AudioCodingModule::Destroy(acm_a_);
acm_a_ = NULL;
}
if (acm_b_ != NULL) {
AudioCodingModule::Destroy(acm_b_);
acm_b_ = NULL;
}
if (channel_a2b_ != NULL) {
delete channel_a2b_;
channel_a2b_ = NULL;
@ -70,9 +62,6 @@ class InitialPlayoutDelayTest : public ::testing::Test {
}
void SetUp() {
acm_a_ = AudioCodingModule::Create(0);
acm_b_ = AudioCodingModule::Create(1);
acm_b_->InitializeReceiver();
acm_a_->InitializeReceiver();
@ -90,7 +79,7 @@ class InitialPlayoutDelayTest : public ::testing::Test {
// Create and connect the channel
channel_a2b_ = new Channel;
acm_a_->RegisterTransportCallback(channel_a2b_);
channel_a2b_->RegisterReceiverACM(acm_b_);
channel_a2b_->RegisterReceiverACM(acm_b_.get());
}
void Run(CodecInst codec, int initial_delay_ms) {
@ -125,8 +114,8 @@ class InitialPlayoutDelayTest : public ::testing::Test {
ASSERT_LE(num_frames * 10, initial_delay_ms + 100);
}
AudioCodingModule* acm_a_;
AudioCodingModule* acm_b_;
scoped_ptr<AudioCodingModule> acm_a_;
scoped_ptr<AudioCodingModule> acm_b_;
Channel* channel_a2b_;
};

View File

@ -18,6 +18,7 @@
#include "webrtc/modules/audio_coding/main/test/PCMFile.h"
#include "webrtc/modules/interface/module_common_types.h"
#include "webrtc/system_wrappers/interface/clock.h"
#include "webrtc/system_wrappers/interface/scoped_ptr.h"
#include "webrtc/test/testsupport/fileutils.h"
// Codec.
@ -75,8 +76,8 @@ class InsertPacketWithTiming {
ASSERT_TRUE(sender_clock_ != NULL);
ASSERT_TRUE(receiver_clock_ != NULL);
ASSERT_TRUE(send_acm_ != NULL);
ASSERT_TRUE(receive_acm_ != NULL);
ASSERT_TRUE(send_acm_.get() != NULL);
ASSERT_TRUE(receive_acm_.get() != NULL);
ASSERT_TRUE(channel_ != NULL);
ASSERT_TRUE(seq_num_fid_ != NULL);
@ -99,7 +100,7 @@ class InsertPacketWithTiming {
samples_in_1ms_ = codec.plfreq / 1000;
num_10ms_in_codec_frame_ = codec.pacsize / (codec.plfreq / 100);
channel_->RegisterReceiverACM(receive_acm_);
channel_->RegisterReceiverACM(receive_acm_.get());
send_acm_->RegisterTransportCallback(channel_);
if (FLAGS_input.size() == 0) {
@ -195,8 +196,6 @@ class InsertPacketWithTiming {
}
void TearDown() {
AudioCodingModule::Destroy(send_acm_);
AudioCodingModule::Destroy(receive_acm_);
delete channel_;
fclose(seq_num_fid_);
@ -250,8 +249,8 @@ class InsertPacketWithTiming {
SimulatedClock* sender_clock_;
SimulatedClock* receiver_clock_;
AudioCodingModule* send_acm_;
AudioCodingModule* receive_acm_;
scoped_ptr<AudioCodingModule> send_acm_;
scoped_ptr<AudioCodingModule> receive_acm_;
Channel* channel_;
FILE* seq_num_fid_; // Input (text), one sequence number per line.

View File

@ -29,7 +29,7 @@
namespace webrtc {
OpusTest::OpusTest()
: acm_receiver_(NULL),
: acm_receiver_(AudioCodingModule::Create(0)),
channel_a2b_(NULL),
counter_(0),
payload_type_(255),
@ -37,10 +37,6 @@ OpusTest::OpusTest()
}
OpusTest::~OpusTest() {
if (acm_receiver_ != NULL) {
AudioCodingModule::Destroy(acm_receiver_);
acm_receiver_ = NULL;
}
if (channel_a2b_ != NULL) {
delete channel_a2b_;
channel_a2b_ = NULL;
@ -93,9 +89,7 @@ void OpusTest::Perform() {
ASSERT_GT(WebRtcOpus_DecoderInitNew(opus_mono_decoder_), -1);
ASSERT_GT(WebRtcOpus_DecoderInitNew(opus_stereo_decoder_), -1);
// Create and initialize one ACM, to be used as receiver.
acm_receiver_ = AudioCodingModule::Create(0);
ASSERT_TRUE(acm_receiver_ != NULL);
ASSERT_TRUE(acm_receiver_.get() != NULL);
EXPECT_EQ(0, acm_receiver_->InitializeReceiver());
// Register Opus stereo as receiving codec.
@ -107,7 +101,7 @@ void OpusTest::Perform() {
// Create and connect the channel.
channel_a2b_ = new TestPackStereo;
channel_a2b_->RegisterReceiverACM(acm_receiver_);
channel_a2b_->RegisterReceiverACM(acm_receiver_.get());
//
// Test Stereo.

View File

@ -19,6 +19,7 @@
#include "webrtc/modules/audio_coding/main/test/Channel.h"
#include "webrtc/modules/audio_coding/main/test/PCMFile.h"
#include "webrtc/modules/audio_coding/main/test/TestStereo.h"
#include "webrtc/system_wrappers/interface/scoped_ptr.h"
namespace webrtc {
@ -34,7 +35,7 @@ class OpusTest : public ACMTest {
void OpenOutFile(int test_number);
AudioCodingModule* acm_receiver_;
scoped_ptr<AudioCodingModule> acm_receiver_;
TestPackStereo* channel_a2b_;
PCMFile in_file_stereo_;
PCMFile in_file_mono_;

View File

@ -12,6 +12,7 @@
#include "webrtc/common_types.h"
#include "webrtc/modules/audio_coding/main/interface/audio_coding_module.h"
#include "webrtc/modules/interface/module_common_types.h"
#include "webrtc/system_wrappers/interface/scoped_ptr.h"
#include "webrtc/system_wrappers/interface/sleep.h"
#include "webrtc/test/testsupport/fileutils.h"
#include "webrtc/test/testsupport/gtest_disable.h"
@ -32,11 +33,10 @@ class TargetDelayTest : public ::testing::Test {
: acm_(AudioCodingModule::Create(0)) {}
~TargetDelayTest() {
AudioCodingModule::Destroy(acm_);
}
void SetUp() {
EXPECT_TRUE(acm_ != NULL);
EXPECT_TRUE(acm_.get() != NULL);
CodecInst codec;
ASSERT_EQ(0, AudioCodingModule::Codec("L16", &codec, kSampleRateHz, 1));
@ -108,7 +108,7 @@ class TargetDelayTest : public ::testing::Test {
return acm_->LeastRequiredDelayMs();
}
AudioCodingModule* acm_;
scoped_ptr<AudioCodingModule> acm_;
WebRtcRTPHeader rtp_info_;
};

View File

@ -52,14 +52,6 @@ namespace webrtc {
} \
} while(0)
#define DESTROY_ACM(acm) \
do { \
if (acm != NULL) { \
AudioCodingModule::Destroy(acm); \
acm = NULL; \
} \
} while(0)
#define DELETE_POINTER(p) \
do { \
if (p != NULL) { \