2011-07-07 08:21:25 +00:00
|
|
|
/*
|
2012-02-08 01:57:29 +00:00
|
|
|
* Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
|
2011-07-07 08:21:25 +00:00
|
|
|
*
|
|
|
|
|
* 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.
|
|
|
|
|
*/
|
|
|
|
|
|
2017-09-15 06:47:31 +02:00
|
|
|
#ifndef MODULES_AUDIO_PROCESSING_INCLUDE_AUDIO_PROCESSING_H_
|
|
|
|
|
#define MODULES_AUDIO_PROCESSING_INCLUDE_AUDIO_PROCESSING_H_
|
2011-07-07 08:21:25 +00:00
|
|
|
|
2015-10-29 18:21:34 -07:00
|
|
|
// MSVC++ requires this to be set before any other includes to get M_PI.
|
2017-12-12 14:41:53 +01:00
|
|
|
#ifndef _USE_MATH_DEFINES
|
2015-10-29 18:21:34 -07:00
|
|
|
#define _USE_MATH_DEFINES
|
2017-12-12 14:41:53 +01:00
|
|
|
#endif
|
2015-10-29 18:21:34 -07:00
|
|
|
|
|
|
|
|
#include <math.h>
|
2012-11-15 21:46:06 +00:00
|
|
|
#include <stddef.h> // size_t
|
2013-12-06 16:05:17 +00:00
|
|
|
#include <stdio.h> // FILE
|
2017-08-24 22:36:53 -07:00
|
|
|
#include <string.h>
|
2019-07-05 19:08:33 +02:00
|
|
|
|
2015-01-05 21:58:58 +00:00
|
|
|
#include <vector>
|
2011-07-18 18:03:01 +00:00
|
|
|
|
2024-01-09 11:52:10 +01:00
|
|
|
#include "absl/base/nullability.h"
|
2022-07-25 22:07:08 +02:00
|
|
|
#include "absl/strings/string_view.h"
|
2018-06-19 10:50:11 +02:00
|
|
|
#include "absl/types/optional.h"
|
2020-05-07 13:07:49 +02:00
|
|
|
#include "api/array_view.h"
|
2018-02-14 15:12:00 +01:00
|
|
|
#include "api/audio/echo_canceller3_config.h"
|
2018-02-15 10:09:09 +01:00
|
|
|
#include "api/audio/echo_control.h"
|
2023-11-02 14:09:26 +00:00
|
|
|
#include "api/ref_count.h"
|
2019-01-25 20:26:48 +01:00
|
|
|
#include "api/scoped_refptr.h"
|
2024-01-09 11:52:10 +01:00
|
|
|
#include "api/task_queue/task_queue_base.h"
|
2017-11-24 17:29:59 +01:00
|
|
|
#include "modules/audio_processing/include/audio_processing_statistics.h"
|
2017-09-15 06:47:31 +02:00
|
|
|
#include "rtc_base/arraysize.h"
|
2020-05-11 11:03:47 +02:00
|
|
|
#include "rtc_base/system/file_wrapper.h"
|
Reland "Export symbols needed by the Chromium component build (part 1)."
This reverts commit 16fe3f290a524a136f71660a114d0b03ef501f10.
Reason for revert:
After discussing this problem with nisse@ and yvesg@, we decided to modify
how RTC_EXPORT works and avoid to depend on the macro COMPONENT_BUILD.
RTC_EXPORT will instead depend on a macro WEBRTC_COMPONENT_BUILD (which
can be set as a GN argument which defaults to false).
When all the symbols needed by Chromium will be marked with RTC_EXPORT we
will flip the GN arg in Chromium, setting to to `component_build` and from
that moment, Chromium will depend on a WebRTC shared library when
`component_build=true`.
Original change's description:
> Revert "Export symbols needed by the Chromium component build (part 1)."
>
> This reverts commit 99eea42fc1fe0be0ebed13c5eba7e1e42059bc5a.
>
> Reason for revert:
> lld-link: error: undefined symbol: "__declspec(dllimport) bool __cdecl cricket::UnwrapTurnPacket(unsigned char const *, unsigned int, unsigned int *, unsigned int *)" (__imp_?UnwrapTurnPacket@cricket@@YA_NPBEIPAI1@Z)
> >>> referenced by obj/services/network/network_service/socket_manager.obj:("virtual void __thiscall network::P2PSocketManager::DumpPacket(class base::span<unsigned char const, 4294967295>, bool)" (?DumpPacket@P2PSocketManager@network@@EAEXV?$span@$$CBE$0PPPPPPPP@@base@@_N@Z))
> lld-link: error: undefined symbol: "__declspec(dllimport) bool __cdecl cricket::ValidateRtpHeader(unsigned char const *, unsigned int, unsigned int *)" (__imp_?ValidateRtpHeader@cricket@@YA_NPBEIPAI@Z)
> >>> referenced by obj/services/network/network_service/socket_manager.obj:("virtual void __thiscall network::P2PSocketManager::DumpPacket(class base::span<unsigned char const, 4294967295>, bool)" (?DumpPacket@P2PSocketManager@network@@EAEXV?$span@$$CBE$0PPPPPPPP@@base@@_N@Z))
> lld-link: error: undefined symbol: "__declspec(dllimport) bool __cdecl cricket::ApplyPacketOptions(unsigned char *, unsigned int, struct rtc::PacketTimeUpdateParams const &, unsigned __int64)" (__imp_?ApplyPacketOptions@cricket@@YA_NPAEIABUPacketTimeUpdateParams@rtc@@_K@Z)
> >>> referenced by obj/services/network/network_service/socket_tcp.obj:("virtual void __thiscall network::P2PSocketTcp::DoSend(class net::IPEndPoint const &, class std::vector<signed char, class std::allocator<signed char>> const &, struct rtc::PacketOptions const &, struct net::NetworkTrafficAnnotationTag)" (?DoSend@P2PSocketTcp@network@@MAEXABVIPEndPoint@net@@ABV?$vector@CV?$allocator@C@std@@@std@@ABUPacketOptions@rtc@@UNetworkTrafficAnnotationTag@4@@Z))
> >>> referenced by obj/services/network/network_service/socket_tcp.obj:("virtual void __thiscall network::P2PSocketStunTcp::DoSend(class net::IPEndPoint const &, class std::vector<signed char, class std::allocator<signed char>> const &, struct rtc::PacketOptions const &, struct net::NetworkTrafficAnnotationTag)" (?DoSend@P2PSocketStunTcp@network@@MAEXABVIPEndPoint@net@@ABV?$vector@CV?$allocator@C@std@@@std@@ABUPacketOptions@rtc@@UNetworkTrafficAnnotationTag@4@@Z))
> lld-link: error: undefined symbol: "__declspec(dllimport) bool __cdecl cricket::ApplyPacketOptions(unsigned char *, unsigned int, struct rtc::PacketTimeUpdateParams const &, unsigned __int64)" (__imp_?ApplyPacketOptions@cricket@@YA_NPAEIABUPacketTimeUpdateParams@rtc@@_K@Z)
> >>> referenced by obj/services/network/network_service/socket_udp.obj:("bool __thiscall network::P2PSocketUdp::DoSend(struct network::P2PSocketUdp::PendingPacket const &)" (?DoSend@P2PSocketUdp@network@@AAE_NABUPendingPacket@12@@Z))
>
> Original change's description:
> > Reland "Reland "Export symbols needed by the Chromium component build (part 1).""
> >
> > This reverts commit b49520bfc08f5c5832dda1d642125f0bb898f974.
> >
> > Reason for revert: Problem fixed in https://chromium-review.googlesource.com/c/chromium/src/+/1261398.
> >
> > Original change's description:
> > > Revert "Reland "Export symbols needed by the Chromium component build (part 1).""
> > >
> > > This reverts commit 588f4642d1a29f7beaf28265dbd08728191b4c52.
> > >
> > > Reason for revert: Breaks WebRTC Chromium FYI Win Builder (dbg).
> > > lld-link: error: undefined symbol: "__declspec(dllimport) __thiscall webrtc::Config::Config(void)" (__imp_??0Config@webrtc@@QAE@XZ)
> > > [...]
> > >
> > > Original change's description:
> > > > Reland "Export symbols needed by the Chromium component build (part 1)."
> > > >
> > > > This reverts commit 2ea9af227517556136fd629dd2663c0d75d77c7b.
> > > >
> > > > Reason for revert: The problem will be fixed by
> > > > https://chromium-review.googlesource.com/c/chromium/src/+/1261122.
> > > >
> > > > Original change's description:
> > > > > Revert "Export symbols needed by the Chromium component build (part 1)."
> > > > >
> > > > > This reverts commit 9e24dcff167c4eb3555bf0ce6eaba090c10fbe53.
> > > > >
> > > > > Reason for revert: Breaks chromium.webrtc.fyi bots.
> > > > >
> > > > > Original change's description:
> > > > > > Export symbols needed by the Chromium component build (part 1).
> > > > > >
> > > > > > This CL uses RTC_EXPORT (defined in rtc_base/system/rtc_export.h)
> > > > > > to mark WebRTC symbols as visible from a shared library, this doesn't
> > > > > > mean these symbols are part of the public API (please continue to refer
> > > > > > to [1] for info about what is considered public WebRTC API).
> > > > > >
> > > > > > [1] - https://webrtc.googlesource.com/src/+/HEAD/native-api.md
> > > > > >
> > > > > > Bug: webrtc:9419
> > > > > > Change-Id: I802abd32874d42d3aa5ecd3c8022e7cf5e043d99
> > > > > > Reviewed-on: https://webrtc-review.googlesource.com/c/103505
> > > > > > Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org>
> > > > > > Reviewed-by: Niels Moller <nisse@webrtc.org>
> > > > > > Reviewed-by: Karl Wiberg <kwiberg@webrtc.org>
> > > > > > Cr-Commit-Position: refs/heads/master@{#24969}
> > > > >
> > > > > TBR=mbonadei@webrtc.org,kwiberg@webrtc.org,nisse@webrtc.org
> > > > >
> > > > > Change-Id: I01f6e18f0d2c0f0309cdaa6c943c3927e1f1f49f
> > > > > No-Presubmit: true
> > > > > No-Tree-Checks: true
> > > > > No-Try: true
> > > > > Bug: webrtc:9419
> > > > > Reviewed-on: https://webrtc-review.googlesource.com/c/103720
> > > > > Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org>
> > > > > Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org>
> > > > > Cr-Commit-Position: refs/heads/master@{#24974}
> > > >
> > > > TBR=mbonadei@webrtc.org,kwiberg@webrtc.org,nisse@webrtc.org
> > > >
> > > > Change-Id: I83bbc7f550fc23e823c4d055e0a6f60c828960dd
> > > > No-Presubmit: true
> > > > No-Tree-Checks: true
> > > > No-Try: true
> > > > Bug: webrtc:9419
> > > > Reviewed-on: https://webrtc-review.googlesource.com/c/103740
> > > > Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org>
> > > > Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org>
> > > > Cr-Commit-Position: refs/heads/master@{#24980}
> > >
> > > TBR=mbonadei@webrtc.org,kwiberg@webrtc.org,nisse@webrtc.org
> > >
> > > Change-Id: I4b7cfe492f2c8eeda5c8ac52520e0cfc95ade9b0
> > > No-Presubmit: true
> > > No-Tree-Checks: true
> > > No-Try: true
> > > Bug: webrtc:9419
> > > Reviewed-on: https://webrtc-review.googlesource.com/c/103801
> > > Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org>
> > > Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org>
> > > Cr-Commit-Position: refs/heads/master@{#24983}
> >
> > TBR=mbonadei@webrtc.org,kwiberg@webrtc.org,nisse@webrtc.org
> >
> > # Not skipping CQ checks because original CL landed > 1 day ago.
> >
> > Bug: webrtc:9419
> > Change-Id: Id986a0a03cdc2818690337784396882af067f7fa
> > Reviewed-on: https://webrtc-review.googlesource.com/c/104602
> > Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org>
> > Reviewed-by: Niels Moller <nisse@webrtc.org>
> > Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org>
> > Cr-Commit-Position: refs/heads/master@{#25049}
>
> TBR=mbonadei@webrtc.org,kwiberg@webrtc.org,nisse@webrtc.org
>
> Change-Id: I6f58b9c90defccdb160307783fb55271ab424fa1
> No-Presubmit: true
> No-Tree-Checks: true
> No-Try: true
> Bug: webrtc:9419
> Reviewed-on: https://webrtc-review.googlesource.com/c/104623
> Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org>
> Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org>
> Cr-Commit-Position: refs/heads/master@{#25050}
TBR=mbonadei@webrtc.org,kwiberg@webrtc.org,nisse@webrtc.org
Change-Id: I4d01ed96ae40a8f9ca42c466be5c87653d75d7c1
Bug: webrtc:9419
Reviewed-on: https://webrtc-review.googlesource.com/c/104641
Reviewed-by: Yves Gerey <yvesg@webrtc.org>
Reviewed-by: Niels Moller <nisse@webrtc.org>
Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org>
Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#25108}
2018-10-11 10:50:45 +02:00
|
|
|
#include "rtc_base/system/rtc_export.h"
|
2011-07-07 08:21:25 +00:00
|
|
|
|
|
|
|
|
namespace webrtc {
|
|
|
|
|
|
AudioProcessingModule has a feature to make a recording of its
configuration, inputs and outputs over a period of time. It is
activated by AudioProcessing::StartRecording. The data is stored in
binary protobuf format in a specified file. The file IO is, as of
this CL, done from the real-time audio thread.
This CL contains an interface for AecDump, a new APM submodule that
will handle the recordings. Calls to the new interface from the
AudioProcessingModule are added. These calls have no effect, and for a
short while, audio_processing_impl.cc will contain two copies of
recording calls.
The original calls are guarded by the WEBRTC_AUDIOPROC_DEBUG_DUMP
preprocessor define. They still have an effect, while the new ones do
not. In the following CLs, the old recording calls will be removed,
and an implementation of AecDump added.
The reasons for the refactoring is to move file IO operations from the
real-time audio thread, to add a top-level low-priority task queue for
logging tasks like this, to simplify and modularize audio_processing_impl.cc
and remove some of the preprocessor directives. These goals will be
archived by the upcoming CLs. The implementation is in
https://codereview.webrtc.org/2865113002.
BUG=webrtc:7404
Review-Url: https://codereview.webrtc.org/2778783002
Cr-Commit-Position: refs/heads/master@{#18233}
2017-05-23 07:20:05 -07:00
|
|
|
class AecDump;
|
2017-09-25 12:04:02 +02:00
|
|
|
class AudioBuffer;
|
2015-03-25 16:37:27 -07:00
|
|
|
|
2015-07-23 11:41:39 -07:00
|
|
|
class StreamConfig;
|
|
|
|
|
class ProcessingConfig;
|
|
|
|
|
|
2018-01-11 16:08:54 +01:00
|
|
|
class EchoDetector;
|
2018-08-29 10:37:09 +02:00
|
|
|
class CustomAudioAnalyzer;
|
2017-12-18 16:02:40 +01:00
|
|
|
class CustomProcessing;
|
2011-07-07 08:21:25 +00:00
|
|
|
|
|
|
|
|
// The Audio Processing Module (APM) provides a collection of voice processing
|
|
|
|
|
// components designed for real-time communications software.
|
|
|
|
|
//
|
|
|
|
|
// APM operates on two audio streams on a frame-by-frame basis. Frames of the
|
|
|
|
|
// primary stream, on which all processing is applied, are passed to
|
2021-07-28 20:50:03 +02:00
|
|
|
// `ProcessStream()`. Frames of the reverse direction stream are passed to
|
|
|
|
|
// `ProcessReverseStream()`. On the client-side, this will typically be the
|
2016-03-17 20:39:53 -07:00
|
|
|
// near-end (capture) and far-end (render) streams, respectively. APM should be
|
|
|
|
|
// placed in the signal chain as close to the audio hardware abstraction layer
|
|
|
|
|
// (HAL) as possible.
|
2011-07-07 08:21:25 +00:00
|
|
|
//
|
|
|
|
|
// On the server-side, the reverse stream will normally not be used, with
|
|
|
|
|
// processing occurring on each incoming stream.
|
|
|
|
|
//
|
|
|
|
|
// Component interfaces follow a similar pattern and are accessed through
|
|
|
|
|
// corresponding getters in APM. All components are disabled at create-time,
|
|
|
|
|
// with default settings that are recommended for most situations. New settings
|
|
|
|
|
// can be applied without enabling a component. Enabling a component triggers
|
|
|
|
|
// memory allocation and initialization to allow it to start processing the
|
|
|
|
|
// streams.
|
|
|
|
|
//
|
|
|
|
|
// Thread safety is provided with the following assumptions to reduce locking
|
|
|
|
|
// overhead:
|
|
|
|
|
// 1. The stream getters and setters are called from the same thread as
|
|
|
|
|
// ProcessStream(). More precisely, stream functions are never called
|
|
|
|
|
// concurrently with ProcessStream().
|
|
|
|
|
// 2. Parameter getters are never called concurrently with the corresponding
|
|
|
|
|
// setter.
|
|
|
|
|
//
|
2022-08-03 14:37:00 +02:00
|
|
|
// APM accepts only linear PCM audio data in chunks of ~10 ms (see
|
2022-11-17 11:26:58 +01:00
|
|
|
// AudioProcessing::GetFrameSize() for details) and sample rates ranging from
|
|
|
|
|
// 8000 Hz to 384000 Hz. The int16 interfaces use interleaved data, while the
|
|
|
|
|
// float interfaces use deinterleaved data.
|
2011-07-07 08:21:25 +00:00
|
|
|
//
|
|
|
|
|
// Usage example, omitting error checking:
|
2022-11-17 11:26:58 +01:00
|
|
|
// rtc::scoped_refptr<AudioProcessing> apm = AudioProcessingBuilder().Create();
|
2011-07-07 08:21:25 +00:00
|
|
|
//
|
2016-09-12 16:47:25 -07:00
|
|
|
// AudioProcessing::Config config;
|
2018-09-17 11:05:17 +02:00
|
|
|
// config.echo_canceller.enabled = true;
|
|
|
|
|
// config.echo_canceller.mobile_mode = false;
|
2019-10-15 10:10:26 +02:00
|
|
|
//
|
|
|
|
|
// config.gain_controller1.enabled = true;
|
|
|
|
|
// config.gain_controller1.mode =
|
|
|
|
|
// AudioProcessing::Config::GainController1::kAdaptiveAnalog;
|
|
|
|
|
// config.gain_controller1.analog_level_minimum = 0;
|
|
|
|
|
// config.gain_controller1.analog_level_maximum = 255;
|
|
|
|
|
//
|
2018-03-05 15:59:06 +01:00
|
|
|
// config.gain_controller2.enabled = true;
|
2019-10-15 10:10:26 +02:00
|
|
|
//
|
|
|
|
|
// config.high_pass_filter.enabled = true;
|
|
|
|
|
//
|
2016-09-12 16:47:25 -07:00
|
|
|
// apm->ApplyConfig(config)
|
|
|
|
|
//
|
2011-07-07 08:21:25 +00:00
|
|
|
// // Start a voice call...
|
|
|
|
|
//
|
|
|
|
|
// // ... Render frame arrives bound for the audio HAL ...
|
2016-03-17 20:39:53 -07:00
|
|
|
// apm->ProcessReverseStream(render_frame);
|
2011-07-07 08:21:25 +00:00
|
|
|
//
|
|
|
|
|
// // ... Capture frame arrives from the audio HAL ...
|
|
|
|
|
// // Call required set_stream_ functions.
|
|
|
|
|
// apm->set_stream_delay_ms(delay_ms);
|
2019-10-15 10:10:26 +02:00
|
|
|
// apm->set_stream_analog_level(analog_level);
|
2011-07-07 08:21:25 +00:00
|
|
|
//
|
|
|
|
|
// apm->ProcessStream(capture_frame);
|
|
|
|
|
//
|
|
|
|
|
// // Call required stream_ functions.
|
2019-10-15 10:10:26 +02:00
|
|
|
// analog_level = apm->recommended_stream_analog_level();
|
2011-07-07 08:21:25 +00:00
|
|
|
// has_voice = apm->stream_has_voice();
|
|
|
|
|
//
|
2021-01-08 16:34:49 +08:00
|
|
|
// // Repeat render and capture processing for the duration of the call...
|
2011-07-07 08:21:25 +00:00
|
|
|
// // Start a new call...
|
|
|
|
|
// apm->Initialize();
|
|
|
|
|
//
|
|
|
|
|
// // Close the application...
|
2022-11-17 11:26:58 +01:00
|
|
|
// apm.reset();
|
2011-07-07 08:21:25 +00:00
|
|
|
//
|
2023-11-02 14:09:26 +00:00
|
|
|
class RTC_EXPORT AudioProcessing : public RefCountInterface {
|
2011-07-07 08:21:25 +00:00
|
|
|
public:
|
2016-09-12 16:47:25 -07:00
|
|
|
// The struct below constitutes the new parameter scheme for the audio
|
|
|
|
|
// processing. It is being introduced gradually and until it is fully
|
|
|
|
|
// introduced, it is prone to change.
|
|
|
|
|
// TODO(peah): Remove this comment once the new config scheme is fully rolled
|
|
|
|
|
// out.
|
|
|
|
|
//
|
|
|
|
|
// The parameters and behavior of the audio processing module are controlled
|
|
|
|
|
// by changing the default values in the AudioProcessing::Config struct.
|
|
|
|
|
// The config is applied by passing the struct to the ApplyConfig method.
|
2019-03-27 13:28:08 +01:00
|
|
|
//
|
|
|
|
|
// This config is intended to be used during setup, and to enable/disable
|
|
|
|
|
// top-level processing effects. Use during processing may cause undesired
|
|
|
|
|
// submodule resets, affecting the audio quality. Use the RuntimeSetting
|
|
|
|
|
// construct for runtime configuration.
|
2019-11-12 20:11:48 +01:00
|
|
|
struct RTC_EXPORT Config {
|
2019-09-15 00:27:58 +02:00
|
|
|
// Sets the properties of the audio processing pipeline.
|
2019-11-12 20:11:48 +01:00
|
|
|
struct RTC_EXPORT Pipeline {
|
2022-12-01 13:26:26 +01:00
|
|
|
// Ways to downmix a multi-channel track to mono.
|
|
|
|
|
enum class DownmixMethod {
|
|
|
|
|
kAverageChannels, // Average across channels.
|
|
|
|
|
kUseFirstChannel // Use the first channel.
|
|
|
|
|
};
|
|
|
|
|
|
2019-09-15 00:27:58 +02:00
|
|
|
// Maximum allowed processing rate used internally. May only be set to
|
2021-01-21 23:03:32 +01:00
|
|
|
// 32000 or 48000 and any differing values will be treated as 48000.
|
|
|
|
|
int maximum_internal_processing_rate = 48000;
|
2019-11-27 09:34:22 +01:00
|
|
|
// Allow multi-channel processing of render audio.
|
|
|
|
|
bool multi_channel_render = false;
|
|
|
|
|
// Allow multi-channel processing of capture audio when AEC3 is active
|
|
|
|
|
// or a custom AEC is injected..
|
|
|
|
|
bool multi_channel_capture = false;
|
2022-12-01 13:26:26 +01:00
|
|
|
// Indicates how to downmix multi-channel capture audio to mono (when
|
|
|
|
|
// needed).
|
|
|
|
|
DownmixMethod capture_downmix_method = DownmixMethod::kAverageChannels;
|
2019-09-15 00:27:58 +02:00
|
|
|
} pipeline;
|
|
|
|
|
|
2019-01-11 15:10:32 +01:00
|
|
|
// Enabled the pre-amplifier. It amplifies the capture signal
|
|
|
|
|
// before any other processing is done.
|
2021-03-15 16:31:04 +00:00
|
|
|
// TODO(webrtc:5298): Deprecate and use the pre-gain functionality in
|
|
|
|
|
// capture_level_adjustment instead.
|
2019-01-11 15:10:32 +01:00
|
|
|
struct PreAmplifier {
|
|
|
|
|
bool enabled = false;
|
2021-03-31 15:04:03 +02:00
|
|
|
float fixed_gain_factor = 1.0f;
|
2019-01-11 15:10:32 +01:00
|
|
|
} pre_amplifier;
|
|
|
|
|
|
2021-03-15 16:31:04 +00:00
|
|
|
// Functionality for general level adjustment in the capture pipeline. This
|
|
|
|
|
// should not be used together with the legacy PreAmplifier functionality.
|
|
|
|
|
struct CaptureLevelAdjustment {
|
|
|
|
|
bool operator==(const CaptureLevelAdjustment& rhs) const;
|
|
|
|
|
bool operator!=(const CaptureLevelAdjustment& rhs) const {
|
|
|
|
|
return !(*this == rhs);
|
|
|
|
|
}
|
|
|
|
|
bool enabled = false;
|
|
|
|
|
// The `pre_gain_factor` scales the signal before any processing is done.
|
2021-03-31 15:04:03 +02:00
|
|
|
float pre_gain_factor = 1.0f;
|
2021-03-15 16:31:04 +00:00
|
|
|
// The `post_gain_factor` scales the signal after all processing is done.
|
2021-03-31 15:04:03 +02:00
|
|
|
float post_gain_factor = 1.0f;
|
2021-03-15 16:31:04 +00:00
|
|
|
struct AnalogMicGainEmulation {
|
|
|
|
|
bool operator==(const AnalogMicGainEmulation& rhs) const;
|
|
|
|
|
bool operator!=(const AnalogMicGainEmulation& rhs) const {
|
|
|
|
|
return !(*this == rhs);
|
|
|
|
|
}
|
|
|
|
|
bool enabled = false;
|
|
|
|
|
// Initial analog gain level to use for the emulated analog gain. Must
|
|
|
|
|
// be in the range [0...255].
|
|
|
|
|
int initial_level = 255;
|
|
|
|
|
} analog_mic_gain_emulation;
|
|
|
|
|
} capture_level_adjustment;
|
|
|
|
|
|
2019-01-11 15:10:32 +01:00
|
|
|
struct HighPassFilter {
|
|
|
|
|
bool enabled = false;
|
2019-12-10 13:04:15 +01:00
|
|
|
bool apply_in_full_band = true;
|
2019-01-11 15:10:32 +01:00
|
|
|
} high_pass_filter;
|
|
|
|
|
|
2018-07-27 13:27:23 +02:00
|
|
|
struct EchoCanceller {
|
|
|
|
|
bool enabled = false;
|
|
|
|
|
bool mobile_mode = false;
|
2019-11-13 11:12:29 +01:00
|
|
|
bool export_linear_aec_output = false;
|
2019-12-04 08:34:12 +01:00
|
|
|
// Enforce the highpass filter to be on (has no effect for the mobile
|
|
|
|
|
// mode).
|
2019-12-03 13:52:40 +01:00
|
|
|
bool enforce_high_pass_filtering = true;
|
2018-07-27 13:27:23 +02:00
|
|
|
} echo_canceller;
|
|
|
|
|
|
2019-01-11 15:10:32 +01:00
|
|
|
// Enables background noise suppression.
|
|
|
|
|
struct NoiseSuppression {
|
2016-11-22 07:24:52 -08:00
|
|
|
bool enabled = false;
|
2019-01-11 15:10:32 +01:00
|
|
|
enum Level { kLow, kModerate, kHigh, kVeryHigh };
|
|
|
|
|
Level level = kModerate;
|
2019-12-20 00:42:22 +01:00
|
|
|
bool analyze_linear_aec_output_when_available = false;
|
2019-01-11 15:10:32 +01:00
|
|
|
} noise_suppression;
|
2016-12-14 01:16:23 -08:00
|
|
|
|
2020-01-02 15:15:36 +01:00
|
|
|
// Enables transient suppression.
|
|
|
|
|
struct TransientSuppression {
|
|
|
|
|
bool enabled = false;
|
|
|
|
|
} transient_suppression;
|
|
|
|
|
|
2019-03-27 13:28:08 +01:00
|
|
|
// Enables automatic gain control (AGC) functionality.
|
|
|
|
|
// The automatic gain control (AGC) component brings the signal to an
|
|
|
|
|
// appropriate range. This is done by applying a digital gain directly and,
|
|
|
|
|
// in the analog mode, prescribing an analog gain to be applied at the audio
|
|
|
|
|
// HAL.
|
|
|
|
|
// Recommended to be enabled on the client-side.
|
2021-05-07 11:58:11 +02:00
|
|
|
struct RTC_EXPORT GainController1 {
|
2020-10-14 12:47:50 +02:00
|
|
|
bool operator==(const GainController1& rhs) const;
|
|
|
|
|
bool operator!=(const GainController1& rhs) const {
|
|
|
|
|
return !(*this == rhs);
|
|
|
|
|
}
|
|
|
|
|
|
2019-03-27 13:28:08 +01:00
|
|
|
bool enabled = false;
|
|
|
|
|
enum Mode {
|
|
|
|
|
// Adaptive mode intended for use if an analog volume control is
|
|
|
|
|
// available on the capture device. It will require the user to provide
|
|
|
|
|
// coupling between the OS mixer controls and AGC through the
|
|
|
|
|
// stream_analog_level() functions.
|
|
|
|
|
// It consists of an analog gain prescription for the audio device and a
|
|
|
|
|
// digital compression stage.
|
|
|
|
|
kAdaptiveAnalog,
|
|
|
|
|
// Adaptive mode intended for situations in which an analog volume
|
|
|
|
|
// control is unavailable. It operates in a similar fashion to the
|
|
|
|
|
// adaptive analog mode, but with scaling instead applied in the digital
|
|
|
|
|
// domain. As with the analog mode, it additionally uses a digital
|
|
|
|
|
// compression stage.
|
|
|
|
|
kAdaptiveDigital,
|
|
|
|
|
// Fixed mode which enables only the digital compression stage also used
|
|
|
|
|
// by the two adaptive modes.
|
|
|
|
|
// It is distinguished from the adaptive modes by considering only a
|
|
|
|
|
// short time-window of the input signal. It applies a fixed gain
|
|
|
|
|
// through most of the input level range, and compresses (gradually
|
|
|
|
|
// reduces gain with increasing level) the input signal at higher
|
|
|
|
|
// levels. This mode is preferred on embedded devices where the capture
|
|
|
|
|
// signal level is predictable, so that a known gain can be applied.
|
|
|
|
|
kFixedDigital
|
|
|
|
|
};
|
|
|
|
|
Mode mode = kAdaptiveAnalog;
|
|
|
|
|
// Sets the target peak level (or envelope) of the AGC in dBFs (decibels
|
|
|
|
|
// from digital full-scale). The convention is to use positive values. For
|
|
|
|
|
// instance, passing in a value of 3 corresponds to -3 dBFs, or a target
|
|
|
|
|
// level 3 dB below full-scale. Limited to [0, 31].
|
|
|
|
|
int target_level_dbfs = 3;
|
|
|
|
|
// Sets the maximum gain the digital compression stage may apply, in dB. A
|
|
|
|
|
// higher number corresponds to greater compression, while a value of 0
|
|
|
|
|
// will leave the signal uncompressed. Limited to [0, 90].
|
|
|
|
|
// For updates after APM setup, use a RuntimeSetting instead.
|
|
|
|
|
int compression_gain_db = 9;
|
|
|
|
|
// When enabled, the compression stage will hard limit the signal to the
|
|
|
|
|
// target level. Otherwise, the signal will be compressed but not limited
|
|
|
|
|
// above the target level.
|
|
|
|
|
bool enable_limiter = true;
|
2020-01-13 14:43:13 +01:00
|
|
|
|
|
|
|
|
// Enables the analog gain controller functionality.
|
|
|
|
|
struct AnalogGainController {
|
|
|
|
|
bool enabled = true;
|
2022-10-13 17:15:36 +02:00
|
|
|
// TODO(bugs.webrtc.org/7494): Deprecated. Stop using and remove.
|
|
|
|
|
int startup_min_volume = 0;
|
2020-01-13 14:43:13 +01:00
|
|
|
// Lowest analog microphone level that will be applied in response to
|
|
|
|
|
// clipping.
|
2022-10-13 13:06:05 +02:00
|
|
|
int clipped_level_min = 70;
|
2022-07-19 12:18:38 +02:00
|
|
|
// If true, an adaptive digital gain is applied.
|
2020-01-13 14:43:13 +01:00
|
|
|
bool enable_digital_adaptive = true;
|
2021-05-20 17:37:56 +02:00
|
|
|
// Amount the microphone level is lowered with every clipping event.
|
|
|
|
|
// Limited to (0, 255].
|
|
|
|
|
int clipped_level_step = 15;
|
|
|
|
|
// Proportion of clipped samples required to declare a clipping event.
|
|
|
|
|
// Limited to (0.f, 1.f).
|
|
|
|
|
float clipped_ratio_threshold = 0.1f;
|
|
|
|
|
// Time in frames to wait after a clipping event before checking again.
|
|
|
|
|
// Limited to values higher than 0.
|
|
|
|
|
int clipped_wait_frames = 300;
|
2021-06-02 17:13:24 +02:00
|
|
|
|
|
|
|
|
// Enables clipping prediction functionality.
|
|
|
|
|
struct ClippingPredictor {
|
|
|
|
|
bool enabled = false;
|
|
|
|
|
enum Mode {
|
2021-06-11 12:37:54 +02:00
|
|
|
// Clipping event prediction mode with fixed step estimation.
|
2021-06-02 17:13:24 +02:00
|
|
|
kClippingEventPrediction,
|
2021-06-11 12:37:54 +02:00
|
|
|
// Clipped peak estimation mode with adaptive step estimation.
|
2021-06-02 17:13:24 +02:00
|
|
|
kAdaptiveStepClippingPeakPrediction,
|
2021-06-11 12:37:54 +02:00
|
|
|
// Clipped peak estimation mode with fixed step estimation.
|
2021-06-02 17:13:24 +02:00
|
|
|
kFixedStepClippingPeakPrediction,
|
|
|
|
|
};
|
|
|
|
|
Mode mode = kClippingEventPrediction;
|
2021-06-11 12:37:54 +02:00
|
|
|
// Number of frames in the sliding analysis window.
|
2021-06-02 17:13:24 +02:00
|
|
|
int window_length = 5;
|
2021-06-11 12:37:54 +02:00
|
|
|
// Number of frames in the sliding reference window.
|
2021-06-02 17:13:24 +02:00
|
|
|
int reference_window_length = 5;
|
2021-06-11 12:37:54 +02:00
|
|
|
// Reference window delay (unit: number of frames).
|
2021-06-02 17:13:24 +02:00
|
|
|
int reference_window_delay = 5;
|
2021-06-11 12:37:54 +02:00
|
|
|
// Clipping prediction threshold (dBFS).
|
2021-06-02 17:13:24 +02:00
|
|
|
float clipping_threshold = -1.0f;
|
|
|
|
|
// Crest factor drop threshold (dB).
|
|
|
|
|
float crest_factor_margin = 3.0f;
|
2021-06-17 17:18:46 +02:00
|
|
|
// If true, the recommended clipped level step is used to modify the
|
|
|
|
|
// analog gain. Otherwise, the predictor runs without affecting the
|
|
|
|
|
// analog gain.
|
|
|
|
|
bool use_predicted_step = true;
|
2021-06-02 17:13:24 +02:00
|
|
|
} clipping_predictor;
|
2020-01-13 14:43:13 +01:00
|
|
|
} analog_gain_controller;
|
2019-03-27 13:28:08 +01:00
|
|
|
} gain_controller1;
|
|
|
|
|
|
2022-12-05 16:31:16 +01:00
|
|
|
// Parameters for AGC2, an Automatic Gain Control (AGC) sub-module which
|
|
|
|
|
// replaces the AGC sub-module parametrized by `gain_controller1`.
|
|
|
|
|
// AGC2 brings the captured audio signal to the desired level by combining
|
|
|
|
|
// three different controllers (namely, input volume controller, adapative
|
|
|
|
|
// digital controller and fixed digital controller) and a limiter.
|
|
|
|
|
// TODO(bugs.webrtc.org:7494): Name `GainController` when AGC1 removed.
|
2021-05-07 11:58:11 +02:00
|
|
|
struct RTC_EXPORT GainController2 {
|
2020-10-14 12:47:50 +02:00
|
|
|
bool operator==(const GainController2& rhs) const;
|
|
|
|
|
bool operator!=(const GainController2& rhs) const {
|
|
|
|
|
return !(*this == rhs);
|
|
|
|
|
}
|
|
|
|
|
|
2022-12-05 16:31:16 +01:00
|
|
|
// AGC2 must be created if and only if `enabled` is true.
|
2017-05-22 06:57:06 -07:00
|
|
|
bool enabled = false;
|
2022-12-05 16:31:16 +01:00
|
|
|
|
|
|
|
|
// Parameters for the input volume controller, which adjusts the input
|
|
|
|
|
// volume applied when the audio is captured (e.g., microphone volume on
|
|
|
|
|
// a soundcard, input volume on HAL).
|
|
|
|
|
struct InputVolumeController {
|
|
|
|
|
bool operator==(const InputVolumeController& rhs) const;
|
|
|
|
|
bool operator!=(const InputVolumeController& rhs) const {
|
|
|
|
|
return !(*this == rhs);
|
|
|
|
|
}
|
|
|
|
|
bool enabled = false;
|
|
|
|
|
} input_volume_controller;
|
|
|
|
|
|
|
|
|
|
// Parameters for the adaptive digital controller, which adjusts and
|
|
|
|
|
// applies a digital gain after echo cancellation and after noise
|
|
|
|
|
// suppression.
|
2021-05-07 11:58:11 +02:00
|
|
|
struct RTC_EXPORT AdaptiveDigital {
|
2021-04-29 16:17:49 +02:00
|
|
|
bool operator==(const AdaptiveDigital& rhs) const;
|
|
|
|
|
bool operator!=(const AdaptiveDigital& rhs) const {
|
|
|
|
|
return !(*this == rhs);
|
|
|
|
|
}
|
2018-11-21 10:50:58 +01:00
|
|
|
bool enabled = false;
|
2024-04-08 15:54:44 +03:00
|
|
|
float headroom_db = 5.0f;
|
|
|
|
|
float max_gain_db = 50.0f;
|
|
|
|
|
float initial_gain_db = 15.0f;
|
|
|
|
|
float max_gain_change_db_per_second = 6.0f;
|
2021-04-14 19:09:17 +02:00
|
|
|
float max_output_noise_level_dbfs = -50.0f;
|
2018-11-13 14:44:15 +01:00
|
|
|
} adaptive_digital;
|
2022-11-01 17:17:54 +01:00
|
|
|
|
2022-12-05 16:31:16 +01:00
|
|
|
// Parameters for the fixed digital controller, which applies a fixed
|
|
|
|
|
// digital gain after the adaptive digital controller and before the
|
|
|
|
|
// limiter.
|
|
|
|
|
struct FixedDigital {
|
|
|
|
|
// By setting `gain_db` to a value greater than zero, the limiter can be
|
|
|
|
|
// turned into a compressor that first applies a fixed gain.
|
|
|
|
|
float gain_db = 0.0f;
|
|
|
|
|
} fixed_digital;
|
2017-05-22 06:57:06 -07:00
|
|
|
} gain_controller2;
|
2017-08-24 22:36:53 -07:00
|
|
|
|
2019-08-02 11:31:37 +02:00
|
|
|
std::string ToString() const;
|
2016-09-12 16:47:25 -07:00
|
|
|
};
|
|
|
|
|
|
2018-04-16 12:10:09 +02:00
|
|
|
// Specifies the properties of a setting to be passed to AudioProcessing at
|
|
|
|
|
// runtime.
|
|
|
|
|
class RuntimeSetting {
|
|
|
|
|
public:
|
2018-05-15 10:52:28 +02:00
|
|
|
enum class Type {
|
|
|
|
|
kNotSpecified,
|
|
|
|
|
kCapturePreGain,
|
2019-03-27 13:28:08 +01:00
|
|
|
kCaptureCompressionGain,
|
2019-04-26 11:33:37 +02:00
|
|
|
kCaptureFixedPostGain,
|
2019-05-10 15:50:02 +02:00
|
|
|
kPlayoutVolumeChange,
|
2019-11-07 13:22:00 +01:00
|
|
|
kCustomRenderProcessingRuntimeSetting,
|
2020-08-12 08:46:47 +02:00
|
|
|
kPlayoutAudioDeviceChange,
|
2021-03-15 16:31:04 +00:00
|
|
|
kCapturePostGain,
|
2020-08-12 08:46:47 +02:00
|
|
|
kCaptureOutputUsed
|
2019-11-07 13:22:00 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// Play-out audio device properties.
|
|
|
|
|
struct PlayoutAudioDeviceInfo {
|
|
|
|
|
int id; // Identifies the audio device.
|
|
|
|
|
int max_volume; // Maximum play-out volume.
|
2018-05-15 10:52:28 +02:00
|
|
|
};
|
2018-04-16 12:10:09 +02:00
|
|
|
|
2021-03-31 15:04:03 +02:00
|
|
|
RuntimeSetting() : type_(Type::kNotSpecified), value_(0.0f) {}
|
2018-04-16 12:10:09 +02:00
|
|
|
~RuntimeSetting() = default;
|
|
|
|
|
|
|
|
|
|
static RuntimeSetting CreateCapturePreGain(float gain) {
|
|
|
|
|
return {Type::kCapturePreGain, gain};
|
|
|
|
|
}
|
|
|
|
|
|
2021-03-15 16:31:04 +00:00
|
|
|
static RuntimeSetting CreateCapturePostGain(float gain) {
|
|
|
|
|
return {Type::kCapturePostGain, gain};
|
|
|
|
|
}
|
|
|
|
|
|
2019-03-27 13:28:08 +01:00
|
|
|
// Corresponds to Config::GainController1::compression_gain_db, but for
|
|
|
|
|
// runtime configuration.
|
|
|
|
|
static RuntimeSetting CreateCompressionGainDb(int gain_db) {
|
|
|
|
|
RTC_DCHECK_GE(gain_db, 0);
|
|
|
|
|
RTC_DCHECK_LE(gain_db, 90);
|
|
|
|
|
return {Type::kCaptureCompressionGain, static_cast<float>(gain_db)};
|
|
|
|
|
}
|
|
|
|
|
|
2019-04-26 11:33:37 +02:00
|
|
|
// Corresponds to Config::GainController2::fixed_digital::gain_db, but for
|
|
|
|
|
// runtime configuration.
|
|
|
|
|
static RuntimeSetting CreateCaptureFixedPostGain(float gain_db) {
|
2021-03-31 15:04:03 +02:00
|
|
|
RTC_DCHECK_GE(gain_db, 0.0f);
|
|
|
|
|
RTC_DCHECK_LE(gain_db, 90.0f);
|
2019-04-26 11:33:37 +02:00
|
|
|
return {Type::kCaptureFixedPostGain, gain_db};
|
|
|
|
|
}
|
|
|
|
|
|
2019-11-07 13:22:00 +01:00
|
|
|
// Creates a runtime setting to notify play-out (aka render) audio device
|
|
|
|
|
// changes.
|
|
|
|
|
static RuntimeSetting CreatePlayoutAudioDeviceChange(
|
|
|
|
|
PlayoutAudioDeviceInfo audio_device) {
|
|
|
|
|
return {Type::kPlayoutAudioDeviceChange, audio_device};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Creates a runtime setting to notify play-out (aka render) volume changes.
|
2021-07-28 20:50:03 +02:00
|
|
|
// `volume` is the unnormalized volume, the maximum of which
|
2019-05-10 15:50:02 +02:00
|
|
|
static RuntimeSetting CreatePlayoutVolumeChange(int volume) {
|
|
|
|
|
return {Type::kPlayoutVolumeChange, volume};
|
|
|
|
|
}
|
|
|
|
|
|
2018-05-15 10:52:28 +02:00
|
|
|
static RuntimeSetting CreateCustomRenderSetting(float payload) {
|
|
|
|
|
return {Type::kCustomRenderProcessingRuntimeSetting, payload};
|
|
|
|
|
}
|
|
|
|
|
|
2021-03-03 10:52:44 +00:00
|
|
|
static RuntimeSetting CreateCaptureOutputUsedSetting(
|
|
|
|
|
bool capture_output_used) {
|
|
|
|
|
return {Type::kCaptureOutputUsed, capture_output_used};
|
2020-08-12 08:46:47 +02:00
|
|
|
}
|
|
|
|
|
|
2018-04-16 12:10:09 +02:00
|
|
|
Type type() const { return type_; }
|
2019-11-07 13:22:00 +01:00
|
|
|
// Getters do not return a value but instead modify the argument to protect
|
|
|
|
|
// from implicit casting.
|
2018-04-16 12:10:09 +02:00
|
|
|
void GetFloat(float* value) const {
|
|
|
|
|
RTC_DCHECK(value);
|
2019-05-10 15:50:02 +02:00
|
|
|
*value = value_.float_value;
|
|
|
|
|
}
|
|
|
|
|
void GetInt(int* value) const {
|
|
|
|
|
RTC_DCHECK(value);
|
|
|
|
|
*value = value_.int_value;
|
2018-04-16 12:10:09 +02:00
|
|
|
}
|
2020-08-12 08:46:47 +02:00
|
|
|
void GetBool(bool* value) const {
|
|
|
|
|
RTC_DCHECK(value);
|
|
|
|
|
*value = value_.bool_value;
|
|
|
|
|
}
|
2019-11-07 13:22:00 +01:00
|
|
|
void GetPlayoutAudioDeviceInfo(PlayoutAudioDeviceInfo* value) const {
|
|
|
|
|
RTC_DCHECK(value);
|
|
|
|
|
*value = value_.playout_audio_device_info;
|
|
|
|
|
}
|
2018-04-16 12:10:09 +02:00
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
RuntimeSetting(Type id, float value) : type_(id), value_(value) {}
|
2019-05-10 15:50:02 +02:00
|
|
|
RuntimeSetting(Type id, int value) : type_(id), value_(value) {}
|
2019-11-07 13:22:00 +01:00
|
|
|
RuntimeSetting(Type id, PlayoutAudioDeviceInfo value)
|
|
|
|
|
: type_(id), value_(value) {}
|
2018-04-16 12:10:09 +02:00
|
|
|
Type type_;
|
2019-05-10 15:50:02 +02:00
|
|
|
union U {
|
|
|
|
|
U() {}
|
|
|
|
|
U(int value) : int_value(value) {}
|
|
|
|
|
U(float value) : float_value(value) {}
|
2019-11-07 13:22:00 +01:00
|
|
|
U(PlayoutAudioDeviceInfo value) : playout_audio_device_info(value) {}
|
2019-05-10 15:50:02 +02:00
|
|
|
float float_value;
|
|
|
|
|
int int_value;
|
2020-08-12 08:46:47 +02:00
|
|
|
bool bool_value;
|
2019-11-07 13:22:00 +01:00
|
|
|
PlayoutAudioDeviceInfo playout_audio_device_info;
|
2019-05-10 15:50:02 +02:00
|
|
|
} value_;
|
2018-04-16 12:10:09 +02:00
|
|
|
};
|
|
|
|
|
|
2017-06-29 08:32:09 -07:00
|
|
|
~AudioProcessing() override {}
|
2011-07-07 08:21:25 +00:00
|
|
|
|
|
|
|
|
// Initializes internal states, while retaining all user settings. This
|
|
|
|
|
// should be called before beginning to process a new audio stream. However,
|
|
|
|
|
// it is not necessary to call before processing the first stream after
|
2014-04-22 21:00:04 +00:00
|
|
|
// creation.
|
|
|
|
|
//
|
|
|
|
|
// It is also not necessary to call if the audio parameters (sample
|
2014-01-07 17:45:09 +00:00
|
|
|
// rate and number of channels) have changed. Passing updated parameters
|
2021-07-28 20:50:03 +02:00
|
|
|
// directly to `ProcessStream()` and `ProcessReverseStream()` is permissible.
|
2014-04-22 21:00:04 +00:00
|
|
|
// If the parameters are known at init-time though, they may be provided.
|
2020-09-01 23:57:20 +02:00
|
|
|
// TODO(webrtc:5298): Change to return void.
|
2011-07-07 08:21:25 +00:00
|
|
|
virtual int Initialize() = 0;
|
2014-04-22 21:00:04 +00:00
|
|
|
|
|
|
|
|
// The int16 interfaces require:
|
2021-07-28 20:50:03 +02:00
|
|
|
// - only `NativeRate`s be used
|
2014-04-22 21:00:04 +00:00
|
|
|
// - that the input, output and reverse rates must match
|
2021-08-10 01:22:31 +02:00
|
|
|
// - that `processing_config.output_stream()` matches
|
|
|
|
|
// `processing_config.input_stream()`.
|
2015-07-23 11:41:39 -07:00
|
|
|
//
|
|
|
|
|
// The float interfaces accept arbitrary rates and support differing input and
|
|
|
|
|
// output layouts, but the output must have either one channel or the same
|
|
|
|
|
// number of channels as the input.
|
|
|
|
|
virtual int Initialize(const ProcessingConfig& processing_config) = 0;
|
|
|
|
|
|
2016-09-12 16:47:25 -07:00
|
|
|
// TODO(peah): This method is a temporary solution used to take control
|
|
|
|
|
// over the parameters in the audio processing module and is likely to change.
|
|
|
|
|
virtual void ApplyConfig(const Config& config) = 0;
|
|
|
|
|
|
2014-04-22 21:00:04 +00:00
|
|
|
// TODO(ajm): Only intended for internal use. Make private and friend the
|
|
|
|
|
// necessary classes?
|
|
|
|
|
virtual int proc_sample_rate_hz() const = 0;
|
|
|
|
|
virtual int proc_split_sample_rate_hz() const = 0;
|
Convert channel counts to size_t.
IIRC, this was originally requested by ajm during review of the other size_t conversions I did over the past year, and I agreed it made sense, but wanted to do it separately since those changes were already gargantuan.
BUG=chromium:81439
TEST=none
R=henrik.lundin@webrtc.org, henrika@webrtc.org, kjellander@webrtc.org, minyue@webrtc.org, perkj@webrtc.org, solenberg@webrtc.org, stefan@webrtc.org, tina.legrand@webrtc.org
Review URL: https://codereview.webrtc.org/1316523002 .
Cr-Commit-Position: refs/heads/master@{#11229}
2016-01-12 16:26:35 -08:00
|
|
|
virtual size_t num_input_channels() const = 0;
|
|
|
|
|
virtual size_t num_proc_channels() const = 0;
|
|
|
|
|
virtual size_t num_output_channels() const = 0;
|
|
|
|
|
virtual size_t num_reverse_channels() const = 0;
|
2011-07-07 08:21:25 +00:00
|
|
|
|
2014-02-12 22:28:31 +00:00
|
|
|
// Set to true when the output of AudioProcessing will be muted or in some
|
|
|
|
|
// other way not used. Ideally, the captured audio would still be processed,
|
|
|
|
|
// but some components may change behavior based on this information.
|
2021-02-09 08:47:51 +01:00
|
|
|
// Default false. This method takes a lock. To achieve this in a lock-less
|
|
|
|
|
// manner the PostRuntimeSetting can instead be used.
|
2014-02-12 22:28:31 +00:00
|
|
|
virtual void set_output_will_be_muted(bool muted) = 0;
|
|
|
|
|
|
2021-02-09 08:47:51 +01:00
|
|
|
// Enqueues a runtime setting.
|
2018-04-16 12:10:09 +02:00
|
|
|
virtual void SetRuntimeSetting(RuntimeSetting setting) = 0;
|
|
|
|
|
|
2021-02-09 08:47:51 +01:00
|
|
|
// Enqueues a runtime setting. Returns a bool indicating whether the
|
|
|
|
|
// enqueueing was successfull.
|
2021-02-09 23:15:07 +01:00
|
|
|
virtual bool PostRuntimeSetting(RuntimeSetting setting) = 0;
|
2021-02-09 08:47:51 +01:00
|
|
|
|
2022-08-03 14:37:00 +02:00
|
|
|
// Accepts and produces a ~10 ms frame of interleaved 16 bit integer audio as
|
2021-07-28 20:50:03 +02:00
|
|
|
// specified in `input_config` and `output_config`. `src` and `dest` may use
|
2020-03-16 12:06:02 +01:00
|
|
|
// the same memory, if desired.
|
|
|
|
|
virtual int ProcessStream(const int16_t* const src,
|
|
|
|
|
const StreamConfig& input_config,
|
|
|
|
|
const StreamConfig& output_config,
|
2020-03-19 14:55:58 +01:00
|
|
|
int16_t* const dest) = 0;
|
2020-03-16 12:06:02 +01:00
|
|
|
|
2015-07-23 11:41:39 -07:00
|
|
|
// Accepts deinterleaved float audio with the range [-1, 1]. Each element of
|
2021-07-28 20:50:03 +02:00
|
|
|
// `src` points to a channel buffer, arranged according to `input_stream`. At
|
|
|
|
|
// output, the channels will be arranged according to `output_stream` in
|
|
|
|
|
// `dest`.
|
2015-07-23 11:41:39 -07:00
|
|
|
//
|
2021-07-28 20:50:03 +02:00
|
|
|
// The output must have one channel or as many channels as the input. `src`
|
|
|
|
|
// and `dest` may use the same memory, if desired.
|
2015-07-23 11:41:39 -07:00
|
|
|
virtual int ProcessStream(const float* const* src,
|
|
|
|
|
const StreamConfig& input_config,
|
|
|
|
|
const StreamConfig& output_config,
|
|
|
|
|
float* const* dest) = 0;
|
|
|
|
|
|
2022-08-03 14:37:00 +02:00
|
|
|
// Accepts and produces a ~10 ms frame of interleaved 16 bit integer audio for
|
2021-07-28 20:50:03 +02:00
|
|
|
// the reverse direction audio stream as specified in `input_config` and
|
|
|
|
|
// `output_config`. `src` and `dest` may use the same memory, if desired.
|
2020-03-16 12:06:02 +01:00
|
|
|
virtual int ProcessReverseStream(const int16_t* const src,
|
|
|
|
|
const StreamConfig& input_config,
|
|
|
|
|
const StreamConfig& output_config,
|
|
|
|
|
int16_t* const dest) = 0;
|
|
|
|
|
|
2015-07-23 11:41:39 -07:00
|
|
|
// Accepts deinterleaved float audio with the range [-1, 1]. Each element of
|
2021-07-28 20:50:03 +02:00
|
|
|
// `data` points to a channel buffer, arranged according to `reverse_config`.
|
2015-08-14 10:35:55 -07:00
|
|
|
virtual int ProcessReverseStream(const float* const* src,
|
2016-09-16 15:02:15 -07:00
|
|
|
const StreamConfig& input_config,
|
|
|
|
|
const StreamConfig& output_config,
|
2015-08-14 10:35:55 -07:00
|
|
|
float* const* dest) = 0;
|
2015-07-23 11:41:39 -07:00
|
|
|
|
2019-10-29 09:30:44 +01:00
|
|
|
// Accepts deinterleaved float audio with the range [-1, 1]. Each element
|
2021-07-28 20:50:03 +02:00
|
|
|
// of `data` points to a channel buffer, arranged according to
|
|
|
|
|
// `reverse_config`.
|
2019-10-29 09:30:44 +01:00
|
|
|
virtual int AnalyzeReverseStream(const float* const* data,
|
|
|
|
|
const StreamConfig& reverse_config) = 0;
|
|
|
|
|
|
2022-08-03 14:37:00 +02:00
|
|
|
// Returns the most recently produced ~10 ms of the linear AEC output at a
|
|
|
|
|
// rate of 16 kHz. If there is more than one capture channel, a mono
|
|
|
|
|
// representation of the input is returned. Returns true/false to indicate
|
|
|
|
|
// whether an output returned.
|
2019-11-13 11:12:29 +01:00
|
|
|
virtual bool GetLinearAecOutput(
|
|
|
|
|
rtc::ArrayView<std::array<float, 160>> linear_output) const = 0;
|
|
|
|
|
|
2019-03-27 13:28:08 +01:00
|
|
|
// This must be called prior to ProcessStream() if and only if adaptive analog
|
|
|
|
|
// gain control is enabled, to pass the current analog level from the audio
|
2021-11-02 11:02:48 +01:00
|
|
|
// HAL. Must be within the range [0, 255].
|
2019-03-27 13:28:08 +01:00
|
|
|
virtual void set_stream_analog_level(int level) = 0;
|
|
|
|
|
|
2022-09-07 17:14:26 +02:00
|
|
|
// When an analog mode is set, this should be called after
|
|
|
|
|
// `set_stream_analog_level()` and `ProcessStream()` to obtain the recommended
|
|
|
|
|
// new analog level for the audio HAL. It is the user's responsibility to
|
|
|
|
|
// apply this level.
|
2019-03-27 13:28:08 +01:00
|
|
|
virtual int recommended_stream_analog_level() const = 0;
|
|
|
|
|
|
2011-07-07 08:21:25 +00:00
|
|
|
// This must be called if and only if echo processing is enabled.
|
|
|
|
|
//
|
2021-07-28 20:50:03 +02:00
|
|
|
// Sets the `delay` in ms between ProcessReverseStream() receiving a far-end
|
2011-07-07 08:21:25 +00:00
|
|
|
// frame and ProcessStream() receiving a near-end frame containing the
|
|
|
|
|
// corresponding echo. On the client-side this can be expressed as
|
|
|
|
|
// delay = (t_render - t_analyze) + (t_process - t_capture)
|
|
|
|
|
// where,
|
2016-03-17 20:39:53 -07:00
|
|
|
// - t_analyze is the time a frame is passed to ProcessReverseStream() and
|
2011-07-07 08:21:25 +00:00
|
|
|
// t_render is the time the first sample of the same frame is rendered by
|
|
|
|
|
// the audio hardware.
|
|
|
|
|
// - t_capture is the time the first sample of a frame is captured by the
|
2017-04-19 05:35:51 -07:00
|
|
|
// audio hardware and t_process is the time the same frame is passed to
|
2011-07-07 08:21:25 +00:00
|
|
|
// ProcessStream().
|
|
|
|
|
virtual int set_stream_delay_ms(int delay) = 0;
|
|
|
|
|
virtual int stream_delay_ms() const = 0;
|
|
|
|
|
|
2014-02-11 20:52:30 +00:00
|
|
|
// Call to signal that a key press occurred (true) or did not occur (false)
|
|
|
|
|
// with this chunk of audio.
|
|
|
|
|
virtual void set_stream_key_pressed(bool key_pressed) = 0;
|
|
|
|
|
|
2020-05-11 11:03:47 +02:00
|
|
|
// Creates and attaches an webrtc::AecDump for recording debugging
|
|
|
|
|
// information.
|
2021-07-28 20:50:03 +02:00
|
|
|
// The `worker_queue` may not be null and must outlive the created
|
2020-05-11 11:03:47 +02:00
|
|
|
// AecDump instance. |max_log_size_bytes == -1| means the log size
|
2021-07-28 20:50:03 +02:00
|
|
|
// will be unlimited. `handle` may not be null. The AecDump takes
|
|
|
|
|
// responsibility for `handle` and closes it in the destructor. A
|
2020-05-11 11:03:47 +02:00
|
|
|
// return value of true indicates that the file has been
|
|
|
|
|
// sucessfully opened, while a value of false indicates that
|
|
|
|
|
// opening the file failed.
|
2024-01-09 11:52:10 +01:00
|
|
|
virtual bool CreateAndAttachAecDump(
|
|
|
|
|
absl::string_view file_name,
|
|
|
|
|
int64_t max_log_size_bytes,
|
2024-01-15 11:42:13 +01:00
|
|
|
absl::Nonnull<TaskQueueBase*> worker_queue) = 0;
|
2024-01-09 11:52:10 +01:00
|
|
|
virtual bool CreateAndAttachAecDump(
|
|
|
|
|
absl::Nonnull<FILE*> handle,
|
|
|
|
|
int64_t max_log_size_bytes,
|
2024-01-15 11:42:13 +01:00
|
|
|
absl::Nonnull<TaskQueueBase*> worker_queue) = 0;
|
2020-05-11 11:03:47 +02:00
|
|
|
|
|
|
|
|
// TODO(webrtc:5298) Deprecated variant.
|
AudioProcessingModule has a feature to make a recording of its
configuration, inputs and outputs over a period of time. It is
activated by AudioProcessing::StartRecording. The data is stored in
binary protobuf format in a specified file. The file IO is, as of
this CL, done from the real-time audio thread.
This CL contains an interface for AecDump, a new APM submodule that
will handle the recordings. Calls to the new interface from the
AudioProcessingModule are added. These calls have no effect, and for a
short while, audio_processing_impl.cc will contain two copies of
recording calls.
The original calls are guarded by the WEBRTC_AUDIOPROC_DEBUG_DUMP
preprocessor define. They still have an effect, while the new ones do
not. In the following CLs, the old recording calls will be removed,
and an implementation of AecDump added.
The reasons for the refactoring is to move file IO operations from the
real-time audio thread, to add a top-level low-priority task queue for
logging tasks like this, to simplify and modularize audio_processing_impl.cc
and remove some of the preprocessor directives. These goals will be
archived by the upcoming CLs. The implementation is in
https://codereview.webrtc.org/2865113002.
BUG=webrtc:7404
Review-Url: https://codereview.webrtc.org/2778783002
Cr-Commit-Position: refs/heads/master@{#18233}
2017-05-23 07:20:05 -07:00
|
|
|
// Attaches provided webrtc::AecDump for recording debugging
|
|
|
|
|
// information. Log file and maximum file size logic is supposed to
|
|
|
|
|
// be handled by implementing instance of AecDump. Calling this
|
|
|
|
|
// method when another AecDump is attached resets the active AecDump
|
|
|
|
|
// with a new one. This causes the d-tor of the earlier AecDump to
|
|
|
|
|
// be called. The d-tor call may block until all pending logging
|
|
|
|
|
// tasks are completed.
|
2017-06-08 09:45:03 +02:00
|
|
|
virtual void AttachAecDump(std::unique_ptr<AecDump> aec_dump) = 0;
|
AudioProcessingModule has a feature to make a recording of its
configuration, inputs and outputs over a period of time. It is
activated by AudioProcessing::StartRecording. The data is stored in
binary protobuf format in a specified file. The file IO is, as of
this CL, done from the real-time audio thread.
This CL contains an interface for AecDump, a new APM submodule that
will handle the recordings. Calls to the new interface from the
AudioProcessingModule are added. These calls have no effect, and for a
short while, audio_processing_impl.cc will contain two copies of
recording calls.
The original calls are guarded by the WEBRTC_AUDIOPROC_DEBUG_DUMP
preprocessor define. They still have an effect, while the new ones do
not. In the following CLs, the old recording calls will be removed,
and an implementation of AecDump added.
The reasons for the refactoring is to move file IO operations from the
real-time audio thread, to add a top-level low-priority task queue for
logging tasks like this, to simplify and modularize audio_processing_impl.cc
and remove some of the preprocessor directives. These goals will be
archived by the upcoming CLs. The implementation is in
https://codereview.webrtc.org/2865113002.
BUG=webrtc:7404
Review-Url: https://codereview.webrtc.org/2778783002
Cr-Commit-Position: refs/heads/master@{#18233}
2017-05-23 07:20:05 -07:00
|
|
|
|
|
|
|
|
// If no AecDump is attached, this has no effect. If an AecDump is
|
|
|
|
|
// attached, it's destructor is called. The d-tor may block until
|
|
|
|
|
// all pending logging tasks are completed.
|
2017-06-08 09:45:03 +02:00
|
|
|
virtual void DetachAecDump() = 0;
|
AudioProcessingModule has a feature to make a recording of its
configuration, inputs and outputs over a period of time. It is
activated by AudioProcessing::StartRecording. The data is stored in
binary protobuf format in a specified file. The file IO is, as of
this CL, done from the real-time audio thread.
This CL contains an interface for AecDump, a new APM submodule that
will handle the recordings. Calls to the new interface from the
AudioProcessingModule are added. These calls have no effect, and for a
short while, audio_processing_impl.cc will contain two copies of
recording calls.
The original calls are guarded by the WEBRTC_AUDIOPROC_DEBUG_DUMP
preprocessor define. They still have an effect, while the new ones do
not. In the following CLs, the old recording calls will be removed,
and an implementation of AecDump added.
The reasons for the refactoring is to move file IO operations from the
real-time audio thread, to add a top-level low-priority task queue for
logging tasks like this, to simplify and modularize audio_processing_impl.cc
and remove some of the preprocessor directives. These goals will be
archived by the upcoming CLs. The implementation is in
https://codereview.webrtc.org/2865113002.
BUG=webrtc:7404
Review-Url: https://codereview.webrtc.org/2778783002
Cr-Commit-Position: refs/heads/master@{#18233}
2017-05-23 07:20:05 -07:00
|
|
|
|
2019-12-30 14:32:14 +01:00
|
|
|
// Get audio processing statistics.
|
|
|
|
|
virtual AudioProcessingStats GetStatistics() = 0;
|
2021-07-28 20:50:03 +02:00
|
|
|
// TODO(webrtc:5298) Deprecated variant. The `has_remote_tracks` argument
|
2019-12-30 14:32:14 +01:00
|
|
|
// should be set if there are active remote tracks (this would usually be true
|
|
|
|
|
// during a call). If there are no remote tracks some of the stats will not be
|
|
|
|
|
// set by AudioProcessing, because they only make sense if there is at least
|
|
|
|
|
// one remote track.
|
|
|
|
|
virtual AudioProcessingStats GetStatistics(bool has_remote_tracks) = 0;
|
2017-11-20 13:07:16 +01:00
|
|
|
|
2017-04-05 05:48:24 -07:00
|
|
|
// Returns the last applied configuration.
|
2017-04-06 23:28:09 -07:00
|
|
|
virtual AudioProcessing::Config GetConfig() const = 0;
|
2017-04-05 05:48:24 -07:00
|
|
|
|
2012-02-08 01:57:29 +00:00
|
|
|
enum Error {
|
|
|
|
|
// Fatal errors.
|
2011-07-07 08:21:25 +00:00
|
|
|
kNoError = 0,
|
|
|
|
|
kUnspecifiedError = -1,
|
|
|
|
|
kCreationFailedError = -2,
|
|
|
|
|
kUnsupportedComponentError = -3,
|
|
|
|
|
kUnsupportedFunctionError = -4,
|
|
|
|
|
kNullPointerError = -5,
|
|
|
|
|
kBadParameterError = -6,
|
|
|
|
|
kBadSampleRateError = -7,
|
|
|
|
|
kBadDataLengthError = -8,
|
|
|
|
|
kBadNumberChannelsError = -9,
|
|
|
|
|
kFileError = -10,
|
|
|
|
|
kStreamParameterNotSetError = -11,
|
2012-02-08 01:57:29 +00:00
|
|
|
kNotEnabledError = -12,
|
2011-07-07 08:21:25 +00:00
|
|
|
|
2012-02-08 01:57:29 +00:00
|
|
|
// Warnings are non-fatal.
|
2011-07-07 08:21:25 +00:00
|
|
|
// This results when a set_stream_ parameter is out of range. Processing
|
|
|
|
|
// will continue, but the parameter may have been truncated.
|
2012-02-08 01:57:29 +00:00
|
|
|
kBadStreamParameterWarning = -13
|
2011-07-07 08:21:25 +00:00
|
|
|
};
|
2014-02-27 22:23:17 +00:00
|
|
|
|
2020-03-19 12:33:29 +01:00
|
|
|
// Native rates supported by the integer interfaces.
|
2014-04-22 21:00:04 +00:00
|
|
|
enum NativeRate {
|
2014-02-27 22:23:17 +00:00
|
|
|
kSampleRate8kHz = 8000,
|
|
|
|
|
kSampleRate16kHz = 16000,
|
2014-11-17 23:01:23 +00:00
|
|
|
kSampleRate32kHz = 32000,
|
|
|
|
|
kSampleRate48kHz = 48000
|
2014-02-27 22:23:17 +00:00
|
|
|
};
|
2014-04-22 21:00:04 +00:00
|
|
|
|
2016-09-13 07:49:33 -07:00
|
|
|
// TODO(kwiberg): We currently need to support a compiler (Visual C++) that
|
|
|
|
|
// complains if we don't explicitly state the size of the array here. Remove
|
|
|
|
|
// the size when that's no longer the case.
|
|
|
|
|
static constexpr int kNativeSampleRatesHz[4] = {
|
|
|
|
|
kSampleRate8kHz, kSampleRate16kHz, kSampleRate32kHz, kSampleRate48kHz};
|
|
|
|
|
static constexpr size_t kNumNativeSampleRates =
|
|
|
|
|
arraysize(kNativeSampleRatesHz);
|
|
|
|
|
static constexpr int kMaxNativeSampleRateHz =
|
|
|
|
|
kNativeSampleRatesHz[kNumNativeSampleRates - 1];
|
2015-09-23 12:49:12 -07:00
|
|
|
|
2022-08-03 14:37:00 +02:00
|
|
|
// APM processes audio in chunks of about 10 ms. See GetFrameSize() for
|
|
|
|
|
// details.
|
2020-12-08 09:40:35 +01:00
|
|
|
static constexpr int kChunkSizeMs = 10;
|
2022-08-03 14:37:00 +02:00
|
|
|
|
|
|
|
|
// Returns floor(sample_rate_hz/100): the number of samples per channel used
|
|
|
|
|
// as input and output to the audio processing module in calls to
|
|
|
|
|
// ProcessStream, ProcessReverseStream, AnalyzeReverseStream, and
|
|
|
|
|
// GetLinearAecOutput.
|
|
|
|
|
//
|
|
|
|
|
// This is exactly 10 ms for sample rates divisible by 100. For example:
|
|
|
|
|
// - 48000 Hz (480 samples per channel),
|
|
|
|
|
// - 44100 Hz (441 samples per channel),
|
|
|
|
|
// - 16000 Hz (160 samples per channel).
|
|
|
|
|
//
|
|
|
|
|
// Sample rates not divisible by 100 are received/produced in frames of
|
|
|
|
|
// approximately 10 ms. For example:
|
|
|
|
|
// - 22050 Hz (220 samples per channel, or ~9.98 ms per frame),
|
|
|
|
|
// - 11025 Hz (110 samples per channel, or ~9.98 ms per frame).
|
|
|
|
|
// These nondivisible sample rates yield lower audio quality compared to
|
|
|
|
|
// multiples of 100. Internal resampling to 10 ms frames causes a simulated
|
|
|
|
|
// clock drift effect which impacts the performance of (for example) echo
|
|
|
|
|
// cancellation.
|
|
|
|
|
static int GetFrameSize(int sample_rate_hz) { return sample_rate_hz / 100; }
|
2011-07-07 08:21:25 +00:00
|
|
|
};
|
|
|
|
|
|
Reland "Export symbols needed by the Chromium component build (part 1)."
This reverts commit 16fe3f290a524a136f71660a114d0b03ef501f10.
Reason for revert:
After discussing this problem with nisse@ and yvesg@, we decided to modify
how RTC_EXPORT works and avoid to depend on the macro COMPONENT_BUILD.
RTC_EXPORT will instead depend on a macro WEBRTC_COMPONENT_BUILD (which
can be set as a GN argument which defaults to false).
When all the symbols needed by Chromium will be marked with RTC_EXPORT we
will flip the GN arg in Chromium, setting to to `component_build` and from
that moment, Chromium will depend on a WebRTC shared library when
`component_build=true`.
Original change's description:
> Revert "Export symbols needed by the Chromium component build (part 1)."
>
> This reverts commit 99eea42fc1fe0be0ebed13c5eba7e1e42059bc5a.
>
> Reason for revert:
> lld-link: error: undefined symbol: "__declspec(dllimport) bool __cdecl cricket::UnwrapTurnPacket(unsigned char const *, unsigned int, unsigned int *, unsigned int *)" (__imp_?UnwrapTurnPacket@cricket@@YA_NPBEIPAI1@Z)
> >>> referenced by obj/services/network/network_service/socket_manager.obj:("virtual void __thiscall network::P2PSocketManager::DumpPacket(class base::span<unsigned char const, 4294967295>, bool)" (?DumpPacket@P2PSocketManager@network@@EAEXV?$span@$$CBE$0PPPPPPPP@@base@@_N@Z))
> lld-link: error: undefined symbol: "__declspec(dllimport) bool __cdecl cricket::ValidateRtpHeader(unsigned char const *, unsigned int, unsigned int *)" (__imp_?ValidateRtpHeader@cricket@@YA_NPBEIPAI@Z)
> >>> referenced by obj/services/network/network_service/socket_manager.obj:("virtual void __thiscall network::P2PSocketManager::DumpPacket(class base::span<unsigned char const, 4294967295>, bool)" (?DumpPacket@P2PSocketManager@network@@EAEXV?$span@$$CBE$0PPPPPPPP@@base@@_N@Z))
> lld-link: error: undefined symbol: "__declspec(dllimport) bool __cdecl cricket::ApplyPacketOptions(unsigned char *, unsigned int, struct rtc::PacketTimeUpdateParams const &, unsigned __int64)" (__imp_?ApplyPacketOptions@cricket@@YA_NPAEIABUPacketTimeUpdateParams@rtc@@_K@Z)
> >>> referenced by obj/services/network/network_service/socket_tcp.obj:("virtual void __thiscall network::P2PSocketTcp::DoSend(class net::IPEndPoint const &, class std::vector<signed char, class std::allocator<signed char>> const &, struct rtc::PacketOptions const &, struct net::NetworkTrafficAnnotationTag)" (?DoSend@P2PSocketTcp@network@@MAEXABVIPEndPoint@net@@ABV?$vector@CV?$allocator@C@std@@@std@@ABUPacketOptions@rtc@@UNetworkTrafficAnnotationTag@4@@Z))
> >>> referenced by obj/services/network/network_service/socket_tcp.obj:("virtual void __thiscall network::P2PSocketStunTcp::DoSend(class net::IPEndPoint const &, class std::vector<signed char, class std::allocator<signed char>> const &, struct rtc::PacketOptions const &, struct net::NetworkTrafficAnnotationTag)" (?DoSend@P2PSocketStunTcp@network@@MAEXABVIPEndPoint@net@@ABV?$vector@CV?$allocator@C@std@@@std@@ABUPacketOptions@rtc@@UNetworkTrafficAnnotationTag@4@@Z))
> lld-link: error: undefined symbol: "__declspec(dllimport) bool __cdecl cricket::ApplyPacketOptions(unsigned char *, unsigned int, struct rtc::PacketTimeUpdateParams const &, unsigned __int64)" (__imp_?ApplyPacketOptions@cricket@@YA_NPAEIABUPacketTimeUpdateParams@rtc@@_K@Z)
> >>> referenced by obj/services/network/network_service/socket_udp.obj:("bool __thiscall network::P2PSocketUdp::DoSend(struct network::P2PSocketUdp::PendingPacket const &)" (?DoSend@P2PSocketUdp@network@@AAE_NABUPendingPacket@12@@Z))
>
> Original change's description:
> > Reland "Reland "Export symbols needed by the Chromium component build (part 1).""
> >
> > This reverts commit b49520bfc08f5c5832dda1d642125f0bb898f974.
> >
> > Reason for revert: Problem fixed in https://chromium-review.googlesource.com/c/chromium/src/+/1261398.
> >
> > Original change's description:
> > > Revert "Reland "Export symbols needed by the Chromium component build (part 1).""
> > >
> > > This reverts commit 588f4642d1a29f7beaf28265dbd08728191b4c52.
> > >
> > > Reason for revert: Breaks WebRTC Chromium FYI Win Builder (dbg).
> > > lld-link: error: undefined symbol: "__declspec(dllimport) __thiscall webrtc::Config::Config(void)" (__imp_??0Config@webrtc@@QAE@XZ)
> > > [...]
> > >
> > > Original change's description:
> > > > Reland "Export symbols needed by the Chromium component build (part 1)."
> > > >
> > > > This reverts commit 2ea9af227517556136fd629dd2663c0d75d77c7b.
> > > >
> > > > Reason for revert: The problem will be fixed by
> > > > https://chromium-review.googlesource.com/c/chromium/src/+/1261122.
> > > >
> > > > Original change's description:
> > > > > Revert "Export symbols needed by the Chromium component build (part 1)."
> > > > >
> > > > > This reverts commit 9e24dcff167c4eb3555bf0ce6eaba090c10fbe53.
> > > > >
> > > > > Reason for revert: Breaks chromium.webrtc.fyi bots.
> > > > >
> > > > > Original change's description:
> > > > > > Export symbols needed by the Chromium component build (part 1).
> > > > > >
> > > > > > This CL uses RTC_EXPORT (defined in rtc_base/system/rtc_export.h)
> > > > > > to mark WebRTC symbols as visible from a shared library, this doesn't
> > > > > > mean these symbols are part of the public API (please continue to refer
> > > > > > to [1] for info about what is considered public WebRTC API).
> > > > > >
> > > > > > [1] - https://webrtc.googlesource.com/src/+/HEAD/native-api.md
> > > > > >
> > > > > > Bug: webrtc:9419
> > > > > > Change-Id: I802abd32874d42d3aa5ecd3c8022e7cf5e043d99
> > > > > > Reviewed-on: https://webrtc-review.googlesource.com/c/103505
> > > > > > Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org>
> > > > > > Reviewed-by: Niels Moller <nisse@webrtc.org>
> > > > > > Reviewed-by: Karl Wiberg <kwiberg@webrtc.org>
> > > > > > Cr-Commit-Position: refs/heads/master@{#24969}
> > > > >
> > > > > TBR=mbonadei@webrtc.org,kwiberg@webrtc.org,nisse@webrtc.org
> > > > >
> > > > > Change-Id: I01f6e18f0d2c0f0309cdaa6c943c3927e1f1f49f
> > > > > No-Presubmit: true
> > > > > No-Tree-Checks: true
> > > > > No-Try: true
> > > > > Bug: webrtc:9419
> > > > > Reviewed-on: https://webrtc-review.googlesource.com/c/103720
> > > > > Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org>
> > > > > Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org>
> > > > > Cr-Commit-Position: refs/heads/master@{#24974}
> > > >
> > > > TBR=mbonadei@webrtc.org,kwiberg@webrtc.org,nisse@webrtc.org
> > > >
> > > > Change-Id: I83bbc7f550fc23e823c4d055e0a6f60c828960dd
> > > > No-Presubmit: true
> > > > No-Tree-Checks: true
> > > > No-Try: true
> > > > Bug: webrtc:9419
> > > > Reviewed-on: https://webrtc-review.googlesource.com/c/103740
> > > > Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org>
> > > > Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org>
> > > > Cr-Commit-Position: refs/heads/master@{#24980}
> > >
> > > TBR=mbonadei@webrtc.org,kwiberg@webrtc.org,nisse@webrtc.org
> > >
> > > Change-Id: I4b7cfe492f2c8eeda5c8ac52520e0cfc95ade9b0
> > > No-Presubmit: true
> > > No-Tree-Checks: true
> > > No-Try: true
> > > Bug: webrtc:9419
> > > Reviewed-on: https://webrtc-review.googlesource.com/c/103801
> > > Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org>
> > > Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org>
> > > Cr-Commit-Position: refs/heads/master@{#24983}
> >
> > TBR=mbonadei@webrtc.org,kwiberg@webrtc.org,nisse@webrtc.org
> >
> > # Not skipping CQ checks because original CL landed > 1 day ago.
> >
> > Bug: webrtc:9419
> > Change-Id: Id986a0a03cdc2818690337784396882af067f7fa
> > Reviewed-on: https://webrtc-review.googlesource.com/c/104602
> > Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org>
> > Reviewed-by: Niels Moller <nisse@webrtc.org>
> > Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org>
> > Cr-Commit-Position: refs/heads/master@{#25049}
>
> TBR=mbonadei@webrtc.org,kwiberg@webrtc.org,nisse@webrtc.org
>
> Change-Id: I6f58b9c90defccdb160307783fb55271ab424fa1
> No-Presubmit: true
> No-Tree-Checks: true
> No-Try: true
> Bug: webrtc:9419
> Reviewed-on: https://webrtc-review.googlesource.com/c/104623
> Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org>
> Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org>
> Cr-Commit-Position: refs/heads/master@{#25050}
TBR=mbonadei@webrtc.org,kwiberg@webrtc.org,nisse@webrtc.org
Change-Id: I4d01ed96ae40a8f9ca42c466be5c87653d75d7c1
Bug: webrtc:9419
Reviewed-on: https://webrtc-review.googlesource.com/c/104641
Reviewed-by: Yves Gerey <yvesg@webrtc.org>
Reviewed-by: Niels Moller <nisse@webrtc.org>
Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org>
Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#25108}
2018-10-11 10:50:45 +02:00
|
|
|
class RTC_EXPORT AudioProcessingBuilder {
|
2017-12-22 11:35:59 +01:00
|
|
|
public:
|
|
|
|
|
AudioProcessingBuilder();
|
2021-10-14 10:55:08 +02:00
|
|
|
AudioProcessingBuilder(const AudioProcessingBuilder&) = delete;
|
|
|
|
|
AudioProcessingBuilder& operator=(const AudioProcessingBuilder&) = delete;
|
2017-12-22 11:35:59 +01:00
|
|
|
~AudioProcessingBuilder();
|
2021-10-14 10:55:08 +02:00
|
|
|
|
|
|
|
|
// Sets the APM configuration.
|
|
|
|
|
AudioProcessingBuilder& SetConfig(const AudioProcessing::Config& config) {
|
|
|
|
|
config_ = config;
|
|
|
|
|
return *this;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Sets the echo controller factory to inject when APM is created.
|
2017-12-22 11:35:59 +01:00
|
|
|
AudioProcessingBuilder& SetEchoControlFactory(
|
2020-04-26 23:56:17 +02:00
|
|
|
std::unique_ptr<EchoControlFactory> echo_control_factory) {
|
|
|
|
|
echo_control_factory_ = std::move(echo_control_factory);
|
|
|
|
|
return *this;
|
|
|
|
|
}
|
2021-10-14 10:55:08 +02:00
|
|
|
|
|
|
|
|
// Sets the capture post-processing sub-module to inject when APM is created.
|
2017-12-22 11:35:59 +01:00
|
|
|
AudioProcessingBuilder& SetCapturePostProcessing(
|
2020-04-26 23:56:17 +02:00
|
|
|
std::unique_ptr<CustomProcessing> capture_post_processing) {
|
|
|
|
|
capture_post_processing_ = std::move(capture_post_processing);
|
|
|
|
|
return *this;
|
|
|
|
|
}
|
2021-10-14 10:55:08 +02:00
|
|
|
|
|
|
|
|
// Sets the render pre-processing sub-module to inject when APM is created.
|
2017-12-22 11:35:59 +01:00
|
|
|
AudioProcessingBuilder& SetRenderPreProcessing(
|
2020-04-26 23:56:17 +02:00
|
|
|
std::unique_ptr<CustomProcessing> render_pre_processing) {
|
|
|
|
|
render_pre_processing_ = std::move(render_pre_processing);
|
|
|
|
|
return *this;
|
|
|
|
|
}
|
2021-10-14 10:55:08 +02:00
|
|
|
|
|
|
|
|
// Sets the echo detector to inject when APM is created.
|
2018-01-11 16:08:54 +01:00
|
|
|
AudioProcessingBuilder& SetEchoDetector(
|
2020-04-26 23:56:17 +02:00
|
|
|
rtc::scoped_refptr<EchoDetector> echo_detector) {
|
|
|
|
|
echo_detector_ = std::move(echo_detector);
|
|
|
|
|
return *this;
|
|
|
|
|
}
|
2021-10-14 10:55:08 +02:00
|
|
|
|
|
|
|
|
// Sets the capture analyzer sub-module to inject when APM is created.
|
2018-08-29 10:37:09 +02:00
|
|
|
AudioProcessingBuilder& SetCaptureAnalyzer(
|
2020-04-26 23:56:17 +02:00
|
|
|
std::unique_ptr<CustomAudioAnalyzer> capture_analyzer) {
|
|
|
|
|
capture_analyzer_ = std::move(capture_analyzer);
|
|
|
|
|
return *this;
|
|
|
|
|
}
|
2021-10-14 10:55:08 +02:00
|
|
|
|
|
|
|
|
// Creates an APM instance with the specified config or the default one if
|
|
|
|
|
// unspecified. Injects the specified components transferring the ownership
|
|
|
|
|
// to the newly created APM instance - i.e., except for the config, the
|
|
|
|
|
// builder is reset to its initial state.
|
2021-07-02 11:30:54 +02:00
|
|
|
rtc::scoped_refptr<AudioProcessing> Create();
|
2017-12-22 11:35:59 +01:00
|
|
|
|
|
|
|
|
private:
|
2021-10-14 10:55:08 +02:00
|
|
|
AudioProcessing::Config config_;
|
2017-12-22 11:35:59 +01:00
|
|
|
std::unique_ptr<EchoControlFactory> echo_control_factory_;
|
|
|
|
|
std::unique_ptr<CustomProcessing> capture_post_processing_;
|
|
|
|
|
std::unique_ptr<CustomProcessing> render_pre_processing_;
|
2018-06-14 11:02:03 +02:00
|
|
|
rtc::scoped_refptr<EchoDetector> echo_detector_;
|
2018-08-29 10:37:09 +02:00
|
|
|
std::unique_ptr<CustomAudioAnalyzer> capture_analyzer_;
|
2017-12-22 11:35:59 +01:00
|
|
|
};
|
|
|
|
|
|
2015-07-23 11:41:39 -07:00
|
|
|
class StreamConfig {
|
|
|
|
|
public:
|
|
|
|
|
// sample_rate_hz: The sampling rate of the stream.
|
2022-02-04 09:02:48 +00:00
|
|
|
// num_channels: The number of audio channels in the stream.
|
2022-02-04 17:06:55 +01:00
|
|
|
StreamConfig(int sample_rate_hz = 0, size_t num_channels = 0)
|
2015-07-23 11:41:39 -07:00
|
|
|
: sample_rate_hz_(sample_rate_hz),
|
|
|
|
|
num_channels_(num_channels),
|
|
|
|
|
num_frames_(calculate_frames(sample_rate_hz)) {}
|
|
|
|
|
|
|
|
|
|
void set_sample_rate_hz(int value) {
|
|
|
|
|
sample_rate_hz_ = value;
|
|
|
|
|
num_frames_ = calculate_frames(value);
|
|
|
|
|
}
|
Convert channel counts to size_t.
IIRC, this was originally requested by ajm during review of the other size_t conversions I did over the past year, and I agreed it made sense, but wanted to do it separately since those changes were already gargantuan.
BUG=chromium:81439
TEST=none
R=henrik.lundin@webrtc.org, henrika@webrtc.org, kjellander@webrtc.org, minyue@webrtc.org, perkj@webrtc.org, solenberg@webrtc.org, stefan@webrtc.org, tina.legrand@webrtc.org
Review URL: https://codereview.webrtc.org/1316523002 .
Cr-Commit-Position: refs/heads/master@{#11229}
2016-01-12 16:26:35 -08:00
|
|
|
void set_num_channels(size_t value) { num_channels_ = value; }
|
2015-07-23 11:41:39 -07:00
|
|
|
|
|
|
|
|
int sample_rate_hz() const { return sample_rate_hz_; }
|
|
|
|
|
|
2022-02-04 09:02:48 +00:00
|
|
|
// The number of channels in the stream.
|
Convert channel counts to size_t.
IIRC, this was originally requested by ajm during review of the other size_t conversions I did over the past year, and I agreed it made sense, but wanted to do it separately since those changes were already gargantuan.
BUG=chromium:81439
TEST=none
R=henrik.lundin@webrtc.org, henrika@webrtc.org, kjellander@webrtc.org, minyue@webrtc.org, perkj@webrtc.org, solenberg@webrtc.org, stefan@webrtc.org, tina.legrand@webrtc.org
Review URL: https://codereview.webrtc.org/1316523002 .
Cr-Commit-Position: refs/heads/master@{#11229}
2016-01-12 16:26:35 -08:00
|
|
|
size_t num_channels() const { return num_channels_; }
|
2015-07-23 11:41:39 -07:00
|
|
|
|
Update a ton of audio code to use size_t more correctly and in general reduce
use of int16_t/uint16_t.
This is the upshot of a recommendation by henrik.lundin and kwiberg on an original small change ( https://webrtc-codereview.appspot.com/42569004/#ps1 ) to stop using int16_t just because values could fit in it, and is similar in nature to a previous "mass change to use size_t more" ( https://webrtc-codereview.appspot.com/23129004/ ) which also needed to be split up for review but to land all at once, since, like adding "const", such changes tend to cause a lot of transitive effects.
This was be reviewed and approved in pieces:
https://codereview.webrtc.org/1224093003
https://codereview.webrtc.org/1224123002
https://codereview.webrtc.org/1224163002
https://codereview.webrtc.org/1225133003
https://codereview.webrtc.org/1225173002
https://codereview.webrtc.org/1227163003
https://codereview.webrtc.org/1227203003
https://codereview.webrtc.org/1227213002
https://codereview.webrtc.org/1227893002
https://codereview.webrtc.org/1228793004
https://codereview.webrtc.org/1228803003
https://codereview.webrtc.org/1228823002
https://codereview.webrtc.org/1228823003
https://codereview.webrtc.org/1228843002
https://codereview.webrtc.org/1230693002
https://codereview.webrtc.org/1231713002
The change is being landed as TBR to all the folks who reviewed the above.
BUG=chromium:81439
TEST=none
R=andrew@webrtc.org, pbos@webrtc.org
TBR=aluebs, andrew, asapersson, henrika, hlundin, jan.skoglund, kwiberg, minyue, pbos, pthatcher
Review URL: https://codereview.webrtc.org/1230503003 .
Cr-Commit-Position: refs/heads/master@{#9768}
2015-08-24 14:52:23 -07:00
|
|
|
size_t num_frames() const { return num_frames_; }
|
|
|
|
|
size_t num_samples() const { return num_channels_ * num_frames_; }
|
2015-07-23 11:41:39 -07:00
|
|
|
|
|
|
|
|
bool operator==(const StreamConfig& other) const {
|
|
|
|
|
return sample_rate_hz_ == other.sample_rate_hz_ &&
|
2022-02-04 09:02:48 +00:00
|
|
|
num_channels_ == other.num_channels_;
|
2015-07-23 11:41:39 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool operator!=(const StreamConfig& other) const { return !(*this == other); }
|
|
|
|
|
|
|
|
|
|
private:
|
Update a ton of audio code to use size_t more correctly and in general reduce
use of int16_t/uint16_t.
This is the upshot of a recommendation by henrik.lundin and kwiberg on an original small change ( https://webrtc-codereview.appspot.com/42569004/#ps1 ) to stop using int16_t just because values could fit in it, and is similar in nature to a previous "mass change to use size_t more" ( https://webrtc-codereview.appspot.com/23129004/ ) which also needed to be split up for review but to land all at once, since, like adding "const", such changes tend to cause a lot of transitive effects.
This was be reviewed and approved in pieces:
https://codereview.webrtc.org/1224093003
https://codereview.webrtc.org/1224123002
https://codereview.webrtc.org/1224163002
https://codereview.webrtc.org/1225133003
https://codereview.webrtc.org/1225173002
https://codereview.webrtc.org/1227163003
https://codereview.webrtc.org/1227203003
https://codereview.webrtc.org/1227213002
https://codereview.webrtc.org/1227893002
https://codereview.webrtc.org/1228793004
https://codereview.webrtc.org/1228803003
https://codereview.webrtc.org/1228823002
https://codereview.webrtc.org/1228823003
https://codereview.webrtc.org/1228843002
https://codereview.webrtc.org/1230693002
https://codereview.webrtc.org/1231713002
The change is being landed as TBR to all the folks who reviewed the above.
BUG=chromium:81439
TEST=none
R=andrew@webrtc.org, pbos@webrtc.org
TBR=aluebs, andrew, asapersson, henrika, hlundin, jan.skoglund, kwiberg, minyue, pbos, pthatcher
Review URL: https://codereview.webrtc.org/1230503003 .
Cr-Commit-Position: refs/heads/master@{#9768}
2015-08-24 14:52:23 -07:00
|
|
|
static size_t calculate_frames(int sample_rate_hz) {
|
2022-08-03 14:37:00 +02:00
|
|
|
return static_cast<size_t>(AudioProcessing::GetFrameSize(sample_rate_hz));
|
2015-07-23 11:41:39 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int sample_rate_hz_;
|
Convert channel counts to size_t.
IIRC, this was originally requested by ajm during review of the other size_t conversions I did over the past year, and I agreed it made sense, but wanted to do it separately since those changes were already gargantuan.
BUG=chromium:81439
TEST=none
R=henrik.lundin@webrtc.org, henrika@webrtc.org, kjellander@webrtc.org, minyue@webrtc.org, perkj@webrtc.org, solenberg@webrtc.org, stefan@webrtc.org, tina.legrand@webrtc.org
Review URL: https://codereview.webrtc.org/1316523002 .
Cr-Commit-Position: refs/heads/master@{#11229}
2016-01-12 16:26:35 -08:00
|
|
|
size_t num_channels_;
|
Update a ton of audio code to use size_t more correctly and in general reduce
use of int16_t/uint16_t.
This is the upshot of a recommendation by henrik.lundin and kwiberg on an original small change ( https://webrtc-codereview.appspot.com/42569004/#ps1 ) to stop using int16_t just because values could fit in it, and is similar in nature to a previous "mass change to use size_t more" ( https://webrtc-codereview.appspot.com/23129004/ ) which also needed to be split up for review but to land all at once, since, like adding "const", such changes tend to cause a lot of transitive effects.
This was be reviewed and approved in pieces:
https://codereview.webrtc.org/1224093003
https://codereview.webrtc.org/1224123002
https://codereview.webrtc.org/1224163002
https://codereview.webrtc.org/1225133003
https://codereview.webrtc.org/1225173002
https://codereview.webrtc.org/1227163003
https://codereview.webrtc.org/1227203003
https://codereview.webrtc.org/1227213002
https://codereview.webrtc.org/1227893002
https://codereview.webrtc.org/1228793004
https://codereview.webrtc.org/1228803003
https://codereview.webrtc.org/1228823002
https://codereview.webrtc.org/1228823003
https://codereview.webrtc.org/1228843002
https://codereview.webrtc.org/1230693002
https://codereview.webrtc.org/1231713002
The change is being landed as TBR to all the folks who reviewed the above.
BUG=chromium:81439
TEST=none
R=andrew@webrtc.org, pbos@webrtc.org
TBR=aluebs, andrew, asapersson, henrika, hlundin, jan.skoglund, kwiberg, minyue, pbos, pthatcher
Review URL: https://codereview.webrtc.org/1230503003 .
Cr-Commit-Position: refs/heads/master@{#9768}
2015-08-24 14:52:23 -07:00
|
|
|
size_t num_frames_;
|
2015-07-23 11:41:39 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class ProcessingConfig {
|
|
|
|
|
public:
|
|
|
|
|
enum StreamName {
|
|
|
|
|
kInputStream,
|
|
|
|
|
kOutputStream,
|
2015-08-14 10:35:55 -07:00
|
|
|
kReverseInputStream,
|
|
|
|
|
kReverseOutputStream,
|
2015-07-23 11:41:39 -07:00
|
|
|
kNumStreamNames,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const StreamConfig& input_stream() const {
|
|
|
|
|
return streams[StreamName::kInputStream];
|
|
|
|
|
}
|
|
|
|
|
const StreamConfig& output_stream() const {
|
|
|
|
|
return streams[StreamName::kOutputStream];
|
|
|
|
|
}
|
2015-08-14 10:35:55 -07:00
|
|
|
const StreamConfig& reverse_input_stream() const {
|
|
|
|
|
return streams[StreamName::kReverseInputStream];
|
|
|
|
|
}
|
|
|
|
|
const StreamConfig& reverse_output_stream() const {
|
|
|
|
|
return streams[StreamName::kReverseOutputStream];
|
2015-07-23 11:41:39 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
StreamConfig& input_stream() { return streams[StreamName::kInputStream]; }
|
|
|
|
|
StreamConfig& output_stream() { return streams[StreamName::kOutputStream]; }
|
2015-08-14 10:35:55 -07:00
|
|
|
StreamConfig& reverse_input_stream() {
|
|
|
|
|
return streams[StreamName::kReverseInputStream];
|
|
|
|
|
}
|
|
|
|
|
StreamConfig& reverse_output_stream() {
|
|
|
|
|
return streams[StreamName::kReverseOutputStream];
|
|
|
|
|
}
|
2015-07-23 11:41:39 -07:00
|
|
|
|
|
|
|
|
bool operator==(const ProcessingConfig& other) const {
|
|
|
|
|
for (int i = 0; i < StreamName::kNumStreamNames; ++i) {
|
|
|
|
|
if (this->streams[i] != other.streams[i]) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool operator!=(const ProcessingConfig& other) const {
|
|
|
|
|
return !(*this == other);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
StreamConfig streams[StreamName::kNumStreamNames];
|
|
|
|
|
};
|
|
|
|
|
|
2018-08-29 10:37:09 +02:00
|
|
|
// Experimental interface for a custom analysis submodule.
|
|
|
|
|
class CustomAudioAnalyzer {
|
|
|
|
|
public:
|
|
|
|
|
// (Re-) Initializes the submodule.
|
|
|
|
|
virtual void Initialize(int sample_rate_hz, int num_channels) = 0;
|
|
|
|
|
// Analyzes the given capture or render signal.
|
|
|
|
|
virtual void Analyze(const AudioBuffer* audio) = 0;
|
|
|
|
|
// Returns a string representation of the module state.
|
|
|
|
|
virtual std::string ToString() const = 0;
|
|
|
|
|
|
|
|
|
|
virtual ~CustomAudioAnalyzer() {}
|
|
|
|
|
};
|
|
|
|
|
|
2017-12-18 16:02:40 +01:00
|
|
|
// Interface for a custom processing submodule.
|
|
|
|
|
class CustomProcessing {
|
2017-09-25 12:04:02 +02:00
|
|
|
public:
|
|
|
|
|
// (Re-)Initializes the submodule.
|
|
|
|
|
virtual void Initialize(int sample_rate_hz, int num_channels) = 0;
|
|
|
|
|
// Processes the given capture or render signal.
|
|
|
|
|
virtual void Process(AudioBuffer* audio) = 0;
|
|
|
|
|
// Returns a string representation of the module state.
|
|
|
|
|
virtual std::string ToString() const = 0;
|
2018-05-15 10:52:28 +02:00
|
|
|
// Handles RuntimeSettings. TODO(webrtc:9262): make pure virtual
|
|
|
|
|
// after updating dependencies.
|
|
|
|
|
virtual void SetRuntimeSetting(AudioProcessing::RuntimeSetting setting);
|
2017-09-25 12:04:02 +02:00
|
|
|
|
2017-12-18 16:02:40 +01:00
|
|
|
virtual ~CustomProcessing() {}
|
2017-09-25 12:04:02 +02:00
|
|
|
};
|
|
|
|
|
|
2018-01-11 16:08:54 +01:00
|
|
|
// Interface for an echo detector submodule.
|
2023-11-02 14:09:26 +00:00
|
|
|
class EchoDetector : public RefCountInterface {
|
2018-01-11 16:08:54 +01:00
|
|
|
public:
|
|
|
|
|
// (Re-)Initializes the submodule.
|
2018-03-14 17:13:48 +01:00
|
|
|
virtual void Initialize(int capture_sample_rate_hz,
|
|
|
|
|
int num_capture_channels,
|
|
|
|
|
int render_sample_rate_hz,
|
|
|
|
|
int num_render_channels) = 0;
|
2018-01-11 16:08:54 +01:00
|
|
|
|
2021-12-06 15:40:04 +01:00
|
|
|
// Analysis (not changing) of the first channel of the render signal.
|
2018-01-11 16:08:54 +01:00
|
|
|
virtual void AnalyzeRenderAudio(rtc::ArrayView<const float> render_audio) = 0;
|
|
|
|
|
|
|
|
|
|
// Analysis (not changing) of the capture signal.
|
|
|
|
|
virtual void AnalyzeCaptureAudio(
|
|
|
|
|
rtc::ArrayView<const float> capture_audio) = 0;
|
|
|
|
|
|
|
|
|
|
struct Metrics {
|
2020-04-29 14:34:48 +02:00
|
|
|
absl::optional<double> echo_likelihood;
|
|
|
|
|
absl::optional<double> echo_likelihood_recent_max;
|
2018-01-11 16:08:54 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// Collect current metrics from the echo detector.
|
|
|
|
|
virtual Metrics GetMetrics() const = 0;
|
|
|
|
|
};
|
|
|
|
|
|
2011-07-07 08:21:25 +00:00
|
|
|
} // namespace webrtc
|
|
|
|
|
|
2017-09-15 06:47:31 +02:00
|
|
|
#endif // MODULES_AUDIO_PROCESSING_INCLUDE_AUDIO_PROCESSING_H_
|