Update to current webrtc library

This is from the upstream library commit id
3326535126e435f1ba647885ce43a8f0f3d317eb, corresponding to Chromium
88.0.4290.1.
This commit is contained in:
Arun Raghavan
2020-10-12 18:08:02 -04:00
parent b1b02581d3
commit bcec8b0b21
859 changed files with 76187 additions and 49580 deletions

View File

@ -1,86 +0,0 @@
/*
* Copyright (c) 2015 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_AEC_AEC_LOGGING_
#define WEBRTC_MODULES_AUDIO_PROCESSING_AEC_AEC_LOGGING_
#include <stdio.h>
#include "webrtc/modules/audio_processing/logging/aec_logging_file_handling.h"
// To enable AEC logging, invoke GYP with -Daec_debug_dump=1.
#ifdef WEBRTC_AEC_DEBUG_DUMP
// Dumps a wav data to file.
#define RTC_AEC_DEBUG_WAV_WRITE(file, data, num_samples) \
do { \
rtc_WavWriteSamples(file, data, num_samples); \
} while (0)
// (Re)opens a wav file for writing using the specified sample rate.
#define RTC_AEC_DEBUG_WAV_REOPEN(name, instance_index, process_rate, \
sample_rate, wav_file) \
do { \
WebRtcAec_ReopenWav(name, instance_index, process_rate, sample_rate, \
wav_file); \
} while (0)
// Closes a wav file.
#define RTC_AEC_DEBUG_WAV_CLOSE(wav_file) \
do { \
rtc_WavClose(wav_file); \
} while (0)
// Dumps a raw data to file.
#define RTC_AEC_DEBUG_RAW_WRITE(file, data, data_size) \
do { \
(void) fwrite(data, data_size, 1, file); \
} while (0)
// Opens a raw data file for writing using the specified sample rate.
#define RTC_AEC_DEBUG_RAW_OPEN(name, instance_counter, file) \
do { \
WebRtcAec_RawFileOpen(name, instance_counter, file); \
} while (0)
// Closes a raw data file.
#define RTC_AEC_DEBUG_RAW_CLOSE(file) \
do { \
fclose(file); \
} while (0)
#else // RTC_AEC_DEBUG_DUMP
#define RTC_AEC_DEBUG_WAV_WRITE(file, data, num_samples) \
do { \
} while (0)
#define RTC_AEC_DEBUG_WAV_REOPEN(wav_file, name, instance_index, process_rate, \
sample_rate) \
do { \
} while (0)
#define RTC_AEC_DEBUG_WAV_CLOSE(wav_file) \
do { \
} while (0)
#define RTC_AEC_DEBUG_RAW_WRITE(file, data, data_size) \
do { \
} while (0)
#define RTC_AEC_DEBUG_RAW_OPEN(file, name, instance_counter) \
do { \
} while (0)
#define RTC_AEC_DEBUG_RAW_CLOSE(file) \
do { \
} while (0)
#endif // WEBRTC_AEC_DEBUG_DUMP
#endif // WEBRTC_MODULES_AUDIO_PROCESSING_AEC_AEC_LOGGING_

View File

@ -1,57 +0,0 @@
/*
* Copyright (c) 2015 The WebRTC project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
#include "webrtc/modules/audio_processing/logging/aec_logging_file_handling.h"
#include <stdint.h>
#include <stdio.h>
#include "webrtc/base/checks.h"
#include "webrtc/base/stringutils.h"
#include "webrtc/common_audio/wav_file.h"
#include "webrtc/typedefs.h"
#ifdef WEBRTC_AEC_DEBUG_DUMP
void WebRtcAec_ReopenWav(const char* name,
int instance_index,
int process_rate,
int sample_rate,
rtc_WavWriter** wav_file) {
if (*wav_file) {
if (rtc_WavSampleRate(*wav_file) == sample_rate)
return;
rtc_WavClose(*wav_file);
}
char filename[64];
int written = rtc::sprintfn(filename, sizeof(filename), "%s%d-%d.wav", name,
instance_index, process_rate);
// Ensure there was no buffer output error.
RTC_DCHECK_GE(written, 0);
// Ensure that the buffer size was sufficient.
RTC_DCHECK_LT(static_cast<size_t>(written), sizeof(filename));
*wav_file = rtc_WavOpen(filename, sample_rate, 1);
}
void WebRtcAec_RawFileOpen(const char* name, int instance_index, FILE** file) {
char filename[64];
int written = rtc::sprintfn(filename, sizeof(filename), "%s_%d.dat", name,
instance_index);
// Ensure there was no buffer output error.
RTC_DCHECK_GE(written, 0);
// Ensure that the buffer size was sufficient.
RTC_DCHECK_LT(static_cast<size_t>(written), sizeof(filename));
*file = fopen(filename, "wb");
}
#endif // WEBRTC_AEC_DEBUG_DUMP

View File

@ -1,41 +0,0 @@
/*
* Copyright (c) 2015 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_AEC_AEC_LOGGING_FILE_HANDLING_
#define WEBRTC_MODULES_AUDIO_PROCESSING_AEC_AEC_LOGGING_FILE_HANDLING_
#include <stdio.h>
#include "webrtc/common_audio/wav_file.h"
#include "webrtc/typedefs.h"
#ifdef __cplusplus
extern "C" {
#endif
#ifdef WEBRTC_AEC_DEBUG_DUMP
// Opens a new Wav file for writing. If it was already open with a different
// sample frequency, it closes it first.
void WebRtcAec_ReopenWav(const char* name,
int instance_index,
int process_rate,
int sample_rate,
rtc_WavWriter** wav_file);
// Opens dumpfile with instance-specific filename.
void WebRtcAec_RawFileOpen(const char* name, int instance_index, FILE** file);
#endif // WEBRTC_AEC_DEBUG_DUMP
#ifdef __cplusplus
}
#endif
#endif // WEBRTC_MODULES_AUDIO_PROCESSING_AEC_AEC_LOGGING_FILE_HANDLING_

View File

@ -0,0 +1,92 @@
/*
* Copyright (c) 2016 The WebRTC project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
#include "modules/audio_processing/logging/apm_data_dumper.h"
#include "rtc_base/strings/string_builder.h"
// Check to verify that the define is properly set.
#if !defined(WEBRTC_APM_DEBUG_DUMP) || \
(WEBRTC_APM_DEBUG_DUMP != 0 && WEBRTC_APM_DEBUG_DUMP != 1)
#error "Set WEBRTC_APM_DEBUG_DUMP to either 0 or 1"
#endif
namespace webrtc {
namespace {
#if WEBRTC_APM_DEBUG_DUMP == 1
#if defined(WEBRTC_WIN)
constexpr char kPathDelimiter = '\\';
#else
constexpr char kPathDelimiter = '/';
#endif
std::string FormFileName(const char* output_dir,
const char* name,
int instance_index,
int reinit_index,
const std::string& suffix) {
char buf[1024];
rtc::SimpleStringBuilder ss(buf);
const size_t output_dir_size = strlen(output_dir);
if (output_dir_size > 0) {
ss << output_dir;
if (output_dir[output_dir_size - 1] != kPathDelimiter) {
ss << kPathDelimiter;
}
}
ss << name << "_" << instance_index << "-" << reinit_index << suffix;
return ss.str();
}
#endif
} // namespace
#if WEBRTC_APM_DEBUG_DUMP == 1
ApmDataDumper::ApmDataDumper(int instance_index)
: instance_index_(instance_index) {}
#else
ApmDataDumper::ApmDataDumper(int instance_index) {}
#endif
ApmDataDumper::~ApmDataDumper() = default;
#if WEBRTC_APM_DEBUG_DUMP == 1
bool ApmDataDumper::recording_activated_ = false;
char ApmDataDumper::output_dir_[] = "";
FILE* ApmDataDumper::GetRawFile(const char* name) {
std::string filename = FormFileName(output_dir_, name, instance_index_,
recording_set_index_, ".dat");
auto& f = raw_files_[filename];
if (!f) {
f.reset(fopen(filename.c_str(), "wb"));
RTC_CHECK(f.get()) << "Cannot write to " << filename << ".";
}
return f.get();
}
WavWriter* ApmDataDumper::GetWavFile(const char* name,
int sample_rate_hz,
int num_channels,
WavFile::SampleFormat format) {
std::string filename = FormFileName(output_dir_, name, instance_index_,
recording_set_index_, ".wav");
auto& f = wav_files_[filename];
if (!f) {
f.reset(
new WavWriter(filename.c_str(), sample_rate_hz, num_channels, format));
}
return f.get();
}
#endif
} // namespace webrtc

View File

@ -0,0 +1,287 @@
/*
* Copyright (c) 2016 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 MODULES_AUDIO_PROCESSING_LOGGING_APM_DATA_DUMPER_H_
#define MODULES_AUDIO_PROCESSING_LOGGING_APM_DATA_DUMPER_H_
#include <stdint.h>
#include <stdio.h>
#include <string.h>
#include <string>
#if WEBRTC_APM_DEBUG_DUMP == 1
#include <memory>
#include <unordered_map>
#endif
#include "api/array_view.h"
#if WEBRTC_APM_DEBUG_DUMP == 1
#include "common_audio/wav_file.h"
#include "rtc_base/checks.h"
#endif
// Check to verify that the define is properly set.
#if !defined(WEBRTC_APM_DEBUG_DUMP) || \
(WEBRTC_APM_DEBUG_DUMP != 0 && WEBRTC_APM_DEBUG_DUMP != 1)
#error "Set WEBRTC_APM_DEBUG_DUMP to either 0 or 1"
#endif
namespace webrtc {
#if WEBRTC_APM_DEBUG_DUMP == 1
// Functor used to use as a custom deleter in the map of file pointers to raw
// files.
struct RawFileCloseFunctor {
void operator()(FILE* f) const { fclose(f); }
};
#endif
// Class that handles dumping of variables into files.
class ApmDataDumper {
public:
// Constructor that takes an instance index that may
// be used to distinguish data dumped from different
// instances of the code.
explicit ApmDataDumper(int instance_index);
ApmDataDumper() = delete;
ApmDataDumper(const ApmDataDumper&) = delete;
ApmDataDumper& operator=(const ApmDataDumper&) = delete;
~ApmDataDumper();
// Activates or deactivate the dumping functionality.
static void SetActivated(bool activated) {
#if WEBRTC_APM_DEBUG_DUMP == 1
recording_activated_ = activated;
#endif
}
// Set an optional output directory.
static void SetOutputDirectory(const std::string& output_dir) {
#if WEBRTC_APM_DEBUG_DUMP == 1
RTC_CHECK_LT(output_dir.size(), kOutputDirMaxLength);
strncpy(output_dir_, output_dir.c_str(), output_dir.size());
#endif
}
// Reinitializes the data dumping such that new versions
// of all files being dumped to are created.
void InitiateNewSetOfRecordings() {
#if WEBRTC_APM_DEBUG_DUMP == 1
++recording_set_index_;
#endif
}
// Methods for performing dumping of data of various types into
// various formats.
void DumpRaw(const char* name, double v) {
#if WEBRTC_APM_DEBUG_DUMP == 1
if (recording_activated_) {
FILE* file = GetRawFile(name);
fwrite(&v, sizeof(v), 1, file);
}
#endif
}
void DumpRaw(const char* name, size_t v_length, const double* v) {
#if WEBRTC_APM_DEBUG_DUMP == 1
if (recording_activated_) {
FILE* file = GetRawFile(name);
fwrite(v, sizeof(v[0]), v_length, file);
}
#endif
}
void DumpRaw(const char* name, rtc::ArrayView<const double> v) {
#if WEBRTC_APM_DEBUG_DUMP == 1
if (recording_activated_) {
DumpRaw(name, v.size(), v.data());
}
#endif
}
void DumpRaw(const char* name, float v) {
#if WEBRTC_APM_DEBUG_DUMP == 1
if (recording_activated_) {
FILE* file = GetRawFile(name);
fwrite(&v, sizeof(v), 1, file);
}
#endif
}
void DumpRaw(const char* name, size_t v_length, const float* v) {
#if WEBRTC_APM_DEBUG_DUMP == 1
if (recording_activated_) {
FILE* file = GetRawFile(name);
fwrite(v, sizeof(v[0]), v_length, file);
}
#endif
}
void DumpRaw(const char* name, rtc::ArrayView<const float> v) {
#if WEBRTC_APM_DEBUG_DUMP == 1
if (recording_activated_) {
DumpRaw(name, v.size(), v.data());
}
#endif
}
void DumpRaw(const char* name, bool v) {
#if WEBRTC_APM_DEBUG_DUMP == 1
if (recording_activated_) {
DumpRaw(name, static_cast<int16_t>(v));
}
#endif
}
void DumpRaw(const char* name, size_t v_length, const bool* v) {
#if WEBRTC_APM_DEBUG_DUMP == 1
if (recording_activated_) {
FILE* file = GetRawFile(name);
for (size_t k = 0; k < v_length; ++k) {
int16_t value = static_cast<int16_t>(v[k]);
fwrite(&value, sizeof(value), 1, file);
}
}
#endif
}
void DumpRaw(const char* name, rtc::ArrayView<const bool> v) {
#if WEBRTC_APM_DEBUG_DUMP == 1
if (recording_activated_) {
DumpRaw(name, v.size(), v.data());
}
#endif
}
void DumpRaw(const char* name, int16_t v) {
#if WEBRTC_APM_DEBUG_DUMP == 1
if (recording_activated_) {
FILE* file = GetRawFile(name);
fwrite(&v, sizeof(v), 1, file);
}
#endif
}
void DumpRaw(const char* name, size_t v_length, const int16_t* v) {
#if WEBRTC_APM_DEBUG_DUMP == 1
if (recording_activated_) {
FILE* file = GetRawFile(name);
fwrite(v, sizeof(v[0]), v_length, file);
}
#endif
}
void DumpRaw(const char* name, rtc::ArrayView<const int16_t> v) {
#if WEBRTC_APM_DEBUG_DUMP == 1
if (recording_activated_) {
DumpRaw(name, v.size(), v.data());
}
#endif
}
void DumpRaw(const char* name, int32_t v) {
#if WEBRTC_APM_DEBUG_DUMP == 1
if (recording_activated_) {
FILE* file = GetRawFile(name);
fwrite(&v, sizeof(v), 1, file);
}
#endif
}
void DumpRaw(const char* name, size_t v_length, const int32_t* v) {
#if WEBRTC_APM_DEBUG_DUMP == 1
if (recording_activated_) {
FILE* file = GetRawFile(name);
fwrite(v, sizeof(v[0]), v_length, file);
}
#endif
}
void DumpRaw(const char* name, size_t v) {
#if WEBRTC_APM_DEBUG_DUMP == 1
if (recording_activated_) {
FILE* file = GetRawFile(name);
fwrite(&v, sizeof(v), 1, file);
}
#endif
}
void DumpRaw(const char* name, size_t v_length, const size_t* v) {
#if WEBRTC_APM_DEBUG_DUMP == 1
if (recording_activated_) {
FILE* file = GetRawFile(name);
fwrite(v, sizeof(v[0]), v_length, file);
}
#endif
}
void DumpRaw(const char* name, rtc::ArrayView<const int32_t> v) {
#if WEBRTC_APM_DEBUG_DUMP == 1
if (recording_activated_) {
DumpRaw(name, v.size(), v.data());
}
#endif
}
void DumpRaw(const char* name, rtc::ArrayView<const size_t> v) {
#if WEBRTC_APM_DEBUG_DUMP == 1
DumpRaw(name, v.size(), v.data());
#endif
}
void DumpWav(const char* name,
size_t v_length,
const float* v,
int sample_rate_hz,
int num_channels) {
#if WEBRTC_APM_DEBUG_DUMP == 1
if (recording_activated_) {
WavWriter* file = GetWavFile(name, sample_rate_hz, num_channels,
WavFile::SampleFormat::kFloat);
file->WriteSamples(v, v_length);
}
#endif
}
void DumpWav(const char* name,
rtc::ArrayView<const float> v,
int sample_rate_hz,
int num_channels) {
#if WEBRTC_APM_DEBUG_DUMP == 1
if (recording_activated_) {
DumpWav(name, v.size(), v.data(), sample_rate_hz, num_channels);
}
#endif
}
private:
#if WEBRTC_APM_DEBUG_DUMP == 1
static bool recording_activated_;
static constexpr size_t kOutputDirMaxLength = 1024;
static char output_dir_[kOutputDirMaxLength];
const int instance_index_;
int recording_set_index_ = 0;
std::unordered_map<std::string, std::unique_ptr<FILE, RawFileCloseFunctor>>
raw_files_;
std::unordered_map<std::string, std::unique_ptr<WavWriter>> wav_files_;
FILE* GetRawFile(const char* name);
WavWriter* GetWavFile(const char* name,
int sample_rate_hz,
int num_channels,
WavFile::SampleFormat format);
#endif
};
} // namespace webrtc
#endif // MODULES_AUDIO_PROCESSING_LOGGING_APM_DATA_DUMPER_H_