g722_interface.h 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  1. /*
  2. * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
  3. *
  4. * Use of this source code is governed by a BSD-style license
  5. * that can be found in the LICENSE file in the root of the source
  6. * tree. An additional intellectual property rights grant can be found
  7. * in the file PATENTS. All contributing project authors may
  8. * be found in the AUTHORS file in the root of the source tree.
  9. */
  10. #ifndef MODULES_AUDIO_CODING_CODECS_G722_G722_INTERFACE_H_
  11. #define MODULES_AUDIO_CODING_CODECS_G722_G722_INTERFACE_H_
  12. #include <stdint.h>
  13. /*
  14. * Solution to support multiple instances
  15. */
  16. typedef struct WebRtcG722EncInst G722EncInst;
  17. typedef struct WebRtcG722DecInst G722DecInst;
  18. /*
  19. * Comfort noise constants
  20. */
  21. #define G722_WEBRTC_SPEECH 1
  22. #define G722_WEBRTC_CNG 2
  23. #ifdef __cplusplus
  24. extern "C" {
  25. #endif
  26. /****************************************************************************
  27. * WebRtcG722_CreateEncoder(...)
  28. *
  29. * Create memory used for G722 encoder
  30. *
  31. * Input:
  32. * - G722enc_inst : G722 instance for encoder
  33. *
  34. * Return value : 0 - Ok
  35. * -1 - Error
  36. */
  37. int16_t WebRtcG722_CreateEncoder(G722EncInst** G722enc_inst);
  38. /****************************************************************************
  39. * WebRtcG722_EncoderInit(...)
  40. *
  41. * This function initializes a G722 instance
  42. *
  43. * Input:
  44. * - G722enc_inst : G722 instance, i.e. the user that should receive
  45. * be initialized
  46. *
  47. * Return value : 0 - Ok
  48. * -1 - Error
  49. */
  50. int16_t WebRtcG722_EncoderInit(G722EncInst* G722enc_inst);
  51. /****************************************************************************
  52. * WebRtcG722_FreeEncoder(...)
  53. *
  54. * Free the memory used for G722 encoder
  55. *
  56. * Input:
  57. * - G722enc_inst : G722 instance for encoder
  58. *
  59. * Return value : 0 - Ok
  60. * -1 - Error
  61. */
  62. int WebRtcG722_FreeEncoder(G722EncInst* G722enc_inst);
  63. /****************************************************************************
  64. * WebRtcG722_Encode(...)
  65. *
  66. * This function encodes G722 encoded data.
  67. *
  68. * Input:
  69. * - G722enc_inst : G722 instance, i.e. the user that should encode
  70. * a packet
  71. * - speechIn : Input speech vector
  72. * - len : Samples in speechIn
  73. *
  74. * Output:
  75. * - encoded : The encoded data vector
  76. *
  77. * Return value : Length (in bytes) of coded data
  78. */
  79. size_t WebRtcG722_Encode(G722EncInst* G722enc_inst,
  80. const int16_t* speechIn,
  81. size_t len,
  82. uint8_t* encoded);
  83. /****************************************************************************
  84. * WebRtcG722_CreateDecoder(...)
  85. *
  86. * Create memory used for G722 encoder
  87. *
  88. * Input:
  89. * - G722dec_inst : G722 instance for decoder
  90. *
  91. * Return value : 0 - Ok
  92. * -1 - Error
  93. */
  94. int16_t WebRtcG722_CreateDecoder(G722DecInst** G722dec_inst);
  95. /****************************************************************************
  96. * WebRtcG722_DecoderInit(...)
  97. *
  98. * This function initializes a G722 instance
  99. *
  100. * Input:
  101. * - inst : G722 instance
  102. */
  103. void WebRtcG722_DecoderInit(G722DecInst* inst);
  104. /****************************************************************************
  105. * WebRtcG722_FreeDecoder(...)
  106. *
  107. * Free the memory used for G722 decoder
  108. *
  109. * Input:
  110. * - G722dec_inst : G722 instance for decoder
  111. *
  112. * Return value : 0 - Ok
  113. * -1 - Error
  114. */
  115. int WebRtcG722_FreeDecoder(G722DecInst* G722dec_inst);
  116. /****************************************************************************
  117. * WebRtcG722_Decode(...)
  118. *
  119. * This function decodes a packet with G729 frame(s). Output speech length
  120. * will be a multiple of 80 samples (80*frames/packet).
  121. *
  122. * Input:
  123. * - G722dec_inst : G722 instance, i.e. the user that should decode
  124. * a packet
  125. * - encoded : Encoded G722 frame(s)
  126. * - len : Bytes in encoded vector
  127. *
  128. * Output:
  129. * - decoded : The decoded vector
  130. * - speechType : 1 normal, 2 CNG (Since G722 does not have its own
  131. * DTX/CNG scheme it should always return 1)
  132. *
  133. * Return value : Samples in decoded vector
  134. */
  135. size_t WebRtcG722_Decode(G722DecInst* G722dec_inst,
  136. const uint8_t* encoded,
  137. size_t len,
  138. int16_t* decoded,
  139. int16_t* speechType);
  140. /****************************************************************************
  141. * WebRtcG722_Version(...)
  142. *
  143. * Get a string with the current version of the codec
  144. */
  145. int16_t WebRtcG722_Version(char* versionStr, short len);
  146. #ifdef __cplusplus
  147. }
  148. #endif
  149. #endif /* MODULES_AUDIO_CODING_CODECS_G722_G722_INTERFACE_H_ */