1 /* Copyright (C) 2002 Jean-Marc Valin*/ 2 /** 3 @file speex_callbacks.h 4 @brief Describes callback handling and in-band signalling 5 */ 6 /* 7 Redistribution and use in source and binary forms, with or without 8 modification, are permitted provided that the following conditions 9 are met: 10 11 - Redistributions of source code must retain the above copyright 12 notice, this list of conditions and the following disclaimer. 13 14 - Redistributions in binary form must reproduce the above copyright 15 notice, this list of conditions and the following disclaimer in the 16 documentation and/or other materials provided with the distribution. 17 18 - Neither the name of the Xiph.org Foundation nor the names of its 19 contributors may be used to endorse or promote products derived from 20 this software without specific prior written permission. 21 22 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 23 ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 24 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 25 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR 26 CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 27 EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 28 PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 29 PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 30 LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 31 NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 32 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 33 34 */ 35 36 #ifndef SPEEX_CALLBACKS_H 37 #define SPEEX_CALLBACKS_H 38 /** @defgroup SpeexCallbacks Various definitions for Speex callbacks supported by the decoder. 39 * @{ 40 */ 41 42 #include "speex.h" 43 44 #ifdef __cplusplus 45 extern "C" { 46 #endif 47 48 /** Total number of callbacks */ 49 #define SPEEX_MAX_CALLBACKS 16 50 51 /* Describes all the in-band requests */ 52 53 /*These are 1-bit requests*/ 54 /** Request for perceptual enhancement (1 for on, 0 for off) */ 55 #define SPEEX_INBAND_ENH_REQUEST 0 56 /** Reserved */ 57 #define SPEEX_INBAND_RESERVED1 1 58 59 /*These are 4-bit requests*/ 60 /** Request for a mode change */ 61 #define SPEEX_INBAND_MODE_REQUEST 2 62 /** Request for a low mode change */ 63 #define SPEEX_INBAND_LOW_MODE_REQUEST 3 64 /** Request for a high mode change */ 65 #define SPEEX_INBAND_HIGH_MODE_REQUEST 4 66 /** Request for VBR (1 on, 0 off) */ 67 #define SPEEX_INBAND_VBR_QUALITY_REQUEST 5 68 /** Request to be sent acknowledge */ 69 #define SPEEX_INBAND_ACKNOWLEDGE_REQUEST 6 70 /** Request for VBR (1 for on, 0 for off) */ 71 #define SPEEX_INBAND_VBR_REQUEST 7 72 73 /*These are 8-bit requests*/ 74 /** Send a character in-band */ 75 #define SPEEX_INBAND_CHAR 8 76 /** Intensity stereo information */ 77 #define SPEEX_INBAND_STEREO 9 78 79 /*These are 16-bit requests*/ 80 /** Transmit max bit-rate allowed */ 81 #define SPEEX_INBAND_MAX_BITRATE 10 82 83 /*These are 32-bit requests*/ 84 /** Acknowledge packet reception */ 85 #define SPEEX_INBAND_ACKNOWLEDGE 12 86 87 /** Callback function type */ 88 typedef int (*speex_callback_func)(SpeexBits *bits, void *state, void *data); 89 90 /** Callback information */ 91 typedef struct SpeexCallback { 92 int callback_id; /**< ID associated to the callback */ 93 speex_callback_func func; /**< Callback handler function */ 94 void *data; /**< Data that will be sent to the handler */ 95 void *reserved1; /**< Reserved for future use */ 96 int reserved2; /**< Reserved for future use */ 97 } SpeexCallback; 98 99 /** Handle in-band request */ 100 int speex_inband_handler(SpeexBits *bits, SpeexCallback *callback_list, void *state); 101 102 /** Standard handler for mode request (change mode, no questions asked) */ 103 int speex_std_mode_request_handler(SpeexBits *bits, void *state, void *data); 104 105 /** Standard handler for high mode request (change high mode, no questions asked) */ 106 int speex_std_high_mode_request_handler(SpeexBits *bits, void *state, void *data); 107 108 /** Standard handler for in-band characters (write to stderr) */ 109 int speex_std_char_handler(SpeexBits *bits, void *state, void *data); 110 111 /** Default handler for user-defined requests: in this case, just ignore */ 112 int speex_default_user_handler(SpeexBits *bits, void *state, void *data); 113 114 115 116 /** Standard handler for low mode request (change low mode, no questions asked) */ 117 int speex_std_low_mode_request_handler(SpeexBits *bits, void *state, void *data); 118 119 /** Standard handler for VBR request (Set VBR, no questions asked) */ 120 int speex_std_vbr_request_handler(SpeexBits *bits, void *state, void *data); 121 122 /** Standard handler for enhancer request (Turn enhancer on/off, no questions asked) */ 123 int speex_std_enh_request_handler(SpeexBits *bits, void *state, void *data); 124 125 /** Standard handler for VBR quality request (Set VBR quality, no questions asked) */ 126 int speex_std_vbr_quality_request_handler(SpeexBits *bits, void *state, void *data); 127 128 129 #ifdef __cplusplus 130 } 131 #endif 132 133 /** @} */ 134 #endif 135