Chisato Kenmochi | 9470443 | 2017-01-10 11:56:48 +0900 | [diff] [blame^] | 1 | /* |
| 2 | * Copyright (C) 2013 - 2016 Sony Corporation |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | #ifndef _LDACBT_H_ |
| 18 | #define _LDACBT_H_ |
| 19 | #ifdef __cplusplus |
| 20 | extern "C" { |
| 21 | #endif |
| 22 | #ifndef LDACBT_API |
| 23 | #define LDACBT_API |
| 24 | #endif /* LDACBT_API */ |
| 25 | |
| 26 | /* This file contains the definitions, declarations and macros for an implimentation of |
| 27 | * LDAC encode processing. |
| 28 | * |
| 29 | * The basic flow of the encode processing is as follows: |
| 30 | * - The program creates an handle of an LDAC api using ldacBT_get_handle(). |
| 31 | * - The program initialize the handle for encode using ldacBT_init_handle_encode(). |
| 32 | * - The program calls ldacBT_encode() to encode data. |
| 33 | * - If the program demands to control the Encode Quality Mode Index, then one of the following |
| 34 | * should be called: |
| 35 | * - ldacBT_set_eqmid() |
| 36 | * - ldacBT_alter_eqmid() |
| 37 | * - The program finishes the encoding with passing NULL to input pcm buffer for ldacBT_encode(), |
| 38 | * which enables the encoder to encode remaining data in its input buffers. |
| 39 | * - The handle may be closed using ldacBT_close_handle() then used again, or released with |
| 40 | * ldacBT_free_handle(). |
| 41 | * - The rest of the set functions should be called only if it is needed by the client. |
| 42 | * |
| 43 | * |
| 44 | * Note for an implimentation |
| 45 | * - Error processing |
| 46 | * When continuous processing for next frame is performed after error detection, following |
| 47 | * processing must be carried out using C function provided in the library. |
| 48 | * - Release of internal variables in encode processing using ldacBT_close_handle(). |
| 49 | * - Allocation and initialization of internal variables in encode processing using |
| 50 | * ldacBT_init_handle_encode(). |
| 51 | * Note that the encoded output for a few frames will not be present just after error recovery. |
| 52 | * |
| 53 | * - Resuming of the encode processing from an interruption |
| 54 | * In case of resuming of the encode processing from interruption (such as changing |
| 55 | * configuration, seeking and playback), initialization of internal variables in encode |
| 56 | * processing must be carried out as error processing described above. |
| 57 | * Note that the encoded output for a few frames will not be present just after initialization |
| 58 | * as above. |
| 59 | * |
| 60 | * |
| 61 | * Glossary |
| 62 | * channel_config_index (cci) |
| 63 | * The channel setting information for ldaclib. |
| 64 | * See ldacBT_cm_to_cci() to get value from channel_mode. |
| 65 | * |
| 66 | * channel_mode (cm) |
| 67 | * The channel setting information for LDAC specification of Bluetooth A2DP. |
| 68 | * See ldacBT_cci_to_cm() to get value from channel_config_index. |
| 69 | * |
| 70 | * ldac_transport_frame |
| 71 | * See LDAC specification of bluetooth A2DP. |
| 72 | * |
| 73 | * Maximum Transmission Unit (MTU) |
| 74 | * The minimum MTU that a L2CAP implementation for LDAC shall support is 679 bytes, because LDAC |
| 75 | * is optimized with 2-DH5 packet as its target. |
| 76 | * |
| 77 | * frame |
| 78 | * An audio signal sequence representing a certain number of PCM audio signals. |
| 79 | * Encoding and decoding are processed frame by frame in LDAC. Number of samples in a frame is |
| 80 | * determined by sampling frequency as described below. |
| 81 | * |
| 82 | * Sampling frequency and frame sample. |
| 83 | * Supported sampling frequencies are 44.1, 48, 88.2 and 96 kHz. |
| 84 | * The relationship between sampling frequency and frame sample in LDAC are shown below. |
| 85 | * -------------------------------------------------------- |
| 86 | * | sampling frequency [kHz] | 44.1 | 48 | 88.2 | 96 | |
| 87 | * | frame sample [samples/channel] | 128 | 256 | |
| 88 | * -------------------------------------------------------- |
| 89 | * Though the frame size varies in LDAC core as described in the table, the number of samples in |
| 90 | * input PCM signal for encoding is fixed to 128 sample/channel, and it is not affected by |
| 91 | * sampling frequency. |
| 92 | */ |
| 93 | #define LDACBT_ENC_LSU 128 |
| 94 | #define LDACBT_MAX_LSU 512 |
| 95 | |
| 96 | /* channel_config_index. |
| 97 | * Supported value are below. |
| 98 | */ |
| 99 | #define LDAC_CCI_MONO 0 /* MONO */ |
| 100 | #define LDAC_CCI_DUAL_CHANNEL 1 /* DUAL CHANNEL */ |
| 101 | #define LDAC_CCI_STEREO 2 /* STEREO */ |
| 102 | |
| 103 | /* PCM format. |
| 104 | * Supported PCM format are shown below. |
| 105 | * - LDACBT_SMPL_FMT_S16 : signed 16bits little endian. |
| 106 | * - LDACBT_SMPL_FMT_S24 : signed 24bits little endian. |
| 107 | * - LDACBT_SMPL_FMT_S32 : signed 32bits little endian. |
| 108 | * - LDACBT_SMPL_FMT_F32 : single-precision floating point. |
| 109 | * The data sequency must be interleaved format by 1 sample. |
| 110 | * Ex) 2 channel audio, the data sequences are aligned as below. |
| 111 | * seq : |L[0]|R[0]|L[1]|R[1]|... |
| 112 | */ |
| 113 | typedef enum { |
| 114 | LDACBT_SMPL_FMT_S16 = 0x2, |
| 115 | LDACBT_SMPL_FMT_S24 = 0x3, |
| 116 | LDACBT_SMPL_FMT_S32 = 0x4, |
| 117 | LDACBT_SMPL_FMT_F32 = 0x5, |
| 118 | } LDACBT_SMPL_FMT_T; |
| 119 | |
| 120 | /* Encode Quality Mode Index. (EQMID) |
| 121 | * The configuration of encoding in LDAC will be coordinated by "Encode Quality Mode Index" |
| 122 | * parameter. Configurable values are shown below. |
| 123 | * - LDACBT_EQMID_HQ : Encode setting for High Quality. |
| 124 | * - LDACBT_EQMID_SQ : Encode setting for Standard Quality. |
| 125 | * - LDACBT_EQMID_MQ : Encode setting for Mobile use Quality. |
| 126 | */ |
| 127 | enum { |
| 128 | LDACBT_EQMID_HQ = 0, |
| 129 | LDACBT_EQMID_SQ, |
| 130 | LDACBT_EQMID_MQ, |
| 131 | LDACBT_EQMID_NUM, /* terminater */ |
| 132 | }; |
| 133 | |
| 134 | /* Bit rates |
| 135 | * Bit rates in each EQMID are depend on sampling frequency. |
| 136 | * In this API specification, these relations are shown below. |
| 137 | * ___________________________________________ |
| 138 | * | | Sampling Frequency[kHz] | |
| 139 | * | EQMID | 44.1, 88.2 | 48, 96 | |
| 140 | * +-----------------+------------+------------+ |
| 141 | * | LDACBT_EQMID_HQ | 909kbps | 990kbps | |
| 142 | * | LDACBT_EQMID_SQ | 606kbps | 660kbps | |
| 143 | * | LDACBT_EQMID_MQ | 303kbps | 330kbps | |
| 144 | * ------------------------------------------- |
| 145 | */ |
| 146 | |
| 147 | /* Maximum size of the "ldac_transport_frame" sequence at transportation. */ |
| 148 | #define LDACBT_MAX_NBYTES 1024 /* byte */ |
| 149 | |
| 150 | /* Maximum number of channel for LDAC */ |
| 151 | #define LDAC_PRCNCH 2 |
| 152 | |
| 153 | /* LDAC handle type */ |
| 154 | typedef struct _st_ldacbt_handle * HANDLE_LDAC_BT; |
| 155 | |
| 156 | /* Allocation of LDAC handle. |
| 157 | * Format |
| 158 | * HANDLE_LDAC_BT ldacBT_get_handle( void ); |
| 159 | * Arguments |
| 160 | * None. |
| 161 | * Return value |
| 162 | * HANDLE_LDAC_BT for success, NULL for failure. |
| 163 | */ |
| 164 | LDACBT_API HANDLE_LDAC_BT ldacBT_get_handle( void ); |
| 165 | |
| 166 | /* Release of LDAC handle. |
| 167 | * Format |
| 168 | * void ldacBT_free_handle( HANDLE_LDAC_BT hLdacBt ); |
| 169 | * Arguments |
| 170 | * hLdacBt HANDLE_LDAC_BT LDAC handle. |
| 171 | * Return value |
| 172 | * None. |
| 173 | */ |
| 174 | LDACBT_API void ldacBT_free_handle( HANDLE_LDAC_BT hLdacBt ); |
| 175 | |
| 176 | /* Closing of initialized LDAC handle. |
| 177 | * Closed handle can be initialized and used again. |
| 178 | * Format |
| 179 | * void ldacBT_close_handle( HANDLE_LDAC_BT hLdacBt ); |
| 180 | * Arguments |
| 181 | * hLdacBt HANDLE_LDAC_BT LDAC handle. |
| 182 | * Return value |
| 183 | * None. |
| 184 | */ |
| 185 | LDACBT_API void ldacBT_close_handle( HANDLE_LDAC_BT hLdacBt ); |
| 186 | |
| 187 | /* Acquisition of the library version. |
| 188 | * Format |
| 189 | * int ldacBT_get_version( void ); |
| 190 | * Arguments |
| 191 | * None. |
| 192 | * Return value |
| 193 | * int : version number. |
| 194 | * 23-16 bit : major version |
| 195 | * 15- 8 bit : minor version |
| 196 | * 7- 0 bit : branch version |
| 197 | * Ex) 0x00010203 -> version 1.02.03 |
| 198 | */ |
| 199 | LDACBT_API int ldacBT_get_version( void ); |
| 200 | |
| 201 | /* Acquisition of the sampling frequency in current configuration. |
| 202 | * The LDAC handle must be initialized by API function ldacBT_init_handle_encode() prior to |
| 203 | * calling this function. |
| 204 | * Format |
| 205 | * int ldacBT_get_sampling_freq( HANDLE_LDAC_BT hLdacBt ); |
| 206 | * Arguments |
| 207 | * hLdacBt HANDLE_LDAC_BT LDAC handle. |
| 208 | * Return value |
| 209 | * int : sampling frequency in current configuration. -1 for failure. |
| 210 | */ |
| 211 | LDACBT_API int ldacBT_get_sampling_freq( HANDLE_LDAC_BT hLdacBt ); |
| 212 | |
| 213 | /* Acquisition of the Bit-rate. |
| 214 | * The LDAC handle must be initialized by API function ldacBT_init_handle_encode() prior to |
| 215 | * calling this function. |
| 216 | * Format |
| 217 | * int ldacBT_get_bitrate( HANDLE_LDAC_BT hLdacBt ); |
| 218 | * Arguments |
| 219 | * hLdacBt HANDLE_LDAC_BT LDAC handle. |
| 220 | * Return value |
| 221 | * int : Bit-rate for previously processed ldac_transport_frame for success. -1 for failure. |
| 222 | */ |
| 223 | LDACBT_API int ldacBT_get_bitrate( HANDLE_LDAC_BT hLdacBt ); |
| 224 | |
| 225 | /* Initialization of a LDAC handle for encode processing. |
| 226 | * The LDAC handle must be allocated by API function ldacBT_get_handle() prior to calling this API. |
| 227 | * "mtu" value should be configured to MTU size of AVDTP Transport Channel, which is determined by |
| 228 | * SRC and SNK devices in Bluetooth transmission. |
| 229 | * "eqmid" is configured to desired value of "Encode Quality Mode Index". |
| 230 | * "cm" is configured to channel_mode in LDAC, which is determined by SRC and SNK devices in |
| 231 | * Bluetooth transmission. |
| 232 | * "fmt" is configured to input pcm audio format. |
| 233 | * When the configuration of "mtu", "cm", or "sf" changed, the re-initialization is required. |
| 234 | * |
| 235 | * Format |
| 236 | * int ldacBT_init_handle_encode( HANDLE_LDAC_BT hLdacBt, int mtu, int eqmid, int cm, |
| 237 | * LDACBT_SMPL_FMT_T fmt, int sf ); |
| 238 | * Arguments |
| 239 | * hLdacBt HANDLE_LDAC_BT LDAC handle. |
| 240 | * mtu int MTU value. Unit:Byte. |
| 241 | * eqmid int Encode Quality Mode Index. |
| 242 | * cm int Information of the channel_mode. |
| 243 | * fmt LDACBT_SMPL_FMT_T Audio format type of input pcm. |
| 244 | * sf int Sampling frequency of input pcm. |
| 245 | * Return value |
| 246 | * int : 0 for success, -1 for failure. |
| 247 | */ |
| 248 | LDACBT_API int ldacBT_init_handle_encode( HANDLE_LDAC_BT hLdacBt, int mtu, int eqmid, int cm, |
| 249 | LDACBT_SMPL_FMT_T fmt, int sf ); |
| 250 | |
| 251 | /* Configuration of Encode Quality Mode Index. |
| 252 | * The LDAC handle must be initialized by API function ldacBT_init_handle_encode() prior to |
| 253 | * calling this function. |
| 254 | * The API function can be called at any time, after the completion of initializing. |
| 255 | * Format |
| 256 | * int ldacBT_set_eqmid( HANDLE_LDAC_BT hLdacBt, int eqmid ); |
| 257 | * Arguments |
| 258 | * hLdacBt HANDLE_LDAC_BT LDAC handle. |
| 259 | * eqmid int Encode Quality Mode Index. |
| 260 | * Return value |
| 261 | * int : 0 for success, -1 for failure. |
| 262 | */ |
| 263 | LDACBT_API int ldacBT_set_eqmid( HANDLE_LDAC_BT hLdacBt, int eqmid ); |
| 264 | |
| 265 | /* Acquisition of prescribed Encode Quality Mode Index in current configuration. |
| 266 | * The LDAC handle must be initialized by API function ldacBT_init_handle_encode() prior to |
| 267 | * calling this function. |
| 268 | * Format |
| 269 | * int ldacBT_get_eqmid( HANDLE_LDAC_BT hLdacBt ); |
| 270 | * Arguments |
| 271 | * hLdacBt HANDLE_LDAC_BT LDAC handle. |
| 272 | * Return value |
| 273 | * int : Encode Quality Mode Index for success, -1 for failure. |
| 274 | */ |
| 275 | LDACBT_API int ldacBT_get_eqmid( HANDLE_LDAC_BT hLdacBt ); |
| 276 | |
| 277 | /* Changing of configuration for Encode Quality Mode Index by one step. |
| 278 | * The LDAC handle must be initialized by API function ldacBT_init_handle_encode() prior to |
| 279 | * calling this function. |
| 280 | * Configuralbe values for "priority" are shown below. |
| 281 | * - LDACBT_EQMID_INC_QUALITY : Adjustment for EQMID by one step for the direction of |
| 282 | * getting close to LDACBT_EQMID_HQ. |
| 283 | * - LDACBT_EQMID_INC_CONNECTION : Adjustment for EQMID by one step for the direction of |
| 284 | * getting away from LDACBT_EQMID_HQ. |
| 285 | * For restoring prescribed value for "Encode Quality Mode Index", it must be configured again by |
| 286 | * API function ldacBT_init_handle_encode() or ldacBT_set_qmode(). |
| 287 | * A transition to the state other than "Encode Quality Mode Index" mention before may be occurred |
| 288 | * caused by an adjustment using this API function. |
| 289 | * The API function can be called at any time, after the completion of initializing. |
| 290 | * Format |
| 291 | * int ldacBT_alter_eqmid_priority( HANDLE_LDAC_BT hLdacBt, int priority ); |
| 292 | * Arguments |
| 293 | * hLdacBt HANDLE_LDAC_BT LDAC handle. |
| 294 | * priority int The direction of changing EQMID. |
| 295 | * Return value |
| 296 | * int : 0 for success, -1 for failure. |
| 297 | */ |
| 298 | #define LDACBT_EQMID_INC_QUALITY 1 |
| 299 | #define LDACBT_EQMID_INC_CONNECTION -1 |
| 300 | LDACBT_API int ldacBT_alter_eqmid_priority( HANDLE_LDAC_BT hLdacBt, int priority ); |
| 301 | |
| 302 | |
| 303 | /* LDAC encode processing. |
| 304 | * The LDAC handle must be initialized by API function ldacBT_init_handle_encode() prior to calling |
| 305 | * this API function. |
| 306 | * <Regarding on a input PCM signal> |
| 307 | * Number of samples in input PCM signal for encoding is fixed to 128 samples per channel, and it |
| 308 | * is not affected by sampling frequency. |
| 309 | * |
| 310 | * The region in input signal buffer without any PCM signal must be filled with zero, if the |
| 311 | * number of samples is less than 128 samples. |
| 312 | * |
| 313 | * The format of PCM signal is determined by "fmt" configured by API function |
| 314 | * ldacBT_init_handle_encode(). |
| 315 | * |
| 316 | * Total size of referenced PCM signal (in byte) will be set in "pcm_used" on return. The value of |
| 317 | * "Number of input samples * Number of channels * sizeof(PCM word length)" will be set in normal. |
| 318 | * |
| 319 | * Finalize processing of encode will be carried out with setting "p_pcm" as zero. |
| 320 | * |
| 321 | * <Regarding on output encoded data> |
| 322 | * An output data in "ldac_transport_frame" sequence will be set to "p_stream" after several frame |
| 323 | * processing. So the output is not necessarily present at each calling of this API function. |
| 324 | * |
| 325 | * The presence of the output can be verified by checking whether the value of "stream_wrote", |
| 326 | * representing the number of written bytes for "p_stream", is positive or not. |
| 327 | * |
| 328 | * In addition, encoded data size for output will be determined by the value of "mtu" configured |
| 329 | * by API function ldacBT_init_handle_encode(). |
| 330 | * |
| 331 | * The number of "ldac_transport_frame" corresponding to "ldac_transport_frame" sequence as output |
| 332 | * will be set to "frame_num". |
| 333 | * |
| 334 | * Format |
| 335 | * int ldacBT_encode( HANDLE_LDAC_BT hLdacBt, void *p_pcm, int *pcm_used, |
| 336 | * unsigned char *p_stream, int *stream_sz, int *frame_num ); |
| 337 | * Arguments |
| 338 | * hLdacBt HANDLE_LDAC_BT LDAC handle. |
| 339 | * p_pcm void * Input PCM signal sequence |
| 340 | * pcm_used int * Data size of referenced PCM singnal. Unit:Byte. |
| 341 | * p_stream unsigned char * Output "ldac_transport_frame" sequence. |
| 342 | * stream_sz int * Size of output data. Unit:Byte. |
| 343 | * frame_num int * Number of output "ldac_transport_frame" |
| 344 | * Return value |
| 345 | * int : 0 for success, -1 for failure. |
| 346 | */ |
| 347 | LDACBT_API int ldacBT_encode( HANDLE_LDAC_BT hLdacBt, void *p_pcm, int *pcm_used, |
| 348 | unsigned char *p_stream, int *stream_sz, int *frame_num ); |
| 349 | |
| 350 | /* Acquisition of previously established error code. |
| 351 | * The LDAC handle must be allocated by API function ldacBT_get_handle() prior to calling this function. |
| 352 | * The details of error code are described below at the end of this header file. |
| 353 | * Tips for error code handling. |
| 354 | * The macro function LDACBT_FATAL() is useful to determine whether the error code is Fatal or not. |
| 355 | * Ex.) if( LDACBT_FATAL(err) ) // Fatal Error occurred. |
| 356 | * |
| 357 | * The macro function LDACBT_ERROR() is useful to determine whether the error occurred or not. |
| 358 | * Ex.) if( LDACBT_ERROR(err) ) // Error occurred. |
| 359 | * |
| 360 | * The macro function LDACBT_HANDLE_ERR() is useful to get the handle level error code. |
| 361 | * Ex.) err_handle_lv = LDACBT_HANDLE_ERR(err); |
| 362 | * |
| 363 | * The macro function LDACBT_BLOCK_ERR() is useful to get the block level error code. |
| 364 | * Ex.) err_block_lv = LDACBT_BLOCK_ERR(err); |
| 365 | * |
| 366 | * Format |
| 367 | * int ldacBT_get_error_code( HANDLE_LDAC_BT hLdacBt ); |
| 368 | * Arguments |
| 369 | * hLdacBt HANDLE_LDAC_BT LDAC handle. |
| 370 | * Return value |
| 371 | * int : Error code. |
| 372 | */ |
| 373 | LDACBT_API int ldacBT_get_error_code( HANDLE_LDAC_BT hLdacBt ); |
| 374 | |
| 375 | /******************************************************************************* |
| 376 | Error Code |
| 377 | *******************************************************************************/ |
| 378 | #define LDACBT_ERR_NONE 0 |
| 379 | |
| 380 | /* Non Fatal Error ***********************************************************/ |
| 381 | #define LDACBT_ERR_NON_FATAL 1 |
| 382 | |
| 383 | /* Non Fatal Error (Block Level) *********************************************/ |
| 384 | #define LDACBT_ERR_BIT_ALLOCATION 5 |
| 385 | |
| 386 | /* Non Fatal Error (Handle Level) ********************************************/ |
| 387 | #define LDACBT_ERR_NOT_IMPLEMENTED 128 |
| 388 | #define LDACBT_ERR_NON_FATAL_ENCODE 132 |
| 389 | |
| 390 | /* Fatal Error ***************************************************************/ |
| 391 | #define LDACBT_ERR_FATAL 256 |
| 392 | |
| 393 | /* Fatal Error (Block Level) *************************************************/ |
| 394 | #define LDACBT_ERR_SYNTAX_BAND 260 |
| 395 | #define LDACBT_ERR_SYNTAX_GRAD_A 261 |
| 396 | #define LDACBT_ERR_SYNTAX_GRAD_B 262 |
| 397 | #define LDACBT_ERR_SYNTAX_GRAD_C 263 |
| 398 | #define LDACBT_ERR_SYNTAX_GRAD_D 264 |
| 399 | #define LDACBT_ERR_SYNTAX_GRAD_E 265 |
| 400 | #define LDACBT_ERR_SYNTAX_IDSF 266 |
| 401 | #define LDACBT_ERR_SYNTAX_SPEC 267 |
| 402 | |
| 403 | #define LDACBT_ERR_BIT_PACKING 280 |
| 404 | |
| 405 | #define LDACBT_ERR_ALLOC_MEMORY 300 |
| 406 | |
| 407 | /* Fatal Error (Handle Level) ************************************************/ |
| 408 | #define LDACBT_ERR_FATAL_HANDLE 512 |
| 409 | |
| 410 | #define LDACBT_ERR_ILL_SYNCWORD 516 |
| 411 | #define LDACBT_ERR_ILL_SMPL_FORMAT 517 |
| 412 | #define LDACBT_ERR_ILL_PARAM 518 |
| 413 | |
| 414 | #define LDACBT_ERR_ASSERT_SAMPLING_FREQ 530 |
| 415 | #define LDACBT_ERR_ASSERT_SUP_SAMPLING_FREQ 531 |
| 416 | #define LDACBT_ERR_CHECK_SAMPLING_FREQ 532 |
| 417 | #define LDACBT_ERR_ASSERT_CHANNEL_CONFIG 533 |
| 418 | #define LDACBT_ERR_CHECK_CHANNEL_CONFIG 534 |
| 419 | #define LDACBT_ERR_ASSERT_FRAME_LENGTH 535 |
| 420 | #define LDACBT_ERR_ASSERT_SUP_FRAME_LENGTH 536 |
| 421 | #define LDACBT_ERR_ASSERT_FRAME_STATUS 537 |
| 422 | #define LDACBT_ERR_ASSERT_NSHIFT 538 |
| 423 | #define LDACBT_ERR_ASSERT_CHANNEL_MODE 539 |
| 424 | |
| 425 | #define LDACBT_ERR_ENC_INIT_ALLOC 550 |
| 426 | #define LDACBT_ERR_ENC_ILL_GRADMODE 551 |
| 427 | #define LDACBT_ERR_ENC_ILL_GRADPAR_A 552 |
| 428 | #define LDACBT_ERR_ENC_ILL_GRADPAR_B 553 |
| 429 | #define LDACBT_ERR_ENC_ILL_GRADPAR_C 554 |
| 430 | #define LDACBT_ERR_ENC_ILL_GRADPAR_D 555 |
| 431 | #define LDACBT_ERR_ENC_ILL_NBANDS 556 |
| 432 | #define LDACBT_ERR_PACK_BLOCK_FAILED 557 |
| 433 | |
| 434 | #define LDACBT_ERR_DEC_INIT_ALLOC 570 |
| 435 | #define LDACBT_ERR_INPUT_BUFFER_SIZE 571 |
| 436 | #define LDACBT_ERR_UNPACK_BLOCK_FAILED 572 |
| 437 | #define LDACBT_ERR_UNPACK_BLOCK_ALIGN 573 |
| 438 | #define LDACBT_ERR_UNPACK_FRAME_ALIGN 574 |
| 439 | #define LDACBT_ERR_FRAME_LENGTH_OVER 575 |
| 440 | #define LDACBT_ERR_FRAME_ALIGN_OVER 576 |
| 441 | |
| 442 | |
| 443 | /* LDAC API for Encode */ |
| 444 | #define LDACBT_ERR_ALTER_EQMID_LIMITED 21 |
| 445 | #define LDACBT_ERR_HANDLE_NOT_INIT 1000 |
| 446 | #define LDACBT_ERR_ILL_EQMID 1024 |
| 447 | #define LDACBT_ERR_ILL_SAMPLING_FREQ 1025 |
| 448 | #define LDACBT_ERR_ILL_NUM_CHANNEL 1026 |
| 449 | #define LDACBT_ERR_ILL_MTU_SIZE 1027 |
| 450 | /* LDAC API for Decode */ |
| 451 | #define LDACBT_ERR_DEC_CONFIG_UPDATED 40 |
| 452 | |
| 453 | |
| 454 | /* Macro Functions for Error Code ********************************************/ |
| 455 | #define LDACBT_API_ERR(err) ((err >> 20) & 0x0FFF) |
| 456 | #define LDACBT_HANDLE_ERR(err) ((err >> 10) & 0x03FF) |
| 457 | #define LDACBT_BLOCK_ERR(err) ( err & 0x03FF) |
| 458 | #define LDACBT_ERROR(err) ((LDACBT_ERR_NON_FATAL) <= LDACBT_API_ERR(err) ? 1 : 0) |
| 459 | #define LDACBT_FATAL(err) ((LDACBT_ERR_FATAL) <= LDACBT_API_ERR(err) ? 1 : 0) |
| 460 | |
| 461 | |
| 462 | |
| 463 | /* Codec Specific Information Elements for LDAC |
| 464 | * (based on "LDAC Specification of Bluetooth A2DP Rev.2.0.1") |
| 465 | * | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 | |
| 466 | * service_caps[4] | SONY ID | Octet0 |
| 467 | * service_caps[5] | SONY ID | Octet1 |
| 468 | * service_caps[6] | SONY ID | Octet2 |
| 469 | * service_caps[7] | SONY ID | Octet3 |
| 470 | * service_caps[8] | SONY Specific Codec ID | Octet4 |
| 471 | * service_caps[9] | SONY Specific Codec ID | Octet5 |
| 472 | * service_caps[A] | RFA | Sampling Frequency | Octet6 |
| 473 | * service_caps[B] | RFA | Channel Mode ID | Octet7 |
| 474 | */ |
| 475 | #define LDACBT_MEDIA_CODEC_SC_SZ (10+2) |
| 476 | |
| 477 | /* [Octet 0-3] Vendor ID for SONY */ |
| 478 | #define LDACBT_VENDOR_ID0 0x2D |
| 479 | #define LDACBT_VENDOR_ID1 0x01 |
| 480 | #define LDACBT_VENDOR_ID2 0x0 |
| 481 | #define LDACBT_VENDOR_ID3 0x0 |
| 482 | |
| 483 | /* [Octet 4-5] Vendor Specific A2DP Codec ID for LDAC */ |
| 484 | #define LDACBT_CODEC_ID0 0xAA |
| 485 | #define LDACBT_CODEC_ID1 0x00 |
| 486 | |
| 487 | /* [Octet 6] |
| 488 | * [b7,b6] : RFA |
| 489 | * Reserved for future additions. |
| 490 | * Bits with this designation shall be set to zero. |
| 491 | * Receivers shall ignore these bits. |
| 492 | * ----------------------------------------------------- |
| 493 | * [b5-b0] : Sampling frequency and its associated bit field in LDAC are shown below. |
| 494 | * | 5 | 4 | 3 | 2 | 1 | 0 | |
| 495 | * | o | | | | | | 44100 |
| 496 | * | | o | | | | | 48000 |
| 497 | * | | | o | | | | 88200 |
| 498 | * | | | | o | | | 96000 |
| 499 | * | | | | | o | | 176400 |
| 500 | * | | | | | | o | 192000 |
| 501 | * |
| 502 | */ |
| 503 | /* Support for 44.1kHz sampling frequency */ |
| 504 | #define LDACBT_SAMPLING_FREQ_044100 0x20 |
| 505 | /* Support for 48kHz sampling frequency */ |
| 506 | #define LDACBT_SAMPLING_FREQ_048000 0x10 |
| 507 | /* Support for 88.2kHz sampling frequency */ |
| 508 | #define LDACBT_SAMPLING_FREQ_088200 0x08 |
| 509 | /* Support for 96kHz sampling frequency */ |
| 510 | #define LDACBT_SAMPLING_FREQ_096000 0x04 |
| 511 | /* Support for 176.4kHz sampling frequency */ |
| 512 | #define LDACBT_SAMPLING_FREQ_176400 0x02 |
| 513 | /* Support for 192kHz sampling frequency */ |
| 514 | #define LDACBT_SAMPLING_FREQ_192000 0x01 |
| 515 | |
| 516 | /* [Octet 7] |
| 517 | * [b7-b3] : RFA |
| 518 | * Reserved for future additions. |
| 519 | * Bits with this designation shall be set to zero. |
| 520 | * Receivers shall ignore these bits. |
| 521 | * ------------------------------------------------------ |
| 522 | * [b2-b0] : Channel mode and its associated bit field in LDAC are shown below. |
| 523 | * | 2 | 1 | 0 | |
| 524 | * | o | | | MONO |
| 525 | * | | o | | DUAL CHANNEL |
| 526 | * | | | o | STEREO |
| 527 | */ |
| 528 | /* Support for MONO */ |
| 529 | #define LDACBT_CHANNEL_MODE_MONO 0x04 |
| 530 | /* Support for DUAL CHANNEL */ |
| 531 | #define LDACBT_CHANNEL_MODE_DUAL_CHANNEL 0x02 |
| 532 | /* Support for STEREO */ |
| 533 | #define LDACBT_CHANNEL_MODE_STEREO 0x01 |
| 534 | |
| 535 | #ifdef __cplusplus |
| 536 | } |
| 537 | #endif |
| 538 | #endif /* _LDACBT_H_ */ |