1 /****************************************************************************** 2 * 3 * Copyright 2006-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 AVRCP Application Programming Interface 22 * 23 ******************************************************************************/ 24 #ifndef AVRC_API_H 25 #define AVRC_API_H 26 27 #include <base/functional/callback.h> 28 29 #include <cstdint> 30 31 #include "stack/include/avct_api.h" 32 #include "stack/include/avrc_defs.h" 33 #include "stack/include/bt_hdr.h" 34 #include "stack/include/sdp_status.h" 35 #include "stack/sdp/sdp_discovery_db.h" 36 #include "types/raw_address.h" 37 38 /***************************************************************************** 39 * constants 40 ****************************************************************************/ 41 42 /* API function return value result codes. */ 43 /* 0 Function successful */ 44 #define AVRC_SUCCESS AVCT_SUCCESS 45 /* 1 Not enough resources */ 46 #define AVRC_NO_RESOURCES AVCT_NO_RESOURCES 47 /* 2 Bad handle */ 48 #define AVRC_BAD_HANDLE AVCT_BAD_HANDLE 49 /* 3 PID already in use */ 50 #define AVRC_PID_IN_USE AVCT_PID_IN_USE 51 /* 4 Connection not open */ 52 #define AVRC_NOT_OPEN AVCT_NOT_OPEN 53 /* 5 the message length exceed the MTU of the browsing channel */ 54 #define AVRC_MSG_TOO_BIG 5 55 /* 0x10 generic failure */ 56 #define AVRC_FAIL 0x10 57 /* 0x11 bad parameter */ 58 #define AVRC_BAD_PARAM 0x11 59 60 /* Control role - same as AVCT_TARGET/AVCT_CONTROL */ 61 /* target */ 62 #define AVRC_CT_TARGET 1 63 /* controller */ 64 #define AVRC_CT_CONTROL 2 65 /* If conflict, allow the other side to succeed */ 66 #define AVRC_CT_PASSIVE 4 67 68 /* AVRC CTRL events */ 69 /* AVRC_OPEN_IND_EVT event is sent when the connection is successfully opened. 70 * This eventis sent in response to an AVRC_Open(). */ 71 #define AVRC_OPEN_IND_EVT 0 72 73 /* AVRC_CLOSE_IND_EVT event is sent when a connection is closed. 74 * This event can result from a call to AVRC_Close() or when the peer closes 75 * the connection. It is also sent when a connection attempted through 76 * AVRC_Open() fails. */ 77 #define AVRC_CLOSE_IND_EVT 1 78 79 /* AVRC_CONG_IND_EVT event indicates that AVCTP is congested and cannot send 80 * any more messages. */ 81 #define AVRC_CONG_IND_EVT 2 82 83 /* AVRC_UNCONG_IND_EVT event indicates that AVCTP is uncongested and ready to 84 * send messages. */ 85 #define AVRC_UNCONG_IND_EVT 3 86 87 /* AVRC_BROWSE_OPEN_IND_EVT event is sent when the browse channel is 88 * successfully opened. 89 * This eventis sent in response to an AVRC_Open() or AVRC_OpenBrowse() . */ 90 #define AVRC_BROWSE_OPEN_IND_EVT 4 91 92 /* AVRC_BROWSE_CLOSE_IND_EVT event is sent when a browse channel is closed. 93 * This event can result from a call to AVRC_Close(), AVRC_CloseBrowse() or 94 * when the peer closes the connection. It is also sent when a connection 95 * attempted through AVRC_OpenBrowse() fails. */ 96 #define AVRC_BROWSE_CLOSE_IND_EVT 5 97 98 /* AVRC_BROWSE_CONG_IND_EVT event indicates that AVCTP browse channel is 99 * congested and cannot send any more messages. */ 100 #define AVRC_BROWSE_CONG_IND_EVT 6 101 102 /* AVRC_BROWSE_UNCONG_IND_EVT event indicates that AVCTP browse channel is 103 * uncongested and ready to send messages. */ 104 #define AVRC_BROWSE_UNCONG_IND_EVT 7 105 106 /* AVRC_CMD_TIMEOUT_EVT event indicates timeout waiting for AVRC command 107 * response from the peer */ 108 #define AVRC_CMD_TIMEOUT_EVT 8 109 110 /* Configurable avrcp version key and constant values */ 111 #ifndef AVRC_VERSION_PROPERTY 112 #define AVRC_VERSION_PROPERTY "persist.bluetooth.avrcpversion" 113 #endif 114 115 /* Configurable avrcp control version key */ 116 #ifndef AVRC_CONTROL_VERSION_PROPERTY 117 #define AVRC_CONTROL_VERSION_PROPERTY "persist.bluetooth.avrcpcontrolversion" 118 #endif 119 120 #ifndef AVRC_1_6_STRING 121 #define AVRC_1_6_STRING "avrcp16" 122 #endif 123 124 #ifndef AVRC_1_5_STRING 125 #define AVRC_1_5_STRING "avrcp15" 126 #endif 127 128 #ifndef AVRC_1_4_STRING 129 #define AVRC_1_4_STRING "avrcp14" 130 #endif 131 132 #ifndef AVRC_1_3_STRING 133 #define AVRC_1_3_STRING "avrcp13" 134 #endif 135 136 #ifndef AVRC_DEFAULT_VERSION 137 #define AVRC_DEFAULT_VERSION AVRC_1_5_STRING 138 #endif 139 140 /* Configurable dynamic avrcp version enable key*/ 141 #ifndef AVRC_DYNAMIC_AVRCP_ENABLE_PROPERTY 142 #define AVRC_DYNAMIC_AVRCP_ENABLE_PROPERTY "persist.bluetooth.dynamic_avrcp.enable" 143 #endif 144 145 /* Supported categories */ 146 #define AVRC_SUPF_CT_CAT1 0x0001 /* Category 1 */ 147 #define AVRC_SUPF_CT_CAT2 0x0002 /* Category 2 */ 148 #define AVRC_SUPF_CT_CAT3 0x0004 /* Category 3 */ 149 #define AVRC_SUPF_CT_CAT4 0x0008 /* Category 4 */ 150 #define AVRC_SUPF_CT_APP_SETTINGS 0x0010 /* Player Application Settings */ 151 #define AVRC_SUPF_CT_GROUP_NAVI 0x0020 /* Group Navigation */ 152 #define AVRC_SUPF_CT_BROWSE 0x0040 /* Browsing */ 153 154 /* Cover Art, get image property */ 155 #define AVRC_SUPF_CT_COVER_ART_GET_IMAGE_PROP 0x0080 156 /* Cover Art, get image */ 157 #define AVRC_SUPF_CT_COVER_ART_GET_IMAGE 0x0100 158 /* Cover Art, get Linked Thumbnail */ 159 #define AVRC_SUPF_CT_COVER_ART_GET_THUMBNAIL 0x0200 160 161 #define AVRC_SUPF_TG_CAT1 0x0001 /* Category 1 */ 162 #define AVRC_SUPF_TG_CAT2 0x0002 /* Category 2 */ 163 #define AVRC_SUPF_TG_CAT3 0x0004 /* Category 3 */ 164 #define AVRC_SUPF_TG_CAT4 0x0008 /* Category 4 */ 165 #define AVRC_SUPF_TG_APP_SETTINGS 0x0010 /* Player Application Settings */ 166 #define AVRC_SUPF_TG_GROUP_NAVI 0x0020 /* Group Navigation */ 167 #define AVRC_SUPF_TG_BROWSE 0x0040 /* Browsing */ 168 #define AVRC_SUPF_TG_MULTI_PLAYER 0x0080 /* Muliple Media Player */ 169 #define AVRC_SUPF_TG_PLAYER_COVER_ART 0x0100 /* Cover Art */ 170 171 #define AVRC_META_SUCCESS AVRC_SUCCESS 172 #define AVRC_META_FAIL AVRC_FAIL 173 #define AVRC_METADATA_CMD 0x0000 174 #define AVRC_METADATA_RESP 0x0001 175 176 #define AVRCP_SUPPORTED_FEATURES_POSITION 1 177 #define AVRCP_BROWSE_SUPPORT_BITMASK 0x40 178 #define AVRCP_MULTI_PLAYER_SUPPORT_BITMASK 0x80 179 #define AVRCP_CA_SUPPORT_BITMASK 0x01 180 181 #define AVRCP_FEAT_CA_BIT 0x0180 182 #define AVRCP_FEAT_BRW_BIT 0x0040 183 184 /***************************************************************************** 185 * data type definitions 186 ****************************************************************************/ 187 188 /* This data type is used in AVRC_FindService() to initialize the SDP database 189 * to hold the result service search. */ 190 typedef struct { 191 uint32_t db_len; /* Length, in bytes, of the discovery database */ 192 tSDP_DISCOVERY_DB* p_db; /* Pointer to the discovery database */ 193 uint16_t num_attr; /* The number of attributes in p_attrs */ 194 uint16_t* p_attrs; /* The attributes filter. If NULL, AVRCP API sets the 195 * attribute filter 196 * to be ATTR_ID_SERVICE_CLASS_ID_LIST, 197 * ATTR_ID_BT_PROFILE_DESC_LIST, 198 * ATTR_ID_SUPPORTED_FEATURES, ATTR_ID_SERVICE_NAME, 199 * ATTR_ID_PROVIDER_NAME. 200 * If not NULL, the input is taken as the filter. */ 201 } tAVRC_SDP_DB_PARAMS; 202 203 /* This callback function returns service discovery information to the 204 * application after the AVRC_FindService() API function is called. The 205 * implementation of this callback function must copy the p_service_name 206 * and p_provider_name parameters passed to it as they are not guaranteed 207 * to remain after the callback function exits. */ 208 using tAVRC_FIND_CBACK = base::Callback<void(tSDP_STATUS status)>; 209 210 /* This is the control callback function. This function passes events 211 * listed in Table 20 to the application. */ 212 using tAVRC_CTRL_CBACK = base::Callback<void(uint8_t handle, uint8_t event, uint16_t result, 213 const RawAddress* peer_addr)>; 214 215 /* This is the message callback function. It is executed when AVCTP has 216 * a message packet ready for the application. The implementation of this 217 * callback function must copy the tAVRC_MSG structure passed to it as it 218 * is not guaranteed to remain after the callback function exits. */ 219 using tAVRC_MSG_CBACK = 220 base::Callback<void(uint8_t handle, uint8_t label, uint8_t opcode, tAVRC_MSG* p_msg)>; 221 222 typedef struct { 223 tAVRC_CTRL_CBACK ctrl_cback; /* application control callback */ 224 tAVRC_MSG_CBACK msg_cback; /* application message callback */ 225 uint32_t company_id; /* the company ID */ 226 tAVCT_ROLE conn; /* Connection role (Initiator/acceptor) */ 227 uint8_t control; /* Control role (Control/Target) */ 228 } tAVRC_CONN_CB; 229 230 typedef struct { 231 uint8_t handle; 232 uint8_t label; 233 uint8_t msg_mask; 234 } tAVRC_PARAM; 235 236 /***************************************************************************** 237 * external function declarations 238 ****************************************************************************/ 239 /****************************************************************************** 240 * 241 * Function avrcp_absolute_volume_is_enabled 242 * 243 * Description Check if config support advance control (absolute volume) 244 * 245 * Returns return true if absolute_volume is enabled 246 * 247 *****************************************************************************/ 248 bool avrcp_absolute_volume_is_enabled(); 249 250 /****************************************************************************** 251 * 252 * Function AVRC_GetControlProfileVersion 253 * 254 * Description Get the overlaid AVRCP control profile version 255 * 256 * Returns The AVRCP control profile version 257 * 258 *****************************************************************************/ 259 uint16_t AVRC_GetControlProfileVersion(); 260 261 /****************************************************************************** 262 * 263 * Function ARVC_GetProfileVersion 264 * 265 * Description Get the user assigned AVRCP profile version 266 * 267 * Returns The AVRCP profile version 268 * 269 *****************************************************************************/ 270 uint16_t AVRC_GetProfileVersion(); 271 272 /****************************************************************************** 273 * 274 * Function AVRC_AddRecord 275 * 276 * Description This function is called to build an AVRCP SDP record. 277 * Prior to calling this function the application must 278 * call SDP_CreateRecord() to create an SDP record. 279 * 280 * Input Parameters: 281 * service_uuid: Indicates 282 * TG(UUID_SERVCLASS_AV_REM_CTRL_TARGET) 283 * or CT(UUID_SERVCLASS_AV_REMOTE_CONTROL) 284 * 285 * p_service_name: Pointer to a null-terminated character 286 * string containing the service name. 287 * If service name is not used set this to NULL. 288 * 289 * p_provider_name: Pointer to a null-terminated character 290 * string containing the provider name. 291 * If provider name is not used set this to NULL. 292 * 293 * categories: Supported categories. 294 * 295 * sdp_handle: SDP handle returned by SDP_CreateRecord(). 296 * 297 * browse_supported: browse support info. 298 * 299 * profile_version: profile version of avrcp record. 300 * 301 * cover_art_psm: The PSM of a cover art service, if 302 * supported. Use 0 Otherwise. Ignored on controller 303 * 304 * Output Parameters: 305 * None. 306 * 307 * Returns AVRC_SUCCESS if successful. 308 * AVRC_NO_RESOURCES if not enough resources to build the SDP 309 * record. 310 * 311 *****************************************************************************/ 312 uint16_t AVRC_AddRecord(uint16_t service_uuid, const char* p_service_name, 313 const char* p_provider_name, uint16_t categories, uint32_t sdp_handle, 314 bool browse_supported, uint16_t profile_version, uint16_t cover_art_psm); 315 316 /******************************************************************************* 317 * 318 * Function AVRC_RemoveRecord 319 * 320 * Description This function is called to remove an AVRCP SDP record. 321 * 322 * Input Parameters: 323 * sdp_handle: Handle you used with AVRC_AddRecord 324 * 325 * Returns AVRC_SUCCESS if successful. 326 * AVRC_FAIL otherwise 327 * 328 *******************************************************************************/ 329 uint16_t AVRC_RemoveRecord(uint32_t sdp_handle); 330 331 /****************************************************************************** 332 * 333 * Function AVRC_FindService 334 * 335 * Description This function is called by the application to perform 336 * service discovery and retrieve AVRCP SDP record information 337 * from a peer device. Information is returned for the first 338 * service record found on the server that matches the service 339 * UUID. The callback function will be executed when service 340 * discovery is complete. There can only be one outstanding 341 * call to AVRC_FindService() at a time; the application must 342 * wait for the callback before it makes another call to the 343 * function. The application is responsible for allocating 344 * memory for the discovery database. It is recommended that 345 * the size of the discovery database be at least 300 bytes. 346 * The application can deallocate the memory after the 347 * callback function has executed. 348 * 349 * Input Parameters: 350 * service_uuid: Indicates 351 * TG(UUID_SERVCLASS_AV_REM_CTRL_TARGET) 352 * or CT(UUID_SERVCLASS_AV_REMOTE_CONTROL) 353 * 354 * bd_addr: BD address of the peer device. 355 * 356 * p_db: SDP discovery database parameters. 357 * 358 * p_cback: Pointer to the callback function. 359 * 360 * Output Parameters: 361 * None. 362 * 363 * Returns AVRC_SUCCESS if successful. 364 * AVRC_BAD_PARAMS if discovery database parameters are 365 * invalid. 366 * AVRC_NO_RESOURCES if there are not enough resources to 367 * perform the service search. 368 * 369 *****************************************************************************/ 370 uint16_t AVRC_FindService(uint16_t service_uuid, const RawAddress& bd_addr, 371 tAVRC_SDP_DB_PARAMS* p_db, const tAVRC_FIND_CBACK& cback); 372 373 /****************************************************************************** 374 * 375 * Function AVRC_Open 376 * 377 * Description This function is called to open a connection to AVCTP. 378 * The connection can be either an initiator or acceptor, as 379 * determined by the p_ccb->stream parameter. 380 * The connection can be a target, a controller or for both 381 * roles, as determined by the p_ccb->control parameter. 382 * By definition, a target connection is an acceptor connection 383 * that waits for an incoming AVCTP connection from the peer. 384 * The connection remains available to the application until 385 * the application closes it by calling AVRC_Close(). The 386 * application does not need to reopen the connection after an 387 * AVRC_CLOSE_IND_EVT is received. 388 * 389 * Input Parameters: 390 * p_ccb->company_id: Company Identifier. 391 * 392 * p_ccb->p_ctrl_cback: Pointer to the control callback 393 * function. 394 * 395 * p_ccb->p_msg_cback: Pointer to the message callback 396 * function. 397 * 398 * p_ccb->conn: AVCTP connection role. This is set to 399 * AVCTP_INT for initiator connections and AVCTP_ACP 400 * for acceptor connections. 401 * 402 * p_ccb->control: Control role. This is set to 403 * AVRC_CT_TARGET for target connections, AVRC_CT_CONTROL 404 * for control connections or 405 * (AVRC_CT_TARGET|AVRC_CT_CONTROL) for connections that 406 * support both roles. 407 * 408 * peer_addr: BD address of peer device. This value is 409 * only used for initiator connections; for acceptor 410 * connections it can be set to NULL. 411 * 412 * Output Parameters: 413 * p_handle: Pointer to handle. This parameter is only 414 * valid if AVRC_SUCCESS is returned. 415 * 416 * Returns AVRC_SUCCESS if successful. 417 * AVRC_NO_RESOURCES if there are not enough resources to open 418 * the connection. 419 * 420 *****************************************************************************/ 421 uint16_t AVRC_Open(uint8_t* p_handle, tAVRC_CONN_CB* p_ccb, const RawAddress& peer_addr); 422 423 /****************************************************************************** 424 * 425 * Function AVRC_Close 426 * 427 * Description Close a connection opened with AVRC_Open(). 428 * This function is called when the 429 * application is no longer using a connection. 430 * 431 * Input Parameters: 432 * handle: Handle of this connection. 433 * 434 * Output Parameters: 435 * None. 436 * 437 * Returns AVRC_SUCCESS if successful. 438 * AVRC_BAD_HANDLE if handle is invalid. 439 * 440 *****************************************************************************/ 441 uint16_t AVRC_Close(uint8_t handle); 442 443 /****************************************************************************** 444 * 445 * Function AVRC_OpenBrowse 446 * 447 * Description This function is called to open a browsing connection to 448 * AVCTP. The connection can be either an initiator or 449 * acceptor, as determined by the conn_role. 450 * The handle is returned by a previous call to AVRC_Open. 451 * 452 * Returns AVRC_SUCCESS if successful. 453 * AVRC_NO_RESOURCES if there are not enough resources to open 454 * the connection. 455 * 456 *****************************************************************************/ 457 uint16_t AVRC_OpenBrowse(uint8_t handle, tAVCT_ROLE conn_role); 458 459 /****************************************************************************** 460 * 461 * Function AVRC_CloseBrowse 462 * 463 * Description Close a connection opened with AVRC_OpenBrowse(). 464 * This function is called when the 465 * application is no longer using a connection. 466 * 467 * Returns AVRC_SUCCESS if successful. 468 * AVRC_BAD_HANDLE if handle is invalid. 469 * 470 *****************************************************************************/ 471 uint16_t AVRC_CloseBrowse(uint8_t handle); 472 473 /****************************************************************************** 474 * 475 * Function AVRC_MsgReq 476 * 477 * Description This function is used to send the AVRCP byte stream in p_pkt 478 * down to AVCTP. 479 * 480 * It is expected that: 481 * p_pkt->offset is at least AVCT_MSG_OFFSET 482 * p_pkt->layer_specific is AVCT_DATA_CTRL or AVCT_DATA_BROWSE 483 * p_pkt->event is AVRC_OP_VENDOR, AVRC_OP_PASS_THRU or 484 * AVRC_OP_BROWSING 485 * The above BT_HDR settings are set by the AVRC_Bld* 486 * functions. 487 * 488 * Returns AVRC_SUCCESS if successful. 489 * AVRC_BAD_HANDLE if handle is invalid. 490 * 491 *****************************************************************************/ 492 uint16_t AVRC_MsgReq(uint8_t handle, uint8_t label, uint8_t ctype, BT_HDR* p_pkt, 493 bool is_new_avrcp); 494 495 /****************************************************************************** 496 * 497 * Function AVRC_SaveControllerVersion 498 * 499 * Description Save AVRC controller version of peer device into bt_config. 500 * This version is used to send same AVRC target version to 501 * peer device to avoid version mismatch IOP issue. 502 * 503 * Input Parameters: 504 * bdaddr: BD address of peer device. 505 * 506 * version: AVRC controller version of peer device. 507 * 508 * Output Parameters: 509 * None. 510 * 511 * Returns Nothing 512 * 513 *****************************************************************************/ 514 void AVRC_SaveControllerVersion(const RawAddress& bdaddr, uint16_t new_version); 515 516 /****************************************************************************** 517 * 518 * Function AVRC_UnitCmd 519 * 520 * Description Send a UNIT INFO command to the peer device. This 521 * function can only be called for controller role connections. 522 * Any response message from the peer is passed back through 523 * the tAVRC_MSG_CBACK callback function. 524 * 525 * Input Parameters: 526 * handle: Handle of this connection. 527 * 528 * label: Transaction label. 529 * 530 * Output Parameters: 531 * None. 532 * 533 * Returns AVRC_SUCCESS if successful. 534 * AVRC_BAD_HANDLE if handle is invalid. 535 * 536 *****************************************************************************/ 537 uint16_t AVRC_UnitCmd(uint8_t handle, uint8_t label); 538 539 /****************************************************************************** 540 * 541 * Function AVRC_SubCmd 542 * 543 * Description Send a SUBUNIT INFO command to the peer device. This 544 * function can only be called for controller role connections. 545 * Any response message from the peer is passed back through 546 * the tAVRC_MSG_CBACK callback function. 547 * 548 * Input Parameters: 549 * handle: Handle of this connection. 550 * 551 * label: Transaction label. 552 * 553 * page: Specifies which part of the subunit type table 554 * is requested. For AVRCP it is typically zero. 555 * Value range is 0-7. 556 * 557 * Output Parameters: 558 * None. 559 * 560 * Returns AVRC_SUCCESS if successful. 561 * AVRC_BAD_HANDLE if handle is invalid. 562 * 563 *****************************************************************************/ 564 uint16_t AVRC_SubCmd(uint8_t handle, uint8_t label, uint8_t page); 565 566 /****************************************************************************** 567 * 568 * Function AVRC_PassCmd 569 * 570 * Description Send a PASS THROUGH command to the peer device. This 571 * function can only be called for controller role connections. 572 * Any response message from the peer is passed back through 573 * the tAVRC_MSG_CBACK callback function. 574 * 575 * Input Parameters: 576 * handle: Handle of this connection. 577 * 578 * label: Transaction label. 579 * 580 * p_msg: Pointer to PASS THROUGH message structure. 581 * 582 * Output Parameters: 583 * None. 584 * 585 * Returns AVRC_SUCCESS if successful. 586 * AVRC_BAD_HANDLE if handle is invalid. 587 * 588 *****************************************************************************/ 589 uint16_t AVRC_PassCmd(uint8_t handle, uint8_t label, tAVRC_MSG_PASS* p_msg); 590 591 /****************************************************************************** 592 * 593 * Function AVRC_PassRsp 594 * 595 * Description Send a PASS THROUGH response to the peer device. This 596 * function can only be called for target role connections. 597 * This function must be called when a PASS THROUGH command 598 * message is received from the peer through the 599 * tAVRC_MSG_CBACK callback function. 600 * 601 * Input Parameters: 602 * handle: Handle of this connection. 603 * 604 * label: Transaction label. Must be the same value as 605 * passed with the command message in the callback 606 * function. 607 * 608 * p_msg: Pointer to PASS THROUGH message structure. 609 * 610 * Output Parameters: 611 * None. 612 * 613 * Returns AVRC_SUCCESS if successful. 614 * AVRC_BAD_HANDLE if handle is invalid. 615 * 616 *****************************************************************************/ 617 uint16_t AVRC_PassRsp(uint8_t handle, uint8_t label, tAVRC_MSG_PASS* p_msg); 618 619 /****************************************************************************** 620 * 621 * Function AVRC_VendorCmd 622 * 623 * Description Send a VENDOR DEPENDENT command to the peer device. This 624 * function can only be called for controller role connections. 625 * Any response message from the peer is passed back through 626 * the tAVRC_MSG_CBACK callback function. 627 * 628 * Input Parameters: 629 * handle: Handle of this connection. 630 * 631 * label: Transaction label. 632 * 633 * p_msg: Pointer to VENDOR DEPENDENT message structure. 634 * 635 * Output Parameters: 636 * None. 637 * 638 * Returns AVRC_SUCCESS if successful. 639 * AVRC_BAD_HANDLE if handle is invalid. 640 * 641 *****************************************************************************/ 642 uint16_t AVRC_VendorCmd(uint8_t handle, uint8_t label, tAVRC_MSG_VENDOR* p_msg); 643 644 /****************************************************************************** 645 * 646 * Function AVRC_VendorRsp 647 * 648 * Description Send a VENDOR DEPENDENT response to the peer device. This 649 * function can only be called for target role connections. 650 * This function must be called when a VENDOR DEPENDENT 651 * command message is received from the peer through the 652 * tAVRC_MSG_CBACK callback function. 653 * 654 * Input Parameters: 655 * handle: Handle of this connection. 656 * 657 * label: Transaction label. Must be the same value as 658 * passed with the command message in the callback 659 * function. 660 * 661 * p_msg: Pointer to VENDOR DEPENDENT message structure. 662 * 663 * Output Parameters: 664 * None. 665 * 666 * Returns AVRC_SUCCESS if successful. 667 * AVRC_BAD_HANDLE if handle is invalid. 668 * 669 *****************************************************************************/ 670 uint16_t AVRC_VendorRsp(uint8_t handle, uint8_t label, tAVRC_MSG_VENDOR* p_msg); 671 672 /******************************************************************************* 673 * 674 * Function AVRC_Init 675 * 676 * Description This function is called at stack startup to allocate the 677 * control block (if using dynamic memory), and initializes the 678 * control block and tracing level. 679 * 680 * Returns void 681 * 682 ******************************************************************************/ 683 void AVRC_Init(void); 684 685 /******************************************************************************* 686 * 687 * Function AVRC_Ctrl_ParsCommand 688 * 689 * Description This function is used to parse cmds received for CTRL 690 * Currently it is for SetAbsVolume and Volume Change 691 * Notification.. 692 * 693 * Returns AVRC_STS_NO_ERROR, if the message in p_data is parsed 694 * successfully. 695 * Otherwise, the error code defined by AVRCP 1.4 696 * 697 ******************************************************************************/ 698 tAVRC_STS AVRC_Ctrl_ParsCommand(tAVRC_MSG* p_msg, tAVRC_COMMAND* p_result); 699 700 /******************************************************************************* 701 * 702 * Function AVRC_ParsCommand 703 * 704 * Description This function is used to parse the received command. 705 * 706 * Returns AVRC_STS_NO_ERROR, if the message in p_data is parsed 707 * successfully. 708 * Otherwise, the error code defined by AVRCP 1.4 709 * 710 ******************************************************************************/ 711 tAVRC_STS AVRC_ParsCommand(tAVRC_MSG* p_msg, tAVRC_COMMAND* p_result, uint8_t* p_buf, 712 uint16_t buf_len); 713 714 /******************************************************************************* 715 * 716 * Function AVRC_ParsResponse 717 * 718 * Description This function is used to parse the received response. 719 * 720 * Returns AVRC_STS_NO_ERROR, if the message in p_data is parsed 721 * successfully. 722 * Otherwise, the error code defined by AVRCP 1.4 723 * 724 ******************************************************************************/ 725 tAVRC_STS AVRC_ParsResponse(tAVRC_MSG* p_msg, tAVRC_RESPONSE* p_result, uint8_t* p_buf, 726 uint16_t buf_len); 727 728 /******************************************************************************* 729 * 730 * Function AVRC_Ctrl_ParsResponse 731 * 732 * Description This function is a parse response for AVRCP Controller. 733 * 734 * Returns AVRC_STS_NO_ERROR, if the message in p_data is parsed 735 * successfully. 736 * Otherwise, the error code defined by AVRCP 1.4 737 * 738 ******************************************************************************/ 739 tAVRC_STS AVRC_Ctrl_ParsResponse(tAVRC_MSG* p_msg, tAVRC_RESPONSE* p_result, uint8_t* p_buf, 740 uint16_t* buf_len); 741 742 /******************************************************************************* 743 * 744 * Function AVRC_BldCommand 745 * 746 * Description This function builds the given AVRCP command to the given 747 * GKI buffer 748 * 749 * Returns AVRC_STS_NO_ERROR, if the command is built successfully 750 * Otherwise, the error code. 751 * 752 ******************************************************************************/ 753 tAVRC_STS AVRC_BldCommand(tAVRC_COMMAND* p_cmd, BT_HDR** pp_pkt); 754 755 /******************************************************************************* 756 * 757 * Function AVRC_BldResponse 758 * 759 * Description This function builds the given AVRCP response to the given 760 * GKI buffer 761 * 762 * Returns AVRC_STS_NO_ERROR, if the response is built successfully 763 * Otherwise, the error code. 764 * 765 ******************************************************************************/ 766 tAVRC_STS AVRC_BldResponse(uint8_t handle, tAVRC_RESPONSE* p_rsp, BT_HDR** pp_pkt); 767 768 /************************************************************************** 769 * 770 * Function AVRC_IsValidAvcType 771 * 772 * Description Check if correct AVC type is specified 773 * 774 * Returns returns true if it is valid 775 * 776 * 777 ******************************************************************************/ 778 bool AVRC_IsValidAvcType(uint8_t pdu_id, uint8_t avc_type); 779 780 /******************************************************************************* 781 * 782 * Function AVRC_IsValidPlayerAttr 783 * 784 * Description Check if the given attrib value is a valid one 785 * 786 * 787 * Returns returns true if it is valid 788 * 789 ******************************************************************************/ 790 bool AVRC_IsValidPlayerAttr(uint8_t attr); 791 792 void AVRC_UpdateCcb(RawAddress* addr, uint32_t company_id); 793 794 #endif /* AVRC_API_H */ 795