sbc.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. /*
  2. *
  3. * Bluetooth low-complexity, subband codec (SBC) library
  4. *
  5. * Copyright (C) 2008-2010 Nokia Corporation
  6. * Copyright (C) 2012-2014 Intel Corporation
  7. * Copyright (C) 2004-2010 Marcel Holtmann <marcel@holtmann.org>
  8. * Copyright (C) 2004-2005 Henryk Ploetz <henryk@ploetzli.ch>
  9. * Copyright (C) 2005-2006 Brad Midgley <bmidgley@xmission.com>
  10. *
  11. *
  12. * This library is free software; you can redistribute it and/or
  13. * modify it under the terms of the GNU Lesser General Public
  14. * License as published by the Free Software Foundation; either
  15. * version 2.1 of the License, or (at your option) any later version.
  16. *
  17. * This library is distributed in the hope that it will be useful,
  18. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  19. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  20. * Lesser General Public License for more details.
  21. *
  22. * You should have received a copy of the GNU Lesser General Public
  23. * License along with this library; if not, write to the Free Software
  24. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  25. *
  26. */
  27. #ifndef __SBC_H
  28. #define __SBC_H
  29. #ifdef __cplusplus
  30. extern "C" {
  31. #endif
  32. #include <stdint.h>
  33. #include <sys/types.h>
  34. /* On MSVC, ssize_t is SSIZE_T */
  35. #ifdef _MSC_VER
  36. #include <BaseTsd.h>
  37. #define ssize_t SSIZE_T
  38. #endif
  39. /* sampling frequency */
  40. #define SBC_FREQ_16000 0x00
  41. #define SBC_FREQ_32000 0x01
  42. #define SBC_FREQ_44100 0x02
  43. #define SBC_FREQ_48000 0x03
  44. /* blocks */
  45. #define SBC_BLK_4 0x00
  46. #define SBC_BLK_8 0x01
  47. #define SBC_BLK_12 0x02
  48. #define SBC_BLK_16 0x03
  49. /* channel mode */
  50. #define SBC_MODE_MONO 0x00
  51. #define SBC_MODE_DUAL_CHANNEL 0x01
  52. #define SBC_MODE_STEREO 0x02
  53. #define SBC_MODE_JOINT_STEREO 0x03
  54. /* allocation method */
  55. #define SBC_AM_LOUDNESS 0x00
  56. #define SBC_AM_SNR 0x01
  57. /* subbands */
  58. #define SBC_SB_4 0x00
  59. #define SBC_SB_8 0x01
  60. /* data endianess */
  61. #define SBC_LE 0x00
  62. #define SBC_BE 0x01
  63. struct sbc_struct {
  64. unsigned long flags;
  65. uint8_t frequency;
  66. uint8_t blocks;
  67. uint8_t subbands;
  68. uint8_t mode;
  69. uint8_t allocation;
  70. uint8_t bitpool;
  71. uint8_t endian;
  72. void *priv;
  73. void *priv_alloc_base;
  74. };
  75. typedef struct sbc_struct sbc_t;
  76. int sbc_init(sbc_t *sbc, unsigned long flags);
  77. int sbc_reinit(sbc_t *sbc, unsigned long flags);
  78. int sbc_init_msbc(sbc_t *sbc, unsigned long flags);
  79. int sbc_init_a2dp(sbc_t *sbc, unsigned long flags,
  80. const void *conf, size_t conf_len);
  81. int sbc_reinit_a2dp(sbc_t *sbc, unsigned long flags,
  82. const void *conf, size_t conf_len);
  83. ssize_t sbc_parse(sbc_t *sbc, const void *input, size_t input_len);
  84. /* Decodes ONE input block into ONE output block */
  85. ssize_t sbc_decode(sbc_t *sbc, const void *input, size_t input_len,
  86. void *output, size_t output_len, size_t *written);
  87. /* Encodes ONE input block into ONE output block */
  88. ssize_t sbc_encode(sbc_t *sbc, const void *input, size_t input_len,
  89. void *output, size_t output_len, ssize_t *written);
  90. /* Returns the output block size in bytes */
  91. size_t sbc_get_frame_length(sbc_t *sbc);
  92. /* Returns the time one input/output block takes to play in msec*/
  93. unsigned sbc_get_frame_duration(sbc_t *sbc);
  94. /* Returns the input block size in bytes */
  95. size_t sbc_get_codesize(sbc_t *sbc);
  96. const char *sbc_get_implementation_info(sbc_t *sbc);
  97. void sbc_finish(sbc_t *sbc);
  98. #ifdef __cplusplus
  99. }
  100. #endif
  101. #endif /* __SBC_H */