Revamp of audio_processing unit test to use protocol buffers. Chromium's protobuf version is synced to third_party. This isn't really needed for the unit test, but I'd like to use it soon for echo recordings, so I used this as a warm up.
Review URL: http://webrtc-codereview.appspot.com/56002 git-svn-id: http://webrtc.googlecode.com/svn/trunk@151 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
parent
c5758f8c51
commit
7c4469bf61
3
DEPS
3
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",
|
||||
|
||||
|
@ -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',
|
||||
],
|
||||
},
|
||||
{
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -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 <string>
|
||||
|
||||
#include <google/protobuf/stubs/common.h>
|
||||
|
||||
#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 <google/protobuf/generated_message_util.h>
|
||||
#include <google/protobuf/repeated_field.h>
|
||||
#include <google/protobuf/extension_set.h>
|
||||
// @@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
|
@ -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;
|
||||
}
|
||||
|
@ -8,14 +8,17 @@
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
#include "unit_test.h"
|
||||
#include <cstdio>
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#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<int>(stereo[i * 2]) +
|
||||
static_cast<int>(stereo[i * 2 + 1])) >> 1;
|
||||
mono[i] = static_cast<WebRtc_Word16>(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<size_t>(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<size_t>(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<size_t>
|
||||
(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<int>(tmpData[i * 2]) +
|
||||
static_cast<int>(tmpData[i * 2 + 1])) >> 1;
|
||||
render_audio._payloadData[i] =
|
||||
static_cast<WebRtc_Word16>(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<size_t>
|
||||
(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<int>(tmpData[i * 2]) +
|
||||
static_cast<int>(tmpData[i * 2 + 1])) >> 1;
|
||||
capture_audio._payloadData[i] =
|
||||
static_cast<WebRtc_Word16>(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<WebRtc_Word16>(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();
|
||||
}
|
||||
|
@ -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 <gtest/gtest.h>
|
||||
|
||||
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_
|
BIN
test/data/audio_processing/output_data.pb
Normal file
BIN
test/data/audio_processing/output_data.pb
Normal file
Binary file not shown.
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user