speex_callbacks.h 5.1 KB

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