blob: 20fe3bf395b27f228d51a50574ece7a0809ba315 [file] [log] [blame]
Ravi Nagarajan482ba782013-02-26 10:34:41 -08001/*
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/* Macros */
23#define BTRC_MAX_ATTR_STR_LEN 255
24#define BTRC_UID_SIZE 8
25#define BTRC_MAX_APP_SETTINGS 8
26#define BTRC_MAX_FOLDER_DEPTH 4
27#define BTRC_MAX_APP_ATTR_SIZE 16
Ravi Nagarajanebb8c1b2013-03-22 04:18:47 -070028#define BTRC_MAX_ELEM_ATTR_SIZE 7
Ayan Ghosh78becc12014-07-25 17:11:58 +053029#define BTRC_CHARSET_UTF8 0x006A
Ravi Nagarajan482ba782013-02-26 10:34:41 -080030
31typedef uint8_t btrc_uid_t[BTRC_UID_SIZE];
32
33typedef enum {
Satya Callojife9728d2013-08-01 03:11:11 -070034 BTRC_FEAT_NONE = 0x00, /* AVRCP 1.0 */
35 BTRC_FEAT_METADATA = 0x01, /* AVRCP 1.3 */
36 BTRC_FEAT_ABSOLUTE_VOLUME = 0x02, /* Supports TG role and volume sync */
37 BTRC_FEAT_BROWSE = 0x04, /* AVRCP 1.4 and up, with Browsing support */
38} btrc_remote_features_t;
39
40typedef enum {
Ravi Nagarajan482ba782013-02-26 10:34:41 -080041 BTRC_PLAYSTATE_STOPPED = 0x00, /* Stopped */
42 BTRC_PLAYSTATE_PLAYING = 0x01, /* Playing */
43 BTRC_PLAYSTATE_PAUSED = 0x02, /* Paused */
44 BTRC_PLAYSTATE_FWD_SEEK = 0x03, /* Fwd Seek*/
45 BTRC_PLAYSTATE_REV_SEEK = 0x04, /* Rev Seek*/
46 BTRC_PLAYSTATE_ERROR = 0xFF, /* Error */
47} btrc_play_status_t;
48
49typedef enum {
50 BTRC_EVT_PLAY_STATUS_CHANGED = 0x01,
51 BTRC_EVT_TRACK_CHANGE = 0x02,
52 BTRC_EVT_TRACK_REACHED_END = 0x03,
53 BTRC_EVT_TRACK_REACHED_START = 0x04,
54 BTRC_EVT_PLAY_POS_CHANGED = 0x05,
55 BTRC_EVT_APP_SETTINGS_CHANGED = 0x08,
Ayan Ghosh78becc12014-07-25 17:11:58 +053056 BTRC_EVT_NOW_PLAYING_CONTENT_CHANGED = 0x09,
57 BTRC_EVT_AVAILABLE_PLAYERS_CHANGED = 0x0a,
58 BTRC_EVT_ADDRESSED_PLAYER_CHANGED = 0x0b,
Ravi Nagarajan482ba782013-02-26 10:34:41 -080059} btrc_event_id_t;
60
Ayan Ghosh78becc12014-07-25 17:11:58 +053061//used for Scope
62typedef enum {
63 BTRC_EVT_MEDIA_PLAYLIST = 0,
64 BTRC_EVT_MEDIA_VIRTUALFILESYST = 1,
65 BTRC_EVT_SEARCH = 2,
66 BTRC_EVT_NOWPLAYING = 3,
67 BTRC_EVT_MAX_BROWSE = 4,
68} btrc_browse_folderitem_t;
69
Ravi Nagarajan482ba782013-02-26 10:34:41 -080070typedef enum {
71 BTRC_NOTIFICATION_TYPE_INTERIM = 0,
72 BTRC_NOTIFICATION_TYPE_CHANGED = 1,
Ayan Ghosh78becc12014-07-25 17:11:58 +053073 BTRC_NOTIFICATION_TYPE_REJECT = 2,
Ravi Nagarajan482ba782013-02-26 10:34:41 -080074} btrc_notification_type_t;
75
76typedef enum {
77 BTRC_PLAYER_ATTR_EQUALIZER = 0x01,
78 BTRC_PLAYER_ATTR_REPEAT = 0x02,
79 BTRC_PLAYER_ATTR_SHUFFLE = 0x03,
80 BTRC_PLAYER_ATTR_SCAN = 0x04,
81} btrc_player_attr_t;
82
83typedef enum {
84 BTRC_MEDIA_ATTR_TITLE = 0x01,
85 BTRC_MEDIA_ATTR_ARTIST = 0x02,
86 BTRC_MEDIA_ATTR_ALBUM = 0x03,
87 BTRC_MEDIA_ATTR_TRACK_NUM = 0x04,
88 BTRC_MEDIA_ATTR_NUM_TRACKS = 0x05,
89 BTRC_MEDIA_ATTR_GENRE = 0x06,
90 BTRC_MEDIA_ATTR_PLAYING_TIME = 0x07,
91} btrc_media_attr_t;
92
93typedef enum {
94 BTRC_PLAYER_VAL_OFF_REPEAT = 0x01,
95 BTRC_PLAYER_VAL_SINGLE_REPEAT = 0x02,
96 BTRC_PLAYER_VAL_ALL_REPEAT = 0x03,
97 BTRC_PLAYER_VAL_GROUP_REPEAT = 0x04
98} btrc_player_repeat_val_t;
99
100typedef enum {
101 BTRC_PLAYER_VAL_OFF_SHUFFLE = 0x01,
102 BTRC_PLAYER_VAL_ALL_SHUFFLE = 0x02,
103 BTRC_PLAYER_VAL_GROUP_SHUFFLE = 0x03
104} btrc_player_shuffle_val_t;
105
106typedef enum {
107 BTRC_STS_BAD_CMD = 0x00, /* Invalid command */
108 BTRC_STS_BAD_PARAM = 0x01, /* Invalid parameter */
109 BTRC_STS_NOT_FOUND = 0x02, /* Specified parameter is wrong or not found */
110 BTRC_STS_INTERNAL_ERR = 0x03, /* Internal Error */
111 BTRC_STS_NO_ERROR = 0x04 /* Operation Success */
112} btrc_status_t;
113
Ayan Ghosh78becc12014-07-25 17:11:58 +0530114typedef enum {
115 BTRC_TYPE_MEDIA_PLAYER = 0x01,
116 BTRC_TYPE_FOLDER = 0x02,
117 BTRC_TYPE_MEDIA_ELEMENT = 0x03
118} btrc_folder_list_item_type_t;
119
Ravi Nagarajan482ba782013-02-26 10:34:41 -0800120typedef struct {
121 uint8_t num_attr;
122 uint8_t attr_ids[BTRC_MAX_APP_SETTINGS];
123 uint8_t attr_values[BTRC_MAX_APP_SETTINGS];
124} btrc_player_settings_t;
125
Ayan Ghosh78becc12014-07-25 17:11:58 +0530126typedef struct {
127 uint32_t start_item;
128 uint32_t end_item;
129 uint32_t size;
130 uint32_t attrs[BTRC_MAX_ELEM_ATTR_SIZE];
131 uint8_t attr_count;
132}btrc_getfolderitem_t;
133
Ravi Nagarajan482ba782013-02-26 10:34:41 -0800134typedef union
135{
136 btrc_play_status_t play_status;
137 btrc_uid_t track; /* queue position in NowPlaying */
138 uint32_t song_pos;
139 btrc_player_settings_t player_setting;
Ayan Ghosh78becc12014-07-25 17:11:58 +0530140 uint16_t player_id;
Ravi Nagarajan482ba782013-02-26 10:34:41 -0800141} btrc_register_notification_t;
142
143typedef struct {
144 uint8_t id; /* can be attr_id or value_id */
145 uint8_t text[BTRC_MAX_ATTR_STR_LEN];
146} btrc_player_setting_text_t;
147
148typedef struct {
149 uint32_t attr_id;
150 uint8_t text[BTRC_MAX_ATTR_STR_LEN];
151} btrc_element_attr_val_t;
152
Satya Callojife9728d2013-08-01 03:11:11 -0700153/** Callback for the controller's supported feautres */
154typedef void (* btrc_remote_features_callback)(bt_bdaddr_t *bd_addr,
155 btrc_remote_features_t features);
Ayan Ghosh78becc12014-07-25 17:11:58 +0530156#define BTRC_FEATURE_MASK_SIZE 16
157
158typedef uint8_t btrc_feature_mask_t[BTRC_FEATURE_MASK_SIZE];
159
160typedef struct {
161 uint16_t charset_id;
162 uint16_t str_len;
163 uint8_t *p_str;
164} btrc_player_full_name_t;
165
166typedef struct
167{
168 uint32_t sub_type;
169 uint16_t player_id;
170 uint8_t major_type;
171 uint8_t play_status;
172 btrc_feature_mask_t features; /* Supported feature bit mask*/
173 btrc_player_full_name_t name; /* The player name, name length and character set id.*/
174} btrc_folder_list_item_player_t;
175
176typedef struct
177{
178 uint64_t uid;
179 uint8_t type;
180 uint8_t playable;
181 btrc_player_full_name_t name;
182} btrc_folder_list_item_folder_t;
183
184typedef struct
185{
186 uint32_t attr_id;
187 btrc_player_full_name_t name;
188} btrc_attr_entry_t;
189
190typedef struct
191{
192 uint64_t uid;
193 uint8_t type;
194 uint8_t attr_count;
195 btrc_player_full_name_t name;
196 btrc_attr_entry_t* p_attr_list;
197} btrc_folder_list_item_media_t;
198
199typedef struct {
200 uint16_t str_len;
201 uint8_t *p_str;
202} btrc_name_t;
203
204/* SetBrowsedPlayer */
205typedef struct
206{
207 uint32_t num_items;
208 uint16_t uid_counter;
209 uint16_t charset_id;
210 uint8_t status;
211 uint8_t folder_depth;
212 btrc_name_t *p_folders;
213} btrc_set_browsed_player_rsp_t;
214
215typedef struct
216{
217 uint8_t item_type;
218 union
219 {
220 btrc_folder_list_item_player_t player;
221 btrc_folder_list_item_folder_t folder;
222 btrc_folder_list_item_media_t media;
223 } u;
224} btrc_folder_list_item_t;
225
226/* GetFolderItems */
227typedef struct
228{
229 uint16_t uid_counter;
230 uint16_t item_count;
231 uint8_t status;
232 btrc_folder_list_item_t *p_item_list;
233} btrc_folder_list_entries_t;
Satya Callojife9728d2013-08-01 03:11:11 -0700234
Ravi Nagarajan482ba782013-02-26 10:34:41 -0800235/** Callback for play status request */
236typedef void (* btrc_get_play_status_callback)();
237
238/** Callback for list player application attributes (Shuffle, Repeat,...) */
239typedef void (* btrc_list_player_app_attr_callback)();
240
241/** Callback for list player application attributes (Shuffle, Repeat,...) */
242typedef void (* btrc_list_player_app_values_callback)(btrc_player_attr_t attr_id);
243
244/** Callback for getting the current player application settings value
245** num_attr: specifies the number of attribute ids contained in p_attrs
246*/
247typedef void (* btrc_get_player_app_value_callback) (uint8_t num_attr, btrc_player_attr_t *p_attrs);
248
249/** Callback for getting the player application settings attributes' text
250** num_attr: specifies the number of attribute ids contained in p_attrs
251*/
252typedef void (* btrc_get_player_app_attrs_text_callback) (uint8_t num_attr, btrc_player_attr_t *p_attrs);
253
254/** Callback for getting the player application settings values' text
255** num_attr: specifies the number of value ids contained in p_vals
256*/
257typedef void (* btrc_get_player_app_values_text_callback) (uint8_t attr_id, uint8_t num_val, uint8_t *p_vals);
258
259/** Callback for setting the player application settings values */
260typedef void (* btrc_set_player_app_value_callback) (btrc_player_settings_t *p_vals);
261
262/** Callback to fetch the get element attributes of the current song
263** num_attr: specifies the number of attributes requested in p_attrs
264*/
265typedef void (* btrc_get_element_attr_callback) (uint8_t num_attr, btrc_media_attr_t *p_attrs);
266
267/** Callback for register notification (Play state change/track change/...)
268** param: Is only valid if event_id is BTRC_EVT_PLAY_POS_CHANGED
269*/
270typedef void (* btrc_register_notification_callback) (btrc_event_id_t event_id, uint32_t param);
271
Satya Callojife9728d2013-08-01 03:11:11 -0700272/* AVRCP 1.4 Enhancements */
273/** Callback for volume change on CT
274** volume: Current volume setting on the CT (0-127)
275*/
276typedef void (* btrc_volume_change_callback) (uint8_t volume, uint8_t ctype);
277
John Dub9844812013-07-23 17:15:34 -0700278/** Callback for passthrough commands */
279typedef void (* btrc_passthrough_cmd_callback) (int id, int key_state);
280
Mike Lockwood7da4cb82014-06-02 16:20:51 -0700281/** BT-RC Target callback structure. */
Ayan Ghosh78becc12014-07-25 17:11:58 +0530282
283typedef void (* btrc_get_folder_items_callback) (btrc_browse_folderitem_t id,
284 btrc_getfolderitem_t *param);
285
286typedef void (* btrc_set_addressed_player_callback) (uint32_t player_id);
287
288typedef void (* btrc_set_browsed_player_callback) (uint32_t player_id);
289
290typedef void (* btrc_change_path_callback) (uint8_t direction, uint64_t uid);
291
292typedef void (* btrc_play_item_callback) (uint8_t scope, uint64_t uid);
293
294typedef void (* btrc_get_item_attr_callback) (uint8_t scope, uint64_t uid,
295 uint8_t num_attr, btrc_media_attr_t *p_attrs);
296
Ravi Nagarajan482ba782013-02-26 10:34:41 -0800297typedef struct {
298 /** set to sizeof(BtRcCallbacks) */
299 size_t size;
Satya Callojife9728d2013-08-01 03:11:11 -0700300 btrc_remote_features_callback remote_features_cb;
Ravi Nagarajan482ba782013-02-26 10:34:41 -0800301 btrc_get_play_status_callback get_play_status_cb;
302 btrc_list_player_app_attr_callback list_player_app_attr_cb;
303 btrc_list_player_app_values_callback list_player_app_values_cb;
304 btrc_get_player_app_value_callback get_player_app_value_cb;
305 btrc_get_player_app_attrs_text_callback get_player_app_attrs_text_cb;
306 btrc_get_player_app_values_text_callback get_player_app_values_text_cb;
307 btrc_set_player_app_value_callback set_player_app_value_cb;
308 btrc_get_element_attr_callback get_element_attr_cb;
309 btrc_register_notification_callback register_notification_cb;
Satya Callojife9728d2013-08-01 03:11:11 -0700310 btrc_volume_change_callback volume_change_cb;
John Dub9844812013-07-23 17:15:34 -0700311 btrc_passthrough_cmd_callback passthrough_cmd_cb;
Ayan Ghosh78becc12014-07-25 17:11:58 +0530312 btrc_get_folder_items_callback get_folderitems_cb;
313 btrc_set_addressed_player_callback set_addrplayer_cb;
314 btrc_set_browsed_player_callback set_browsed_player_cb;
315 btrc_change_path_callback change_path_cb;
316 btrc_play_item_callback play_item_cb;
317 btrc_get_item_attr_callback get_item_attr_cb;
Ravi Nagarajan482ba782013-02-26 10:34:41 -0800318} btrc_callbacks_t;
319
Mike Lockwood7da4cb82014-06-02 16:20:51 -0700320/** Represents the standard BT-RC AVRCP Target interface. */
Ravi Nagarajan482ba782013-02-26 10:34:41 -0800321typedef struct {
322
323 /** set to sizeof(BtRcInterface) */
324 size_t size;
325 /**
326 * Register the BtRc callbacks
327 */
328 bt_status_t (*init)( btrc_callbacks_t* callbacks );
329
330 /** Respose to GetPlayStatus request. Contains the current
331 ** 1. Play status
332 ** 2. Song duration/length
333 ** 3. Song position
334 */
335 bt_status_t (*get_play_status_rsp)( btrc_play_status_t play_status, uint32_t song_len, uint32_t song_pos);
336
337 /** Lists the support player application attributes (Shuffle/Repeat/...)
338 ** num_attr: Specifies the number of attributes contained in the pointer p_attrs
339 */
Ayan Ghosh78becc12014-07-25 17:11:58 +0530340 bt_status_t (*list_player_app_attr_rsp)( uint8_t num_attr, btrc_player_attr_t *p_attrs);
Ravi Nagarajan482ba782013-02-26 10:34:41 -0800341
342 /** Lists the support player application attributes (Shuffle Off/On/Group)
343 ** num_val: Specifies the number of values contained in the pointer p_vals
344 */
Ayan Ghosh78becc12014-07-25 17:11:58 +0530345 bt_status_t (*list_player_app_value_rsp)( uint8_t num_val, uint8_t *p_vals);
Ravi Nagarajan482ba782013-02-26 10:34:41 -0800346
347 /** Returns the current application attribute values for each of the specified attr_id */
348 bt_status_t (*get_player_app_value_rsp)( btrc_player_settings_t *p_vals);
349
350 /** Returns the application attributes text ("Shuffle"/"Repeat"/...)
351 ** num_attr: Specifies the number of attributes' text contained in the pointer p_attrs
352 */
353 bt_status_t (*get_player_app_attr_text_rsp)( int num_attr, btrc_player_setting_text_t *p_attrs);
354
355 /** Returns the application attributes text ("Shuffle"/"Repeat"/...)
356 ** num_attr: Specifies the number of attribute values' text contained in the pointer p_vals
357 */
358 bt_status_t (*get_player_app_value_text_rsp)( int num_val, btrc_player_setting_text_t *p_vals);
359
360 /** Returns the current songs' element attributes text ("Title"/"Album"/"Artist")
361 ** num_attr: Specifies the number of attributes' text contained in the pointer p_attrs
362 */
363 bt_status_t (*get_element_attr_rsp)( uint8_t num_attr, btrc_element_attr_val_t *p_attrs);
364
365 /** Response to set player attribute request ("Shuffle"/"Repeat")
366 ** rsp_status: Status of setting the player attributes for the current media player
367 */
368 bt_status_t (*set_player_app_value_rsp)(btrc_status_t rsp_status);
369
370 /* Response to the register notification request (Play state change/track change/...).
371 ** event_id: Refers to the event_id this notification change corresponds too
372 ** type: Response type - interim/changed
373 ** p_params: Based on the event_id, this parameter should be populated
374 */
375 bt_status_t (*register_notification_rsp)(btrc_event_id_t event_id,
376 btrc_notification_type_t type,
377 btrc_register_notification_t *p_param);
378
Satya Callojife9728d2013-08-01 03:11:11 -0700379 /* AVRCP 1.4 enhancements */
380
381 /**Send current volume setting to remote side. Support limited to SetAbsoluteVolume
382 ** This can be enhanced to support Relative Volume (AVRCP 1.0).
383 ** With RelateVolume, we will send VOLUME_UP/VOLUME_DOWN opposed to absolute volume level
384 ** volume: Should be in the range 0-127. bit7 is reseved and cannot be set
385 */
386 bt_status_t (*set_volume)(uint8_t volume);
Ayan Ghosh78becc12014-07-25 17:11:58 +0530387 bt_status_t (*get_folder_items_rsp) (btrc_folder_list_entries_t *p_param);
388
389 bt_status_t (*set_addressed_player_rsp) (btrc_status_t status_code);
390 bt_status_t (*set_browsed_player_rsp) (btrc_set_browsed_player_rsp_t *p_param);
391 bt_status_t (*change_path_rsp) (uint8_t status_code, uint32_t item_count);
392 bt_status_t (*play_item_rsp) (uint8_t status_code);
393 bt_status_t (*get_item_attr_rsp)( uint8_t num_attr, btrc_element_attr_val_t *p_attrs);
Satya Callojife9728d2013-08-01 03:11:11 -0700394
Ravi Nagarajan482ba782013-02-26 10:34:41 -0800395 /** Closes the interface. */
396 void (*cleanup)( void );
397} btrc_interface_t;
398
Mike Lockwood7da4cb82014-06-02 16:20:51 -0700399
400typedef void (* btrc_passthrough_rsp_callback) (int id, int key_state);
401
402typedef void (* btrc_connection_state_callback) (bool state, bt_bdaddr_t *bd_addr);
403
404/** BT-RC Controller callback structure. */
405typedef struct {
406 /** set to sizeof(BtRcCallbacks) */
407 size_t size;
408 btrc_passthrough_rsp_callback passthrough_rsp_cb;
409 btrc_connection_state_callback connection_state_cb;
410} btrc_ctrl_callbacks_t;
411
412/** Represents the standard BT-RC AVRCP Controller interface. */
413typedef struct {
414
415 /** set to sizeof(BtRcInterface) */
416 size_t size;
417 /**
418 * Register the BtRc callbacks
419 */
420 bt_status_t (*init)( btrc_ctrl_callbacks_t* callbacks );
421
422 /** send pass through command to target */
423 bt_status_t (*send_pass_through_cmd) ( bt_bdaddr_t *bd_addr, uint8_t key_code, uint8_t key_state );
424
425 /** Closes the interface. */
426 void (*cleanup)( void );
427} btrc_ctrl_interface_t;
428
Ravi Nagarajan482ba782013-02-26 10:34:41 -0800429__END_DECLS
430
Satya Callojife9728d2013-08-01 03:11:11 -0700431#endif /* ANDROID_INCLUDE_BT_RC_H */