Reland "Added option to specify a maximum file size when recording an AEC dump.", commit ae2c5ad12afc8cc29fe9c59dea432b697b871a87.
The revert of the original CL was commit 36d4c545007129446e551c45c17b25377dce89a4. Original review: https://codereview.webrtc.org/1413483003/ The original CL changes a function on audio_processing.h that is used by Chrome, this CL adds back the old function. TBR=glaznev@webrtc.org, henrik.lundin@webrtc.org, solenberg@google.com, henrikg@webrtc.org, perkj@webrtc.org BUG=webrtc:4741 Committed: https://crrev.com/f4f5cb09277d5ef6aeac8341e5f54a055867803a Cr-Commit-Position: refs/heads/master@{#11093} Review URL: https://codereview.webrtc.org/1540103002 Cr-Commit-Position: refs/heads/master@{#11267}
This commit is contained in:
@ -383,7 +383,8 @@ class ApmTest : public ::testing::Test {
|
||||
int AnalyzeReverseStreamChooser(Format format);
|
||||
void ProcessDebugDump(const std::string& in_filename,
|
||||
const std::string& out_filename,
|
||||
Format format);
|
||||
Format format,
|
||||
int max_size_bytes);
|
||||
void VerifyDebugDumpTest(Format format);
|
||||
|
||||
const std::string output_path_;
|
||||
@ -1706,7 +1707,8 @@ TEST_F(ApmTest, SplittingFilter) {
|
||||
#ifdef WEBRTC_AUDIOPROC_DEBUG_DUMP
|
||||
void ApmTest::ProcessDebugDump(const std::string& in_filename,
|
||||
const std::string& out_filename,
|
||||
Format format) {
|
||||
Format format,
|
||||
int max_size_bytes) {
|
||||
FILE* in_file = fopen(in_filename.c_str(), "rb");
|
||||
ASSERT_TRUE(in_file != NULL);
|
||||
audioproc::Event event_msg;
|
||||
@ -1734,7 +1736,8 @@ void ApmTest::ProcessDebugDump(const std::string& in_filename,
|
||||
if (first_init) {
|
||||
// StartDebugRecording() writes an additional init message. Don't start
|
||||
// recording until after the first init to avoid the extra message.
|
||||
EXPECT_NOERR(apm_->StartDebugRecording(out_filename.c_str()));
|
||||
EXPECT_NOERR(
|
||||
apm_->StartDebugRecording(out_filename.c_str(), max_size_bytes));
|
||||
first_init = false;
|
||||
}
|
||||
|
||||
@ -1809,34 +1812,54 @@ void ApmTest::VerifyDebugDumpTest(Format format) {
|
||||
test::OutputPath(), std::string("ref") + format_string + "_aecdump");
|
||||
const std::string out_filename = test::TempFilename(
|
||||
test::OutputPath(), std::string("out") + format_string + "_aecdump");
|
||||
const std::string limited_filename = test::TempFilename(
|
||||
test::OutputPath(), std::string("limited") + format_string + "_aecdump");
|
||||
const size_t logging_limit_bytes = 100000;
|
||||
// We expect at least this many bytes in the created logfile.
|
||||
const size_t logging_expected_bytes = 95000;
|
||||
EnableAllComponents();
|
||||
ProcessDebugDump(in_filename, ref_filename, format);
|
||||
ProcessDebugDump(ref_filename, out_filename, format);
|
||||
ProcessDebugDump(in_filename, ref_filename, format, -1);
|
||||
ProcessDebugDump(ref_filename, out_filename, format, -1);
|
||||
ProcessDebugDump(ref_filename, limited_filename, format, logging_limit_bytes);
|
||||
|
||||
FILE* ref_file = fopen(ref_filename.c_str(), "rb");
|
||||
FILE* out_file = fopen(out_filename.c_str(), "rb");
|
||||
FILE* limited_file = fopen(limited_filename.c_str(), "rb");
|
||||
ASSERT_TRUE(ref_file != NULL);
|
||||
ASSERT_TRUE(out_file != NULL);
|
||||
ASSERT_TRUE(limited_file != NULL);
|
||||
rtc::scoped_ptr<uint8_t[]> ref_bytes;
|
||||
rtc::scoped_ptr<uint8_t[]> out_bytes;
|
||||
rtc::scoped_ptr<uint8_t[]> limited_bytes;
|
||||
|
||||
size_t ref_size = ReadMessageBytesFromFile(ref_file, &ref_bytes);
|
||||
size_t out_size = ReadMessageBytesFromFile(out_file, &out_bytes);
|
||||
size_t limited_size = ReadMessageBytesFromFile(limited_file, &limited_bytes);
|
||||
size_t bytes_read = 0;
|
||||
size_t bytes_read_limited = 0;
|
||||
while (ref_size > 0 && out_size > 0) {
|
||||
bytes_read += ref_size;
|
||||
bytes_read_limited += limited_size;
|
||||
EXPECT_EQ(ref_size, out_size);
|
||||
EXPECT_GE(ref_size, limited_size);
|
||||
EXPECT_EQ(0, memcmp(ref_bytes.get(), out_bytes.get(), ref_size));
|
||||
EXPECT_EQ(0, memcmp(ref_bytes.get(), limited_bytes.get(), limited_size));
|
||||
ref_size = ReadMessageBytesFromFile(ref_file, &ref_bytes);
|
||||
out_size = ReadMessageBytesFromFile(out_file, &out_bytes);
|
||||
limited_size = ReadMessageBytesFromFile(limited_file, &limited_bytes);
|
||||
}
|
||||
EXPECT_GT(bytes_read, 0u);
|
||||
EXPECT_GT(bytes_read_limited, logging_expected_bytes);
|
||||
EXPECT_LE(bytes_read_limited, logging_limit_bytes);
|
||||
EXPECT_NE(0, feof(ref_file));
|
||||
EXPECT_NE(0, feof(out_file));
|
||||
EXPECT_NE(0, feof(limited_file));
|
||||
ASSERT_EQ(0, fclose(ref_file));
|
||||
ASSERT_EQ(0, fclose(out_file));
|
||||
ASSERT_EQ(0, fclose(limited_file));
|
||||
remove(ref_filename.c_str());
|
||||
remove(out_filename.c_str());
|
||||
remove(limited_filename.c_str());
|
||||
}
|
||||
|
||||
TEST_F(ApmTest, VerifyDebugDumpInt) {
|
||||
@ -1853,13 +1876,13 @@ TEST_F(ApmTest, DebugDump) {
|
||||
const std::string filename =
|
||||
test::TempFilename(test::OutputPath(), "debug_aec");
|
||||
EXPECT_EQ(apm_->kNullPointerError,
|
||||
apm_->StartDebugRecording(static_cast<const char*>(NULL)));
|
||||
apm_->StartDebugRecording(static_cast<const char*>(NULL), -1));
|
||||
|
||||
#ifdef WEBRTC_AUDIOPROC_DEBUG_DUMP
|
||||
// Stopping without having started should be OK.
|
||||
EXPECT_EQ(apm_->kNoError, apm_->StopDebugRecording());
|
||||
|
||||
EXPECT_EQ(apm_->kNoError, apm_->StartDebugRecording(filename.c_str()));
|
||||
EXPECT_EQ(apm_->kNoError, apm_->StartDebugRecording(filename.c_str(), -1));
|
||||
EXPECT_EQ(apm_->kNoError, apm_->ProcessStream(frame_));
|
||||
EXPECT_EQ(apm_->kNoError, apm_->AnalyzeReverseStream(revframe_));
|
||||
EXPECT_EQ(apm_->kNoError, apm_->StopDebugRecording());
|
||||
@ -1873,7 +1896,7 @@ TEST_F(ApmTest, DebugDump) {
|
||||
ASSERT_EQ(0, remove(filename.c_str()));
|
||||
#else
|
||||
EXPECT_EQ(apm_->kUnsupportedFunctionError,
|
||||
apm_->StartDebugRecording(filename.c_str()));
|
||||
apm_->StartDebugRecording(filename.c_str(), -1));
|
||||
EXPECT_EQ(apm_->kUnsupportedFunctionError, apm_->StopDebugRecording());
|
||||
|
||||
// Verify the file has NOT been written.
|
||||
@ -1884,7 +1907,7 @@ TEST_F(ApmTest, DebugDump) {
|
||||
// TODO(andrew): expand test to verify output.
|
||||
TEST_F(ApmTest, DebugDumpFromFileHandle) {
|
||||
FILE* fid = NULL;
|
||||
EXPECT_EQ(apm_->kNullPointerError, apm_->StartDebugRecording(fid));
|
||||
EXPECT_EQ(apm_->kNullPointerError, apm_->StartDebugRecording(fid, -1));
|
||||
const std::string filename =
|
||||
test::TempFilename(test::OutputPath(), "debug_aec");
|
||||
fid = fopen(filename.c_str(), "w");
|
||||
@ -1894,7 +1917,7 @@ TEST_F(ApmTest, DebugDumpFromFileHandle) {
|
||||
// Stopping without having started should be OK.
|
||||
EXPECT_EQ(apm_->kNoError, apm_->StopDebugRecording());
|
||||
|
||||
EXPECT_EQ(apm_->kNoError, apm_->StartDebugRecording(fid));
|
||||
EXPECT_EQ(apm_->kNoError, apm_->StartDebugRecording(fid, -1));
|
||||
EXPECT_EQ(apm_->kNoError, apm_->AnalyzeReverseStream(revframe_));
|
||||
EXPECT_EQ(apm_->kNoError, apm_->ProcessStream(frame_));
|
||||
EXPECT_EQ(apm_->kNoError, apm_->StopDebugRecording());
|
||||
@ -1908,7 +1931,7 @@ TEST_F(ApmTest, DebugDumpFromFileHandle) {
|
||||
ASSERT_EQ(0, remove(filename.c_str()));
|
||||
#else
|
||||
EXPECT_EQ(apm_->kUnsupportedFunctionError,
|
||||
apm_->StartDebugRecording(fid));
|
||||
apm_->StartDebugRecording(fid, -1));
|
||||
EXPECT_EQ(apm_->kUnsupportedFunctionError, apm_->StopDebugRecording());
|
||||
|
||||
ASSERT_EQ(0, fclose(fid));
|
||||
|
||||
Reference in New Issue
Block a user