1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
24
29
30
31
32
33
34
35
36
37
38
39
40
43
44
45
46
47
48
49
50
66
67
68
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
161
162
163
164
167
168
169
170
173
174
175
176
177
178
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
251
252
253
254
255
260
261
262
263
264
265
266
267
268
269
270
274
275
279
280
281
282
287
288
289
290
295
296
302
303
304
305
306
307
308
309
313
314
315
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
409
410
/* ... */
/* ... */
#include <string.h>
#include "common/bt_target.h"
#include "stack/avrc_api.h"
#include "avrc_int.h"
#include "osi/allocator.h"5 includes
#if (defined(AVRC_INCLUDED) && AVRC_INCLUDED == TRUE)
#ifndef SDP_AVRCP_1_6
#define SDP_AVRCP_1_6 TRUE
#endif
#ifndef SDP_AVCTP_1_4
#define SDP_AVCTP_1_4 TRUE
#endif
/* ... */
#if AVRC_DYNAMIC_MEMORY == FALSE
tAVRC_CB avrc_cb;
#else
tAVRC_CB *avrc_cb_ptr;
#endif
const tSDP_PROTOCOL_ELEM avrc_proto_list [] = {
{UUID_PROTOCOL_L2CAP, 1, {AVCT_PSM, 0} },
#if SDP_AVCTP_1_4 == TRUE
{UUID_PROTOCOL_AVCTP, 1, {AVCT_REV_1_4, 0} }
#else
#if SDP_AVRCP_1_6 == TRUE
{UUID_PROTOCOL_AVCTP, 1, {AVCT_REV_1_3, 0} }
#else
#if AVRC_METADATA_INCLUDED == TRUE
{UUID_PROTOCOL_AVCTP, 1, {AVCT_REV_1_2, 0} }
#else
{UUID_PROTOCOL_AVCTP, 1, {AVCT_REV_1_0, 0} }
#endif/* ... */
#endif/* ... */
#endif
}{...};
#if SDP_AVRCP_1_6 == TRUE
const tSDP_PROTO_LIST_ELEM avrc_add_proto_list [] = {
{
AVRC_NUM_PROTO_ELEMS,
{
{UUID_PROTOCOL_L2CAP, 1, {AVCT_BR_PSM, 0} },
#if SDP_AVCTP_1_4 == TRUE
{UUID_PROTOCOL_AVCTP, 1, {AVCT_REV_1_4, 0} }
#else
{UUID_PROTOCOL_AVCTP, 1, {AVCT_REV_1_3, 0} }
#endif
}{...}
}{...}
}{...};/* ... */
#endif
/* ... */
static void avrc_sdp_cback(UINT16 status)
{
AVRC_TRACE_API("avrc_sdp_cback status: %d", status);
avrc_cb.service_uuid = 0;
(*avrc_cb.p_cback) (status);
return;
}{...}
/* ... */
UINT16 AVRC_FindService(UINT16 service_uuid, BD_ADDR bd_addr,
tAVRC_SDP_DB_PARAMS *p_db, tAVRC_FIND_CBACK *p_cback)
{
tSDP_UUID uuid_list;
BOOLEAN result = TRUE;
UINT16 a2d_attr_list[] = {ATTR_ID_SERVICE_CLASS_ID_LIST,
ATTR_ID_PROTOCOL_DESC_LIST,
ATTR_ID_BT_PROFILE_DESC_LIST,
ATTR_ID_SERVICE_NAME,
ATTR_ID_SUPPORTED_FEATURES,
ATTR_ID_PROVIDER_NAME
}{...};
AVRC_TRACE_API("AVRC_FindService uuid: %x", service_uuid);
if ( (service_uuid != UUID_SERVCLASS_AV_REM_CTRL_TARGET && service_uuid != UUID_SERVCLASS_AV_REMOTE_CONTROL) ||
p_db == NULL || p_db->p_db == NULL || p_cback == NULL) {
return AVRC_BAD_PARAM;
}{...}
if ( avrc_cb.service_uuid == UUID_SERVCLASS_AV_REM_CTRL_TARGET ||
avrc_cb.service_uuid == UUID_SERVCLASS_AV_REMOTE_CONTROL) {
return AVRC_NO_RESOURCES;
}{...}
uuid_list.len = LEN_UUID_16;
uuid_list.uu.uuid16 = service_uuid;
if (p_db->p_attrs == NULL || p_db->num_attr == 0) {
p_db->p_attrs = a2d_attr_list;
p_db->num_attr = AVRC_NUM_ATTR;
}{...}
result = SDP_InitDiscoveryDb(p_db->p_db, p_db->db_len, 1, &uuid_list, p_db->num_attr,
p_db->p_attrs);
if (result == TRUE) {
avrc_cb.p_db = p_db->p_db;
avrc_cb.service_uuid = service_uuid;
avrc_cb.p_cback = p_cback;
result = SDP_ServiceSearchAttributeRequest(bd_addr, p_db->p_db, avrc_sdp_cback);
}{...}
return (result ? AVRC_SUCCESS : AVRC_FAIL);
}{...}
/* ... */
UINT16 AVRC_AddRecord(UINT16 service_uuid, char *p_service_name, char *p_provider_name,
UINT16 categories, UINT32 sdp_handle, BOOLEAN browsing_en)
{
UINT16 browse_list[1];
BOOLEAN result = TRUE;
UINT8 temp[8];
UINT8 *p;
UINT16 count = 1;
UINT16 class_list[2];
UINT16 supported_feature = categories;
BOOLEAN media_player_virtual_filesystem_supported = FALSE;
BOOLEAN add_additional_protocol_list = FALSE;
AVRC_TRACE_API("AVRC_AddRecord uuid: %x, browsing_en:%d", service_uuid, browsing_en);
if ( service_uuid != UUID_SERVCLASS_AV_REM_CTRL_TARGET && service_uuid != UUID_SERVCLASS_AV_REMOTE_CONTROL ) {
return AVRC_BAD_PARAM;
}{...}
class_list[0] = service_uuid;
#if (SDP_AVCTP_1_4 == TRUE || SDP_AVRCP_1_6 == TRUE)
if ( service_uuid == UUID_SERVCLASS_AV_REMOTE_CONTROL ) {
class_list[1] = UUID_SERVCLASS_AV_REM_CTRL_CONTROL;
count = 2;
}{...}
/* ... */#endif
result &= SDP_AddServiceClassIdList(sdp_handle, count, class_list);
result &= SDP_AddProtocolList(sdp_handle, AVRC_NUM_PROTO_ELEMS, (tSDP_PROTOCOL_ELEM *)avrc_proto_list);
#if SDP_AVRCP_1_6 == TRUE
if (browsing_en) {
add_additional_protocol_list = TRUE;
}{...} else if (service_uuid == UUID_SERVCLASS_AV_REM_CTRL_TARGET &&
(categories & (AVRC_SUPF_TG_CAT1 | AVRC_SUPF_TG_CAT3))) {
AVRC_TRACE_WARNING("For AVRCP Target Cateory 1 and 3, SDP record shall contain additional protocol list");
add_additional_protocol_list = TRUE;
}{...}
if (add_additional_protocol_list) {
result &= SDP_AddAdditionProtoLists( sdp_handle, 1, (tSDP_PROTO_LIST_ELEM *)avrc_add_proto_list);
}{...}
result &= SDP_AddProfileDescriptorList(sdp_handle, UUID_SERVCLASS_AV_REMOTE_CONTROL, AVRC_REV_1_6);/* ... */
#else
#if AVRC_METADATA_INCLUDED == TRUE
result &= SDP_AddProfileDescriptorList(sdp_handle, UUID_SERVCLASS_AV_REMOTE_CONTROL, AVRC_REV_1_3);
#else
result &= SDP_AddProfileDescriptorList(sdp_handle, UUID_SERVCLASS_AV_REMOTE_CONTROL, AVRC_REV_1_0);
#endif/* ... */
#endif
if (service_uuid == UUID_SERVCLASS_AV_REM_CTRL_CONTROL && browsing_en) {
supported_feature |= AVRC_SUPF_CT_BROWSE;
}{...} else if (service_uuid == UUID_SERVCLASS_AV_REM_CTRL_TARGET && media_player_virtual_filesystem_supported) {
supported_feature |= AVRC_SUPF_TG_BROWSE;
}{...}
#if AVRC_CA_INCLUDED
if (service_uuid == UUID_SERVCLASS_AV_REM_CTRL_CONTROL || service_uuid == UUID_SERVCLASS_AV_REMOTE_CONTROL) {
supported_feature |= AVRC_SUPF_CT_COVER_ART_GIP;
supported_feature |= AVRC_SUPF_CT_COVER_ART_GI;
supported_feature |= AVRC_SUPF_CT_COVER_ART_GLT;
}{...}
/* ... */#endif
p = temp;
UINT16_TO_BE_STREAM(p, supported_feature);
result &= SDP_AddAttribute(sdp_handle, ATTR_ID_SUPPORTED_FEATURES, UINT_DESC_TYPE,
(UINT32)2, (UINT8 *)temp);
if (p_provider_name != NULL) {
result &= SDP_AddAttribute(sdp_handle, ATTR_ID_PROVIDER_NAME, TEXT_STR_DESC_TYPE,
(UINT32)(strlen(p_provider_name) + 1), (UINT8 *) p_provider_name);
}{...}
if (p_service_name != NULL) {
result &= SDP_AddAttribute(sdp_handle, ATTR_ID_SERVICE_NAME, TEXT_STR_DESC_TYPE,
(UINT32)(strlen(p_service_name) + 1), (UINT8 *) p_service_name);
}{...}
browse_list[0] = UUID_SERVCLASS_PUBLIC_BROWSE_GROUP;
result &= SDP_AddUuidSequence(sdp_handle, ATTR_ID_BROWSE_GROUP_LIST, 1, browse_list);
return (result ? AVRC_SUCCESS : AVRC_FAIL);
}{...}
/* ... */
UINT8 AVRC_SetTraceLevel (UINT8 new_level)
{
if (new_level != 0xFF) {
avrc_cb.trace_level = new_level;
}{...}
return (avrc_cb.trace_level);
}{...}
/* ... */
bt_status_t AVRC_Init(void)
{
#if AVRC_DYNAMIC_MEMORY
avrc_cb_ptr = (tAVRC_CB *)osi_malloc(sizeof(tAVRC_CB));
if (!avrc_cb_ptr) {
return BT_STATUS_NOMEM;
}{...}
/* ... */#endif
memset(&avrc_cb, 0, sizeof(tAVRC_CB));
#if defined(AVRC_INITIAL_TRACE_LEVEL)
avrc_cb.trace_level = AVRC_INITIAL_TRACE_LEVEL;
#else
avrc_cb.trace_level = BT_TRACE_LEVEL_NONE;
#endif
return BT_STATUS_SUCCESS;
}{...}
/* ... */
void AVRC_Deinit(void)
{
#if AVRC_DYNAMIC_MEMORY
if (avrc_cb_ptr){
osi_free(avrc_cb_ptr);
avrc_cb_ptr = NULL;
}{...}
/* ... */#endif
}{...}
/* ... */
#endif