Re-organizing ACM tests

The ACM tests needed re-writing, because all tests were not individual gtests, and the result was difficult to interpret.

While doing the re-write, I discovered a bug related to 48 kHz CNG. We can't have the 48 kHz CNG active at the moment. The bug is fixed in this CL.

I also needed to rewrite parts of the VAD/DTX implementation, so that the status of VAD and DTX (enabled or not) is propagated back from the function SetVAD().

BUG=issue2173
R=minyue@webrtc.org, turaj@webrtc.org

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

git-svn-id: http://webrtc.googlecode.com/svn/trunk@4625 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
tina.legrand@webrtc.org 2013-08-27 07:33:51 +00:00
parent d6fef9d380
commit ee92b664b3
19 changed files with 496 additions and 1038 deletions

View File

@ -183,7 +183,9 @@ const CodecInst ACMCodecDB::database_[] = {
{13, "CN", 8000, 240, 1, 0},
{98, "CN", 16000, 480, 1, 0},
{99, "CN", 32000, 960, 1, 0},
#ifdef ENABLE_48000_HZ
{100, "CN", 48000, 1440, 1, 0},
#endif
#ifdef WEBRTC_CODEC_AVT
{106, "telephone-event", 8000, 240, 1, 0},
#endif
@ -277,7 +279,9 @@ const ACMCodecDB::CodecSettings ACMCodecDB::codec_settings_[] = {
{1, {240}, 240, 1},
{1, {480}, 480, 1},
{1, {960}, 960, 1},
#ifdef ENABLE_48000_HZ
{1, {1440}, 1440, 1},
#endif
#ifdef WEBRTC_CODEC_AVT
{1, {240}, 240, 1},
#endif
@ -366,7 +370,9 @@ const WebRtcNetEQDecoder ACMCodecDB::neteq_decoders_[] = {
kDecoderCNG,
kDecoderCNG,
kDecoderCNG,
#ifdef ENABLE_48000_HZ
kDecoderCNG,
#endif
#ifdef WEBRTC_CODEC_AVT
kDecoderAVT,
#endif
@ -693,10 +699,12 @@ ACMGenericCodec* ACMCodecDB::CreateCodecInstance(const CodecInst* codec_inst) {
codec_id = kCNSWB;
break;
}
#ifdef ENABLE_48000_HZ
case 48000: {
codec_id = kCNFB;
break;
}
#endif
default: {
return NULL;
}
@ -748,10 +756,12 @@ ACMGenericCodec* ACMCodecDB::CreateCodecInstance(const CodecInst* codec_inst) {
codec_id = kCNSWB;
break;
}
#ifdef ENABLE_48000_HZ
case 48000: {
codec_id = kCNFB;
break;
}
#endif
default: {
return NULL;
}

View File

@ -103,7 +103,9 @@ class ACMCodecDB {
, kCNNB
, kCNWB
, kCNSWB
#ifdef ENABLE_48000_HZ
, kCNFB
#endif
#ifdef WEBRTC_CODEC_AVT
, kAVT
#endif

View File

@ -491,7 +491,11 @@ int16_t ACMGenericCodec::ResetEncoderSafe() {
DisableVAD();
// Set DTX/VAD.
return SetVADSafe(enable_dtx, enable_vad, mode);
int status = SetVADSafe(&enable_dtx, &enable_vad, &mode);
vad_enabled_ = enable_dtx;
dtx_enabled_ = enable_vad;
vad_mode_ = mode;
return status;
}
int16_t ACMGenericCodec::InternalResetEncoder() {
@ -579,8 +583,8 @@ int16_t ACMGenericCodec::InitEncoderSafe(WebRtcACMCodecParams* codec_params,
}
is_audio_buff_fresh_ = true;
}
status = SetVADSafe(codec_params->enable_dtx, codec_params->enable_vad,
codec_params->vad_mode);
status = SetVADSafe(&codec_params->enable_dtx, &codec_params->enable_vad,
&codec_params->vad_mode);
return status;
}
@ -856,70 +860,76 @@ uint32_t ACMGenericCodec::EarliestTimestamp() const {
return in_timestamp_[0];
}
int16_t ACMGenericCodec::SetVAD(const bool enable_dtx,
const bool enable_vad,
const ACMVADMode mode) {
int16_t ACMGenericCodec::SetVAD(bool* enable_dtx, bool* enable_vad,
ACMVADMode* mode) {
WriteLockScoped cs(codec_wrapper_lock_);
return SetVADSafe(enable_dtx, enable_vad, mode);
}
int16_t ACMGenericCodec::SetVADSafe(const bool enable_dtx,
const bool enable_vad,
const ACMVADMode mode) {
if (enable_dtx) {
int16_t ACMGenericCodec::SetVADSafe(bool* enable_dtx, bool* enable_vad,
ACMVADMode* mode) {
if (!STR_CASE_CMP(encoder_params_.codec_inst.plname, "OPUS") ||
encoder_params_.codec_inst.channels == 2 ) {
// VAD/DTX is not supported for Opus (even if sending mono), or other
// stereo codecs.
DisableDTX();
DisableVAD();
*enable_dtx = false;
*enable_vad = false;
return 0;
}
if (*enable_dtx) {
// Make G729 AnnexB a special case.
if (!STR_CASE_CMP(encoder_params_.codec_inst.plname, "G729")
&& !has_internal_dtx_) {
if (ACMGenericCodec::EnableDTX() < 0) {
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, unique_id_,
"SetVADSafe: error in enable DTX");
*enable_dtx = false;
*enable_vad = vad_enabled_;
return -1;
}
} else {
if (EnableDTX() < 0) {
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, unique_id_,
"SetVADSafe: error in enable DTX");
*enable_dtx = false;
*enable_vad = vad_enabled_;
return -1;
}
}
if (has_internal_dtx_) {
// Codec has internal DTX, practically we don't need WebRtc VAD, however,
// If codec does not have internal DTX (normal case) enabling DTX requires
// an active VAD. '*enable_dtx == true' overwrites VAD status.
// If codec has internal DTX, practically we don't need WebRtc VAD, however,
// we let the user to turn it on if they need call-backs on silence.
// Store VAD mode for future even if VAD is off.
vad_mode_ = mode;
return (enable_vad) ? EnableVAD(mode) : DisableVAD();
} else {
// Codec does not have internal DTX so enabling DTX requires an active
// VAD. 'enable_dtx == true' overwrites VAD status.
if (EnableVAD(mode) < 0) {
// If we cannot create VAD we have to disable DTX.
if (!vad_enabled_) {
DisableDTX();
}
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, unique_id_,
"SetVADSafe: error in enable VAD");
return -1;
}
// Return '1', to let the caller know VAD was turned on, even if the
// function was called with VAD='false'.
if (enable_vad == false) {
return 1;
} else {
return 0;
}
if (!has_internal_dtx_) {
// DTX is enabled, and VAD will be activated.
*enable_vad = true;
}
} else {
// Make G729 AnnexB a special case.
if (!STR_CASE_CMP(encoder_params_.codec_inst.plname, "G729")
&& !has_internal_dtx_) {
ACMGenericCodec::DisableDTX();
*enable_dtx = false;
} else {
DisableDTX();
*enable_dtx = false;
}
return (enable_vad) ? EnableVAD(mode) : DisableVAD();
}
int16_t status = (*enable_vad) ? EnableVAD(*mode) : DisableVAD();
if (status < 0) {
// Failed to set VAD, disable DTX.
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, unique_id_,
"SetVADSafe: error in enable VAD");
DisableDTX();
*enable_dtx = false;
*enable_vad = false;
}
return status;
}
int16_t ACMGenericCodec::EnableDTX() {

View File

@ -367,16 +367,16 @@ class ACMGenericCodec {
///////////////////////////////////////////////////////////////////////////
// int16_t SetVAD()
// This is called to set VAD & DTX. If the codec has internal DTX that will
// This is called to set VAD & DTX. If the codec has internal DTX, it will
// be used. If DTX is enabled and the codec does not have internal DTX,
// WebRtc-VAD will be used to decide if the frame is active. If DTX is
// disabled but VAD is enabled. The audio is passed through VAD to label it
// disabled but VAD is enabled the audio is passed through VAD to label it
// as active or passive, but the frame is encoded normally. However the
// bit-stream is labeled properly so that ACM::Process() can use this
// information. In case of failure, the previous states of the VAD & DTX
// are kept.
//
// Inputs:
// Input/Output:
// -enable_dtx : if true DTX will be enabled otherwise the DTX is
// disabled. If codec has internal DTX that will be
// used, otherwise WebRtc-CNG is used. In the latter
@ -392,9 +392,9 @@ class ACMGenericCodec {
// -1 if failed to set DTX & VAD as specified,
// 0 if succeeded.
//
int16_t SetVAD(const bool enable_dtx = true,
const bool enable_vad = false,
const ACMVADMode mode = VADNormal);
int16_t SetVAD(bool* enable_dtx,
bool* enable_vad,
ACMVADMode* mode);
///////////////////////////////////////////////////////////////////////////
// int32_t ReplaceInternalDTX()
@ -882,9 +882,9 @@ class ACMGenericCodec {
// See SetVAD() for the description of function, input(s)/output(s) and
// return value.
//
int16_t SetVADSafe(const bool enable_dtx = true,
const bool enable_vad = false,
const ACMVADMode mode = VADNormal);
int16_t SetVADSafe(bool* enable_dtx,
bool* enable_vad,
ACMVADMode* mode);
///////////////////////////////////////////////////////////////////////////
// See ReplaceInternalDTX() for the description of function, input and

View File

@ -574,7 +574,7 @@ int AudioCodingModuleImpl::ProcessSingleStream() {
}
case kActiveNormalEncoded:
case kPassiveNormalEncoded: {
current_payload_type = (uint8_t) send_codec_inst_.pltype;
current_payload_type = static_cast<uint8_t>(send_codec_inst_.pltype);
frame_type = kAudioFrameSpeech;
break;
}
@ -662,8 +662,8 @@ int AudioCodingModuleImpl::ProcessSingleStream() {
fragmentation_.fragmentationLength[1]);
// Update the fragmentation time difference vector, in number of
// timestamps.
uint16_t time_since_last = uint16_t(
rtp_timestamp - last_fec_timestamp_);
uint16_t time_since_last = static_cast<uint16_t>(rtp_timestamp -
last_fec_timestamp_);
// Update fragmentation vectors.
fragmentation_.fragmentationPlType[1] =
@ -736,7 +736,7 @@ int AudioCodingModuleImpl::ProcessSingleStream() {
if (vad_callback_ != NULL) {
// Callback with VAD decision.
vad_callback_->InFrameType(((int16_t) encoding_type));
vad_callback_->InFrameType(static_cast<int16_t>(encoding_type));
}
}
return length_bytes;
@ -1060,7 +1060,6 @@ int32_t AudioCodingModuleImpl::RegisterSendCodec(
}
ACMGenericCodec* codec_ptr = codecs_[codec_id];
int16_t status;
WebRtcACMCodecParams codec_params;
memcpy(&(codec_params.codec_inst), &send_codec, sizeof(CodecInst));
@ -1068,12 +1067,7 @@ int32_t AudioCodingModuleImpl::RegisterSendCodec(
codec_params.enable_dtx = dtx_enabled_;
codec_params.vad_mode = vad_mode_;
// Force initialization.
status = codec_ptr->InitEncoder(&codec_params, true);
// Check if VAD was turned on, or if error is reported.
if (status == 1) {
vad_enabled_ = true;
} else if (status < 0) {
if (codec_ptr->InitEncoder(&codec_params, true) < 0) {
// Could not initialize the encoder.
// Check if already have a registered codec.
@ -1090,17 +1084,18 @@ int32_t AudioCodingModuleImpl::RegisterSendCodec(
return -1;
}
// Update states.
dtx_enabled_ = codec_params.enable_dtx;
vad_enabled_ = codec_params.enable_vad;
vad_mode_ = codec_params.vad_mode;
// Everything is fine so we can replace the previous codec with this one.
if (send_codec_registered_) {
// If we change codec we start fresh with FEC.
// This is not strictly required by the standard.
is_first_red_ = true;
if (codec_ptr->SetVAD(dtx_enabled_, vad_enabled_, vad_mode_) < 0) {
// SetVAD failed.
vad_enabled_ = false;
dtx_enabled_ = false;
}
codec_ptr->SetVAD(&dtx_enabled_, &vad_enabled_, &vad_mode_);
}
current_send_codec_idx_ = codec_id;
@ -1436,8 +1431,8 @@ int AudioCodingModuleImpl::PreprocessToAddData(const AudioFrame& in_frame,
assert((secondary_encoder_.get() != NULL) ?
secondary_send_codec_inst_.plfreq == send_codec_inst_.plfreq : true);
bool resample = ((int32_t) in_frame.sample_rate_hz_
!= send_codec_inst_.plfreq);
bool resample = static_cast<int32_t>(in_frame.sample_rate_hz_) !=
send_codec_inst_.plfreq;
// This variable is true if primary codec and secondary codec (if exists)
// are both mono and input is stereo.
@ -1489,7 +1484,7 @@ int AudioCodingModuleImpl::PreprocessToAddData(const AudioFrame& in_frame,
// Calculate the timestamp of this frame.
if (last_in_timestamp_ > in_frame.timestamp_) {
// A wrap around has happened.
timestamp_diff = ((uint32_t) 0xFFFFFFFF - last_in_timestamp_)
timestamp_diff = (static_cast<uint32_t>(0xFFFFFFFF) - last_in_timestamp_)
+ in_frame.timestamp_;
} else {
timestamp_diff = in_frame.timestamp_ - last_in_timestamp_;
@ -1556,15 +1551,13 @@ AudioCodingModuleImpl::SetFECStatus(
/////////////////////////////////////////
// (VAD) Voice Activity Detection
//
int32_t AudioCodingModuleImpl::SetVAD(const bool enable_dtx,
const bool enable_vad,
const ACMVADMode mode) {
int32_t AudioCodingModuleImpl::SetVAD(bool enable_dtx, bool enable_vad,
ACMVADMode mode) {
CriticalSectionScoped lock(acm_crit_sect_);
return SetVADSafe(enable_dtx, enable_vad, mode);
}
int AudioCodingModuleImpl::SetVADSafe(bool enable_dtx,
bool enable_vad,
int AudioCodingModuleImpl::SetVADSafe(bool enable_dtx, bool enable_vad,
ACMVADMode mode) {
// Sanity check of the mode.
if ((mode != VADNormal) && (mode != VADLowBitrate)
@ -1579,7 +1572,10 @@ int AudioCodingModuleImpl::SetVADSafe(bool enable_dtx,
// sending.
if ((enable_dtx || enable_vad) && stereo_send_) {
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, id_,
"VAD/DTX not supported for stereo sending");
"VAD/DTX not supported for stereo sending.");
dtx_enabled_ = false;
vad_enabled_ = false;
vad_mode_ = mode;
return -1;
}
@ -1588,37 +1584,31 @@ int AudioCodingModuleImpl::SetVADSafe(bool enable_dtx,
if ((enable_dtx || enable_vad) && secondary_encoder_.get() != NULL) {
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, id_,
"VAD/DTX not supported when dual-streaming is enabled.");
dtx_enabled_ = false;
vad_enabled_ = false;
vad_mode_ = mode;
return -1;
}
// Store VAD/DTX settings. Values can be changed in the call to "SetVAD"
// below.
dtx_enabled_ = enable_dtx;
vad_enabled_ = enable_vad;
vad_mode_ = mode;
// If a send codec is registered, set VAD/DTX for the codec.
if (HaveValidEncoder("SetVAD")) {
int16_t status = codecs_[current_send_codec_idx_]->SetVAD(enable_dtx,
enable_vad,
mode);
if (status == 1) {
// Vad was enabled.
vad_enabled_ = true;
dtx_enabled_ = enable_dtx;
vad_mode_ = mode;
return 0;
} else if (status < 0) {
if (codecs_[current_send_codec_idx_]->SetVAD(&dtx_enabled_, &vad_enabled_,
&vad_mode_) < 0) {
// SetVAD failed.
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, id_,
"SetVAD failed");
vad_enabled_ = false;
dtx_enabled_ = false;
vad_enabled_ = false;
return -1;
}
}
vad_enabled_ = enable_vad;
dtx_enabled_ = enable_dtx;
vad_mode_ = mode;
return 0;
}
@ -2379,7 +2369,7 @@ int32_t AudioCodingModuleImpl::PlayoutData10Ms(
}
// Set the payload data length from the resampler.
audio_frame->samples_per_channel_ = (uint16_t) temp_len;
audio_frame->samples_per_channel_ = static_cast<uint16_t>(temp_len);
// Set the sampling frequency.
audio_frame->sample_rate_hz_ = desired_freq_hz;
} else {
@ -2453,11 +2443,12 @@ int32_t AudioCodingModuleImpl::PlayoutData10Ms(
if (dtmf_callback_ != NULL) {
if (tone != kACMToneEnd) {
// just a tone
dtmf_callback_->IncomingDtmf((uint8_t) tone, false);
dtmf_callback_->IncomingDtmf(static_cast<uint8_t>(tone), false);
} else if ((tone == kACMToneEnd) && (last_detected_tone != kACMToneEnd)) {
// The tone is "END" and the previously detected tone is
// not "END," so call fir an end.
dtmf_callback_->IncomingDtmf((uint8_t) last_detected_tone, true);
dtmf_callback_->IncomingDtmf(static_cast<uint8_t>(last_detected_tone),
true);
}
}
}
@ -2658,7 +2649,7 @@ int16_t AudioCodingModuleImpl::DecoderListIDByPlName(
assert(registered_pltypes_[id] >= 0);
assert(registered_pltypes_[id] <= 255);
codecs_[id]->DecoderParams(
&codec_params, (uint8_t) registered_pltypes_[id]);
&codec_params, static_cast<uint8_t>(registered_pltypes_[id]));
if (!STR_CASE_CMP(codec_params.codec_inst.plname, name)) {
// Check if the given sampling frequency matches.
// A zero sampling frequency means we matching the names

View File

@ -121,9 +121,9 @@ class AudioCodingModuleImpl : public AudioCodingModule {
// (CNG) Comfort Noise Generation
//
int32_t SetVAD(const bool enable_dtx = true,
const bool enable_vad = false,
const ACMVADMode mode = VADNormal);
int32_t SetVAD(bool enable_dtx = true,
bool enable_vad = false,
ACMVADMode mode = VADNormal);
int32_t VAD(bool* dtx_enabled, bool* vad_enabled,
ACMVADMode* mode) const;

View File

@ -72,23 +72,22 @@ void Sender::Setup(AudioCodingModule *acm, RTPStream *rtpStream) {
// Choose codec on command line.
printf("List of supported codec.\n");
for (int n = 0; n < noOfCodecs; n++) {
acm->Codec(n, &sendCodec);
EXPECT_EQ(0, acm->Codec(n, &sendCodec));
printf("%d %s\n", n, sendCodec.plname);
}
printf("Choose your codec:");
ASSERT_GT(scanf("%d", &codecNo), 0);
}
acm->Codec(codecNo, &sendCodec);
EXPECT_EQ(0, acm->Codec(codecNo, &sendCodec));
// Default number of channels is 2 for CELT, so we change to 1 in this test.
if (!strcmp(sendCodec.plname, "CELT")) {
sendCodec.channels = 1;
}
acm->RegisterSendCodec(sendCodec);
EXPECT_EQ(0, acm->RegisterSendCodec(sendCodec));
_packetization = new TestPacketization(rtpStream, sendCodec.plfreq);
if (acm->RegisterTransportCallback(_packetization) < 0) {
printf("Registering Transport Callback failed, for run: codecId: %d: --\n",
codeId);
}
EXPECT_EQ(0, acm->RegisterTransportCallback(_packetization));
_acm = acm;
}
@ -100,34 +99,23 @@ void Sender::Teardown() {
bool Sender::Add10MsData() {
if (!_pcmFile.EndOfFile()) {
_pcmFile.Read10MsData(_audioFrame);
EXPECT_GT(_pcmFile.Read10MsData(_audioFrame), 0);
int32_t ok = _acm->Add10MsData(_audioFrame);
EXPECT_EQ(0, ok);
if (ok != 0) {
printf("Error calling Add10MsData: for run: codecId: %d\n", codeId);
exit(1);
return false;
}
return true;
}
return false;
}
bool Sender::Process() {
int32_t ok = _acm->Process();
if (ok < 0) {
printf("Error calling Add10MsData: for run: codecId: %d\n", codeId);
exit(1);
}
return true;
}
void Sender::Run() {
while (true) {
if (!Add10MsData()) {
break;
}
if (!Process()) { // This could be done in a processing thread
break;
}
EXPECT_GT(_acm->Process(), -1);
}
}
@ -139,15 +127,12 @@ Receiver::Receiver()
void Receiver::Setup(AudioCodingModule *acm, RTPStream *rtpStream) {
struct CodecInst recvCodec;
int noOfCodecs;
acm->InitializeReceiver();
EXPECT_EQ(0, acm->InitializeReceiver());
noOfCodecs = acm->NumberOfCodecs();
for (int i = 0; i < noOfCodecs; i++) {
acm->Codec((uint8_t) i, &recvCodec);
if (acm->RegisterReceiveCodec(recvCodec) != 0) {
printf("Unable to register codec: for run: codecId: %d\n", codeId);
exit(1);
}
EXPECT_EQ(0, acm->Codec(static_cast<uint8_t>(i), &recvCodec));
EXPECT_EQ(0, acm->RegisterReceiveCodec(recvCodec));
}
int playSampFreq;
@ -184,8 +169,9 @@ void Receiver::Setup(AudioCodingModule *acm, RTPStream *rtpStream) {
void Receiver::Teardown() {
delete[] _playoutBuffer;
_pcmFile.Close();
if (testMode > 1)
if (testMode > 1) {
Trace::ReturnTrace();
}
}
bool Receiver::IncomingPacket() {
@ -199,18 +185,13 @@ bool Receiver::IncomingPacket() {
_firstTime = true;
return true;
} else {
printf("Error in reading incoming payload.\n");
return false;
}
}
}
int32_t ok = _acm->IncomingPacket(_incomingPayload, _realPayloadSizeBytes,
_rtpInfo);
if (ok != 0) {
printf("Error when inserting packet to ACM, for run: codecId: %d\n",
codeId);
}
EXPECT_EQ(0, _acm->IncomingPacket(_incomingPayload, _realPayloadSizeBytes,
_rtpInfo));
_realPayloadSizeBytes = _rtpStream->Read(&_rtpInfo, _incomingPayload,
_payloadSizeBytes, &_nextTime);
if (_realPayloadSizeBytes == 0 && _rtpStream->EndOfFile()) {
@ -223,10 +204,10 @@ bool Receiver::IncomingPacket() {
bool Receiver::PlayoutData() {
AudioFrame audioFrame;
if (_acm->PlayoutData10Ms(_frequency, &audioFrame) != 0) {
printf("Error when calling PlayoutData10Ms, for run: codecId: %d\n",
codeId);
exit(1);
int32_t ok =_acm->PlayoutData10Ms(_frequency, &audioFrame);
EXPECT_EQ(0, ok);
if (ok < 0){
return false;
}
if (_playoutLengthSmpls == 0) {
return false;
@ -241,7 +222,7 @@ void Receiver::Run() {
while (counter500Ms > 0) {
if (clock == 0 || clock >= _nextTime) {
IncomingPacket();
EXPECT_TRUE(IncomingPacket());
if (clock == 0) {
clock = _nextTime;
}
@ -279,12 +260,6 @@ EncodeDecodeTest::EncodeDecodeTest(int testMode) {
}
void EncodeDecodeTest::Perform() {
if (_testMode == 0) {
printf("Running Encode/Decode Test");
WEBRTC_TRACE(webrtc::kTraceStateInfo, webrtc::kTraceAudioCoding, -1,
"---------- EncodeDecodeTest ----------");
}
int numCodecs = 1;
int codePars[3]; // Frequency, packet size, rate.
int numPars[52]; // Number of codec parameters sets (freq, pacsize, rate)
@ -298,12 +273,9 @@ void EncodeDecodeTest::Perform() {
struct CodecInst sendCodecTmp;
numCodecs = acm->NumberOfCodecs();
if (_testMode == 1) {
printf("List of supported codec.\n");
}
if (_testMode != 2) {
for (int n = 0; n < numCodecs; n++) {
acm->Codec(n, &sendCodecTmp);
EXPECT_EQ(0, acm->Codec(n, &sendCodecTmp));
if (STR_CASE_CMP(sendCodecTmp.plname, "telephone-event") == 0) {
numPars[n] = 0;
} else if (STR_CASE_CMP(sendCodecTmp.plname, "cn") == 0) {
@ -314,9 +286,6 @@ void EncodeDecodeTest::Perform() {
numPars[n] = 0;
} else {
numPars[n] = 1;
if (_testMode == 1) {
printf("%d %s\n", n, sendCodecTmp.plname);
}
}
}
} else {
@ -330,14 +299,7 @@ void EncodeDecodeTest::Perform() {
for (int codeId = 0; codeId < numCodecs; codeId++) {
// Only encode using real mono encoders, not telephone-event and cng.
for (int loopPars = 1; loopPars <= numPars[codeId]; loopPars++) {
if (_testMode == 1) {
printf("\n");
printf("***FOR RUN: codeId: %d\n", codeId);
printf("\n");
} else if (_testMode == 0) {
printf(".");
}
// Encode all data to file.
EncodeToFile(1, codeId, codePars, _testMode);
RTPFile rtpFile;
@ -351,18 +313,15 @@ void EncodeDecodeTest::Perform() {
_receiver.Run();
_receiver.Teardown();
rtpFile.Close();
}
}
if (_testMode == 1) {
printf("***COMPLETED RUN FOR: codecID: %d ***\n", codeId);
}
}
}
AudioCodingModule::Destroy(acm);
if (_testMode == 0) {
printf("Done!\n");
}
if (_testMode == 1)
// End tracing.
if (_testMode == 1) {
Trace::ReturnTrace();
}
}
void EncodeDecodeTest::EncodeToFile(int fileType, int codeId, int* codePars,
@ -373,7 +332,7 @@ void EncodeDecodeTest::EncodeToFile(int fileType, int codeId, int* codePars,
rtpFile.Open(fileName.c_str(), "wb+");
rtpFile.WriteHeader();
//for auto_test and logging
// Store for auto_test and logging.
_sender.testMode = testMode;
_sender.codeId = codeId;

View File

@ -48,7 +48,6 @@ class Sender {
void Teardown();
void Run();
bool Add10MsData();
bool Process();
//for auto_test and logging
uint8_t testMode;

View File

@ -23,12 +23,11 @@
namespace webrtc {
TestFEC::TestFEC(int testMode)
TestFEC::TestFEC()
: _acmA(NULL),
_acmB(NULL),
_channelA2B(NULL),
_testCntr(0) {
_testMode = testMode;
}
TestFEC::~TestFEC() {
@ -47,35 +46,21 @@ TestFEC::~TestFEC() {
}
void TestFEC::Perform() {
if (_testMode == 0) {
printf("Running FEC Test");
WEBRTC_TRACE(kTraceStateInfo, kTraceAudioCoding, -1,
"---------- TestFEC ----------");
}
const std::string file_name = webrtc::test::ResourcePath(
"audio_coding/testfile32kHz", "pcm");
_inFileA.Open(file_name, 32000, "rb");
bool fecEnabled;
_acmA = AudioCodingModule::Create(0);
_acmB = AudioCodingModule::Create(1);
_acmA->InitializeReceiver();
_acmB->InitializeReceiver();
ASSERT_EQ(0, _acmA->InitializeReceiver());
ASSERT_EQ(0, _acmB->InitializeReceiver());
uint8_t numEncoders = _acmA->NumberOfCodecs();
CodecInst myCodecParam;
if (_testMode != 0) {
printf("Registering codecs at receiver... \n");
}
for (uint8_t n = 0; n < numEncoders; n++) {
_acmB->Codec(n, &myCodecParam);
if (_testMode != 0) {
printf("%s\n", myCodecParam.plname);
}
_acmB->RegisterReceiveCodec(myCodecParam);
EXPECT_EQ(0, _acmB->Codec(n, &myCodecParam));
EXPECT_EQ(0, _acmB->RegisterReceiveCodec(myCodecParam));
}
// Create and connect the channel
@ -83,333 +68,151 @@ void TestFEC::Perform() {
_acmA->RegisterTransportCallback(_channelA2B);
_channelA2B->RegisterReceiverACM(_acmB);
if (_testMode != 0) {
printf("===============================================================\n");
printf("%d ", _testCntr++);
} else {
printf(".");
}
#ifndef WEBRTC_CODEC_G722
EXPECT_TRUE(false);
printf("G722 needs to be activated to run this test\n");
exit(-1);
return;
#endif
char nameG722[] = "G722";
RegisterSendCodec('A', nameG722, 16000);
EXPECT_EQ(0, RegisterSendCodec('A', nameG722, 16000));
char nameCN[] = "CN";
RegisterSendCodec('A', nameCN, 16000);
EXPECT_EQ(0, RegisterSendCodec('A', nameCN, 16000));
char nameRED[] = "RED";
RegisterSendCodec('A', nameRED);
EXPECT_EQ(0, RegisterSendCodec('A', nameRED));
OpenOutFile(_testCntr);
SetVAD(true, true, VADAggr);
_acmA->SetFECStatus(false);
fecEnabled = _acmA->FECStatus();
if (_testMode != 0) {
printf("FEC currently %s\n", (fecEnabled ? "ON" : "OFF"));
DisplaySendReceiveCodec();
}
EXPECT_EQ(0, SetVAD(true, true, VADAggr));
EXPECT_EQ(0, _acmA->SetFECStatus(false));
EXPECT_FALSE(_acmA->FECStatus());
Run();
_outFileB.Close();
if (_testMode != 0) {
printf("===============================================================\n");
printf("%d ", _testCntr++);
} else {
printf(".");
}
_acmA->SetFECStatus(true);
fecEnabled = _acmA->FECStatus();
if (_testMode != 0) {
printf("FEC currently %s\n", (fecEnabled ? "ON" : "OFF"));
DisplaySendReceiveCodec();
}
EXPECT_EQ(0, _acmA->SetFECStatus(true));
EXPECT_TRUE(_acmA->FECStatus());
OpenOutFile(_testCntr);
Run();
_outFileB.Close();
if (_testMode != 0) {
printf("===============================================================\n");
printf("%d ", _testCntr++);
} else {
printf(".");
}
char nameISAC[] = "iSAC";
RegisterSendCodec('A', nameISAC, 16000);
OpenOutFile(_testCntr);
SetVAD(true, true, VADVeryAggr);
_acmA->SetFECStatus(false);
fecEnabled = _acmA->FECStatus();
if (_testMode != 0) {
printf("FEC currently %s\n", (fecEnabled ? "ON" : "OFF"));
DisplaySendReceiveCodec();
}
EXPECT_EQ(0, SetVAD(true, true, VADVeryAggr));
EXPECT_EQ(0, _acmA->SetFECStatus(false));
EXPECT_FALSE(_acmA->FECStatus());
Run();
_outFileB.Close();
if (_testMode != 0) {
printf("===============================================================\n");
printf("%d ", _testCntr++);
} else {
printf(".");
}
_acmA->SetFECStatus(true);
fecEnabled = _acmA->FECStatus();
if (_testMode != 0) {
printf("FEC currently %s\n", (fecEnabled ? "ON" : "OFF"));
DisplaySendReceiveCodec();
}
EXPECT_EQ(0, _acmA->SetFECStatus(true));
EXPECT_TRUE(_acmA->FECStatus());
OpenOutFile(_testCntr);
Run();
_outFileB.Close();
if (_testMode != 0) {
printf("===============================================================\n");
printf("%d ", _testCntr++);
} else {
printf(".");
}
RegisterSendCodec('A', nameISAC, 32000);
OpenOutFile(_testCntr);
SetVAD(true, true, VADVeryAggr);
_acmA->SetFECStatus(false);
fecEnabled = _acmA->FECStatus();
if (_testMode != 0) {
printf("FEC currently %s\n", (fecEnabled ? "ON" : "OFF"));
DisplaySendReceiveCodec();
}
EXPECT_EQ(0, SetVAD(true, true, VADVeryAggr));
EXPECT_EQ(0, _acmA->SetFECStatus(false));
EXPECT_FALSE(_acmA->FECStatus());
Run();
_outFileB.Close();
if (_testMode != 0) {
printf("===============================================================\n");
printf("%d ", _testCntr++);
} else {
printf(".");
}
_acmA->SetFECStatus(true);
fecEnabled = _acmA->FECStatus();
if (_testMode != 0) {
printf("FEC currently %s\n", (fecEnabled ? "ON" : "OFF"));
DisplaySendReceiveCodec();
}
EXPECT_EQ(0, _acmA->SetFECStatus(true));
EXPECT_TRUE(_acmA->FECStatus());
OpenOutFile(_testCntr);
Run();
_outFileB.Close();
if (_testMode != 0) {
printf("===============================================================\n");
printf("%d ", _testCntr++);
} else {
printf(".");
}
RegisterSendCodec('A', nameISAC, 32000);
OpenOutFile(_testCntr);
SetVAD(false, false, VADNormal);
_acmA->SetFECStatus(true);
fecEnabled = _acmA->FECStatus();
if (_testMode != 0) {
printf("FEC currently %s\n", (fecEnabled ? "ON" : "OFF"));
DisplaySendReceiveCodec();
}
EXPECT_EQ(0, SetVAD(false, false, VADNormal));
EXPECT_EQ(0, _acmA->SetFECStatus(true));
EXPECT_TRUE(_acmA->FECStatus());
Run();
RegisterSendCodec('A', nameISAC, 16000);
fecEnabled = _acmA->FECStatus();
if (_testMode != 0) {
printf("FEC currently %s\n", (fecEnabled ? "ON" : "OFF"));
DisplaySendReceiveCodec();
}
EXPECT_TRUE(_acmA->FECStatus());
Run();
RegisterSendCodec('A', nameISAC, 32000);
fecEnabled = _acmA->FECStatus();
if (_testMode != 0) {
printf("FEC currently %s\n", (fecEnabled ? "ON" : "OFF"));
DisplaySendReceiveCodec();
}
EXPECT_TRUE(_acmA->FECStatus());
Run();
RegisterSendCodec('A', nameISAC, 16000);
fecEnabled = _acmA->FECStatus();
if (_testMode != 0) {
printf("FEC currently %s\n", (fecEnabled ? "ON" : "OFF"));
DisplaySendReceiveCodec();
}
EXPECT_TRUE(_acmA->FECStatus());
Run();
_outFileB.Close();
_channelA2B->SetFECTestWithPacketLoss(true);
if (_testMode != 0) {
printf("===============================================================\n");
printf("%d ", _testCntr++);
} else {
printf(".");
}
RegisterSendCodec('A', nameG722);
RegisterSendCodec('A', nameCN, 16000);
EXPECT_EQ(0, RegisterSendCodec('A', nameG722));
EXPECT_EQ(0, RegisterSendCodec('A', nameCN, 16000));
OpenOutFile(_testCntr);
SetVAD(true, true, VADAggr);
_acmA->SetFECStatus(false);
fecEnabled = _acmA->FECStatus();
if (_testMode != 0) {
printf("FEC currently %s\n", (fecEnabled ? "ON" : "OFF"));
DisplaySendReceiveCodec();
}
EXPECT_EQ(0, SetVAD(true, true, VADAggr));
EXPECT_EQ(0, _acmA->SetFECStatus(false));
EXPECT_FALSE(_acmA->FECStatus());
Run();
_outFileB.Close();
if (_testMode != 0) {
printf("===============================================================\n");
printf("%d ", _testCntr++);
} else {
printf(".");
}
_acmA->SetFECStatus(true);
fecEnabled = _acmA->FECStatus();
if (_testMode != 0) {
printf("FEC currently %s\n", (fecEnabled ? "ON" : "OFF"));
DisplaySendReceiveCodec();
}
EXPECT_EQ(0, _acmA->SetFECStatus(true));
EXPECT_TRUE(_acmA->FECStatus());
OpenOutFile(_testCntr);
Run();
_outFileB.Close();
if (_testMode != 0) {
printf("===============================================================\n");
printf("%d ", _testCntr++);
} else {
printf(".");
}
RegisterSendCodec('A', nameISAC, 16000);
OpenOutFile(_testCntr);
SetVAD(true, true, VADVeryAggr);
_acmA->SetFECStatus(false);
fecEnabled = _acmA->FECStatus();
if (_testMode != 0) {
printf("FEC currently %s\n", (fecEnabled ? "ON" : "OFF"));
DisplaySendReceiveCodec();
}
EXPECT_EQ(0, SetVAD(true, true, VADVeryAggr));
EXPECT_EQ(0, _acmA->SetFECStatus(false));
EXPECT_FALSE(_acmA->FECStatus());
Run();
_outFileB.Close();
if (_testMode != 0) {
printf("===============================================================\n");
printf("%d ", _testCntr++);
} else {
printf(".");
}
_acmA->SetFECStatus(true);
fecEnabled = _acmA->FECStatus();
if (_testMode != 0) {
printf("FEC currently %s\n", (fecEnabled ? "ON" : "OFF"));
DisplaySendReceiveCodec();
}
EXPECT_EQ(0, _acmA->SetFECStatus(true));
EXPECT_TRUE(_acmA->FECStatus());
OpenOutFile(_testCntr);
Run();
_outFileB.Close();
if (_testMode != 0) {
printf("===============================================================\n");
printf("%d ", _testCntr++);
} else {
printf(".");
}
RegisterSendCodec('A', nameISAC, 32000);
OpenOutFile(_testCntr);
SetVAD(true, true, VADVeryAggr);
_acmA->SetFECStatus(false);
fecEnabled = _acmA->FECStatus();
if (_testMode != 0) {
printf("FEC currently %s\n", (fecEnabled ? "ON" : "OFF"));
DisplaySendReceiveCodec();
}
EXPECT_EQ(0, SetVAD(true, true, VADVeryAggr));
EXPECT_EQ(0, _acmA->SetFECStatus(false));
EXPECT_FALSE(_acmA->FECStatus());
Run();
_outFileB.Close();
if (_testMode != 0) {
printf("===============================================================\n");
printf("%d ", _testCntr++);
} else {
printf(".");
}
_acmA->SetFECStatus(true);
fecEnabled = _acmA->FECStatus();
if (_testMode != 0) {
printf("FEC currently %s\n", (fecEnabled ? "ON" : "OFF"));
DisplaySendReceiveCodec();
}
EXPECT_EQ(0, _acmA->SetFECStatus(true));
EXPECT_TRUE(_acmA->FECStatus());
OpenOutFile(_testCntr);
Run();
_outFileB.Close();
if (_testMode != 0) {
printf("===============================================================\n");
printf("%d ", _testCntr++);
} else {
printf(".");
}
RegisterSendCodec('A', nameISAC, 32000);
OpenOutFile(_testCntr);
SetVAD(false, false, VADNormal);
_acmA->SetFECStatus(true);
fecEnabled = _acmA->FECStatus();
if (_testMode != 0) {
printf("FEC currently %s\n", (fecEnabled ? "ON" : "OFF"));
DisplaySendReceiveCodec();
}
EXPECT_EQ(0, SetVAD(false, false, VADNormal));
EXPECT_EQ(0, _acmA->SetFECStatus(true));
EXPECT_TRUE(_acmA->FECStatus());
Run();
RegisterSendCodec('A', nameISAC, 16000);
fecEnabled = _acmA->FECStatus();
if (_testMode != 0) {
printf("FEC currently %s\n", (fecEnabled ? "ON" : "OFF"));
DisplaySendReceiveCodec();
}
EXPECT_TRUE(_acmA->FECStatus());
Run();
RegisterSendCodec('A', nameISAC, 32000);
fecEnabled = _acmA->FECStatus();
if (_testMode != 0) {
printf("FEC currently %s\n", (fecEnabled ? "ON" : "OFF"));
DisplaySendReceiveCodec();
}
EXPECT_TRUE(_acmA->FECStatus());
Run();
RegisterSendCodec('A', nameISAC, 16000);
fecEnabled = _acmA->FECStatus();
if (_testMode != 0) {
printf("FEC currently %s\n", (fecEnabled ? "ON" : "OFF"));
DisplaySendReceiveCodec();
}
EXPECT_TRUE(_acmA->FECStatus());
Run();
_outFileB.Close();
if (_testMode == 0) {
printf("Done!\n");
}
}
int32_t TestFEC::SetVAD(bool enableDTX, bool enableVAD, ACMVADMode vadMode) {
if (_testMode != 0) {
printf("DTX %s; VAD %s; VAD-Mode %d\n", enableDTX ? "ON" : "OFF",
enableVAD ? "ON" : "OFF", (int16_t) vadMode);
}
return _acmA->SetVAD(enableDTX, enableVAD, vadMode);
}
int16_t TestFEC::RegisterSendCodec(char side, char* codecName,
int32_t samplingFreqHz) {
if (_testMode != 0) {
if (samplingFreqHz > 0) {
printf("Registering %s-%d for side %c\n", codecName, samplingFreqHz,
side);
} else {
printf("Registering %s for side %c\n", codecName, side);
}
}
std::cout << std::flush;
AudioCodingModule* myACM;
switch (side) {
@ -430,13 +233,11 @@ int16_t TestFEC::RegisterSendCodec(char side, char* codecName,
return -1;
}
CodecInst myCodecParam;
EXPECT_GT(AudioCodingModule::Codec(codecName, &myCodecParam,
samplingFreqHz, 1), -1);
EXPECT_GT(myACM->RegisterSendCodec(myCodecParam), -1);
CHECK_ERROR(
AudioCodingModule::Codec(codecName, &myCodecParam, samplingFreqHz, 1));
CHECK_ERROR(myACM->RegisterSendCodec(myCodecParam));
// initialization was succesful
// Initialization was successful.
return 0;
}
@ -448,25 +249,22 @@ void TestFEC::Run() {
int32_t outFreqHzB = _outFileB.SamplingFrequency();
while (!_inFileA.EndOfFile()) {
_inFileA.Read10MsData(audioFrame);
CHECK_ERROR(_acmA->Add10MsData(audioFrame));
CHECK_ERROR(_acmA->Process());
CHECK_ERROR(_acmB->PlayoutData10Ms(outFreqHzB, &audioFrame));
EXPECT_GT(_inFileA.Read10MsData(audioFrame), 0);
EXPECT_EQ(0, _acmA->Add10MsData(audioFrame));
EXPECT_GT(_acmA->Process(), -1);
EXPECT_EQ(0, _acmB->PlayoutData10Ms(outFreqHzB, &audioFrame));
_outFileB.Write10MsData(audioFrame.data_, audioFrame.samples_per_channel_);
msecPassed += 10;
if (msecPassed >= 1000) {
msecPassed = 0;
secPassed++;
}
// Test that toggling FEC on and off works.
if (((secPassed % 5) == 4) && (msecPassed == 0) && (_testCntr > 14)) {
printf("%3u:%3u ", secPassed, msecPassed);
_acmA->SetFECStatus(false);
printf("FEC currently %s\n", (_acmA->FECStatus() ? "ON" : "OFF"));
EXPECT_EQ(0, _acmA->SetFECStatus(false));
}
if (((secPassed % 5) == 4) && (msecPassed >= 990) && (_testCntr > 14)) {
printf("%3u:%3u ", secPassed, msecPassed);
_acmA->SetFECStatus(true);
printf("FEC currently %s\n", (_acmA->FECStatus() ? "ON" : "OFF"));
EXPECT_EQ(0, _acmA->SetFECStatus(true));
}
}
_inFileA.Rewind();
@ -476,22 +274,10 @@ void TestFEC::OpenOutFile(int16_t test_number) {
std::string file_name;
std::stringstream file_stream;
file_stream << webrtc::test::OutputPath();
if (_testMode == 0) {
file_stream << "TestFEC_autoFile_";
} else {
file_stream << "TestFEC_outFile_";
}
file_stream << test_number << ".pcm";
file_name = file_stream.str();
_outFileB.Open(file_name, 16000, "wb");
}
void TestFEC::DisplaySendReceiveCodec() {
CodecInst myCodecParam;
_acmA->SendCodec(&myCodecParam);
printf("%s -> ", myCodecParam.plname);
_acmB->ReceiveCodec(&myCodecParam);
printf("%s\n", myCodecParam.plname);
}
} // namespace webrtc

View File

@ -19,7 +19,7 @@ namespace webrtc {
class TestFEC : public ACMTest {
public:
TestFEC(int testMode);
TestFEC();
~TestFEC();
void Perform();
@ -31,7 +31,6 @@ class TestFEC : public ACMTest {
int32_t sampFreqHz = -1);
void Run();
void OpenOutFile(int16_t testNumber);
void DisplaySendReceiveCodec();
int32_t SetVAD(bool enableDTX, bool enableVAD, ACMVADMode vadMode);
AudioCodingModule* _acmA;
AudioCodingModule* _acmB;
@ -41,7 +40,6 @@ class TestFEC : public ACMTest {
PCMFile _inFileA;
PCMFile _outFileB;
int16_t _testCntr;
int _testMode;
};
} // namespace webrtc

View File

@ -154,12 +154,6 @@ void TestStereo::Perform() {
bool vad;
ACMVADMode vad_mode;
if (test_mode_ == 0) {
printf("Running Stereo Test");
WEBRTC_TRACE(kTraceStateInfo, kTraceAudioCoding, -1,
"---------- TestStereo ----------");
}
// Open both mono and stereo test files in 32 kHz.
const std::string file_name_stereo = webrtc::test::ResourcePath(
"audio_coding/teststereo32kHz", "pcm");
@ -200,21 +194,6 @@ void TestStereo::Perform() {
EXPECT_EQ(0, acm_b_->RegisterReceiveCodec(my_codec_param));
}
// TODO(tlegrand): Take care of return values of all function calls.
// TODO(tlegrand): Re-register all stereo codecs needed in the test,
// with new payload numbers.
// g722_pltype_ = 117;
// l16_8khz_pltype_ = 120;
// l16_16khz_pltype_ = 121;
// l16_32khz_pltype_ = 122;
// pcma_pltype_ = 110;
// pcmu_pltype_ = 118;
// celt_pltype_ = 119;
// cn_8khz_pltype_ = 123;
// cn_16khz_pltype_ = 124;
// cn_32khz_pltype_ = 125;
// Create and connect the channel.
channel_a2b_ = new TestPackStereo;
EXPECT_EQ(0, acm_a_->RegisterTransportCallback(channel_a2b_));
@ -821,11 +800,11 @@ void TestStereo::RegisterSendCodec(char side, char* codec_name,
CodecInst my_codec_param;
// Get all codec parameters before registering
CHECK_ERROR(AudioCodingModule::Codec(codec_name, &my_codec_param,
sampling_freq_hz, channels));
EXPECT_GT(AudioCodingModule::Codec(codec_name, &my_codec_param,
sampling_freq_hz, channels), -1);
my_codec_param.rate = rate;
my_codec_param.pacsize = pack_size;
CHECK_ERROR(my_acm->RegisterSendCodec(my_codec_param));
EXPECT_EQ(0, my_acm->RegisterSendCodec(my_codec_param));
send_codec_name_ = codec_name;
}
@ -865,10 +844,10 @@ void TestStereo::Run(TestPackStereo* channel, int in_channels, int out_channels,
}
in_file_stereo_->Read10MsData(audio_frame);
}
CHECK_ERROR(acm_a_->Add10MsData(audio_frame));
EXPECT_EQ(0, acm_a_->Add10MsData(audio_frame));
// Run sender side of ACM
CHECK_ERROR(acm_a_->Process());
EXPECT_GT(acm_a_->Process(), -1);
// Verify that the received packet size matches the settings
rec_size = channel->payload_size();
@ -888,7 +867,7 @@ void TestStereo::Run(TestPackStereo* channel, int in_channels, int out_channels,
}
// Run received side of ACM
CHECK_ERROR(acm_b_->PlayoutData10Ms(out_freq_hz_b, &audio_frame));
EXPECT_EQ(0, acm_b_->PlayoutData10Ms(out_freq_hz_b, &audio_frame));
// Write output speech to file
out_file_.Write10MsData(

View File

@ -22,14 +22,10 @@
namespace webrtc {
TestVADDTX::TestVADDTX(int testMode)
TestVADDTX::TestVADDTX()
: _acmA(NULL),
_acmB(NULL),
_channelA2B(NULL),
_testResults(0) {
//testMode == 1 for more extensive testing
//testMode == 0 for quick test (autotest)
_testMode = testMode;
_channelA2B(NULL) {
}
TestVADDTX::~TestVADDTX() {
@ -48,12 +44,6 @@ TestVADDTX::~TestVADDTX() {
}
void TestVADDTX::Perform() {
if (_testMode == 0) {
printf("Running VAD/DTX Test");
WEBRTC_TRACE(webrtc::kTraceStateInfo, webrtc::kTraceAudioCoding, -1,
"---------- TestVADDTX ----------");
}
const std::string file_name = webrtc::test::ResourcePath(
"audio_coding/testfile32kHz", "pcm");
_inFileA.Open(file_name, 32000, "rb");
@ -61,24 +51,18 @@ void TestVADDTX::Perform() {
_acmA = AudioCodingModule::Create(0);
_acmB = AudioCodingModule::Create(1);
_acmA->InitializeReceiver();
_acmB->InitializeReceiver();
EXPECT_EQ(0, _acmA->InitializeReceiver());
EXPECT_EQ(0, _acmB->InitializeReceiver());
uint8_t numEncoders = _acmA->NumberOfCodecs();
CodecInst myCodecParam;
if (_testMode != 0) {
printf("Registering codecs at receiver... \n");
}
for (uint8_t n = 0; n < numEncoders; n++) {
_acmB->Codec(n, &myCodecParam);
if (_testMode != 0) {
printf("%s\n", myCodecParam.plname);
}
EXPECT_EQ(0, _acmB->Codec(n, &myCodecParam));
if (!strcmp(myCodecParam.plname, "opus")) {
// Use mono decoding for Opus in the VAD/DTX test.
// Register Opus as mono.
myCodecParam.channels = 1;
}
_acmB->RegisterReceiveCodec(myCodecParam);
EXPECT_EQ(0, _acmB->RegisterReceiveCodec(myCodecParam));
}
// Create and connect the channel
@ -89,7 +73,6 @@ void TestVADDTX::Perform() {
_acmA->RegisterVADCallback(&_monitor);
int16_t testCntr = 1;
int16_t testResults = 0;
#ifdef WEBRTC_CODEC_ISAC
// Open outputfile
@ -147,101 +130,51 @@ void TestVADDTX::Perform() {
_outFileB.Close();
#endif
if (_testMode) {
printf("Done!\n");
}
printf("VAD/DTX test completed with %d subtests failed\n", testResults);
if (testResults > 0) {
printf("Press return\n\n");
getchar();
}
}
void TestVADDTX::runTestCases() {
if (_testMode != 0) {
CodecInst myCodecParam;
_acmA->SendCodec(&myCodecParam);
printf("%s\n", myCodecParam.plname);
} else {
printf(".");
}
// #1 DTX = OFF, VAD = ON, VADNormal
if (_testMode != 0)
printf("Test #1 ");
SetVAD(false, true, VADNormal);
Run();
_testResults += VerifyTest();
VerifyTest();
// #2 DTX = OFF, VAD = ON, VADAggr
if (_testMode != 0)
printf("Test #2 ");
SetVAD(false, true, VADAggr);
Run();
_testResults += VerifyTest();
VerifyTest();
// #3 DTX = ON, VAD = ON, VADLowBitrate
if (_testMode != 0)
printf("Test #3 ");
SetVAD(true, true, VADLowBitrate);
Run();
_testResults += VerifyTest();
VerifyTest();
// #4 DTX = ON, VAD = ON, VADVeryAggr
if (_testMode != 0)
printf("Test #4 ");
SetVAD(true, true, VADVeryAggr);
Run();
_testResults += VerifyTest();
VerifyTest();
// #5 DTX = ON, VAD = OFF, VADNormal
if (_testMode != 0)
printf("Test #5 ");
SetVAD(true, false, VADNormal);
Run();
_testResults += VerifyTest();
VerifyTest();
}
void TestVADDTX::runTestInternalDTX() {
// #6 DTX = ON, VAD = ON, VADNormal
if (_testMode != 0)
printf("Test #6 ");
void TestVADDTX::runTestInternalDTX(int expected_result) {
// #6 DTX = ON, VAD = ON, VADNormal
SetVAD(true, true, VADNormal);
if (_acmA->ReplaceInternalDTXWithWebRtc(true) < 0) {
printf("Was not able to replace DTX since CN was not registered\n");
}
EXPECT_EQ(expected_result, _acmA->ReplaceInternalDTXWithWebRtc(true));
if (expected_result == 0) {
Run();
_testResults += VerifyTest();
VerifyTest();
}
}
void TestVADDTX::SetVAD(bool statusDTX, bool statusVAD, int16_t vadMode) {
bool dtxEnabled, vadEnabled;
ACMVADMode vadModeSet;
if (_acmA->SetVAD(statusDTX, statusVAD, (ACMVADMode) vadMode) < 0) {
assert(false);
}
if (_acmA->VAD(&dtxEnabled, &vadEnabled, &vadModeSet) < 0) {
assert(false);
}
if (_testMode != 0) {
if (statusDTX != dtxEnabled) {
printf("DTX: %s not the same as requested: %s\n",
dtxEnabled ? "ON" : "OFF", dtxEnabled ? "OFF" : "ON");
}
if (((statusVAD == true) && (vadEnabled == false)) ||
((statusVAD == false) && (vadEnabled == false) &&
(statusDTX == true))) {
printf("VAD: %s not the same as requested: %s\n",
vadEnabled ? "ON" : "OFF", vadEnabled ? "OFF" : "ON");
}
if (vadModeSet != vadMode) {
printf("VAD mode: %d not the same as requested: %d\n",
(int16_t) vadModeSet, (int16_t) vadMode);
}
}
EXPECT_EQ(0, _acmA->SetVAD(statusDTX, statusVAD, (ACMVADMode) vadMode));
EXPECT_EQ(0, _acmA->VAD(&dtxEnabled, &vadEnabled, &vadModeSet));
// Requested VAD/DTX settings
_setStruct.statusDTX = statusDTX;
@ -252,7 +185,6 @@ void TestVADDTX::SetVAD(bool statusDTX, bool statusVAD, int16_t vadMode) {
_getStruct.statusDTX = dtxEnabled;
_getStruct.statusVAD = vadEnabled;
_getStruct.vadMode = vadModeSet;
}
VADDTXstruct TestVADDTX::GetVAD() {
@ -260,9 +192,7 @@ VADDTXstruct TestVADDTX::GetVAD() {
bool dtxEnabled, vadEnabled;
ACMVADMode vadModeSet;
if (_acmA->VAD(&dtxEnabled, &vadEnabled, &vadModeSet) < 0) {
assert(false);
}
EXPECT_EQ(0, _acmA->VAD(&dtxEnabled, &vadEnabled, &vadModeSet));
retStruct.statusDTX = dtxEnabled;
retStruct.statusVAD = vadEnabled;
@ -273,9 +203,6 @@ VADDTXstruct TestVADDTX::GetVAD() {
int16_t TestVADDTX::RegisterSendCodec(char side, char* codecName,
int32_t samplingFreqHz,
int32_t rateKbps) {
if (_testMode != 0) {
printf("Registering %s for side %c\n", codecName, side);
}
std::cout << std::flush;
AudioCodingModule* myACM;
switch (side) {
@ -298,7 +225,7 @@ int16_t TestVADDTX::RegisterSendCodec(char side, char* codecName,
CodecInst myCodecParam;
for (int16_t codecCntr = 0; codecCntr < myACM->NumberOfCodecs();
codecCntr++) {
CHECK_ERROR(myACM->Codec((uint8_t) codecCntr, &myCodecParam));
EXPECT_EQ(0, myACM->Codec((uint8_t) codecCntr, &myCodecParam));
if (!STR_CASE_CMP(myCodecParam.plname, codecName)) {
if ((samplingFreqHz == -1) || (myCodecParam.plfreq == samplingFreqHz)) {
if ((rateKbps == -1) || (myCodecParam.rate == rateKbps)) {
@ -310,7 +237,7 @@ int16_t TestVADDTX::RegisterSendCodec(char side, char* codecName,
// We only allow VAD/DTX when sending mono.
myCodecParam.channels = 1;
CHECK_ERROR(myACM->RegisterSendCodec(myCodecParam));
EXPECT_EQ(0, myACM->RegisterSendCodec(myCodecParam));
// initialization was succesful
return 0;
@ -327,15 +254,13 @@ void TestVADDTX::Run() {
_inFileA.Read10MsData(audioFrame);
audioFrame.timestamp_ = timestampA;
timestampA += SamplesIn10MsecA;
CHECK_ERROR(_acmA->Add10MsData(audioFrame));
CHECK_ERROR(_acmA->Process());
CHECK_ERROR(_acmB->PlayoutData10Ms(outFreqHzB, &audioFrame));
EXPECT_EQ(0, _acmA->Add10MsData(audioFrame));
EXPECT_GT(_acmA->Process(), -1);
EXPECT_EQ(0, _acmB->PlayoutData10Ms(outFreqHzB, &audioFrame));
_outFileB.Write10MsData(audioFrame.data_, audioFrame.samples_per_channel_);
}
#ifdef PRINT_STAT
_monitor.PrintStatistics(_testMode);
_monitor.PrintStatistics();
#endif
_inFileA.Rewind();
_monitor.GetStatistics(_statCounter);
@ -346,11 +271,7 @@ void TestVADDTX::OpenOutFile(int16_t test_number) {
std::string file_name;
std::stringstream file_stream;
file_stream << webrtc::test::OutputPath();
if (_testMode == 0) {
file_stream << "testVADDTX_autoFile_";
} else {
file_stream << "testVADDTX_outFile_";
}
file_stream << test_number << ".pcm";
file_name = file_stream.str();
_outFileB.Open(file_name, 16000, "wb");
@ -374,6 +295,17 @@ int16_t TestVADDTX::VerifyTest() {
if (!isReplaced) {
dtxInUse = false;
}
} else if (STR_CASE_CMP(myCodecParam.plname, "opus") == 0) {
if (_getStruct.statusDTX != false) {
// DTX status doesn't match expected.
vadPattern |= 4;
} else if (_getStruct.statusVAD != false) {
// Mismatch in VAD setting.
vadPattern |= 2;
} else {
_setStruct.statusDTX = false;
_setStruct.statusVAD = false;
}
}
// Check for error in VAD/DTX settings
@ -429,21 +361,10 @@ int16_t TestVADDTX::VerifyTest() {
statusEF |= (_statCounter[ii] > 0);
}
}
if ((statusEF == 0) && (vadPattern == 0)) {
if (_testMode != 0) {
printf(" Test OK!\n");
}
EXPECT_EQ(0, statusEF);
EXPECT_EQ(0, vadPattern);
return 0;
} else {
if (statusEF) {
printf("\t\t\tUnexpected empty frame result!\n");
}
if (vadPattern) {
printf("\t\t\tUnexpected SetVAD() result!\tDTX: %d\tVAD: %d\tMode: %d\n",
(vadPattern >> 2) & 1, (vadPattern >> 1) & 1, vadPattern & 1);
}
return 1;
}
}
ActivityMonitor::ActivityMonitor() {
@ -459,8 +380,7 @@ int32_t ActivityMonitor::InFrameType(int16_t frameType) {
return 0;
}
void ActivityMonitor::PrintStatistics(int testMode) {
if (testMode != 0) {
void ActivityMonitor::PrintStatistics() {
printf("\n");
printf("kActiveNormalEncoded kPassiveNormalEncoded kPassiveDTXWB ");
printf("kPassiveDTXNB kPassiveDTXSWB kFrameEmpty\n");
@ -471,7 +391,6 @@ void ActivityMonitor::PrintStatistics(int testMode) {
printf("%14u", _counter[5]);
printf("%11u", _counter[0]);
printf("\n\n");
}
}
void ActivityMonitor::ResetStatistics() {

View File

@ -28,7 +28,7 @@ class ActivityMonitor : public ACMVADCallback {
ActivityMonitor();
~ActivityMonitor();
int32_t InFrameType(int16_t frameType);
void PrintStatistics(int testMode);
void PrintStatistics();
void ResetStatistics();
void GetStatistics(uint32_t* getCounter);
private:
@ -46,7 +46,7 @@ class ActivityMonitor : public ACMVADCallback {
class TestVADDTX : public ACMTest {
public:
TestVADDTX(int testMode);
TestVADDTX();
~TestVADDTX();
void Perform();
@ -60,7 +60,7 @@ class TestVADDTX : public ACMTest {
void Run();
void OpenOutFile(int16_t testNumber);
void runTestCases();
void runTestInternalDTX();
void runTestInternalDTX(int expected_result);
void SetVAD(bool statusDTX, bool statusVAD, int16_t vadMode);
VADDTXstruct GetVAD();
int16_t VerifyTest();
@ -75,8 +75,6 @@ class TestVADDTX : public ACMTest {
ActivityMonitor _monitor;
uint32_t _statCounter[6];
int _testMode;
int _testResults;
VADDTXstruct _setStruct;
VADDTXstruct _getStruct;
};

View File

@ -31,95 +31,9 @@ using webrtc::AudioCodingModule;
using webrtc::Trace;
// This parameter is used to describe how to run the tests. It is normally
// set to 1, but in auto test all printing is turned off, and the parameter is
// set to 0.
#define ACM_TEST_MODE 1
// TODO(tlegrand): Add all tests as individual gtests, like already done for
// TestAllCodecs (ACM_TEST_ALL_ENC_DEC).
// Choose what tests to run by defining one or more of the following:
//
// ACM_AUTO_TEST - Most common codecs and settings will be tested. All the
// other tests will be activated.
// ACM_TEST_ENC_DEC - You decide what to test in run time. Used for debugging
// and for testing while implementing.
// ACM_TEST_TWO_WAY - Mainly for debugging.
// ACM_TEST_ALL_CODECS - Loop through all defined codecs and settings.
// ACM_TEST_STEREO - Run stereo and spatial audio tests.
// ACM_TEST_VAD_DTX - Run all VAD/DTX tests.
// ACM_TEST_FEC - Test FEC (also called RED).
// ACM_TEST_CODEC_SPEC_API - Test the iSAC has codec specfic APIs.
// ACM_TEST_FULL_API - Test all APIs with threads (long test).
#define ACM_AUTO_TEST
//#define ACM_TEST_ENC_DEC
//#define ACM_TEST_TWO_WAY
//#define ACM_TEST_ALL_CODECS
//#define ACM_TEST_STEREO
//#define ACM_TEST_VAD_DTX
//#define ACM_TEST_FEC
//#define ACM_TEST_CODEC_SPEC_API
//#define ACM_TEST_FULL_API
// If Auto test is active, we activate all tests.
#ifdef ACM_AUTO_TEST
#undef ACM_TEST_MODE
// set to 0, and all tests are run in quite mode.
#define ACM_TEST_MODE 0
#ifndef ACM_TEST_ALL_CODECS
#define ACM_TEST_ALL_CODECS
#endif
#endif
void PopulateTests(std::vector<ACMTest*>* tests) {
Trace::CreateTrace();
Trace::SetTraceFile((webrtc::test::OutputPath() + "acm_trace.txt").c_str());
printf("The following tests will be executed:\n");
#ifdef ACM_AUTO_TEST
printf(" ACM auto test\n");
tests->push_back(new webrtc::EncodeDecodeTest(0));
tests->push_back(new webrtc::TwoWayCommunication(0));
tests->push_back(new webrtc::TestStereo(0));
tests->push_back(new webrtc::TestVADDTX(0));
tests->push_back(new webrtc::TestFEC(0));
tests->push_back(new webrtc::ISACTest(0));
#endif
#ifdef ACM_TEST_ENC_DEC
printf(" ACM encode-decode test\n");
tests->push_back(new webrtc::EncodeDecodeTest(2));
#endif
#ifdef ACM_TEST_TWO_WAY
printf(" ACM two-way communication test\n");
tests->push_back(new webrtc::TwoWayCommunication(1));
#endif
#ifdef ACM_TEST_STEREO
printf(" ACM stereo test\n");
tests->push_back(new webrtc::TestStereo(1));
#endif
#ifdef ACM_TEST_VAD_DTX
printf(" ACM VAD-DTX test\n");
tests->push_back(new webrtc::TestVADDTX(1));
#endif
#ifdef ACM_TEST_FEC
printf(" ACM FEC test\n");
tests->push_back(new webrtc::TestFEC(1));
#endif
#ifdef ACM_TEST_CODEC_SPEC_API
printf(" ACM codec API test\n");
tests->push_back(new webrtc::ISACTest(1));
#endif
#ifdef ACM_TEST_FULL_API
printf(" ACM full API test\n");
tests->push_back(new webrtc::APITest());
#endif
printf("\n");
}
// TODO(kjellander): Make this a proper gtest instead of using this single test
// to run all the tests.
#ifdef ACM_TEST_ALL_CODECS
TEST(AudioCodingModuleTest, TestAllCodecs) {
Trace::CreateTrace();
Trace::SetTraceFile((webrtc::test::OutputPath() +
@ -127,7 +41,54 @@ TEST(AudioCodingModuleTest, TestAllCodecs) {
webrtc::TestAllCodecs(ACM_TEST_MODE).Perform();
Trace::ReturnTrace();
}
#endif
TEST(AudioCodingModuleTest, DISABLED_ON_ANDROID(TestEncodeDecode)) {
Trace::CreateTrace();
Trace::SetTraceFile((webrtc::test::OutputPath() +
"acm_encodedecode_trace.txt").c_str());
webrtc::EncodeDecodeTest(ACM_TEST_MODE).Perform();
Trace::ReturnTrace();
}
TEST(AudioCodingModuleTest, DISABLED_ON_ANDROID(TestFEC)) {
Trace::CreateTrace();
Trace::SetTraceFile((webrtc::test::OutputPath() +
"acm_fec_trace.txt").c_str());
webrtc::TestFEC().Perform();
Trace::ReturnTrace();
}
TEST(AudioCodingModuleTest, DISABLED_ON_ANDROID(TestIsac)) {
Trace::CreateTrace();
Trace::SetTraceFile((webrtc::test::OutputPath() +
"acm_isac_trace.txt").c_str());
webrtc::ISACTest(ACM_TEST_MODE).Perform();
Trace::ReturnTrace();
}
TEST(AudioCodingModuleTest, DISABLED_ON_ANDROID(TwoWayCommunication)) {
Trace::CreateTrace();
Trace::SetTraceFile((webrtc::test::OutputPath() +
"acm_twowaycom_trace.txt").c_str());
webrtc::TwoWayCommunication(ACM_TEST_MODE).Perform();
Trace::ReturnTrace();
}
TEST(AudioCodingModuleTest, DISABLED_ON_ANDROID(TestStereo)) {
Trace::CreateTrace();
Trace::SetTraceFile((webrtc::test::OutputPath() +
"acm_stereo_trace.txt").c_str());
webrtc::TestStereo(ACM_TEST_MODE).Perform();
Trace::ReturnTrace();
}
TEST(AudioCodingModuleTest, DISABLED_ON_ANDROID(TestVADDTX)) {
Trace::CreateTrace();
Trace::SetTraceFile((webrtc::test::OutputPath() +
"acm_vaddtx_trace.txt").c_str());
webrtc::TestVADDTX().Perform();
Trace::ReturnTrace();
}
TEST(AudioCodingModuleTest, TestOpus) {
Trace::CreateTrace();
@ -137,15 +98,14 @@ TEST(AudioCodingModuleTest, TestOpus) {
Trace::ReturnTrace();
}
TEST(AudioCodingModuleTest, DISABLED_ON_ANDROID(RunAllTests)) {
std::vector<ACMTest*> tests;
PopulateTests(&tests);
std::vector<ACMTest*>::iterator it;
for (it = tests.begin(); it < tests.end(); it++) {
(*it)->Perform();
delete (*it);
}
// The full API test is too long to run automatically on bots, but can be used
// for offline testing. User interaction is needed.
#ifdef ACM_TEST_FULL_API
TEST(AudioCodingModuleTest, TestAPI) {
Trace::CreateTrace();
Trace::SetTraceFile((webrtc::test::OutputPath() +
"acm_apitest_trace.txt").c_str());
webrtc::APITest().Perform();
Trace::ReturnTrace();
printf("ACM test completed\n");
}
}
#endif

View File

@ -37,22 +37,18 @@ TwoWayCommunication::TwoWayCommunication(int testMode) {
TwoWayCommunication::~TwoWayCommunication() {
AudioCodingModule::Destroy(_acmA);
AudioCodingModule::Destroy(_acmB);
AudioCodingModule::Destroy(_acmRefA);
AudioCodingModule::Destroy(_acmRefB);
delete _channel_A2B;
delete _channel_B2A;
delete _channelRef_A2B;
delete _channelRef_B2A;
#ifdef WEBRTC_DTMF_DETECTION
if(_dtmfDetectorA != NULL)
{
if (_dtmfDetectorA != NULL) {
delete _dtmfDetectorA;
}
if(_dtmfDetectorB != NULL)
{
if (_dtmfDetectorB != NULL) {
delete _dtmfDetectorB;
}
#endif
@ -64,7 +60,7 @@ TwoWayCommunication::~TwoWayCommunication() {
_outFileRefB.Close();
}
uint8_t TwoWayCommunication::ChooseCodec(uint8_t* codecID_A,
void TwoWayCommunication::ChooseCodec(uint8_t* codecID_A,
uint8_t* codecID_B) {
AudioCodingModule* tmpACM = AudioCodingModule::Create(0);
uint8_t noCodec = tmpACM->NumberOfCodecs();
@ -72,7 +68,7 @@ uint8_t TwoWayCommunication::ChooseCodec(uint8_t* codecID_A,
printf("List of Supported Codecs\n");
printf("========================\n");
for (uint8_t codecCntr = 0; codecCntr < noCodec; codecCntr++) {
tmpACM->Codec(codecCntr, &codecInst);
EXPECT_EQ(tmpACM->Codec(codecCntr, &codecInst), 0);
printf("%d- %s\n", codecCntr, codecInst.plname);
}
printf("\nChoose a send codec for side A [0]: ");
@ -86,10 +82,9 @@ uint8_t TwoWayCommunication::ChooseCodec(uint8_t* codecID_A,
AudioCodingModule::Destroy(tmpACM);
printf("\n");
return 0;
}
int16_t TwoWayCommunication::SetUp() {
void TwoWayCommunication::SetUp() {
_acmA = AudioCodingModule::Create(1);
_acmB = AudioCodingModule::Create(2);
@ -103,35 +98,34 @@ int16_t TwoWayCommunication::SetUp() {
CodecInst codecInst_A;
CodecInst codecInst_B;
CodecInst dummyCodec;
_acmA->Codec(codecID_A, &codecInst_A);
_acmB->Codec(codecID_B, &codecInst_B);
_acmA->Codec(6, &dummyCodec);
EXPECT_EQ(0, _acmA->Codec(codecID_A, &codecInst_A));
EXPECT_EQ(0, _acmB->Codec(codecID_B, &codecInst_B));
EXPECT_EQ(0, _acmA->Codec(6, &dummyCodec));
//--- Set A codecs
CHECK_ERROR(_acmA->RegisterSendCodec(codecInst_A));
CHECK_ERROR(_acmA->RegisterReceiveCodec(codecInst_B));
EXPECT_EQ(0, _acmA->RegisterSendCodec(codecInst_A));
EXPECT_EQ(0, _acmA->RegisterReceiveCodec(codecInst_B));
#ifdef WEBRTC_DTMF_DETECTION
_dtmfDetectorA = new(DTMFDetector);
CHECK_ERROR(_acmA->RegisterIncomingMessagesCallback(_dtmfDetectorA,
ACMUSA));
EXPECT_GT(_acmA->RegisterIncomingMessagesCallback(_dtmfDetectorA, ACMUSA),
-1);
#endif
//--- Set ref-A codecs
CHECK_ERROR(_acmRefA->RegisterSendCodec(codecInst_A));
CHECK_ERROR(_acmRefA->RegisterReceiveCodec(codecInst_B));
EXPECT_EQ(0, _acmRefA->RegisterSendCodec(codecInst_A));
EXPECT_EQ(0, _acmRefA->RegisterReceiveCodec(codecInst_B));
//--- Set B codecs
CHECK_ERROR(_acmB->RegisterSendCodec(codecInst_B));
CHECK_ERROR(_acmB->RegisterReceiveCodec(codecInst_A));
EXPECT_EQ(0, _acmB->RegisterSendCodec(codecInst_B));
EXPECT_EQ(0, _acmB->RegisterReceiveCodec(codecInst_A));
#ifdef WEBRTC_DTMF_DETECTION
_dtmfDetectorB = new(DTMFDetector);
CHECK_ERROR(_acmB->RegisterIncomingMessagesCallback(_dtmfDetectorB,
ACMUSA));
EXPECT_GT(_acmB->RegisterIncomingMessagesCallback(_dtmfDetectorB, ACMUSA),
-1);
#endif
//--- Set ref-B codecs
CHECK_ERROR(_acmRefB->RegisterSendCodec(codecInst_B));
CHECK_ERROR(_acmRefB->RegisterReceiveCodec(codecInst_A));
EXPECT_EQ(0, _acmRefB->RegisterSendCodec(codecInst_B));
EXPECT_EQ(0, _acmRefB->RegisterReceiveCodec(codecInst_A));
uint16_t frequencyHz;
@ -187,13 +181,11 @@ int16_t TwoWayCommunication::SetUp() {
// The clicks will be more obvious when we
// are in FAX mode.
_acmB->SetPlayoutMode(fax);
_acmRefB->SetPlayoutMode(fax);
return 0;
EXPECT_EQ(_acmB->SetPlayoutMode(fax), 0);
EXPECT_EQ(_acmRefB->SetPlayoutMode(fax), 0);
}
int16_t TwoWayCommunication::SetUpAutotest() {
void TwoWayCommunication::SetUpAutotest() {
_acmA = AudioCodingModule::Create(1);
_acmB = AudioCodingModule::Create(2);
@ -204,35 +196,33 @@ int16_t TwoWayCommunication::SetUpAutotest() {
CodecInst codecInst_B;
CodecInst dummyCodec;
_acmA->Codec("ISAC", &codecInst_A, 16000, 1);
_acmB->Codec("L16", &codecInst_B, 8000, 1);
_acmA->Codec(6, &dummyCodec);
EXPECT_EQ(0, _acmA->Codec("ISAC", &codecInst_A, 16000, 1));
EXPECT_EQ(0, _acmB->Codec("L16", &codecInst_B, 8000, 1));
EXPECT_EQ(0, _acmA->Codec(6, &dummyCodec));
//--- Set A codecs
CHECK_ERROR(_acmA->RegisterSendCodec(codecInst_A));
CHECK_ERROR(_acmA->RegisterReceiveCodec(codecInst_B));
EXPECT_EQ(0, _acmA->RegisterSendCodec(codecInst_A));
EXPECT_EQ(0, _acmA->RegisterReceiveCodec(codecInst_B));
#ifdef WEBRTC_DTMF_DETECTION
_dtmfDetectorA = new(DTMFDetector);
CHECK_ERROR(_acmA->RegisterIncomingMessagesCallback(_dtmfDetectorA,
ACMUSA));
EXPECT_EQ(0, _acmA->RegisterIncomingMessagesCallback(_dtmfDetectorA, ACMUSA));
#endif
//--- Set ref-A codecs
CHECK_ERROR(_acmRefA->RegisterSendCodec(codecInst_A));
CHECK_ERROR(_acmRefA->RegisterReceiveCodec(codecInst_B));
EXPECT_GT(_acmRefA->RegisterSendCodec(codecInst_A), -1);
EXPECT_GT(_acmRefA->RegisterReceiveCodec(codecInst_B), -1);
//--- Set B codecs
CHECK_ERROR(_acmB->RegisterSendCodec(codecInst_B));
CHECK_ERROR(_acmB->RegisterReceiveCodec(codecInst_A));
EXPECT_GT(_acmB->RegisterSendCodec(codecInst_B), -1);
EXPECT_GT(_acmB->RegisterReceiveCodec(codecInst_A), -1);
#ifdef WEBRTC_DTMF_DETECTION
_dtmfDetectorB = new(DTMFDetector);
CHECK_ERROR(_acmB->RegisterIncomingMessagesCallback(_dtmfDetectorB,
ACMUSA));
EXPECT_EQ(0, _acmB->RegisterIncomingMessagesCallback(_dtmfDetectorB, ACMUSA));
#endif
//--- Set ref-B codecs
CHECK_ERROR(_acmRefB->RegisterSendCodec(codecInst_B));
CHECK_ERROR(_acmRefB->RegisterReceiveCodec(codecInst_A));
EXPECT_EQ(0, _acmRefB->RegisterSendCodec(codecInst_B));
EXPECT_EQ(0, _acmRefB->RegisterReceiveCodec(codecInst_A));
uint16_t frequencyHz;
@ -279,17 +269,12 @@ int16_t TwoWayCommunication::SetUpAutotest() {
// The clicks will be more obvious when we
// are in FAX mode.
_acmB->SetPlayoutMode(fax);
_acmRefB->SetPlayoutMode(fax);
return 0;
EXPECT_EQ(0, _acmB->SetPlayoutMode(fax));
EXPECT_EQ(0, _acmRefB->SetPlayoutMode(fax));
}
void TwoWayCommunication::Perform() {
if (_testMode == 0) {
printf("Running TwoWayCommunication Test");
WEBRTC_TRACE(kTraceStateInfo, kTraceAudioCoding, -1,
"---------- TwoWayCommunication ----------");
SetUpAutotest();
} else {
SetUp();
@ -305,111 +290,78 @@ void TwoWayCommunication::Perform() {
CodecInst codecInst_B;
CodecInst dummy;
_acmB->SendCodec(&codecInst_B);
if (_testMode != 0) {
printf("\n");
printf("sec:msec A B\n");
printf("-------- ----- -----\n");
}
EXPECT_EQ(0, _acmB->SendCodec(&codecInst_B));
// In the following loop we tests that the code can handle misuse of the APIs.
// In the middle of a session with data flowing between two sides, called A
// and B, APIs will be called, like ResetEncoder(), and the code should
// continue to run, and be able to recover.
bool expect_error_add = false;
bool expect_error_process = false;
while (!_inFileA.EndOfFile() && !_inFileB.EndOfFile()) {
_inFileA.Read10MsData(audioFrame);
_acmA->Add10MsData(audioFrame);
_acmRefA->Add10MsData(audioFrame);
msecPassed += 10;
EXPECT_GT(_inFileA.Read10MsData(audioFrame), 0);
EXPECT_EQ(0, _acmA->Add10MsData(audioFrame));
EXPECT_EQ(0, _acmRefA->Add10MsData(audioFrame));
_inFileB.Read10MsData(audioFrame);
_acmB->Add10MsData(audioFrame);
_acmRefB->Add10MsData(audioFrame);
EXPECT_GT(_inFileB.Read10MsData(audioFrame), 0);
_acmA->Process();
_acmB->Process();
_acmRefA->Process();
_acmRefB->Process();
_acmA->PlayoutData10Ms(outFreqHzA, &audioFrame);
// Expect call to pass except for the time when no send codec is registered.
if (!expect_error_add) {
EXPECT_EQ(0, _acmB->Add10MsData(audioFrame));
} else {
EXPECT_EQ(-1, _acmB->Add10MsData(audioFrame));
}
// Expect to pass except for the time when there either is no send codec
// registered, or no receive codec.
if (!expect_error_process) {
EXPECT_GT(_acmB->Process(), -1);
} else {
EXPECT_EQ(_acmB->Process(), -1);
}
EXPECT_EQ(0, _acmRefB->Add10MsData(audioFrame));
EXPECT_GT(_acmA->Process(), -1);
EXPECT_GT(_acmRefA->Process(), -1);
EXPECT_GT(_acmRefB->Process(), -1);
EXPECT_EQ(0, _acmA->PlayoutData10Ms(outFreqHzA, &audioFrame));
_outFileA.Write10MsData(audioFrame);
_acmRefA->PlayoutData10Ms(outFreqHzA, &audioFrame);
EXPECT_EQ(0, _acmRefA->PlayoutData10Ms(outFreqHzA, &audioFrame));
_outFileRefA.Write10MsData(audioFrame);
_acmB->PlayoutData10Ms(outFreqHzB, &audioFrame);
EXPECT_EQ(0, _acmB->PlayoutData10Ms(outFreqHzB, &audioFrame));
_outFileB.Write10MsData(audioFrame);
_acmRefB->PlayoutData10Ms(outFreqHzB, &audioFrame);
EXPECT_EQ(0, _acmRefB->PlayoutData10Ms(outFreqHzB, &audioFrame));
_outFileRefB.Write10MsData(audioFrame);
msecPassed += 10;
// Update time counters each time a second of data has passed.
if (msecPassed >= 1000) {
msecPassed = 0;
secPassed++;
}
// Call RestEncoder for ACM on side A, and InitializeSender for ACM on
// side B.
if (((secPassed % 5) == 4) && (msecPassed == 0)) {
if (_testMode != 0) {
printf("%3u:%3u ", secPassed, msecPassed);
}
_acmA->ResetEncoder();
if (_testMode == 0) {
WEBRTC_TRACE(kTraceStateInfo, kTraceAudioCoding, -1,
"---------- Errors expected");
printf(".");
} else {
printf("Reset Encoder (click in side B) ");
printf("Initialize Sender (no audio in side A)\n");
}
CHECK_ERROR(_acmB->InitializeSender());
EXPECT_EQ(0, _acmA->ResetEncoder());
EXPECT_EQ(0, _acmB->InitializeSender());
expect_error_add = true;
expect_error_process = true;
}
// Re-register send codec on side B.
if (((secPassed % 5) == 4) && (msecPassed >= 990)) {
if (_testMode == 0) {
WEBRTC_TRACE(kTraceStateInfo, kTraceAudioCoding, -1,
"----- END: Errors expected");
printf(".");
} else {
printf("%3u:%3u ", secPassed, msecPassed);
printf(" ");
printf("Register Send Codec (audio back in side A)\n");
}
CHECK_ERROR(_acmB->RegisterSendCodec(codecInst_B));
CHECK_ERROR(_acmB->SendCodec(&dummy));
EXPECT_EQ(0, _acmB->RegisterSendCodec(codecInst_B));
EXPECT_EQ(0, _acmB->SendCodec(&dummy));
expect_error_add = false;
expect_error_process = false;
}
// Reset decoder on side B, and initialize receiver on side A.
if (((secPassed % 7) == 6) && (msecPassed == 0)) {
CHECK_ERROR(_acmB->ResetDecoder());
if (_testMode == 0) {
WEBRTC_TRACE(kTraceStateInfo, kTraceAudioCoding, -1,
"---------- Errors expected");
printf(".");
} else {
printf("%3u:%3u ", secPassed, msecPassed);
printf("Initialize Receiver (no audio in side A) ");
printf("Reset Decoder\n");
}
CHECK_ERROR(_acmA->InitializeReceiver());
EXPECT_EQ(0, _acmB->ResetDecoder());
EXPECT_EQ(0, _acmA->InitializeReceiver());
}
// Re-register codec on side A.
if (((secPassed % 7) == 6) && (msecPassed >= 990)) {
if (_testMode == 0) {
WEBRTC_TRACE(kTraceStateInfo, kTraceAudioCoding, -1,
"----- END: Errors expected");
printf(".");
} else {
printf("%3u:%3u ", secPassed, msecPassed);
printf("Register Receive Coded (audio back in side A)\n");
EXPECT_EQ(0, _acmA->RegisterReceiveCodec(codecInst_B));
}
CHECK_ERROR(_acmA->RegisterReceiveCodec(codecInst_B));
}
//Sleep(9);
}
if (_testMode == 0) {
printf("Done!\n");
}
#ifdef WEBRTC_DTMF_DETECTION
printf("\nDTMF at Side A\n");
_dtmfDetectorA->PrintDetectedDigits();
printf("\nDTMF at Side B\n");
_dtmfDetectorB->PrintDetectedDigits();
#endif
}
} // namespace webrtc

View File

@ -26,9 +26,9 @@ class TwoWayCommunication : public ACMTest {
void Perform();
private:
uint8_t ChooseCodec(uint8_t* codecID_A, uint8_t* codecID_B);
int16_t SetUp();
int16_t SetUpAutotest();
void ChooseCodec(uint8_t* codecID_A, uint8_t* codecID_B);
void SetUp();
void SetUpAutotest();
AudioCodingModule* _acmA;
AudioCodingModule* _acmB;

View File

@ -50,16 +50,12 @@ int16_t SetISAConfig(ACMTestISACConfig& isacConfig, AudioCodingModule* acm,
if ((isacConfig.currentRateBitPerSec != 0)
|| (isacConfig.currentFrameSizeMsec != 0)) {
CodecInst sendCodec;
acm->SendCodec(&sendCodec);
EXPECT_EQ(0, acm->SendCodec(&sendCodec));
if (isacConfig.currentRateBitPerSec < 0) {
// Register iSAC in adaptive (channel-dependent) mode.
sendCodec.rate = -1;
CHECK_ERROR(acm->RegisterSendCodec(sendCodec));
if (testMode != 0) {
printf("ISAC-%s Registered in adaptive (channel-dependent) mode.\n",
(sendCodec.plfreq == 32000) ? "swb" : "wb");
}
EXPECT_EQ(0, acm->RegisterSendCodec(sendCodec));
} else {
if (isacConfig.currentRateBitPerSec != 0) {
sendCodec.rate = isacConfig.currentRateBitPerSec;
}
@ -67,43 +63,24 @@ int16_t SetISAConfig(ACMTestISACConfig& isacConfig, AudioCodingModule* acm,
sendCodec.pacsize = isacConfig.currentFrameSizeMsec
* (sendCodec.plfreq / 1000);
}
CHECK_ERROR(acm->RegisterSendCodec(sendCodec));
if (testMode != 0) {
printf("Target rate is set to %d bit/sec with frame-size %d ms \n",
(int) isacConfig.currentRateBitPerSec,
(int) sendCodec.pacsize / (sendCodec.plfreq / 1000));
}
EXPECT_EQ(0, acm->RegisterSendCodec(sendCodec));
}
}
if (isacConfig.maxRateBitPerSec > 0) {
CHECK_ERROR(acm->SetISACMaxRate(isacConfig.maxRateBitPerSec));
if (testMode != 0) {
printf("Max rate is set to %u bit/sec\n", isacConfig.maxRateBitPerSec);
}
// Set max rate.
EXPECT_EQ(0, acm->SetISACMaxRate(isacConfig.maxRateBitPerSec));
}
if (isacConfig.maxPayloadSizeByte > 0) {
CHECK_ERROR(acm->SetISACMaxPayloadSize(isacConfig.maxPayloadSizeByte));
if (testMode != 0) {
printf("Max payload-size is set to %u bit/sec\n",
isacConfig.maxPayloadSizeByte);
}
// Set max payload size.
EXPECT_EQ(0, acm->SetISACMaxPayloadSize(isacConfig.maxPayloadSizeByte));
}
if ((isacConfig.initFrameSizeInMsec != 0)
|| (isacConfig.initRateBitPerSec != 0)) {
CHECK_ERROR(
acm->ConfigISACBandwidthEstimator(
(uint8_t) isacConfig.initFrameSizeInMsec,
(uint16_t) isacConfig.initRateBitPerSec,
EXPECT_EQ(0, acm->ConfigISACBandwidthEstimator(
static_cast<uint8_t>(isacConfig.initFrameSizeInMsec),
static_cast<uint16_t>(isacConfig.initRateBitPerSec),
isacConfig.enforceFrameSize));
if ((isacConfig.initFrameSizeInMsec != 0) && (testMode != 0)) {
printf("Initialize BWE to %d msec frame-size\n",
isacConfig.initFrameSizeInMsec);
}
if ((isacConfig.initRateBitPerSec != 0) && (testMode != 0)) {
printf("Initialize BWE to %u bit/sec send-bandwidth\n",
isacConfig.initRateBitPerSec);
}
}
return 0;
@ -121,7 +98,7 @@ ISACTest::~ISACTest() {
delete _channel_B2A;
}
int16_t ISACTest::Setup() {
void ISACTest::Setup() {
int codecCntr;
CodecInst codecParam;
@ -130,7 +107,7 @@ int16_t ISACTest::Setup() {
for (codecCntr = 0; codecCntr < AudioCodingModule::NumberOfCodecs();
codecCntr++) {
AudioCodingModule::Codec(codecCntr, &codecParam);
EXPECT_EQ(0, AudioCodingModule::Codec(codecCntr, &codecParam));
if (!STR_CASE_CMP(codecParam.plname, "ISAC")
&& codecParam.plfreq == 16000) {
memcpy(&_paramISAC16kHz, &codecParam, sizeof(CodecInst));
@ -143,35 +120,27 @@ int16_t ISACTest::Setup() {
}
}
// register both iSAC-wb & iSAC-swb in both sides as receiver codecs
CHECK_ERROR(_acmA->RegisterReceiveCodec(_paramISAC16kHz));
CHECK_ERROR(_acmA->RegisterReceiveCodec(_paramISAC32kHz));
CHECK_ERROR(_acmB->RegisterReceiveCodec(_paramISAC16kHz));
CHECK_ERROR(_acmB->RegisterReceiveCodec(_paramISAC32kHz));
// Register both iSAC-wb & iSAC-swb in both sides as receiver codecs.
EXPECT_EQ(0, _acmA->RegisterReceiveCodec(_paramISAC16kHz));
EXPECT_EQ(0, _acmA->RegisterReceiveCodec(_paramISAC32kHz));
EXPECT_EQ(0, _acmB->RegisterReceiveCodec(_paramISAC16kHz));
EXPECT_EQ(0, _acmB->RegisterReceiveCodec(_paramISAC32kHz));
//--- Set A-to-B channel
_channel_A2B = new Channel;
CHECK_ERROR(_acmA->RegisterTransportCallback(_channel_A2B));
EXPECT_EQ(0, _acmA->RegisterTransportCallback(_channel_A2B));
_channel_A2B->RegisterReceiverACM(_acmB);
//--- Set B-to-A channel
_channel_B2A = new Channel;
CHECK_ERROR(_acmB->RegisterTransportCallback(_channel_B2A));
EXPECT_EQ(0, _acmB->RegisterTransportCallback(_channel_B2A));
_channel_B2A->RegisterReceiverACM(_acmA);
file_name_swb_ = webrtc::test::ResourcePath("audio_coding/testfile32kHz",
"pcm");
_acmB->RegisterSendCodec(_paramISAC16kHz);
_acmA->RegisterSendCodec(_paramISAC32kHz);
if (_testMode != 0) {
printf("Side A Send Codec\n");
printf("%s %d\n", _paramISAC32kHz.plname, _paramISAC32kHz.plfreq);
printf("Side B Send Codec\n");
printf("%s %d\n", _paramISAC16kHz.plname, _paramISAC16kHz.plfreq);
}
EXPECT_EQ(0, _acmB->RegisterSendCodec(_paramISAC16kHz));
EXPECT_EQ(0, _acmA->RegisterSendCodec(_paramISAC32kHz));
_inFileA.Open(file_name_swb_, 32000, "rb");
std::string fileNameA = webrtc::test::OutputPath() + "testisac_a.pcm";
@ -183,32 +152,15 @@ int16_t ISACTest::Setup() {
Run10ms();
}
CodecInst receiveCodec;
CHECK_ERROR(_acmA->ReceiveCodec(&receiveCodec));
if (_testMode != 0) {
printf("Side A Receive Codec\n");
printf("%s %d\n", receiveCodec.plname, receiveCodec.plfreq);
}
CHECK_ERROR(_acmB->ReceiveCodec(&receiveCodec));
if (_testMode != 0) {
printf("Side B Receive Codec\n");
printf("%s %d\n", receiveCodec.plname, receiveCodec.plfreq);
}
EXPECT_EQ(0, _acmA->ReceiveCodec(&receiveCodec));
EXPECT_EQ(0, _acmB->ReceiveCodec(&receiveCodec));
_inFileA.Close();
_outFileA.Close();
_outFileB.Close();
return 0;
}
void ISACTest::Perform() {
if (_testMode == 0) {
printf("Running iSAC Test");
WEBRTC_TRACE(webrtc::kTraceStateInfo, webrtc::kTraceAudioCoding, -1,
"---------- iSACTest ----------");
}
Setup();
int16_t testNr = 0;
@ -258,8 +210,8 @@ void ISACTest::Perform() {
int user_input;
if ((_testMode == 0) || (_testMode == 1)) {
swbISACConfig.maxPayloadSizeByte = (uint16_t) 200;
wbISACConfig.maxPayloadSizeByte = (uint16_t) 200;
swbISACConfig.maxPayloadSizeByte = static_cast<uint16_t>(200);
wbISACConfig.maxPayloadSizeByte = static_cast<uint16_t>(200);
} else {
printf("Enter the max payload-size for side A: ");
CHECK_ERROR(scanf("%d", &user_input));
@ -277,8 +229,8 @@ void ISACTest::Perform() {
SetISACConfigDefault(swbISACConfig);
if ((_testMode == 0) || (_testMode == 1)) {
swbISACConfig.maxRateBitPerSec = (uint32_t) 48000;
wbISACConfig.maxRateBitPerSec = (uint32_t) 48000;
swbISACConfig.maxRateBitPerSec = static_cast<uint32_t>(48000);
wbISACConfig.maxRateBitPerSec = static_cast<uint32_t>(48000);
} else {
printf("Enter the max rate for side A: ");
CHECK_ERROR(scanf("%d", &user_input));
@ -294,7 +246,6 @@ void ISACTest::Perform() {
testNr++;
if (_testMode == 0) {
SwitchingSamplingRate(testNr, 4);
printf("Done!\n");
} else {
SwitchingSamplingRate(testNr, 80);
}
@ -302,30 +253,19 @@ void ISACTest::Perform() {
void ISACTest::Run10ms() {
AudioFrame audioFrame;
_inFileA.Read10MsData(audioFrame);
CHECK_ERROR(_acmA->Add10MsData(audioFrame));
CHECK_ERROR(_acmB->Add10MsData(audioFrame));
CHECK_ERROR(_acmA->Process());
CHECK_ERROR(_acmB->Process());
CHECK_ERROR(_acmA->PlayoutData10Ms(32000, &audioFrame));
EXPECT_GT(_inFileA.Read10MsData(audioFrame), 0);
EXPECT_EQ(0, _acmA->Add10MsData(audioFrame));
EXPECT_EQ(0, _acmB->Add10MsData(audioFrame));
EXPECT_GT(_acmA->Process(), -1);
EXPECT_GT(_acmB->Process(), -1);
EXPECT_EQ(0, _acmA->PlayoutData10Ms(32000, &audioFrame));
_outFileA.Write10MsData(audioFrame);
CHECK_ERROR(_acmB->PlayoutData10Ms(32000, &audioFrame));
EXPECT_EQ(0, _acmB->PlayoutData10Ms(32000, &audioFrame));
_outFileB.Write10MsData(audioFrame);
}
void ISACTest::EncodeDecode(int testNr, ACMTestISACConfig& wbISACConfig,
ACMTestISACConfig& swbISACConfig) {
if (_testMode == 0) {
printf(".");
} else {
printf("\nTest %d:\n\n", testNr);
}
// Files in Side A and B
_inFileA.Open(file_name_swb_, 32000, "rb", true);
_inFileB.Open(file_name_swb_, 32000, "rb", true);
@ -335,29 +275,19 @@ void ISACTest::EncodeDecode(int testNr, ACMTestISACConfig& wbISACConfig,
std::stringstream file_stream_b;
file_stream_a << webrtc::test::OutputPath();
file_stream_b << webrtc::test::OutputPath();
if (_testMode == 0) {
file_stream_a << "out_iSACTest_A_" << testNr << ".pcm";
file_stream_b << "out_iSACTest_B_" << testNr << ".pcm";
} else {
file_stream_a << "outA_" << testNr << ".pcm";
file_stream_b << "outB_" << testNr << ".pcm";
}
file_name_out = file_stream_a.str();
_outFileA.Open(file_name_out, 32000, "wb");
file_name_out = file_stream_b.str();
_outFileB.Open(file_name_out, 32000, "wb");
CHECK_ERROR(_acmA->RegisterSendCodec(_paramISAC16kHz));
CHECK_ERROR(_acmA->RegisterSendCodec(_paramISAC32kHz));
CHECK_ERROR(_acmB->RegisterSendCodec(_paramISAC32kHz));
CHECK_ERROR(_acmB->RegisterSendCodec(_paramISAC16kHz));
if (_testMode != 0) {
printf("Side A Sending Super-Wideband \n");
printf("Side B Sending Wideband\n\n");
}
EXPECT_EQ(0, _acmA->RegisterSendCodec(_paramISAC16kHz));
EXPECT_EQ(0, _acmA->RegisterSendCodec(_paramISAC32kHz));
EXPECT_EQ(0, _acmB->RegisterSendCodec(_paramISAC32kHz));
EXPECT_EQ(0, _acmB->RegisterSendCodec(_paramISAC16kHz));
// Side A is sending super-wideband, and side B is sending wideband.
SetISAConfig(swbISACConfig, _acmA, _testMode);
SetISAConfig(wbISACConfig, _acmB, _testMode);
@ -371,27 +301,18 @@ void ISACTest::EncodeDecode(int testNr, ACMTestISACConfig& wbISACConfig,
_channel_B2A->ResetStats();
char currentTime[500];
if (_testMode == 2)
printf("\n");
CodecInst sendCodec;
EventWrapper* myEvent = EventWrapper::Create();
myEvent->StartTimer(true, 10);
EXPECT_TRUE(myEvent->StartTimer(true, 10));
while (!(_inFileA.EndOfFile() || _inFileA.Rewinded())) {
Run10ms();
_myTimer.Tick10ms();
_myTimer.CurrentTimeHMS(currentTime);
if (_testMode == 2)
printf("\r%s ", currentTime);
if ((adaptiveMode) && (_testMode != 0)) {
myEvent->Wait(5000);
_acmA->SendCodec(&sendCodec);
if (_testMode == 2)
printf("[%d] ", sendCodec.rate);
_acmB->SendCodec(&sendCodec);
if (_testMode == 2)
printf("[%d] ", sendCodec.rate);
EXPECT_EQ(0, _acmA->SendCodec(&sendCodec));
EXPECT_EQ(0, _acmB->SendCodec(&sendCodec));
}
}
@ -406,8 +327,6 @@ void ISACTest::EncodeDecode(int testNr, ACMTestISACConfig& wbISACConfig,
_channel_A2B->ResetStats();
_channel_B2A->ResetStats();
if (_testMode != 0)
printf("\n");
_outFileA.Close();
_outFileB.Close();
_inFileA.Close();
@ -424,26 +343,17 @@ void ISACTest::SwitchingSamplingRate(int testNr, int maxSampRateChange) {
std::stringstream file_stream_b;
file_stream_a << webrtc::test::OutputPath();
file_stream_b << webrtc::test::OutputPath();
if (_testMode == 0) {
file_stream_a << "out_iSACTest_A_" << testNr << ".pcm";
file_stream_b << "out_iSACTest_B_" << testNr << ".pcm";
} else {
printf("\nTest %d", testNr);
printf(" Alternate between WB and SWB at the sender Side\n\n");
file_stream_a << "outA_" << testNr << ".pcm";
file_stream_b << "outB_" << testNr << ".pcm";
}
file_name_out = file_stream_a.str();
_outFileA.Open(file_name_out, 32000, "wb");
file_name_out = file_stream_b.str();
_outFileB.Open(file_name_out, 32000, "wb");
CHECK_ERROR(_acmA->RegisterSendCodec(_paramISAC32kHz));
CHECK_ERROR(_acmB->RegisterSendCodec(_paramISAC16kHz));
if (_testMode != 0) {
printf("Side A Sending Super-Wideband \n");
printf("Side B Sending Wideband\n");
}
// Start with side A sending super-wideband and side B seding wideband.
// Toggle sending wideband/super-wideband in this test.
EXPECT_EQ(0, _acmA->RegisterSendCodec(_paramISAC32kHz));
EXPECT_EQ(0, _acmB->RegisterSendCodec(_paramISAC16kHz));
int numSendCodecChanged = 0;
_myTimer.Reset();
@ -456,34 +366,30 @@ void ISACTest::SwitchingSamplingRate(int testNr, int maxSampRateChange) {
printf("\r%s", currentTime);
if (_inFileA.EndOfFile()) {
if (_inFileA.SamplingFrequency() == 16000) {
if (_testMode != 0)
printf("\nSide A switched to Send Super-Wideband\n");
// Switch side A to send super-wideband.
_inFileA.Close();
_inFileA.Open(file_name_swb_, 32000, "rb");
CHECK_ERROR(_acmA->RegisterSendCodec(_paramISAC32kHz));
EXPECT_EQ(0, _acmA->RegisterSendCodec(_paramISAC32kHz));
} else {
if (_testMode != 0)
printf("\nSide A switched to Send Wideband\n");
// Switch side A to send wideband.
_inFileA.Close();
_inFileA.Open(file_name_swb_, 32000, "rb");
CHECK_ERROR(_acmA->RegisterSendCodec(_paramISAC16kHz));
EXPECT_EQ(0, _acmA->RegisterSendCodec(_paramISAC16kHz));
}
numSendCodecChanged++;
}
if (_inFileB.EndOfFile()) {
if (_inFileB.SamplingFrequency() == 16000) {
if (_testMode != 0)
printf("\nSide B switched to Send Super-Wideband\n");
// Switch side B to send super-wideband.
_inFileB.Close();
_inFileB.Open(file_name_swb_, 32000, "rb");
CHECK_ERROR(_acmB->RegisterSendCodec(_paramISAC32kHz));
EXPECT_EQ(0, _acmB->RegisterSendCodec(_paramISAC32kHz));
} else {
if (_testMode != 0)
printf("\nSide B switched to Send Wideband\n");
// Switch side B to send wideband.
_inFileB.Close();
_inFileB.Open(file_name_swb_, 32000, "rb");
CHECK_ERROR(_acmB->RegisterSendCodec(_paramISAC16kHz));
EXPECT_EQ(0, _acmB->RegisterSendCodec(_paramISAC16kHz));
}
numSendCodecChanged++;
}

View File

@ -43,17 +43,13 @@ class ISACTest : public ACMTest {
void Perform();
private:
int16_t Setup();
int16_t SetupConference();
int16_t RunConference();
void Setup();
void Run10ms();
void EncodeDecode(int testNr, ACMTestISACConfig& wbISACConfig,
ACMTestISACConfig& swbISACConfig);
void TestBWE(int testNr);
void SwitchingSamplingRate(int testNr, int maxSampRateChange);
AudioCodingModule* _acmA;
@ -77,16 +73,6 @@ class ISACTest : public ACMTest {
ACMTestTimer _myTimer;
int _testMode;
AudioCodingModule* _defaultACM32;
AudioCodingModule* _defaultACM16;
AudioCodingModule* _confACM[NO_OF_CLIENTS];
AudioCodingModule* _clientACM[NO_OF_CLIENTS];
Channel* _conf2Client[NO_OF_CLIENTS];
Channel* _client2Conf[NO_OF_CLIENTS];
PCMFile _clientOutFile[NO_OF_CLIENTS];
};
} // namespace webrtc

View File

@ -217,6 +217,15 @@ int WebRtcNetEQ_DbAdd(CodecDbInst_t *inst, enum WebRtcNetEQDecoder codec,
/* find the appropriate insert position in CNG payload vector */
switch (codec_fs)
{
case 8000:
CNGpos = 0;
/*
* The 8 kHz CNG payload type is the one associated with the regular codec DB
* should override any other setting.
* Overwrite if this isn't the first CNG
*/
overwriteCNGcodec = !insertCNGcodec;
break;
#ifdef NETEQ_WIDEBAND
case 16000:
CNGpos = 1;
@ -232,15 +241,9 @@ int WebRtcNetEQ_DbAdd(CodecDbInst_t *inst, enum WebRtcNetEQDecoder codec,
CNGpos = 3;
break;
#endif
default: /* 8000 Hz case */
CNGpos = 0;
/*
* The 8 kHz CNG payload type is the one associated with the regular codec DB
* should override any other setting.
* Overwrite if this isn't the first CNG
*/
overwriteCNGcodec = !insertCNGcodec;
break;
default:
/* If we get to this point, the inserted codec is not supported */
return CODEC_DB_UNSUPPORTED_CODEC;
}
/* insert CNG payload type */