gnunet-android

GNUnet for Android
Log | Files | Refs | README

gnunet_speaker_lib.h (3366B)


      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 speaker; provides access to hardware speakers
     31  *
     32  * @defgroup speaker  Speaker service
     33  * Access hardware audio speakers.
     34  * @{
     35  */
     36 #ifndef GNUNET_SPEAKER_SERVICE_H
     37 #define GNUNET_SPEAKER_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  * Function that enables a speaker.
     52  *
     53  * @param cls closure
     54  * @return #GNUNET_OK on success, #GNUNET_SYSERR on error
     55  */
     56 typedef int (*GNUNET_SPEAKER_EnableCallback)(void *cls);
     57 
     58 /**
     59  * Function that disables a speaker.
     60  *
     61  * @param cls closure
     62  */
     63 typedef void (*GNUNET_SPEAKER_DisableCallback)(void *cls);
     64 
     65 /**
     66  * Function to destroy a speaker.
     67  *
     68  * @param cls closure
     69  */
     70 typedef void (*GNUNET_SPEAKER_DestroyCallback)(void *cls);
     71 
     72 /**
     73  * Function to cause a speaker to play audio data.
     74  *
     75  * @param cls closure
     76  * @param data_size number of bytes in @a data
     77  * @param data audio data to play, format is
     78  *        opaque to the API but should be OPUS.
     79  */
     80 typedef void (*GNUNET_SPEAKER_PlayCallback)(void *cls,
     81                                             size_t data_size,
     82                                             const void *data);
     83 
     84 
     85 /**
     86  * A speaker is a device that can play or record audio data.
     87  */
     88 struct GNUNET_SPEAKER_Handle
     89 {
     90   /**
     91    * Turn on the speaker.
     92    */
     93   GNUNET_SPEAKER_EnableCallback enable_speaker;
     94 
     95   /**
     96    * Play audio.
     97    */
     98   GNUNET_SPEAKER_PlayCallback play;
     99 
    100   /**
    101    * Turn the speaker off.
    102    */
    103   GNUNET_SPEAKER_DisableCallback disable_speaker;
    104 
    105   /**
    106    * Destroy the speaker.  Called by #GNUNET_SPEAKER_destroy.
    107    */
    108   GNUNET_SPEAKER_DestroyCallback destroy_speaker;
    109 
    110   /**
    111    * Closure for the callbacks.
    112    */
    113   void *cls;
    114 };
    115 
    116 
    117 /**
    118  * Create a speaker that corresponds to the speaker hardware
    119  * of our system.
    120  *
    121  * @param cfg configuration to use
    122  * @return NULL on error
    123  */
    124 struct GNUNET_SPEAKER_Handle *
    125 GNUNET_SPEAKER_create_from_hardware (const struct
    126                                      GNUNET_CONFIGURATION_Handle *cfg);
    127 
    128 
    129 /**
    130  * Destroy a speaker.
    131  *
    132  * @param speaker speaker to destroy
    133  */
    134 void
    135 GNUNET_SPEAKER_destroy (struct GNUNET_SPEAKER_Handle *speaker);
    136 
    137 
    138 #if 0                           /* keep Emacsens' auto-indent happy */
    139 {
    140 #endif
    141 #ifdef __cplusplus
    142 }
    143 #endif
    144 
    145 #endif
    146 
    147 /** @} */ /* end of group */
    148 
    149 /** @} */ /* end of group addition */
    150 
    151 /* end of gnunet_speaker_lib.h */