g7221.h 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  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_CODECS_G7221_H__
  20. #define __PJMEDIA_CODECS_G7221_H__
  21. /**
  22. * @file pjmedia-codec/g7221.h
  23. * @brief G722.1 codec.
  24. */
  25. #include <pjmedia-codec/types.h>
  26. /**
  27. * @defgroup PJMED_G7221_CODEC G.722.1 Codec (Siren7/Siren14)
  28. * @ingroup PJMEDIA_CODEC_CODECS
  29. * @brief Implementation of G.722.1 codec
  30. * @{
  31. *
  32. * <b>G.722.1 licensed from Polycom�</b><br />
  33. * <b>G.722.1 Annex C licensed from Polycom�</b>
  34. *
  35. * This section describes functions to initialize and register G.722.1 codec
  36. * factory to the codec manager. After the codec factory has been registered,
  37. * application can use @ref PJMEDIA_CODEC API to manipulate the codec.
  38. *
  39. * PJMEDIA G722.1 codec implementation is based on ITU-T Recommendation
  40. * G.722.1 (05/2005) C fixed point implementation including its Annex C.
  41. *
  42. * G.722.1 is a low complexity codec that supports 7kHz and 14kHz audio
  43. * bandwidth working at bitrates ranging from 16kbps to 48kbps. It may be
  44. * used with speech or music inputs.
  45. *
  46. *
  47. * \section g7221_codec_setting Codec Settings
  48. *
  49. * \subsection g7221_general_setting General Settings
  50. *
  51. * General codec settings for this codec such as VAD and PLC can be
  52. * manipulated through the <tt>setting</tt> field in #pjmedia_codec_param.
  53. * Please see the documentation of #pjmedia_codec_param for more info.
  54. *
  55. * \subsection g7221_specific_setting Codec Specific Settings
  56. *
  57. * The following settings are applicable for this codec.
  58. *
  59. * \subsubsection g7221_bitrate Bitrate
  60. *
  61. * The codec implementation supports standard and non-standard bitrates.
  62. * Use #pjmedia_codec_g7221_set_mode() to enable or disable the bitrates.
  63. *
  64. * By default, only standard bitrates are enabled upon initialization:
  65. * - for 7kHz audio bandwidth (16kHz sampling rate): 24kbps and 32kbps,
  66. * - for 14kHz audio bandwidth (32kHz sampling rate): 24kbps, 32kbps, and
  67. * 48kbps.
  68. *
  69. * The usage of non-standard bitrates must follow these requirements:
  70. * - for 7kHz audio bandwidth (16kHz sampling rate): 16000 to 32000 bps,
  71. * multiplication of 400
  72. * - for 14kHz audio bandwidth (32kHz sampling rate): 24000 to 48000 bps,
  73. * multiplication of 400
  74. *
  75. * The bitrate is set via <tt>param.setting.dec_fmtp</tt>, if it does not
  76. * contain bitrate info, the codec will check <tt>param.info.avg_bps</tt>.
  77. *
  78. * \note
  79. * Currently only up to two non-standard modes can be enabled.
  80. *
  81. * \remark
  82. * There is a flaw in the codec manager as currently it could not
  83. * differentiate G.722.1 codecs by bitrates, hence invoking
  84. * #pjmedia_codec_mgr_set_default_param() may only affect a G.722.1 codec
  85. * with the highest priority (or first index found in codec enumeration
  86. * when they have same priority) and invoking
  87. * #pjmedia_codec_mgr_set_codec_priority() will set priority of all G.722.1
  88. * codecs with sampling rate as specified.
  89. */
  90. PJ_BEGIN_DECL
  91. /**
  92. * Initialize and register G.722.1 codec factory to pjmedia endpoint.
  93. *
  94. * @param endpt The pjmedia endpoint.
  95. *
  96. * @return PJ_SUCCESS on success.
  97. */
  98. PJ_DECL(pj_status_t) pjmedia_codec_g7221_init( pjmedia_endpt *endpt );
  99. /**
  100. * Enable and disable G.722.1 mode. By default, the standard modes are
  101. * enabled upon initialization, i.e.:
  102. * - sampling rate 16kHz, bitrate 24kbps and 32kbps.
  103. * - sampling rate 32kHz, bitrate 24kbps, 32kbps, and 48kbps.
  104. * This function can also be used for enabling non-standard modes.
  105. * Note that currently only up to two non-standard modes can be enabled
  106. * at one time.
  107. *
  108. * @param sample_rate PCM sampling rate, in Hz, valid values are only
  109. * 16000 and 32000.
  110. * @param bitrate G722.1 bitrate, in bps, the valid values are
  111. * standard and non-standard bitrates as described
  112. * above.
  113. * @param enabled PJ_TRUE for enabling specified mode.
  114. *
  115. * @return PJ_SUCCESS on success.
  116. */
  117. PJ_DECL(pj_status_t) pjmedia_codec_g7221_set_mode(unsigned sample_rate,
  118. unsigned bitrate,
  119. pj_bool_t enabled);
  120. /**
  121. * Set the G.722.1 codec encoder and decoder level adjustment.
  122. * If the value is non-zero, then PCM input samples to the encoder will
  123. * be shifted right by this value, and similarly PCM output samples from
  124. * the decoder will be shifted left by this value.
  125. *
  126. * \note
  127. * This function is also applicable for G722.1 implementation with IPP
  128. * back-end.
  129. *
  130. * Default value is PJMEDIA_G7221_DEFAULT_PCM_SHIFT.
  131. *
  132. * @param val The value
  133. *
  134. * @return PJ_SUCCESS on success.
  135. */
  136. PJ_DECL(pj_status_t) pjmedia_codec_g7221_set_pcm_shift(int val);
  137. /**
  138. * Unregister G.722.1 codecs factory from pjmedia endpoint.
  139. *
  140. * @return PJ_SUCCESS on success.
  141. */
  142. PJ_DECL(pj_status_t) pjmedia_codec_g7221_deinit(void);
  143. PJ_END_DECL
  144. /**
  145. * @}
  146. */
  147. #endif /* __PJMEDIA_CODECS_G7221_H__ */