-split off microphone/speaker APIs
[oweals/gnunet.git] / src / include / gnunet_microphone_lib.h
1 /*
2   This file is part of GNUnet
3   (C) 2013 Christian Grothoff (and other contributing authors)
4   
5   GNUnet is free software; you can redistribute it and/or modify
6   it under the terms of the GNU General Public License as published
7   by the Free Software Foundation; either version 3, or (at your
8   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   General Public License for more details.
14   
15   You should have received a copy of the GNU General Public License
16   along with GNUnet; see the file COPYING.  If not, write to the
17   Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18   Boston, MA 02111-1307, USA.
19  */
20
21 /**
22  * @file include/gnunet_microphone_lib.h
23  * @brief API to access an audio microphone; provides access to hardware microphones
24  * @author Simon Dieterle
25  * @author Andreas Fuchs
26  * @author Christian Grothoff
27  */
28 #ifndef GNUNET_MICROPHONE_SERVICE_H
29 #define GNUNET_MICROPHONE_SERVICE_H
30
31 #ifdef __cplusplus
32 extern "C"
33 {
34 #if 0                           /* keep Emacsens' auto-indent happy */
35 }
36 #endif
37 #endif
38
39 /**
40  * Process recorded audio data.
41  *
42  * @param cls clsoure
43  * @param data_size number of bytes in @a data
44  * @param data audio data to play
45  */
46 typedef void (*GNUNET_MICROPHONE_RecordedDataCallback)(void *cls,
47                                                        size_t data_size,
48                                                        const void *data);
49
50 /**
51  * Enable a microphone.
52  *
53  * @param cls clsoure
54  * @param rdc function to call with recorded data
55  * @param rdc_cls closure for @a dc
56  */
57 typedef void (*GNUNET_MICROPHONE_EnableCallback)(void *cls,
58                                                  GNUNET_MICROPHONE_RecordedDataCallback rdc,
59                                                  void *rdc_cls);
60
61 /**
62  * Function that disables a microphone.
63  *
64  * @param cls clsoure
65  */
66 typedef void (*GNUNET_MICROPHONE_DisableCallback)(void *cls);
67
68 /**
69  * Function to destroy a microphone.
70  *
71  * @param cls clsoure
72  */
73 typedef void (*GNUNET_MICROPHONE_DestroyCallback)(void *cls);
74
75
76 /**
77  * A microphone is a device that can play or record audio data.
78  */
79 struct GNUNET_MICROPHONE_Handle
80 {
81
82   /**
83    * Turn on the microphone.
84    */
85   GNUNET_MICROPHONE_EnableCallback enable_microphone;
86
87   /**
88    * Turn the microphone off.
89    */
90   GNUNET_MICROPHONE_DisableCallback disable_microphone;
91
92   /**
93    * Destroy the microphone.  Called by #GNUNET_MICROPHONE_destroy.
94    */
95   GNUNET_MICROPHONE_DestroyCallback destroy_microphone;
96
97   /**
98    * Closure for the callbacks.
99    */
100   void *cls;
101
102 };
103
104
105 /**
106  * Create a microphone that corresponds to the microphone hardware
107  * of our system.
108  *
109  * @param cfg configuration to use
110  * @return NULL on error
111  */
112 struct GNUNET_MICROPHONE_Handle *
113 GNUNET_MICROPHONE_create_from_hardware (const struct GNUNET_CONFIGURATION_Handle *cfg);
114
115
116 /**
117  * Destroy a microphone.
118  *
119  * @param microphone microphone to destroy
120  */
121 void
122 GNUNET_MICROPHONE_destroy (struct GNUNET_MICROPHONE_Handle *microphone);
123
124
125 #if 0                           /* keep Emacsens' auto-indent happy */
126 {
127 #endif
128 #ifdef __cplusplus
129 }
130 #endif
131
132 #endif
133 /* end of gnunet_microphone_lib.h */