blob: 1e2c293609096f714357a76ce981132a4c08da32 [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
Ravi Nagarajan482ba782013-02-26 10:34:41 -080029
30typedef uint8_t btrc_uid_t[BTRC_UID_SIZE];
31
32typedef enum {
Satya Callojife9728d2013-08-01 03:11:11 -070033 BTRC_FEAT_NONE = 0x00, /* AVRCP 1.0 */
34 BTRC_FEAT_METADATA = 0x01, /* AVRCP 1.3 */
35 BTRC_FEAT_ABSOLUTE_VOLUME = 0x02, /* Supports TG role and volume sync */
36 BTRC_FEAT_BROWSE = 0x04, /* AVRCP 1.4 and up, with Browsing support */
37} btrc_remote_features_t;
38
39typedef enum {
Ravi Nagarajan482ba782013-02-26 10:34:41 -080040 BTRC_PLAYSTATE_STOPPED = 0x00, /* Stopped */
41 BTRC_PLAYSTATE_PLAYING = 0x01, /* Playing */
42 BTRC_PLAYSTATE_PAUSED = 0x02, /* Paused */
43 BTRC_PLAYSTATE_FWD_SEEK = 0x03, /* Fwd Seek*/
44 BTRC_PLAYSTATE_REV_SEEK = 0x04, /* Rev Seek*/
45 BTRC_PLAYSTATE_ERROR = 0xFF, /* Error */
46} btrc_play_status_t;
47
48typedef enum {
49 BTRC_EVT_PLAY_STATUS_CHANGED = 0x01,
50 BTRC_EVT_TRACK_CHANGE = 0x02,
51 BTRC_EVT_TRACK_REACHED_END = 0x03,
52 BTRC_EVT_TRACK_REACHED_START = 0x04,
53 BTRC_EVT_PLAY_POS_CHANGED = 0x05,
54 BTRC_EVT_APP_SETTINGS_CHANGED = 0x08,
55} btrc_event_id_t;
56
57typedef enum {
58 BTRC_NOTIFICATION_TYPE_INTERIM = 0,
59 BTRC_NOTIFICATION_TYPE_CHANGED = 1,
60} btrc_notification_type_t;
61
62typedef enum {
63 BTRC_PLAYER_ATTR_EQUALIZER = 0x01,
64 BTRC_PLAYER_ATTR_REPEAT = 0x02,
65 BTRC_PLAYER_ATTR_SHUFFLE = 0x03,
66 BTRC_PLAYER_ATTR_SCAN = 0x04,
67} btrc_player_attr_t;
68
69typedef enum {
70 BTRC_MEDIA_ATTR_TITLE = 0x01,
71 BTRC_MEDIA_ATTR_ARTIST = 0x02,
72 BTRC_MEDIA_ATTR_ALBUM = 0x03,
73 BTRC_MEDIA_ATTR_TRACK_NUM = 0x04,
74 BTRC_MEDIA_ATTR_NUM_TRACKS = 0x05,
75 BTRC_MEDIA_ATTR_GENRE = 0x06,
76 BTRC_MEDIA_ATTR_PLAYING_TIME = 0x07,
77} btrc_media_attr_t;
78
79typedef enum {
80 BTRC_PLAYER_VAL_OFF_REPEAT = 0x01,
81 BTRC_PLAYER_VAL_SINGLE_REPEAT = 0x02,
82 BTRC_PLAYER_VAL_ALL_REPEAT = 0x03,
83 BTRC_PLAYER_VAL_GROUP_REPEAT = 0x04
84} btrc_player_repeat_val_t;
85
86typedef enum {
87 BTRC_PLAYER_VAL_OFF_SHUFFLE = 0x01,
88 BTRC_PLAYER_VAL_ALL_SHUFFLE = 0x02,
89 BTRC_PLAYER_VAL_GROUP_SHUFFLE = 0x03
90} btrc_player_shuffle_val_t;
91
92typedef enum {
93 BTRC_STS_BAD_CMD = 0x00, /* Invalid command */
94 BTRC_STS_BAD_PARAM = 0x01, /* Invalid parameter */
95 BTRC_STS_NOT_FOUND = 0x02, /* Specified parameter is wrong or not found */
96 BTRC_STS_INTERNAL_ERR = 0x03, /* Internal Error */
97 BTRC_STS_NO_ERROR = 0x04 /* Operation Success */
98} btrc_status_t;
99
100typedef struct {
101 uint8_t num_attr;
102 uint8_t attr_ids[BTRC_MAX_APP_SETTINGS];
103 uint8_t attr_values[BTRC_MAX_APP_SETTINGS];
104} btrc_player_settings_t;
105
AnubhavGuptaa5b557a2015-09-18 14:34:02 +0530106typedef struct {
107 uint8_t val;
108 uint16_t charset_id;
109 uint16_t str_len;
110 uint8_t *p_str;
111} btrc_player_app_ext_attr_val_t;
112
113typedef struct {
114 uint8_t attr_id;
115 uint16_t charset_id;
116 uint16_t str_len;
117 uint8_t *p_str;
118 uint8_t num_val;
119 btrc_player_app_ext_attr_val_t ext_attr_val[BTRC_MAX_APP_ATTR_SIZE];
120} btrc_player_app_ext_attr_t;
121
122typedef struct {
123 uint8_t attr_id;
124 uint8_t num_val;
125 uint8_t attr_val[BTRC_MAX_APP_ATTR_SIZE];
126} btrc_player_app_attr_t;
127
128typedef struct {
129 uint32_t start_item;
130 uint32_t end_item;
131 uint32_t size;
132 uint32_t attrs[BTRC_MAX_ELEM_ATTR_SIZE];
133 uint8_t attr_count;
134} btrc_getfolderitem_t;
135
Ravi Nagarajan482ba782013-02-26 10:34:41 -0800136typedef union
137{
138 btrc_play_status_t play_status;
139 btrc_uid_t track; /* queue position in NowPlaying */
140 uint32_t song_pos;
141 btrc_player_settings_t player_setting;
142} btrc_register_notification_t;
143
144typedef struct {
145 uint8_t id; /* can be attr_id or value_id */
146 uint8_t text[BTRC_MAX_ATTR_STR_LEN];
147} btrc_player_setting_text_t;
148
149typedef struct {
150 uint32_t attr_id;
151 uint8_t text[BTRC_MAX_ATTR_STR_LEN];
152} btrc_element_attr_val_t;
153
Satya Callojife9728d2013-08-01 03:11:11 -0700154/** Callback for the controller's supported feautres */
155typedef void (* btrc_remote_features_callback)(bt_bdaddr_t *bd_addr,
156 btrc_remote_features_t features);
157
Ravi Nagarajan482ba782013-02-26 10:34:41 -0800158/** Callback for play status request */
159typedef void (* btrc_get_play_status_callback)();
160
161/** Callback for list player application attributes (Shuffle, Repeat,...) */
162typedef void (* btrc_list_player_app_attr_callback)();
163
164/** Callback for list player application attributes (Shuffle, Repeat,...) */
165typedef void (* btrc_list_player_app_values_callback)(btrc_player_attr_t attr_id);
166
167/** Callback for getting the current player application settings value
168** num_attr: specifies the number of attribute ids contained in p_attrs
169*/
170typedef void (* btrc_get_player_app_value_callback) (uint8_t num_attr, btrc_player_attr_t *p_attrs);
171
172/** Callback for getting the player application settings attributes' text
173** num_attr: specifies the number of attribute ids contained in p_attrs
174*/
175typedef void (* btrc_get_player_app_attrs_text_callback) (uint8_t num_attr, btrc_player_attr_t *p_attrs);
176
177/** Callback for getting the player application settings values' text
178** num_attr: specifies the number of value ids contained in p_vals
179*/
180typedef void (* btrc_get_player_app_values_text_callback) (uint8_t attr_id, uint8_t num_val, uint8_t *p_vals);
181
182/** Callback for setting the player application settings values */
183typedef void (* btrc_set_player_app_value_callback) (btrc_player_settings_t *p_vals);
184
185/** Callback to fetch the get element attributes of the current song
186** num_attr: specifies the number of attributes requested in p_attrs
187*/
188typedef void (* btrc_get_element_attr_callback) (uint8_t num_attr, btrc_media_attr_t *p_attrs);
189
190/** Callback for register notification (Play state change/track change/...)
191** param: Is only valid if event_id is BTRC_EVT_PLAY_POS_CHANGED
192*/
193typedef void (* btrc_register_notification_callback) (btrc_event_id_t event_id, uint32_t param);
194
Satya Callojife9728d2013-08-01 03:11:11 -0700195/* AVRCP 1.4 Enhancements */
196/** Callback for volume change on CT
197** volume: Current volume setting on the CT (0-127)
198*/
199typedef void (* btrc_volume_change_callback) (uint8_t volume, uint8_t ctype);
200
John Dub9844812013-07-23 17:15:34 -0700201/** Callback for passthrough commands */
202typedef void (* btrc_passthrough_cmd_callback) (int id, int key_state);
203
Mike Lockwood7da4cb82014-06-02 16:20:51 -0700204/** BT-RC Target callback structure. */
Ravi Nagarajan482ba782013-02-26 10:34:41 -0800205typedef struct {
206 /** set to sizeof(BtRcCallbacks) */
207 size_t size;
Satya Callojife9728d2013-08-01 03:11:11 -0700208 btrc_remote_features_callback remote_features_cb;
Ravi Nagarajan482ba782013-02-26 10:34:41 -0800209 btrc_get_play_status_callback get_play_status_cb;
210 btrc_list_player_app_attr_callback list_player_app_attr_cb;
211 btrc_list_player_app_values_callback list_player_app_values_cb;
212 btrc_get_player_app_value_callback get_player_app_value_cb;
213 btrc_get_player_app_attrs_text_callback get_player_app_attrs_text_cb;
214 btrc_get_player_app_values_text_callback get_player_app_values_text_cb;
215 btrc_set_player_app_value_callback set_player_app_value_cb;
216 btrc_get_element_attr_callback get_element_attr_cb;
217 btrc_register_notification_callback register_notification_cb;
Satya Callojife9728d2013-08-01 03:11:11 -0700218 btrc_volume_change_callback volume_change_cb;
John Dub9844812013-07-23 17:15:34 -0700219 btrc_passthrough_cmd_callback passthrough_cmd_cb;
Ravi Nagarajan482ba782013-02-26 10:34:41 -0800220} btrc_callbacks_t;
221
Mike Lockwood7da4cb82014-06-02 16:20:51 -0700222/** Represents the standard BT-RC AVRCP Target interface. */
Ravi Nagarajan482ba782013-02-26 10:34:41 -0800223typedef struct {
224
225 /** set to sizeof(BtRcInterface) */
226 size_t size;
227 /**
228 * Register the BtRc callbacks
229 */
230 bt_status_t (*init)( btrc_callbacks_t* callbacks );
231
232 /** Respose to GetPlayStatus request. Contains the current
233 ** 1. Play status
234 ** 2. Song duration/length
235 ** 3. Song position
236 */
237 bt_status_t (*get_play_status_rsp)( btrc_play_status_t play_status, uint32_t song_len, uint32_t song_pos);
238
239 /** Lists the support player application attributes (Shuffle/Repeat/...)
240 ** num_attr: Specifies the number of attributes contained in the pointer p_attrs
241 */
242 bt_status_t (*list_player_app_attr_rsp)( int num_attr, btrc_player_attr_t *p_attrs);
243
244 /** Lists the support player application attributes (Shuffle Off/On/Group)
245 ** num_val: Specifies the number of values contained in the pointer p_vals
246 */
247 bt_status_t (*list_player_app_value_rsp)( int num_val, uint8_t *p_vals);
248
249 /** Returns the current application attribute values for each of the specified attr_id */
250 bt_status_t (*get_player_app_value_rsp)( btrc_player_settings_t *p_vals);
251
252 /** Returns the application attributes text ("Shuffle"/"Repeat"/...)
253 ** num_attr: Specifies the number of attributes' text contained in the pointer p_attrs
254 */
255 bt_status_t (*get_player_app_attr_text_rsp)( int num_attr, btrc_player_setting_text_t *p_attrs);
256
257 /** Returns the application attributes text ("Shuffle"/"Repeat"/...)
258 ** num_attr: Specifies the number of attribute values' text contained in the pointer p_vals
259 */
260 bt_status_t (*get_player_app_value_text_rsp)( int num_val, btrc_player_setting_text_t *p_vals);
261
262 /** Returns the current songs' element attributes text ("Title"/"Album"/"Artist")
263 ** num_attr: Specifies the number of attributes' text contained in the pointer p_attrs
264 */
265 bt_status_t (*get_element_attr_rsp)( uint8_t num_attr, btrc_element_attr_val_t *p_attrs);
266
267 /** Response to set player attribute request ("Shuffle"/"Repeat")
268 ** rsp_status: Status of setting the player attributes for the current media player
269 */
270 bt_status_t (*set_player_app_value_rsp)(btrc_status_t rsp_status);
271
272 /* Response to the register notification request (Play state change/track change/...).
273 ** event_id: Refers to the event_id this notification change corresponds too
274 ** type: Response type - interim/changed
275 ** p_params: Based on the event_id, this parameter should be populated
276 */
277 bt_status_t (*register_notification_rsp)(btrc_event_id_t event_id,
278 btrc_notification_type_t type,
279 btrc_register_notification_t *p_param);
280
Satya Callojife9728d2013-08-01 03:11:11 -0700281 /* AVRCP 1.4 enhancements */
282
283 /**Send current volume setting to remote side. Support limited to SetAbsoluteVolume
284 ** This can be enhanced to support Relative Volume (AVRCP 1.0).
285 ** With RelateVolume, we will send VOLUME_UP/VOLUME_DOWN opposed to absolute volume level
286 ** volume: Should be in the range 0-127. bit7 is reseved and cannot be set
287 */
288 bt_status_t (*set_volume)(uint8_t volume);
289
Ravi Nagarajan482ba782013-02-26 10:34:41 -0800290 /** Closes the interface. */
291 void (*cleanup)( void );
292} btrc_interface_t;
293
Mike Lockwood7da4cb82014-06-02 16:20:51 -0700294
295typedef void (* btrc_passthrough_rsp_callback) (int id, int key_state);
296
AnubhavGuptaa5b557a2015-09-18 14:34:02 +0530297typedef void (* btrc_groupnavigation_rsp_callback) (int id, int key_state);
298
Mike Lockwood7da4cb82014-06-02 16:20:51 -0700299typedef void (* btrc_connection_state_callback) (bool state, bt_bdaddr_t *bd_addr);
300
AnubhavGuptaa5b557a2015-09-18 14:34:02 +0530301typedef void (* btrc_ctrl_getrcfeatures_callback) (bt_bdaddr_t *bd_addr, int features);
302
303typedef void (* btrc_ctrl_setabsvol_cmd_callback) (bt_bdaddr_t *bd_addr, uint8_t abs_vol, uint8_t label);
304
305typedef void (* btrc_ctrl_registernotification_abs_vol_callback) (bt_bdaddr_t *bd_addr, uint8_t label);
306
307typedef void (* btrc_ctrl_setplayerapplicationsetting_rsp_callback) (bt_bdaddr_t *bd_addr,
308 uint8_t accepted);
309
310typedef void (* btrc_ctrl_playerapplicationsetting_callback)(bt_bdaddr_t *bd_addr,
311 uint8_t num_attr,
312 btrc_player_app_attr_t *app_attrs,
313 uint8_t num_ext_attr,
314 btrc_player_app_ext_attr_t *ext_attrs);
315
316typedef void (* btrc_ctrl_playerapplicationsetting_changed_callback)(bt_bdaddr_t *bd_addr,
317 btrc_player_settings_t *p_vals);
318
319typedef void (* btrc_ctrl_track_changed_callback)(bt_bdaddr_t *bd_addr, uint8_t num_attr,
320 btrc_element_attr_val_t *p_attrs);
321
322typedef void (* btrc_ctrl_play_position_changed_callback)(bt_bdaddr_t *bd_addr,
323 uint32_t song_len, uint32_t song_pos);
324
325typedef void (* btrc_ctrl_play_status_changed_callback)(bt_bdaddr_t *bd_addr,
326 btrc_play_status_t play_status);
327
Mike Lockwood7da4cb82014-06-02 16:20:51 -0700328/** BT-RC Controller callback structure. */
329typedef struct {
330 /** set to sizeof(BtRcCallbacks) */
331 size_t size;
AnubhavGuptaa5b557a2015-09-18 14:34:02 +0530332 btrc_passthrough_rsp_callback passthrough_rsp_cb;
333 btrc_groupnavigation_rsp_callback groupnavigation_rsp_cb;
334 btrc_connection_state_callback connection_state_cb;
335 btrc_ctrl_getrcfeatures_callback getrcfeatures_cb;
336 btrc_ctrl_setplayerapplicationsetting_rsp_callback setplayerappsetting_rsp_cb;
337 btrc_ctrl_playerapplicationsetting_callback playerapplicationsetting_cb;
338 btrc_ctrl_playerapplicationsetting_changed_callback playerapplicationsetting_changed_cb;
339 btrc_ctrl_setabsvol_cmd_callback setabsvol_cmd_cb;
340 btrc_ctrl_registernotification_abs_vol_callback registernotification_absvol_cb;
341 btrc_ctrl_track_changed_callback track_changed_cb;
342 btrc_ctrl_play_position_changed_callback play_position_changed_cb;
343 btrc_ctrl_play_status_changed_callback play_status_changed_cb;
Mike Lockwood7da4cb82014-06-02 16:20:51 -0700344} btrc_ctrl_callbacks_t;
345
346/** Represents the standard BT-RC AVRCP Controller interface. */
347typedef struct {
348
349 /** set to sizeof(BtRcInterface) */
350 size_t size;
351 /**
352 * Register the BtRc callbacks
353 */
354 bt_status_t (*init)( btrc_ctrl_callbacks_t* callbacks );
355
356 /** send pass through command to target */
AnubhavGuptaa5b557a2015-09-18 14:34:02 +0530357 bt_status_t (*send_pass_through_cmd) (bt_bdaddr_t *bd_addr, uint8_t key_code,
358 uint8_t key_state );
359
360 /** send group navigation command to target */
361 bt_status_t (*send_group_navigation_cmd) (bt_bdaddr_t *bd_addr, uint8_t key_code,
362 uint8_t key_state );
363
364 /** send command to set player applicaiton setting attributes to target */
365 bt_status_t (*set_player_app_setting_cmd) (bt_bdaddr_t *bd_addr, uint8_t num_attrib,
366 uint8_t* attrib_ids, uint8_t* attrib_vals);
367
368 /** send rsp to set_abs_vol received from target */
369 bt_status_t (*set_volume_rsp) (bt_bdaddr_t *bd_addr, uint8_t abs_vol, uint8_t label);
370
371 /** send notificaiton rsp for abs vol to target */
372 bt_status_t (*register_abs_vol_rsp) (bt_bdaddr_t *bd_addr, btrc_notification_type_t rsp_type,
373 uint8_t abs_vol, uint8_t label);
Mike Lockwood7da4cb82014-06-02 16:20:51 -0700374
375 /** Closes the interface. */
376 void (*cleanup)( void );
377} btrc_ctrl_interface_t;
378
Ravi Nagarajan482ba782013-02-26 10:34:41 -0800379__END_DECLS
380
Satya Callojife9728d2013-08-01 03:11:11 -0700381#endif /* ANDROID_INCLUDE_BT_RC_H */