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