2021-12-21 18:55:07 +08:00
|
|
|
// SPDX-License-Identifier: BSD-3-Clause
|
|
|
|
//
|
|
|
|
// Copyright(c) 2021 Google LLC.
|
|
|
|
//
|
|
|
|
// Author: Lionel Koenig <lionelk@google.com>
|
|
|
|
#ifndef GOOGLE_RTC_AUDIO_PROCESSING_H
|
|
|
|
#define GOOGLE_RTC_AUDIO_PROCESSING_H
|
|
|
|
|
|
|
|
#include <stdint.h>
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// This define ensure that the linked library matches the header file.
|
2022-12-07 06:29:50 +08:00
|
|
|
// LINT.IfChange(api_version)
|
2021-12-21 18:55:07 +08:00
|
|
|
#define GoogleRtcAudioProcessingCreate GoogleRtcAudioProcessingCreate_v1
|
2022-12-07 06:29:50 +08:00
|
|
|
// LINT.ThenChange()
|
2021-12-21 18:55:07 +08:00
|
|
|
|
|
|
|
typedef struct GoogleRtcAudioProcessingState GoogleRtcAudioProcessingState;
|
|
|
|
|
2022-12-07 06:29:50 +08:00
|
|
|
// LINT.IfChange()
|
|
|
|
|
|
|
|
// Attaches `buffer` to use for memory allocations. The ownership of `buffer`
|
|
|
|
// remains within the caller.
|
|
|
|
void GoogleRtcAudioProcessingAttachMemoryBuffer(uint8_t *const buffer,
|
|
|
|
int buffer_size);
|
|
|
|
|
|
|
|
// Detaches any attached memory buffer used for memory allocations. Returns 0 if
|
|
|
|
// success and non zero if failure.
|
|
|
|
void GoogleRtcAudioProcessingDetachMemoryBuffer(void);
|
|
|
|
|
2021-12-21 18:55:07 +08:00
|
|
|
// Creates an instance of GoogleRtcAudioProcessing with the tuning embedded in
|
2022-12-07 06:29:50 +08:00
|
|
|
// the library. If creation fails, NULL is returned.
|
2021-12-21 18:55:07 +08:00
|
|
|
GoogleRtcAudioProcessingState *GoogleRtcAudioProcessingCreate(void);
|
|
|
|
|
2022-12-07 06:29:50 +08:00
|
|
|
// Creates an instance of GoogleRtcAudioProcessing based on `config` and stream
|
|
|
|
// formats, where the content of config overrides any embedded parameters and
|
|
|
|
// the stream formats overrides any content in the config. Setting `config` to
|
|
|
|
// NULL means that no config is specified. If creation fails, NULL is returned.
|
|
|
|
GoogleRtcAudioProcessingState *GoogleRtcAudioProcessingCreateWithConfig(
|
|
|
|
int capture_sample_rate_hz, int num_capture_input_channels,
|
|
|
|
int num_capture_output_channels, int render_sample_rate_hz,
|
|
|
|
int num_render_channels, const uint8_t *const config, int config_size);
|
|
|
|
|
2021-12-21 18:55:07 +08:00
|
|
|
// Frees all allocated resources in `state`.
|
|
|
|
void GoogleRtcAudioProcessingFree(GoogleRtcAudioProcessingState *state);
|
|
|
|
|
2022-12-07 06:29:50 +08:00
|
|
|
// Specifies the stream formats to use. Returns 0 if success and non zero if
|
|
|
|
// failure.
|
|
|
|
int GoogleRtcAudioProcessingSetStreamFormats(
|
|
|
|
GoogleRtcAudioProcessingState *const state, int capture_sample_rate_hz,
|
|
|
|
int num_capture_input_channels, int num_capture_output_channels,
|
|
|
|
int render_sample_rate_hz, int num_render_channels);
|
|
|
|
|
|
|
|
// Specifies setup-specific parameters. Returns 0 if success and non zero if
|
|
|
|
// failure. Parameters which are NULL are ignored.
|
|
|
|
int GoogleRtcAudioProcessingParameters(
|
|
|
|
GoogleRtcAudioProcessingState *const state, float *capture_headroom_linear,
|
|
|
|
float *echo_path_delay_ms);
|
|
|
|
|
2021-12-21 18:55:07 +08:00
|
|
|
// Returns the framesize used for processing.
|
|
|
|
int GoogleRtcAudioProcessingGetFramesizeInMs(
|
2022-03-08 22:18:13 +08:00
|
|
|
GoogleRtcAudioProcessingState *const state);
|
|
|
|
|
|
|
|
// Reconfigure the audio processing.
|
|
|
|
// Returns 0 if success and non zero if failure.
|
|
|
|
int GoogleRtcAudioProcessingReconfigure(
|
|
|
|
GoogleRtcAudioProcessingState *const state, const uint8_t *const config,
|
|
|
|
int config_size);
|
2021-12-21 18:55:07 +08:00
|
|
|
|
|
|
|
// Processes the microphone stream.
|
|
|
|
// Accepts deinterleaved float audio with the range [-1, 1]. Each element of
|
|
|
|
// |src| points to an array of samples for the channel. At output, the channels
|
|
|
|
// will be in |dest|.
|
|
|
|
// Returns 0 if success and non zero if failure.
|
|
|
|
int GoogleRtcAudioProcessingProcessCapture_float32(
|
2022-03-08 22:18:13 +08:00
|
|
|
GoogleRtcAudioProcessingState *const state, const float *const *src,
|
|
|
|
float *const *dest);
|
2021-12-21 18:55:07 +08:00
|
|
|
|
|
|
|
// Accepts and and produces a frame of interleaved 16 bit integer audio. `src`
|
|
|
|
// and `dest` may use the same memory, if desired.
|
|
|
|
// Returns 0 if success and non zero if failure.
|
|
|
|
int GoogleRtcAudioProcessingProcessCapture_int16(
|
2022-03-08 22:18:13 +08:00
|
|
|
GoogleRtcAudioProcessingState *const state, const int16_t *const src,
|
|
|
|
int16_t *const dest);
|
2021-12-21 18:55:07 +08:00
|
|
|
|
|
|
|
// Analyzes the playback stream.
|
|
|
|
// Accepts deinterleaved float audio with the range [-1, 1]. Each element
|
|
|
|
// of |src| points to an array of samples for the channel.
|
|
|
|
// Returns 0 if success and non zero if failure.
|
|
|
|
int GoogleRtcAudioProcessingAnalyzeRender_float32(
|
2022-03-08 22:18:13 +08:00
|
|
|
GoogleRtcAudioProcessingState *const state, const float *const *src);
|
2021-12-21 18:55:07 +08:00
|
|
|
|
|
|
|
// Accepts interleaved int16 audio.
|
|
|
|
// Returns 0 if success and non zero if failure.
|
|
|
|
int GoogleRtcAudioProcessingAnalyzeRender_int16(
|
2022-03-08 22:18:13 +08:00
|
|
|
GoogleRtcAudioProcessingState *const state, const int16_t *const src);
|
2021-12-21 18:55:07 +08:00
|
|
|
|
2022-12-07 06:29:50 +08:00
|
|
|
// LINT.ThenChange(:api_version)
|
|
|
|
|
2021-12-21 18:55:07 +08:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2022-12-07 06:29:50 +08:00
|
|
|
#endif // GOOGLE_RTC_AUDIO_PROCESSING_H
|