- Remove unused unit test webrtc/modules/audio_processing/agc/agc_unittest.cc
- Remove webrtc/tools/agc/test_utils.cc/.h - only used from the above test. - Remove webrtc/tools/agc/agc_harness.cc - not used anymore. BUG=webrtc:4690 Review-Url: https://codereview.webrtc.org/2299023004 Cr-Commit-Position: refs/heads/master@{#14039}
This commit is contained in:
parent
bca69e87de
commit
f383c5754f
@ -317,9 +317,6 @@ if (rtc_include_tests) {
|
||||
"audio_processing/aec/echo_cancellation_unittest.cc",
|
||||
"audio_processing/aec/system_delay_unittest.cc",
|
||||
"audio_processing/agc/agc_manager_direct_unittest.cc",
|
||||
|
||||
# TODO(ajm): Fix to match new interface.
|
||||
# "audio_processing/agc/agc_unittest.cc",
|
||||
"audio_processing/agc/loudness_histogram_unittest.cc",
|
||||
"audio_processing/agc/mock_agc.h",
|
||||
"audio_processing/audio_buffer_unittest.cc",
|
||||
@ -598,7 +595,6 @@ if (rtc_include_tests) {
|
||||
"../test:test_support_main",
|
||||
"../test:test_support_main",
|
||||
"../test:video_test_common",
|
||||
"../tools:agc_test_utils",
|
||||
"audio_coding",
|
||||
"audio_coding:acm_receive_test",
|
||||
"audio_coding:acm_send_test",
|
||||
|
||||
@ -1,162 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license
|
||||
* that can be found in the LICENSE file in the root of the source
|
||||
* tree. An additional intellectual property rights grant can be found
|
||||
* in the file PATENTS. All contributing project authors may
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
#include "webrtc/modules/audio_processing/agc/agc.h"
|
||||
|
||||
#include "testing/gmock/include/gmock/gmock.h"
|
||||
#include "testing/gtest/include/gtest/gtest.h"
|
||||
|
||||
#include "webrtc/modules/include/module_common_types.h"
|
||||
#include "webrtc/test/testsupport/fileutils.h"
|
||||
#include "webrtc/tools/agc/test_utils.h"
|
||||
|
||||
using ::testing::_;
|
||||
using ::testing::AllOf;
|
||||
using ::testing::AtLeast;
|
||||
using ::testing::Eq;
|
||||
using ::testing::Gt;
|
||||
using ::testing::InSequence;
|
||||
using ::testing::Lt;
|
||||
using ::testing::Mock;
|
||||
using ::testing::SaveArg;
|
||||
|
||||
namespace webrtc {
|
||||
namespace {
|
||||
|
||||
// The tested values depend on this assumed gain.
|
||||
const int kMaxGain = 80;
|
||||
|
||||
MATCHER_P(GtPointee, p, "") { return arg > *p; }
|
||||
MATCHER_P(LtPointee, p, "") { return arg < *p; }
|
||||
|
||||
class AgcChecker {
|
||||
public:
|
||||
MOCK_METHOD2(LevelChanged, void(int iterations, int level));
|
||||
};
|
||||
|
||||
class AgcTest : public ::testing::Test {
|
||||
protected:
|
||||
AgcTest()
|
||||
: agc_(),
|
||||
checker_(),
|
||||
mic_level_(128) {
|
||||
}
|
||||
|
||||
// A gain of <= -100 will zero out the signal.
|
||||
void RunAgc(int iterations, float gain_db) {
|
||||
FILE* input_file = fopen(
|
||||
test::ResourcePath("voice_engine/audio_long16", "pcm").c_str(), "rb");
|
||||
ASSERT_TRUE(input_file != NULL);
|
||||
|
||||
AudioFrame frame;
|
||||
frame.sample_rate_hz_ = 16000;
|
||||
frame.num_channels_ = 1;
|
||||
frame.samples_per_channel_ = frame.sample_rate_hz_ / 100;
|
||||
const size_t length = frame.samples_per_channel_ * frame.num_channels_;
|
||||
|
||||
float gain = Db2Linear(gain_db);
|
||||
if (gain_db <= -100) {
|
||||
gain = 0;
|
||||
}
|
||||
|
||||
for (int i = 0; i < iterations; ++i) {
|
||||
ASSERT_EQ(length, fread(frame.data_, sizeof(int16_t), length,
|
||||
input_file));
|
||||
SimulateMic(kMaxGain, mic_level_, &frame);
|
||||
ApplyGainLinear(gain, &frame);
|
||||
ASSERT_GE(agc_.Process(frame), 0);
|
||||
|
||||
int mic_level = agc_.MicLevel();
|
||||
if (mic_level != mic_level_) {
|
||||
printf("mic_level=%d\n", mic_level);
|
||||
checker_.LevelChanged(i, mic_level);
|
||||
}
|
||||
mic_level_ = mic_level;
|
||||
}
|
||||
fclose(input_file);
|
||||
}
|
||||
|
||||
Agc agc_;
|
||||
AgcChecker checker_;
|
||||
// Stores mic level between multiple runs of RunAgc in one test.
|
||||
int mic_level_;
|
||||
};
|
||||
|
||||
TEST_F(AgcTest, UpwardsChangeIsLimited) {
|
||||
{
|
||||
InSequence seq;
|
||||
EXPECT_CALL(checker_, LevelChanged(Lt(500), Eq(179))).Times(1);
|
||||
EXPECT_CALL(checker_, LevelChanged(_, Gt(179))).Times(AtLeast(1));
|
||||
}
|
||||
RunAgc(1000, -40);
|
||||
}
|
||||
|
||||
TEST_F(AgcTest, DownwardsChangeIsLimited) {
|
||||
{
|
||||
InSequence seq;
|
||||
EXPECT_CALL(checker_, LevelChanged(Lt(500), Eq(77))).Times(1);
|
||||
EXPECT_CALL(checker_, LevelChanged(_, Lt(77))).Times(AtLeast(1));
|
||||
}
|
||||
RunAgc(1000, 40);
|
||||
}
|
||||
|
||||
TEST_F(AgcTest, MovesUpToMaxAndDownToMin) {
|
||||
int last_level = 128;
|
||||
EXPECT_CALL(checker_, LevelChanged(_, GtPointee(&last_level)))
|
||||
.Times(AtLeast(2))
|
||||
.WillRepeatedly(SaveArg<1>(&last_level));
|
||||
RunAgc(1000, -30);
|
||||
EXPECT_EQ(255, last_level);
|
||||
Mock::VerifyAndClearExpectations(&checker_);
|
||||
|
||||
EXPECT_CALL(checker_, LevelChanged(_, LtPointee(&last_level)))
|
||||
.Times(AtLeast(2))
|
||||
.WillRepeatedly(SaveArg<1>(&last_level));
|
||||
RunAgc(1000, 50);
|
||||
EXPECT_EQ(1, last_level);
|
||||
}
|
||||
|
||||
TEST_F(AgcTest, HandlesZeroSignal) {
|
||||
int last_level = 128;
|
||||
// Doesn't respond to a zero signal.
|
||||
EXPECT_CALL(checker_, LevelChanged(_, _)).Times(0);
|
||||
RunAgc(1000, -100);
|
||||
Mock::VerifyAndClearExpectations(&checker_);
|
||||
|
||||
// Reacts as usual afterwards.
|
||||
EXPECT_CALL(checker_, LevelChanged(_, GtPointee(&last_level)))
|
||||
.Times(AtLeast(2))
|
||||
.WillRepeatedly(SaveArg<1>(&last_level));
|
||||
RunAgc(500, -20);
|
||||
}
|
||||
|
||||
TEST_F(AgcTest, ReachesSteadyState) {
|
||||
int last_level = 128;
|
||||
EXPECT_CALL(checker_, LevelChanged(_, _))
|
||||
.Times(AtLeast(2))
|
||||
.WillRepeatedly(SaveArg<1>(&last_level));
|
||||
RunAgc(1000, -20);
|
||||
Mock::VerifyAndClearExpectations(&checker_);
|
||||
|
||||
// If the level changes, it should be in a narrow band around the previous
|
||||
// adaptation.
|
||||
EXPECT_CALL(checker_, LevelChanged(_,
|
||||
AllOf(Gt(last_level * 0.95), Lt(last_level * 1.05))))
|
||||
.Times(AtLeast(0));
|
||||
RunAgc(1000, -20);
|
||||
}
|
||||
|
||||
// TODO(ajm): Add this test; requires measuring the signal RMS.
|
||||
TEST_F(AgcTest, AdaptsToCorrectRMS) {
|
||||
}
|
||||
|
||||
} // namespace
|
||||
} // namespace webrtc
|
||||
|
||||
@ -163,7 +163,6 @@
|
||||
'<(webrtc_root)/test/test.gyp:rtp_test_utils',
|
||||
'<(webrtc_root)/test/test.gyp:test_support_main',
|
||||
'<(webrtc_root)/test/test.gyp:test_common',
|
||||
'<(webrtc_root)/tools/tools.gyp:agc_test_utils',
|
||||
],
|
||||
'sources': [
|
||||
'audio_coding/acm2/acm_receiver_unittest_oldapi.cc',
|
||||
@ -237,8 +236,6 @@
|
||||
'audio_processing/aec/echo_cancellation_unittest.cc',
|
||||
'audio_processing/aec/system_delay_unittest.cc',
|
||||
'audio_processing/agc/agc_manager_direct_unittest.cc',
|
||||
# TODO(ajm): Fix to match new interface.
|
||||
# 'audio_processing/agc/agc_unittest.cc',
|
||||
'audio_processing/agc/loudness_histogram_unittest.cc',
|
||||
'audio_processing/agc/mock_agc.h',
|
||||
'audio_processing/audio_buffer_unittest.cc',
|
||||
|
||||
@ -164,17 +164,6 @@ executable("force_mic_volume_max") {
|
||||
]
|
||||
}
|
||||
|
||||
source_set("agc_test_utils") {
|
||||
testonly = true
|
||||
sources = [
|
||||
"agc/test_utils.cc",
|
||||
"agc/test_utils.h",
|
||||
]
|
||||
|
||||
configs += [ "..:common_config" ]
|
||||
public_configs = [ "..:common_inherited_config" ]
|
||||
}
|
||||
|
||||
if (rtc_enable_protobuf) {
|
||||
proto_library("graph_proto") {
|
||||
sources = [
|
||||
@ -244,33 +233,6 @@ if (rtc_include_tests) {
|
||||
}
|
||||
}
|
||||
|
||||
executable("agc_harness") {
|
||||
testonly = true
|
||||
sources = [
|
||||
"agc/agc_harness.cc",
|
||||
]
|
||||
|
||||
configs += [ "..:common_config" ]
|
||||
public_configs = [ "..:common_inherited_config" ]
|
||||
|
||||
if (is_clang) {
|
||||
# Suppress warnings from the Chromium Clang plugin.
|
||||
# See http://code.google.com/p/webrtc/issues/detail?id=163 for details.
|
||||
configs -= [ "//build/config/clang:find_bad_constructs" ]
|
||||
}
|
||||
|
||||
deps = [
|
||||
"../system_wrappers:system_wrappers_default",
|
||||
"../test:channel_transport",
|
||||
"../test:test_support",
|
||||
"../voice_engine",
|
||||
"//build/config/sanitizers:deps",
|
||||
"//build/win:default_exe_manifest",
|
||||
"//testing/gtest",
|
||||
"//third_party/gflags",
|
||||
]
|
||||
}
|
||||
|
||||
executable("activity_metric") {
|
||||
testonly = true
|
||||
sources = [
|
||||
|
||||
@ -1,284 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license
|
||||
* that can be found in the LICENSE file in the root of the source
|
||||
* tree. An additional intellectual property rights grant can be found
|
||||
* in the file PATENTS. All contributing project authors may
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
// Refer to kUsage below for a description.
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "gflags/gflags.h"
|
||||
#include "webrtc/base/checks.h"
|
||||
#include "webrtc/base/format_macros.h"
|
||||
#include "webrtc/system_wrappers/include/sleep.h"
|
||||
#include "webrtc/system_wrappers/include/trace.h"
|
||||
#include "webrtc/test/channel_transport/channel_transport.h"
|
||||
#include "webrtc/test/testsupport/trace_to_stderr.h"
|
||||
#include "webrtc/modules/audio_processing/include/audio_processing.h"
|
||||
#include "webrtc/voice_engine/include/voe_audio_processing.h"
|
||||
#include "webrtc/voice_engine/include/voe_base.h"
|
||||
#include "webrtc/voice_engine/include/voe_codec.h"
|
||||
#include "webrtc/voice_engine/include/voe_external_media.h"
|
||||
#include "webrtc/voice_engine/include/voe_file.h"
|
||||
#include "webrtc/voice_engine/include/voe_hardware.h"
|
||||
#include "webrtc/voice_engine/include/voe_network.h"
|
||||
#include "webrtc/voice_engine/include/voe_volume_control.h"
|
||||
|
||||
DEFINE_bool(codecs, false, "print out available codecs");
|
||||
DEFINE_int32(pt, 120, "codec payload type (defaults to opus/48000/2)");
|
||||
DEFINE_bool(legacy_agc,
|
||||
false,
|
||||
"use the legacy AGC in 'serial' mode, or as the first voice "
|
||||
"engine's AGC in parallel mode");
|
||||
DEFINE_bool(parallel,
|
||||
false,
|
||||
"run new and legacy AGCs in parallel, with left- and right-panning "
|
||||
"respectively. Not compatible with -aec.");
|
||||
DEFINE_bool(devices, false, "print out capture devices and indexes to be used "
|
||||
"with the capture flags");
|
||||
DEFINE_int32(capture1, 0, "capture device index for the first voice engine");
|
||||
DEFINE_int32(capture2, 0, "capture device index for second voice engine");
|
||||
DEFINE_int32(render1, 0, "render device index for first voice engine");
|
||||
DEFINE_int32(render2, 0, "render device index for second voice engine");
|
||||
DEFINE_bool(aec,
|
||||
false,
|
||||
"runs two voice engines in parallel, with the first playing out a "
|
||||
"file and sending its captured signal to the second voice engine. "
|
||||
"Also enables echo cancellation.");
|
||||
DEFINE_bool(ns, true, "enable noise suppression");
|
||||
DEFINE_bool(highpass, true, "enable high pass filter");
|
||||
DEFINE_string(filename, "", "filename for the -aec mode");
|
||||
|
||||
namespace webrtc {
|
||||
namespace {
|
||||
|
||||
const char kUsage[] =
|
||||
"\nWithout additional flags, sets up a simple VoiceEngine loopback call\n"
|
||||
"with the default audio devices and runs forever.\n"
|
||||
|
||||
"It can also run the new and legacy AGCs in parallel, panned to\n"
|
||||
"opposite stereo channels on the default render device. The capture\n"
|
||||
"devices for each can be selected (recommended, because otherwise they\n"
|
||||
"will fight for the level on the same device).\n\n"
|
||||
|
||||
"Lastly, it can be used for local AEC testing. In this mode, the first\n"
|
||||
"voice engine plays out a file over the selected render device (normally\n"
|
||||
"loudspeakers) and records from the selected capture device. The second\n"
|
||||
"voice engine receives the capture signal and plays it out over the\n"
|
||||
"selected render device (normally headphones). This allows the user to\n"
|
||||
"test an echo scenario with the first voice engine, while monitoring the\n"
|
||||
"result with the second.";
|
||||
|
||||
class AgcVoiceEngine {
|
||||
public:
|
||||
enum Pan {
|
||||
NoPan,
|
||||
PanLeft,
|
||||
PanRight
|
||||
};
|
||||
|
||||
AgcVoiceEngine(bool legacy_agc,
|
||||
int tx_port,
|
||||
int rx_port,
|
||||
int capture_idx,
|
||||
int render_idx)
|
||||
: voe_(VoiceEngine::Create()),
|
||||
base_(VoEBase::GetInterface(voe_)),
|
||||
hardware_(VoEHardware::GetInterface(voe_)),
|
||||
codec_(VoECodec::GetInterface(voe_)),
|
||||
channel_(-1),
|
||||
capture_idx_(capture_idx),
|
||||
render_idx_(render_idx) {
|
||||
SetUp(legacy_agc, tx_port, rx_port);
|
||||
}
|
||||
|
||||
~AgcVoiceEngine() {
|
||||
TearDown();
|
||||
}
|
||||
|
||||
void SetUp(bool legacy_agc, int tx_port, int rx_port) {
|
||||
VoEAudioProcessing* audio = VoEAudioProcessing::GetInterface(voe_);
|
||||
VoENetwork* network = VoENetwork::GetInterface(voe_);
|
||||
{
|
||||
webrtc::Config config;
|
||||
config.Set<ExperimentalAgc>(new ExperimentalAgc(!legacy_agc));
|
||||
AudioProcessing* audioproc = AudioProcessing::Create(config);
|
||||
RTC_CHECK_EQ(0, base_->Init(nullptr, audioproc));
|
||||
// Set this stuff after Init, to override the default voice engine
|
||||
// settings.
|
||||
audioproc->gain_control()->Enable(true);
|
||||
audioproc->high_pass_filter()->Enable(FLAGS_highpass);
|
||||
audioproc->noise_suppression()->Enable(FLAGS_ns);
|
||||
audioproc->echo_cancellation()->Enable(FLAGS_aec);
|
||||
}
|
||||
channel_ = base_->CreateChannel();
|
||||
RTC_CHECK_NE(-1, channel_);
|
||||
|
||||
channel_transport_.reset(
|
||||
new test::VoiceChannelTransport(network, channel_));
|
||||
RTC_CHECK_EQ(0,
|
||||
channel_transport_->SetSendDestination("127.0.0.1", tx_port));
|
||||
RTC_CHECK_EQ(0, channel_transport_->SetLocalReceiver(rx_port));
|
||||
|
||||
RTC_CHECK_EQ(0, hardware_->SetRecordingDevice(capture_idx_));
|
||||
RTC_CHECK_EQ(0, hardware_->SetPlayoutDevice(render_idx_));
|
||||
|
||||
CodecInst codec_params = {};
|
||||
bool codec_found = false;
|
||||
for (int i = 0; i < codec_->NumOfCodecs(); i++) {
|
||||
RTC_CHECK_EQ(0, codec_->GetCodec(i, codec_params));
|
||||
if (FLAGS_pt == codec_params.pltype) {
|
||||
codec_found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
RTC_CHECK(codec_found);
|
||||
RTC_CHECK_EQ(0, codec_->SetSendCodec(channel_, codec_params));
|
||||
|
||||
audio->Release();
|
||||
network->Release();
|
||||
}
|
||||
|
||||
void TearDown() {
|
||||
Stop();
|
||||
channel_transport_.reset(nullptr);
|
||||
RTC_CHECK_EQ(0, base_->DeleteChannel(channel_));
|
||||
RTC_CHECK_EQ(0, base_->Terminate());
|
||||
hardware_->Release();
|
||||
base_->Release();
|
||||
codec_->Release();
|
||||
RTC_CHECK(VoiceEngine::Delete(voe_));
|
||||
}
|
||||
|
||||
void PrintDevices() {
|
||||
int num_devices = 0;
|
||||
char device_name[128] = {0};
|
||||
char guid[128] = {0};
|
||||
RTC_CHECK_EQ(0, hardware_->GetNumOfRecordingDevices(num_devices));
|
||||
printf("Capture devices:\n");
|
||||
for (int i = 0; i < num_devices; i++) {
|
||||
RTC_CHECK_EQ(0, hardware_->GetRecordingDeviceName(i, device_name, guid));
|
||||
printf("%d: %s\n", i, device_name);
|
||||
}
|
||||
RTC_CHECK_EQ(0, hardware_->GetNumOfPlayoutDevices(num_devices));
|
||||
printf("Render devices:\n");
|
||||
for (int i = 0; i < num_devices; i++) {
|
||||
RTC_CHECK_EQ(0, hardware_->GetPlayoutDeviceName(i, device_name, guid));
|
||||
printf("%d: %s\n", i, device_name);
|
||||
}
|
||||
}
|
||||
|
||||
void PrintCodecs() {
|
||||
CodecInst params = {0};
|
||||
printf("Codecs:\n");
|
||||
for (int i = 0; i < codec_->NumOfCodecs(); i++) {
|
||||
RTC_CHECK_EQ(0, codec_->GetCodec(i, params));
|
||||
printf("%d %s/%d/%" PRIuS "\n", params.pltype, params.plname,
|
||||
params.plfreq, params.channels);
|
||||
}
|
||||
}
|
||||
|
||||
void StartSending() { RTC_CHECK_EQ(0, base_->StartSend(channel_)); }
|
||||
|
||||
void StartPlaying(Pan pan, const std::string& filename) {
|
||||
VoEVolumeControl* volume = VoEVolumeControl::GetInterface(voe_);
|
||||
VoEFile* file = VoEFile::GetInterface(voe_);
|
||||
if (pan == PanLeft) {
|
||||
volume->SetOutputVolumePan(channel_, 1, 0);
|
||||
} else if (pan == PanRight) {
|
||||
volume->SetOutputVolumePan(channel_, 0, 1);
|
||||
}
|
||||
if (filename != "") {
|
||||
printf("playing file\n");
|
||||
RTC_CHECK_EQ(
|
||||
0, file->StartPlayingFileLocally(channel_, filename.c_str(), true,
|
||||
kFileFormatPcm16kHzFile, 1.0, 0, 0));
|
||||
}
|
||||
RTC_CHECK_EQ(0, base_->StartReceive(channel_));
|
||||
RTC_CHECK_EQ(0, base_->StartPlayout(channel_));
|
||||
volume->Release();
|
||||
file->Release();
|
||||
}
|
||||
|
||||
void Stop() {
|
||||
RTC_CHECK_EQ(0, base_->StopSend(channel_));
|
||||
RTC_CHECK_EQ(0, base_->StopPlayout(channel_));
|
||||
}
|
||||
|
||||
private:
|
||||
VoiceEngine* voe_;
|
||||
VoEBase* base_;
|
||||
VoEHardware* hardware_;
|
||||
VoECodec* codec_;
|
||||
int channel_;
|
||||
int capture_idx_;
|
||||
int render_idx_;
|
||||
std::unique_ptr<test::VoiceChannelTransport> channel_transport_;
|
||||
};
|
||||
|
||||
void RunHarness() {
|
||||
std::unique_ptr<AgcVoiceEngine> voe1(new AgcVoiceEngine(
|
||||
FLAGS_legacy_agc, 2000, 2000, FLAGS_capture1, FLAGS_render1));
|
||||
std::unique_ptr<AgcVoiceEngine> voe2;
|
||||
if (FLAGS_parallel) {
|
||||
voe2.reset(new AgcVoiceEngine(!FLAGS_legacy_agc, 3000, 3000, FLAGS_capture2,
|
||||
FLAGS_render2));
|
||||
voe1->StartPlaying(AgcVoiceEngine::PanLeft, "");
|
||||
voe1->StartSending();
|
||||
voe2->StartPlaying(AgcVoiceEngine::PanRight, "");
|
||||
voe2->StartSending();
|
||||
} else if (FLAGS_aec) {
|
||||
voe1.reset(new AgcVoiceEngine(FLAGS_legacy_agc, 2000, 4242, FLAGS_capture1,
|
||||
FLAGS_render1));
|
||||
voe2.reset(new AgcVoiceEngine(!FLAGS_legacy_agc, 4242, 2000, FLAGS_capture2,
|
||||
FLAGS_render2));
|
||||
voe1->StartPlaying(AgcVoiceEngine::NoPan, FLAGS_filename);
|
||||
voe1->StartSending();
|
||||
voe2->StartPlaying(AgcVoiceEngine::NoPan, "");
|
||||
} else {
|
||||
voe1->StartPlaying(AgcVoiceEngine::NoPan, "");
|
||||
voe1->StartSending();
|
||||
}
|
||||
|
||||
// Run forever...
|
||||
SleepMs(0x7fffffff);
|
||||
}
|
||||
|
||||
void PrintDevices() {
|
||||
AgcVoiceEngine device_voe(false, 4242, 4242, 0, 0);
|
||||
device_voe.PrintDevices();
|
||||
}
|
||||
|
||||
void PrintCodecs() {
|
||||
AgcVoiceEngine codec_voe(false, 4242, 4242, 0, 0);
|
||||
codec_voe.PrintCodecs();
|
||||
}
|
||||
|
||||
} // namespace
|
||||
} // namespace webrtc
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
google::SetUsageMessage(webrtc::kUsage);
|
||||
google::ParseCommandLineFlags(&argc, &argv, true);
|
||||
webrtc::test::TraceToStderr trace_to_stderr;
|
||||
|
||||
if (FLAGS_parallel && FLAGS_aec) {
|
||||
printf("-parallel and -aec are not compatible\n");
|
||||
return 1;
|
||||
}
|
||||
if (FLAGS_devices) {
|
||||
webrtc::PrintDevices();
|
||||
}
|
||||
if (FLAGS_codecs) {
|
||||
webrtc::PrintCodecs();
|
||||
}
|
||||
if (!FLAGS_devices && !FLAGS_codecs) {
|
||||
webrtc::RunHarness();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@ -1,64 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license
|
||||
* that can be found in the LICENSE file in the root of the source
|
||||
* tree. An additional intellectual property rights grant can be found
|
||||
* in the file PATENTS. All contributing project authors may
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
#include "webrtc/tools/agc/test_utils.h"
|
||||
|
||||
#include <cmath>
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
#include "webrtc/modules/include/module_common_types.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
float MicLevel2Gain(int gain_range_db, int level) {
|
||||
return (level - 127.0f) / 128.0f * gain_range_db / 2;
|
||||
}
|
||||
|
||||
float Db2Linear(float db) {
|
||||
return powf(10.0f, db / 20.0f);
|
||||
}
|
||||
|
||||
void ApplyGainLinear(float gain, float last_gain, AudioFrame* frame) {
|
||||
const size_t frame_length =
|
||||
frame->samples_per_channel_ * frame->num_channels_;
|
||||
// Smooth the transition between gain levels across the frame.
|
||||
float smoothed_gain = last_gain;
|
||||
float gain_step = (gain - last_gain) / (frame_length - 1);
|
||||
for (size_t i = 0; i < frame_length; ++i) {
|
||||
smoothed_gain += gain_step;
|
||||
float sample = std::floor(frame->data_[i] * smoothed_gain + 0.5);
|
||||
sample = std::max(std::min(32767.0f, sample), -32768.0f);
|
||||
frame->data_[i] = static_cast<int16_t>(sample);
|
||||
}
|
||||
}
|
||||
|
||||
void ApplyGain(float gain_db, float last_gain_db, AudioFrame* frame) {
|
||||
ApplyGainLinear(Db2Linear(gain_db), Db2Linear(last_gain_db), frame);
|
||||
}
|
||||
|
||||
void SimulateMic(int gain_range_db, int mic_level, int last_mic_level,
|
||||
AudioFrame* frame) {
|
||||
assert(mic_level >= 0 && mic_level <= 255);
|
||||
assert(last_mic_level >= 0 && last_mic_level <= 255);
|
||||
ApplyGain(MicLevel2Gain(gain_range_db, mic_level),
|
||||
MicLevel2Gain(gain_range_db, last_mic_level),
|
||||
frame);
|
||||
}
|
||||
|
||||
void SimulateMic(int gain_map[255], int mic_level, int last_mic_level,
|
||||
AudioFrame* frame) {
|
||||
assert(mic_level >= 0 && mic_level <= 255);
|
||||
assert(last_mic_level >= 0 && last_mic_level <= 255);
|
||||
ApplyGain(gain_map[mic_level], gain_map[last_mic_level], frame);
|
||||
}
|
||||
|
||||
} // namespace webrtc
|
||||
|
||||
@ -1,28 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license
|
||||
* that can be found in the LICENSE file in the root of the source
|
||||
* tree. An additional intellectual property rights grant can be found
|
||||
* in the file PATENTS. All contributing project authors may
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
#ifndef WEBRTC_TOOLS_AGC_TEST_UTILS_H_
|
||||
#define WEBRTC_TOOLS_AGC_TEST_UTILS_H_
|
||||
namespace webrtc {
|
||||
|
||||
class AudioFrame;
|
||||
|
||||
float MicLevel2Gain(int gain_range_db, int level);
|
||||
float Db2Linear(float db);
|
||||
void ApplyGainLinear(float gain, float last_gain, AudioFrame* frame);
|
||||
void ApplyGain(float gain_db, float last_gain_db, AudioFrame* frame);
|
||||
void SimulateMic(int gain_range_db, int mic_level, int last_mic_level,
|
||||
AudioFrame* frame);
|
||||
void SimulateMic(int gain_map[255], int mic_level, int last_mic_level,
|
||||
AudioFrame* frame);
|
||||
|
||||
} // namespace webrtc
|
||||
|
||||
#endif // WEBRTC_TOOLS_AGC_TEST_UTILS_H_
|
||||
@ -164,29 +164,6 @@
|
||||
}],
|
||||
['include_tests==1', {
|
||||
'targets' : [
|
||||
{
|
||||
'target_name': 'agc_test_utils',
|
||||
'type': 'static_library',
|
||||
'sources': [
|
||||
'agc/test_utils.cc',
|
||||
'agc/test_utils.h',
|
||||
],
|
||||
},
|
||||
{
|
||||
'target_name': 'agc_harness',
|
||||
'type': 'executable',
|
||||
'dependencies': [
|
||||
'<(DEPTH)/testing/gtest.gyp:gtest',
|
||||
'<(DEPTH)/third_party/gflags/gflags.gyp:gflags',
|
||||
'<(webrtc_root)/system_wrappers/system_wrappers.gyp:system_wrappers_default',
|
||||
'<(webrtc_root)/test/test.gyp:channel_transport',
|
||||
'<(webrtc_root)/test/test.gyp:test_support',
|
||||
'<(webrtc_root)/voice_engine/voice_engine.gyp:voice_engine',
|
||||
],
|
||||
'sources': [
|
||||
'agc/agc_harness.cc',
|
||||
],
|
||||
}, # agc_harness
|
||||
{
|
||||
'target_name': 'activity_metric',
|
||||
'type': 'executable',
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user