RECLAIM/OIDC: code cleanup
[oweals/gnunet.git] / src / include / gnunet_microphone_lib.h
1 /*
2   This file is part of GNUnet
3   Copyright (C) 2013 GNUnet e.V.
4
5   GNUnet is free software: you can redistribute it and/or modify it
6   under the terms of the GNU Affero General Public License as published
7   by the Free Software Foundation, either version 3 of the License,
8   or (at your option) any later version.
9
10   GNUnet is distributed in the hope that it will be useful, but
11   WITHOUT ANY WARRANTY; without even the implied warranty of
12   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13   Affero General Public License for more details.
14  
15   You should have received a copy of the GNU Affero General Public License
16   along with this program.  If not, see <http://www.gnu.org/licenses/>.
17
18      SPDX-License-Identifier: AGPL3.0-or-later
19  */
20
21 /**
22  * @author Simon Dieterle
23  * @author Andreas Fuchs
24  * @author Christian Grothoff
25  *
26  * @file
27  * API to access an audio microphone; provides access to hardware microphones
28  *
29  * @defgroup microphone  Microphone library
30  * Provides access to hardware microphones.
31  * @{
32  */
33 #ifndef GNUNET_MICROPHONE_SERVICE_H
34 #define GNUNET_MICROPHONE_SERVICE_H
35
36 #ifdef __cplusplus
37 extern "C"
38 {
39 #if 0                           /* keep Emacsens' auto-indent happy */
40 }
41 #endif
42 #endif
43
44 #include "gnunet_util_lib.h"
45
46 /**
47  * Process recorded audio data.
48  *
49  * @param cls clsoure
50  * @param data_size number of bytes in @a data
51  * @param data audio data to play
52  */
53 typedef void (*GNUNET_MICROPHONE_RecordedDataCallback)(void *cls,
54                                                        size_t data_size,
55                                                        const void *data);
56
57 /**
58  * Enable a microphone.
59  *
60  * @param cls clsoure
61  * @param rdc function to call with recorded data
62  * @param rdc_cls closure for @a dc
63  * @return #GNUNET_OK on success, #GNUNET_SYSERR on error
64  */
65 typedef int (*GNUNET_MICROPHONE_EnableCallback)(void *cls,
66                                                 GNUNET_MICROPHONE_RecordedDataCallback rdc,
67                                                 void *rdc_cls);
68
69 /**
70  * Function that disables a microphone.
71  *
72  * @param cls clsoure
73  */
74 typedef void (*GNUNET_MICROPHONE_DisableCallback)(void *cls);
75
76 /**
77  * Function to destroy a microphone.
78  *
79  * @param cls clsoure
80  */
81 typedef void (*GNUNET_MICROPHONE_DestroyCallback)(void *cls);
82
83
84 /**
85  * A microphone is a device that can capture or otherwise produce audio data.
86  */
87 struct GNUNET_MICROPHONE_Handle
88 {
89
90   /**
91    * Turn on the microphone.
92    */
93   GNUNET_MICROPHONE_EnableCallback enable_microphone;
94
95   /**
96    * Turn the microphone off.
97    */
98   GNUNET_MICROPHONE_DisableCallback disable_microphone;
99
100   /**
101    * Destroy the microphone.  Called by #GNUNET_MICROPHONE_destroy.
102    */
103   GNUNET_MICROPHONE_DestroyCallback destroy_microphone;
104
105   /**
106    * Closure for the callbacks.
107    */
108   void *cls;
109
110 };
111
112
113 /**
114  * Create a microphone that corresponds to the microphone hardware
115  * of our system.
116  *
117  * @param cfg configuration to use
118  * @return NULL on error
119  */
120 struct GNUNET_MICROPHONE_Handle *
121 GNUNET_MICROPHONE_create_from_hardware (const struct GNUNET_CONFIGURATION_Handle *cfg);
122
123
124 /**
125  * Destroy a microphone.
126  *
127  * @param microphone microphone to destroy
128  */
129 void
130 GNUNET_MICROPHONE_destroy (struct GNUNET_MICROPHONE_Handle *microphone);
131
132
133 #if 0                           /* keep Emacsens' auto-indent happy */
134 {
135 #endif
136 #ifdef __cplusplus
137 }
138 #endif
139
140 #endif
141
142 /** @} */  /* end of group */
143
144 /* end of gnunet_microphone_lib.h */