Hsin-Yu Chao | b6f63cd | 2018-03-17 16:52:35 +0800 | [diff] [blame] | 1 | /* Copyright (c) 2018 The Chromium Authors. All rights reserved. |
| 2 | * Use of this source code is governed by a BSD-style license that can be |
| 3 | * found in the LICENSE file. |
| 4 | */ |
| 5 | |
| 6 | #ifndef WEBRTC_APM_H_ |
| 7 | #define WEBRTC_APM_H_ |
| 8 | |
Hsin-Yu Chao | 2583e8a | 2018-11-13 17:13:09 +0800 | [diff] [blame] | 9 | #include <iniparser.h> |
Hsin-Yu Chao | b6f63cd | 2018-03-17 16:52:35 +0800 | [diff] [blame] | 10 | #include <stdint.h> |
| 11 | #include <stdio.h> |
| 12 | |
| 13 | #define WEBRTC_APM_API __attribute__((visibility("default"))) |
| 14 | |
| 15 | /* Pointer to a webrtc::AudioProcessing instance. */ |
| 16 | typedef void* webrtc_apm; |
| 17 | |
Per Åhgren | aa5a43f | 2021-03-30 08:29:43 +0200 | [diff] [blame] | 18 | /* Creates a webrtc_apm for forward stream properties using optional enforcement |
| 19 | * of the effects that are specified in the config files. In CRAS use case it |
Hsin-Yu Chao | b6f63cd | 2018-03-17 16:52:35 +0800 | [diff] [blame] | 20 | * is usually created for input stream. |
| 21 | * Args: |
Per Åhgren | aa5a43f | 2021-03-30 08:29:43 +0200 | [diff] [blame] | 22 | * num_channels - Number of channels of the forward stream. |
| 23 | * frame_rate - Frame rate used by forward stream. |
| 24 | * aec_config - Pointer to aec config. |
| 25 | * apm_config - Pointer to apm config. |
| 26 | * enforce_aec_on - When set to 1, enforces the aec to be activated |
| 27 | * regardless of settings in apm.ini |
| 28 | * enforce_ns_on - When set to 1, enforces the ns to be activated |
| 29 | * regardless of settings in apm.ini |
| 30 | * enforce_agc_on - When set to 1, enforces the agc to be activated |
| 31 | * regardless of settings in apm.ini |
| 32 | */ |
| 33 | WEBRTC_APM_API webrtc_apm webrtc_apm_create_with_enforced_effects( |
| 34 | unsigned int num_channels, |
| 35 | unsigned int frame_rate, |
| 36 | dictionary *aec_ini, |
| 37 | dictionary *apm_ini, |
| 38 | unsigned int enforce_aec_on, |
| 39 | unsigned int enforce_ns_on, |
| 40 | unsigned int enforce_agc_on); |
| 41 | |
| 42 | /* Deprecated: Should be removed. |
| 43 | * Creates a webrtc_apm for forward stream properties using the parameters in |
| 44 | * the configs. In CRAS use case it is usually created for input stream. |
| 45 | * Args: |
| 46 | * num_channels - Number of channels of the forward stream. |
| 47 | * frame_rate - Frame rate used by forward stream. |
| 48 | * aec_config - Pointer to aec config. |
| 49 | * apm_config - Pointer to apm config. |
Hsin-Yu Chao | b6f63cd | 2018-03-17 16:52:35 +0800 | [diff] [blame] | 50 | */ |
| 51 | WEBRTC_APM_API webrtc_apm webrtc_apm_create( |
| 52 | unsigned int num_channels, |
| 53 | unsigned int frame_rate, |
Hsin-Yu Chao | 2583e8a | 2018-11-13 17:13:09 +0800 | [diff] [blame] | 54 | dictionary *aec_ini, |
| 55 | dictionary *apm_ini); |
| 56 | |
| 57 | /* Dumps configs content. |
| 58 | * Args: |
| 59 | * apm_ini - APM config file in ini format. |
| 60 | * aec_ini - AEC3 config file in ini format. |
| 61 | */ |
| 62 | WEBRTC_APM_API void webrtc_apm_dump_configs( |
| 63 | dictionary *apm_ini, |
| 64 | dictionary *aec_ini); |
Hsin-Yu Chao | b6f63cd | 2018-03-17 16:52:35 +0800 | [diff] [blame] | 65 | |
| 66 | /* Destroys a webrtc_apm instance. */ |
| 67 | WEBRTC_APM_API void webrtc_apm_destroy(webrtc_apm apm); |
| 68 | |
Hsin-Yu Chao | b6f63cd | 2018-03-17 16:52:35 +0800 | [diff] [blame] | 69 | /* Processes deinterleaved float data in reverse stream. Expecting data |
| 70 | * size be 10 ms equivalent of frames. */ |
| 71 | WEBRTC_APM_API int webrtc_apm_process_reverse_stream_f( |
| 72 | webrtc_apm ptr, |
| 73 | int num_channels, int rate, |
| 74 | float *const *data); |
| 75 | |
Hsin-Yu Chao | b6f63cd | 2018-03-17 16:52:35 +0800 | [diff] [blame] | 76 | /* Processes deinterleaved float data in forward stream. Expecting data |
| 77 | * size be 10 ms equivalent of frames. */ |
| 78 | WEBRTC_APM_API int webrtc_apm_process_stream_f(webrtc_apm ptr, |
| 79 | int num_channels, |
| 80 | int rate, |
| 81 | float *const *data); |
| 82 | |
| 83 | /* Sets the delay in ms between apm analyzes a frame in reverse stream |
| 84 | * (playback) and this frame received as echo in forward stream (record) |
| 85 | * This is required for echo cancellation enabled apm. |
| 86 | * Args: |
| 87 | * ptr - Pointer to the webrtc_apm instance. |
| 88 | * delay_ms - The delay in ms. |
| 89 | */ |
| 90 | WEBRTC_APM_API int webrtc_apm_set_stream_delay(webrtc_apm ptr, int delay_ms); |
| 91 | |
Hsin-Yu Chao | b6f63cd | 2018-03-17 16:52:35 +0800 | [diff] [blame] | 92 | /* Dump aec debug info to a file. |
| 93 | * Args: |
| 94 | * ptr - Pointer to the webrtc_apm instance. |
| 95 | * work_queue - Pointer holding or to hold the allocated task queue for |
| 96 | * aec dump. Will be deleted when aec dump stops. |
| 97 | * start - True to start dumping, false to stop. |
| 98 | * handle - Pointer of the file storing aec dump. |
| 99 | */ |
| 100 | WEBRTC_APM_API int webrtc_apm_aec_dump( |
| 101 | webrtc_apm ptr, void** work_queue, |
| 102 | int start, FILE *handle); |
| 103 | |
| 104 | #endif /* WEBRTC_APM_H_ */ |