1 /* 2 * Copyright (C) 2012 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 #ifndef ANDROID_INCLUDE_BT_RC_H 18 #define ANDROID_INCLUDE_BT_RC_H 19 20 #include <raw_address.h> 21 __BEGIN_DECLS 22 23 /* Change this macro to use multiple RC */ 24 #define BT_RC_NUM_APP 6 25 26 /* Macros */ 27 #define BTRC_MAX_ATTR_STR_LEN (1 << 16) 28 #define BTRC_UID_SIZE 8 29 #define BTRC_MAX_APP_SETTINGS 8 30 #define BTRC_MAX_FOLDER_DEPTH 4 31 #define BTRC_MAX_APP_ATTR_SIZE 16 32 #define BTRC_MAX_ELEM_ATTR_SIZE 8 33 #define BTRC_FEATURE_BIT_MASK_SIZE 16 34 35 /* Macros for valid scopes in get_folder_items */ 36 #define BTRC_SCOPE_PLAYER_LIST 0x00 /* Media Player List */ 37 #define BTRC_SCOPE_FILE_SYSTEM 0x01 /* Virtual File System */ 38 #define BTRC_SCOPE_SEARCH 0x02 /* Search */ 39 #define BTRC_SCOPE_NOW_PLAYING 0x03 /* Now Playing */ 40 41 /* Macros for supported character encoding */ 42 #define BTRC_CHARSET_ID_UTF8 0x006A 43 44 /* Macros for item types */ 45 #define BTRC_ITEM_PLAYER 0x01 /* Media Player */ 46 #define BTRC_ITEM_FOLDER 0x02 /* Folder */ 47 #define BTRC_ITEM_MEDIA 0x03 /* Media File */ 48 49 /* Macros for media attribute IDs */ 50 #define BTRC_MEDIA_ATTR_ID_INVALID -1 51 #define BTRC_MEDIA_ATTR_ID_TITLE 0x00000001 52 #define BTRC_MEDIA_ATTR_ID_ARTIST 0x00000002 53 #define BTRC_MEDIA_ATTR_ID_ALBUM 0x00000003 54 #define BTRC_MEDIA_ATTR_ID_TRACK_NUM 0x00000004 55 #define BTRC_MEDIA_ATTR_ID_NUM_TRACKS 0x00000005 56 #define BTRC_MEDIA_ATTR_ID_GENRE 0x00000006 57 #define BTRC_MEDIA_ATTR_ID_PLAYING_TIME 0x00000007 /* in miliseconds */ 58 #define BTRC_MEDIA_ATTR_ID_COVER_ARTWORK_HANDLE 0x00000008 59 60 /* Macros for folder types */ 61 #define BTRC_FOLDER_TYPE_MIXED 0x00 62 #define BTRC_FOLDER_TYPE_TITLES 0x01 63 #define BTRC_FOLDER_TYPE_ALBUMS 0x02 64 #define BTRC_FOLDER_TYPE_ARTISTS 0x03 65 #define BTRC_FOLDER_TYPE_GENRES 0x04 66 #define BTRC_FOLDER_TYPE_PLAYLISTS 0x05 67 #define BTRC_FOLDER_TYPE_YEARS 0x06 68 69 /* Macros for media types */ 70 #define BTRC_MEDIA_TYPE_AUDIO 0x00 /* audio */ 71 #define BTRC_MEDIA_TYPE_VIDEO 0x01 /* video */ 72 73 /* Macros for num attributes */ 74 #define BTRC_NUM_ATTR_NONE 0xFF /* No attributes required */ 75 #define BTRC_NUM_ATTR_ALL 0X00 /* All attributes required */ 76 77 #define BTRC_HANDLE_NONE 0xFF 78 79 typedef uint8_t btrc_uid_t[BTRC_UID_SIZE]; 80 81 typedef enum { 82 BTRC_CONNECTION_STATE_DISCONNECTED = 0, 83 BTRC_CONNECTION_STATE_CONNECTED 84 } btrc_connection_state_t; 85 86 typedef enum { 87 BTRC_FEAT_NONE = 0x00, /* AVRCP 1.0 */ 88 BTRC_FEAT_METADATA = 0x01, /* AVRCP 1.3 */ 89 BTRC_FEAT_ABSOLUTE_VOLUME = 0x02, /* Supports TG role and volume sync */ 90 BTRC_FEAT_BROWSE = 0x04, /* AVRCP 1.4 and up, with Browsing support */ 91 BTRC_FEAT_COVER_ARTWORK = 0x8, /* AVRCP 1.6 and up, Cover Art */ 92 } btrc_remote_features_t; 93 94 typedef enum { 95 BTRC_PLAYSTATE_STOPPED = 0x00, /* Stopped */ 96 BTRC_PLAYSTATE_PLAYING = 0x01, /* Playing */ 97 BTRC_PLAYSTATE_PAUSED = 0x02, /* Paused */ 98 BTRC_PLAYSTATE_FWD_SEEK = 0x03, /* Fwd Seek*/ 99 BTRC_PLAYSTATE_REV_SEEK = 0x04, /* Rev Seek*/ 100 BTRC_PLAYSTATE_ERROR = 0xFF, /* Error */ 101 } btrc_play_status_t; 102 103 typedef enum { 104 BTRC_EVT_PLAY_STATUS_CHANGED = 0x01, 105 BTRC_EVT_TRACK_CHANGE = 0x02, 106 BTRC_EVT_TRACK_REACHED_END = 0x03, 107 BTRC_EVT_TRACK_REACHED_START = 0x04, 108 BTRC_EVT_PLAY_POS_CHANGED = 0x05, 109 BTRC_EVT_APP_SETTINGS_CHANGED = 0x08, 110 BTRC_EVT_NOW_PLAYING_CONTENT_CHANGED = 0x09, 111 BTRC_EVT_AVAL_PLAYER_CHANGE = 0x0a, 112 BTRC_EVT_ADDR_PLAYER_CHANGE = 0x0b, 113 BTRC_EVT_UIDS_CHANGED = 0x0c, 114 BTRC_EVT_VOL_CHANGED = 0x0d, 115 } btrc_event_id_t; 116 117 typedef enum { 118 BTRC_NOTIFICATION_TYPE_INTERIM = 0, 119 BTRC_NOTIFICATION_TYPE_CHANGED = 1, 120 } btrc_notification_type_t; 121 122 typedef enum { 123 BTRC_PLAYER_ATTR_EQUALIZER = 0x01, 124 BTRC_PLAYER_ATTR_REPEAT = 0x02, 125 BTRC_PLAYER_ATTR_SHUFFLE = 0x03, 126 BTRC_PLAYER_ATTR_SCAN = 0x04, 127 } btrc_player_attr_t; 128 129 typedef enum { 130 BTRC_MEDIA_ATTR_TITLE = 0x01, 131 BTRC_MEDIA_ATTR_ARTIST = 0x02, 132 BTRC_MEDIA_ATTR_ALBUM = 0x03, 133 BTRC_MEDIA_ATTR_TRACK_NUM = 0x04, 134 BTRC_MEDIA_ATTR_NUM_TRACKS = 0x05, 135 BTRC_MEDIA_ATTR_GENRE = 0x06, 136 BTRC_MEDIA_ATTR_PLAYING_TIME = 0x07, 137 } btrc_media_attr_t; 138 139 typedef enum { 140 BTRC_PLAYER_VAL_OFF_REPEAT = 0x01, 141 BTRC_PLAYER_VAL_SINGLE_REPEAT = 0x02, 142 BTRC_PLAYER_VAL_ALL_REPEAT = 0x03, 143 BTRC_PLAYER_VAL_GROUP_REPEAT = 0x04 144 } btrc_player_repeat_val_t; 145 146 typedef enum { 147 BTRC_PLAYER_VAL_OFF_SHUFFLE = 0x01, 148 BTRC_PLAYER_VAL_ALL_SHUFFLE = 0x02, 149 BTRC_PLAYER_VAL_GROUP_SHUFFLE = 0x03 150 } btrc_player_shuffle_val_t; 151 152 typedef enum { 153 BTRC_STS_BAD_CMD = 0x00, /* Invalid command */ 154 BTRC_STS_BAD_PARAM = 0x01, /* Invalid parameter */ 155 BTRC_STS_NOT_FOUND = 0x02, /* Specified parameter is wrong or not found */ 156 BTRC_STS_INTERNAL_ERR = 0x03, /* Internal Error */ 157 BTRC_STS_NO_ERROR = 0x04, /* Operation Success */ 158 BTRC_STS_UID_CHANGED = 0x05, /* UIDs changed */ 159 BTRC_STS_RESERVED = 0x06, /* Reserved */ 160 BTRC_STS_INV_DIRN = 0x07, /* Invalid direction */ 161 BTRC_STS_INV_DIRECTORY = 0x08, /* Invalid directory */ 162 BTRC_STS_INV_ITEM = 0x09, /* Invalid Item */ 163 BTRC_STS_INV_SCOPE = 0x0a, /* Invalid scope */ 164 BTRC_STS_INV_RANGE = 0x0b, /* Invalid range */ 165 BTRC_STS_DIRECTORY = 0x0c, /* UID is a directory */ 166 BTRC_STS_MEDIA_IN_USE = 0x0d, /* Media in use */ 167 BTRC_STS_PLAY_LIST_FULL = 0x0e, /* Playing list full */ 168 BTRC_STS_SRCH_NOT_SPRTD = 0x0f, /* Search not supported */ 169 BTRC_STS_SRCH_IN_PROG = 0x10, /* Search in progress */ 170 BTRC_STS_INV_PLAYER = 0x11, /* Invalid player */ 171 BTRC_STS_PLAY_NOT_BROW = 0x12, /* Player not browsable */ 172 BTRC_STS_PLAY_NOT_ADDR = 0x13, /* Player not addressed */ 173 BTRC_STS_INV_RESULTS = 0x14, /* Invalid results */ 174 BTRC_STS_NO_AVBL_PLAY = 0x15, /* No available players */ 175 BTRC_STS_ADDR_PLAY_CHGD = 0x16, /* Addressed player changed */ 176 } btrc_status_t; 177 178 typedef struct { 179 uint16_t player_id; 180 uint16_t uid_counter; 181 } btrc_addr_player_changed_t; 182 183 typedef struct { 184 uint8_t num_attr; 185 uint8_t attr_ids[BTRC_MAX_APP_SETTINGS]; 186 uint8_t attr_values[BTRC_MAX_APP_SETTINGS]; 187 } btrc_player_settings_t; 188 189 typedef struct { 190 uint8_t val; 191 uint16_t charset_id; 192 uint16_t str_len; 193 uint8_t* p_str; 194 } btrc_player_app_ext_attr_val_t; 195 196 typedef struct { 197 uint8_t attr_id; 198 uint16_t charset_id; 199 uint16_t str_len; 200 uint8_t* p_str; 201 uint8_t num_val; 202 btrc_player_app_ext_attr_val_t ext_attr_val[BTRC_MAX_APP_ATTR_SIZE]; 203 } btrc_player_app_ext_attr_t; 204 205 typedef struct { 206 uint8_t attr_id; 207 uint8_t num_val; 208 uint8_t attr_val[BTRC_MAX_APP_ATTR_SIZE]; 209 } btrc_player_app_attr_t; 210 211 typedef struct { 212 uint32_t start_item; 213 uint32_t end_item; 214 uint32_t size; 215 uint32_t attrs[BTRC_MAX_ELEM_ATTR_SIZE]; 216 uint8_t attr_count; 217 } btrc_getfolderitem_t; 218 219 typedef struct { 220 uint16_t type; 221 uint16_t uid_counter; 222 } btrc_uids_changed_t; 223 224 typedef struct { uint16_t type; } btrc_now_playing_changed_t; 225 226 typedef union { 227 btrc_play_status_t play_status; 228 btrc_uid_t track; /* queue position in NowPlaying */ 229 uint32_t song_pos; 230 uint16_t uid_counter; 231 btrc_player_settings_t player_setting; 232 btrc_addr_player_changed_t addr_player_changed; 233 btrc_uids_changed_t uids_changed; 234 btrc_now_playing_changed_t now_playing_changed; 235 } btrc_register_notification_t; 236 237 typedef struct { 238 uint8_t id; /* can be attr_id or value_id */ 239 uint8_t text[BTRC_MAX_ATTR_STR_LEN]; 240 } btrc_player_setting_text_t; 241 242 typedef struct { 243 uint32_t attr_id; 244 uint8_t text[BTRC_MAX_ATTR_STR_LEN]; 245 } btrc_element_attr_val_t; 246 247 typedef struct { 248 uint16_t player_id; 249 uint8_t major_type; 250 uint32_t sub_type; 251 uint8_t play_status; 252 uint8_t features[BTRC_FEATURE_BIT_MASK_SIZE]; 253 uint16_t charset_id; 254 uint8_t name[BTRC_MAX_ATTR_STR_LEN]; 255 } btrc_item_player_t; 256 257 typedef struct { 258 uint8_t uid[BTRC_UID_SIZE]; 259 uint8_t type; 260 uint8_t playable; 261 uint16_t charset_id; 262 uint8_t name[BTRC_MAX_ATTR_STR_LEN]; 263 } btrc_item_folder_t; 264 265 typedef struct { 266 uint8_t uid[BTRC_UID_SIZE]; 267 uint8_t type; 268 uint16_t charset_id; 269 uint8_t name[BTRC_MAX_ATTR_STR_LEN]; 270 int num_attrs; 271 btrc_element_attr_val_t* p_attrs; 272 } btrc_item_media_t; 273 274 typedef struct { 275 uint8_t item_type; 276 union { 277 btrc_item_player_t player; 278 btrc_item_folder_t folder; 279 btrc_item_media_t media; 280 }; 281 } btrc_folder_items_t; 282 283 typedef struct { 284 uint16_t str_len; 285 uint8_t p_str[BTRC_MAX_ATTR_STR_LEN]; 286 } btrc_br_folder_name_t; 287 288 /** Callback for the controller's supported feautres */ 289 typedef void (*btrc_remote_features_callback)(const RawAddress& bd_addr, 290 btrc_remote_features_t features); 291 292 /** Callback for play status request */ 293 typedef void (*btrc_get_play_status_callback)(const RawAddress& bd_addr); 294 295 /** Callback for list player application attributes (Shuffle, Repeat,...) */ 296 typedef void (*btrc_list_player_app_attr_callback)(const RawAddress& bd_addr); 297 298 /** Callback for list player application attributes (Shuffle, Repeat,...) */ 299 typedef void (*btrc_list_player_app_values_callback)(btrc_player_attr_t attr_id, 300 const RawAddress& bd_addr); 301 302 /** Callback for getting the current player application settings value 303 ** num_attr: specifies the number of attribute ids contained in p_attrs 304 */ 305 typedef void (*btrc_get_player_app_value_callback)(uint8_t num_attr, 306 btrc_player_attr_t* p_attrs, 307 const RawAddress& bd_addr); 308 309 /** Callback for getting the player application settings attributes' text 310 ** num_attr: specifies the number of attribute ids contained in p_attrs 311 */ 312 typedef void (*btrc_get_player_app_attrs_text_callback)( 313 uint8_t num_attr, btrc_player_attr_t* p_attrs, const RawAddress& bd_addr); 314 315 /** Callback for getting the player application settings values' text 316 ** num_attr: specifies the number of value ids contained in p_vals 317 */ 318 typedef void (*btrc_get_player_app_values_text_callback)( 319 uint8_t attr_id, uint8_t num_val, uint8_t* p_vals, 320 const RawAddress& bd_addr); 321 322 /** Callback for setting the player application settings values */ 323 typedef void (*btrc_set_player_app_value_callback)( 324 btrc_player_settings_t* p_vals, const RawAddress& bd_addr); 325 326 /** Callback to fetch the get element attributes of the current song 327 ** num_attr: specifies the number of attributes requested in p_attrs 328 */ 329 typedef void (*btrc_get_element_attr_callback)(uint8_t num_attr, 330 btrc_media_attr_t* p_attrs, 331 const RawAddress& bd_addr); 332 333 /** Callback for register notification (Play state change/track change/...) 334 ** param: Is only valid if event_id is BTRC_EVT_PLAY_POS_CHANGED 335 */ 336 typedef void (*btrc_register_notification_callback)(btrc_event_id_t event_id, 337 uint32_t param, 338 const RawAddress& bd_addr); 339 340 /* AVRCP 1.4 Enhancements */ 341 /** Callback for volume change on CT 342 ** volume: Current volume setting on the CT (0-127) 343 */ 344 typedef void (*btrc_volume_change_callback)(uint8_t volume, uint8_t ctype, 345 const RawAddress& bd_addr); 346 347 /** Callback for passthrough commands */ 348 typedef void (*btrc_passthrough_cmd_callback)(int id, int key_state, 349 const RawAddress& bd_addr); 350 351 /** Callback for set addressed player response on TG **/ 352 typedef void (*btrc_set_addressed_player_callback)(uint16_t player_id, 353 const RawAddress& bd_addr); 354 355 /** Callback for set browsed player response on TG **/ 356 typedef void (*btrc_set_browsed_player_callback)(uint16_t player_id, 357 const RawAddress& bd_addr); 358 359 /** Callback for get folder items on TG 360 ** num_attr: specifies the number of attributes requested in p_attr_ids 361 */ 362 typedef void (*btrc_get_folder_items_callback)( 363 uint8_t scope, uint32_t start_item, uint32_t end_item, uint8_t num_attr, 364 uint32_t* p_attr_ids, const RawAddress& bd_addr); 365 366 /** Callback for changing browsed path on TG **/ 367 typedef void (*btrc_change_path_callback)(uint8_t direction, 368 uint8_t* folder_uid, 369 const RawAddress& bd_addr); 370 371 /** Callback to fetch the get item attributes of the media item 372 ** num_attr: specifies the number of attributes requested in p_attrs 373 */ 374 typedef void (*btrc_get_item_attr_callback)(uint8_t scope, uint8_t* uid, 375 uint16_t uid_counter, 376 uint8_t num_attr, 377 btrc_media_attr_t* p_attrs, 378 const RawAddress& bd_addr); 379 380 /** Callback for play request for the media item indicated by an identifier */ 381 typedef void (*btrc_play_item_callback)(uint8_t scope, uint16_t uid_counter, 382 uint8_t* uid, 383 const RawAddress& bd_addr); 384 385 /** Callback to fetch total number of items from a folder **/ 386 typedef void (*btrc_get_total_num_of_items_callback)(uint8_t scope, 387 const RawAddress& bd_addr); 388 389 /** Callback for conducting recursive search on a current browsed path for a 390 * specified string */ 391 typedef void (*btrc_search_callback)(uint16_t charset_id, uint16_t str_len, 392 uint8_t* p_str, const RawAddress& bd_addr); 393 394 /** Callback to add a specified media item indicated by an identifier to now 395 * playing queue. */ 396 typedef void (*btrc_add_to_now_playing_callback)(uint8_t scope, uint8_t* uid, 397 uint16_t uid_counter, 398 const RawAddress& bd_addr); 399 400 /** BT-RC Target callback structure. */ 401 typedef struct { 402 /** set to sizeof(BtRcCallbacks) */ 403 size_t size; 404 btrc_remote_features_callback remote_features_cb; 405 btrc_get_play_status_callback get_play_status_cb; 406 btrc_list_player_app_attr_callback list_player_app_attr_cb; 407 btrc_list_player_app_values_callback list_player_app_values_cb; 408 btrc_get_player_app_value_callback get_player_app_value_cb; 409 btrc_get_player_app_attrs_text_callback get_player_app_attrs_text_cb; 410 btrc_get_player_app_values_text_callback get_player_app_values_text_cb; 411 btrc_set_player_app_value_callback set_player_app_value_cb; 412 btrc_get_element_attr_callback get_element_attr_cb; 413 btrc_register_notification_callback register_notification_cb; 414 btrc_volume_change_callback volume_change_cb; 415 btrc_passthrough_cmd_callback passthrough_cmd_cb; 416 btrc_set_addressed_player_callback set_addressed_player_cb; 417 btrc_set_browsed_player_callback set_browsed_player_cb; 418 btrc_get_folder_items_callback get_folder_items_cb; 419 btrc_change_path_callback change_path_cb; 420 btrc_get_item_attr_callback get_item_attr_cb; 421 btrc_play_item_callback play_item_cb; 422 btrc_get_total_num_of_items_callback get_total_num_of_items_cb; 423 btrc_search_callback search_cb; 424 btrc_add_to_now_playing_callback add_to_now_playing_cb; 425 } btrc_callbacks_t; 426 427 /** Represents the standard BT-RC AVRCP Target interface. */ 428 typedef struct { 429 /** set to sizeof(BtRcInterface) */ 430 size_t size; 431 /** 432 * Register the BtRc callbacks 433 */ 434 bt_status_t (*init)(btrc_callbacks_t* callbacks); 435 436 /** Respose to GetPlayStatus request. Contains the current 437 ** 1. Play status 438 ** 2. Song duration/length 439 ** 3. Song position 440 */ 441 bt_status_t (*get_play_status_rsp)(const RawAddress& bd_addr, 442 btrc_play_status_t play_status, 443 uint32_t song_len, uint32_t song_pos); 444 445 /** Lists the support player application attributes (Shuffle/Repeat/...) 446 ** num_attr: Specifies the number of attributes contained in the pointer 447 *p_attrs 448 */ 449 bt_status_t (*list_player_app_attr_rsp)(const RawAddress& bd_addr, 450 int num_attr, 451 btrc_player_attr_t* p_attrs); 452 453 /** Lists the support player application attributes (Shuffle Off/On/Group) 454 ** num_val: Specifies the number of values contained in the pointer p_vals 455 */ 456 bt_status_t (*list_player_app_value_rsp)(const RawAddress& bd_addr, 457 int num_val, uint8_t* p_vals); 458 459 /** Returns the current application attribute values for each of the specified 460 * attr_id */ 461 bt_status_t (*get_player_app_value_rsp)(const RawAddress& bd_addr, 462 btrc_player_settings_t* p_vals); 463 464 /** Returns the application attributes text ("Shuffle"/"Repeat"/...) 465 ** num_attr: Specifies the number of attributes' text contained in the 466 *pointer p_attrs 467 */ 468 bt_status_t (*get_player_app_attr_text_rsp)( 469 const RawAddress& bd_addr, int num_attr, 470 btrc_player_setting_text_t* p_attrs); 471 472 /** Returns the application attributes text ("Shuffle"/"Repeat"/...) 473 ** num_attr: Specifies the number of attribute values' text contained in the 474 *pointer p_vals 475 */ 476 bt_status_t (*get_player_app_value_text_rsp)( 477 const RawAddress& bd_addr, int num_val, 478 btrc_player_setting_text_t* p_vals); 479 480 /** Returns the current songs' element attributes text 481 *("Title"/"Album"/"Artist") 482 ** num_attr: Specifies the number of attributes' text contained in the 483 *pointer p_attrs 484 */ 485 bt_status_t (*get_element_attr_rsp)(const RawAddress& bd_addr, 486 uint8_t num_attr, 487 btrc_element_attr_val_t* p_attrs); 488 489 /** Response to set player attribute request ("Shuffle"/"Repeat") 490 ** rsp_status: Status of setting the player attributes for the current media 491 *player 492 */ 493 bt_status_t (*set_player_app_value_rsp)(const RawAddress& bd_addr, 494 btrc_status_t rsp_status); 495 496 /* Response to the register notification request (Play state change/track 497 *change/...). 498 ** event_id: Refers to the event_id this notification change corresponds too 499 ** type: Response type - interim/changed 500 ** p_params: Based on the event_id, this parameter should be populated 501 */ 502 bt_status_t (*register_notification_rsp)( 503 btrc_event_id_t event_id, btrc_notification_type_t type, 504 btrc_register_notification_t* p_param); 505 506 /* AVRCP 1.4 enhancements */ 507 508 /**Send current volume setting to remote side. Support limited to 509 *SetAbsoluteVolume 510 ** This can be enhanced to support Relative Volume (AVRCP 1.0). 511 ** With RelateVolume, we will send VOLUME_UP/VOLUME_DOWN opposed to absolute 512 *volume level 513 ** volume: Should be in the range 0-127. bit7 is reseved and cannot be set 514 */ 515 bt_status_t (*set_volume)(uint8_t volume); 516 517 /* Set addressed player response from TG to CT */ 518 bt_status_t (*set_addressed_player_rsp)(const RawAddress& bd_addr, 519 btrc_status_t rsp_status); 520 521 /* Set browsed player response from TG to CT */ 522 bt_status_t (*set_browsed_player_rsp)(const RawAddress& bd_addr, 523 btrc_status_t rsp_status, 524 uint32_t num_items, uint16_t charset_id, 525 uint8_t folder_depth, 526 btrc_br_folder_name_t* p_folders); 527 528 /* Get folder item list response from TG to CT */ 529 bt_status_t (*get_folder_items_list_rsp)(const RawAddress& bd_addr, 530 btrc_status_t rsp_status, 531 uint16_t uid_counter, 532 uint8_t num_items, 533 btrc_folder_items_t* p_items); 534 535 /* Change path response from TG to CT */ 536 bt_status_t (*change_path_rsp)(const RawAddress& bd_addr, 537 btrc_status_t rsp_status, uint32_t num_items); 538 539 /** Returns the element's attributes num_attr: Specifies the number of 540 * attributes' text contained in the pointer p_attrs 541 */ 542 bt_status_t (*get_item_attr_rsp)(const RawAddress& bd_addr, 543 btrc_status_t rsp_status, uint8_t num_attr, 544 btrc_element_attr_val_t* p_attrs); 545 546 /* play media item response from TG to CT */ 547 bt_status_t (*play_item_rsp)(const RawAddress& bd_addr, 548 btrc_status_t rsp_status); 549 550 /* get total number of items response from TG to CT*/ 551 bt_status_t (*get_total_num_of_items_rsp)(const RawAddress& bd_addr, 552 btrc_status_t rsp_status, 553 uint32_t uid_counter, 554 uint32_t num_items); 555 556 /* Search VFS response from TG to CT */ 557 bt_status_t (*search_rsp)(const RawAddress& bd_addr, btrc_status_t rsp_status, 558 uint32_t uid_counter, uint32_t num_items); 559 560 /* add_to_now playing list response from TG to CT */ 561 bt_status_t (*add_to_now_playing_rsp)(const RawAddress& bd_addr, 562 btrc_status_t rsp_status); 563 564 /** Closes the interface. */ 565 void (*cleanup)(void); 566 } btrc_interface_t; 567 568 typedef void (*btrc_passthrough_rsp_callback)(const RawAddress& bd_addr, int id, 569 int key_state); 570 571 typedef void (*btrc_groupnavigation_rsp_callback)(int id, int key_state); 572 573 typedef void (*btrc_connection_state_callback)(bool rc_connect, bool bt_connect, 574 const RawAddress& bd_addr); 575 576 typedef void (*btrc_ctrl_getrcfeatures_callback)(const RawAddress& bd_addr, 577 int features); 578 579 typedef void (*btrc_ctrl_setabsvol_cmd_callback)(const RawAddress& bd_addr, 580 uint8_t abs_vol, 581 uint8_t label); 582 583 typedef void (*btrc_ctrl_registernotification_abs_vol_callback)( 584 const RawAddress& bd_addr, uint8_t label); 585 586 typedef void (*btrc_ctrl_setplayerapplicationsetting_rsp_callback)( 587 const RawAddress& bd_addr, uint8_t accepted); 588 589 typedef void (*btrc_ctrl_playerapplicationsetting_callback)( 590 const RawAddress& bd_addr, uint8_t num_attr, 591 btrc_player_app_attr_t* app_attrs, uint8_t num_ext_attr, 592 btrc_player_app_ext_attr_t* ext_attrs); 593 594 typedef void (*btrc_ctrl_playerapplicationsetting_changed_callback)( 595 const RawAddress& bd_addr, const btrc_player_settings_t& vals); 596 597 typedef void (*btrc_ctrl_track_changed_callback)( 598 const RawAddress& bd_addr, uint8_t num_attr, 599 btrc_element_attr_val_t* p_attrs); 600 601 typedef void (*btrc_ctrl_play_position_changed_callback)( 602 const RawAddress& bd_addr, uint32_t song_len, uint32_t song_pos); 603 604 typedef void (*btrc_ctrl_play_status_changed_callback)( 605 const RawAddress& bd_addr, btrc_play_status_t play_status); 606 607 typedef void (*btrc_ctrl_get_folder_items_callback)( 608 const RawAddress& bd_addr, btrc_status_t status, 609 const btrc_folder_items_t* folder_items, uint8_t count); 610 611 typedef void (*btrc_ctrl_change_path_callback)(const RawAddress& bd_addr, 612 uint32_t count); 613 614 typedef void (*btrc_ctrl_set_browsed_player_callback)(const RawAddress& bd_addr, 615 uint8_t num_items, 616 uint8_t depth); 617 typedef void (*btrc_ctrl_set_addressed_player_callback)( 618 const RawAddress& bd_addr, uint8_t status); 619 typedef void (*btrc_ctrl_addressed_player_changed_callback)( 620 const RawAddress& bd_addr, uint16_t id); 621 typedef void (*btrc_ctrl_now_playing_contents_changed_callback)( 622 const RawAddress& bd_addr); 623 typedef void (*btrc_ctrl_available_player_changed_callback)( 624 const RawAddress& bd_addr); 625 626 typedef void (*btrc_ctrl_get_cover_art_psm_callback)(const RawAddress& bd_addr, 627 const uint16_t psm); 628 629 /** BT-RC Controller callback structure. */ 630 typedef struct { 631 /** set to sizeof(BtRcCallbacks) */ 632 size_t size; 633 btrc_passthrough_rsp_callback passthrough_rsp_cb; 634 btrc_groupnavigation_rsp_callback groupnavigation_rsp_cb; 635 btrc_connection_state_callback connection_state_cb; 636 btrc_ctrl_getrcfeatures_callback getrcfeatures_cb; 637 btrc_ctrl_setplayerapplicationsetting_rsp_callback setplayerappsetting_rsp_cb; 638 btrc_ctrl_playerapplicationsetting_callback playerapplicationsetting_cb; 639 btrc_ctrl_playerapplicationsetting_changed_callback 640 playerapplicationsetting_changed_cb; 641 btrc_ctrl_setabsvol_cmd_callback setabsvol_cmd_cb; 642 btrc_ctrl_registernotification_abs_vol_callback 643 registernotification_absvol_cb; 644 btrc_ctrl_track_changed_callback track_changed_cb; 645 btrc_ctrl_play_position_changed_callback play_position_changed_cb; 646 btrc_ctrl_play_status_changed_callback play_status_changed_cb; 647 btrc_ctrl_get_folder_items_callback get_folder_items_cb; 648 btrc_ctrl_change_path_callback change_folder_path_cb; 649 btrc_ctrl_set_browsed_player_callback set_browsed_player_cb; 650 btrc_ctrl_set_addressed_player_callback set_addressed_player_cb; 651 btrc_ctrl_addressed_player_changed_callback addressed_player_changed_cb; 652 btrc_ctrl_now_playing_contents_changed_callback 653 now_playing_contents_changed_cb; 654 btrc_ctrl_available_player_changed_callback available_player_changed_cb; 655 btrc_ctrl_get_cover_art_psm_callback get_cover_art_psm_cb; 656 } btrc_ctrl_callbacks_t; 657 658 /** Represents the standard BT-RC AVRCP Controller interface. */ 659 typedef struct { 660 /** set to sizeof(BtRcInterface) */ 661 size_t size; 662 /** 663 * Register the BtRc callbacks 664 */ 665 bt_status_t (*init)(btrc_ctrl_callbacks_t* callbacks); 666 667 /** send pass through command to target */ 668 bt_status_t (*send_pass_through_cmd)(const RawAddress& bd_addr, 669 uint8_t key_code, uint8_t key_state); 670 671 /** send group navigation command to target */ 672 bt_status_t (*send_group_navigation_cmd)(const RawAddress& bd_addr, 673 uint8_t key_code, uint8_t key_state); 674 675 /** send command to set player applicaiton setting attributes to target */ 676 bt_status_t (*set_player_app_setting_cmd)(const RawAddress& bd_addr, 677 uint8_t num_attrib, 678 uint8_t* attrib_ids, 679 uint8_t* attrib_vals); 680 681 /** send command to play a particular item */ 682 bt_status_t (*play_item_cmd)(const RawAddress& bd_addr, uint8_t scope, 683 uint8_t* uid, uint16_t uid_counter); 684 685 /** get the current track's media metadata */ 686 bt_status_t (*get_current_metadata_cmd)(const RawAddress& bd_addr); 687 688 /** get the playback state */ 689 bt_status_t (*get_playback_state_cmd)(const RawAddress& bd_addr); 690 691 /** get the now playing list */ 692 bt_status_t (*get_now_playing_list_cmd)(const RawAddress& bd_addr, 693 uint32_t start, uint32_t end); 694 695 /** get the folder list */ 696 bt_status_t (*get_folder_list_cmd)(const RawAddress& bd_addr, uint32_t start, 697 uint32_t end); 698 699 /** get the player list */ 700 bt_status_t (*get_player_list_cmd)(const RawAddress& bd_addr, uint32_t start, 701 uint32_t end); 702 703 /** change the folder path */ 704 bt_status_t (*change_folder_path_cmd)(const RawAddress& bd_addr, 705 uint8_t direction, uint8_t* uid); 706 707 /** set browsed player */ 708 bt_status_t (*set_browsed_player_cmd)(const RawAddress& bd_addr, 709 uint16_t player_id); 710 711 /** set addressed player */ 712 bt_status_t (*set_addressed_player_cmd)(const RawAddress& bd_addr, 713 uint16_t player_id); 714 715 /** send rsp to set_abs_vol received from target */ 716 bt_status_t (*set_volume_rsp)(const RawAddress& bd_addr, uint8_t abs_vol, 717 uint8_t label); 718 719 /** send notificaiton rsp for abs vol to target */ 720 bt_status_t (*register_abs_vol_rsp)(const RawAddress& bd_addr, 721 btrc_notification_type_t rsp_type, 722 uint8_t abs_vol, uint8_t label); 723 724 /** Closes the interface. */ 725 void (*cleanup)(void); 726 } btrc_ctrl_interface_t; 727 728 __END_DECLS 729 730 #if __has_include(<bluetooth/log.h>) 731 #include <bluetooth/log.h> 732 733 namespace fmt { 734 template <> 735 struct formatter<btrc_status_t> : enum_formatter<btrc_status_t> {}; 736 template <> 737 struct formatter<btrc_event_id_t> : enum_formatter<btrc_event_id_t> {}; 738 template <> 739 struct formatter<btrc_remote_features_t> 740 : enum_formatter<btrc_remote_features_t> {}; 741 template <> 742 struct formatter<btrc_notification_type_t> 743 : enum_formatter<btrc_notification_type_t> {}; 744 } // namespace fmt 745 746 #endif // __has_include(<bluetooth/log.h>) 747 748 #endif /* ANDROID_INCLUDE_BT_RC_H */ 749