gnunet_microphone_lib.h 3.2 KB

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