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
45 /** Total number of callbacks */
46 #define SPEEX_MAX_CALLBACKS 16
48 /* Describes all the in-band requests */
50 /*These are 1-bit requests*/
51 /** Request for perceptual enhancement (1 for on, 0 for off) */
52 #define SPEEX_INBAND_ENH_REQUEST 0
54 #define SPEEX_INBAND_RESERVED1 1
56 /*These are 4-bit requests*/
57 /** Request for a mode change */
58 #define SPEEX_INBAND_MODE_REQUEST 2
59 /** Request for a low mode change */
60 #define SPEEX_INBAND_LOW_MODE_REQUEST 3
61 /** Request for a high mode change */
62 #define SPEEX_INBAND_HIGH_MODE_REQUEST 4
63 /** Request for VBR (1 on, 0 off) */
64 #define SPEEX_INBAND_VBR_QUALITY_REQUEST 5
65 /** Request to be sent acknowledge */
66 #define SPEEX_INBAND_ACKNOWLEDGE_REQUEST 6
67 /** Request for VBR (1 for on, 0 for off) */
68 #define SPEEX_INBAND_VBR_REQUEST 7
70 /*These are 8-bit requests*/
71 /** Send a character in-band */
72 #define SPEEX_INBAND_CHAR 8
73 /** Intensity stereo information */
74 #define SPEEX_INBAND_STEREO 9
76 /*These are 16-bit requests*/
77 /** Transmit max bit-rate allowed */
78 #define SPEEX_INBAND_MAX_BITRATE 10
80 /*These are 32-bit requests*/
81 /** Acknowledge packet reception */
82 #define SPEEX_INBAND_ACKNOWLEDGE 12
84 /** Callback function type */
85 typedef int (*speex_callback_func
)(SpeexBits
*bits
, void *state
, void *data
);
87 /** Callback information */
88 typedef struct SpeexCallback
{
89 int callback_id
; /**< ID associated to the callback */
90 speex_callback_func func
; /**< Callback handler function */
91 void *data
; /**< Data that will be sent to the handler */
92 void *reserved1
; /**< Reserved for future use */
93 int reserved2
; /**< Reserved for future use */
96 /** Handle in-band request */
97 int speex_inband_handler(SpeexBits
*bits
, SpeexCallback
*callback_list
, void *state
);
99 /** Standard handler for mode request (change mode, no questions asked) */
100 int speex_std_mode_request_handler(SpeexBits
*bits
, void *state
, void *data
);
102 /** Standard handler for high mode request (change high mode, no questions asked) */
103 int speex_std_high_mode_request_handler(SpeexBits
*bits
, void *state
, void *data
);
105 /** Standard handler for in-band characters (write to stderr) */
106 int speex_std_char_handler(SpeexBits
*bits
, void *state
, void *data
);
108 /** Default handler for user-defined requests: in this case, just ignore */
109 int speex_default_user_handler(SpeexBits
*bits
, void *state
, void *data
);
114 int speex_std_low_mode_request_handler(SpeexBits
*bits
, void *state
, void *data
);
116 int speex_std_vbr_request_handler(SpeexBits
*bits
, void *state
, void *data
);
118 int speex_std_enh_request_handler(SpeexBits
*bits
, void *state
, void *data
);
120 int speex_std_vbr_quality_request_handler(SpeexBits
*bits
, void *state
, void *data
);