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