]> code.delx.au - pulseaudio/blob - src/modules/echo-cancel/echo-cancel.h
echo-cancel: Add the WebRTC echo canceller
[pulseaudio] / src / modules / echo-cancel / echo-cancel.h
1 /***
2 This file is part of PulseAudio.
3
4 Copyright 2010 Arun Raghavan <arun.raghavan@collabora.co.uk>
5
6 PulseAudio is free software; you can redistribute it and/or modify
7 it under the terms of the GNU Lesser General Public License as published
8 by the Free Software Foundation; either version 2.1 of the License,
9 or (at your option) any later version.
10
11 PulseAudio is distributed in the hope that it will be useful, but
12 WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 General Public License for more details.
15
16 You should have received a copy of the GNU Lesser General Public License
17 along with PulseAudio; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
19 USA.
20 ***/
21
22 #ifndef fooechocancelhfoo
23 #define fooechocancelhfoo
24
25 #ifdef HAVE_CONFIG_H
26 #include <config.h>
27 #endif
28
29 #include <pulse/sample.h>
30 #include <pulse/channelmap.h>
31 #include <pulsecore/core.h>
32 #include <pulsecore/macro.h>
33
34 #include <speex/speex_echo.h>
35 #include <speex/speex_preprocess.h>
36 #include "adrian.h"
37
38 /* Common data structures */
39
40 typedef struct pa_echo_canceller_params pa_echo_canceller_params;
41
42 struct pa_echo_canceller_params {
43 union {
44 struct {
45 SpeexEchoState *state;
46 SpeexPreprocessState *pp_state;
47 } speex;
48 struct {
49 uint32_t blocksize;
50 AEC *aec;
51 } adrian;
52 #ifdef HAVE_WEBRTC
53 struct {
54 /* This is a void* so that we don't have to convert this whole file
55 * to C++ linkage. apm is a pointer to an AudioProcessing object */
56 void *apm;
57 uint32_t blocksize;
58 pa_sample_spec sample_spec;
59 } webrtc;
60 #endif
61 /* each canceller-specific structure goes here */
62 } priv;
63 };
64
65 typedef struct pa_echo_canceller pa_echo_canceller;
66
67 struct pa_echo_canceller {
68 pa_bool_t (*init) (pa_core *c,
69 pa_echo_canceller *ec,
70 pa_sample_spec *source_ss,
71 pa_channel_map *source_map,
72 pa_sample_spec *sink_ss,
73 pa_channel_map *sink_map,
74 uint32_t *blocksize,
75 const char *args);
76 void (*run) (pa_echo_canceller *ec, const uint8_t *rec, const uint8_t *play, uint8_t *out);
77 void (*done) (pa_echo_canceller *ec);
78
79 pa_echo_canceller_params params;
80 };
81
82 /* Speex canceller functions */
83 pa_bool_t pa_speex_ec_init(pa_core *c, pa_echo_canceller *ec,
84 pa_sample_spec *source_ss, pa_channel_map *source_map,
85 pa_sample_spec *sink_ss, pa_channel_map *sink_map,
86 uint32_t *blocksize, const char *args);
87 void pa_speex_ec_run(pa_echo_canceller *ec, const uint8_t *rec, const uint8_t *play, uint8_t *out);
88 void pa_speex_ec_done(pa_echo_canceller *ec);
89
90 /* Adrian Andre's echo canceller */
91 pa_bool_t pa_adrian_ec_init(pa_core *c, pa_echo_canceller *ec,
92 pa_sample_spec *source_ss, pa_channel_map *source_map,
93 pa_sample_spec *sink_ss, pa_channel_map *sink_map,
94 uint32_t *blocksize, const char *args);
95 void pa_adrian_ec_run(pa_echo_canceller *ec, const uint8_t *rec, const uint8_t *play, uint8_t *out);
96 void pa_adrian_ec_done(pa_echo_canceller *ec);
97
98 #ifdef HAVE_WEBRTC
99 /* WebRTC canceller functions */
100 PA_C_DECL_BEGIN
101 pa_bool_t pa_webrtc_ec_init(pa_core *c, pa_echo_canceller *ec,
102 pa_sample_spec *source_ss, pa_channel_map *source_map,
103 pa_sample_spec *sink_ss, pa_channel_map *sink_map,
104 uint32_t *blocksize, const char *args);
105 void pa_webrtc_ec_run(pa_echo_canceller *ec, const uint8_t *rec, const uint8_t *play, uint8_t *out);
106 void pa_webrtc_ec_done(pa_echo_canceller *ec);
107 PA_C_DECL_END
108 #endif
109
110 #endif /* fooechocancelhfoo */