OSDN Git Service

sbc: Add Intel copyright to public header file
[android-x86/external-bluetooth-sbc.git] / sbc / sbc.h
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
28 #ifndef __SBC_H
29 #define __SBC_H
30
31 #ifdef __cplusplus
32 extern "C" {
33 #endif
34
35 #include <stdint.h>
36 #include <sys/types.h>
37
38 /* sampling frequency */
39 #define SBC_FREQ_16000          0x00
40 #define SBC_FREQ_32000          0x01
41 #define SBC_FREQ_44100          0x02
42 #define SBC_FREQ_48000          0x03
43
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
50 /* channel mode */
51 #define SBC_MODE_MONO           0x00
52 #define SBC_MODE_DUAL_CHANNEL   0x01
53 #define SBC_MODE_STEREO         0x02
54 #define SBC_MODE_JOINT_STEREO   0x03
55
56 /* allocation method */
57 #define SBC_AM_LOUDNESS         0x00
58 #define SBC_AM_SNR              0x01
59
60 /* subbands */
61 #define SBC_SB_4                0x00
62 #define SBC_SB_8                0x01
63
64 /* data endianess */
65 #define SBC_LE                  0x00
66 #define SBC_BE                  0x01
67
68 struct sbc_struct {
69         unsigned long flags;
70
71         uint8_t frequency;
72         uint8_t blocks;
73         uint8_t subbands;
74         uint8_t mode;
75         uint8_t allocation;
76         uint8_t bitpool;
77         uint8_t endian;
78
79         void *priv;
80         void *priv_alloc_base;
81 };
82
83 typedef struct sbc_struct sbc_t;
84
85 int sbc_init(sbc_t *sbc, unsigned long flags);
86 int sbc_reinit(sbc_t *sbc, unsigned long flags);
87 int sbc_init_msbc(sbc_t *sbc, unsigned long flags);
88 int sbc_init_a2dp(sbc_t *sbc, unsigned long flags,
89                                         const void *conf, size_t conf_len);
90
91 ssize_t sbc_parse(sbc_t *sbc, const void *input, size_t input_len);
92
93 /* Decodes ONE input block into ONE output block */
94 ssize_t sbc_decode(sbc_t *sbc, const void *input, size_t input_len,
95                         void *output, size_t output_len, size_t *written);
96
97 /* Encodes ONE input block into ONE output block */
98 ssize_t sbc_encode(sbc_t *sbc, const void *input, size_t input_len,
99                         void *output, size_t output_len, ssize_t *written);
100
101 /* Returns the output block size in bytes */
102 size_t sbc_get_frame_length(sbc_t *sbc);
103
104 /* Returns the time one input/output block takes to play in msec*/
105 unsigned sbc_get_frame_duration(sbc_t *sbc);
106
107 /* Returns the input block size in bytes */
108 size_t sbc_get_codesize(sbc_t *sbc);
109
110 const char *sbc_get_implementation_info(sbc_t *sbc);
111 void sbc_finish(sbc_t *sbc);
112
113 #ifdef __cplusplus
114 }
115 #endif
116
117 #endif /* __SBC_H */