gnunet_microphone_lib.h (3661B)
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 * @addtogroup conversation_l2 Conversation service and libraries 23 * @{ 24 * 25 * @author Simon Dieterle 26 * @author Andreas Fuchs 27 * @author Christian Grothoff 28 * 29 * @file 30 * API to access an audio microphone; provides access to hardware microphones 31 * 32 * @defgroup microphone Microphone library 33 * Provides access to hardware microphones. 34 * @{ 35 */ 36 #ifndef GNUNET_MICROPHONE_SERVICE_H 37 #define GNUNET_MICROPHONE_SERVICE_H 38 39 #ifdef __cplusplus 40 extern "C" 41 { 42 #if 0 /* keep Emacsens' auto-indent happy */ 43 } 44 #endif 45 #endif 46 47 48 #include "gnunet_util_lib.h" 49 50 /** 51 * Process recorded audio data. 52 * 53 * @param cls clsoure 54 * @param data_size number of bytes in @a data 55 * @param data audio data to play 56 */ 57 typedef void (*GNUNET_MICROPHONE_RecordedDataCallback)(void *cls, 58 size_t data_size, 59 const void *data); 60 61 /** 62 * Enable a microphone. 63 * 64 * @param cls clsoure 65 * @param rdc function to call with recorded data 66 * @param rdc_cls closure for @a dc 67 * @return #GNUNET_OK on success, #GNUNET_SYSERR on error 68 */ 69 typedef int (*GNUNET_MICROPHONE_EnableCallback)(void *cls, 70 GNUNET_MICROPHONE_RecordedDataCallback 71 rdc, 72 void *rdc_cls); 73 74 /** 75 * Function that disables a microphone. 76 * 77 * @param cls clsoure 78 */ 79 typedef void (*GNUNET_MICROPHONE_DisableCallback)(void *cls); 80 81 /** 82 * Function to destroy a microphone. 83 * 84 * @param cls clsoure 85 */ 86 typedef void (*GNUNET_MICROPHONE_DestroyCallback)(void *cls); 87 88 89 /** 90 * A microphone is a device that can capture or otherwise produce audio data. 91 */ 92 struct GNUNET_MICROPHONE_Handle 93 { 94 /** 95 * Turn on the microphone. 96 */ 97 GNUNET_MICROPHONE_EnableCallback enable_microphone; 98 99 /** 100 * Turn the microphone off. 101 */ 102 GNUNET_MICROPHONE_DisableCallback disable_microphone; 103 104 /** 105 * Destroy the microphone. Called by #GNUNET_MICROPHONE_destroy. 106 */ 107 GNUNET_MICROPHONE_DestroyCallback destroy_microphone; 108 109 /** 110 * Closure for the callbacks. 111 */ 112 void *cls; 113 }; 114 115 116 /** 117 * Create a microphone that corresponds to the microphone hardware 118 * of our system. 119 * 120 * @param cfg configuration to use 121 * @return NULL on error 122 */ 123 struct GNUNET_MICROPHONE_Handle * 124 GNUNET_MICROPHONE_create_from_hardware (const struct 125 GNUNET_CONFIGURATION_Handle *cfg); 126 127 128 /** 129 * Destroy a microphone. 130 * 131 * @param microphone microphone to destroy 132 */ 133 void 134 GNUNET_MICROPHONE_destroy (struct GNUNET_MICROPHONE_Handle *microphone); 135 136 137 #if 0 /* keep Emacsens' auto-indent happy */ 138 { 139 #endif 140 #ifdef __cplusplus 141 } 142 #endif 143 144 #endif 145 146 /** @} */ /* end of group */ 147 148 /** @} */ /* end of group addition */ 149 150 /* end of gnunet_microphone_lib.h */