blob: 3ba68c8a31cd710193f9dd098b8d1a2e34ee5562 [file] [log] [blame]
Hsin-Yu Chaob6f63cd2018-03-17 16:52:35 +08001/* 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 Chao2583e8a2018-11-13 17:13:09 +08009#include <iniparser.h>
Hsin-Yu Chaob6f63cd2018-03-17 16:52:35 +080010#include <stdint.h>
11#include <stdio.h>
12
13#define WEBRTC_APM_API __attribute__((visibility("default")))
14
15/* Pointer to a webrtc::AudioProcessing instance. */
16typedef void* webrtc_apm;
17
Hsin-Yu Chaob3dfb0e2021-04-20 08:04:00 +000018/* Enables UMA metrics in webrtc APM.
19 * Args:
20 * prefix - String to append to existing histogram name.
21 */
22WEBRTC_APM_API void webrtc_apm_init_metrics(const char *prefix);
23
Per Åhgrenaa5a43f2021-03-30 08:29:43 +020024/* Creates a webrtc_apm for forward stream properties using optional enforcement
25 * of the effects that are specified in the config files. In CRAS use case it
Hsin-Yu Chaob6f63cd2018-03-17 16:52:35 +080026 * is usually created for input stream.
27 * Args:
Per Åhgrenaa5a43f2021-03-30 08:29:43 +020028 * num_channels - Number of channels of the forward stream.
29 * frame_rate - Frame rate used by forward stream.
30 * aec_config - Pointer to aec config.
31 * apm_config - Pointer to apm config.
32 * enforce_aec_on - When set to 1, enforces the aec to be activated
33 * regardless of settings in apm.ini
34 * enforce_ns_on - When set to 1, enforces the ns to be activated
35 * regardless of settings in apm.ini
36 * enforce_agc_on - When set to 1, enforces the agc to be activated
37 * regardless of settings in apm.ini
38 */
39WEBRTC_APM_API webrtc_apm webrtc_apm_create_with_enforced_effects(
40 unsigned int num_channels,
41 unsigned int frame_rate,
42 dictionary *aec_ini,
43 dictionary *apm_ini,
44 unsigned int enforce_aec_on,
45 unsigned int enforce_ns_on,
46 unsigned int enforce_agc_on);
47
48/* Deprecated: Should be removed.
49 * Creates a webrtc_apm for forward stream properties using the parameters in
50 * the configs. In CRAS use case it is usually created for input stream.
51 * Args:
52 * num_channels - Number of channels of the forward stream.
53 * frame_rate - Frame rate used by forward stream.
54 * aec_config - Pointer to aec config.
55 * apm_config - Pointer to apm config.
Hsin-Yu Chaob6f63cd2018-03-17 16:52:35 +080056 */
57WEBRTC_APM_API webrtc_apm webrtc_apm_create(
58 unsigned int num_channels,
59 unsigned int frame_rate,
Hsin-Yu Chao2583e8a2018-11-13 17:13:09 +080060 dictionary *aec_ini,
61 dictionary *apm_ini);
62
63/* Dumps configs content.
64 * Args:
65 * apm_ini - APM config file in ini format.
66 * aec_ini - AEC3 config file in ini format.
67 */
68WEBRTC_APM_API void webrtc_apm_dump_configs(
69 dictionary *apm_ini,
70 dictionary *aec_ini);
Hsin-Yu Chaob6f63cd2018-03-17 16:52:35 +080071
72/* Destroys a webrtc_apm instance. */
73WEBRTC_APM_API void webrtc_apm_destroy(webrtc_apm apm);
74
Hsin-Yu Chaob6f63cd2018-03-17 16:52:35 +080075/* Processes deinterleaved float data in reverse stream. Expecting data
76 * size be 10 ms equivalent of frames. */
77WEBRTC_APM_API int webrtc_apm_process_reverse_stream_f(
78 webrtc_apm ptr,
79 int num_channels, int rate,
80 float *const *data);
81
Hsin-Yu Chaob6f63cd2018-03-17 16:52:35 +080082/* Processes deinterleaved float data in forward stream. Expecting data
83 * size be 10 ms equivalent of frames. */
84WEBRTC_APM_API int webrtc_apm_process_stream_f(webrtc_apm ptr,
85 int num_channels,
86 int rate,
87 float *const *data);
88
89/* Sets the delay in ms between apm analyzes a frame in reverse stream
90 * (playback) and this frame received as echo in forward stream (record)
91 * This is required for echo cancellation enabled apm.
92 * Args:
93 * ptr - Pointer to the webrtc_apm instance.
94 * delay_ms - The delay in ms.
95 */
96WEBRTC_APM_API int webrtc_apm_set_stream_delay(webrtc_apm ptr, int delay_ms);
97
Hsin-Yu Chaob6f63cd2018-03-17 16:52:35 +080098/* Dump aec debug info to a file.
99 * Args:
100 * ptr - Pointer to the webrtc_apm instance.
101 * work_queue - Pointer holding or to hold the allocated task queue for
102 * aec dump. Will be deleted when aec dump stops.
103 * start - True to start dumping, false to stop.
104 * handle - Pointer of the file storing aec dump.
105 */
106WEBRTC_APM_API int webrtc_apm_aec_dump(
107 webrtc_apm ptr, void** work_queue,
108 int start, FILE *handle);
109
110#endif /* WEBRTC_APM_H_ */