Introduce a config struct for AudioCoding module
The config struct currently contains the module ID, and the NetEq config struct, but will be extended in the future. The purpose of this change is to expose certain NetEq settings to the ACM interface. BUG=3083 R=turaj@webrtc.org Review URL: https://webrtc-codereview.appspot.com/13379004 git-svn-id: http://webrtc.googlecode.com/svn/trunk@5993 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
parent
f043f79711
commit
e772c71743
@ -117,16 +117,15 @@ bool IsCng(int codec_id) {
|
||||
|
||||
} // namespace
|
||||
|
||||
AcmReceiver::AcmReceiver(Clock* clock)
|
||||
: id_(0),
|
||||
neteq_config_(),
|
||||
neteq_(NetEq::Create(neteq_config_)),
|
||||
AcmReceiver::AcmReceiver(const AudioCodingModule::Config& config, Clock* clock)
|
||||
: id_(config.id),
|
||||
neteq_(NetEq::Create(config.neteq_config)),
|
||||
last_audio_decoder_(-1), // Invalid value.
|
||||
decode_lock_(RWLockWrapper::CreateRWLock()),
|
||||
neteq_crit_sect_(CriticalSectionWrapper::CreateCriticalSection()),
|
||||
vad_enabled_(true),
|
||||
previous_audio_activity_(AudioFrame::kVadPassive),
|
||||
current_sample_rate_hz_(neteq_config_.sample_rate_hz),
|
||||
current_sample_rate_hz_(config.neteq_config.sample_rate_hz),
|
||||
nack_(),
|
||||
nack_enabled_(false),
|
||||
clock_(clock),
|
||||
@ -780,7 +779,6 @@ bool AcmReceiver::GetSilence(int desired_sample_rate_hz, AudioFrame* frame) {
|
||||
current_sample_rate_hz_ = ACMCodecDB::database_[last_audio_decoder_].plfreq;
|
||||
frame->num_channels_ = decoders_[last_audio_decoder_].channels;
|
||||
} else {
|
||||
current_sample_rate_hz_ = neteq_config_.sample_rate_hz;
|
||||
frame->num_channels_ = 1;
|
||||
}
|
||||
|
||||
|
@ -48,7 +48,7 @@ class AcmReceiver {
|
||||
};
|
||||
|
||||
// Constructor of the class
|
||||
explicit AcmReceiver(Clock* clock);
|
||||
explicit AcmReceiver(const AudioCodingModule::Config& config, Clock* clock);
|
||||
|
||||
// Destructor of the class.
|
||||
~AcmReceiver();
|
||||
@ -339,7 +339,6 @@ class AcmReceiver {
|
||||
void InsertStreamOfSyncPackets(InitialDelayManager::SyncStream* sync_stream);
|
||||
|
||||
int id_;
|
||||
NetEq::Config neteq_config_;
|
||||
NetEq* neteq_;
|
||||
Decoder decoders_[ACMCodecDB::kMaxNumCodecs];
|
||||
int last_audio_decoder_;
|
||||
|
@ -43,12 +43,14 @@ class AcmReceiverTest : public AudioPacketizationCallback,
|
||||
public ::testing::Test {
|
||||
protected:
|
||||
AcmReceiverTest()
|
||||
: receiver_(new AcmReceiver(Clock::GetRealTimeClock())),
|
||||
acm_(new AudioCodingModuleImpl(0, Clock::GetRealTimeClock())),
|
||||
timestamp_(0),
|
||||
: timestamp_(0),
|
||||
packet_sent_(false),
|
||||
last_packet_send_timestamp_(timestamp_),
|
||||
last_frame_type_(kFrameEmpty) {}
|
||||
last_frame_type_(kFrameEmpty) {
|
||||
AudioCodingModule::Config config;
|
||||
acm_.reset(new AudioCodingModuleImpl(config, Clock::GetRealTimeClock()));
|
||||
receiver_.reset(new AcmReceiver(config, Clock::GetRealTimeClock()));
|
||||
}
|
||||
|
||||
~AcmReceiverTest() {}
|
||||
|
||||
|
@ -24,11 +24,13 @@ const char kExperimentalAcmVersion[] = "acm2";
|
||||
|
||||
// Create module
|
||||
AudioCodingModule* AudioCodingModule::Create(int id) {
|
||||
return new acm2::AudioCodingModuleImpl(id, Clock::GetRealTimeClock());
|
||||
return Create(id, Clock::GetRealTimeClock());
|
||||
}
|
||||
|
||||
AudioCodingModule* AudioCodingModule::Create(int id, Clock* clock) {
|
||||
return new acm2::AudioCodingModuleImpl(id, clock);
|
||||
AudioCodingModule::Config config;
|
||||
config.id = id;
|
||||
return new acm2::AudioCodingModuleImpl(config, clock);
|
||||
}
|
||||
|
||||
// Get number of supported codecs
|
||||
@ -101,7 +103,9 @@ AudioCodingModule* AudioCodingModuleFactory::Create(int id) const {
|
||||
}
|
||||
|
||||
AudioCodingModule* NewAudioCodingModuleFactory::Create(int id) const {
|
||||
return new acm2::AudioCodingModuleImpl(id, Clock::GetRealTimeClock());
|
||||
AudioCodingModule::Config config;
|
||||
config.id = id;
|
||||
return new acm2::AudioCodingModuleImpl(config, Clock::GetRealTimeClock());
|
||||
}
|
||||
|
||||
} // namespace webrtc
|
||||
|
@ -114,9 +114,11 @@ static int TimestampLessThan(uint32_t t1, uint32_t t2) {
|
||||
|
||||
} // namespace
|
||||
|
||||
AudioCodingModuleImpl::AudioCodingModuleImpl(int id, Clock* clock)
|
||||
AudioCodingModuleImpl::AudioCodingModuleImpl(
|
||||
const AudioCodingModule::Config& config,
|
||||
Clock* clock)
|
||||
: packetization_callback_(NULL),
|
||||
id_(id),
|
||||
id_(config.id),
|
||||
expected_codec_ts_(0xD87F3F9F),
|
||||
expected_in_ts_(0xD87F3F9F),
|
||||
send_codec_inst_(),
|
||||
@ -131,7 +133,7 @@ AudioCodingModuleImpl::AudioCodingModuleImpl(int id, Clock* clock)
|
||||
stereo_send_(false),
|
||||
current_send_codec_idx_(-1),
|
||||
send_codec_registered_(false),
|
||||
receiver_(clock),
|
||||
receiver_(config, clock),
|
||||
acm_crit_sect_(CriticalSectionWrapper::CreateCriticalSection()),
|
||||
vad_callback_(NULL),
|
||||
is_first_red_(true),
|
||||
@ -160,8 +162,6 @@ AudioCodingModuleImpl::AudioCodingModuleImpl(int id, Clock* clock)
|
||||
mirror_codec_idx_[i] = -1;
|
||||
}
|
||||
|
||||
receiver_.set_id(id_);
|
||||
|
||||
// Allocate memory for RED.
|
||||
red_buffer_ = new uint8_t[MAX_PAYLOAD_SIZE_BYTE];
|
||||
|
||||
@ -202,7 +202,7 @@ AudioCodingModuleImpl::AudioCodingModuleImpl(int id, Clock* clock)
|
||||
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, id_,
|
||||
"Cannot initialize receiver");
|
||||
}
|
||||
WEBRTC_TRACE(webrtc::kTraceMemory, webrtc::kTraceAudioCoding, id, "Created");
|
||||
WEBRTC_TRACE(webrtc::kTraceMemory, webrtc::kTraceAudioCoding, id_, "Created");
|
||||
}
|
||||
|
||||
AudioCodingModuleImpl::~AudioCodingModuleImpl() {
|
||||
|
@ -33,7 +33,7 @@ class ACMGenericCodec;
|
||||
|
||||
class AudioCodingModuleImpl : public AudioCodingModule {
|
||||
public:
|
||||
AudioCodingModuleImpl(int id, Clock* clock);
|
||||
AudioCodingModuleImpl(const AudioCodingModule::Config& config, Clock* clock);
|
||||
~AudioCodingModuleImpl();
|
||||
|
||||
virtual const char* Version() const;
|
||||
|
@ -15,6 +15,7 @@
|
||||
|
||||
#include "webrtc/common_types.h"
|
||||
#include "webrtc/modules/audio_coding/main/interface/audio_coding_module_typedefs.h"
|
||||
#include "webrtc/modules/audio_coding/neteq4/interface/neteq.h"
|
||||
#include "webrtc/modules/interface/module.h"
|
||||
#include "webrtc/typedefs.h"
|
||||
|
||||
@ -82,6 +83,15 @@ class AudioCodingModule: public Module {
|
||||
AudioCodingModule() {}
|
||||
|
||||
public:
|
||||
struct Config {
|
||||
Config()
|
||||
: id(0),
|
||||
neteq_config() {}
|
||||
|
||||
int id;
|
||||
NetEq::Config neteq_config;
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// Creation and destruction of a ACM.
|
||||
//
|
||||
|
Loading…
x
Reference in New Issue
Block a user