lyra.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. /*
  2. * Copyright (C) 2024 Teluu Inc. (http://www.teluu.com)
  3. *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License as published by
  6. * the Free Software Foundation; either version 2 of the License, or
  7. * (at your option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program; if not, write to the Free Software
  16. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  17. */
  18. #ifndef __PJMEDIA_CODEC_LYRA_H__
  19. #define __PJMEDIA_CODEC_LYRA_H__
  20. /**
  21. * @file pjmedia-codec/lyra.hpp
  22. * @brief lyra codec.
  23. */
  24. #include <pjmedia-codec/types.h>
  25. /**
  26. * @defgroup PJMED_LYRA lyra Codec
  27. * @ingroup PJMEDIA_CODEC_CODECS
  28. * @brief Implementation of lyra Codec
  29. * @{
  30. *
  31. * This section describes functions to initialize and register lyra codec
  32. * factory to the codec manager. After the codec factory has been registered,
  33. * application can use @ref PJMEDIA_CODEC API to manipulate the codec.
  34. *
  35. * Lyra codec supports 16-bit PCM audio signal with sampling rate of (8000Hz,
  36. * 16000Hz, 32000Hz and 48000Hz), frame length 20ms, and resulting in
  37. * bitrate 3200bps, 6000bps and 9200bps.
  38. */
  39. PJ_BEGIN_DECL
  40. /**
  41. * Lyra codec setting;
  42. */
  43. typedef struct pjmedia_codec_lyra_config
  44. {
  45. /**
  46. * The value represents the decoder bitrate requested by the receiver.
  47. * Endpoints can be configured with different bitrates. For example,
  48. * the local endpoint might be set to a bitrate of 3200, while
  49. * the remote endpoint is set to 6000. In this scenario, the remote
  50. * endpoint will send data at 3200 bitrate, while the local endpoint
  51. * will send data at 6000 bitrate. Valid bitrate: 3200, 6000, 9200.
  52. * By default it is set to PJMEDIA_CODEC_LYRA_DEFAULT_BIT_RATE.
  53. */
  54. unsigned bit_rate;
  55. /**
  56. * Lyra required some additional (model) files, including
  57. * \b lyra_config.binarypb , \b lyragan.tflite , \b quantizer.tflite and
  58. * \b soundstream_encoder.tflite .
  59. * This setting represents the folder containing the above files.
  60. * The specified folder should contain these files. If an invalid folder
  61. * is provided, the codec creation will fail.
  62. */
  63. pj_str_t model_path;
  64. } pjmedia_codec_lyra_config;
  65. /**
  66. * Initialize and register lyra codec factory to pjmedia endpoint.
  67. *
  68. * @param endpt The pjmedia endpoint.
  69. *
  70. * @return PJ_SUCCESS on success.
  71. */
  72. PJ_DECL(pj_status_t) pjmedia_codec_lyra_init(pjmedia_endpt *endpt);
  73. /**
  74. * Unregister lyra codec factory from pjmedia endpoint and deinitialize
  75. * the lyra codec library.
  76. *
  77. * @return PJ_SUCCESS on success.
  78. */
  79. PJ_DECL(pj_status_t) pjmedia_codec_lyra_deinit(void);
  80. /**
  81. * Get the default Lyra configuration.
  82. *
  83. * @param cfg Lyra codec configuration.
  84. *
  85. * @return PJ_SUCCESS on success.
  86. */
  87. PJ_DECL(pj_status_t)
  88. pjmedia_codec_lyra_get_config( pjmedia_codec_lyra_config *cfg);
  89. /**
  90. * Set the default Lyra configuration.
  91. *
  92. * @param cfg Lyra codec configuration.
  93. *
  94. * @return PJ_SUCCESS on success.
  95. */
  96. PJ_DECL(pj_status_t)
  97. pjmedia_codec_lyra_set_config(const pjmedia_codec_lyra_config *cfg);
  98. PJ_END_DECL
  99. /**
  100. * @}
  101. */
  102. #endif /* __PJMEDIA_CODEC_LYRA_H__ */