• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /******************************************************************************
2  *
3  *  Copyright (C) 2004-2012 Broadcom Corporation
4  *
5  *  Licensed under the Apache License, Version 2.0 (the "License");
6  *  you may not use this file except in compliance with the License.
7  *  You may obtain a copy of the License at:
8  *
9  *  http://www.apache.org/licenses/LICENSE-2.0
10  *
11  *  Unless required by applicable law or agreed to in writing, software
12  *  distributed under the License is distributed on an "AS IS" BASIS,
13  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  *  See the License for the specific language governing permissions and
15  *  limitations under the License.
16  *
17  ******************************************************************************/
18 
19 /******************************************************************************
20  *
21  *  This is the interface to utility functions for dealing with SBC data
22  *  frames and codec capabilities.
23  *
24  ******************************************************************************/
25 #ifndef BTA_AV_SBC_H
26 #define BTA_AV_SBC_H
27 
28 /*****************************************************************************
29 **  constants
30 *****************************************************************************/
31 
32 /* SBC packet header size */
33 #define BTA_AV_SBC_HDR_SIZE         A2D_SBC_MPL_HDR_LEN
34 
35 /*******************************************************************************
36 **
37 ** Function         bta_av_sbc_init_up_sample
38 **
39 ** Description      initialize the up sample
40 **
41 **                  src_sps: samples per second (source audio data)
42 **                  dst_sps: samples per second (converted audio data)
43 **                  bits: number of bits per pcm sample
44 **                  n_channels: number of channels (i.e. mono(1), stereo(2)...)
45 **
46 ** Returns          none
47 **
48 *******************************************************************************/
49 extern void bta_av_sbc_init_up_sample (UINT32 src_sps, UINT32 dst_sps,
50                                        UINT16 bits, UINT16 n_channels);
51 
52 /*******************************************************************************
53 **
54 ** Function         bta_av_sbc_up_sample
55 **
56 ** Description      Given the source (p_src) audio data and
57 **                  source speed (src_sps, samples per second),
58 **                  This function converts it to audio data in the desired format
59 **
60 **                  p_src: the data buffer that holds the source audio data
61 **                  p_dst: the data buffer to hold the converted audio data
62 **                  src_samples: The number of source samples (number of bytes)
63 **                  dst_samples: The size of p_dst (number of bytes)
64 **
65 ** Note:            An AE reported an issue with this function.
66 **                  When called with bta_av_sbc_up_sample(src, uint8_array_dst..)
67 **                  the byte before uint8_array_dst may get overwritten.
68 **                  Using uint16_array_dst avoids the problem.
69 **                  This issue is related to endian-ness and is hard to resolve
70 **                  in a generic manner.
71 ** **************** Please use uint16 array as dst.
72 **
73 ** Returns          The number of bytes used in p_dst
74 **                  The number of bytes used in p_src (in *p_ret)
75 **
76 *******************************************************************************/
77 extern int bta_av_sbc_up_sample (void *p_src, void *p_dst,
78                                  UINT32 src_samples, UINT32 dst_samples,
79                                  UINT32 *p_ret);
80 
81 /*******************************************************************************
82 **
83 ** Function         bta_av_sbc_up_sample_16s (16bits-stereo)
84 **
85 ** Description      Given the source (p_src) audio data and
86 **                  source speed (src_sps, samples per second),
87 **                  This function converts it to audio data in the desired format
88 **
89 **                  p_src: the data buffer that holds the source audio data
90 **                  p_dst: the data buffer to hold the converted audio data
91 **                  src_samples: The number of source samples (in uint of 4 bytes)
92 **                  dst_samples: The size of p_dst (in uint of 4 bytes)
93 **
94 ** Returns          The number of bytes used in p_dst
95 **                  The number of bytes used in p_src (in *p_ret)
96 **
97 *******************************************************************************/
98 extern int bta_av_sbc_up_sample_16s (void *p_src, void *p_dst,
99                                  UINT32 src_samples, UINT32 dst_samples,
100                                  UINT32 *p_ret);
101 
102 /*******************************************************************************
103 **
104 ** Function         bta_av_sbc_up_sample_16m (16bits-mono)
105 **
106 ** Description      Given the source (p_src) audio data and
107 **                  source speed (src_sps, samples per second),
108 **                  This function converts it to audio data in the desired format
109 **
110 **                  p_src: the data buffer that holds the source audio data
111 **                  p_dst: the data buffer to hold the converted audio data
112 **                  src_samples: The number of source samples (in uint of 2 bytes)
113 **                  dst_samples: The size of p_dst (in uint of 2 bytes)
114 **
115 ** Returns          The number of bytes used in p_dst
116 **                  The number of bytes used in p_src (in *p_ret)
117 **
118 *******************************************************************************/
119 extern int bta_av_sbc_up_sample_16m (void *p_src, void *p_dst,
120                                      UINT32 src_samples, UINT32 dst_samples,
121                                      UINT32 *p_ret);
122 
123 /*******************************************************************************
124 **
125 ** Function         bta_av_sbc_up_sample_8s (8bits-stereo)
126 **
127 ** Description      Given the source (p_src) audio data and
128 **                  source speed (src_sps, samples per second),
129 **                  This function converts it to audio data in the desired format
130 **
131 **                  p_src: the data buffer that holds the source audio data
132 **                  p_dst: the data buffer to hold the converted audio data
133 **                  src_samples: The number of source samples (in uint of 2 bytes)
134 **                  dst_samples: The size of p_dst (in uint of 2 bytes)
135 **
136 ** Returns          The number of bytes used in p_dst
137 **                  The number of bytes used in p_src (in *p_ret)
138 **
139 *******************************************************************************/
140 extern int bta_av_sbc_up_sample_8s (void *p_src, void *p_dst,
141                                  UINT32 src_samples, UINT32 dst_samples,
142                                  UINT32 *p_ret);
143 
144 /*******************************************************************************
145 **
146 ** Function         bta_av_sbc_up_sample_8m (8bits-mono)
147 **
148 ** Description      Given the source (p_src) audio data and
149 **                  source speed (src_sps, samples per second),
150 **                  This function converts it to audio data in the desired format
151 **
152 **                  p_src: the data buffer that holds the source audio data
153 **                  p_dst: the data buffer to hold the converted audio data
154 **                  src_samples: The number of source samples (number of bytes)
155 **                  dst_samples: The size of p_dst (number of bytes)
156 **
157 ** Returns          The number of bytes used in p_dst
158 **                  The number of bytes used in p_src (in *p_ret)
159 **
160 *******************************************************************************/
161 extern int bta_av_sbc_up_sample_8m (void *p_src, void *p_dst,
162                                      UINT32 src_samples, UINT32 dst_samples,
163                                      UINT32 *p_ret);
164 
165 /*******************************************************************************
166 **
167 ** Function         bta_av_sbc_cfg_for_cap
168 **
169 ** Description      Determine the preferred SBC codec configuration for the
170 **                  given codec capabilities.  The function is passed the
171 **                  preferred codec configuration and the peer codec
172 **                  capabilities for the stream.  The function attempts to
173 **                  match the preferred capabilities with the configuration
174 **                  as best it can.  The resulting codec configuration is
175 **                  returned in the same memory used for the capabilities.
176 **
177 ** Returns          0 if ok, nonzero if error.
178 **                  Codec configuration in p_cap.
179 **
180 *******************************************************************************/
181 extern UINT8 bta_av_sbc_cfg_for_cap(UINT8 *p_peer, tA2D_SBC_CIE *p_cap, tA2D_SBC_CIE *p_pref);
182 
183 /*******************************************************************************
184 **
185 ** Function         bta_av_sbc_cfg_in_cap
186 **
187 ** Description      This function checks whether an SBC codec configuration
188 **                  is allowable for the given codec capabilities.
189 **
190 ** Returns          0 if ok, nonzero if error.
191 **
192 *******************************************************************************/
193 extern UINT8 bta_av_sbc_cfg_in_cap(UINT8 *p_cfg, tA2D_SBC_CIE *p_cap);
194 
195 /*******************************************************************************
196 **
197 ** Function         bta_av_sbc_cfg_matches_cap
198 **
199 ** Description      This function checks whether an SBC codec configuration
200 **                  matched with capabilities. Here we check subset.
201 **
202 ** Returns          0 if ok, nonzero if error.
203 **
204 *******************************************************************************/
205 extern UINT8 bta_av_sbc_cfg_matches_cap(UINT8 *p_cfg, tA2D_SBC_CIE *p_cap);
206 
207 /*******************************************************************************
208 **
209 ** Function         bta_av_sbc_bld_hdr
210 **
211 ** Description      This function builds the packet header for MPF1.
212 **
213 ** Returns          void
214 **
215 *******************************************************************************/
216 extern void bta_av_sbc_bld_hdr(BT_HDR *p_buf, UINT16 fr_per_pkt);
217 
218 #endif /* BTA_AV_SBC_H */
219 
220