a2d_api.h 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295
  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. * nterface to A2DP Application Programming Interface
  21. *
  22. ******************************************************************************/
  23. #ifndef A2D_API_H
  24. #define A2D_API_H
  25. #include "common/bt_defs.h"
  26. #include "stack/sdp_api.h"
  27. #if (A2D_INCLUDED == TRUE)
  28. /*****************************************************************************
  29. ** constants
  30. *****************************************************************************/
  31. #define A2D_VERSION 0x0102
  32. #define A2D_VERSION_1_3 0x0103
  33. #define A2D_VERSION_1_4 0x0104
  34. /* Profile supported features */
  35. #define A2D_SUPF_PLAYER 0x0001
  36. #define A2D_SUPF_MIC 0x0002
  37. #define A2D_SUPF_TUNER 0x0004
  38. #define A2D_SUPF_MIXER 0x0008
  39. #define A2D_SUPF_HEADPHONE 0x0001
  40. #define A2D_SUPF_SPEAKER 0x0002
  41. #define A2D_SUPF_RECORDER 0x0004
  42. #define A2D_SUPF_AMP 0x0008
  43. /* AV Media Types */
  44. #define A2D_MEDIA_TYPE_AUDIO 0x00 /* audio media type + RFA */
  45. #define A2D_MEDIA_TYPE_VIDEO 0x10 /* video media type + RFA */
  46. #define A2D_MEDIA_TYPE_MULTI 0x20 /* multimedia media type + RFA */
  47. /* AV Media Codec Type (Audio Codec ID) */
  48. #define A2D_MEDIA_CT_SBC 0x00 /* SBC media codec type */
  49. #define A2D_MEDIA_CT_M12 0x01 /* MPEG-1, 2 Audio media codec type */
  50. #define A2D_MEDIA_CT_M24 0x02 /* MPEG-2, 4 AAC media codec type */
  51. #define A2D_MEDIA_CT_ATRAC 0x04 /* ATRAC family media codec type */
  52. #define A2D_SUCCESS 0 /* Success */
  53. #define A2D_FAIL 0x0A /* Failed */
  54. #define A2D_BUSY 0x0B /* A2D_FindService is already in progress */
  55. #define A2D_INVALID_PARAMS 0x0C /* bad parameters */
  56. #define A2D_WRONG_CODEC 0x0D /* wrong codec info */
  57. #define A2D_BAD_CODEC_TYPE 0xC1 /* Media Codec Type is not valid */
  58. #define A2D_NS_CODEC_TYPE 0xC2 /* Media Codec Type is not supported */
  59. #define A2D_BAD_SAMP_FREQ 0xC3 /* Sampling Frequency is not valid or multiple values have been selected */
  60. #define A2D_NS_SAMP_FREQ 0xC4 /* Sampling Frequency is not supported */
  61. #define A2D_BAD_CH_MODE 0xC5 /* Channel Mode is not valid or multiple values have been selected */
  62. #define A2D_NS_CH_MODE 0xC6 /* Channel Mode is not supported */
  63. #define A2D_BAD_SUBBANDS 0xC7 /* None or multiple values have been selected for Number of Subbands */
  64. #define A2D_NS_SUBBANDS 0xC8 /* Number of Subbands is not supported */
  65. #define A2D_BAD_ALLOC_MTHD 0xC9 /* None or multiple values have been selected for Allocation Method */
  66. #define A2D_NS_ALLOC_MTHD 0xCA /* Allocation Method is not supported */
  67. #define A2D_BAD_MIN_BITPOOL 0xCB /* Minimum Bitpool Value is not valid */
  68. #define A2D_NS_MIN_BITPOOL 0xCC /* Minimum Bitpool Value is not supported */
  69. #define A2D_BAD_MAX_BITPOOL 0xCD /* Maximum Bitpool Value is not valid */
  70. #define A2D_NS_MAX_BITPOOL 0xCE /* Maximum Bitpool Value is not supported */
  71. #define A2D_BAD_LAYER 0xCF /* None or multiple values have been selected for Layer */
  72. #define A2D_NS_LAYER 0xD0 /* Layer is not supported */
  73. #define A2D_NS_CRC 0xD1 /* CRC is not supported */
  74. #define A2D_NS_MPF 0xD2 /* MPF-2 is not supported */
  75. #define A2D_NS_VBR 0xD3 /* VBR is not supported */
  76. #define A2D_BAD_BIT_RATE 0xD4 /* None or multiple values have been selected for Bit Rate */
  77. #define A2D_NS_BIT_RATE 0xD5 /* Bit Rate is not supported */
  78. #define A2D_BAD_OBJ_TYPE 0xD6 /* Either 1) Object type is not valid (b3-b0) or 2) None or multiple values have been selected for Object Type */
  79. #define A2D_NS_OBJ_TYPE 0xD7 /* Object type is not supported */
  80. #define A2D_BAD_CHANNEL 0xD8 /* None or multiple values have been selected for Channels */
  81. #define A2D_NS_CHANNEL 0xD9 /* Channels is not supported */
  82. #define A2D_BAD_BLOCK_LEN 0xDD /* None or multiple values have been selected for Block Length */
  83. #define A2D_BAD_CP_TYPE 0xE0 /* The requested CP Type is not supported. */
  84. #define A2D_BAD_CP_FORMAT 0xE1 /* The format of Content Protection Service Capability/Content Protection Scheme Dependent Data is not correct. */
  85. typedef UINT8 tA2D_STATUS;
  86. /* the return values from A2D_BitsSet() */
  87. #define A2D_SET_ONE_BIT 1 /* one and only one bit is set */
  88. #define A2D_SET_ZERO_BIT 0 /* all bits clear */
  89. #define A2D_SET_MULTL_BIT 2 /* multiple bits are set */
  90. /*****************************************************************************
  91. ** type definitions
  92. *****************************************************************************/
  93. /* This data type is used in A2D_FindService() to initialize the SDP database
  94. * to hold the result service search. */
  95. typedef struct {
  96. UINT32 db_len; /* Length, in bytes, of the discovery database */
  97. UINT16 num_attr;/* The number of attributes in p_attrs */
  98. tSDP_DISCOVERY_DB *p_db; /* Pointer to the discovery database */
  99. UINT16 *p_attrs; /* The attributes filter. If NULL, A2DP API sets the attribute filter
  100. * to be ATTR_ID_SERVICE_CLASS_ID_LIST, ATTR_ID_BT_PROFILE_DESC_LIST,
  101. * ATTR_ID_SUPPORTED_FEATURES, ATTR_ID_SERVICE_NAME and ATTR_ID_PROVIDER_NAME.
  102. * If not NULL, the input is taken as the filter. */
  103. } tA2D_SDP_DB_PARAMS;
  104. /* This data type is used in tA2D_FIND_CBACK to report the result of the SDP discovery process. */
  105. typedef struct {
  106. UINT16 service_len; /* Length, in bytes, of the service name */
  107. UINT16 provider_len; /* Length, in bytes, of the provider name */
  108. char *p_service_name; /* Pointer the service name. This character string may not be null terminated.
  109. * Use the service_len parameter to safely copy this string */
  110. char *p_provider_name;/* Pointer the provider name. This character string may not be null terminated.
  111. * Use the provider_len parameter to safely copy this string */
  112. UINT16 features; /* Profile supported features */
  113. UINT16 avdt_version; /* AVDTP protocol version */
  114. } tA2D_Service;
  115. /* This is the callback to notify the result of the SDP discovery process. */
  116. typedef void (tA2D_FIND_CBACK)(BOOLEAN found, tA2D_Service *p_service);
  117. /*****************************************************************************
  118. ** external function declarations
  119. *****************************************************************************/
  120. #ifdef __cplusplus
  121. extern "C"
  122. {
  123. #endif
  124. /******************************************************************************
  125. **
  126. ** Function A2D_AddRecord
  127. **
  128. ** Description This function is called by a server application to add
  129. ** SRC or SNK information to an SDP record. Prior to
  130. ** calling this function the application must call
  131. ** SDP_CreateRecord() to create an SDP record.
  132. **
  133. ** Input Parameters:
  134. ** service_uuid: Indicates SRC or SNK.
  135. **
  136. ** p_service_name: Pointer to a null-terminated character
  137. ** string containing the service name.
  138. **
  139. ** p_provider_name: Pointer to a null-terminated character
  140. ** string containing the provider name.
  141. **
  142. ** features: Profile supported features.
  143. **
  144. ** sdp_handle: SDP handle returned by SDP_CreateRecord().
  145. **
  146. ** Output Parameters:
  147. ** None.
  148. **
  149. ** Returns A2D_SUCCESS if function execution succeeded,
  150. ** A2D_INVALID_PARAMS if bad parameters are given.
  151. ** A2D_FAIL if function execution failed.
  152. **
  153. ******************************************************************************/
  154. extern tA2D_STATUS A2D_AddRecord(UINT16 service_uuid, char *p_service_name, char *p_provider_name,
  155. UINT16 features, UINT32 sdp_handle);
  156. /******************************************************************************
  157. **
  158. ** Function A2D_FindService
  159. **
  160. ** Description This function is called by a client application to
  161. ** perform service discovery and retrieve SRC or SNK SDP
  162. ** record information from a server. Information is
  163. ** returned for the first service record found on the
  164. ** server that matches the service UUID. The callback
  165. ** function will be executed when service discovery is
  166. ** complete. There can only be one outstanding call to
  167. ** A2D_FindService() at a time; the application must wait
  168. ** for the callback before it makes another call to
  169. ** the function.
  170. **
  171. ** Input Parameters:
  172. ** service_uuid: Indicates SRC or SNK.
  173. **
  174. ** bd_addr: BD address of the peer device.
  175. **
  176. ** p_db: Pointer to the information to initialize
  177. ** the discovery database.
  178. **
  179. ** p_cback: Pointer to the A2D_FindService()
  180. ** callback function.
  181. **
  182. ** Output Parameters:
  183. ** None.
  184. **
  185. ** Returns A2D_SUCCESS if function execution succeeded,
  186. ** A2D_INVALID_PARAMS if bad parameters are given.
  187. ** A2D_BUSY if discovery is already in progress.
  188. ** A2D_FAIL if function execution failed.
  189. **
  190. ******************************************************************************/
  191. extern tA2D_STATUS A2D_FindService(UINT16 service_uuid, BD_ADDR bd_addr,
  192. tA2D_SDP_DB_PARAMS *p_db, tA2D_FIND_CBACK *p_cback);
  193. /******************************************************************************
  194. **
  195. ** Function A2D_SetTraceLevel
  196. **
  197. ** Description Sets the trace level for A2D. If 0xff is passed, the
  198. ** current trace level is returned.
  199. **
  200. ** Input Parameters:
  201. ** new_level: The level to set the A2D tracing to:
  202. ** 0xff-returns the current setting.
  203. ** 0-turns off tracing.
  204. ** >= 1-Errors.
  205. ** >= 2-Warnings.
  206. ** >= 3-APIs.
  207. ** >= 4-Events.
  208. ** >= 5-Debug.
  209. **
  210. ** Returns The new trace level or current trace level if
  211. ** the input parameter is 0xff.
  212. **
  213. ******************************************************************************/
  214. extern UINT8 A2D_SetTraceLevel (UINT8 new_level);
  215. /******************************************************************************
  216. ** Function A2D_BitsSet
  217. **
  218. ** Description Check the given num for the number of bits set
  219. ** Returns A2D_SET_ONE_BIT, if one and only one bit is set
  220. ** A2D_SET_ZERO_BIT, if all bits clear
  221. ** A2D_SET_MULTL_BIT, if multiple bits are set
  222. ******************************************************************************/
  223. extern UINT8 A2D_BitsSet(UINT8 num);
  224. /*******************************************************************************
  225. **
  226. ** Function A2D_Init
  227. **
  228. ** Description This function is called at stack startup to allocate the
  229. ** control block (if using dynamic memory), and initializes the
  230. ** control block and tracing level.
  231. **
  232. ** Returns void
  233. **
  234. *******************************************************************************/
  235. extern bt_status_t A2D_Init(void);
  236. /*******************************************************************************
  237. **
  238. ** Function A2D_Deinit
  239. **
  240. ** Description This function is called at stack startup to free the
  241. ** control block (if using dynamic memory), and free the
  242. ** control block and tracing level.
  243. **
  244. ** Returns void
  245. **
  246. *******************************************************************************/
  247. extern void A2D_Deinit(void);
  248. /*******************************************************************************
  249. **
  250. ** Function a2d_set_avdt_sdp_ver
  251. **
  252. ** Description Used for change version of avdtp
  253. **
  254. ** Returns void
  255. **
  256. *******************************************************************************/
  257. extern void a2d_set_avdt_sdp_ver(UINT16 avdt_sdp_ver);
  258. /*******************************************************************************
  259. **
  260. ** Function a2d_set_a2dp_sdp_ver
  261. **
  262. ** Description Used for change version of a2dp
  263. **
  264. ** Returns void
  265. **
  266. *******************************************************************************/
  267. extern void a2d_set_a2dp_sdp_ver(UINT16 a2dp_sdp_ver);
  268. #ifdef __cplusplus
  269. }
  270. #endif
  271. #endif ///A2D_INCLUDED
  272. #endif /* A2D_API_H */