gnunet_microphone_lib.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. /*
  2. This file is part of GNUnet
  3. Copyright (C) 2013 Christian Grothoff (and other contributing authors)
  4. GNUnet is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published
  6. by the Free Software Foundation; either version 3, or (at your
  7. 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. General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with GNUnet; see the file COPYING. If not, write to the
  14. Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  15. Boston, MA 02110-1301, USA.
  16. */
  17. /**
  18. * @author Simon Dieterle
  19. * @author Andreas Fuchs
  20. * @author Christian Grothoff
  21. *
  22. * @file
  23. * API to access an audio microphone; provides access to hardware microphones
  24. *
  25. * @defgroup microphone Microphone library
  26. * Provides access to hardware microphones.
  27. * @{
  28. */
  29. #ifndef GNUNET_MICROPHONE_SERVICE_H
  30. #define GNUNET_MICROPHONE_SERVICE_H
  31. #ifdef __cplusplus
  32. extern "C"
  33. {
  34. #if 0 /* keep Emacsens' auto-indent happy */
  35. }
  36. #endif
  37. #endif
  38. #include "gnunet_util_lib.h"
  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. * Enable a microphone.
  51. *
  52. * @param cls clsoure
  53. * @param rdc function to call with recorded data
  54. * @param rdc_cls closure for @a dc
  55. * @return #GNUNET_OK on success, #GNUNET_SYSERR on error
  56. */
  57. typedef int (*GNUNET_MICROPHONE_EnableCallback)(void *cls,
  58. GNUNET_MICROPHONE_RecordedDataCallback rdc,
  59. void *rdc_cls);
  60. /**
  61. * Function that disables a microphone.
  62. *
  63. * @param cls clsoure
  64. */
  65. typedef void (*GNUNET_MICROPHONE_DisableCallback)(void *cls);
  66. /**
  67. * Function to destroy a microphone.
  68. *
  69. * @param cls clsoure
  70. */
  71. typedef void (*GNUNET_MICROPHONE_DestroyCallback)(void *cls);
  72. /**
  73. * A microphone is a device that can capture or otherwise produce audio data.
  74. */
  75. struct GNUNET_MICROPHONE_Handle
  76. {
  77. /**
  78. * Turn on the microphone.
  79. */
  80. GNUNET_MICROPHONE_EnableCallback enable_microphone;
  81. /**
  82. * Turn the microphone off.
  83. */
  84. GNUNET_MICROPHONE_DisableCallback disable_microphone;
  85. /**
  86. * Destroy the microphone. Called by #GNUNET_MICROPHONE_destroy.
  87. */
  88. GNUNET_MICROPHONE_DestroyCallback destroy_microphone;
  89. /**
  90. * Closure for the callbacks.
  91. */
  92. void *cls;
  93. };
  94. /**
  95. * Create a microphone that corresponds to the microphone hardware
  96. * of our system.
  97. *
  98. * @param cfg configuration to use
  99. * @return NULL on error
  100. */
  101. struct GNUNET_MICROPHONE_Handle *
  102. GNUNET_MICROPHONE_create_from_hardware (const struct GNUNET_CONFIGURATION_Handle *cfg);
  103. /**
  104. * Destroy a microphone.
  105. *
  106. * @param microphone microphone to destroy
  107. */
  108. void
  109. GNUNET_MICROPHONE_destroy (struct GNUNET_MICROPHONE_Handle *microphone);
  110. #if 0 /* keep Emacsens' auto-indent happy */
  111. {
  112. #endif
  113. #ifdef __cplusplus
  114. }
  115. #endif
  116. #endif
  117. /** @} */ /* end of group */
  118. /* end of gnunet_microphone_lib.h */