diff --git a/DEPS b/DEPS index d874da27b0..84596d5c0d 100644 --- a/DEPS +++ b/DEPS @@ -21,6 +21,9 @@ deps = { "tools/gyp": "http://gyp.googlecode.com/svn/trunk@930", + "third_party/protobuf/": + Var("chromium_trunk") + "/src/third_party/protobuf@" + Var("chromium_revision"), + "third_party/libvpx/": "git://review.webmproject.org/libvpx.git@v0.9.6", diff --git a/modules/audio_processing/main/apm_tests.gyp b/modules/audio_processing/main/apm_tests.gyp index 24cd5f1b95..441abebb49 100644 --- a/modules/audio_processing/main/apm_tests.gyp +++ b/modules/audio_processing/main/apm_tests.gyp @@ -21,13 +21,15 @@ '../../../../testing/gtest.gyp:gtest', '../../../../testing/gtest.gyp:gtest_main', + '../../../../third_party/protobuf/protobuf.gyp:protobuf_lite', ], 'include_dirs': [ '../../../../testing/gtest/include', ], 'sources': [ 'test/unit_test/unit_test.cc', - 'test/unit_test/unit_test.h', + 'test/unit_test/audio_processing_unittest.pb.cc', + 'test/unit_test/audio_processing_unittest.pb.h', ], }, { diff --git a/modules/audio_processing/main/test/unit_test/audio_processing_unittest.pb.cc b/modules/audio_processing/main/test/unit_test/audio_processing_unittest.pb.cc new file mode 100644 index 0000000000..c82ffdb43e --- /dev/null +++ b/modules/audio_processing/main/test/unit_test/audio_processing_unittest.pb.cc @@ -0,0 +1,1111 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! + +#define INTERNAL_SUPPRESS_PROTOBUF_FIELD_DEPRECATION +#include "audio_processing_unittest.pb.h" + +#include + +#include +#include +#include +// @@protoc_insertion_point(includes) + +namespace audio_processing_unittest { + +void protobuf_ShutdownFile_audio_5fprocessing_5funittest_2eproto() { + delete Test::default_instance_; + delete Test_Statistic::default_instance_; + delete Test_EchoMetrics::default_instance_; + delete OutputData::default_instance_; +} + +void protobuf_AddDesc_audio_5fprocessing_5funittest_2eproto() { + static bool already_here = false; + if (already_here) return; + already_here = true; + GOOGLE_PROTOBUF_VERIFY_VERSION; + + Test::default_instance_ = new Test(); + Test_Statistic::default_instance_ = new Test_Statistic(); + Test_EchoMetrics::default_instance_ = new Test_EchoMetrics(); + OutputData::default_instance_ = new OutputData(); + Test::default_instance_->InitAsDefaultInstance(); + Test_Statistic::default_instance_->InitAsDefaultInstance(); + Test_EchoMetrics::default_instance_->InitAsDefaultInstance(); + OutputData::default_instance_->InitAsDefaultInstance(); + ::google::protobuf::internal::OnShutdown(&protobuf_ShutdownFile_audio_5fprocessing_5funittest_2eproto); +} + +// Force AddDescriptors() to be called at static initialization time. +struct StaticDescriptorInitializer_audio_5fprocessing_5funittest_2eproto { + StaticDescriptorInitializer_audio_5fprocessing_5funittest_2eproto() { + protobuf_AddDesc_audio_5fprocessing_5funittest_2eproto(); + } +} static_descriptor_initializer_audio_5fprocessing_5funittest_2eproto_; + + +// =================================================================== + +#ifndef _MSC_VER +const int Test_Statistic::kInstantFieldNumber; +const int Test_Statistic::kAverageFieldNumber; +const int Test_Statistic::kMaximumFieldNumber; +const int Test_Statistic::kMinimumFieldNumber; +#endif // !_MSC_VER + +Test_Statistic::Test_Statistic() + : ::google::protobuf::MessageLite() { + SharedCtor(); +} + +void Test_Statistic::InitAsDefaultInstance() { +} + +Test_Statistic::Test_Statistic(const Test_Statistic& from) + : ::google::protobuf::MessageLite() { + SharedCtor(); + MergeFrom(from); +} + +void Test_Statistic::SharedCtor() { + _cached_size_ = 0; + instant_ = 0; + average_ = 0; + maximum_ = 0; + minimum_ = 0; + ::memset(_has_bits_, 0, sizeof(_has_bits_)); +} + +Test_Statistic::~Test_Statistic() { + SharedDtor(); +} + +void Test_Statistic::SharedDtor() { + if (this != default_instance_) { + } +} + +void Test_Statistic::SetCachedSize(int size) const { + GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); + _cached_size_ = size; + GOOGLE_SAFE_CONCURRENT_WRITES_END(); +} +const Test_Statistic& Test_Statistic::default_instance() { + if (default_instance_ == NULL) protobuf_AddDesc_audio_5fprocessing_5funittest_2eproto(); return *default_instance_; +} + +Test_Statistic* Test_Statistic::default_instance_ = NULL; + +Test_Statistic* Test_Statistic::New() const { + return new Test_Statistic; +} + +void Test_Statistic::Clear() { + if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) { + instant_ = 0; + average_ = 0; + maximum_ = 0; + minimum_ = 0; + } + ::memset(_has_bits_, 0, sizeof(_has_bits_)); +} + +bool Test_Statistic::MergePartialFromCodedStream( + ::google::protobuf::io::CodedInputStream* input) { +#define DO_(EXPRESSION) if (!(EXPRESSION)) return false + ::google::protobuf::uint32 tag; + while ((tag = input->ReadTag()) != 0) { + switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { + // optional int32 instant = 1; + case 1: { + if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == + ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) { + DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< + ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>( + input, &instant_))); + set_has_instant(); + } else { + goto handle_uninterpreted; + } + if (input->ExpectTag(16)) goto parse_average; + break; + } + + // optional int32 average = 2; + case 2: { + if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == + ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) { + parse_average: + DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< + ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>( + input, &average_))); + set_has_average(); + } else { + goto handle_uninterpreted; + } + if (input->ExpectTag(24)) goto parse_maximum; + break; + } + + // optional int32 maximum = 3; + case 3: { + if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == + ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) { + parse_maximum: + DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< + ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>( + input, &maximum_))); + set_has_maximum(); + } else { + goto handle_uninterpreted; + } + if (input->ExpectTag(32)) goto parse_minimum; + break; + } + + // optional int32 minimum = 4; + case 4: { + if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == + ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) { + parse_minimum: + DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< + ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>( + input, &minimum_))); + set_has_minimum(); + } else { + goto handle_uninterpreted; + } + if (input->ExpectAtEnd()) return true; + break; + } + + default: { + handle_uninterpreted: + if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == + ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) { + return true; + } + DO_(::google::protobuf::internal::WireFormatLite::SkipField(input, tag, NULL)); + break; + } + } + } + return true; +#undef DO_ +} + +void Test_Statistic::SerializeWithCachedSizes( + ::google::protobuf::io::CodedOutputStream* output) const { + // optional int32 instant = 1; + if (has_instant()) { + ::google::protobuf::internal::WireFormatLite::WriteInt32(1, this->instant(), output); + } + + // optional int32 average = 2; + if (has_average()) { + ::google::protobuf::internal::WireFormatLite::WriteInt32(2, this->average(), output); + } + + // optional int32 maximum = 3; + if (has_maximum()) { + ::google::protobuf::internal::WireFormatLite::WriteInt32(3, this->maximum(), output); + } + + // optional int32 minimum = 4; + if (has_minimum()) { + ::google::protobuf::internal::WireFormatLite::WriteInt32(4, this->minimum(), output); + } + +} + +int Test_Statistic::ByteSize() const { + int total_size = 0; + + if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) { + // optional int32 instant = 1; + if (has_instant()) { + total_size += 1 + + ::google::protobuf::internal::WireFormatLite::Int32Size( + this->instant()); + } + + // optional int32 average = 2; + if (has_average()) { + total_size += 1 + + ::google::protobuf::internal::WireFormatLite::Int32Size( + this->average()); + } + + // optional int32 maximum = 3; + if (has_maximum()) { + total_size += 1 + + ::google::protobuf::internal::WireFormatLite::Int32Size( + this->maximum()); + } + + // optional int32 minimum = 4; + if (has_minimum()) { + total_size += 1 + + ::google::protobuf::internal::WireFormatLite::Int32Size( + this->minimum()); + } + + } + GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); + _cached_size_ = total_size; + GOOGLE_SAFE_CONCURRENT_WRITES_END(); + return total_size; +} + +void Test_Statistic::CheckTypeAndMergeFrom( + const ::google::protobuf::MessageLite& from) { + MergeFrom(*::google::protobuf::down_cast(&from)); +} + +void Test_Statistic::MergeFrom(const Test_Statistic& from) { + GOOGLE_CHECK_NE(&from, this); + if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) { + if (from.has_instant()) { + set_instant(from.instant()); + } + if (from.has_average()) { + set_average(from.average()); + } + if (from.has_maximum()) { + set_maximum(from.maximum()); + } + if (from.has_minimum()) { + set_minimum(from.minimum()); + } + } +} + +void Test_Statistic::CopyFrom(const Test_Statistic& from) { + if (&from == this) return; + Clear(); + MergeFrom(from); +} + +bool Test_Statistic::IsInitialized() const { + + return true; +} + +void Test_Statistic::Swap(Test_Statistic* other) { + if (other != this) { + std::swap(instant_, other->instant_); + std::swap(average_, other->average_); + std::swap(maximum_, other->maximum_); + std::swap(minimum_, other->minimum_); + std::swap(_has_bits_[0], other->_has_bits_[0]); + std::swap(_cached_size_, other->_cached_size_); + } +} + +::std::string Test_Statistic::GetTypeName() const { + return "audio_processing_unittest.Test.Statistic"; +} + + +// ------------------------------------------------------------------- + +#ifndef _MSC_VER +const int Test_EchoMetrics::kResidualEchoReturnLossFieldNumber; +const int Test_EchoMetrics::kEchoReturnLossFieldNumber; +const int Test_EchoMetrics::kEchoReturnLossEnhancementFieldNumber; +const int Test_EchoMetrics::kANlpFieldNumber; +#endif // !_MSC_VER + +Test_EchoMetrics::Test_EchoMetrics() + : ::google::protobuf::MessageLite() { + SharedCtor(); +} + +void Test_EchoMetrics::InitAsDefaultInstance() { + residualechoreturnloss_ = const_cast< ::audio_processing_unittest::Test_Statistic*>(&::audio_processing_unittest::Test_Statistic::default_instance()); + echoreturnloss_ = const_cast< ::audio_processing_unittest::Test_Statistic*>(&::audio_processing_unittest::Test_Statistic::default_instance()); + echoreturnlossenhancement_ = const_cast< ::audio_processing_unittest::Test_Statistic*>(&::audio_processing_unittest::Test_Statistic::default_instance()); + anlp_ = const_cast< ::audio_processing_unittest::Test_Statistic*>(&::audio_processing_unittest::Test_Statistic::default_instance()); +} + +Test_EchoMetrics::Test_EchoMetrics(const Test_EchoMetrics& from) + : ::google::protobuf::MessageLite() { + SharedCtor(); + MergeFrom(from); +} + +void Test_EchoMetrics::SharedCtor() { + _cached_size_ = 0; + residualechoreturnloss_ = NULL; + echoreturnloss_ = NULL; + echoreturnlossenhancement_ = NULL; + anlp_ = NULL; + ::memset(_has_bits_, 0, sizeof(_has_bits_)); +} + +Test_EchoMetrics::~Test_EchoMetrics() { + SharedDtor(); +} + +void Test_EchoMetrics::SharedDtor() { + if (this != default_instance_) { + delete residualechoreturnloss_; + delete echoreturnloss_; + delete echoreturnlossenhancement_; + delete anlp_; + } +} + +void Test_EchoMetrics::SetCachedSize(int size) const { + GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); + _cached_size_ = size; + GOOGLE_SAFE_CONCURRENT_WRITES_END(); +} +const Test_EchoMetrics& Test_EchoMetrics::default_instance() { + if (default_instance_ == NULL) protobuf_AddDesc_audio_5fprocessing_5funittest_2eproto(); return *default_instance_; +} + +Test_EchoMetrics* Test_EchoMetrics::default_instance_ = NULL; + +Test_EchoMetrics* Test_EchoMetrics::New() const { + return new Test_EchoMetrics; +} + +void Test_EchoMetrics::Clear() { + if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) { + if (has_residualechoreturnloss()) { + if (residualechoreturnloss_ != NULL) residualechoreturnloss_->::audio_processing_unittest::Test_Statistic::Clear(); + } + if (has_echoreturnloss()) { + if (echoreturnloss_ != NULL) echoreturnloss_->::audio_processing_unittest::Test_Statistic::Clear(); + } + if (has_echoreturnlossenhancement()) { + if (echoreturnlossenhancement_ != NULL) echoreturnlossenhancement_->::audio_processing_unittest::Test_Statistic::Clear(); + } + if (has_anlp()) { + if (anlp_ != NULL) anlp_->::audio_processing_unittest::Test_Statistic::Clear(); + } + } + ::memset(_has_bits_, 0, sizeof(_has_bits_)); +} + +bool Test_EchoMetrics::MergePartialFromCodedStream( + ::google::protobuf::io::CodedInputStream* input) { +#define DO_(EXPRESSION) if (!(EXPRESSION)) return false + ::google::protobuf::uint32 tag; + while ((tag = input->ReadTag()) != 0) { + switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { + // optional .audio_processing_unittest.Test.Statistic residualEchoReturnLoss = 1; + case 1: { + if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == + ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { + DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( + input, mutable_residualechoreturnloss())); + } else { + goto handle_uninterpreted; + } + if (input->ExpectTag(18)) goto parse_echoReturnLoss; + break; + } + + // optional .audio_processing_unittest.Test.Statistic echoReturnLoss = 2; + case 2: { + if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == + ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { + parse_echoReturnLoss: + DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( + input, mutable_echoreturnloss())); + } else { + goto handle_uninterpreted; + } + if (input->ExpectTag(26)) goto parse_echoReturnLossEnhancement; + break; + } + + // optional .audio_processing_unittest.Test.Statistic echoReturnLossEnhancement = 3; + case 3: { + if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == + ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { + parse_echoReturnLossEnhancement: + DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( + input, mutable_echoreturnlossenhancement())); + } else { + goto handle_uninterpreted; + } + if (input->ExpectTag(34)) goto parse_aNlp; + break; + } + + // optional .audio_processing_unittest.Test.Statistic aNlp = 4; + case 4: { + if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == + ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { + parse_aNlp: + DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( + input, mutable_anlp())); + } else { + goto handle_uninterpreted; + } + if (input->ExpectAtEnd()) return true; + break; + } + + default: { + handle_uninterpreted: + if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == + ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) { + return true; + } + DO_(::google::protobuf::internal::WireFormatLite::SkipField(input, tag, NULL)); + break; + } + } + } + return true; +#undef DO_ +} + +void Test_EchoMetrics::SerializeWithCachedSizes( + ::google::protobuf::io::CodedOutputStream* output) const { + // optional .audio_processing_unittest.Test.Statistic residualEchoReturnLoss = 1; + if (has_residualechoreturnloss()) { + ::google::protobuf::internal::WireFormatLite::WriteMessage( + 1, this->residualechoreturnloss(), output); + } + + // optional .audio_processing_unittest.Test.Statistic echoReturnLoss = 2; + if (has_echoreturnloss()) { + ::google::protobuf::internal::WireFormatLite::WriteMessage( + 2, this->echoreturnloss(), output); + } + + // optional .audio_processing_unittest.Test.Statistic echoReturnLossEnhancement = 3; + if (has_echoreturnlossenhancement()) { + ::google::protobuf::internal::WireFormatLite::WriteMessage( + 3, this->echoreturnlossenhancement(), output); + } + + // optional .audio_processing_unittest.Test.Statistic aNlp = 4; + if (has_anlp()) { + ::google::protobuf::internal::WireFormatLite::WriteMessage( + 4, this->anlp(), output); + } + +} + +int Test_EchoMetrics::ByteSize() const { + int total_size = 0; + + if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) { + // optional .audio_processing_unittest.Test.Statistic residualEchoReturnLoss = 1; + if (has_residualechoreturnloss()) { + total_size += 1 + + ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( + this->residualechoreturnloss()); + } + + // optional .audio_processing_unittest.Test.Statistic echoReturnLoss = 2; + if (has_echoreturnloss()) { + total_size += 1 + + ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( + this->echoreturnloss()); + } + + // optional .audio_processing_unittest.Test.Statistic echoReturnLossEnhancement = 3; + if (has_echoreturnlossenhancement()) { + total_size += 1 + + ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( + this->echoreturnlossenhancement()); + } + + // optional .audio_processing_unittest.Test.Statistic aNlp = 4; + if (has_anlp()) { + total_size += 1 + + ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( + this->anlp()); + } + + } + GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); + _cached_size_ = total_size; + GOOGLE_SAFE_CONCURRENT_WRITES_END(); + return total_size; +} + +void Test_EchoMetrics::CheckTypeAndMergeFrom( + const ::google::protobuf::MessageLite& from) { + MergeFrom(*::google::protobuf::down_cast(&from)); +} + +void Test_EchoMetrics::MergeFrom(const Test_EchoMetrics& from) { + GOOGLE_CHECK_NE(&from, this); + if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) { + if (from.has_residualechoreturnloss()) { + mutable_residualechoreturnloss()->::audio_processing_unittest::Test_Statistic::MergeFrom(from.residualechoreturnloss()); + } + if (from.has_echoreturnloss()) { + mutable_echoreturnloss()->::audio_processing_unittest::Test_Statistic::MergeFrom(from.echoreturnloss()); + } + if (from.has_echoreturnlossenhancement()) { + mutable_echoreturnlossenhancement()->::audio_processing_unittest::Test_Statistic::MergeFrom(from.echoreturnlossenhancement()); + } + if (from.has_anlp()) { + mutable_anlp()->::audio_processing_unittest::Test_Statistic::MergeFrom(from.anlp()); + } + } +} + +void Test_EchoMetrics::CopyFrom(const Test_EchoMetrics& from) { + if (&from == this) return; + Clear(); + MergeFrom(from); +} + +bool Test_EchoMetrics::IsInitialized() const { + + return true; +} + +void Test_EchoMetrics::Swap(Test_EchoMetrics* other) { + if (other != this) { + std::swap(residualechoreturnloss_, other->residualechoreturnloss_); + std::swap(echoreturnloss_, other->echoreturnloss_); + std::swap(echoreturnlossenhancement_, other->echoreturnlossenhancement_); + std::swap(anlp_, other->anlp_); + std::swap(_has_bits_[0], other->_has_bits_[0]); + std::swap(_cached_size_, other->_cached_size_); + } +} + +::std::string Test_EchoMetrics::GetTypeName() const { + return "audio_processing_unittest.Test.EchoMetrics"; +} + + +// ------------------------------------------------------------------- + +#ifndef _MSC_VER +const int Test::kNumReverseChannelsFieldNumber; +const int Test::kNumChannelsFieldNumber; +const int Test::kSampleRateFieldNumber; +const int Test::kHasEchoCountFieldNumber; +const int Test::kHasVoiceCountFieldNumber; +const int Test::kIsSaturatedCountFieldNumber; +const int Test::kEchoMetricsFieldNumber; +#endif // !_MSC_VER + +Test::Test() + : ::google::protobuf::MessageLite() { + SharedCtor(); +} + +void Test::InitAsDefaultInstance() { + echometrics_ = const_cast< ::audio_processing_unittest::Test_EchoMetrics*>(&::audio_processing_unittest::Test_EchoMetrics::default_instance()); +} + +Test::Test(const Test& from) + : ::google::protobuf::MessageLite() { + SharedCtor(); + MergeFrom(from); +} + +void Test::SharedCtor() { + _cached_size_ = 0; + numreversechannels_ = 0; + numchannels_ = 0; + samplerate_ = 0; + hasechocount_ = 0; + hasvoicecount_ = 0; + issaturatedcount_ = 0; + echometrics_ = NULL; + ::memset(_has_bits_, 0, sizeof(_has_bits_)); +} + +Test::~Test() { + SharedDtor(); +} + +void Test::SharedDtor() { + if (this != default_instance_) { + delete echometrics_; + } +} + +void Test::SetCachedSize(int size) const { + GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); + _cached_size_ = size; + GOOGLE_SAFE_CONCURRENT_WRITES_END(); +} +const Test& Test::default_instance() { + if (default_instance_ == NULL) protobuf_AddDesc_audio_5fprocessing_5funittest_2eproto(); return *default_instance_; +} + +Test* Test::default_instance_ = NULL; + +Test* Test::New() const { + return new Test; +} + +void Test::Clear() { + if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) { + numreversechannels_ = 0; + numchannels_ = 0; + samplerate_ = 0; + hasechocount_ = 0; + hasvoicecount_ = 0; + issaturatedcount_ = 0; + if (has_echometrics()) { + if (echometrics_ != NULL) echometrics_->::audio_processing_unittest::Test_EchoMetrics::Clear(); + } + } + ::memset(_has_bits_, 0, sizeof(_has_bits_)); +} + +bool Test::MergePartialFromCodedStream( + ::google::protobuf::io::CodedInputStream* input) { +#define DO_(EXPRESSION) if (!(EXPRESSION)) return false + ::google::protobuf::uint32 tag; + while ((tag = input->ReadTag()) != 0) { + switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { + // optional int32 numReverseChannels = 1; + case 1: { + if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == + ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) { + DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< + ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>( + input, &numreversechannels_))); + set_has_numreversechannels(); + } else { + goto handle_uninterpreted; + } + if (input->ExpectTag(16)) goto parse_numChannels; + break; + } + + // optional int32 numChannels = 2; + case 2: { + if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == + ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) { + parse_numChannels: + DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< + ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>( + input, &numchannels_))); + set_has_numchannels(); + } else { + goto handle_uninterpreted; + } + if (input->ExpectTag(24)) goto parse_sampleRate; + break; + } + + // optional int32 sampleRate = 3; + case 3: { + if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == + ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) { + parse_sampleRate: + DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< + ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>( + input, &samplerate_))); + set_has_samplerate(); + } else { + goto handle_uninterpreted; + } + if (input->ExpectTag(32)) goto parse_hasEchoCount; + break; + } + + // optional int32 hasEchoCount = 4; + case 4: { + if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == + ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) { + parse_hasEchoCount: + DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< + ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>( + input, &hasechocount_))); + set_has_hasechocount(); + } else { + goto handle_uninterpreted; + } + if (input->ExpectTag(40)) goto parse_hasVoiceCount; + break; + } + + // optional int32 hasVoiceCount = 5; + case 5: { + if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == + ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) { + parse_hasVoiceCount: + DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< + ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>( + input, &hasvoicecount_))); + set_has_hasvoicecount(); + } else { + goto handle_uninterpreted; + } + if (input->ExpectTag(48)) goto parse_isSaturatedCount; + break; + } + + // optional int32 isSaturatedCount = 6; + case 6: { + if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == + ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) { + parse_isSaturatedCount: + DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< + ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>( + input, &issaturatedcount_))); + set_has_issaturatedcount(); + } else { + goto handle_uninterpreted; + } + if (input->ExpectTag(58)) goto parse_echoMetrics; + break; + } + + // optional .audio_processing_unittest.Test.EchoMetrics echoMetrics = 7; + case 7: { + if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == + ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { + parse_echoMetrics: + DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( + input, mutable_echometrics())); + } else { + goto handle_uninterpreted; + } + if (input->ExpectAtEnd()) return true; + break; + } + + default: { + handle_uninterpreted: + if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == + ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) { + return true; + } + DO_(::google::protobuf::internal::WireFormatLite::SkipField(input, tag, NULL)); + break; + } + } + } + return true; +#undef DO_ +} + +void Test::SerializeWithCachedSizes( + ::google::protobuf::io::CodedOutputStream* output) const { + // optional int32 numReverseChannels = 1; + if (has_numreversechannels()) { + ::google::protobuf::internal::WireFormatLite::WriteInt32(1, this->numreversechannels(), output); + } + + // optional int32 numChannels = 2; + if (has_numchannels()) { + ::google::protobuf::internal::WireFormatLite::WriteInt32(2, this->numchannels(), output); + } + + // optional int32 sampleRate = 3; + if (has_samplerate()) { + ::google::protobuf::internal::WireFormatLite::WriteInt32(3, this->samplerate(), output); + } + + // optional int32 hasEchoCount = 4; + if (has_hasechocount()) { + ::google::protobuf::internal::WireFormatLite::WriteInt32(4, this->hasechocount(), output); + } + + // optional int32 hasVoiceCount = 5; + if (has_hasvoicecount()) { + ::google::protobuf::internal::WireFormatLite::WriteInt32(5, this->hasvoicecount(), output); + } + + // optional int32 isSaturatedCount = 6; + if (has_issaturatedcount()) { + ::google::protobuf::internal::WireFormatLite::WriteInt32(6, this->issaturatedcount(), output); + } + + // optional .audio_processing_unittest.Test.EchoMetrics echoMetrics = 7; + if (has_echometrics()) { + ::google::protobuf::internal::WireFormatLite::WriteMessage( + 7, this->echometrics(), output); + } + +} + +int Test::ByteSize() const { + int total_size = 0; + + if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) { + // optional int32 numReverseChannels = 1; + if (has_numreversechannels()) { + total_size += 1 + + ::google::protobuf::internal::WireFormatLite::Int32Size( + this->numreversechannels()); + } + + // optional int32 numChannels = 2; + if (has_numchannels()) { + total_size += 1 + + ::google::protobuf::internal::WireFormatLite::Int32Size( + this->numchannels()); + } + + // optional int32 sampleRate = 3; + if (has_samplerate()) { + total_size += 1 + + ::google::protobuf::internal::WireFormatLite::Int32Size( + this->samplerate()); + } + + // optional int32 hasEchoCount = 4; + if (has_hasechocount()) { + total_size += 1 + + ::google::protobuf::internal::WireFormatLite::Int32Size( + this->hasechocount()); + } + + // optional int32 hasVoiceCount = 5; + if (has_hasvoicecount()) { + total_size += 1 + + ::google::protobuf::internal::WireFormatLite::Int32Size( + this->hasvoicecount()); + } + + // optional int32 isSaturatedCount = 6; + if (has_issaturatedcount()) { + total_size += 1 + + ::google::protobuf::internal::WireFormatLite::Int32Size( + this->issaturatedcount()); + } + + // optional .audio_processing_unittest.Test.EchoMetrics echoMetrics = 7; + if (has_echometrics()) { + total_size += 1 + + ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( + this->echometrics()); + } + + } + GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); + _cached_size_ = total_size; + GOOGLE_SAFE_CONCURRENT_WRITES_END(); + return total_size; +} + +void Test::CheckTypeAndMergeFrom( + const ::google::protobuf::MessageLite& from) { + MergeFrom(*::google::protobuf::down_cast(&from)); +} + +void Test::MergeFrom(const Test& from) { + GOOGLE_CHECK_NE(&from, this); + if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) { + if (from.has_numreversechannels()) { + set_numreversechannels(from.numreversechannels()); + } + if (from.has_numchannels()) { + set_numchannels(from.numchannels()); + } + if (from.has_samplerate()) { + set_samplerate(from.samplerate()); + } + if (from.has_hasechocount()) { + set_hasechocount(from.hasechocount()); + } + if (from.has_hasvoicecount()) { + set_hasvoicecount(from.hasvoicecount()); + } + if (from.has_issaturatedcount()) { + set_issaturatedcount(from.issaturatedcount()); + } + if (from.has_echometrics()) { + mutable_echometrics()->::audio_processing_unittest::Test_EchoMetrics::MergeFrom(from.echometrics()); + } + } +} + +void Test::CopyFrom(const Test& from) { + if (&from == this) return; + Clear(); + MergeFrom(from); +} + +bool Test::IsInitialized() const { + + return true; +} + +void Test::Swap(Test* other) { + if (other != this) { + std::swap(numreversechannels_, other->numreversechannels_); + std::swap(numchannels_, other->numchannels_); + std::swap(samplerate_, other->samplerate_); + std::swap(hasechocount_, other->hasechocount_); + std::swap(hasvoicecount_, other->hasvoicecount_); + std::swap(issaturatedcount_, other->issaturatedcount_); + std::swap(echometrics_, other->echometrics_); + std::swap(_has_bits_[0], other->_has_bits_[0]); + std::swap(_cached_size_, other->_cached_size_); + } +} + +::std::string Test::GetTypeName() const { + return "audio_processing_unittest.Test"; +} + + +// =================================================================== + +#ifndef _MSC_VER +const int OutputData::kTestFieldNumber; +#endif // !_MSC_VER + +OutputData::OutputData() + : ::google::protobuf::MessageLite() { + SharedCtor(); +} + +void OutputData::InitAsDefaultInstance() { +} + +OutputData::OutputData(const OutputData& from) + : ::google::protobuf::MessageLite() { + SharedCtor(); + MergeFrom(from); +} + +void OutputData::SharedCtor() { + _cached_size_ = 0; + ::memset(_has_bits_, 0, sizeof(_has_bits_)); +} + +OutputData::~OutputData() { + SharedDtor(); +} + +void OutputData::SharedDtor() { + if (this != default_instance_) { + } +} + +void OutputData::SetCachedSize(int size) const { + GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); + _cached_size_ = size; + GOOGLE_SAFE_CONCURRENT_WRITES_END(); +} +const OutputData& OutputData::default_instance() { + if (default_instance_ == NULL) protobuf_AddDesc_audio_5fprocessing_5funittest_2eproto(); return *default_instance_; +} + +OutputData* OutputData::default_instance_ = NULL; + +OutputData* OutputData::New() const { + return new OutputData; +} + +void OutputData::Clear() { + test_.Clear(); + ::memset(_has_bits_, 0, sizeof(_has_bits_)); +} + +bool OutputData::MergePartialFromCodedStream( + ::google::protobuf::io::CodedInputStream* input) { +#define DO_(EXPRESSION) if (!(EXPRESSION)) return false + ::google::protobuf::uint32 tag; + while ((tag = input->ReadTag()) != 0) { + switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { + // repeated .audio_processing_unittest.Test test = 1; + case 1: { + if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == + ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { + parse_test: + DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( + input, add_test())); + } else { + goto handle_uninterpreted; + } + if (input->ExpectTag(10)) goto parse_test; + if (input->ExpectAtEnd()) return true; + break; + } + + default: { + handle_uninterpreted: + if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == + ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) { + return true; + } + DO_(::google::protobuf::internal::WireFormatLite::SkipField(input, tag, NULL)); + break; + } + } + } + return true; +#undef DO_ +} + +void OutputData::SerializeWithCachedSizes( + ::google::protobuf::io::CodedOutputStream* output) const { + // repeated .audio_processing_unittest.Test test = 1; + for (int i = 0; i < this->test_size(); i++) { + ::google::protobuf::internal::WireFormatLite::WriteMessage( + 1, this->test(i), output); + } + +} + +int OutputData::ByteSize() const { + int total_size = 0; + + // repeated .audio_processing_unittest.Test test = 1; + total_size += 1 * this->test_size(); + for (int i = 0; i < this->test_size(); i++) { + total_size += + ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( + this->test(i)); + } + + GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); + _cached_size_ = total_size; + GOOGLE_SAFE_CONCURRENT_WRITES_END(); + return total_size; +} + +void OutputData::CheckTypeAndMergeFrom( + const ::google::protobuf::MessageLite& from) { + MergeFrom(*::google::protobuf::down_cast(&from)); +} + +void OutputData::MergeFrom(const OutputData& from) { + GOOGLE_CHECK_NE(&from, this); + test_.MergeFrom(from.test_); +} + +void OutputData::CopyFrom(const OutputData& from) { + if (&from == this) return; + Clear(); + MergeFrom(from); +} + +bool OutputData::IsInitialized() const { + + return true; +} + +void OutputData::Swap(OutputData* other) { + if (other != this) { + test_.Swap(&other->test_); + std::swap(_has_bits_[0], other->_has_bits_[0]); + std::swap(_cached_size_, other->_cached_size_); + } +} + +::std::string OutputData::GetTypeName() const { + return "audio_processing_unittest.OutputData"; +} + + +// @@protoc_insertion_point(namespace_scope) + +} // namespace audio_processing_unittest + +// @@protoc_insertion_point(global_scope) diff --git a/modules/audio_processing/main/test/unit_test/audio_processing_unittest.pb.h b/modules/audio_processing/main/test/unit_test/audio_processing_unittest.pb.h new file mode 100644 index 0000000000..34c21b2f40 --- /dev/null +++ b/modules/audio_processing/main/test/unit_test/audio_processing_unittest.pb.h @@ -0,0 +1,862 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: audio_processing_unittest.proto + +#ifndef PROTOBUF_audio_5fprocessing_5funittest_2eproto__INCLUDED +#define PROTOBUF_audio_5fprocessing_5funittest_2eproto__INCLUDED + +#include + +#include + +#if GOOGLE_PROTOBUF_VERSION < 2004000 +#error This file was generated by a newer version of protoc which is +#error incompatible with your Protocol Buffer headers. Please update +#error your headers. +#endif +#if 2004000 < GOOGLE_PROTOBUF_MIN_PROTOC_VERSION +#error This file was generated by an older version of protoc which is +#error incompatible with your Protocol Buffer headers. Please +#error regenerate this file with a newer version of protoc. +#endif + +#include +#include +#include +// @@protoc_insertion_point(includes) + +namespace audio_processing_unittest { + +// Internal implementation detail -- do not call these. +void protobuf_AddDesc_audio_5fprocessing_5funittest_2eproto(); +void protobuf_AssignDesc_audio_5fprocessing_5funittest_2eproto(); +void protobuf_ShutdownFile_audio_5fprocessing_5funittest_2eproto(); + +class Test; +class Test_Statistic; +class Test_EchoMetrics; +class OutputData; + +// =================================================================== + +class Test_Statistic : public ::google::protobuf::MessageLite { + public: + Test_Statistic(); + virtual ~Test_Statistic(); + + Test_Statistic(const Test_Statistic& from); + + inline Test_Statistic& operator=(const Test_Statistic& from) { + CopyFrom(from); + return *this; + } + + static const Test_Statistic& default_instance(); + + void Swap(Test_Statistic* other); + + // implements Message ---------------------------------------------- + + Test_Statistic* New() const; + void CheckTypeAndMergeFrom(const ::google::protobuf::MessageLite& from); + void CopyFrom(const Test_Statistic& from); + void MergeFrom(const Test_Statistic& from); + void Clear(); + bool IsInitialized() const; + + int ByteSize() const; + bool MergePartialFromCodedStream( + ::google::protobuf::io::CodedInputStream* input); + void SerializeWithCachedSizes( + ::google::protobuf::io::CodedOutputStream* output) const; + int GetCachedSize() const { return _cached_size_; } + private: + void SharedCtor(); + void SharedDtor(); + void SetCachedSize(int size) const; + public: + + ::std::string GetTypeName() const; + + // nested types ---------------------------------------------------- + + // accessors ------------------------------------------------------- + + // optional int32 instant = 1; + inline bool has_instant() const; + inline void clear_instant(); + static const int kInstantFieldNumber = 1; + inline ::google::protobuf::int32 instant() const; + inline void set_instant(::google::protobuf::int32 value); + + // optional int32 average = 2; + inline bool has_average() const; + inline void clear_average(); + static const int kAverageFieldNumber = 2; + inline ::google::protobuf::int32 average() const; + inline void set_average(::google::protobuf::int32 value); + + // optional int32 maximum = 3; + inline bool has_maximum() const; + inline void clear_maximum(); + static const int kMaximumFieldNumber = 3; + inline ::google::protobuf::int32 maximum() const; + inline void set_maximum(::google::protobuf::int32 value); + + // optional int32 minimum = 4; + inline bool has_minimum() const; + inline void clear_minimum(); + static const int kMinimumFieldNumber = 4; + inline ::google::protobuf::int32 minimum() const; + inline void set_minimum(::google::protobuf::int32 value); + + // @@protoc_insertion_point(class_scope:audio_processing_unittest.Test.Statistic) + private: + inline void set_has_instant(); + inline void clear_has_instant(); + inline void set_has_average(); + inline void clear_has_average(); + inline void set_has_maximum(); + inline void clear_has_maximum(); + inline void set_has_minimum(); + inline void clear_has_minimum(); + + ::google::protobuf::int32 instant_; + ::google::protobuf::int32 average_; + ::google::protobuf::int32 maximum_; + ::google::protobuf::int32 minimum_; + + mutable int _cached_size_; + ::google::protobuf::uint32 _has_bits_[(4 + 31) / 32]; + + friend void protobuf_AddDesc_audio_5fprocessing_5funittest_2eproto(); + friend void protobuf_AssignDesc_audio_5fprocessing_5funittest_2eproto(); + friend void protobuf_ShutdownFile_audio_5fprocessing_5funittest_2eproto(); + + void InitAsDefaultInstance(); + static Test_Statistic* default_instance_; +}; +// ------------------------------------------------------------------- + +class Test_EchoMetrics : public ::google::protobuf::MessageLite { + public: + Test_EchoMetrics(); + virtual ~Test_EchoMetrics(); + + Test_EchoMetrics(const Test_EchoMetrics& from); + + inline Test_EchoMetrics& operator=(const Test_EchoMetrics& from) { + CopyFrom(from); + return *this; + } + + static const Test_EchoMetrics& default_instance(); + + void Swap(Test_EchoMetrics* other); + + // implements Message ---------------------------------------------- + + Test_EchoMetrics* New() const; + void CheckTypeAndMergeFrom(const ::google::protobuf::MessageLite& from); + void CopyFrom(const Test_EchoMetrics& from); + void MergeFrom(const Test_EchoMetrics& from); + void Clear(); + bool IsInitialized() const; + + int ByteSize() const; + bool MergePartialFromCodedStream( + ::google::protobuf::io::CodedInputStream* input); + void SerializeWithCachedSizes( + ::google::protobuf::io::CodedOutputStream* output) const; + int GetCachedSize() const { return _cached_size_; } + private: + void SharedCtor(); + void SharedDtor(); + void SetCachedSize(int size) const; + public: + + ::std::string GetTypeName() const; + + // nested types ---------------------------------------------------- + + // accessors ------------------------------------------------------- + + // optional .audio_processing_unittest.Test.Statistic residualEchoReturnLoss = 1; + inline bool has_residualechoreturnloss() const; + inline void clear_residualechoreturnloss(); + static const int kResidualEchoReturnLossFieldNumber = 1; + inline const ::audio_processing_unittest::Test_Statistic& residualechoreturnloss() const; + inline ::audio_processing_unittest::Test_Statistic* mutable_residualechoreturnloss(); + inline ::audio_processing_unittest::Test_Statistic* release_residualechoreturnloss(); + + // optional .audio_processing_unittest.Test.Statistic echoReturnLoss = 2; + inline bool has_echoreturnloss() const; + inline void clear_echoreturnloss(); + static const int kEchoReturnLossFieldNumber = 2; + inline const ::audio_processing_unittest::Test_Statistic& echoreturnloss() const; + inline ::audio_processing_unittest::Test_Statistic* mutable_echoreturnloss(); + inline ::audio_processing_unittest::Test_Statistic* release_echoreturnloss(); + + // optional .audio_processing_unittest.Test.Statistic echoReturnLossEnhancement = 3; + inline bool has_echoreturnlossenhancement() const; + inline void clear_echoreturnlossenhancement(); + static const int kEchoReturnLossEnhancementFieldNumber = 3; + inline const ::audio_processing_unittest::Test_Statistic& echoreturnlossenhancement() const; + inline ::audio_processing_unittest::Test_Statistic* mutable_echoreturnlossenhancement(); + inline ::audio_processing_unittest::Test_Statistic* release_echoreturnlossenhancement(); + + // optional .audio_processing_unittest.Test.Statistic aNlp = 4; + inline bool has_anlp() const; + inline void clear_anlp(); + static const int kANlpFieldNumber = 4; + inline const ::audio_processing_unittest::Test_Statistic& anlp() const; + inline ::audio_processing_unittest::Test_Statistic* mutable_anlp(); + inline ::audio_processing_unittest::Test_Statistic* release_anlp(); + + // @@protoc_insertion_point(class_scope:audio_processing_unittest.Test.EchoMetrics) + private: + inline void set_has_residualechoreturnloss(); + inline void clear_has_residualechoreturnloss(); + inline void set_has_echoreturnloss(); + inline void clear_has_echoreturnloss(); + inline void set_has_echoreturnlossenhancement(); + inline void clear_has_echoreturnlossenhancement(); + inline void set_has_anlp(); + inline void clear_has_anlp(); + + ::audio_processing_unittest::Test_Statistic* residualechoreturnloss_; + ::audio_processing_unittest::Test_Statistic* echoreturnloss_; + ::audio_processing_unittest::Test_Statistic* echoreturnlossenhancement_; + ::audio_processing_unittest::Test_Statistic* anlp_; + + mutable int _cached_size_; + ::google::protobuf::uint32 _has_bits_[(4 + 31) / 32]; + + friend void protobuf_AddDesc_audio_5fprocessing_5funittest_2eproto(); + friend void protobuf_AssignDesc_audio_5fprocessing_5funittest_2eproto(); + friend void protobuf_ShutdownFile_audio_5fprocessing_5funittest_2eproto(); + + void InitAsDefaultInstance(); + static Test_EchoMetrics* default_instance_; +}; +// ------------------------------------------------------------------- + +class Test : public ::google::protobuf::MessageLite { + public: + Test(); + virtual ~Test(); + + Test(const Test& from); + + inline Test& operator=(const Test& from) { + CopyFrom(from); + return *this; + } + + static const Test& default_instance(); + + void Swap(Test* other); + + // implements Message ---------------------------------------------- + + Test* New() const; + void CheckTypeAndMergeFrom(const ::google::protobuf::MessageLite& from); + void CopyFrom(const Test& from); + void MergeFrom(const Test& from); + void Clear(); + bool IsInitialized() const; + + int ByteSize() const; + bool MergePartialFromCodedStream( + ::google::protobuf::io::CodedInputStream* input); + void SerializeWithCachedSizes( + ::google::protobuf::io::CodedOutputStream* output) const; + int GetCachedSize() const { return _cached_size_; } + private: + void SharedCtor(); + void SharedDtor(); + void SetCachedSize(int size) const; + public: + + ::std::string GetTypeName() const; + + // nested types ---------------------------------------------------- + + typedef Test_Statistic Statistic; + typedef Test_EchoMetrics EchoMetrics; + + // accessors ------------------------------------------------------- + + // optional int32 numReverseChannels = 1; + inline bool has_numreversechannels() const; + inline void clear_numreversechannels(); + static const int kNumReverseChannelsFieldNumber = 1; + inline ::google::protobuf::int32 numreversechannels() const; + inline void set_numreversechannels(::google::protobuf::int32 value); + + // optional int32 numChannels = 2; + inline bool has_numchannels() const; + inline void clear_numchannels(); + static const int kNumChannelsFieldNumber = 2; + inline ::google::protobuf::int32 numchannels() const; + inline void set_numchannels(::google::protobuf::int32 value); + + // optional int32 sampleRate = 3; + inline bool has_samplerate() const; + inline void clear_samplerate(); + static const int kSampleRateFieldNumber = 3; + inline ::google::protobuf::int32 samplerate() const; + inline void set_samplerate(::google::protobuf::int32 value); + + // optional int32 hasEchoCount = 4; + inline bool has_hasechocount() const; + inline void clear_hasechocount(); + static const int kHasEchoCountFieldNumber = 4; + inline ::google::protobuf::int32 hasechocount() const; + inline void set_hasechocount(::google::protobuf::int32 value); + + // optional int32 hasVoiceCount = 5; + inline bool has_hasvoicecount() const; + inline void clear_hasvoicecount(); + static const int kHasVoiceCountFieldNumber = 5; + inline ::google::protobuf::int32 hasvoicecount() const; + inline void set_hasvoicecount(::google::protobuf::int32 value); + + // optional int32 isSaturatedCount = 6; + inline bool has_issaturatedcount() const; + inline void clear_issaturatedcount(); + static const int kIsSaturatedCountFieldNumber = 6; + inline ::google::protobuf::int32 issaturatedcount() const; + inline void set_issaturatedcount(::google::protobuf::int32 value); + + // optional .audio_processing_unittest.Test.EchoMetrics echoMetrics = 7; + inline bool has_echometrics() const; + inline void clear_echometrics(); + static const int kEchoMetricsFieldNumber = 7; + inline const ::audio_processing_unittest::Test_EchoMetrics& echometrics() const; + inline ::audio_processing_unittest::Test_EchoMetrics* mutable_echometrics(); + inline ::audio_processing_unittest::Test_EchoMetrics* release_echometrics(); + + // @@protoc_insertion_point(class_scope:audio_processing_unittest.Test) + private: + inline void set_has_numreversechannels(); + inline void clear_has_numreversechannels(); + inline void set_has_numchannels(); + inline void clear_has_numchannels(); + inline void set_has_samplerate(); + inline void clear_has_samplerate(); + inline void set_has_hasechocount(); + inline void clear_has_hasechocount(); + inline void set_has_hasvoicecount(); + inline void clear_has_hasvoicecount(); + inline void set_has_issaturatedcount(); + inline void clear_has_issaturatedcount(); + inline void set_has_echometrics(); + inline void clear_has_echometrics(); + + ::google::protobuf::int32 numreversechannels_; + ::google::protobuf::int32 numchannels_; + ::google::protobuf::int32 samplerate_; + ::google::protobuf::int32 hasechocount_; + ::google::protobuf::int32 hasvoicecount_; + ::google::protobuf::int32 issaturatedcount_; + ::audio_processing_unittest::Test_EchoMetrics* echometrics_; + + mutable int _cached_size_; + ::google::protobuf::uint32 _has_bits_[(7 + 31) / 32]; + + friend void protobuf_AddDesc_audio_5fprocessing_5funittest_2eproto(); + friend void protobuf_AssignDesc_audio_5fprocessing_5funittest_2eproto(); + friend void protobuf_ShutdownFile_audio_5fprocessing_5funittest_2eproto(); + + void InitAsDefaultInstance(); + static Test* default_instance_; +}; +// ------------------------------------------------------------------- + +class OutputData : public ::google::protobuf::MessageLite { + public: + OutputData(); + virtual ~OutputData(); + + OutputData(const OutputData& from); + + inline OutputData& operator=(const OutputData& from) { + CopyFrom(from); + return *this; + } + + static const OutputData& default_instance(); + + void Swap(OutputData* other); + + // implements Message ---------------------------------------------- + + OutputData* New() const; + void CheckTypeAndMergeFrom(const ::google::protobuf::MessageLite& from); + void CopyFrom(const OutputData& from); + void MergeFrom(const OutputData& from); + void Clear(); + bool IsInitialized() const; + + int ByteSize() const; + bool MergePartialFromCodedStream( + ::google::protobuf::io::CodedInputStream* input); + void SerializeWithCachedSizes( + ::google::protobuf::io::CodedOutputStream* output) const; + int GetCachedSize() const { return _cached_size_; } + private: + void SharedCtor(); + void SharedDtor(); + void SetCachedSize(int size) const; + public: + + ::std::string GetTypeName() const; + + // nested types ---------------------------------------------------- + + // accessors ------------------------------------------------------- + + // repeated .audio_processing_unittest.Test test = 1; + inline int test_size() const; + inline void clear_test(); + static const int kTestFieldNumber = 1; + inline const ::audio_processing_unittest::Test& test(int index) const; + inline ::audio_processing_unittest::Test* mutable_test(int index); + inline ::audio_processing_unittest::Test* add_test(); + inline const ::google::protobuf::RepeatedPtrField< ::audio_processing_unittest::Test >& + test() const; + inline ::google::protobuf::RepeatedPtrField< ::audio_processing_unittest::Test >* + mutable_test(); + + // @@protoc_insertion_point(class_scope:audio_processing_unittest.OutputData) + private: + + ::google::protobuf::RepeatedPtrField< ::audio_processing_unittest::Test > test_; + + mutable int _cached_size_; + ::google::protobuf::uint32 _has_bits_[(1 + 31) / 32]; + + friend void protobuf_AddDesc_audio_5fprocessing_5funittest_2eproto(); + friend void protobuf_AssignDesc_audio_5fprocessing_5funittest_2eproto(); + friend void protobuf_ShutdownFile_audio_5fprocessing_5funittest_2eproto(); + + void InitAsDefaultInstance(); + static OutputData* default_instance_; +}; +// =================================================================== + + +// =================================================================== + +// Test_Statistic + +// optional int32 instant = 1; +inline bool Test_Statistic::has_instant() const { + return (_has_bits_[0] & 0x00000001u) != 0; +} +inline void Test_Statistic::set_has_instant() { + _has_bits_[0] |= 0x00000001u; +} +inline void Test_Statistic::clear_has_instant() { + _has_bits_[0] &= ~0x00000001u; +} +inline void Test_Statistic::clear_instant() { + instant_ = 0; + clear_has_instant(); +} +inline ::google::protobuf::int32 Test_Statistic::instant() const { + return instant_; +} +inline void Test_Statistic::set_instant(::google::protobuf::int32 value) { + set_has_instant(); + instant_ = value; +} + +// optional int32 average = 2; +inline bool Test_Statistic::has_average() const { + return (_has_bits_[0] & 0x00000002u) != 0; +} +inline void Test_Statistic::set_has_average() { + _has_bits_[0] |= 0x00000002u; +} +inline void Test_Statistic::clear_has_average() { + _has_bits_[0] &= ~0x00000002u; +} +inline void Test_Statistic::clear_average() { + average_ = 0; + clear_has_average(); +} +inline ::google::protobuf::int32 Test_Statistic::average() const { + return average_; +} +inline void Test_Statistic::set_average(::google::protobuf::int32 value) { + set_has_average(); + average_ = value; +} + +// optional int32 maximum = 3; +inline bool Test_Statistic::has_maximum() const { + return (_has_bits_[0] & 0x00000004u) != 0; +} +inline void Test_Statistic::set_has_maximum() { + _has_bits_[0] |= 0x00000004u; +} +inline void Test_Statistic::clear_has_maximum() { + _has_bits_[0] &= ~0x00000004u; +} +inline void Test_Statistic::clear_maximum() { + maximum_ = 0; + clear_has_maximum(); +} +inline ::google::protobuf::int32 Test_Statistic::maximum() const { + return maximum_; +} +inline void Test_Statistic::set_maximum(::google::protobuf::int32 value) { + set_has_maximum(); + maximum_ = value; +} + +// optional int32 minimum = 4; +inline bool Test_Statistic::has_minimum() const { + return (_has_bits_[0] & 0x00000008u) != 0; +} +inline void Test_Statistic::set_has_minimum() { + _has_bits_[0] |= 0x00000008u; +} +inline void Test_Statistic::clear_has_minimum() { + _has_bits_[0] &= ~0x00000008u; +} +inline void Test_Statistic::clear_minimum() { + minimum_ = 0; + clear_has_minimum(); +} +inline ::google::protobuf::int32 Test_Statistic::minimum() const { + return minimum_; +} +inline void Test_Statistic::set_minimum(::google::protobuf::int32 value) { + set_has_minimum(); + minimum_ = value; +} + +// ------------------------------------------------------------------- + +// Test_EchoMetrics + +// optional .audio_processing_unittest.Test.Statistic residualEchoReturnLoss = 1; +inline bool Test_EchoMetrics::has_residualechoreturnloss() const { + return (_has_bits_[0] & 0x00000001u) != 0; +} +inline void Test_EchoMetrics::set_has_residualechoreturnloss() { + _has_bits_[0] |= 0x00000001u; +} +inline void Test_EchoMetrics::clear_has_residualechoreturnloss() { + _has_bits_[0] &= ~0x00000001u; +} +inline void Test_EchoMetrics::clear_residualechoreturnloss() { + if (residualechoreturnloss_ != NULL) residualechoreturnloss_->::audio_processing_unittest::Test_Statistic::Clear(); + clear_has_residualechoreturnloss(); +} +inline const ::audio_processing_unittest::Test_Statistic& Test_EchoMetrics::residualechoreturnloss() const { + return residualechoreturnloss_ != NULL ? *residualechoreturnloss_ : *default_instance_->residualechoreturnloss_; +} +inline ::audio_processing_unittest::Test_Statistic* Test_EchoMetrics::mutable_residualechoreturnloss() { + set_has_residualechoreturnloss(); + if (residualechoreturnloss_ == NULL) residualechoreturnloss_ = new ::audio_processing_unittest::Test_Statistic; + return residualechoreturnloss_; +} +inline ::audio_processing_unittest::Test_Statistic* Test_EchoMetrics::release_residualechoreturnloss() { + clear_has_residualechoreturnloss(); + ::audio_processing_unittest::Test_Statistic* temp = residualechoreturnloss_; + residualechoreturnloss_ = NULL; + return temp; +} + +// optional .audio_processing_unittest.Test.Statistic echoReturnLoss = 2; +inline bool Test_EchoMetrics::has_echoreturnloss() const { + return (_has_bits_[0] & 0x00000002u) != 0; +} +inline void Test_EchoMetrics::set_has_echoreturnloss() { + _has_bits_[0] |= 0x00000002u; +} +inline void Test_EchoMetrics::clear_has_echoreturnloss() { + _has_bits_[0] &= ~0x00000002u; +} +inline void Test_EchoMetrics::clear_echoreturnloss() { + if (echoreturnloss_ != NULL) echoreturnloss_->::audio_processing_unittest::Test_Statistic::Clear(); + clear_has_echoreturnloss(); +} +inline const ::audio_processing_unittest::Test_Statistic& Test_EchoMetrics::echoreturnloss() const { + return echoreturnloss_ != NULL ? *echoreturnloss_ : *default_instance_->echoreturnloss_; +} +inline ::audio_processing_unittest::Test_Statistic* Test_EchoMetrics::mutable_echoreturnloss() { + set_has_echoreturnloss(); + if (echoreturnloss_ == NULL) echoreturnloss_ = new ::audio_processing_unittest::Test_Statistic; + return echoreturnloss_; +} +inline ::audio_processing_unittest::Test_Statistic* Test_EchoMetrics::release_echoreturnloss() { + clear_has_echoreturnloss(); + ::audio_processing_unittest::Test_Statistic* temp = echoreturnloss_; + echoreturnloss_ = NULL; + return temp; +} + +// optional .audio_processing_unittest.Test.Statistic echoReturnLossEnhancement = 3; +inline bool Test_EchoMetrics::has_echoreturnlossenhancement() const { + return (_has_bits_[0] & 0x00000004u) != 0; +} +inline void Test_EchoMetrics::set_has_echoreturnlossenhancement() { + _has_bits_[0] |= 0x00000004u; +} +inline void Test_EchoMetrics::clear_has_echoreturnlossenhancement() { + _has_bits_[0] &= ~0x00000004u; +} +inline void Test_EchoMetrics::clear_echoreturnlossenhancement() { + if (echoreturnlossenhancement_ != NULL) echoreturnlossenhancement_->::audio_processing_unittest::Test_Statistic::Clear(); + clear_has_echoreturnlossenhancement(); +} +inline const ::audio_processing_unittest::Test_Statistic& Test_EchoMetrics::echoreturnlossenhancement() const { + return echoreturnlossenhancement_ != NULL ? *echoreturnlossenhancement_ : *default_instance_->echoreturnlossenhancement_; +} +inline ::audio_processing_unittest::Test_Statistic* Test_EchoMetrics::mutable_echoreturnlossenhancement() { + set_has_echoreturnlossenhancement(); + if (echoreturnlossenhancement_ == NULL) echoreturnlossenhancement_ = new ::audio_processing_unittest::Test_Statistic; + return echoreturnlossenhancement_; +} +inline ::audio_processing_unittest::Test_Statistic* Test_EchoMetrics::release_echoreturnlossenhancement() { + clear_has_echoreturnlossenhancement(); + ::audio_processing_unittest::Test_Statistic* temp = echoreturnlossenhancement_; + echoreturnlossenhancement_ = NULL; + return temp; +} + +// optional .audio_processing_unittest.Test.Statistic aNlp = 4; +inline bool Test_EchoMetrics::has_anlp() const { + return (_has_bits_[0] & 0x00000008u) != 0; +} +inline void Test_EchoMetrics::set_has_anlp() { + _has_bits_[0] |= 0x00000008u; +} +inline void Test_EchoMetrics::clear_has_anlp() { + _has_bits_[0] &= ~0x00000008u; +} +inline void Test_EchoMetrics::clear_anlp() { + if (anlp_ != NULL) anlp_->::audio_processing_unittest::Test_Statistic::Clear(); + clear_has_anlp(); +} +inline const ::audio_processing_unittest::Test_Statistic& Test_EchoMetrics::anlp() const { + return anlp_ != NULL ? *anlp_ : *default_instance_->anlp_; +} +inline ::audio_processing_unittest::Test_Statistic* Test_EchoMetrics::mutable_anlp() { + set_has_anlp(); + if (anlp_ == NULL) anlp_ = new ::audio_processing_unittest::Test_Statistic; + return anlp_; +} +inline ::audio_processing_unittest::Test_Statistic* Test_EchoMetrics::release_anlp() { + clear_has_anlp(); + ::audio_processing_unittest::Test_Statistic* temp = anlp_; + anlp_ = NULL; + return temp; +} + +// ------------------------------------------------------------------- + +// Test + +// optional int32 numReverseChannels = 1; +inline bool Test::has_numreversechannels() const { + return (_has_bits_[0] & 0x00000001u) != 0; +} +inline void Test::set_has_numreversechannels() { + _has_bits_[0] |= 0x00000001u; +} +inline void Test::clear_has_numreversechannels() { + _has_bits_[0] &= ~0x00000001u; +} +inline void Test::clear_numreversechannels() { + numreversechannels_ = 0; + clear_has_numreversechannels(); +} +inline ::google::protobuf::int32 Test::numreversechannels() const { + return numreversechannels_; +} +inline void Test::set_numreversechannels(::google::protobuf::int32 value) { + set_has_numreversechannels(); + numreversechannels_ = value; +} + +// optional int32 numChannels = 2; +inline bool Test::has_numchannels() const { + return (_has_bits_[0] & 0x00000002u) != 0; +} +inline void Test::set_has_numchannels() { + _has_bits_[0] |= 0x00000002u; +} +inline void Test::clear_has_numchannels() { + _has_bits_[0] &= ~0x00000002u; +} +inline void Test::clear_numchannels() { + numchannels_ = 0; + clear_has_numchannels(); +} +inline ::google::protobuf::int32 Test::numchannels() const { + return numchannels_; +} +inline void Test::set_numchannels(::google::protobuf::int32 value) { + set_has_numchannels(); + numchannels_ = value; +} + +// optional int32 sampleRate = 3; +inline bool Test::has_samplerate() const { + return (_has_bits_[0] & 0x00000004u) != 0; +} +inline void Test::set_has_samplerate() { + _has_bits_[0] |= 0x00000004u; +} +inline void Test::clear_has_samplerate() { + _has_bits_[0] &= ~0x00000004u; +} +inline void Test::clear_samplerate() { + samplerate_ = 0; + clear_has_samplerate(); +} +inline ::google::protobuf::int32 Test::samplerate() const { + return samplerate_; +} +inline void Test::set_samplerate(::google::protobuf::int32 value) { + set_has_samplerate(); + samplerate_ = value; +} + +// optional int32 hasEchoCount = 4; +inline bool Test::has_hasechocount() const { + return (_has_bits_[0] & 0x00000008u) != 0; +} +inline void Test::set_has_hasechocount() { + _has_bits_[0] |= 0x00000008u; +} +inline void Test::clear_has_hasechocount() { + _has_bits_[0] &= ~0x00000008u; +} +inline void Test::clear_hasechocount() { + hasechocount_ = 0; + clear_has_hasechocount(); +} +inline ::google::protobuf::int32 Test::hasechocount() const { + return hasechocount_; +} +inline void Test::set_hasechocount(::google::protobuf::int32 value) { + set_has_hasechocount(); + hasechocount_ = value; +} + +// optional int32 hasVoiceCount = 5; +inline bool Test::has_hasvoicecount() const { + return (_has_bits_[0] & 0x00000010u) != 0; +} +inline void Test::set_has_hasvoicecount() { + _has_bits_[0] |= 0x00000010u; +} +inline void Test::clear_has_hasvoicecount() { + _has_bits_[0] &= ~0x00000010u; +} +inline void Test::clear_hasvoicecount() { + hasvoicecount_ = 0; + clear_has_hasvoicecount(); +} +inline ::google::protobuf::int32 Test::hasvoicecount() const { + return hasvoicecount_; +} +inline void Test::set_hasvoicecount(::google::protobuf::int32 value) { + set_has_hasvoicecount(); + hasvoicecount_ = value; +} + +// optional int32 isSaturatedCount = 6; +inline bool Test::has_issaturatedcount() const { + return (_has_bits_[0] & 0x00000020u) != 0; +} +inline void Test::set_has_issaturatedcount() { + _has_bits_[0] |= 0x00000020u; +} +inline void Test::clear_has_issaturatedcount() { + _has_bits_[0] &= ~0x00000020u; +} +inline void Test::clear_issaturatedcount() { + issaturatedcount_ = 0; + clear_has_issaturatedcount(); +} +inline ::google::protobuf::int32 Test::issaturatedcount() const { + return issaturatedcount_; +} +inline void Test::set_issaturatedcount(::google::protobuf::int32 value) { + set_has_issaturatedcount(); + issaturatedcount_ = value; +} + +// optional .audio_processing_unittest.Test.EchoMetrics echoMetrics = 7; +inline bool Test::has_echometrics() const { + return (_has_bits_[0] & 0x00000040u) != 0; +} +inline void Test::set_has_echometrics() { + _has_bits_[0] |= 0x00000040u; +} +inline void Test::clear_has_echometrics() { + _has_bits_[0] &= ~0x00000040u; +} +inline void Test::clear_echometrics() { + if (echometrics_ != NULL) echometrics_->::audio_processing_unittest::Test_EchoMetrics::Clear(); + clear_has_echometrics(); +} +inline const ::audio_processing_unittest::Test_EchoMetrics& Test::echometrics() const { + return echometrics_ != NULL ? *echometrics_ : *default_instance_->echometrics_; +} +inline ::audio_processing_unittest::Test_EchoMetrics* Test::mutable_echometrics() { + set_has_echometrics(); + if (echometrics_ == NULL) echometrics_ = new ::audio_processing_unittest::Test_EchoMetrics; + return echometrics_; +} +inline ::audio_processing_unittest::Test_EchoMetrics* Test::release_echometrics() { + clear_has_echometrics(); + ::audio_processing_unittest::Test_EchoMetrics* temp = echometrics_; + echometrics_ = NULL; + return temp; +} + +// ------------------------------------------------------------------- + +// OutputData + +// repeated .audio_processing_unittest.Test test = 1; +inline int OutputData::test_size() const { + return test_.size(); +} +inline void OutputData::clear_test() { + test_.Clear(); +} +inline const ::audio_processing_unittest::Test& OutputData::test(int index) const { + return test_.Get(index); +} +inline ::audio_processing_unittest::Test* OutputData::mutable_test(int index) { + return test_.Mutable(index); +} +inline ::audio_processing_unittest::Test* OutputData::add_test() { + return test_.Add(); +} +inline const ::google::protobuf::RepeatedPtrField< ::audio_processing_unittest::Test >& +OutputData::test() const { + return test_; +} +inline ::google::protobuf::RepeatedPtrField< ::audio_processing_unittest::Test >* +OutputData::mutable_test() { + return &test_; +} + + +// @@protoc_insertion_point(namespace_scope) + +} // namespace audio_processing_unittest + +// @@protoc_insertion_point(global_scope) + +#endif // PROTOBUF_audio_5fprocessing_5funittest_2eproto__INCLUDED diff --git a/modules/audio_processing/main/test/unit_test/audio_processing_unittest.proto b/modules/audio_processing/main/test/unit_test/audio_processing_unittest.proto new file mode 100644 index 0000000000..8520e64f22 --- /dev/null +++ b/modules/audio_processing/main/test/unit_test/audio_processing_unittest.proto @@ -0,0 +1,33 @@ +package audio_processing_unittest; +option optimize_for = LITE_RUNTIME; + +message Test { + optional int32 numReverseChannels = 1; + optional int32 numChannels = 2; + optional int32 sampleRate = 3; + + optional int32 hasEchoCount = 4; + optional int32 hasVoiceCount = 5; + optional int32 isSaturatedCount = 6; + + message Statistic { + optional int32 instant = 1; + optional int32 average = 2; + optional int32 maximum = 3; + optional int32 minimum = 4; + } + + message EchoMetrics { + optional Statistic residualEchoReturnLoss = 1; + optional Statistic echoReturnLoss = 2; + optional Statistic echoReturnLossEnhancement = 3; + optional Statistic aNlp = 4; + } + + optional EchoMetrics echoMetrics = 7; +} + +message OutputData { + repeated Test test = 1; +} + diff --git a/modules/audio_processing/main/test/unit_test/unit_test.cc b/modules/audio_processing/main/test/unit_test/unit_test.cc index 9ebae5a0ff..3a6fce5a3f 100644 --- a/modules/audio_processing/main/test/unit_test/unit_test.cc +++ b/modules/audio_processing/main/test/unit_test/unit_test.cc @@ -8,14 +8,17 @@ * be found in the AUTHORS file in the root of the source tree. */ -#include "unit_test.h" +#include +#include + +#include "audio_processing.h" +#include "audio_processing_unittest.pb.h" #include "event_wrapper.h" #include "module_common_types.h" #include "thread_wrapper.h" #include "trace.h" #include "signal_processing_library.h" -#include "audio_processing.h" using webrtc::AudioProcessing; using webrtc::AudioFrame; @@ -30,10 +33,141 @@ using webrtc::EchoControlMobile; using webrtc::VoiceDetection; namespace { +// When true, this will compare the output data with the results stored to +// file. This is the typical case. When the file should be updated, it can +// be set to false with the command-line switch --write_output_data. +bool global_read_output_data = true; -// If false, this will write out a new statistics file. -// For usual testing we normally want to read the file. -const bool kReadStatFile = true; +class ApmEnvironment : public ::testing::Environment { + public: + virtual void SetUp() { + Trace::CreateTrace(); + ASSERT_EQ(0, Trace::SetTraceFile("apm_trace.txt")); + } + + virtual void TearDown() { + Trace::ReturnTrace(); + } +}; + +class ApmTest : public ::testing::Test { + protected: + ApmTest(); + virtual void SetUp(); + virtual void TearDown(); + + webrtc::AudioProcessing* apm_; + webrtc::AudioFrame* frame_; + webrtc::AudioFrame* revframe_; + FILE* far_file_; + FILE* near_file_; + bool update_output_data_; +}; + +ApmTest::ApmTest() + : apm_(NULL), + far_file_(NULL), + near_file_(NULL), + frame_(NULL), + revframe_(NULL) {} + +void ApmTest::SetUp() { + apm_ = AudioProcessing::Create(0); + ASSERT_TRUE(apm_ != NULL); + + frame_ = new AudioFrame(); + revframe_ = new AudioFrame(); + + ASSERT_EQ(apm_->kNoError, apm_->set_sample_rate_hz(32000)); + ASSERT_EQ(apm_->kNoError, apm_->set_num_channels(2, 2)); + ASSERT_EQ(apm_->kNoError, apm_->set_num_reverse_channels(2)); + + frame_->_payloadDataLengthInSamples = 320; + frame_->_audioChannel = 2; + frame_->_frequencyInHz = 32000; + revframe_->_payloadDataLengthInSamples = 320; + revframe_->_audioChannel = 2; + revframe_->_frequencyInHz = 32000; + + far_file_ = fopen("aec_far.pcm", "rb"); + ASSERT_TRUE(far_file_ != NULL) << "Could not open input file aec_far.pcm\n"; + near_file_ = fopen("aec_near.pcm", "rb"); + ASSERT_TRUE(near_file_ != NULL) << "Could not open input file aec_near.pcm\n"; +} + +void ApmTest::TearDown() { + if (frame_) { + delete frame_; + } + frame_ = NULL; + + if (revframe_) { + delete revframe_; + } + revframe_ = NULL; + + if (far_file_) { + ASSERT_EQ(0, fclose(far_file_)); + } + far_file_ = NULL; + + if (near_file_) { + ASSERT_EQ(0, fclose(near_file_)); + } + near_file_ = NULL; + + if (apm_ != NULL) { + AudioProcessing::Destroy(apm_); + } + apm_ = NULL; +} + +void MixStereoToMono(WebRtc_Word16* stereo, + WebRtc_Word16* mono, + int numSamples) { + for (int i = 0; i < numSamples; i++) { + int int32 = (static_cast(stereo[i * 2]) + + static_cast(stereo[i * 2 + 1])) >> 1; + mono[i] = static_cast(int32); + } +} + +void WriteMessageLiteToFile(const char* filename, + const ::google::protobuf::MessageLite& message) { + assert(filename != NULL); + + FILE* file = fopen(filename, "wb"); + ASSERT_TRUE(file != NULL) << "Could not open " << filename; + int size = message.ByteSize(); + ASSERT_GT(size, 0); + unsigned char* array = new unsigned char[size]; + ASSERT_TRUE(message.SerializeToArray(array, size)); + + ASSERT_EQ(1, fwrite(&size, sizeof(int), 1, file)); + ASSERT_EQ(size, fwrite(array, sizeof(unsigned char), size, file)); + + delete [] array; + fclose(file); +} + +void ReadMessageLiteFromFile(const char* filename, + ::google::protobuf::MessageLite* message) { + assert(filename != NULL); + assert(message != NULL); + + FILE* file = fopen(filename, "rb"); + ASSERT_TRUE(file != NULL) << "Could not open " << filename; + int size = 0; + ASSERT_EQ(1, fread(&size, sizeof(int), 1, file)); + ASSERT_GT(size, 0); + unsigned char* array = new unsigned char[size]; + ASSERT_EQ(size, fread(array, sizeof(unsigned char), size, file)); + + ASSERT_TRUE(message->ParseFromArray(array, size)); + + delete [] array; + fclose(file); +} struct ThreadData { ThreadData(int thread_num_, AudioProcessing* ap_) @@ -99,89 +233,6 @@ bool DeadlockProc(void* thread_object) { return true; } -} // namespace - -class ApmEnvironment : public ::testing::Environment { - public: - virtual void SetUp() { - Trace::CreateTrace(); - ASSERT_EQ(0, Trace::SetTraceFile("apm_trace.txt")); - } - - virtual void TearDown() { - Trace::ReturnTrace(); - } -}; - -ApmTest::ApmTest() - : apm_(NULL), - far_file_(NULL), - near_file_(NULL), - stat_file_(NULL), - frame_(NULL), - reverse_frame_(NULL) {} - -void ApmTest::SetUp() { - apm_ = AudioProcessing::Create(0); - ASSERT_TRUE(apm_ != NULL); - - frame_ = new AudioFrame(); - reverse_frame_ = new AudioFrame(); - - ASSERT_EQ(apm_->kNoError, apm_->set_sample_rate_hz(32000)); - ASSERT_EQ(apm_->kNoError, apm_->set_num_channels(2, 2)); - ASSERT_EQ(apm_->kNoError, apm_->set_num_reverse_channels(2)); - - frame_->_payloadDataLengthInSamples = 320; - frame_->_audioChannel = 2; - frame_->_frequencyInHz = 32000; - reverse_frame_->_payloadDataLengthInSamples = 320; - reverse_frame_->_audioChannel = 2; - reverse_frame_->_frequencyInHz = 32000; - - far_file_ = fopen("aec_far.pcm", "rb"); - ASSERT_TRUE(far_file_ != NULL) << "Cannot read source file aec_far.pcm\n"; - near_file_ = fopen("aec_near.pcm", "rb"); - ASSERT_TRUE(near_file_ != NULL) << "Cannot read source file aec_near.pcm\n"; - - if (kReadStatFile) { - stat_file_ = fopen("stat_data.dat", "rb"); - ASSERT_TRUE(stat_file_ != NULL) << - "Cannot write to source file stat_data.dat\n"; - } -} - -void ApmTest::TearDown() { - if (frame_) { - delete frame_; - } - frame_ = NULL; - - if (reverse_frame_) { - delete reverse_frame_; - } - reverse_frame_ = NULL; - - if (far_file_) { - ASSERT_EQ(0, fclose(far_file_)); - } - far_file_ = NULL; - - if (near_file_) { - ASSERT_EQ(0, fclose(near_file_)); - } - near_file_ = NULL; - - if (stat_file_) { - ASSERT_EQ(0, fclose(stat_file_)); - } - stat_file_ = NULL; - - if (apm_ != NULL) { - AudioProcessing::Destroy(apm_); - } - apm_ = NULL; -} /*TEST_F(ApmTest, Deadlock) { const int num_threads = 16; @@ -266,7 +317,7 @@ TEST_F(ApmTest, StreamParameters) { // No stream parameters EXPECT_EQ(apm_->kNoError, apm_->Initialize()); EXPECT_EQ(apm_->kNoError, - apm_->AnalyzeReverseStream(reverse_frame_)); + apm_->AnalyzeReverseStream(revframe_)); EXPECT_EQ(apm_->kStreamParameterNotSetError, apm_->ProcessStream(frame_)); @@ -317,22 +368,29 @@ TEST_F(ApmTest, SampleRates) { } TEST_F(ApmTest, Process) { - if (!kReadStatFile) { - stat_file_ = fopen("statData.dat", "wb"); - ASSERT_TRUE(stat_file_ != NULL) - << "Cannot write to source file statData.dat\n"; + GOOGLE_PROTOBUF_VERIFY_VERSION; + audio_processing_unittest::OutputData output_data; + + if (global_read_output_data) { + ReadMessageLiteFromFile("output_data.pb", &output_data); + + } else { + // We don't have a file; add the required tests to the protobuf. + int rev_ch[] = {1, 2}; + int ch[] = {1, 2}; + int fs[] = {8000, 16000, 32000}; + for (size_t i = 0; i < sizeof(rev_ch) / sizeof(*rev_ch); i++) { + for (size_t j = 0; j < sizeof(ch) / sizeof(*ch); j++) { + for (size_t k = 0; k < sizeof(fs) / sizeof(*fs); k++) { + audio_processing_unittest::Test* test = output_data.add_test(); + test->set_numreversechannels(rev_ch[i]); + test->set_numchannels(ch[j]); + test->set_samplerate(fs[k]); + } + } + } } - AudioFrame render_audio; - AudioFrame capture_audio; - - render_audio._payloadDataLengthInSamples = 320; - render_audio._audioChannel = 2; - render_audio._frequencyInHz = 32000; - capture_audio._payloadDataLengthInSamples = 320; - capture_audio._audioChannel = 2; - capture_audio._frequencyInHz = 32000; - EXPECT_EQ(apm_->kNoError, apm_->echo_cancellation()->enable_drift_compensation(true)); EXPECT_EQ(apm_->kNoError, @@ -348,8 +406,8 @@ TEST_F(ApmTest, Process) { EXPECT_EQ(apm_->kNoError, apm_->high_pass_filter()->Enable(true)); - EXPECT_EQ(apm_->kUnsupportedComponentError, - apm_->level_estimator()->Enable(true)); + //EXPECT_EQ(apm_->kNoError, + // apm_->level_estimator()->Enable(true)); EXPECT_EQ(apm_->kNoError, apm_->noise_suppression()->Enable(true)); @@ -357,339 +415,132 @@ TEST_F(ApmTest, Process) { EXPECT_EQ(apm_->kNoError, apm_->voice_detection()->Enable(true)); - LevelEstimator::Metrics far_metrics; - LevelEstimator::Metrics near_metrics; - EchoCancellation::Metrics echo_metrics; - for (int i = 0; i < 100; i++) { - EXPECT_EQ(apm_->kNoError, - apm_->AnalyzeReverseStream(&render_audio)); + for (int i = 0; i < output_data.test_size(); i++) { + printf("Running test %d of %d...\n", i + 1, output_data.test_size()); - EXPECT_EQ(apm_->kNoError, apm_->set_stream_delay_ms(100)); - EXPECT_EQ(apm_->kNoError, - apm_->echo_cancellation()->set_stream_drift_samples(0)); + audio_processing_unittest::Test* test = output_data.mutable_test(i); + const int num_samples = test->samplerate() / 100; + revframe_->_payloadDataLengthInSamples = num_samples; + revframe_->_audioChannel = test->numreversechannels(); + revframe_->_frequencyInHz = test->samplerate(); + frame_->_payloadDataLengthInSamples = num_samples; + frame_->_audioChannel = test->numchannels(); + frame_->_frequencyInHz = test->samplerate(); - EXPECT_EQ(apm_->kNoError, - apm_->gain_control()->set_stream_analog_level(127)); + EXPECT_EQ(apm_->kNoError, apm_->Initialize()); + ASSERT_EQ(apm_->kNoError, apm_->set_sample_rate_hz(test->samplerate())); + ASSERT_EQ(apm_->kNoError, apm_->set_num_channels(frame_->_audioChannel, + frame_->_audioChannel)); + ASSERT_EQ(apm_->kNoError, + apm_->set_num_reverse_channels(revframe_->_audioChannel)); - EXPECT_EQ(apm_->kNoError, apm_->ProcessStream(&capture_audio)); - apm_->echo_cancellation()->stream_has_echo(); - EXPECT_EQ(apm_->kNoError, - apm_->echo_cancellation()->GetMetrics(&echo_metrics)); + int has_echo_count = 0; + int has_voice_count = 0; + int is_saturated_count = 0; - apm_->gain_control()->stream_analog_level(); - apm_->gain_control()->stream_is_saturated(); + while (1) { + WebRtc_Word16 temp_data[640]; + int analog_level = 127; - EXPECT_EQ(apm_->kUnsupportedComponentError, - apm_->level_estimator()->GetMetrics(&near_metrics, - &far_metrics)); + // Read far-end frame + size_t read_count = fread(temp_data, + sizeof(WebRtc_Word16), + num_samples * 2, + far_file_); + if (read_count != static_cast(num_samples * 2)) { + // Check that the file really ended. + ASSERT_NE(0, feof(far_file_)); + break; // This is expected. + } - apm_->voice_detection()->stream_has_voice(); - } + if (revframe_->_audioChannel == 1) { + MixStereoToMono(temp_data, revframe_->_payloadData, + revframe_->_payloadDataLengthInSamples); + } else { + memcpy(revframe_->_payloadData, + &temp_data[0], + sizeof(WebRtc_Word16) * read_count); + } - // Test with real audio - // Loop through all possible combinations - // (# reverse channels, # channels, sample rates) - int rev_ch[] = {1, 2}; - int ch[] = {1, 2}; - int fs[] = {8000, 16000, 32000}; - size_t rev_ch_size = sizeof(rev_ch) / sizeof(*rev_ch); - size_t ch_size = sizeof(ch) / sizeof(*ch); - size_t fs_size = sizeof(fs) / sizeof(*fs); - if (kReadStatFile) { - fread(&rev_ch_size, sizeof(rev_ch_size), 1, stat_file_); - fread(rev_ch, sizeof(int), rev_ch_size, stat_file_); - fread(&ch_size, sizeof(ch_size), 1, stat_file_); - fread(ch, sizeof(int), ch_size, stat_file_); - fread(&fs_size, sizeof(fs_size), 1, stat_file_); - fread(fs, sizeof(int), fs_size, stat_file_); - } else { - fwrite(&rev_ch_size, sizeof(int), 1, stat_file_); - fwrite(rev_ch, sizeof(int), rev_ch_size, stat_file_); - fwrite(&ch_size, sizeof(int), 1, stat_file_); - fwrite(ch, sizeof(int), ch_size, stat_file_); - fwrite(&fs_size, sizeof(int), 1, stat_file_); - fwrite(fs, sizeof(int), fs_size, stat_file_); - } - int test_count = 0; - for (size_t i_rev_ch = 0; i_rev_ch < rev_ch_size; i_rev_ch++) { - for (size_t i_ch = 0; i_ch < ch_size; i_ch++) { - for (size_t i_fs = 0; i_fs < fs_size; i_fs++) { - render_audio._payloadDataLengthInSamples = fs[i_fs] / 100; - render_audio._audioChannel = rev_ch[i_rev_ch]; - render_audio._frequencyInHz = fs[i_fs]; - capture_audio._payloadDataLengthInSamples = fs[i_fs] / 100; - capture_audio._audioChannel = ch[i_ch]; - capture_audio._frequencyInHz = fs[i_fs]; + EXPECT_EQ(apm_->kNoError, + apm_->AnalyzeReverseStream(revframe_)); - EXPECT_EQ(apm_->kNoError, apm_->Initialize()); - ASSERT_EQ(apm_->kNoError, apm_->set_sample_rate_hz(fs[i_fs])); - ASSERT_EQ(apm_->kNoError, - apm_->set_num_channels(capture_audio._audioChannel, - capture_audio._audioChannel)); - ASSERT_EQ(apm_->kNoError, - apm_->set_num_reverse_channels(render_audio._audioChannel)); - EXPECT_EQ(apm_->kNoError, - apm_->echo_cancellation()->enable_drift_compensation(false)); - EXPECT_EQ(apm_->kNoError, - apm_->echo_cancellation()->enable_metrics(true)); - EXPECT_EQ(apm_->kNoError, apm_->echo_cancellation()->Enable(true)); + EXPECT_EQ(apm_->kNoError, apm_->set_stream_delay_ms(0)); + EXPECT_EQ(apm_->kNoError, + apm_->echo_cancellation()->set_stream_drift_samples(0)); + EXPECT_EQ(apm_->kNoError, + apm_->gain_control()->set_stream_analog_level(analog_level)); - EXPECT_EQ(apm_->kNoError, - apm_->gain_control()->set_mode(GainControl::kAdaptiveAnalog)); - EXPECT_EQ(apm_->kNoError, - apm_->gain_control()->set_analog_level_limits(0, 255)); - EXPECT_EQ(apm_->kNoError, apm_->gain_control()->Enable(true)); + // Read near-end frame + read_count = fread(temp_data, + sizeof(WebRtc_Word16), + num_samples * 2, + near_file_); + if (read_count != static_cast(num_samples * 2)) { + // Check that the file really ended. + ASSERT_NE(0, feof(near_file_)); + break; // This is expected. + } - EXPECT_EQ(apm_->kNoError, - apm_->high_pass_filter()->Enable(true)); + if (frame_->_audioChannel == 1) { + MixStereoToMono(temp_data, frame_->_payloadData, num_samples); + } else { + memcpy(frame_->_payloadData, + &temp_data[0], + sizeof(WebRtc_Word16) * read_count); + } - //EXPECT_EQ(apm_->kNoError, - // apm_->level_estimator()->Enable(true)); + EXPECT_EQ(apm_->kNoError, apm_->ProcessStream(frame_)); - EXPECT_EQ(apm_->kNoError, - apm_->noise_suppression()->Enable(true)); + if (apm_->echo_cancellation()->stream_has_echo()) { + has_echo_count++; + } - EXPECT_EQ(apm_->kNoError, - apm_->voice_detection()->Enable(true)); - bool runningFiles = true; - int echo_count = 0; - int vad_count = 0; - int sat_count = 0; - int analog_level = 127; - int sat_gain = 2; - size_t read_count = 0; - WebRtc_Word16 tmpData[640]; - int tmp_int; - - int echo_count_ref_ = 0; - int vad_count_ref_ = 0; - int sat_count_ref_ = 0; - //LevelEstimator::Metrics far_metrics_ref_; - //LevelEstimator::Metrics near_metrics_ref_; - EchoCancellation::Metrics echo_metrics_ref_; - - while (runningFiles) { - // Read far end frame - read_count = fread(tmpData, - sizeof(WebRtc_Word16), - render_audio._payloadDataLengthInSamples * 2, - far_file_); - if (read_count != - static_cast - (render_audio._payloadDataLengthInSamples * 2)) { - break; // This is expected. - } - if (render_audio._audioChannel == 1) { - for (int i = 0; i < render_audio._payloadDataLengthInSamples; - i++) { - tmp_int = (static_cast(tmpData[i * 2]) + - static_cast(tmpData[i * 2 + 1])) >> 1; - render_audio._payloadData[i] = - static_cast(tmp_int); - } - } else { - memcpy(render_audio._payloadData, - &tmpData[0], - sizeof(WebRtc_Word16) * read_count); - } - EXPECT_EQ(apm_->kNoError, - apm_->AnalyzeReverseStream(&render_audio)); - - EXPECT_EQ(apm_->kNoError, apm_->set_stream_delay_ms(0)); - EXPECT_EQ(apm_->kNoError, - apm_->gain_control()->set_stream_analog_level(analog_level)); - - // Read near end frame - read_count = fread(tmpData, - sizeof(WebRtc_Word16), - capture_audio._payloadDataLengthInSamples * 2, - near_file_); - if (read_count != - static_cast - (capture_audio._payloadDataLengthInSamples * 2)) { - break; // This is expected. - } - if (capture_audio._audioChannel == 1) { - for (int i = 0; - i < capture_audio._payloadDataLengthInSamples; i++) { - tmp_int = (static_cast(tmpData[i * 2]) + - static_cast(tmpData[i * 2 + 1])) >> 1; - capture_audio._payloadData[i] = - static_cast(tmp_int); - } - } else { - memcpy(capture_audio._payloadData, - &tmpData[0], - sizeof(WebRtc_Word16) * read_count); - } - WebRtc_Word32 tmpF = 0; - for (size_t i = 0; i < read_count; i++) { - tmpF = (WebRtc_Word32)capture_audio._payloadData[i] * sat_gain; - if (tmpF > WEBRTC_SPL_WORD16_MAX) { - capture_audio._payloadData[i] = WEBRTC_SPL_WORD16_MAX; - } else if (tmpF < WEBRTC_SPL_WORD16_MIN) { - capture_audio._payloadData[i] = WEBRTC_SPL_WORD16_MIN; - } else { - capture_audio._payloadData[i] = static_cast(tmpF); - } - } - EXPECT_EQ(apm_->kNoError, apm_->ProcessStream(&capture_audio)); - - if (apm_->echo_cancellation()->stream_has_echo()) { - echo_count++; - } - - analog_level = apm_->gain_control()->stream_analog_level(); - if (apm_->gain_control()->stream_is_saturated()) { - sat_count++; - sat_gain = 1; - } - if (apm_->voice_detection()->stream_has_voice()) { - vad_count++; - } - } - //<-- Statistics --> - EXPECT_EQ(apm_->kNoError, - apm_->echo_cancellation()->GetMetrics(&echo_metrics)); - //EXPECT_EQ(apm_->kNoError, - // apm_->level_estimator()->GetMetrics(&near_metrics, - - // TODO(ajm): Perhaps we don't have to check every value? The average - // could be sufficient. Or, how about hashing the output? - if (kReadStatFile) { - // Read from statData - fread(&echo_count_ref_, 1, sizeof(echo_count), stat_file_); - EXPECT_EQ(echo_count_ref_, echo_count); - fread(&echo_metrics_ref_, - 1, - sizeof(EchoCancellation::Metrics), - stat_file_); - EXPECT_EQ(echo_metrics_ref_.residual_echo_return_loss.instant, - echo_metrics.residual_echo_return_loss.instant); - EXPECT_EQ(echo_metrics_ref_.residual_echo_return_loss.average, - echo_metrics.residual_echo_return_loss.average); - EXPECT_EQ(echo_metrics_ref_.residual_echo_return_loss.maximum, - echo_metrics.residual_echo_return_loss.maximum); - EXPECT_EQ(echo_metrics_ref_.residual_echo_return_loss.minimum, - echo_metrics.residual_echo_return_loss.minimum); - EXPECT_EQ(echo_metrics_ref_.echo_return_loss.instant, - echo_metrics.echo_return_loss.instant); - EXPECT_EQ(echo_metrics_ref_.echo_return_loss.average, - echo_metrics.echo_return_loss.average); - EXPECT_EQ(echo_metrics_ref_.echo_return_loss.maximum, - echo_metrics.echo_return_loss.maximum); - EXPECT_EQ(echo_metrics_ref_.echo_return_loss.minimum, - echo_metrics.echo_return_loss.minimum); - EXPECT_EQ(echo_metrics_ref_.echo_return_loss_enhancement.instant, - echo_metrics.echo_return_loss_enhancement.instant); - EXPECT_EQ(echo_metrics_ref_.echo_return_loss_enhancement.average, - echo_metrics.echo_return_loss_enhancement.average); - EXPECT_EQ(echo_metrics_ref_.echo_return_loss_enhancement.maximum, - echo_metrics.echo_return_loss_enhancement.maximum); - EXPECT_EQ(echo_metrics_ref_.echo_return_loss_enhancement.minimum, - echo_metrics.echo_return_loss_enhancement.minimum); - EXPECT_EQ(echo_metrics_ref_.a_nlp.instant, - echo_metrics.a_nlp.instant); - EXPECT_EQ(echo_metrics_ref_.a_nlp.average, - echo_metrics.a_nlp.average); - EXPECT_EQ(echo_metrics_ref_.a_nlp.maximum, - echo_metrics.a_nlp.maximum); - EXPECT_EQ(echo_metrics_ref_.a_nlp.minimum, - echo_metrics.a_nlp.minimum); - - fread(&vad_count_ref_, 1, sizeof(vad_count), stat_file_); - EXPECT_EQ(vad_count_ref_, vad_count); - fread(&sat_count_ref_, 1, sizeof(sat_count), stat_file_); - EXPECT_EQ(sat_count_ref_, sat_count); - - /*fread(&far_metrics_ref_, - 1, - sizeof(LevelEstimator::Metrics), - stat_file_); - EXPECT_EQ(far_metrics_ref_.signal.instant, - far_metrics.signal.instant); - EXPECT_EQ(far_metrics_ref_.signal.average, - far_metrics.signal.average); - EXPECT_EQ(far_metrics_ref_.signal.maximum, - far_metrics.signal.maximum); - EXPECT_EQ(far_metrics_ref_.signal.minimum, - far_metrics.signal.minimum); - - EXPECT_EQ(far_metrics_ref_.speech.instant, - far_metrics.speech.instant); - EXPECT_EQ(far_metrics_ref_.speech.average, - far_metrics.speech.average); - EXPECT_EQ(far_metrics_ref_.speech.maximum, - far_metrics.speech.maximum); - EXPECT_EQ(far_metrics_ref_.speech.minimum, - far_metrics.speech.minimum); - - EXPECT_EQ(far_metrics_ref_.noise.instant, - far_metrics.noise.instant); - EXPECT_EQ(far_metrics_ref_.noise.average, - far_metrics.noise.average); - EXPECT_EQ(far_metrics_ref_.noise.maximum, - far_metrics.noise.maximum); - EXPECT_EQ(far_metrics_ref_.noise.minimum, - far_metrics.noise.minimum); - - fread(&near_metrics_ref_, - 1, - sizeof(LevelEstimator::Metrics), - stat_file_); - EXPECT_EQ(near_metrics_ref_.signal.instant, - near_metrics.signal.instant); - EXPECT_EQ(near_metrics_ref_.signal.average, - near_metrics.signal.average); - EXPECT_EQ(near_metrics_ref_.signal.maximum, - near_metrics.signal.maximum); - EXPECT_EQ(near_metrics_ref_.signal.minimum, - near_metrics.signal.minimum); - - EXPECT_EQ(near_metrics_ref_.speech.instant, - near_metrics.speech.instant); - EXPECT_EQ(near_metrics_ref_.speech.average, - near_metrics.speech.average); - EXPECT_EQ(near_metrics_ref_.speech.maximum, - near_metrics.speech.maximum); - EXPECT_EQ(near_metrics_ref_.speech.minimum, - near_metrics.speech.minimum); - - EXPECT_EQ(near_metrics_ref_.noise.instant, - near_metrics.noise.instant); - EXPECT_EQ(near_metrics_ref_.noise.average, - near_metrics.noise.average); - EXPECT_EQ(near_metrics_ref_.noise.maximum, - near_metrics.noise.maximum); - EXPECT_EQ(near_metrics_ref_.noise.minimum, - near_metrics.noise.minimum);*/ - } else { - // Write to statData - fwrite(&echo_count, 1, sizeof(echo_count), stat_file_); - fwrite(&echo_metrics, - 1, - sizeof(EchoCancellation::Metrics), - stat_file_); - fwrite(&vad_count, 1, sizeof(vad_count), stat_file_); - fwrite(&sat_count, 1, sizeof(sat_count), stat_file_); - //fwrite(&far_metrics, 1, sizeof(LevelEstimator::Metrics), stat_file_); - //fwrite(&near_metrics, 1, sizeof(LevelEstimator::Metrics), stat_file_); - } - - rewind(far_file_); - rewind(near_file_); - test_count++; - printf("Loop %d of %lu\n", test_count, rev_ch_size * ch_size * fs_size); + analog_level = apm_->gain_control()->stream_analog_level(); + if (apm_->gain_control()->stream_is_saturated()) { + is_saturated_count++; + } + if (apm_->voice_detection()->stream_has_voice()) { + has_voice_count++; } } - } - if (!kReadStatFile) { - if (stat_file_ != NULL) { - ASSERT_EQ(0, fclose(stat_file_)); + + //<-- Statistics --> + //LevelEstimator::Metrics far_metrics; + //LevelEstimator::Metrics near_metrics; + //EchoCancellation::Metrics echo_metrics; + //LevelEstimator::Metrics far_metrics_ref_; + //LevelEstimator::Metrics near_metrics_ref_; + //EchoCancellation::Metrics echo_metrics_ref_; + //EXPECT_EQ(apm_->kNoError, + // apm_->echo_cancellation()->GetMetrics(&echo_metrics)); + //EXPECT_EQ(apm_->kNoError, + // apm_->level_estimator()->GetMetrics(&near_metrics, + + // TODO(ajm): check echo metrics and output audio. + if (global_read_output_data) { + EXPECT_EQ(has_echo_count, + test->hasechocount()); + EXPECT_EQ(has_voice_count, + test->hasvoicecount()); + EXPECT_EQ(is_saturated_count, + test->issaturatedcount()); + } else { + test->set_hasechocount(has_echo_count); + test->set_hasvoicecount(has_voice_count); + test->set_issaturatedcount(is_saturated_count); } - stat_file_ = NULL; + + rewind(far_file_); + rewind(near_file_); } + + if (!global_read_output_data) { + WriteMessageLiteToFile("output_data.pb", output_data); + } + + google::protobuf::ShutdownProtobufLibrary(); } TEST_F(ApmTest, EchoCancellation) { @@ -1013,11 +864,18 @@ TEST_F(VideoProcessingModuleTest, IdenticalResultsAfterReset) { } */ +} // namespace int main(int argc, char** argv) { ::testing::InitGoogleTest(&argc, argv); - ApmEnvironment* env = new ApmEnvironment; + ApmEnvironment* env = new ApmEnvironment; // GTest takes ownership. ::testing::AddGlobalTestEnvironment(env); + for (int i = 1; i < argc; i++) { + if (strcmp(argv[i], "--write_output_data") == 0) { + global_read_output_data = false; + } + } + return RUN_ALL_TESTS(); } diff --git a/modules/audio_processing/main/test/unit_test/unit_test.h b/modules/audio_processing/main/test/unit_test/unit_test.h deleted file mode 100644 index 6de3bf916a..0000000000 --- a/modules/audio_processing/main/test/unit_test/unit_test.h +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (c) 2011 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_MODULES_AUDIO_PROCESSING_MAIN_TEST_UNIT_TEST_UNIT_TEST_H_ -#define WEBRTC_MODULES_AUDIO_PROCESSING_MAIN_TEST_UNIT_TEST_UNIT_TEST_H_ - -#include - -namespace webrtc { -class AudioProcessing; -class AudioFrame; -} - -class ApmTest : public ::testing::Test { - protected: - ApmTest(); - virtual void SetUp(); - virtual void TearDown(); - - webrtc::AudioProcessing* apm_; - FILE* far_file_; - FILE* near_file_; - FILE* stat_file_; - webrtc::AudioFrame* frame_; - webrtc::AudioFrame* reverse_frame_; -}; - -#endif // WEBRTC_MODULES_AUDIO_PROCESSING_MAIN_TEST_UNIT_TEST_UNIT_TEST_H_ diff --git a/test/data/audio_processing/output_data.pb b/test/data/audio_processing/output_data.pb new file mode 100644 index 0000000000..16805926f8 Binary files /dev/null and b/test/data/audio_processing/output_data.pb differ diff --git a/test/data/audio_processing/stat_data.dat b/test/data/audio_processing/stat_data.dat deleted file mode 100644 index 4783b7db6e..0000000000 Binary files a/test/data/audio_processing/stat_data.dat and /dev/null differ