• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /******************************************************************************
2  *
3  *  Copyright 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 // A2DP API
21 //
22 
23 #ifndef A2DP_API_H
24 #define A2DP_API_H
25 
26 #include <inttypes.h>
27 
28 #include "a2dp_constants.h"
29 #include "a2dp_error_codes.h"
30 #include "sdp_api.h"
31 
32 /*****************************************************************************
33  *  constants
34  ****************************************************************************/
35 
36 //
37 // |MAX_PCM_FRAME_NUM_PER_TICK| controls how many buffers we can hold in
38 // the A2DP buffer queues during temporary link congestion.
39 //
40 #ifndef MAX_PCM_FRAME_NUM_PER_TICK
41 #define MAX_PCM_FRAME_NUM_PER_TICK 14
42 #endif
43 
44 /* the return values from A2DP_BitsSet() */
45 #define A2DP_SET_ONE_BIT 1   /* one and only one bit is set */
46 #define A2DP_SET_ZERO_BIT 0  /* all bits clear */
47 #define A2DP_SET_MULTL_BIT 2 /* multiple bits are set */
48 
49 /*****************************************************************************
50  *  type definitions
51  ****************************************************************************/
52 
53 /* This data type is used in A2DP_FindService() to initialize the SDP database
54  * to hold the result service search. */
55 typedef struct {
56   uint32_t db_len;   /* Length, in bytes, of the discovery database */
57   uint16_t num_attr; /* The number of attributes in p_attrs */
58   uint16_t* p_attrs; /* The attributes filter. If NULL, A2DP API sets the
59                       * attribute filter
60                       * to be ATTR_ID_SERVICE_CLASS_ID_LIST,
61                       * ATTR_ID_BT_PROFILE_DESC_LIST,
62                       * ATTR_ID_SUPPORTED_FEATURES, ATTR_ID_SERVICE_NAME and
63                       * ATTR_ID_PROVIDER_NAME.
64                       * If not NULL, the input is taken as the filter. */
65 } tA2DP_SDP_DB_PARAMS;
66 
67 /* This data type is used in tA2DP_FIND_CBACK to report the result of the SDP
68  * discovery process. */
69 typedef struct {
70   uint16_t service_len;  /* Length, in bytes, of the service name */
71   uint16_t provider_len; /* Length, in bytes, of the provider name */
72   char* p_service_name;  /* Pointer the service name.  This character string may
73                           * not be null terminated.
74                           * Use the service_len parameter to safely copy this
75                           * string */
76   char* p_provider_name; /* Pointer the provider name.  This character string
77                           * may not be null terminated.
78                           * Use the provider_len parameter to safely copy this
79                           * string */
80   uint16_t features;     /* Profile supported features */
81   uint16_t avdt_version; /* AVDTP protocol version */
82 } tA2DP_Service;
83 
84 /* This is the callback to notify the result of the SDP discovery process. */
85 typedef void(tA2DP_FIND_CBACK)(bool found, tA2DP_Service* p_service,
86                                const RawAddress& peer_address);
87 
88 /*****************************************************************************
89  *  external function declarations
90  ****************************************************************************/
91 /******************************************************************************
92  *
93  * Function         A2DP_AddRecord
94  *
95  * Description      This function is called by a server application to add
96  *                  SRC or SNK information to an SDP record.  Prior to
97  *                  calling this function the application must call
98  *                  SDP_CreateRecord() to create an SDP record.
99  *
100  *                  Input Parameters:
101  *                      service_uuid:  Indicates SRC or SNK.
102  *
103  *                      p_service_name:  Pointer to a null-terminated character
104  *                      string containing the service name.
105  *
106  *                      p_provider_name:  Pointer to a null-terminated character
107  *                      string containing the provider name.
108  *
109  *                      features:  Profile supported features.
110  *
111  *                      sdp_handle:  SDP handle returned by SDP_CreateRecord().
112  *
113  *                  Output Parameters:
114  *                      None.
115  *
116  * Returns          A2DP_SUCCESS if function execution succeeded,
117  *                  A2DP_INVALID_PARAMS if bad parameters are given.
118  *                  A2DP_FAIL if function execution failed.
119  *
120  *****************************************************************************/
121 extern tA2DP_STATUS A2DP_AddRecord(uint16_t service_uuid, char* p_service_name,
122                                    char* p_provider_name, uint16_t features,
123                                    uint32_t sdp_handle);
124 
125 /******************************************************************************
126  *
127  * Function         A2DP_FindService
128  *
129  * Description      This function is called by a client application to
130  *                  perform service discovery and retrieve SRC or SNK SDP
131  *                  record information from a server.  Information is
132  *                  returned for the first service record found on the
133  *                  server that matches the service UUID.  The callback
134  *                  function will be executed when service discovery is
135  *                  complete.  There can only be one outstanding call to
136  *                  A2DP_FindService() at a time; the application must wait
137  *                  for the callback before it makes another call to
138  *                  the function.
139  *
140  *                  Input Parameters:
141  *                      service_uuid:  Indicates SRC or SNK.
142  *
143  *                      bd_addr:  BD address of the peer device.
144  *
145  *                      p_db:  Pointer to the information to initialize
146  *                             the discovery database.
147  *
148  *                      p_cback:  Pointer to the A2DP_FindService()
149  *                      callback function.
150  *
151  *                  Output Parameters:
152  *                      None.
153  *
154  * Returns          A2DP_SUCCESS if function execution succeeded,
155  *                  A2DP_INVALID_PARAMS if bad parameters are given.
156  *                  A2DP_BUSY if discovery is already in progress.
157  *                  A2DP_FAIL if function execution failed.
158  *
159  *****************************************************************************/
160 extern tA2DP_STATUS A2DP_FindService(uint16_t service_uuid,
161                                      const RawAddress& bd_addr,
162                                      tA2DP_SDP_DB_PARAMS* p_db,
163                                      tA2DP_FIND_CBACK* p_cback);
164 
165 /******************************************************************************
166  *
167  * Function         A2DP_GetAvdtpVersion()
168  *
169  * Description      Gets the local version of AVDTP
170  *
171  * Returns          The local version of AVDTP.
172  *
173  *****************************************************************************/
174 extern uint16_t A2DP_GetAvdtpVersion(void);
175 
176 /******************************************************************************
177  *
178  * Function         A2DP_SetTraceLevel
179  *
180  * Description      Sets the trace level for A2D. If 0xff is passed, the
181  *                  current trace level is returned.
182  *
183  *                  Input Parameters:
184  *                      new_level:  The level to set the A2DP tracing to:
185  *                      0xff-returns the current setting.
186  *                      0-turns off tracing.
187  *                      >= 1-Errors.
188  *                      >= 2-Warnings.
189  *                      >= 3-APIs.
190  *                      >= 4-Events.
191  *                      >= 5-Debug.
192  *
193  * Returns          The new trace level or current trace level if
194  *                  the input parameter is 0xff.
195  *
196  *****************************************************************************/
197 extern uint8_t A2DP_SetTraceLevel(uint8_t new_level);
198 
199 /******************************************************************************
200  * Function         A2DP_BitsSet
201  *
202  * Description      Check the given num for the number of bits set
203  * Returns          A2DP_SET_ONE_BIT, if one and only one bit is set
204  *                  A2DP_SET_ZERO_BIT, if all bits clear
205  *                  A2DP_SET_MULTL_BIT, if multiple bits are set
206  *****************************************************************************/
207 extern uint8_t A2DP_BitsSet(uint64_t num);
208 
209 // Initializes the A2DP control block.
210 void A2DP_Init(void);
211 
212 #endif  // A2DP_API_H
213