speex.h 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. /*
  2. * Copyright (C) 2008-2011 Teluu Inc. (http://www.teluu.com)
  3. * Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org>
  4. *
  5. * This program is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation; either version 2 of the License, or
  8. * (at your option) any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this program; if not, write to the Free Software
  17. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  18. */
  19. #ifndef __PJMEDIA_CODEC_SPEEX_H__
  20. #define __PJMEDIA_CODEC_SPEEX_H__
  21. /**
  22. * @file speex.h
  23. * @brief Speex codec header.
  24. */
  25. #include <pjmedia-codec/types.h>
  26. /**
  27. * @defgroup PJMED_SPEEX Speex Codec Family
  28. * @ingroup PJMEDIA_CODEC_CODECS
  29. * @brief Implementation of Speex codecs (narrow/wide/ultrawide-band).
  30. * @{
  31. *
  32. * This section describes functions to initialize and register speex codec
  33. * factory to the codec manager. After the codec factory has been registered,
  34. * application can use @ref PJMEDIA_CODEC API to manipulate the codec.
  35. *
  36. * The Speex codec uses multiple bit rates, and supports ultra-wideband
  37. * (32 kHz sampling rate), wideband (16 kHz sampling rate) and narrowband
  38. * (telephone quality, 8 kHz sampling rate)
  39. *
  40. * By default, the speex codec factory registers three Speex codecs:
  41. * "speex/8000" narrowband codec, "speex/16000" wideband codec, and
  42. * "speex/32000" ultra-wideband codec. This behavior can be changed by
  43. * specifying #pjmedia_speex_options flags during initialization.
  44. *
  45. *
  46. * \section speex_codec_setting Codec Settings
  47. *
  48. * \subsection speex_general_setting General Settings
  49. *
  50. * General codec settings for this codec such as VAD and PLC can be
  51. * manipulated through the <tt>setting</tt> field in #pjmedia_codec_param.
  52. * Please see the documentation of #pjmedia_codec_param for more info.
  53. *
  54. * \subsection speex_specific_setting Codec Specific Settings
  55. *
  56. * The following settings are applicable for this codec.
  57. *
  58. * \subsubsection speex_quality_vs_complexity Quality vs Complexity
  59. *
  60. * The Speex codec quality versus computational complexity and bandwidth
  61. * requirement can be adjusted by modifying the quality and complexity
  62. * setting, by calling #pjmedia_codec_speex_set_param(). The RFC 5574
  63. * Section 5 shows the relationship between quality setting and the
  64. * resulting bitrate.
  65. *
  66. * The default setting of quality is specified in
  67. * #PJMEDIA_CODEC_SPEEX_DEFAULT_QUALITY. And the default setting of
  68. * complexity is specified in #PJMEDIA_CODEC_SPEEX_DEFAULT_COMPLEXITY.
  69. */
  70. PJ_BEGIN_DECL
  71. /**
  72. * Bitmask options to be passed during Speex codec factory initialization.
  73. */
  74. enum pjmedia_speex_options
  75. {
  76. PJMEDIA_SPEEX_NO_NB = 1, /**< Disable narrowband mode. */
  77. PJMEDIA_SPEEX_NO_WB = 2, /**< Disable wideband mode. */
  78. PJMEDIA_SPEEX_NO_UWB = 4, /**< Disable ultra-wideband mode. */
  79. };
  80. /**
  81. * Initialize and register Speex codec factory to pjmedia endpoint.
  82. *
  83. * @param endpt The pjmedia endpoint.
  84. * @param options Bitmask of pjmedia_speex_options (default=0).
  85. * @param quality Specify encoding quality, or use -1 for default
  86. * (@see PJMEDIA_CODEC_SPEEX_DEFAULT_QUALITY).
  87. * @param complexity Specify encoding complexity , or use -1 for default
  88. * (@see PJMEDIA_CODEC_SPEEX_DEFAULT_COMPLEXITY).
  89. *
  90. * @return PJ_SUCCESS on success.
  91. */
  92. PJ_DECL(pj_status_t) pjmedia_codec_speex_init( pjmedia_endpt *endpt,
  93. unsigned options,
  94. int quality,
  95. int complexity );
  96. /**
  97. * Initialize Speex codec factory using default settings and register to
  98. * pjmedia endpoint.
  99. *
  100. * @param endpt The pjmedia endpoint.
  101. *
  102. * @return PJ_SUCCESS on success.
  103. */
  104. PJ_DECL(pj_status_t) pjmedia_codec_speex_init_default(pjmedia_endpt *endpt);
  105. /**
  106. * Change the settings of Speex codec.
  107. *
  108. * @param clock_rate Clock rate of Speex mode to be set.
  109. * @param quality Specify encoding quality, or use -1 for default
  110. * (@see PJMEDIA_CODEC_SPEEX_DEFAULT_QUALITY).
  111. * @param complexity Specify encoding complexity , or use -1 for default
  112. * (@see PJMEDIA_CODEC_SPEEX_DEFAULT_COMPLEXITY).
  113. *
  114. * @return PJ_SUCCESS on success.
  115. */
  116. PJ_DECL(pj_status_t) pjmedia_codec_speex_set_param(unsigned clock_rate,
  117. int quality,
  118. int complexity);
  119. /**
  120. * Unregister Speex codec factory from pjmedia endpoint and deinitialize
  121. * the Speex codec library.
  122. *
  123. * @return PJ_SUCCESS on success.
  124. */
  125. PJ_DECL(pj_status_t) pjmedia_codec_speex_deinit(void);
  126. PJ_END_DECL
  127. /**
  128. * @}
  129. */
  130. #endif /* __PJMEDIA_CODEC_SPEEX_H__ */