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