| /* Copyright (c) 2018 The Chromium Authors. All rights reserved. |
| * Use of this source code is governed by a BSD-style license that can be |
| * found in the LICENSE file. |
| */ |
| |
| #ifndef WEBRTC_APM_H_ |
| #define WEBRTC_APM_H_ |
| |
| #include <iniparser.h> |
| #include <stdint.h> |
| #include <stdio.h> |
| |
| #define WEBRTC_APM_API __attribute__((visibility("default"))) |
| |
| /* Pointer to a webrtc::AudioProcessing instance. */ |
| typedef void* webrtc_apm; |
| |
| /* Enables UMA metrics in webrtc APM. |
| * Args: |
| * prefix - String to append to existing histogram name. |
| */ |
| WEBRTC_APM_API void webrtc_apm_init_metrics(const char *prefix); |
| |
| /* Creates a webrtc_apm for forward stream properties using optional enforcement |
| * of the effects that are specified in the config files. In CRAS use case it |
| * is usually created for input stream. |
| * Args: |
| * num_channels - Number of channels of the forward stream. |
| * frame_rate - Frame rate used by forward stream. |
| * aec_config - Pointer to aec config. |
| * apm_config - Pointer to apm config. |
| * enforce_aec_on - When set to 1, enforces the aec to be activated |
| * regardless of settings in apm.ini |
| * enforce_ns_on - When set to 1, enforces the ns to be activated |
| * regardless of settings in apm.ini |
| * enforce_agc_on - When set to 1, enforces the agc to be activated |
| * regardless of settings in apm.ini |
| */ |
| WEBRTC_APM_API webrtc_apm webrtc_apm_create_with_enforced_effects( |
| unsigned int num_channels, |
| unsigned int frame_rate, |
| dictionary *aec_ini, |
| dictionary *apm_ini, |
| unsigned int enforce_aec_on, |
| unsigned int enforce_ns_on, |
| unsigned int enforce_agc_on); |
| |
| /* Deprecated: Should be removed. |
| * Creates a webrtc_apm for forward stream properties using the parameters in |
| * the configs. In CRAS use case it is usually created for input stream. |
| * Args: |
| * num_channels - Number of channels of the forward stream. |
| * frame_rate - Frame rate used by forward stream. |
| * aec_config - Pointer to aec config. |
| * apm_config - Pointer to apm config. |
| */ |
| WEBRTC_APM_API webrtc_apm webrtc_apm_create( |
| unsigned int num_channels, |
| unsigned int frame_rate, |
| dictionary *aec_ini, |
| dictionary *apm_ini); |
| |
| /* Dumps configs content. |
| * Args: |
| * apm_ini - APM config file in ini format. |
| * aec_ini - AEC3 config file in ini format. |
| */ |
| WEBRTC_APM_API void webrtc_apm_dump_configs( |
| dictionary *apm_ini, |
| dictionary *aec_ini); |
| |
| /* Destroys a webrtc_apm instance. */ |
| WEBRTC_APM_API void webrtc_apm_destroy(webrtc_apm apm); |
| |
| /* Processes deinterleaved float data in reverse stream. Expecting data |
| * size be 10 ms equivalent of frames. */ |
| WEBRTC_APM_API int webrtc_apm_process_reverse_stream_f( |
| webrtc_apm ptr, |
| int num_channels, int rate, |
| float *const *data); |
| |
| /* Processes deinterleaved float data in forward stream. Expecting data |
| * size be 10 ms equivalent of frames. */ |
| WEBRTC_APM_API int webrtc_apm_process_stream_f(webrtc_apm ptr, |
| int num_channels, |
| int rate, |
| float *const *data); |
| |
| /* Sets the delay in ms between apm analyzes a frame in reverse stream |
| * (playback) and this frame received as echo in forward stream (record) |
| * This is required for echo cancellation enabled apm. |
| * Args: |
| * ptr - Pointer to the webrtc_apm instance. |
| * delay_ms - The delay in ms. |
| */ |
| WEBRTC_APM_API int webrtc_apm_set_stream_delay(webrtc_apm ptr, int delay_ms); |
| |
| /* Dump aec debug info to a file. |
| * Args: |
| * ptr - Pointer to the webrtc_apm instance. |
| * work_queue - Pointer holding or to hold the allocated task queue for |
| * aec dump. Will be deleted when aec dump stops. |
| * start - True to start dumping, false to stop. |
| * handle - Pointer of the file storing aec dump. |
| */ |
| WEBRTC_APM_API int webrtc_apm_aec_dump( |
| webrtc_apm ptr, void** work_queue, |
| int start, FILE *handle); |
| |
| #endif /* WEBRTC_APM_H_ */ |