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:
41
webrtc/modules/audio_processing/include/aec_dump.cc
Normal file
41
webrtc/modules/audio_processing/include/aec_dump.cc
Normal file
@ -0,0 +1,41 @@
|
||||
/*
|
||||
* Copyright (c) 2017 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/include/aec_dump.h"
|
||||
|
||||
namespace webrtc {
|
||||
InternalAPMConfig::InternalAPMConfig() = default;
|
||||
InternalAPMConfig::InternalAPMConfig(const InternalAPMConfig&) = default;
|
||||
InternalAPMConfig::InternalAPMConfig(InternalAPMConfig&&) = default;
|
||||
InternalAPMConfig& InternalAPMConfig::operator=(const InternalAPMConfig&) =
|
||||
default;
|
||||
|
||||
bool InternalAPMConfig::operator==(const InternalAPMConfig& other) {
|
||||
return aec_enabled == other.aec_enabled &&
|
||||
aec_delay_agnostic_enabled == other.aec_delay_agnostic_enabled &&
|
||||
aec_drift_compensation_enabled ==
|
||||
other.aec_drift_compensation_enabled &&
|
||||
aec_extended_filter_enabled == other.aec_extended_filter_enabled &&
|
||||
aec_suppression_level == other.aec_suppression_level &&
|
||||
aecm_enabled == other.aecm_enabled &&
|
||||
aecm_comfort_noise_enabled == other.aecm_comfort_noise_enabled &&
|
||||
aecm_routing_mode == other.aecm_routing_mode &&
|
||||
agc_enabled == other.agc_enabled && agc_mode == other.agc_mode &&
|
||||
agc_limiter_enabled == other.agc_limiter_enabled &&
|
||||
hpf_enabled == other.hpf_enabled && ns_enabled == other.ns_enabled &&
|
||||
ns_level == other.ns_level &&
|
||||
transient_suppression_enabled == other.transient_suppression_enabled &&
|
||||
noise_robust_agc_enabled == other.noise_robust_agc_enabled &&
|
||||
pre_amplifier_enabled == other.pre_amplifier_enabled &&
|
||||
pre_amplifier_fixed_gain_factor ==
|
||||
other.pre_amplifier_fixed_gain_factor &&
|
||||
experiments_description == other.experiments_description;
|
||||
}
|
||||
} // namespace webrtc
|
114
webrtc/modules/audio_processing/include/aec_dump.h
Normal file
114
webrtc/modules/audio_processing/include/aec_dump.h
Normal file
@ -0,0 +1,114 @@
|
||||
/*
|
||||
* Copyright (c) 2017 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_INCLUDE_AEC_DUMP_H_
|
||||
#define MODULES_AUDIO_PROCESSING_INCLUDE_AEC_DUMP_H_
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "modules/audio_processing/include/audio_frame_view.h"
|
||||
#include "modules/audio_processing/include/audio_processing.h"
|
||||
#include "rtc_base/deprecation.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
// Struct for passing current config from APM without having to
|
||||
// include protobuf headers.
|
||||
struct InternalAPMConfig {
|
||||
InternalAPMConfig();
|
||||
InternalAPMConfig(const InternalAPMConfig&);
|
||||
InternalAPMConfig(InternalAPMConfig&&);
|
||||
|
||||
InternalAPMConfig& operator=(const InternalAPMConfig&);
|
||||
InternalAPMConfig& operator=(InternalAPMConfig&&) = delete;
|
||||
|
||||
bool operator==(const InternalAPMConfig& other);
|
||||
|
||||
bool aec_enabled = false;
|
||||
bool aec_delay_agnostic_enabled = false;
|
||||
bool aec_drift_compensation_enabled = false;
|
||||
bool aec_extended_filter_enabled = false;
|
||||
int aec_suppression_level = 0;
|
||||
bool aecm_enabled = false;
|
||||
bool aecm_comfort_noise_enabled = false;
|
||||
int aecm_routing_mode = 0;
|
||||
bool agc_enabled = false;
|
||||
int agc_mode = 0;
|
||||
bool agc_limiter_enabled = false;
|
||||
bool hpf_enabled = false;
|
||||
bool ns_enabled = false;
|
||||
int ns_level = 0;
|
||||
bool transient_suppression_enabled = false;
|
||||
bool noise_robust_agc_enabled = false;
|
||||
bool pre_amplifier_enabled = false;
|
||||
float pre_amplifier_fixed_gain_factor = 1.f;
|
||||
std::string experiments_description = "";
|
||||
};
|
||||
|
||||
// An interface for recording configuration and input/output streams
|
||||
// of the Audio Processing Module. The recordings are called
|
||||
// 'aec-dumps' and are stored in a protobuf format defined in
|
||||
// debug.proto.
|
||||
// The Write* methods are always safe to call concurrently or
|
||||
// otherwise for all implementing subclasses. The intended mode of
|
||||
// operation is to create a protobuf object from the input, and send
|
||||
// it away to be written to file asynchronously.
|
||||
class AecDump {
|
||||
public:
|
||||
struct AudioProcessingState {
|
||||
int delay;
|
||||
int drift;
|
||||
int level;
|
||||
bool keypress;
|
||||
};
|
||||
|
||||
virtual ~AecDump() = default;
|
||||
|
||||
// Logs Event::Type INIT message.
|
||||
virtual void WriteInitMessage(const ProcessingConfig& api_format,
|
||||
int64_t time_now_ms) = 0;
|
||||
RTC_DEPRECATED void WriteInitMessage(const ProcessingConfig& api_format) {
|
||||
WriteInitMessage(api_format, 0);
|
||||
}
|
||||
|
||||
// Logs Event::Type STREAM message. To log an input/output pair,
|
||||
// call the AddCapture* and AddAudioProcessingState methods followed
|
||||
// by a WriteCaptureStreamMessage call.
|
||||
virtual void AddCaptureStreamInput(
|
||||
const AudioFrameView<const float>& src) = 0;
|
||||
virtual void AddCaptureStreamOutput(
|
||||
const AudioFrameView<const float>& src) = 0;
|
||||
virtual void AddCaptureStreamInput(const int16_t* const data,
|
||||
int num_channels,
|
||||
int samples_per_channel) = 0;
|
||||
virtual void AddCaptureStreamOutput(const int16_t* const data,
|
||||
int num_channels,
|
||||
int samples_per_channel) = 0;
|
||||
virtual void AddAudioProcessingState(const AudioProcessingState& state) = 0;
|
||||
virtual void WriteCaptureStreamMessage() = 0;
|
||||
|
||||
// Logs Event::Type REVERSE_STREAM message.
|
||||
virtual void WriteRenderStreamMessage(const int16_t* const data,
|
||||
int num_channels,
|
||||
int samples_per_channel) = 0;
|
||||
virtual void WriteRenderStreamMessage(
|
||||
const AudioFrameView<const float>& src) = 0;
|
||||
|
||||
virtual void WriteRuntimeSetting(
|
||||
const AudioProcessing::RuntimeSetting& runtime_setting) = 0;
|
||||
|
||||
// Logs Event::Type CONFIG message.
|
||||
virtual void WriteConfig(const InternalAPMConfig& config) = 0;
|
||||
};
|
||||
} // namespace webrtc
|
||||
|
||||
#endif // MODULES_AUDIO_PROCESSING_INCLUDE_AEC_DUMP_H_
|
@ -0,0 +1,70 @@
|
||||
/*
|
||||
* Copyright (c) 2020 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/include/audio_frame_proxies.h"
|
||||
|
||||
#include "api/audio/audio_frame.h"
|
||||
#include "modules/audio_processing/include/audio_processing.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
int ProcessAudioFrame(AudioProcessing* ap, AudioFrame* frame) {
|
||||
if (!frame || !ap) {
|
||||
return AudioProcessing::Error::kNullPointerError;
|
||||
}
|
||||
|
||||
StreamConfig input_config(frame->sample_rate_hz_, frame->num_channels_,
|
||||
/*has_keyboard=*/false);
|
||||
StreamConfig output_config(frame->sample_rate_hz_, frame->num_channels_,
|
||||
/*has_keyboard=*/false);
|
||||
RTC_DCHECK_EQ(frame->samples_per_channel(), input_config.num_frames());
|
||||
|
||||
int result = ap->ProcessStream(frame->data(), input_config, output_config,
|
||||
frame->mutable_data());
|
||||
|
||||
AudioProcessingStats stats = ap->GetStatistics();
|
||||
|
||||
if (stats.voice_detected) {
|
||||
frame->vad_activity_ = *stats.voice_detected
|
||||
? AudioFrame::VADActivity::kVadActive
|
||||
: AudioFrame::VADActivity::kVadPassive;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
int ProcessReverseAudioFrame(AudioProcessing* ap, AudioFrame* frame) {
|
||||
if (!frame || !ap) {
|
||||
return AudioProcessing::Error::kNullPointerError;
|
||||
}
|
||||
|
||||
// Must be a native rate.
|
||||
if (frame->sample_rate_hz_ != AudioProcessing::NativeRate::kSampleRate8kHz &&
|
||||
frame->sample_rate_hz_ != AudioProcessing::NativeRate::kSampleRate16kHz &&
|
||||
frame->sample_rate_hz_ != AudioProcessing::NativeRate::kSampleRate32kHz &&
|
||||
frame->sample_rate_hz_ != AudioProcessing::NativeRate::kSampleRate48kHz) {
|
||||
return AudioProcessing::Error::kBadSampleRateError;
|
||||
}
|
||||
|
||||
if (frame->num_channels_ <= 0) {
|
||||
return AudioProcessing::Error::kBadNumberChannelsError;
|
||||
}
|
||||
|
||||
StreamConfig input_config(frame->sample_rate_hz_, frame->num_channels_,
|
||||
/*has_keyboard=*/false);
|
||||
StreamConfig output_config(frame->sample_rate_hz_, frame->num_channels_,
|
||||
/*has_keyboard=*/false);
|
||||
|
||||
int result = ap->ProcessReverseStream(frame->data(), input_config,
|
||||
output_config, frame->mutable_data());
|
||||
return result;
|
||||
}
|
||||
|
||||
} // namespace webrtc
|
@ -0,0 +1,41 @@
|
||||
/*
|
||||
* Copyright (c) 2020 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_INCLUDE_AUDIO_FRAME_PROXIES_H_
|
||||
#define MODULES_AUDIO_PROCESSING_INCLUDE_AUDIO_FRAME_PROXIES_H_
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
class AudioFrame;
|
||||
class AudioProcessing;
|
||||
|
||||
// Processes a 10 ms |frame| of the primary audio stream using the provided
|
||||
// AudioProcessing object. On the client-side, this is the near-end (or
|
||||
// captured) audio. The |sample_rate_hz_|, |num_channels_|, and
|
||||
// |samples_per_channel_| members of |frame| must be valid. If changed from the
|
||||
// previous call to this function, it will trigger an initialization of the
|
||||
// provided AudioProcessing object.
|
||||
// The function returns any error codes passed from the AudioProcessing
|
||||
// ProcessStream method.
|
||||
int ProcessAudioFrame(AudioProcessing* ap, AudioFrame* frame);
|
||||
|
||||
// Processes a 10 ms |frame| of the reverse direction audio stream using the
|
||||
// provided AudioProcessing object. The frame may be modified. On the
|
||||
// client-side, this is the far-end (or to be rendered) audio. The
|
||||
// |sample_rate_hz_|, |num_channels_|, and |samples_per_channel_| members of
|
||||
// |frame| must be valid. If changed from the previous call to this function, it
|
||||
// will trigger an initialization of the provided AudioProcessing object.
|
||||
// The function returns any error codes passed from the AudioProcessing
|
||||
// ProcessReverseStream method.
|
||||
int ProcessReverseAudioFrame(AudioProcessing* ap, AudioFrame* frame);
|
||||
|
||||
} // namespace webrtc
|
||||
|
||||
#endif // MODULES_AUDIO_PROCESSING_INCLUDE_AUDIO_FRAME_PROXIES_H_
|
67
webrtc/modules/audio_processing/include/audio_frame_view.h
Normal file
67
webrtc/modules/audio_processing/include/audio_frame_view.h
Normal file
@ -0,0 +1,67 @@
|
||||
/*
|
||||
* Copyright (c) 2018 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_INCLUDE_AUDIO_FRAME_VIEW_H_
|
||||
#define MODULES_AUDIO_PROCESSING_INCLUDE_AUDIO_FRAME_VIEW_H_
|
||||
|
||||
#include "api/array_view.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
// Class to pass audio data in T** format, where T is a numeric type.
|
||||
template <class T>
|
||||
class AudioFrameView {
|
||||
public:
|
||||
// |num_channels| and |channel_size| describe the T**
|
||||
// |audio_samples|. |audio_samples| is assumed to point to a
|
||||
// two-dimensional |num_channels * channel_size| array of floats.
|
||||
AudioFrameView(T* const* audio_samples,
|
||||
size_t num_channels,
|
||||
size_t channel_size)
|
||||
: audio_samples_(audio_samples),
|
||||
num_channels_(num_channels),
|
||||
channel_size_(channel_size) {}
|
||||
|
||||
// Implicit cast to allow converting Frame<float> to
|
||||
// Frame<const float>.
|
||||
template <class U>
|
||||
AudioFrameView(AudioFrameView<U> other)
|
||||
: audio_samples_(other.data()),
|
||||
num_channels_(other.num_channels()),
|
||||
channel_size_(other.samples_per_channel()) {}
|
||||
|
||||
AudioFrameView() = delete;
|
||||
|
||||
size_t num_channels() const { return num_channels_; }
|
||||
|
||||
size_t samples_per_channel() const { return channel_size_; }
|
||||
|
||||
rtc::ArrayView<T> channel(size_t idx) {
|
||||
RTC_DCHECK_LE(0, idx);
|
||||
RTC_DCHECK_LE(idx, num_channels_);
|
||||
return rtc::ArrayView<T>(audio_samples_[idx], channel_size_);
|
||||
}
|
||||
|
||||
rtc::ArrayView<const T> channel(size_t idx) const {
|
||||
RTC_DCHECK_LE(0, idx);
|
||||
RTC_DCHECK_LE(idx, num_channels_);
|
||||
return rtc::ArrayView<const T>(audio_samples_[idx], channel_size_);
|
||||
}
|
||||
|
||||
T* const* data() { return audio_samples_; }
|
||||
|
||||
private:
|
||||
T* const* audio_samples_;
|
||||
size_t num_channels_;
|
||||
size_t channel_size_;
|
||||
};
|
||||
} // namespace webrtc
|
||||
|
||||
#endif // MODULES_AUDIO_PROCESSING_INCLUDE_AUDIO_FRAME_VIEW_H_
|
124
webrtc/modules/audio_processing/include/audio_processing.cc
Normal file
124
webrtc/modules/audio_processing/include/audio_processing.cc
Normal file
@ -0,0 +1,124 @@
|
||||
/*
|
||||
* 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/include/audio_processing.h"
|
||||
|
||||
#include "rtc_base/strings/string_builder.h"
|
||||
#include "rtc_base/system/arch.h"
|
||||
|
||||
namespace webrtc {
|
||||
namespace {
|
||||
|
||||
std::string NoiseSuppressionLevelToString(
|
||||
const AudioProcessing::Config::NoiseSuppression::Level& level) {
|
||||
switch (level) {
|
||||
case AudioProcessing::Config::NoiseSuppression::Level::kLow:
|
||||
return "Low";
|
||||
case AudioProcessing::Config::NoiseSuppression::Level::kModerate:
|
||||
return "Moderate";
|
||||
case AudioProcessing::Config::NoiseSuppression::Level::kHigh:
|
||||
return "High";
|
||||
case AudioProcessing::Config::NoiseSuppression::Level::kVeryHigh:
|
||||
return "VeryHigh";
|
||||
}
|
||||
}
|
||||
|
||||
std::string GainController1ModeToString(
|
||||
const AudioProcessing::Config::GainController1::Mode& mode) {
|
||||
switch (mode) {
|
||||
case AudioProcessing::Config::GainController1::Mode::kAdaptiveAnalog:
|
||||
return "AdaptiveAnalog";
|
||||
case AudioProcessing::Config::GainController1::Mode::kAdaptiveDigital:
|
||||
return "AdaptiveDigital";
|
||||
case AudioProcessing::Config::GainController1::Mode::kFixedDigital:
|
||||
return "FixedDigital";
|
||||
}
|
||||
}
|
||||
|
||||
std::string GainController2LevelEstimatorToString(
|
||||
const AudioProcessing::Config::GainController2::LevelEstimator& level) {
|
||||
switch (level) {
|
||||
case AudioProcessing::Config::GainController2::LevelEstimator::kRms:
|
||||
return "Rms";
|
||||
case AudioProcessing::Config::GainController2::LevelEstimator::kPeak:
|
||||
return "Peak";
|
||||
}
|
||||
}
|
||||
|
||||
int GetDefaultMaxInternalRate() {
|
||||
#ifdef WEBRTC_ARCH_ARM_FAMILY
|
||||
return 32000;
|
||||
#else
|
||||
return 48000;
|
||||
#endif
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
constexpr int AudioProcessing::kNativeSampleRatesHz[];
|
||||
|
||||
void CustomProcessing::SetRuntimeSetting(
|
||||
AudioProcessing::RuntimeSetting setting) {}
|
||||
|
||||
AudioProcessing::Config::Pipeline::Pipeline()
|
||||
: maximum_internal_processing_rate(GetDefaultMaxInternalRate()) {}
|
||||
|
||||
std::string AudioProcessing::Config::ToString() const {
|
||||
char buf[1024];
|
||||
rtc::SimpleStringBuilder builder(buf);
|
||||
builder << "AudioProcessing::Config{ "
|
||||
"pipeline: {"
|
||||
"maximum_internal_processing_rate: "
|
||||
<< pipeline.maximum_internal_processing_rate
|
||||
<< ", multi_channel_render: " << pipeline.multi_channel_render
|
||||
<< ", "
|
||||
", multi_channel_capture: "
|
||||
<< pipeline.multi_channel_capture
|
||||
<< "}, "
|
||||
"pre_amplifier: { enabled: "
|
||||
<< pre_amplifier.enabled
|
||||
<< ", fixed_gain_factor: " << pre_amplifier.fixed_gain_factor
|
||||
<< " }, high_pass_filter: { enabled: " << high_pass_filter.enabled
|
||||
<< " }, echo_canceller: { enabled: " << echo_canceller.enabled
|
||||
<< ", mobile_mode: " << echo_canceller.mobile_mode
|
||||
<< ", enforce_high_pass_filtering: "
|
||||
<< echo_canceller.enforce_high_pass_filtering
|
||||
<< " }, noise_suppression: { enabled: " << noise_suppression.enabled
|
||||
<< ", level: "
|
||||
<< NoiseSuppressionLevelToString(noise_suppression.level)
|
||||
<< " }, transient_suppression: { enabled: "
|
||||
<< transient_suppression.enabled
|
||||
<< " }, voice_detection: { enabled: " << voice_detection.enabled
|
||||
<< " }, gain_controller1: { enabled: " << gain_controller1.enabled
|
||||
<< ", mode: " << GainController1ModeToString(gain_controller1.mode)
|
||||
<< ", target_level_dbfs: " << gain_controller1.target_level_dbfs
|
||||
<< ", compression_gain_db: " << gain_controller1.compression_gain_db
|
||||
<< ", enable_limiter: " << gain_controller1.enable_limiter
|
||||
<< ", analog_level_minimum: " << gain_controller1.analog_level_minimum
|
||||
<< ", analog_level_maximum: " << gain_controller1.analog_level_maximum
|
||||
<< " }, gain_controller2: { enabled: " << gain_controller2.enabled
|
||||
<< ", fixed_digital: { gain_db: "
|
||||
<< gain_controller2.fixed_digital.gain_db
|
||||
<< " }, adaptive_digital: { enabled: "
|
||||
<< gain_controller2.adaptive_digital.enabled << ", level_estimator: "
|
||||
<< GainController2LevelEstimatorToString(
|
||||
gain_controller2.adaptive_digital.level_estimator)
|
||||
<< ", use_saturation_protector: "
|
||||
<< gain_controller2.adaptive_digital.use_saturation_protector
|
||||
<< ", extra_saturation_margin_db: "
|
||||
<< gain_controller2.adaptive_digital.extra_saturation_margin_db
|
||||
<< " } }, residual_echo_detector: { enabled: "
|
||||
<< residual_echo_detector.enabled
|
||||
<< " }, level_estimation: { enabled: " << level_estimation.enabled
|
||||
<< " } }";
|
||||
return builder.str();
|
||||
}
|
||||
|
||||
} // namespace webrtc
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,22 @@
|
||||
/*
|
||||
* Copyright 2017 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/include/audio_processing_statistics.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
AudioProcessingStats::AudioProcessingStats() = default;
|
||||
|
||||
AudioProcessingStats::AudioProcessingStats(const AudioProcessingStats& other) =
|
||||
default;
|
||||
|
||||
AudioProcessingStats::~AudioProcessingStats() = default;
|
||||
|
||||
} // namespace webrtc
|
@ -0,0 +1,73 @@
|
||||
/*
|
||||
* Copyright 2017 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_INCLUDE_AUDIO_PROCESSING_STATISTICS_H_
|
||||
#define MODULES_AUDIO_PROCESSING_INCLUDE_AUDIO_PROCESSING_STATISTICS_H_
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "absl/types/optional.h"
|
||||
#include "rtc_base/system/rtc_export.h"
|
||||
|
||||
namespace webrtc {
|
||||
// This version of the stats uses Optionals, it will replace the regular
|
||||
// AudioProcessingStatistics struct.
|
||||
struct RTC_EXPORT AudioProcessingStats {
|
||||
AudioProcessingStats();
|
||||
AudioProcessingStats(const AudioProcessingStats& other);
|
||||
~AudioProcessingStats();
|
||||
|
||||
// The root mean square (RMS) level in dBFS (decibels from digital
|
||||
// full-scale) of the last capture frame, after processing. It is
|
||||
// constrained to [-127, 0].
|
||||
// The computation follows: https://tools.ietf.org/html/rfc6465
|
||||
// with the intent that it can provide the RTP audio level indication.
|
||||
// Only reported if level estimation is enabled in AudioProcessing::Config.
|
||||
absl::optional<int> output_rms_dbfs;
|
||||
|
||||
// True if voice is detected in the last capture frame, after processing.
|
||||
// It is conservative in flagging audio as speech, with low likelihood of
|
||||
// incorrectly flagging a frame as voice.
|
||||
// Only reported if voice detection is enabled in AudioProcessing::Config.
|
||||
absl::optional<bool> voice_detected;
|
||||
|
||||
// AEC Statistics.
|
||||
// ERL = 10log_10(P_far / P_echo)
|
||||
absl::optional<double> echo_return_loss;
|
||||
// ERLE = 10log_10(P_echo / P_out)
|
||||
absl::optional<double> echo_return_loss_enhancement;
|
||||
// Fraction of time that the AEC linear filter is divergent, in a 1-second
|
||||
// non-overlapped aggregation window.
|
||||
absl::optional<double> divergent_filter_fraction;
|
||||
|
||||
// The delay metrics consists of the delay median and standard deviation. It
|
||||
// also consists of the fraction of delay estimates that can make the echo
|
||||
// cancellation perform poorly. The values are aggregated until the first
|
||||
// call to |GetStatistics()| and afterwards aggregated and updated every
|
||||
// second. Note that if there are several clients pulling metrics from
|
||||
// |GetStatistics()| during a session the first call from any of them will
|
||||
// change to one second aggregation window for all.
|
||||
absl::optional<int32_t> delay_median_ms;
|
||||
absl::optional<int32_t> delay_standard_deviation_ms;
|
||||
|
||||
// Residual echo detector likelihood.
|
||||
absl::optional<double> residual_echo_likelihood;
|
||||
// Maximum residual echo likelihood from the last time period.
|
||||
absl::optional<double> residual_echo_likelihood_recent_max;
|
||||
|
||||
// The instantaneous delay estimate produced in the AEC. The unit is in
|
||||
// milliseconds and the value is the instantaneous value at the time of the
|
||||
// call to |GetStatistics()|.
|
||||
absl::optional<int32_t> delay_ms;
|
||||
};
|
||||
|
||||
} // namespace webrtc
|
||||
|
||||
#endif // MODULES_AUDIO_PROCESSING_INCLUDE_AUDIO_PROCESSING_STATISTICS_H_
|
23
webrtc/modules/audio_processing/include/config.cc
Normal file
23
webrtc/modules/audio_processing/include/config.cc
Normal file
@ -0,0 +1,23 @@
|
||||
/*
|
||||
* 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/include/config.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
Config::Config() {}
|
||||
|
||||
Config::~Config() {
|
||||
for (OptionMap::iterator it = options_.begin(); it != options_.end(); ++it) {
|
||||
delete it->second;
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace webrtc
|
131
webrtc/modules/audio_processing/include/config.h
Normal file
131
webrtc/modules/audio_processing/include/config.h
Normal file
@ -0,0 +1,131 @@
|
||||
/*
|
||||
* Copyright (c) 2013 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_INCLUDE_CONFIG_H_
|
||||
#define MODULES_AUDIO_PROCESSING_INCLUDE_CONFIG_H_
|
||||
|
||||
#include <map>
|
||||
|
||||
#include "rtc_base/system/rtc_export.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
// Only add new values to the end of the enumeration and never remove (only
|
||||
// deprecate) to maintain binary compatibility.
|
||||
enum class ConfigOptionID {
|
||||
kMyExperimentForTest,
|
||||
kAlgo1CostFunctionForTest,
|
||||
kTemporalLayersFactory, // Deprecated
|
||||
kNetEqCapacityConfig, // Deprecated
|
||||
kNetEqFastAccelerate, // Deprecated
|
||||
kVoicePacing, // Deprecated
|
||||
kExtendedFilter, // Deprecated
|
||||
kDelayAgnostic, // Deprecated
|
||||
kExperimentalAgc,
|
||||
kExperimentalNs,
|
||||
kBeamforming, // Deprecated
|
||||
kIntelligibility, // Deprecated
|
||||
kEchoCanceller3, // Deprecated
|
||||
kAecRefinedAdaptiveFilter, // Deprecated
|
||||
kLevelControl // Deprecated
|
||||
};
|
||||
|
||||
// Class Config is designed to ease passing a set of options across webrtc code.
|
||||
// Options are identified by typename in order to avoid incorrect casts.
|
||||
//
|
||||
// Usage:
|
||||
// * declaring an option:
|
||||
// struct Algo1_CostFunction {
|
||||
// virtual float cost(int x) const { return x; }
|
||||
// virtual ~Algo1_CostFunction() {}
|
||||
// };
|
||||
//
|
||||
// * accessing an option:
|
||||
// config.Get<Algo1_CostFunction>().cost(value);
|
||||
//
|
||||
// * setting an option:
|
||||
// struct SqrCost : Algo1_CostFunction {
|
||||
// virtual float cost(int x) const { return x*x; }
|
||||
// };
|
||||
// config.Set<Algo1_CostFunction>(new SqrCost());
|
||||
//
|
||||
// Note: This class is thread-compatible (like STL containers).
|
||||
class RTC_EXPORT Config {
|
||||
public:
|
||||
// Returns the option if set or a default constructed one.
|
||||
// Callers that access options too often are encouraged to cache the result.
|
||||
// Returned references are owned by this.
|
||||
//
|
||||
// Requires std::is_default_constructible<T>
|
||||
template <typename T>
|
||||
const T& Get() const;
|
||||
|
||||
// Set the option, deleting any previous instance of the same.
|
||||
// This instance gets ownership of the newly set value.
|
||||
template <typename T>
|
||||
void Set(T* value);
|
||||
|
||||
Config();
|
||||
~Config();
|
||||
|
||||
private:
|
||||
struct BaseOption {
|
||||
virtual ~BaseOption() {}
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
struct Option : BaseOption {
|
||||
explicit Option(T* v) : value(v) {}
|
||||
~Option() { delete value; }
|
||||
T* value;
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
static ConfigOptionID identifier() {
|
||||
return T::identifier;
|
||||
}
|
||||
|
||||
// Used to instantiate a default constructed object that doesn't needs to be
|
||||
// owned. This allows Get<T> to be implemented without requiring explicitly
|
||||
// locks.
|
||||
template <typename T>
|
||||
static const T& default_value() {
|
||||
static const T* const def = new T();
|
||||
return *def;
|
||||
}
|
||||
|
||||
typedef std::map<ConfigOptionID, BaseOption*> OptionMap;
|
||||
OptionMap options_;
|
||||
|
||||
Config(const Config&);
|
||||
void operator=(const Config&);
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
const T& Config::Get() const {
|
||||
OptionMap::const_iterator it = options_.find(identifier<T>());
|
||||
if (it != options_.end()) {
|
||||
const T* t = static_cast<Option<T>*>(it->second)->value;
|
||||
if (t) {
|
||||
return *t;
|
||||
}
|
||||
}
|
||||
return default_value<T>();
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void Config::Set(T* value) {
|
||||
BaseOption*& it = options_[identifier<T>()];
|
||||
delete it;
|
||||
it = new Option<T>(value);
|
||||
}
|
||||
} // namespace webrtc
|
||||
|
||||
#endif // MODULES_AUDIO_PROCESSING_INCLUDE_CONFIG_H_
|
Reference in New Issue
Block a user