1 /****************************************************************************** 2 * 3 * Copyright (C) 2000-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 * nterface to low complexity subband codec (SBC) 22 * 23 ******************************************************************************/ 24 #ifndef A2D_SBC_H 25 #define A2D_SBC_H 26 #if (A2D_INCLUDED == TRUE) 27 /***************************************************************************** 28 ** Constants 29 *****************************************************************************/ 30 /* the length of the SBC Media Payload header. */ 31 #define A2D_SBC_MPL_HDR_LEN 1 32 33 /* the LOSC of SBC media codec capabilitiy */ 34 #define A2D_SBC_INFO_LEN 6 35 36 /* for Codec Specific Information Element */ 37 #define A2D_SBC_IE_SAMP_FREQ_MSK 0xF0 /* b7-b4 sampling frequency */ 38 #define A2D_SBC_IE_SAMP_FREQ_16 0x80 /* b7:16 kHz */ 39 #define A2D_SBC_IE_SAMP_FREQ_32 0x40 /* b6:32 kHz */ 40 #define A2D_SBC_IE_SAMP_FREQ_44 0x20 /* b5:44.1kHz */ 41 #define A2D_SBC_IE_SAMP_FREQ_48 0x10 /* b4:48 kHz */ 42 43 #define A2D_SBC_IE_CH_MD_MSK 0x0F /* b3-b0 channel mode */ 44 #define A2D_SBC_IE_CH_MD_MONO 0x08 /* b3: mono */ 45 #define A2D_SBC_IE_CH_MD_DUAL 0x04 /* b2: dual */ 46 #define A2D_SBC_IE_CH_MD_STEREO 0x02 /* b1: stereo */ 47 #define A2D_SBC_IE_CH_MD_JOINT 0x01 /* b0: joint stereo */ 48 49 #define A2D_SBC_IE_BLOCKS_MSK 0xF0 /* b7-b4 number of blocks */ 50 #define A2D_SBC_IE_BLOCKS_4 0x80 /* 4 blocks */ 51 #define A2D_SBC_IE_BLOCKS_8 0x40 /* 8 blocks */ 52 #define A2D_SBC_IE_BLOCKS_12 0x20 /* 12blocks */ 53 #define A2D_SBC_IE_BLOCKS_16 0x10 /* 16blocks */ 54 55 #define A2D_SBC_IE_SUBBAND_MSK 0x0C /* b3-b2 number of subbands */ 56 #define A2D_SBC_IE_SUBBAND_4 0x08 /* b3: 4 */ 57 #define A2D_SBC_IE_SUBBAND_8 0x04 /* b2: 8 */ 58 59 #define A2D_SBC_IE_ALLOC_MD_MSK 0x03 /* b1-b0 allocation mode */ 60 #define A2D_SBC_IE_ALLOC_MD_S 0x02 /* b1: SNR */ 61 #define A2D_SBC_IE_ALLOC_MD_L 0x01 /* b0: loundess */ 62 63 #define A2D_SBC_IE_MIN_BITPOOL 2 64 #define A2D_SBC_IE_MAX_BITPOOL 250 65 66 /* for media payload header */ 67 #define A2D_SBC_HDR_F_MSK 0x80 68 #define A2D_SBC_HDR_S_MSK 0x40 69 #define A2D_SBC_HDR_L_MSK 0x20 70 #define A2D_SBC_HDR_NUM_MSK 0x0F 71 72 /***************************************************************************** 73 ** Type Definitions 74 *****************************************************************************/ 75 76 /* data type for the SBC Codec Information Element*/ 77 typedef struct { 78 UINT8 samp_freq; /* Sampling frequency */ 79 UINT8 ch_mode; /* Channel mode */ 80 UINT8 block_len; /* Block length */ 81 UINT8 num_subbands; /* Number of subbands */ 82 UINT8 alloc_mthd; /* Allocation method */ 83 UINT8 max_bitpool; /* Maximum bitpool */ 84 UINT8 min_bitpool; /* Minimum bitpool */ 85 } tA2D_SBC_CIE; 86 87 88 /***************************************************************************** 89 ** External Function Declarations 90 *****************************************************************************/ 91 #ifdef __cplusplus 92 extern "C" 93 { 94 #endif 95 /****************************************************************************** 96 ** 97 ** Function A2D_BldSbcInfo 98 ** 99 ** Description This function is called by an application to build 100 ** the SBC Media Codec Capabilities byte sequence 101 ** beginning from the LOSC octet. 102 ** Input Parameters: 103 ** media_type: Indicates Audio, or Multimedia. 104 ** 105 ** p_ie: The SBC Codec Information Element information. 106 ** 107 ** Output Parameters: 108 ** p_result: the resulting codec info byte sequence. 109 ** 110 ** Returns A2D_SUCCESS if function execution succeeded. 111 ** Error status code, otherwise. 112 ******************************************************************************/ 113 extern tA2D_STATUS A2D_BldSbcInfo(UINT8 media_type, tA2D_SBC_CIE *p_ie, 114 UINT8 *p_result); 115 116 /****************************************************************************** 117 ** 118 ** Function A2D_ParsSbcInfo 119 ** 120 ** Description This function is called by an application to parse 121 ** the SBC Media Codec Capabilities byte sequence 122 ** beginning from the LOSC octet. 123 ** Input Parameters: 124 ** p_info: the byte sequence to parse. 125 ** 126 ** for_caps: TRUE, if the byte sequence is for get capabilities response. 127 ** 128 ** Output Parameters: 129 ** p_ie: The SBC Codec Information Element information. 130 ** 131 ** Returns A2D_SUCCESS if function execution succeeded. 132 ** Error status code, otherwise. 133 ******************************************************************************/ 134 extern tA2D_STATUS A2D_ParsSbcInfo(tA2D_SBC_CIE *p_ie, UINT8 *p_info, 135 BOOLEAN for_caps); 136 137 /****************************************************************************** 138 ** 139 ** Function A2D_BldSbcMplHdr 140 ** 141 ** Description This function is called by an application to parse 142 ** the SBC Media Payload header. 143 ** Input Parameters: 144 ** frag: 1, if fragmented. 0, otherwise. 145 ** 146 ** start: 1, if the starting packet of a fragmented frame. 147 ** 148 ** last: 1, if the last packet of a fragmented frame. 149 ** 150 ** num: If frag is 1, this is the number of remaining fragments 151 ** (including this fragment) of this frame. 152 ** If frag is 0, this is the number of frames in this packet. 153 ** 154 ** Output Parameters: 155 ** p_dst: the resulting media payload header byte sequence. 156 ** 157 ** Returns void. 158 ******************************************************************************/ 159 extern void A2D_BldSbcMplHdr(UINT8 *p_dst, BOOLEAN frag, BOOLEAN start, 160 BOOLEAN last, UINT8 num); 161 162 /****************************************************************************** 163 ** 164 ** Function A2D_ParsSbcMplHdr 165 ** 166 ** Description This function is called by an application to parse 167 ** the SBC Media Payload header. 168 ** Input Parameters: 169 ** p_src: the byte sequence to parse.. 170 ** 171 ** Output Parameters: 172 ** frag: 1, if fragmented. 0, otherwise. 173 ** 174 ** start: 1, if the starting packet of a fragmented frame. 175 ** 176 ** last: 1, if the last packet of a fragmented frame. 177 ** 178 ** num: If frag is 1, this is the number of remaining fragments 179 ** (including this fragment) of this frame. 180 ** If frag is 0, this is the number of frames in this packet. 181 ** 182 ** Returns void. 183 ******************************************************************************/ 184 extern void A2D_ParsSbcMplHdr(UINT8 *p_src, BOOLEAN *p_frag, 185 BOOLEAN *p_start, BOOLEAN *p_last, 186 UINT8 *p_num); 187 #ifdef __cplusplus 188 } 189 #endif 190 191 #endif ///A2D_INCLUDED == TRUE 192 193 #endif /* A2D_SBC_H */ 194