15738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/******************************************************************************
25738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project *
35738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project *  Copyright (C) 2004-2012 Broadcom Corporation
45738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project *
55738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project *  Licensed under the Apache License, Version 2.0 (the "License");
65738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project *  you may not use this file except in compliance with the License.
75738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project *  You may obtain a copy of the License at:
85738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project *
95738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project *  http://www.apache.org/licenses/LICENSE-2.0
105738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project *
115738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project *  Unless required by applicable law or agreed to in writing, software
125738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project *  distributed under the License is distributed on an "AS IS" BASIS,
135738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
145738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project *  See the License for the specific language governing permissions and
155738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project *  limitations under the License.
165738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project *
175738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project ******************************************************************************/
185738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
195738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/******************************************************************************
205738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project *
215738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project *  This is the interface to utility functions for dealing with SBC data
225738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project *  frames and codec capabilities.
235738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project *
245738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project ******************************************************************************/
255738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#ifndef BTA_AV_SBC_H
265738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#define BTA_AV_SBC_H
275738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
285738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/*****************************************************************************
295738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**  constants
305738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project*****************************************************************************/
315738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
325738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/* SBC packet header size */
335738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#define BTA_AV_SBC_HDR_SIZE         A2D_SBC_MPL_HDR_LEN
345738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
355738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/*******************************************************************************
365738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**
375738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Function         bta_av_sbc_init_up_sample
385738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**
395738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Description      initialize the up sample
405738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**
415738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**                  src_sps: samples per second (source audio data)
425738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**                  dst_sps: samples per second (converted audio data)
435738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**                  bits: number of bits per pcm sample
445738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**                  n_channels: number of channels (i.e. mono(1), stereo(2)...)
455738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**
465738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Returns          none
475738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**
485738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project*******************************************************************************/
495738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectextern void bta_av_sbc_init_up_sample (UINT32 src_sps, UINT32 dst_sps,
505738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                                       UINT16 bits, UINT16 n_channels);
515738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
525738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/*******************************************************************************
535738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**
545738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Function         bta_av_sbc_up_sample
555738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**
565738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Description      Given the source (p_src) audio data and
575738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**                  source speed (src_sps, samples per second),
585738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**                  This function converts it to audio data in the desired format
595738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**
605738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**                  p_src: the data buffer that holds the source audio data
615738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**                  p_dst: the data buffer to hold the converted audio data
625738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**                  src_samples: The number of source samples (number of bytes)
635738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**                  dst_samples: The size of p_dst (number of bytes)
645738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**
655738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Note:            An AE reported an issue with this function.
665738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**                  When called with bta_av_sbc_up_sample(src, uint8_array_dst..)
675738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**                  the byte before uint8_array_dst may get overwritten.
685738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**                  Using uint16_array_dst avoids the problem.
695738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**                  This issue is related to endian-ness and is hard to resolve
705738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**                  in a generic manner.
715738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** **************** Please use uint16 array as dst.
725738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**
735738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Returns          The number of bytes used in p_dst
745738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**                  The number of bytes used in p_src (in *p_ret)
755738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**
765738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project*******************************************************************************/
775738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectextern int bta_av_sbc_up_sample (void *p_src, void *p_dst,
785738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                                 UINT32 src_samples, UINT32 dst_samples,
795738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                                 UINT32 *p_ret);
805738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
815738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/*******************************************************************************
825738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**
835738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Function         bta_av_sbc_up_sample_16s (16bits-stereo)
845738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**
855738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Description      Given the source (p_src) audio data and
865738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**                  source speed (src_sps, samples per second),
875738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**                  This function converts it to audio data in the desired format
885738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**
895738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**                  p_src: the data buffer that holds the source audio data
905738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**                  p_dst: the data buffer to hold the converted audio data
915738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**                  src_samples: The number of source samples (in uint of 4 bytes)
925738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**                  dst_samples: The size of p_dst (in uint of 4 bytes)
935738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**
945738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Returns          The number of bytes used in p_dst
955738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**                  The number of bytes used in p_src (in *p_ret)
965738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**
975738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project*******************************************************************************/
985738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectextern int bta_av_sbc_up_sample_16s (void *p_src, void *p_dst,
995738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                                 UINT32 src_samples, UINT32 dst_samples,
1005738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                                 UINT32 *p_ret);
1015738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
1025738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/*******************************************************************************
1035738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**
1045738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Function         bta_av_sbc_up_sample_16m (16bits-mono)
1055738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**
1065738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Description      Given the source (p_src) audio data and
1075738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**                  source speed (src_sps, samples per second),
1085738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**                  This function converts it to audio data in the desired format
1095738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**
1105738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**                  p_src: the data buffer that holds the source audio data
1115738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**                  p_dst: the data buffer to hold the converted audio data
1125738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**                  src_samples: The number of source samples (in uint of 2 bytes)
1135738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**                  dst_samples: The size of p_dst (in uint of 2 bytes)
1145738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**
1155738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Returns          The number of bytes used in p_dst
1165738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**                  The number of bytes used in p_src (in *p_ret)
1175738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**
1185738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project*******************************************************************************/
1195738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectextern int bta_av_sbc_up_sample_16m (void *p_src, void *p_dst,
1205738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                                     UINT32 src_samples, UINT32 dst_samples,
1215738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                                     UINT32 *p_ret);
1225738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
1235738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/*******************************************************************************
1245738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**
1255738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Function         bta_av_sbc_up_sample_8s (8bits-stereo)
1265738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**
1275738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Description      Given the source (p_src) audio data and
1285738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**                  source speed (src_sps, samples per second),
1295738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**                  This function converts it to audio data in the desired format
1305738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**
1315738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**                  p_src: the data buffer that holds the source audio data
1325738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**                  p_dst: the data buffer to hold the converted audio data
1335738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**                  src_samples: The number of source samples (in uint of 2 bytes)
1345738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**                  dst_samples: The size of p_dst (in uint of 2 bytes)
1355738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**
1365738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Returns          The number of bytes used in p_dst
1375738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**                  The number of bytes used in p_src (in *p_ret)
1385738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**
1395738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project*******************************************************************************/
1405738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectextern int bta_av_sbc_up_sample_8s (void *p_src, void *p_dst,
1415738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                                 UINT32 src_samples, UINT32 dst_samples,
1425738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                                 UINT32 *p_ret);
1435738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
1445738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/*******************************************************************************
1455738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**
1465738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Function         bta_av_sbc_up_sample_8m (8bits-mono)
1475738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**
1485738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Description      Given the source (p_src) audio data and
1495738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**                  source speed (src_sps, samples per second),
1505738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**                  This function converts it to audio data in the desired format
1515738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**
1525738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**                  p_src: the data buffer that holds the source audio data
1535738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**                  p_dst: the data buffer to hold the converted audio data
1545738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**                  src_samples: The number of source samples (number of bytes)
1555738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**                  dst_samples: The size of p_dst (number of bytes)
1565738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**
1575738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Returns          The number of bytes used in p_dst
1585738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**                  The number of bytes used in p_src (in *p_ret)
1595738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**
1605738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project*******************************************************************************/
1615738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectextern int bta_av_sbc_up_sample_8m (void *p_src, void *p_dst,
1625738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                                     UINT32 src_samples, UINT32 dst_samples,
1635738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                                     UINT32 *p_ret);
1645738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
1655738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/*******************************************************************************
1665738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**
1675738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Function         bta_av_sbc_cfg_for_cap
1685738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**
1695738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Description      Determine the preferred SBC codec configuration for the
1705738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**                  given codec capabilities.  The function is passed the
1715738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**                  preferred codec configuration and the peer codec
1725738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**                  capabilities for the stream.  The function attempts to
1735738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**                  match the preferred capabilities with the configuration
1745738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**                  as best it can.  The resulting codec configuration is
1755738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**                  returned in the same memory used for the capabilities.
1765738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**
1775738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Returns          0 if ok, nonzero if error.
1785738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**                  Codec configuration in p_cap.
1795738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**
1805738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project*******************************************************************************/
1815738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectextern UINT8 bta_av_sbc_cfg_for_cap(UINT8 *p_peer, tA2D_SBC_CIE *p_cap, tA2D_SBC_CIE *p_pref);
1825738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
1835738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/*******************************************************************************
1845738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**
1855738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Function         bta_av_sbc_cfg_in_cap
1865738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**
1875738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Description      This function checks whether an SBC codec configuration
1885738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**                  is allowable for the given codec capabilities.
1895738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**
1905738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Returns          0 if ok, nonzero if error.
1915738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**
1925738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project*******************************************************************************/
1935738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectextern UINT8 bta_av_sbc_cfg_in_cap(UINT8 *p_cfg, tA2D_SBC_CIE *p_cap);
1945738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
1955738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/*******************************************************************************
1965738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**
1975738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Function         bta_av_sbc_bld_hdr
1985738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**
1995738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Description      This function builds the packet header for MPF1.
2005738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**
2015738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Returns          void
2025738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**
2035738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project*******************************************************************************/
2045738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectextern void bta_av_sbc_bld_hdr(BT_HDR *p_buf, UINT16 fr_per_pkt);
2055738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
2065738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#endif /* BTA_AV_SBC_H */
2075738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
208