1 /* Copyright (C) 2002 Jean-Marc Valin*/
3 @file speex_callbacks.h
4 @brief Describes callback handling and in-band signalling
7 Redistribution and use in source and binary forms, with or without
8 modification, are permitted provided that the following conditions
11 - Redistributions of source code must retain the above copyright
12 notice, this list of conditions and the following disclaimer.
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.
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.
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.
36 #ifndef SPEEX_CALLBACKS_H
37 #define SPEEX_CALLBACKS_H
38 /** @defgroup SpeexCallbacks Various definitions for Speex callbacks supported by the decoder.
48 /** Total number of callbacks */
49 #define SPEEX_MAX_CALLBACKS 16
51 /* Describes all the in-band requests */
53 /*These are 1-bit requests*/
54 /** Request for perceptual enhancement (1 for on, 0 for off) */
55 #define SPEEX_INBAND_ENH_REQUEST 0
57 #define SPEEX_INBAND_RESERVED1 1
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
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
79 /*These are 16-bit requests*/
80 /** Transmit max bit-rate allowed */
81 #define SPEEX_INBAND_MAX_BITRATE 10
83 /*These are 32-bit requests*/
84 /** Acknowledge packet reception */
85 #define SPEEX_INBAND_ACKNOWLEDGE 12
87 /** Callback function type */
88 typedef int (*speex_callback_func
)(SpeexBits
*bits
, void *state
, void *data
);
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 */
99 /** Handle in-band request */
100 int speex_inband_handler(SpeexBits
*bits
, SpeexCallback
*callback_list
, void *state
);
102 /** Standard handler for mode request (change mode, no questions asked) */
103 int speex_std_mode_request_handler(SpeexBits
*bits
, void *state
, void *data
);
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
);
108 /** Standard handler for in-band characters (write to stderr) */
109 int speex_std_char_handler(SpeexBits
*bits
, void *state
, void *data
);
111 /** Default handler for user-defined requests: in this case, just ignore */
112 int speex_default_user_handler(SpeexBits
*bits
, void *state
, void *data
);
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
);
119 /** Standard handler for VBR request (Set VBR, no questions asked) */
120 int speex_std_vbr_request_handler(SpeexBits
*bits
, void *state
, void *data
);
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
);
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
);