PipeWire  0.3.61
aec.h
1 /* PipeWire
2  *
3  * Copyright © 2021 Wim Taymans <wim.taymans@gmail.com>
4  *
5  * Permission is hereby granted, free of charge, to any person obtaining a
6  * copy of this software and associated documentation files (the "Software"),
7  * to deal in the Software without restriction, including without limitation
8  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
9  * and/or sell copies of the Software, and to permit persons to whom the
10  * Software is furnished to do so, subject to the following conditions:
11  *
12  * The above copyright notice and this permission notice (including the next
13  * paragraph) shall be included in all copies or substantial portions of the
14  * Software.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22  * DEALINGS IN THE SOFTWARE.
23  */
24 
25 
26 #include <spa/pod/builder.h>
27 #include <spa/utils/dict.h>
28 #include <spa/utils/hook.h>
29 #include <spa/param/audio/raw.h>
30 
31 #ifndef SPA_AUDIO_AEC_H
32 #define SPA_AUDIO_AEC_H
33 
34 #ifdef __cplusplus
35 extern "C" {
36 #endif
37 
38 #define SPA_TYPE_INTERFACE_AUDIO_AEC SPA_TYPE_INFO_INTERFACE_BASE "Audio:AEC"
39 
40 #define SPA_VERSION_AUDIO_AEC 1
41 struct spa_audio_aec {
42  struct spa_interface iface;
43  const char *name;
44  const struct spa_dict *info;
45  const char *latency;
46 };
47 
48 struct spa_audio_aec_info {
49 #define SPA_AUDIO_AEC_CHANGE_MASK_PROPS (1u<<0)
50  uint64_t change_mask;
51 
52  const struct spa_dict *props;
53 };
54 
55 struct spa_audio_aec_events {
56 #define SPA_VERSION_AUDIO_AEC_EVENTS 0
57  uint32_t version;
60  void (*info) (void *data, const struct spa_audio_aec_info *info);
61 };
62 
63 struct spa_audio_aec_methods {
64 #define SPA_VERSION_AUDIO_AEC_METHODS 2
65  uint32_t version;
66 
67  int (*add_listener) (void *object,
68  struct spa_hook *listener,
69  const struct spa_audio_aec_events *events,
70  void *data);
71 
72  int (*init) (void *object, const struct spa_dict *args, const struct spa_audio_info_raw *info);
73  int (*run) (void *object, const float *rec[], const float *play[], float *out[], uint32_t n_samples);
74  int (*set_props) (void *object, const struct spa_dict *args);
75  /* since 0.3.58, version 1:1 */
76  int (*activate) (void *object);
77  /* since 0.3.58, version 1:1 */
78  int (*deactivate) (void *object);
79 
80  /* version 1:2 */
81  int (*enum_props) (void* object, int index, struct spa_pod_builder* builder);
82  int (*get_params) (void* object, struct spa_pod_builder* builder);
83  int (*set_params) (void *object, const struct spa_pod *args);
84 };
85 
86 #define spa_audio_aec_method(o,method,version,...) \
87 ({ \
88  int _res = -ENOTSUP; \
89  struct spa_audio_aec *_o = (o); \
90  spa_interface_call_res(&_o->iface, \
91  struct spa_audio_aec_methods, _res, \
92  method, (version), ##__VA_ARGS__); \
93  _res; \
94 })
95 
96 #define spa_audio_aec_add_listener(o,...) spa_audio_aec_method(o, add_listener, 0, __VA_ARGS__)
97 #define spa_audio_aec_init(o,...) spa_audio_aec_method(o, init, 0, __VA_ARGS__)
98 #define spa_audio_aec_run(o,...) spa_audio_aec_method(o, run, 0, __VA_ARGS__)
99 #define spa_audio_aec_set_props(o,...) spa_audio_aec_method(o, set_props, 0, __VA_ARGS__)
100 #define spa_audio_aec_activate(o) spa_audio_aec_method(o, activate, 1)
101 #define spa_audio_aec_deactivate(o) spa_audio_aec_method(o, deactivate, 1)
102 #define spa_audio_aec_enum_props(o,...) spa_audio_aec_method(o, enum_props, 2, __VA_ARGS__)
103 #define spa_audio_aec_get_params(o,...) spa_audio_aec_method(o, get_params, 2, __VA_ARGS__)
104 #define spa_audio_aec_set_params(o,...) spa_audio_aec_method(o, set_params, 2, __VA_ARGS__)
105 
106 #ifdef __cplusplus
107 } /* extern "C" */
108 #endif
109 
110 #endif /* SPA_AUDIO_AEC_H */
spa/param/audio/raw.h
spa/pod/builder.h
spa/utils/hook.h
Definition: aec.h:62
void(* info)(void *data, const struct spa_audio_aec_info *info)
Emitted when info changes.
Definition: aec.h:68
uint32_t version
version of this structure
Definition: aec.h:65
Definition: aec.h:54
uint64_t change_mask
Definition: aec.h:57
Definition: aec.h:71
int(* get_params)(void *object, struct spa_pod_builder *builder)
Definition: aec.h:91
int(* add_listener)(void *object, struct spa_hook *listener, const struct spa_audio_aec_events *events, void *data)
Definition: aec.h:76
int(* set_props)(void *object, const struct spa_dict *args)
Definition: aec.h:83
int(* deactivate)(void *object)
Definition: aec.h:87
int(* activate)(void *object)
Definition: aec.h:85
int(* enum_props)(void *object, int index, struct spa_pod_builder *builder)
Definition: aec.h:90
int(* run)(void *object, const float *rec[], const float *play[], float *out[], uint32_t n_samples)
Definition: aec.h:82
int(* set_params)(void *object, const struct spa_pod *args)
Definition: aec.h:92
int(* init)(void *object, const struct spa_dict *args, const struct spa_audio_info_raw *info)
Definition: aec.h:81
Definition: aec.h:47
const struct spa_dict * info
Definition: aec.h:50
const char * latency
Definition: aec.h:51
struct spa_interface iface
Definition: aec.h:48
Audio information description.
Definition: raw.h:298
Definition: dict.h:59
A hook, contains the structure with functions and the data passed to the functions.
Definition: hook.h:351
Definition: hook.h:158
Definition: builder.h:73
Definition: pod.h:63
spa/utils/dict.h