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 <cstdint> 27 28 #include "stack/include/a2dp_constants.h" 29 #include "stack/include/a2dp_error_codes.h" 30 #include "stack/include/sdp_api.h" 31 #include "types/raw_address.h" 32 33 /***************************************************************************** 34 * constants 35 ****************************************************************************/ 36 37 // 38 // |MAX_PCM_FRAME_NUM_PER_TICK| controls how many buffers we can hold in 39 // the A2DP buffer queues during temporary link congestion. 40 // 41 #ifndef MAX_PCM_FRAME_NUM_PER_TICK 42 #define MAX_PCM_FRAME_NUM_PER_TICK 14 43 #endif 44 45 /* the return values from A2DP_BitsSet() */ 46 #define A2DP_SET_ONE_BIT 1 /* one and only one bit is set */ 47 #define A2DP_SET_ZERO_BIT 0 /* all bits clear */ 48 #define A2DP_SET_MULTL_BIT 2 /* multiple bits are set */ 49 50 /***************************************************************************** 51 * type definitions 52 ****************************************************************************/ 53 54 /* This data type is used in A2DP_FindService() to initialize the SDP database 55 * to hold the result service search. */ 56 typedef struct { 57 uint32_t db_len; /* Length, in bytes, of the discovery database */ 58 uint16_t num_attr; /* The number of attributes in p_attrs */ 59 uint16_t* p_attrs; /* The attributes filter. If NULL, A2DP API sets the 60 * attribute filter 61 * to be ATTR_ID_SERVICE_CLASS_ID_LIST, 62 * ATTR_ID_BT_PROFILE_DESC_LIST, 63 * ATTR_ID_SUPPORTED_FEATURES, ATTR_ID_SERVICE_NAME and 64 * ATTR_ID_PROVIDER_NAME. 65 * If not NULL, the input is taken as the filter. */ 66 } tA2DP_SDP_DB_PARAMS; 67 68 /* This data type is used in tA2DP_FIND_CBACK to report the result of the SDP 69 * discovery process. */ 70 typedef struct { 71 uint16_t service_len; /* Length, in bytes, of the service name */ 72 uint16_t provider_len; /* Length, in bytes, of the provider name */ 73 char* p_service_name; /* Pointer the service name. This character string may 74 * not be null terminated. 75 * Use the service_len parameter to safely copy this 76 * string */ 77 char* p_provider_name; /* Pointer the provider name. This character string 78 * may not be null terminated. 79 * Use the provider_len parameter to safely copy this 80 * string */ 81 uint16_t features; /* Profile supported features */ 82 uint16_t avdt_version; /* AVDTP protocol version */ 83 } tA2DP_Service; 84 85 /* This is the callback to notify the result of the SDP discovery process. */ 86 typedef void(tA2DP_FIND_CBACK)(bool found, tA2DP_Service* p_service, 87 const RawAddress& peer_address); 88 89 /***************************************************************************** 90 * external function declarations 91 ****************************************************************************/ 92 /****************************************************************************** 93 * 94 * Function A2DP_AddRecord 95 * 96 * Description This function is called by a server application to add 97 * SRC or SNK information to an SDP record. Prior to 98 * calling this function the application must call 99 * SDP_CreateRecord() to create an SDP record. 100 * 101 * Input Parameters: 102 * service_uuid: Indicates SRC or SNK. 103 * 104 * p_service_name: Pointer to a null-terminated character 105 * string containing the service name. 106 * 107 * p_provider_name: Pointer to a null-terminated character 108 * string containing the provider name. 109 * 110 * features: Profile supported features. 111 * 112 * sdp_handle: SDP handle returned by SDP_CreateRecord(). 113 * 114 * Output Parameters: 115 * None. 116 * 117 * Returns A2DP_SUCCESS if function execution succeeded, 118 * A2DP_INVALID_PARAMS if bad parameters are given. 119 * A2DP_FAIL if function execution failed. 120 * 121 *****************************************************************************/ 122 tA2DP_STATUS A2DP_AddRecord(uint16_t service_uuid, char* p_service_name, 123 char* p_provider_name, uint16_t features, 124 uint32_t sdp_handle); 125 126 /****************************************************************************** 127 * 128 * Function A2DP_FindService 129 * 130 * Description This function is called by a client application to 131 * perform service discovery and retrieve SRC or SNK SDP 132 * record information from a server. Information is 133 * returned for the first service record found on the 134 * server that matches the service UUID. The callback 135 * function will be executed when service discovery is 136 * complete. There can only be one outstanding call to 137 * A2DP_FindService() at a time; the application must wait 138 * for the callback before it makes another call to 139 * the function. 140 * 141 * Input Parameters: 142 * service_uuid: Indicates SRC or SNK. 143 * 144 * bd_addr: BD address of the peer device. 145 * 146 * p_db: Pointer to the information to initialize 147 * the discovery database. 148 * 149 * p_cback: Pointer to the A2DP_FindService() 150 * callback function. 151 * 152 * Output Parameters: 153 * None. 154 * 155 * Returns A2DP_SUCCESS if function execution succeeded, 156 * A2DP_INVALID_PARAMS if bad parameters are given. 157 * A2DP_BUSY if discovery is already in progress. 158 * A2DP_FAIL if function execution failed. 159 * 160 *****************************************************************************/ 161 tA2DP_STATUS A2DP_FindService(uint16_t service_uuid, 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 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 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 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