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