Remove deprecated AudioCodingModule::Destroy.

Have Channel hold a pointer rather than reference, and shorten the name.

TESTED=trybots
R=turaj@webrtc.org

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

git-svn-id: http://webrtc.googlecode.com/svn/trunk@4820 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
andrew@webrtc.org
2013-09-23 23:02:24 +00:00
parent 1112c30e1e
commit eb524d997b
7 changed files with 78 additions and 110 deletions

View File

@ -49,7 +49,7 @@ class AcmReceiverTest : public AudioPacketizationCallback,
void SetUp() { void SetUp() {
ASSERT_TRUE(receiver_.get() != NULL); ASSERT_TRUE(receiver_.get() != NULL);
ASSERT_TRUE(acm_ != NULL); ASSERT_TRUE(acm_.get() != NULL);
for (int n = 0; n < ACMCodecDB::kNumCodecs; n++) { for (int n = 0; n < ACMCodecDB::kNumCodecs; n++) {
ASSERT_EQ(0, ACMCodecDB::Codec(n, &codecs_[n])); ASSERT_EQ(0, ACMCodecDB::Codec(n, &codecs_[n]));
} }
@ -69,7 +69,6 @@ class AcmReceiverTest : public AudioPacketizationCallback,
} }
void TearDown() { void TearDown() {
AudioCodingModule::Destroy(acm_);
} }
void InsertOnePacketOfSilence(int codec_id) { void InsertOnePacketOfSilence(int codec_id) {
@ -145,7 +144,7 @@ class AcmReceiverTest : public AudioPacketizationCallback,
scoped_ptr<AcmReceiver> receiver_; scoped_ptr<AcmReceiver> receiver_;
CodecInst codecs_[ACMCodecDB::kMaxNumCodecs]; CodecInst codecs_[ACMCodecDB::kMaxNumCodecs];
AudioCodingModule* acm_; scoped_ptr<AudioCodingModule> acm_;
WebRtcRTPHeader rtp_header_; WebRtcRTPHeader rtp_header_;
uint32_t timestamp_; uint32_t timestamp_;
bool packet_sent_; // Set when SendData is called reset when inserting audio. bool packet_sent_; // Set when SendData is called reset when inserting audio.

View File

@ -28,11 +28,6 @@ AudioCodingModule* AudioCodingModule::Create(int id, Clock* clock) {
return new acm1::AudioCodingModuleImpl(id, clock); return new acm1::AudioCodingModuleImpl(id, clock);
} }
// Destroy module
void AudioCodingModule::Destroy(AudioCodingModule* module) {
delete module;
}
// Get number of supported codecs // Get number of supported codecs
int AudioCodingModule::NumberOfCodecs() { int AudioCodingModule::NumberOfCodecs() {
return ACMCodecDB::kNumCodecs; return ACMCodecDB::kNumCodecs;

View File

@ -82,16 +82,13 @@ class AudioCodingModule: public Module {
// Creation and destruction of a ACM. // Creation and destruction of a ACM.
// //
// The second method is used for testing where a simulated clock can be // The second method is used for testing where a simulated clock can be
// injected into ACM. ACM will take the owner ship of the object clock and // injected into ACM. ACM will take the ownership of the object clock and
// delete it when destroyed. // delete it when destroyed.
// //
static AudioCodingModule* Create(int id); static AudioCodingModule* Create(int id);
static AudioCodingModule* Create(int id, Clock* clock); static AudioCodingModule* Create(int id, Clock* clock);
virtual ~AudioCodingModule() {}; virtual ~AudioCodingModule() {};
// TODO(ajm): Deprecated. Remove all calls to this unneeded method.
static void Destroy(AudioCodingModule* module);
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// Utility functions // Utility functions
// //

View File

@ -28,7 +28,6 @@ AudioCoder::AudioCoder(uint32_t instanceID)
AudioCoder::~AudioCoder() AudioCoder::~AudioCoder()
{ {
AudioCodingModule::Destroy(_acm);
} }
int32_t AudioCoder::SetEncodeCodec(const CodecInst& codecInst, int32_t AudioCoder::SetEncodeCodec(const CodecInst& codecInst,

View File

@ -13,6 +13,7 @@
#include "webrtc/common_types.h" #include "webrtc/common_types.h"
#include "webrtc/modules/audio_coding/main/interface/audio_coding_module.h" #include "webrtc/modules/audio_coding/main/interface/audio_coding_module.h"
#include "webrtc/system_wrappers/interface/scoped_ptr.h"
#include "webrtc/typedefs.h" #include "webrtc/typedefs.h"
namespace webrtc { namespace webrtc {
@ -49,7 +50,7 @@ protected:
const RTPFragmentationHeader* fragmentation); const RTPFragmentationHeader* fragmentation);
private: private:
AudioCodingModule* _acm; scoped_ptr<AudioCodingModule> _acm;
CodecInst _receiveCodec; CodecInst _receiveCodec;

View File

@ -469,11 +469,11 @@ Channel::OnInitializeDecoder(
receiveCodec.rate = rate; receiveCodec.rate = rate;
strncpy(receiveCodec.plname, payloadName, RTP_PAYLOAD_NAME_SIZE - 1); strncpy(receiveCodec.plname, payloadName, RTP_PAYLOAD_NAME_SIZE - 1);
_audioCodingModule.Codec(payloadName, &dummyCodec, frequency, channels); audio_coding_->Codec(payloadName, &dummyCodec, frequency, channels);
receiveCodec.pacsize = dummyCodec.pacsize; receiveCodec.pacsize = dummyCodec.pacsize;
// Register the new codec to the ACM // Register the new codec to the ACM
if (_audioCodingModule.RegisterReceiveCodec(receiveCodec) == -1) if (audio_coding_->RegisterReceiveCodec(receiveCodec) == -1)
{ {
WEBRTC_TRACE(kTraceWarning, kTraceVoice, WEBRTC_TRACE(kTraceWarning, kTraceVoice,
VoEId(_instanceId, _channelId), VoEId(_instanceId, _channelId),
@ -625,9 +625,9 @@ Channel::OnReceivedPayloadData(const uint8_t* payloadData,
} }
// Push the incoming payload (parsed and ready for decoding) into the ACM // Push the incoming payload (parsed and ready for decoding) into the ACM
if (_audioCodingModule.IncomingPacket(payloadData, if (audio_coding_->IncomingPacket(payloadData,
payloadSize, payloadSize,
*rtpHeader) != 0) *rtpHeader) != 0)
{ {
_engineStatisticsPtr->SetLastError( _engineStatisticsPtr->SetLastError(
VE_AUDIO_CODING_MODULE_ERROR, kTraceWarning, VE_AUDIO_CODING_MODULE_ERROR, kTraceWarning,
@ -643,7 +643,7 @@ Channel::OnReceivedPayloadData(const uint8_t* payloadData,
_rtpRtcpModule->RTT(rtp_receiver_->SSRC(), &round_trip_time, _rtpRtcpModule->RTT(rtp_receiver_->SSRC(), &round_trip_time,
NULL, NULL, NULL); NULL, NULL, NULL);
std::vector<uint16_t> nack_list = _audioCodingModule.GetNackList( std::vector<uint16_t> nack_list = audio_coding_->GetNackList(
round_trip_time); round_trip_time);
if (!nack_list.empty()) { if (!nack_list.empty()) {
// Can't use nack_list.data() since it's not supported by all // Can't use nack_list.data() since it's not supported by all
@ -674,8 +674,8 @@ int32_t Channel::GetAudioFrame(int32_t id, AudioFrame& audioFrame)
"Channel::GetAudioFrame(id=%d)", id); "Channel::GetAudioFrame(id=%d)", id);
// Get 10ms raw PCM data from the ACM (mixer limits output frequency) // Get 10ms raw PCM data from the ACM (mixer limits output frequency)
if (_audioCodingModule.PlayoutData10Ms(audioFrame.sample_rate_hz_, if (audio_coding_->PlayoutData10Ms(audioFrame.sample_rate_hz_,
&audioFrame) == -1) &audioFrame) == -1)
{ {
WEBRTC_TRACE(kTraceError, kTraceVoice, WEBRTC_TRACE(kTraceError, kTraceVoice,
VoEId(_instanceId,_channelId), VoEId(_instanceId,_channelId),
@ -782,12 +782,12 @@ Channel::NeededFrequency(int32_t id)
int highestNeeded = 0; int highestNeeded = 0;
// Determine highest needed receive frequency // Determine highest needed receive frequency
int32_t receiveFrequency = _audioCodingModule.ReceiveFrequency(); int32_t receiveFrequency = audio_coding_->ReceiveFrequency();
// Return the bigger of playout and receive frequency in the ACM. // Return the bigger of playout and receive frequency in the ACM.
if (_audioCodingModule.PlayoutFrequency() > receiveFrequency) if (audio_coding_->PlayoutFrequency() > receiveFrequency)
{ {
highestNeeded = _audioCodingModule.PlayoutFrequency(); highestNeeded = audio_coding_->PlayoutFrequency();
} }
else else
{ {
@ -917,7 +917,7 @@ Channel::Channel(int32_t channelId,
VoEModuleId(instanceId, channelId), Clock::GetRealTimeClock(), this, VoEModuleId(instanceId, channelId), Clock::GetRealTimeClock(), this,
this, this, rtp_payload_registry_.get())), this, this, rtp_payload_registry_.get())),
telephone_event_handler_(rtp_receiver_->GetTelephoneEventHandler()), telephone_event_handler_(rtp_receiver_->GetTelephoneEventHandler()),
_audioCodingModule(*config.Get<AudioCodingModuleFactory>().Create( audio_coding_(config.Get<AudioCodingModuleFactory>().Create(
VoEModuleId(instanceId, channelId))), VoEModuleId(instanceId, channelId))),
_rtpDumpIn(*RtpDump::CreateRtpDump()), _rtpDumpIn(*RtpDump::CreateRtpDump()),
_rtpDumpOut(*RtpDump::CreateRtpDump()), _rtpDumpOut(*RtpDump::CreateRtpDump()),
@ -1071,14 +1071,14 @@ Channel::~Channel()
// 1. De-register callbacks in modules // 1. De-register callbacks in modules
// 2. De-register modules in process thread // 2. De-register modules in process thread
// 3. Destroy modules // 3. Destroy modules
if (_audioCodingModule.RegisterTransportCallback(NULL) == -1) if (audio_coding_->RegisterTransportCallback(NULL) == -1)
{ {
WEBRTC_TRACE(kTraceWarning, kTraceVoice, WEBRTC_TRACE(kTraceWarning, kTraceVoice,
VoEId(_instanceId,_channelId), VoEId(_instanceId,_channelId),
"~Channel() failed to de-register transport callback" "~Channel() failed to de-register transport callback"
" (Audio coding module)"); " (Audio coding module)");
} }
if (_audioCodingModule.RegisterVADCallback(NULL) == -1) if (audio_coding_->RegisterVADCallback(NULL) == -1)
{ {
WEBRTC_TRACE(kTraceWarning, kTraceVoice, WEBRTC_TRACE(kTraceWarning, kTraceVoice,
VoEId(_instanceId,_channelId), VoEId(_instanceId,_channelId),
@ -1092,10 +1092,6 @@ Channel::~Channel()
VoEId(_instanceId,_channelId), VoEId(_instanceId,_channelId),
"~Channel() failed to deregister RTP/RTCP module"); "~Channel() failed to deregister RTP/RTCP module");
} }
// Destroy modules
AudioCodingModule::Destroy(&_audioCodingModule);
// End of modules shutdown // End of modules shutdown
// Delete other objects // Delete other objects
@ -1140,12 +1136,12 @@ Channel::Init()
} }
// --- ACM initialization // --- ACM initialization
if ((_audioCodingModule.InitializeReceiver() == -1) || if ((audio_coding_->InitializeReceiver() == -1) ||
#ifdef WEBRTC_CODEC_AVT #ifdef WEBRTC_CODEC_AVT
// out-of-band Dtmf tones are played out by default // out-of-band Dtmf tones are played out by default
(_audioCodingModule.SetDtmfPlayoutStatus(true) == -1) || (audio_coding_->SetDtmfPlayoutStatus(true) == -1) ||
#endif #endif
(_audioCodingModule.InitializeSender() == -1)) (audio_coding_->InitializeSender() == -1))
{ {
_engineStatisticsPtr->SetLastError( _engineStatisticsPtr->SetLastError(
VE_AUDIO_CODING_MODULE_ERROR, kTraceError, VE_AUDIO_CODING_MODULE_ERROR, kTraceError,
@ -1172,8 +1168,8 @@ Channel::Init()
// --- Register all permanent callbacks // --- Register all permanent callbacks
const bool fail = const bool fail =
(_audioCodingModule.RegisterTransportCallback(this) == -1) || (audio_coding_->RegisterTransportCallback(this) == -1) ||
(_audioCodingModule.RegisterVADCallback(this) == -1); (audio_coding_->RegisterVADCallback(this) == -1);
if (fail) if (fail)
{ {
@ -1192,7 +1188,7 @@ Channel::Init()
for (int idx = 0; idx < nSupportedCodecs; idx++) for (int idx = 0; idx < nSupportedCodecs; idx++)
{ {
// Open up the RTP/RTCP receiver for all supported codecs // Open up the RTP/RTCP receiver for all supported codecs
if ((_audioCodingModule.Codec(idx, &codec) == -1) || if ((audio_coding_->Codec(idx, &codec) == -1) ||
(rtp_receiver_->RegisterReceivePayload( (rtp_receiver_->RegisterReceivePayload(
codec.plname, codec.plname,
codec.pltype, codec.pltype,
@ -1227,7 +1223,7 @@ Channel::Init()
if (!STR_CASE_CMP(codec.plname, "telephone-event")) if (!STR_CASE_CMP(codec.plname, "telephone-event"))
{ {
if ((_rtpRtcpModule->RegisterSendPayload(codec) == -1) || if ((_rtpRtcpModule->RegisterSendPayload(codec) == -1) ||
(_audioCodingModule.RegisterReceiveCodec(codec) == -1)) (audio_coding_->RegisterReceiveCodec(codec) == -1))
{ {
WEBRTC_TRACE(kTraceWarning, kTraceVoice, WEBRTC_TRACE(kTraceWarning, kTraceVoice,
VoEId(_instanceId,_channelId), VoEId(_instanceId,_channelId),
@ -1239,8 +1235,8 @@ Channel::Init()
if (!STR_CASE_CMP(codec.plname, "CN")) if (!STR_CASE_CMP(codec.plname, "CN"))
{ {
if ((_audioCodingModule.RegisterSendCodec(codec) == -1) || if ((audio_coding_->RegisterSendCodec(codec) == -1) ||
(_audioCodingModule.RegisterReceiveCodec(codec) == -1) || (audio_coding_->RegisterReceiveCodec(codec) == -1) ||
(_rtpRtcpModule->RegisterSendPayload(codec) == -1)) (_rtpRtcpModule->RegisterSendPayload(codec) == -1))
{ {
WEBRTC_TRACE(kTraceWarning, kTraceVoice, WEBRTC_TRACE(kTraceWarning, kTraceVoice,
@ -1255,7 +1251,7 @@ Channel::Init()
// We will not receive an OnInitializeDecoder() callback for RED. // We will not receive an OnInitializeDecoder() callback for RED.
if (!STR_CASE_CMP(codec.plname, "RED")) if (!STR_CASE_CMP(codec.plname, "RED"))
{ {
if (_audioCodingModule.RegisterReceiveCodec(codec) == -1) if (audio_coding_->RegisterReceiveCodec(codec) == -1)
{ {
WEBRTC_TRACE(kTraceWarning, kTraceVoice, WEBRTC_TRACE(kTraceWarning, kTraceVoice,
VoEId(_instanceId,_channelId), VoEId(_instanceId,_channelId),
@ -1537,7 +1533,7 @@ Channel::SetNetEQPlayoutMode(NetEqModes mode)
playoutMode = off; playoutMode = off;
break; break;
} }
if (_audioCodingModule.SetPlayoutMode(playoutMode) != 0) if (audio_coding_->SetPlayoutMode(playoutMode) != 0)
{ {
_engineStatisticsPtr->SetLastError( _engineStatisticsPtr->SetLastError(
VE_AUDIO_CODING_MODULE_ERROR, kTraceError, VE_AUDIO_CODING_MODULE_ERROR, kTraceError,
@ -1550,7 +1546,7 @@ Channel::SetNetEQPlayoutMode(NetEqModes mode)
int32_t int32_t
Channel::GetNetEQPlayoutMode(NetEqModes& mode) Channel::GetNetEQPlayoutMode(NetEqModes& mode)
{ {
const AudioPlayoutMode playoutMode = _audioCodingModule.PlayoutMode(); const AudioPlayoutMode playoutMode = audio_coding_->PlayoutMode();
switch (playoutMode) switch (playoutMode)
{ {
case voice: case voice:
@ -1655,13 +1651,13 @@ Channel::DeRegisterVoiceEngineObserver()
int32_t int32_t
Channel::GetSendCodec(CodecInst& codec) Channel::GetSendCodec(CodecInst& codec)
{ {
return (_audioCodingModule.SendCodec(&codec)); return (audio_coding_->SendCodec(&codec));
} }
int32_t int32_t
Channel::GetRecCodec(CodecInst& codec) Channel::GetRecCodec(CodecInst& codec)
{ {
return (_audioCodingModule.ReceiveCodec(&codec)); return (audio_coding_->ReceiveCodec(&codec));
} }
int32_t int32_t
@ -1670,7 +1666,7 @@ Channel::SetSendCodec(const CodecInst& codec)
WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId,_channelId), WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId,_channelId),
"Channel::SetSendCodec()"); "Channel::SetSendCodec()");
if (_audioCodingModule.RegisterSendCodec(codec) != 0) if (audio_coding_->RegisterSendCodec(codec) != 0)
{ {
WEBRTC_TRACE(kTraceError, kTraceVoice, VoEId(_instanceId,_channelId), WEBRTC_TRACE(kTraceError, kTraceVoice, VoEId(_instanceId,_channelId),
"SetSendCodec() failed to register codec to ACM"); "SetSendCodec() failed to register codec to ACM");
@ -1707,7 +1703,7 @@ Channel::SetVADStatus(bool enableVAD, ACMVADMode mode, bool disableDTX)
"Channel::SetVADStatus(mode=%d)", mode); "Channel::SetVADStatus(mode=%d)", mode);
// To disable VAD, DTX must be disabled too // To disable VAD, DTX must be disabled too
disableDTX = ((enableVAD == false) ? true : disableDTX); disableDTX = ((enableVAD == false) ? true : disableDTX);
if (_audioCodingModule.SetVAD(!disableDTX, enableVAD, mode) != 0) if (audio_coding_->SetVAD(!disableDTX, enableVAD, mode) != 0)
{ {
_engineStatisticsPtr->SetLastError( _engineStatisticsPtr->SetLastError(
VE_AUDIO_CODING_MODULE_ERROR, kTraceError, VE_AUDIO_CODING_MODULE_ERROR, kTraceError,
@ -1722,7 +1718,7 @@ Channel::GetVADStatus(bool& enabledVAD, ACMVADMode& mode, bool& disabledDTX)
{ {
WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId,_channelId), WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId,_channelId),
"Channel::GetVADStatus"); "Channel::GetVADStatus");
if (_audioCodingModule.VAD(&disabledDTX, &enabledVAD, &mode) != 0) if (audio_coding_->VAD(&disabledDTX, &enabledVAD, &mode) != 0)
{ {
_engineStatisticsPtr->SetLastError( _engineStatisticsPtr->SetLastError(
VE_AUDIO_CODING_MODULE_ERROR, kTraceError, VE_AUDIO_CODING_MODULE_ERROR, kTraceError,
@ -1779,7 +1775,7 @@ Channel::SetRecPayloadType(const CodecInst& codec)
"failed"); "failed");
return -1; return -1;
} }
if (_audioCodingModule.UnregisterReceiveCodec(rxCodec.pltype) != 0) if (audio_coding_->UnregisterReceiveCodec(rxCodec.pltype) != 0)
{ {
_engineStatisticsPtr->SetLastError( _engineStatisticsPtr->SetLastError(
VE_AUDIO_CODING_MODULE_ERROR, kTraceError, VE_AUDIO_CODING_MODULE_ERROR, kTraceError,
@ -1811,10 +1807,10 @@ Channel::SetRecPayloadType(const CodecInst& codec)
return -1; return -1;
} }
} }
if (_audioCodingModule.RegisterReceiveCodec(codec) != 0) if (audio_coding_->RegisterReceiveCodec(codec) != 0)
{ {
_audioCodingModule.UnregisterReceiveCodec(codec.pltype); audio_coding_->UnregisterReceiveCodec(codec.pltype);
if (_audioCodingModule.RegisterReceiveCodec(codec) != 0) if (audio_coding_->RegisterReceiveCodec(codec) != 0)
{ {
_engineStatisticsPtr->SetLastError( _engineStatisticsPtr->SetLastError(
VE_AUDIO_CODING_MODULE_ERROR, kTraceError, VE_AUDIO_CODING_MODULE_ERROR, kTraceError,
@ -1904,7 +1900,7 @@ Channel::SetSendCNPayloadType(int type, PayloadFrequencies frequency)
else if (frequency == kFreq16000Hz) else if (frequency == kFreq16000Hz)
samplingFreqHz = 16000; samplingFreqHz = 16000;
if (_audioCodingModule.Codec("CN", &codec, samplingFreqHz, kMono) == -1) if (audio_coding_->Codec("CN", &codec, samplingFreqHz, kMono) == -1)
{ {
_engineStatisticsPtr->SetLastError( _engineStatisticsPtr->SetLastError(
VE_AUDIO_CODING_MODULE_ERROR, kTraceError, VE_AUDIO_CODING_MODULE_ERROR, kTraceError,
@ -1916,7 +1912,7 @@ Channel::SetSendCNPayloadType(int type, PayloadFrequencies frequency)
// Modify the payload type (must be set to dynamic range) // Modify the payload type (must be set to dynamic range)
codec.pltype = type; codec.pltype = type;
if (_audioCodingModule.RegisterSendCodec(codec) != 0) if (audio_coding_->RegisterSendCodec(codec) != 0)
{ {
_engineStatisticsPtr->SetLastError( _engineStatisticsPtr->SetLastError(
VE_AUDIO_CODING_MODULE_ERROR, kTraceError, VE_AUDIO_CODING_MODULE_ERROR, kTraceError,
@ -1946,7 +1942,7 @@ Channel::SetISACInitTargetRate(int rateBps, bool useFixedFrameSize)
"Channel::SetISACInitTargetRate()"); "Channel::SetISACInitTargetRate()");
CodecInst sendCodec; CodecInst sendCodec;
if (_audioCodingModule.SendCodec(&sendCodec) == -1) if (audio_coding_->SendCodec(&sendCodec) == -1)
{ {
_engineStatisticsPtr->SetLastError( _engineStatisticsPtr->SetLastError(
VE_CODEC_ERROR, kTraceError, VE_CODEC_ERROR, kTraceError,
@ -1995,7 +1991,7 @@ Channel::SetISACInitTargetRate(int rateBps, bool useFixedFrameSize)
initFrameSizeMsec = (uint8_t)(sendCodec.pacsize / 32); // 30ms initFrameSizeMsec = (uint8_t)(sendCodec.pacsize / 32); // 30ms
} }
if (_audioCodingModule.ConfigISACBandwidthEstimator( if (audio_coding_->ConfigISACBandwidthEstimator(
initFrameSizeMsec, rateBps, useFixedFrameSize) == -1) initFrameSizeMsec, rateBps, useFixedFrameSize) == -1)
{ {
_engineStatisticsPtr->SetLastError( _engineStatisticsPtr->SetLastError(
@ -2014,7 +2010,7 @@ Channel::SetISACMaxRate(int rateBps)
"Channel::SetISACMaxRate()"); "Channel::SetISACMaxRate()");
CodecInst sendCodec; CodecInst sendCodec;
if (_audioCodingModule.SendCodec(&sendCodec) == -1) if (audio_coding_->SendCodec(&sendCodec) == -1)
{ {
_engineStatisticsPtr->SetLastError( _engineStatisticsPtr->SetLastError(
VE_CODEC_ERROR, kTraceError, VE_CODEC_ERROR, kTraceError,
@ -2061,7 +2057,7 @@ Channel::SetISACMaxRate(int rateBps)
// Set the maximum instantaneous rate of iSAC (works for both adaptive // Set the maximum instantaneous rate of iSAC (works for both adaptive
// and non-adaptive mode) // and non-adaptive mode)
if (_audioCodingModule.SetISACMaxRate(rateBps) == -1) if (audio_coding_->SetISACMaxRate(rateBps) == -1)
{ {
_engineStatisticsPtr->SetLastError( _engineStatisticsPtr->SetLastError(
VE_AUDIO_CODING_MODULE_ERROR, kTraceError, VE_AUDIO_CODING_MODULE_ERROR, kTraceError,
@ -2078,7 +2074,7 @@ Channel::SetISACMaxPayloadSize(int sizeBytes)
WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId,_channelId), WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId,_channelId),
"Channel::SetISACMaxPayloadSize()"); "Channel::SetISACMaxPayloadSize()");
CodecInst sendCodec; CodecInst sendCodec;
if (_audioCodingModule.SendCodec(&sendCodec) == -1) if (audio_coding_->SendCodec(&sendCodec) == -1)
{ {
_engineStatisticsPtr->SetLastError( _engineStatisticsPtr->SetLastError(
VE_CODEC_ERROR, kTraceError, VE_CODEC_ERROR, kTraceError,
@ -2122,7 +2118,7 @@ Channel::SetISACMaxPayloadSize(int sizeBytes)
return -1; return -1;
} }
if (_audioCodingModule.SetISACMaxPayloadSize(sizeBytes) == -1) if (audio_coding_->SetISACMaxPayloadSize(sizeBytes) == -1)
{ {
_engineStatisticsPtr->SetLastError( _engineStatisticsPtr->SetLastError(
VE_AUDIO_CODING_MODULE_ERROR, kTraceError, VE_AUDIO_CODING_MODULE_ERROR, kTraceError,
@ -3151,7 +3147,7 @@ Channel::SetDtmfPlayoutStatus(bool enable)
{ {
WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId,_channelId), WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId,_channelId),
"Channel::SetDtmfPlayoutStatus()"); "Channel::SetDtmfPlayoutStatus()");
if (_audioCodingModule.SetDtmfPlayoutStatus(enable) != 0) if (audio_coding_->SetDtmfPlayoutStatus(enable) != 0)
{ {
_engineStatisticsPtr->SetLastError( _engineStatisticsPtr->SetLastError(
VE_AUDIO_CODING_MODULE_ERROR, kTraceWarning, VE_AUDIO_CODING_MODULE_ERROR, kTraceWarning,
@ -3164,7 +3160,7 @@ Channel::SetDtmfPlayoutStatus(bool enable)
bool bool
Channel::DtmfPlayoutStatus() const Channel::DtmfPlayoutStatus() const
{ {
return _audioCodingModule.DtmfPlayoutStatus(); return audio_coding_->DtmfPlayoutStatus();
} }
int int
@ -3962,8 +3958,7 @@ Channel::GetRTPStatistics(
"RTP/RTCP module"); "RTP/RTCP module");
} }
const int32_t playoutFrequency = const int32_t playoutFrequency = audio_coding_->PlayoutFrequency();
_audioCodingModule.PlayoutFrequency();
if (playoutFrequency > 0) if (playoutFrequency > 0)
{ {
// Scale RTP statistics given the current playout frequency // Scale RTP statistics given the current playout frequency
@ -4169,7 +4164,7 @@ int Channel::SetFECStatus(bool enable, int redPayloadtype) {
} }
} }
if (_audioCodingModule.SetFECStatus(enable) != 0) { if (audio_coding_->SetFECStatus(enable) != 0) {
_engineStatisticsPtr->SetLastError( _engineStatisticsPtr->SetLastError(
VE_AUDIO_CODING_MODULE_ERROR, kTraceError, VE_AUDIO_CODING_MODULE_ERROR, kTraceError,
"SetFECStatus() failed to set FEC state in the ACM"); "SetFECStatus() failed to set FEC state in the ACM");
@ -4181,7 +4176,7 @@ int Channel::SetFECStatus(bool enable, int redPayloadtype) {
int int
Channel::GetFECStatus(bool& enabled, int& redPayloadtype) Channel::GetFECStatus(bool& enabled, int& redPayloadtype)
{ {
enabled = _audioCodingModule.FECStatus(); enabled = audio_coding_->FECStatus();
if (enabled) if (enabled)
{ {
int8_t payloadType(0); int8_t payloadType(0);
@ -4211,9 +4206,9 @@ void Channel::SetNACKStatus(bool enable, int maxNumberOfPackets) {
rtp_receive_statistics_->SetMaxReorderingThreshold(maxNumberOfPackets); rtp_receive_statistics_->SetMaxReorderingThreshold(maxNumberOfPackets);
rtp_receiver_->SetNACKStatus(enable ? kNackRtcp : kNackOff); rtp_receiver_->SetNACKStatus(enable ? kNackRtcp : kNackOff);
if (enable) if (enable)
_audioCodingModule.EnableNack(maxNumberOfPackets); audio_coding_->EnableNack(maxNumberOfPackets);
else else
_audioCodingModule.DisableNack(); audio_coding_->DisableNack();
} }
// Called when we are missing one or more packets. // Called when we are missing one or more packets.
@ -4525,7 +4520,7 @@ Channel::EncodeAndSend()
// The ACM resamples internally. // The ACM resamples internally.
_audioFrame.timestamp_ = _timeStamp; _audioFrame.timestamp_ = _timeStamp;
if (_audioCodingModule.Add10MsData((AudioFrame&)_audioFrame) != 0) if (audio_coding_->Add10MsData((AudioFrame&)_audioFrame) != 0)
{ {
WEBRTC_TRACE(kTraceError, kTraceVoice, VoEId(_instanceId,_channelId), WEBRTC_TRACE(kTraceError, kTraceVoice, VoEId(_instanceId,_channelId),
"Channel::EncodeAndSend() ACM encoding failed"); "Channel::EncodeAndSend() ACM encoding failed");
@ -4538,7 +4533,7 @@ Channel::EncodeAndSend()
// This call will trigger AudioPacketizationCallback::SendData if encoding // This call will trigger AudioPacketizationCallback::SendData if encoding
// is done and payload is ready for packetization and transmission. // is done and payload is ready for packetization and transmission.
return _audioCodingModule.Process(); return audio_coding_->Process();
} }
int Channel::RegisterExternalMediaProcessing( int Channel::RegisterExternalMediaProcessing(
@ -4702,7 +4697,7 @@ Channel::GetNetworkStatistics(NetworkStatistics& stats)
WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId,_channelId), WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId,_channelId),
"Channel::GetNetworkStatistics()"); "Channel::GetNetworkStatistics()");
ACMNetworkStatistics acm_stats; ACMNetworkStatistics acm_stats;
int return_value = _audioCodingModule.NetworkStatistics(&acm_stats); int return_value = audio_coding_->NetworkStatistics(&acm_stats);
if (return_value >= 0) { if (return_value >= 0) {
memcpy(&stats, &acm_stats, sizeof(NetworkStatistics)); memcpy(&stats, &acm_stats, sizeof(NetworkStatistics));
} }
@ -4736,7 +4731,7 @@ int Channel::SetInitialPlayoutDelay(int delay_ms)
"SetInitialPlayoutDelay() invalid min delay"); "SetInitialPlayoutDelay() invalid min delay");
return -1; return -1;
} }
if (_audioCodingModule.SetInitialPlayoutDelay(delay_ms) != 0) if (audio_coding_->SetInitialPlayoutDelay(delay_ms) != 0)
{ {
_engineStatisticsPtr->SetLastError( _engineStatisticsPtr->SetLastError(
VE_AUDIO_CODING_MODULE_ERROR, kTraceError, VE_AUDIO_CODING_MODULE_ERROR, kTraceError,
@ -4760,7 +4755,7 @@ Channel::SetMinimumPlayoutDelay(int delayMs)
"SetMinimumPlayoutDelay() invalid min delay"); "SetMinimumPlayoutDelay() invalid min delay");
return -1; return -1;
} }
if (_audioCodingModule.SetMinimumPlayoutDelay(delayMs) != 0) if (audio_coding_->SetMinimumPlayoutDelay(delayMs) != 0)
{ {
_engineStatisticsPtr->SetLastError( _engineStatisticsPtr->SetLastError(
VE_AUDIO_CODING_MODULE_ERROR, kTraceError, VE_AUDIO_CODING_MODULE_ERROR, kTraceError,
@ -4773,7 +4768,7 @@ Channel::SetMinimumPlayoutDelay(int delayMs)
void Channel::UpdatePlayoutTimestamp(bool rtcp) { void Channel::UpdatePlayoutTimestamp(bool rtcp) {
uint32_t playout_timestamp = 0; uint32_t playout_timestamp = 0;
if (_audioCodingModule.PlayoutTimestamp(&playout_timestamp) == -1) { if (audio_coding_->PlayoutTimestamp(&playout_timestamp) == -1) {
WEBRTC_TRACE(kTraceWarning, kTraceVoice, VoEId(_instanceId,_channelId), WEBRTC_TRACE(kTraceWarning, kTraceVoice, VoEId(_instanceId,_channelId),
"Channel::UpdatePlayoutTimestamp() failed to read playout" "Channel::UpdatePlayoutTimestamp() failed to read playout"
" timestamp from the ACM"); " timestamp from the ACM");
@ -4794,9 +4789,9 @@ void Channel::UpdatePlayoutTimestamp(bool rtcp) {
return; return;
} }
int32_t playout_frequency = _audioCodingModule.PlayoutFrequency(); int32_t playout_frequency = audio_coding_->PlayoutFrequency();
CodecInst current_recive_codec; CodecInst current_recive_codec;
if (_audioCodingModule.ReceiveCodec(&current_recive_codec) == 0) { if (audio_coding_->ReceiveCodec(&current_recive_codec) == 0) {
if (STR_CASE_CMP("G722", current_recive_codec.plname) == 0) { if (STR_CASE_CMP("G722", current_recive_codec.plname) == 0) {
playout_frequency = 8000; playout_frequency = 8000;
} else if (STR_CASE_CMP("opus", current_recive_codec.plname) == 0) { } else if (STR_CASE_CMP("opus", current_recive_codec.plname) == 0) {
@ -5132,15 +5127,15 @@ void Channel::UpdatePacketDelay(uint32_t rtp_timestamp,
rtp_timestamp, sequence_number); rtp_timestamp, sequence_number);
// Get frequency of last received payload // Get frequency of last received payload
int rtp_receive_frequency = _audioCodingModule.ReceiveFrequency(); int rtp_receive_frequency = audio_coding_->ReceiveFrequency();
CodecInst current_receive_codec; CodecInst current_receive_codec;
if (_audioCodingModule.ReceiveCodec(&current_receive_codec) != 0) { if (audio_coding_->ReceiveCodec(&current_receive_codec) != 0) {
return; return;
} }
// Update the least required delay. // Update the least required delay.
least_required_delay_ms_ = _audioCodingModule.LeastRequiredDelayMs(); least_required_delay_ms_ = audio_coding_->LeastRequiredDelayMs();
if (STR_CASE_CMP("G722", current_receive_codec.plname) == 0) { if (STR_CASE_CMP("G722", current_receive_codec.plname) == 0) {
// Even though the actual sampling rate for G.722 audio is // Even though the actual sampling rate for G.722 audio is
@ -5202,7 +5197,7 @@ Channel::RegisterReceiveCodecsToRTPModule()
for (int idx = 0; idx < nSupportedCodecs; idx++) for (int idx = 0; idx < nSupportedCodecs; idx++)
{ {
// Open up the RTP/RTCP receiver for all supported codecs // Open up the RTP/RTCP receiver for all supported codecs
if ((_audioCodingModule.Codec(idx, &codec) == -1) || if ((audio_coding_->Codec(idx, &codec) == -1) ||
(rtp_receiver_->RegisterReceivePayload( (rtp_receiver_->RegisterReceivePayload(
codec.plname, codec.plname,
codec.pltype, codec.pltype,
@ -5265,7 +5260,7 @@ int Channel::SetSecondarySendCodec(const CodecInst& codec,
"SetSecondarySendCodec() Failed to register RED ACM"); "SetSecondarySendCodec() Failed to register RED ACM");
return -1; return -1;
} }
if (_audioCodingModule.RegisterSecondarySendCodec(codec) < 0) { if (audio_coding_->RegisterSecondarySendCodec(codec) < 0) {
_engineStatisticsPtr->SetLastError( _engineStatisticsPtr->SetLastError(
VE_AUDIO_CODING_MODULE_ERROR, kTraceError, VE_AUDIO_CODING_MODULE_ERROR, kTraceError,
"SetSecondarySendCodec() Failed to register secondary send codec in " "SetSecondarySendCodec() Failed to register secondary send codec in "
@ -5277,11 +5272,11 @@ int Channel::SetSecondarySendCodec(const CodecInst& codec,
} }
void Channel::RemoveSecondarySendCodec() { void Channel::RemoveSecondarySendCodec() {
_audioCodingModule.UnregisterSecondarySendCodec(); audio_coding_->UnregisterSecondarySendCodec();
} }
int Channel::GetSecondarySendCodec(CodecInst* codec) { int Channel::GetSecondarySendCodec(CodecInst* codec) {
if (_audioCodingModule.SecondarySendCodec(codec) < 0) { if (audio_coding_->SecondarySendCodec(codec) < 0) {
_engineStatisticsPtr->SetLastError( _engineStatisticsPtr->SetLastError(
VE_AUDIO_CODING_MODULE_ERROR, kTraceError, VE_AUDIO_CODING_MODULE_ERROR, kTraceError,
"GetSecondarySendCodec() Failed to get secondary sent codec from ACM"); "GetSecondarySendCodec() Failed to get secondary sent codec from ACM");
@ -5298,7 +5293,7 @@ int Channel::SetRedPayloadType(int red_payload_type) {
// Get default RED settings from the ACM database // Get default RED settings from the ACM database
const int num_codecs = AudioCodingModule::NumberOfCodecs(); const int num_codecs = AudioCodingModule::NumberOfCodecs();
for (int idx = 0; idx < num_codecs; idx++) { for (int idx = 0; idx < num_codecs; idx++) {
_audioCodingModule.Codec(idx, &codec); audio_coding_->Codec(idx, &codec);
if (!STR_CASE_CMP(codec.plname, "RED")) { if (!STR_CASE_CMP(codec.plname, "RED")) {
found_red = true; found_red = true;
break; break;
@ -5313,7 +5308,7 @@ int Channel::SetRedPayloadType(int red_payload_type) {
} }
codec.pltype = red_payload_type; codec.pltype = red_payload_type;
if (_audioCodingModule.RegisterSendCodec(codec) < 0) { if (audio_coding_->RegisterSendCodec(codec) < 0) {
_engineStatisticsPtr->SetLastError( _engineStatisticsPtr->SetLastError(
VE_AUDIO_CODING_MODULE_ERROR, kTraceError, VE_AUDIO_CODING_MODULE_ERROR, kTraceError,
"SetRedPayloadType() RED registration in ACM module failed"); "SetRedPayloadType() RED registration in ACM module failed");

View File

@ -33,8 +33,8 @@
#include "webrtc/voice_engine/include/voe_dtmf.h" #include "webrtc/voice_engine/include/voe_dtmf.h"
#endif #endif
namespace webrtc namespace webrtc {
{
class AudioDeviceModule; class AudioDeviceModule;
class Config; class Config;
class CriticalSectionWrapper; class CriticalSectionWrapper;
@ -56,8 +56,8 @@ struct CallStatistics;
struct ReportBlock; struct ReportBlock;
struct SenderInfo; struct SenderInfo;
namespace voe namespace voe {
{
class Statistics; class Statistics;
class TransmitMixer; class TransmitMixer;
class OutputMixer; class OutputMixer;
@ -77,7 +77,6 @@ class Channel:
public: public:
enum {KNumSocketThreads = 1}; enum {KNumSocketThreads = 1};
enum {KNumberOfSocketBuffers = 8}; enum {KNumberOfSocketBuffers = 8};
public:
virtual ~Channel(); virtual ~Channel();
static int32_t CreateChannel(Channel*& channel, static int32_t CreateChannel(Channel*& channel,
int32_t channelId, int32_t channelId,
@ -95,7 +94,6 @@ public:
CriticalSectionWrapper* callbackCritSect); CriticalSectionWrapper* callbackCritSect);
int32_t UpdateLocalTimeStamp(); int32_t UpdateLocalTimeStamp();
public:
// API methods // API methods
// VoEBase // VoEBase
@ -288,7 +286,6 @@ public:
unsigned short payloadSize); unsigned short payloadSize);
uint32_t LastRemoteTimeStamp() { return _lastRemoteTimeStamp; } uint32_t LastRemoteTimeStamp() { return _lastRemoteTimeStamp; }
public:
// From AudioPacketizationCallback in the ACM // From AudioPacketizationCallback in the ACM
int32_t SendData(FrameType frameType, int32_t SendData(FrameType frameType,
uint8_t payloadType, uint8_t payloadType,
@ -299,10 +296,8 @@ public:
// From ACMVADCallback in the ACM // From ACMVADCallback in the ACM
int32_t InFrameType(int16_t frameType); int32_t InFrameType(int16_t frameType);
public:
int32_t OnRxVadDetected(int vadDecision); int32_t OnRxVadDetected(int vadDecision);
public:
// From RtpData in the RTP/RTCP module // From RtpData in the RTP/RTCP module
int32_t OnReceivedPayloadData(const uint8_t* payloadData, int32_t OnReceivedPayloadData(const uint8_t* payloadData,
uint16_t payloadSize, uint16_t payloadSize,
@ -310,7 +305,6 @@ public:
bool OnRecoveredPacket(const uint8_t* packet, int packet_length); bool OnRecoveredPacket(const uint8_t* packet, int packet_length);
public:
// From RtpFeedback in the RTP/RTCP module // From RtpFeedback in the RTP/RTCP module
int32_t OnInitializeDecoder( int32_t OnInitializeDecoder(
int32_t id, int32_t id,
@ -335,7 +329,6 @@ public:
void ResetStatistics(uint32_t ssrc); void ResetStatistics(uint32_t ssrc);
public:
// From RtcpFeedback in the RTP/RTCP module // From RtcpFeedback in the RTP/RTCP module
void OnApplicationDataReceived(int32_t id, void OnApplicationDataReceived(int32_t id,
uint8_t subType, uint8_t subType,
@ -343,7 +336,6 @@ public:
uint16_t length, uint16_t length,
const uint8_t* data); const uint8_t* data);
public:
// From RtpAudioFeedback in the RTP/RTCP module // From RtpAudioFeedback in the RTP/RTCP module
void OnReceivedTelephoneEvent(int32_t id, void OnReceivedTelephoneEvent(int32_t id,
uint8_t event, uint8_t event,
@ -354,21 +346,17 @@ public:
uint16_t lengthMs, uint16_t lengthMs,
uint8_t volume); uint8_t volume);
public:
// From Transport (called by the RTP/RTCP module) // From Transport (called by the RTP/RTCP module)
int SendPacket(int /*channel*/, const void *data, int len); int SendPacket(int /*channel*/, const void *data, int len);
int SendRTCPPacket(int /*channel*/, const void *data, int len); int SendRTCPPacket(int /*channel*/, const void *data, int len);
public:
// From MixerParticipant // From MixerParticipant
int32_t GetAudioFrame(int32_t id, AudioFrame& audioFrame); int32_t GetAudioFrame(int32_t id, AudioFrame& audioFrame);
int32_t NeededFrequency(int32_t id); int32_t NeededFrequency(int32_t id);
public:
// From MonitorObserver // From MonitorObserver
void OnPeriodicProcess(); void OnPeriodicProcess();
public:
// From FileCallback // From FileCallback
void PlayNotification(int32_t id, void PlayNotification(int32_t id,
uint32_t durationMs); uint32_t durationMs);
@ -377,7 +365,6 @@ public:
void PlayFileEnded(int32_t id); void PlayFileEnded(int32_t id);
void RecordFileEnded(int32_t id); void RecordFileEnded(int32_t id);
public:
uint32_t InstanceId() const uint32_t InstanceId() const
{ {
return _instanceId; return _instanceId;
@ -457,23 +444,21 @@ private:
int ApmProcessRx(AudioFrame& audioFrame); int ApmProcessRx(AudioFrame& audioFrame);
int SetRedPayloadType(int red_payload_type); int SetRedPayloadType(int red_payload_type);
private:
CriticalSectionWrapper& _fileCritSect; CriticalSectionWrapper& _fileCritSect;
CriticalSectionWrapper& _callbackCritSect; CriticalSectionWrapper& _callbackCritSect;
uint32_t _instanceId; uint32_t _instanceId;
int32_t _channelId; int32_t _channelId;
private:
scoped_ptr<RtpHeaderParser> rtp_header_parser_; scoped_ptr<RtpHeaderParser> rtp_header_parser_;
scoped_ptr<RTPPayloadRegistry> rtp_payload_registry_; scoped_ptr<RTPPayloadRegistry> rtp_payload_registry_;
scoped_ptr<ReceiveStatistics> rtp_receive_statistics_; scoped_ptr<ReceiveStatistics> rtp_receive_statistics_;
scoped_ptr<RtpReceiver> rtp_receiver_; scoped_ptr<RtpReceiver> rtp_receiver_;
TelephoneEventHandler* telephone_event_handler_; TelephoneEventHandler* telephone_event_handler_;
scoped_ptr<RtpRtcp> _rtpRtcpModule; scoped_ptr<RtpRtcp> _rtpRtcpModule;
AudioCodingModule& _audioCodingModule; scoped_ptr<AudioCodingModule> audio_coding_;
RtpDump& _rtpDumpIn; RtpDump& _rtpDumpIn;
RtpDump& _rtpDumpOut; RtpDump& _rtpDumpOut;
private:
AudioLevel _outputAudioLevel; AudioLevel _outputAudioLevel;
bool _externalTransport; bool _externalTransport;
AudioFrame _audioFrame; AudioFrame _audioFrame;
@ -509,7 +494,6 @@ private:
uint16_t send_sequence_number_; uint16_t send_sequence_number_;
uint8_t restored_packet_[kVoiceEngineMaxIpPacketSizeBytes]; uint8_t restored_packet_[kVoiceEngineMaxIpPacketSizeBytes];
private:
// uses // uses
Statistics* _engineStatisticsPtr; Statistics* _engineStatisticsPtr;
OutputMixer* _outputMixerPtr; OutputMixer* _outputMixerPtr;
@ -527,7 +511,6 @@ private:
int32_t _sendFrameType; // Send data is voice, 1-voice, 0-otherwise int32_t _sendFrameType; // Send data is voice, 1-voice, 0-otherwise
VoERTPObserver* _rtpObserverPtr; VoERTPObserver* _rtpObserverPtr;
VoERTCPObserver* _rtcpObserverPtr; VoERTCPObserver* _rtcpObserverPtr;
private:
// VoEBase // VoEBase
bool _outputIsOnHold; bool _outputIsOnHold;
bool _externalPlayout; bool _externalPlayout;
@ -581,7 +564,6 @@ private:
}; };
} // namespace voe } // namespace voe
} // namespace webrtc } // namespace webrtc
#endif // WEBRTC_VOICE_ENGINE_CHANNEL_H #endif // WEBRTC_VOICE_ENGINE_CHANNEL_H