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