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 #if (BTA_AV_INCLUDED == TRUE) 29 30 /***************************************************************************** 31 ** constants 32 *****************************************************************************/ 33 34 /* SBC packet header size */ 35 #define BTA_AV_SBC_HDR_SIZE A2D_SBC_MPL_HDR_LEN 36 37 /******************************************************************************* 38 ** 39 ** Function bta_av_sbc_init_up_sample 40 ** 41 ** Description initialize the up sample 42 ** 43 ** src_sps: samples per second (source audio data) 44 ** dst_sps: samples per second (converted audio data) 45 ** bits: number of bits per pcm sample 46 ** n_channels: number of channels (i.e. mono(1), stereo(2)...) 47 ** 48 ** Returns none 49 ** 50 *******************************************************************************/ 51 extern void bta_av_sbc_init_up_sample (UINT32 src_sps, UINT32 dst_sps, 52 UINT16 bits, UINT16 n_channels); 53 54 /******************************************************************************* 55 ** 56 ** Function bta_av_sbc_up_sample 57 ** 58 ** Description Given the source (p_src) audio data and 59 ** source speed (src_sps, samples per second), 60 ** This function converts it to audio data in the desired format 61 ** 62 ** p_src: the data buffer that holds the source audio data 63 ** p_dst: the data buffer to hold the converted audio data 64 ** src_samples: The number of source samples (number of bytes) 65 ** dst_samples: The size of p_dst (number of bytes) 66 ** 67 ** Note: An AE reported an issue with this function. 68 ** When called with bta_av_sbc_up_sample(src, uint8_array_dst..) 69 ** the byte before uint8_array_dst may get overwritten. 70 ** Using uint16_array_dst avoids the problem. 71 ** This issue is related to endian-ness and is hard to resolve 72 ** in a generic manner. 73 ** **************** Please use uint16 array as dst. 74 ** 75 ** Returns The number of bytes used in p_dst 76 ** The number of bytes used in p_src (in *p_ret) 77 ** 78 *******************************************************************************/ 79 extern int bta_av_sbc_up_sample (void *p_src, void *p_dst, 80 UINT32 src_samples, UINT32 dst_samples, 81 UINT32 *p_ret); 82 83 /******************************************************************************* 84 ** 85 ** Function bta_av_sbc_up_sample_16s (16bits-stereo) 86 ** 87 ** Description Given the source (p_src) audio data and 88 ** source speed (src_sps, samples per second), 89 ** This function converts it to audio data in the desired format 90 ** 91 ** p_src: the data buffer that holds the source audio data 92 ** p_dst: the data buffer to hold the converted audio data 93 ** src_samples: The number of source samples (in uint of 4 bytes) 94 ** dst_samples: The size of p_dst (in uint of 4 bytes) 95 ** 96 ** Returns The number of bytes used in p_dst 97 ** The number of bytes used in p_src (in *p_ret) 98 ** 99 *******************************************************************************/ 100 extern int bta_av_sbc_up_sample_16s (void *p_src, void *p_dst, 101 UINT32 src_samples, UINT32 dst_samples, 102 UINT32 *p_ret); 103 104 /******************************************************************************* 105 ** 106 ** Function bta_av_sbc_up_sample_16m (16bits-mono) 107 ** 108 ** Description Given the source (p_src) audio data and 109 ** source speed (src_sps, samples per second), 110 ** This function converts it to audio data in the desired format 111 ** 112 ** p_src: the data buffer that holds the source audio data 113 ** p_dst: the data buffer to hold the converted audio data 114 ** src_samples: The number of source samples (in uint of 2 bytes) 115 ** dst_samples: The size of p_dst (in uint of 2 bytes) 116 ** 117 ** Returns The number of bytes used in p_dst 118 ** The number of bytes used in p_src (in *p_ret) 119 ** 120 *******************************************************************************/ 121 extern int bta_av_sbc_up_sample_16m (void *p_src, void *p_dst, 122 UINT32 src_samples, UINT32 dst_samples, 123 UINT32 *p_ret); 124 125 /******************************************************************************* 126 ** 127 ** Function bta_av_sbc_up_sample_8s (8bits-stereo) 128 ** 129 ** Description Given the source (p_src) audio data and 130 ** source speed (src_sps, samples per second), 131 ** This function converts it to audio data in the desired format 132 ** 133 ** p_src: the data buffer that holds the source audio data 134 ** p_dst: the data buffer to hold the converted audio data 135 ** src_samples: The number of source samples (in uint of 2 bytes) 136 ** dst_samples: The size of p_dst (in uint of 2 bytes) 137 ** 138 ** Returns The number of bytes used in p_dst 139 ** The number of bytes used in p_src (in *p_ret) 140 ** 141 *******************************************************************************/ 142 extern int bta_av_sbc_up_sample_8s (void *p_src, void *p_dst, 143 UINT32 src_samples, UINT32 dst_samples, 144 UINT32 *p_ret); 145 146 /******************************************************************************* 147 ** 148 ** Function bta_av_sbc_up_sample_8m (8bits-mono) 149 ** 150 ** Description Given the source (p_src) audio data and 151 ** source speed (src_sps, samples per second), 152 ** This function converts it to audio data in the desired format 153 ** 154 ** p_src: the data buffer that holds the source audio data 155 ** p_dst: the data buffer to hold the converted audio data 156 ** src_samples: The number of source samples (number of bytes) 157 ** dst_samples: The size of p_dst (number of bytes) 158 ** 159 ** Returns The number of bytes used in p_dst 160 ** The number of bytes used in p_src (in *p_ret) 161 ** 162 *******************************************************************************/ 163 extern int bta_av_sbc_up_sample_8m (void *p_src, void *p_dst, 164 UINT32 src_samples, UINT32 dst_samples, 165 UINT32 *p_ret); 166 167 /******************************************************************************* 168 ** 169 ** Function bta_av_sbc_cfg_for_cap 170 ** 171 ** Description Determine the preferred SBC codec configuration for the 172 ** given codec capabilities. The function is passed the 173 ** preferred codec configuration and the peer codec 174 ** capabilities for the stream. The function attempts to 175 ** match the preferred capabilities with the configuration 176 ** as best it can. The resulting codec configuration is 177 ** returned in the same memory used for the capabilities. 178 ** 179 ** Returns 0 if ok, nonzero if error. 180 ** Codec configuration in p_cap. 181 ** 182 *******************************************************************************/ 183 extern UINT8 bta_av_sbc_cfg_for_cap(UINT8 *p_peer, tA2D_SBC_CIE *p_cap, tA2D_SBC_CIE *p_pref); 184 185 /******************************************************************************* 186 ** 187 ** Function bta_av_sbc_cfg_in_cap 188 ** 189 ** Description This function checks whether an SBC codec configuration 190 ** is allowable for the given codec capabilities. 191 ** 192 ** Returns 0 if ok, nonzero if error. 193 ** 194 *******************************************************************************/ 195 extern UINT8 bta_av_sbc_cfg_in_cap(UINT8 *p_cfg, tA2D_SBC_CIE *p_cap); 196 197 /******************************************************************************* 198 ** 199 ** Function bta_av_sbc_cfg_matches_cap 200 ** 201 ** Description This function checks whether an SBC codec configuration 202 ** matched with capabilities. Here we check subset. 203 ** 204 ** Returns 0 if ok, nonzero if error. 205 ** 206 *******************************************************************************/ 207 extern UINT8 bta_av_sbc_cfg_matches_cap(UINT8 *p_cfg, tA2D_SBC_CIE *p_cap); 208 209 /******************************************************************************* 210 ** 211 ** Function bta_av_sbc_bld_hdr 212 ** 213 ** Description This function builds the packet header for MPF1. 214 ** 215 ** Returns void 216 ** 217 *******************************************************************************/ 218 extern void bta_av_sbc_bld_hdr(BT_HDR *p_buf, UINT16 fr_per_pkt); 219 220 #endif ///BTA_AV_INCLUDED == TRUE 221 222 #endif /* BTA_AV_SBC_H */ 223