diff options
author | Christian Grothoff <christian@grothoff.org> | 2013-10-02 19:06:07 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2013-10-02 19:06:07 +0000 |
commit | ec9740ca2ca84525842e6743b45ceb9cb2a3ea95 (patch) | |
tree | 5382b500ec7e5e66197d697c40a69bf4b0cb890f /src | |
parent | 705d8a8c1efe6cd7f0d9a452e8bb89cd7923fe99 (diff) | |
download | gnunet-ec9740ca2ca84525842e6743b45ceb9cb2a3ea95.tar.gz gnunet-ec9740ca2ca84525842e6743b45ceb9cb2a3ea95.zip |
-split off microphone/speaker APIs
Diffstat (limited to 'src')
-rw-r--r-- | src/conversation/Makefile.am | 3 | ||||
-rw-r--r-- | src/conversation/conversation_api2.c | 251 | ||||
-rw-r--r-- | src/include/Makefile.am | 2 | ||||
-rw-r--r-- | src/include/gnunet_conversation_service.h | 67 | ||||
-rw-r--r-- | src/include/gnunet_microphone_lib.h | 133 | ||||
-rw-r--r-- | src/include/gnunet_speaker_lib.h | 135 |
6 files changed, 533 insertions, 58 deletions
diff --git a/src/conversation/Makefile.am b/src/conversation/Makefile.am index b5dc0d49b..895e1136e 100644 --- a/src/conversation/Makefile.am +++ b/src/conversation/Makefile.am | |||
@@ -21,7 +21,8 @@ pkgcfgdir= $(prefix)/share/gnunet/config.d/ | |||
21 | libexecdir= $(prefix)/lib/gnunet/libexec/ | 21 | libexecdir= $(prefix)/lib/gnunet/libexec/ |
22 | 22 | ||
23 | libgnunetconversation_la_SOURCES = \ | 23 | libgnunetconversation_la_SOURCES = \ |
24 | conversation_api.c | 24 | conversation_api.c \ |
25 | conversation_api2.c | ||
25 | libgnunetconversation_la_LIBADD = \ | 26 | libgnunetconversation_la_LIBADD = \ |
26 | -lgnunetutil -lgnunetnamestore -lgnunetgns | 27 | -lgnunetutil -lgnunetnamestore -lgnunetgns |
27 | libgnunetconversation_la_LDFLAGS = \ | 28 | libgnunetconversation_la_LDFLAGS = \ |
diff --git a/src/conversation/conversation_api2.c b/src/conversation/conversation_api2.c new file mode 100644 index 000000000..3c19828a4 --- /dev/null +++ b/src/conversation/conversation_api2.c | |||
@@ -0,0 +1,251 @@ | |||
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 conversation/conversation_api2.c | ||
23 | * @brief API to the conversation service | ||
24 | * @author Simon Dieterle | ||
25 | * @author Andreas Fuchs | ||
26 | * @author Christian Grothoff | ||
27 | */ | ||
28 | #include "platform.h" | ||
29 | #include "gnunet_conversation_service.h" | ||
30 | |||
31 | |||
32 | /** | ||
33 | * A phone record specifies which peer is hosting a given user and | ||
34 | * may also specify the phone line that is used (typically zero). | ||
35 | * The version is also right now always zero. | ||
36 | */ | ||
37 | struct PhoneRecord | ||
38 | { | ||
39 | |||
40 | /** | ||
41 | * Version of the phone record, for now always zero. We may | ||
42 | * use other versions for anonymously hosted phone lines in | ||
43 | * the future. | ||
44 | */ | ||
45 | uint32_t version GNUNET_PACKED; | ||
46 | |||
47 | /** | ||
48 | * Phone line to use at the peer. | ||
49 | */ | ||
50 | uint32_t line GNUNET_PACKED; | ||
51 | |||
52 | /** | ||
53 | * Identity of the peer hosting the phone service. | ||
54 | */ | ||
55 | struct GNUNET_PeerIdentity my_peer; | ||
56 | |||
57 | }; | ||
58 | |||
59 | |||
60 | |||
61 | /** | ||
62 | * A phone is a device that can ring to signal an incoming call and | ||
63 | * that you can pick up to answer the call and hang up to terminate | ||
64 | * the call. You can also hang up a ringing phone immediately | ||
65 | * (without picking it up) to stop it from ringing. Phones have | ||
66 | * caller ID. You can ask the phone for its record and make that | ||
67 | * record available (via GNS) to enable others to call you. | ||
68 | * Multiple phones maybe connected to the same line (the line is | ||
69 | * something rather internal to a phone and not obvious from it). | ||
70 | * You can only have one conversation per phone at any time. | ||
71 | */ | ||
72 | struct GNUNET_CONVERSATION_Phone | ||
73 | { | ||
74 | /** | ||
75 | * Our configuration. | ||
76 | */ | ||
77 | const struct GNUNET_CONFIGURATION_Handle *cfg; | ||
78 | |||
79 | /** | ||
80 | * Function to call for phone events. | ||
81 | */ | ||
82 | GNUNET_CONVERSATION_EventHandler event_handler; | ||
83 | |||
84 | /** | ||
85 | * Closure for @e event_handler | ||
86 | */ | ||
87 | void *event_handler_cls; | ||
88 | |||
89 | /** | ||
90 | * Speaker, or NULL if none is attached. | ||
91 | */ | ||
92 | struct GNUNET_CONVERSATION_Speaker *speaker; | ||
93 | |||
94 | /** | ||
95 | * Microphone, or NULL if none is attached. | ||
96 | */ | ||
97 | struct GNUNET_CONVERSATION_Microphone *mic; | ||
98 | |||
99 | /** | ||
100 | * This phone's record. | ||
101 | */ | ||
102 | struct PhoneRecord my_record; | ||
103 | |||
104 | }; | ||
105 | |||
106 | |||
107 | /** | ||
108 | * Create a new phone. | ||
109 | * | ||
110 | * @param cfg configuration for the phone; specifies the phone service and | ||
111 | * which line the phone is to be connected to | ||
112 | * @param event_handler how to notify the owner of the phone about events | ||
113 | * @param event_handler_cls closure for @a event_handler | ||
114 | */ | ||
115 | struct GNUNET_CONVERSATION_Phone * | ||
116 | GNUNET_CONVERSATION_phone_create (const struct GNUNET_CONFIGURATION_Handle *cfg, | ||
117 | GNUNET_CONVERSATION_EventHandler event_handler, | ||
118 | void *event_handler_cls) | ||
119 | { | ||
120 | return NULL; | ||
121 | } | ||
122 | |||
123 | |||
124 | /** | ||
125 | * Fill in a namestore record with the contact information | ||
126 | * for this phone. Note that the filled in "data" value | ||
127 | * is only valid until the phone is destroyed. | ||
128 | * | ||
129 | * @param phone phone to create a record for | ||
130 | * @param rd namestore record to fill in | ||
131 | */ | ||
132 | void | ||
133 | GNUNET_CONVERSATION_phone_get_record (struct GNUNET_CONVERSATION_Phone *phone, | ||
134 | struct GNUNET_NAMESTORE_RecordData *rd) | ||
135 | { | ||
136 | GNUNET_assert (0); | ||
137 | } | ||
138 | |||
139 | |||
140 | /** | ||
141 | * Picks up a (ringing) phone. This will connect the speaker | ||
142 | * to the microphone of the other party, and vice versa. | ||
143 | * | ||
144 | * @param phone phone to pick up | ||
145 | * @param metadata meta data to give to the other user about the pick up event | ||
146 | * @param speaker speaker to use | ||
147 | * @param mic microphone to use | ||
148 | */ | ||
149 | void | ||
150 | GNUNET_CONVERSTATION_phone_pick_up (struct GNUNET_CONVERSATION_Phone *phone, | ||
151 | const char *metadata, | ||
152 | struct GNUNET_SPEAKER_Handle *speaker, | ||
153 | struct GNUNET_MICROPHONE_Handle *mic) | ||
154 | { | ||
155 | GNUNET_assert (0); | ||
156 | } | ||
157 | |||
158 | |||
159 | /** | ||
160 | * Hang up up a (possibly ringing) phone. This will notify the other | ||
161 | * party that we are no longer interested in talking with them. | ||
162 | * | ||
163 | * @param phone phone to pick up | ||
164 | * @param reason text we give to the other party about why we terminated the conversation | ||
165 | */ | ||
166 | void | ||
167 | GNUNET_CONVERSTATION_phone_hang_up (struct GNUNET_CONVERSATION_Phone *phone, | ||
168 | const char *reason) | ||
169 | { | ||
170 | GNUNET_assert (0); | ||
171 | } | ||
172 | |||
173 | |||
174 | /** | ||
175 | * Destroys a phone. | ||
176 | * | ||
177 | * @param phone phone to destroy | ||
178 | */ | ||
179 | void | ||
180 | GNUNET_CONVERSATION_phone_destroy (struct GNUNET_CONVERSATION_Phone *phone) | ||
181 | { | ||
182 | GNUNET_assert (0); | ||
183 | } | ||
184 | |||
185 | |||
186 | /** | ||
187 | * Handle for an outgoing call. | ||
188 | */ | ||
189 | struct GNUNET_CONVERSATION_Call | ||
190 | { | ||
191 | |||
192 | const struct GNUNET_CONFIGURATION_Handle *cfg; | ||
193 | |||
194 | struct GNUNET_IDENTITY_Ego *caller_id; | ||
195 | |||
196 | char *callee; | ||
197 | |||
198 | struct GNUNET_CONVERSATION_Speaker *speaker; | ||
199 | |||
200 | struct GNUNET_CONVERSATION_Microphone *mic; | ||
201 | |||
202 | GNUNET_CONVERSATION_EventHandler event_handler; | ||
203 | |||
204 | void *event_handler_cls; | ||
205 | |||
206 | }; | ||
207 | |||
208 | |||
209 | /** | ||
210 | * Call the phone of another user. | ||
211 | * | ||
212 | * @param cfg configuration to use, specifies our phone service | ||
213 | * @param caller_id identity of the caller | ||
214 | * @param callee GNS name of the callee (used to locate the callee's record) | ||
215 | * @param speaker speaker to use (will be used automatically immediately once the | ||
216 | * #GNUNET_CONVERSATION_EC_READY event is generated); we will NOT generate | ||
217 | * a ring tone on the speaker | ||
218 | * @param mic microphone to use (will be used automatically immediately once the | ||
219 | * #GNUNET_CONVERSATION_EC_READY event is generated) | ||
220 | * @param event_handler how to notify the owner of the phone about events | ||
221 | * @param event_handler_cls closure for @a event_handler | ||
222 | */ | ||
223 | struct GNUNET_CONVERSATION_Call * | ||
224 | GNUNET_CONVERSATION_call_start (const struct GNUNET_CONFIGURATION_Handle *cfg, | ||
225 | struct GNUNET_IDENTITY_Ego *caller_id, | ||
226 | const char *callee, | ||
227 | struct GNUNET_SPEAKER_Handle *speaker, | ||
228 | struct GNUNET_MICROPHONE_Handle *mic, | ||
229 | GNUNET_CONVERSATION_EventHandler event_handler, | ||
230 | void *event_handler_cls) | ||
231 | { | ||
232 | GNUNET_assert (0); | ||
233 | } | ||
234 | |||
235 | |||
236 | /** | ||
237 | * Terminate a call. The call may be ringing or ready at this time. | ||
238 | * | ||
239 | * @param call call to terminate | ||
240 | * @param reason if the call was active (ringing or ready) this will be the | ||
241 | * reason given to the other user for why we hung up | ||
242 | */ | ||
243 | void | ||
244 | GNUNET_CONVERSATION_call_stop (const struct GNUNET_CONVERSATION_Call *call, | ||
245 | const char *reason) | ||
246 | { | ||
247 | GNUNET_assert (0); | ||
248 | } | ||
249 | |||
250 | |||
251 | /* end of conversation_api.c */ | ||
diff --git a/src/include/Makefile.am b/src/include/Makefile.am index 9a6594b41..fef95c5fe 100644 --- a/src/include/Makefile.am +++ b/src/include/Makefile.am | |||
@@ -54,6 +54,7 @@ gnunetinclude_HEADERS = \ | |||
54 | gnunet_load_lib.h \ | 54 | gnunet_load_lib.h \ |
55 | gnunet_lockmanager_service.h \ | 55 | gnunet_lockmanager_service.h \ |
56 | gnunet_mesh_service.h \ | 56 | gnunet_mesh_service.h \ |
57 | gnunet_microphone_lib.h \ | ||
57 | gnunet_mq_lib.h \ | 58 | gnunet_mq_lib.h \ |
58 | gnunet_mysql_lib.h \ | 59 | gnunet_mysql_lib.h \ |
59 | gnunet_namestore_plugin.h \ | 60 | gnunet_namestore_plugin.h \ |
@@ -77,6 +78,7 @@ gnunetinclude_HEADERS = \ | |||
77 | gnunet_service_lib.h \ | 78 | gnunet_service_lib.h \ |
78 | gnunet_signal_lib.h \ | 79 | gnunet_signal_lib.h \ |
79 | gnunet_signatures.h \ | 80 | gnunet_signatures.h \ |
81 | gnunet_speaker_lib.h \ | ||
80 | gnunet_statistics_service.h \ | 82 | gnunet_statistics_service.h \ |
81 | gnunet_strings_lib.h \ | 83 | gnunet_strings_lib.h \ |
82 | gnunet_testbed_service.h \ | 84 | gnunet_testbed_service.h \ |
diff --git a/src/include/gnunet_conversation_service.h b/src/include/gnunet_conversation_service.h index 9f7b829aa..677c40244 100644 --- a/src/include/gnunet_conversation_service.h +++ b/src/include/gnunet_conversation_service.h | |||
@@ -36,6 +36,8 @@ extern "C" | |||
36 | #endif | 36 | #endif |
37 | #endif | 37 | #endif |
38 | 38 | ||
39 | #include "gnunet_util_lib.h" | ||
40 | |||
39 | /** | 41 | /** |
40 | * Version of the conversation API. | 42 | * Version of the conversation API. |
41 | */ | 43 | */ |
@@ -233,60 +235,11 @@ GNUNET_CONVERSATION_reject (struct GNUNET_CONVERSATION_Handle *handle); | |||
233 | talking to.x */ | 235 | talking to.x */ |
234 | 236 | ||
235 | 237 | ||
238 | #include "gnunet_util_lib.h" | ||
236 | #include "gnunet_identity_service.h" | 239 | #include "gnunet_identity_service.h" |
237 | #include "gnunet_namestore_service.h" | 240 | #include "gnunet_namestore_service.h" |
238 | 241 | #include "gnunet_speaker_lib.h" | |
239 | 242 | #include "gnunet_microphone_lib.h" | |
240 | /** | ||
241 | * A speaker is a device that can play or record audio data. | ||
242 | */ | ||
243 | struct GNUNET_CONVERSATION_Speaker; | ||
244 | |||
245 | |||
246 | /** | ||
247 | * Create a speaker that corresponds to the speaker hardware | ||
248 | * of our system. | ||
249 | * | ||
250 | * @param cfg configuration to use | ||
251 | * @return NULL on error | ||
252 | */ | ||
253 | struct GNUNET_CONVERSATION_Speaker * | ||
254 | GNUNET_CONVERSATION_speaker_create_from_hardware (struct GNUNET_CONFIGURATION_Handle *cfg); | ||
255 | |||
256 | |||
257 | /** | ||
258 | * Destroy a speaker. | ||
259 | * | ||
260 | * @param speaker speaker to destroy | ||
261 | */ | ||
262 | void | ||
263 | GNUNET_CONVERSATION_speaker_destroy (struct GNUNET_CONVERSATION_Speaker *speaker); | ||
264 | |||
265 | |||
266 | /** | ||
267 | * A speaker is a device that can generate audio data. | ||
268 | */ | ||
269 | struct GNUNET_CONVERSATION_Microphone; | ||
270 | |||
271 | |||
272 | /** | ||
273 | * Create a speaker that corresponds to the speaker hardware | ||
274 | * of our system. | ||
275 | * | ||
276 | * @param cfg configuration to use | ||
277 | * @return NULL on error | ||
278 | */ | ||
279 | struct GNUNET_CONVERSATION_Microphone * | ||
280 | GNUNET_CONVERSATION_microphone_create_from_hardware (struct GNUNET_CONFIGURATION_Handle *cfg); | ||
281 | |||
282 | |||
283 | /** | ||
284 | * Destroy a microphone. | ||
285 | * | ||
286 | * @param mic microphone to destroy | ||
287 | */ | ||
288 | void | ||
289 | GNUNET_CONVERSATION_microphone_destroy (struct GNUNET_CONVERSATION_Microphone *mic); | ||
290 | 243 | ||
291 | 244 | ||
292 | /** | 245 | /** |
@@ -382,8 +335,8 @@ GNUNET_CONVERSATION_phone_get_record (struct GNUNET_CONVERSATION_Phone *phone, | |||
382 | void | 335 | void |
383 | GNUNET_CONVERSTATION_phone_pick_up (struct GNUNET_CONVERSATION_Phone *phone, | 336 | GNUNET_CONVERSTATION_phone_pick_up (struct GNUNET_CONVERSATION_Phone *phone, |
384 | const char *metadata, | 337 | const char *metadata, |
385 | struct GNUNET_CONVERSATION_Speaker *speaker, | 338 | struct GNUNET_SPEAKER_Handle *speaker, |
386 | struct GNUNET_CONVERSATION_Microphone *mic); | 339 | struct GNUNET_MICROPHONE_Handle *mic); |
387 | 340 | ||
388 | 341 | ||
389 | /** | 342 | /** |
@@ -431,8 +384,8 @@ struct GNUNET_CONVERSATION_Call * | |||
431 | GNUNET_CONVERSATION_call_start (const struct GNUNET_CONFIGURATION_Handle *cfg, | 384 | GNUNET_CONVERSATION_call_start (const struct GNUNET_CONFIGURATION_Handle *cfg, |
432 | struct GNUNET_IDENTITY_Ego *caller_id, | 385 | struct GNUNET_IDENTITY_Ego *caller_id, |
433 | const char *callee, | 386 | const char *callee, |
434 | struct GNUNET_CONVERSATION_Speaker *speaker, | 387 | struct GNUNET_SPEAKER_Handle *speaker, |
435 | struct GNUNET_CONVERSATION_Microphone *mic, | 388 | struct GNUNET_MICROPHONE_Handle *mic, |
436 | GNUNET_CONVERSATION_EventHandler event_handler, | 389 | GNUNET_CONVERSATION_EventHandler event_handler, |
437 | void *event_handler_cls); | 390 | void *event_handler_cls); |
438 | 391 | ||
@@ -444,7 +397,7 @@ GNUNET_CONVERSATION_call_start (const struct GNUNET_CONFIGURATION_Handle *cfg, | |||
444 | * @param reason if the call was active (ringing or ready) this will be the | 397 | * @param reason if the call was active (ringing or ready) this will be the |
445 | * reason given to the other user for why we hung up | 398 | * reason given to the other user for why we hung up |
446 | */ | 399 | */ |
447 | struct GNUNET_CONVERSATION_Call * | 400 | void |
448 | GNUNET_CONVERSATION_call_stop (const struct GNUNET_CONVERSATION_Call *call, | 401 | GNUNET_CONVERSATION_call_stop (const struct GNUNET_CONVERSATION_Call *call, |
449 | const char *reason); | 402 | const char *reason); |
450 | 403 | ||
diff --git a/src/include/gnunet_microphone_lib.h b/src/include/gnunet_microphone_lib.h new file mode 100644 index 000000000..c99777d0c --- /dev/null +++ b/src/include/gnunet_microphone_lib.h | |||
@@ -0,0 +1,133 @@ | |||
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 */ | ||
diff --git a/src/include/gnunet_speaker_lib.h b/src/include/gnunet_speaker_lib.h new file mode 100644 index 000000000..567b984e0 --- /dev/null +++ b/src/include/gnunet_speaker_lib.h | |||
@@ -0,0 +1,135 @@ | |||
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_speaker_lib.h | ||
23 | * @brief API to access an audio speaker; provides access to hardware speakers | ||
24 | * @author Simon Dieterle | ||
25 | * @author Andreas Fuchs | ||
26 | * @author Christian Grothoff | ||
27 | */ | ||
28 | #ifndef GNUNET_SPEAKER_SERVICE_H | ||
29 | #define GNUNET_SPEAKER_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 | * Function that enables a speaker. | ||
41 | * | ||
42 | * @param cls clsoure | ||
43 | */ | ||
44 | typedef void (*GNUNET_SPEAKER_EnableCallback)(void *cls); | ||
45 | |||
46 | /** | ||
47 | * Function that disables a speaker. | ||
48 | * | ||
49 | * @param cls clsoure | ||
50 | */ | ||
51 | typedef void (*GNUNET_SPEAKER_DisableCallback)(void *cls); | ||
52 | |||
53 | /** | ||
54 | * Function to destroy a speaker. | ||
55 | * | ||
56 | * @param cls clsoure | ||
57 | */ | ||
58 | typedef void (*GNUNET_SPEAKER_DestroyCallback)(void *cls); | ||
59 | |||
60 | /** | ||
61 | * Function to cause a speaker to play audio data. | ||
62 | * | ||
63 | * @param cls clsoure | ||
64 | * @param data_size number of bytes in @a data | ||
65 | * @param data audio data to play, format is | ||
66 | * opaque to the API but should be OPUS. | ||
67 | */ | ||
68 | typedef void (*GNUNET_SPEAKER_PlayCallback)(void *cls, | ||
69 | size_t data_size, | ||
70 | const void *data); | ||
71 | |||
72 | |||
73 | /** | ||
74 | * A speaker is a device that can play or record audio data. | ||
75 | */ | ||
76 | struct GNUNET_SPEAKER_Handle | ||
77 | { | ||
78 | |||
79 | /** | ||
80 | * Turn on the speaker. | ||
81 | */ | ||
82 | GNUNET_SPEAKER_EnableCallback enable_speaker; | ||
83 | |||
84 | /** | ||
85 | * Play audio. | ||
86 | */ | ||
87 | GNUNET_SPEAKER_PlayCallback play; | ||
88 | |||
89 | /** | ||
90 | * Turn the speaker off. | ||
91 | */ | ||
92 | GNUNET_SPEAKER_DisableCallback disable_speaker; | ||
93 | |||
94 | /** | ||
95 | * Destroy the speaker. Called by #GNUNET_SPEAKER_destroy. | ||
96 | */ | ||
97 | GNUNET_SPEAKER_DestroyCallback destroy_speaker; | ||
98 | |||
99 | /** | ||
100 | * Closure for the callbacks. | ||
101 | */ | ||
102 | void *cls; | ||
103 | |||
104 | }; | ||
105 | |||
106 | |||
107 | /** | ||
108 | * Create a speaker that corresponds to the speaker hardware | ||
109 | * of our system. | ||
110 | * | ||
111 | * @param cfg configuration to use | ||
112 | * @return NULL on error | ||
113 | */ | ||
114 | struct GNUNET_SPEAKER_Handle * | ||
115 | GNUNET_SPEAKER_create_from_hardware (const struct GNUNET_CONFIGURATION_Handle *cfg); | ||
116 | |||
117 | |||
118 | /** | ||
119 | * Destroy a speaker. | ||
120 | * | ||
121 | * @param speaker speaker to destroy | ||
122 | */ | ||
123 | void | ||
124 | GNUNET_SPEAKER_destroy (struct GNUNET_SPEAKER_Handle *speaker); | ||
125 | |||
126 | |||
127 | #if 0 /* keep Emacsens' auto-indent happy */ | ||
128 | { | ||
129 | #endif | ||
130 | #ifdef __cplusplus | ||
131 | } | ||
132 | #endif | ||
133 | |||
134 | #endif | ||
135 | /* end of gnunet_speaker_lib.h */ | ||