sbc.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  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. /* sampling frequency */
  35. #define SBC_FREQ_16000 0x00
  36. #define SBC_FREQ_32000 0x01
  37. #define SBC_FREQ_44100 0x02
  38. #define SBC_FREQ_48000 0x03
  39. /* blocks */
  40. #define SBC_BLK_4 0x00
  41. #define SBC_BLK_8 0x01
  42. #define SBC_BLK_12 0x02
  43. #define SBC_BLK_16 0x03
  44. /* channel mode */
  45. #define SBC_MODE_MONO 0x00
  46. #define SBC_MODE_DUAL_CHANNEL 0x01
  47. #define SBC_MODE_STEREO 0x02
  48. #define SBC_MODE_JOINT_STEREO 0x03
  49. /* allocation method */
  50. #define SBC_AM_LOUDNESS 0x00
  51. #define SBC_AM_SNR 0x01
  52. /* subbands */
  53. #define SBC_SB_4 0x00
  54. #define SBC_SB_8 0x01
  55. /* data endianess */
  56. #define SBC_LE 0x00
  57. #define SBC_BE 0x01
  58. struct sbc_struct {
  59. unsigned long flags;
  60. uint8_t frequency;
  61. uint8_t blocks;
  62. uint8_t subbands;
  63. uint8_t mode;
  64. uint8_t allocation;
  65. uint8_t bitpool;
  66. uint8_t endian;
  67. void *priv;
  68. void *priv_alloc_base;
  69. };
  70. typedef struct sbc_struct sbc_t;
  71. int sbc_init(sbc_t *sbc, unsigned long flags);
  72. int sbc_reinit(sbc_t *sbc, unsigned long flags);
  73. int sbc_init_msbc(sbc_t *sbc, unsigned long flags);
  74. int sbc_init_a2dp(sbc_t *sbc, unsigned long flags,
  75. const void *conf, size_t conf_len);
  76. int sbc_reinit_a2dp(sbc_t *sbc, unsigned long flags,
  77. const void *conf, size_t conf_len);
  78. ssize_t sbc_parse(sbc_t *sbc, const void *input, size_t input_len);
  79. /* Decodes ONE input block into ONE output block */
  80. ssize_t sbc_decode(sbc_t *sbc, const void *input, size_t input_len,
  81. void *output, size_t output_len, size_t *written);
  82. /* Encodes ONE input block into ONE output block */
  83. ssize_t sbc_encode(sbc_t *sbc, const void *input, size_t input_len,
  84. void *output, size_t output_len, ssize_t *written);
  85. /* Returns the output block size in bytes */
  86. size_t sbc_get_frame_length(sbc_t *sbc);
  87. /* Returns the time one input/output block takes to play in msec*/
  88. unsigned sbc_get_frame_duration(sbc_t *sbc);
  89. /* Returns the input block size in bytes */
  90. size_t sbc_get_codesize(sbc_t *sbc);
  91. const char *sbc_get_implementation_info(sbc_t *sbc);
  92. void sbc_finish(sbc_t *sbc);
  93. #ifdef __cplusplus
  94. }
  95. #endif
  96. #endif /* __SBC_H */