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/include | |
parent | 705d8a8c1efe6cd7f0d9a452e8bb89cd7923fe99 (diff) | |
download | gnunet-ec9740ca2ca84525842e6743b45ceb9cb2a3ea95.tar.gz gnunet-ec9740ca2ca84525842e6743b45ceb9cb2a3ea95.zip |
-split off microphone/speaker APIs
Diffstat (limited to 'src/include')
-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 |
4 files changed, 280 insertions, 57 deletions
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 */ | ||