blob: 277d9c84c64108ab2b3f96446861eb89b5a327c8 [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
106typedef union
107{
108 btrc_play_status_t play_status;
109 btrc_uid_t track; /* queue position in NowPlaying */
110 uint32_t song_pos;
111 btrc_player_settings_t player_setting;
112} btrc_register_notification_t;
113
114typedef struct {
115 uint8_t id; /* can be attr_id or value_id */
116 uint8_t text[BTRC_MAX_ATTR_STR_LEN];
117} btrc_player_setting_text_t;
118
119typedef struct {
120 uint32_t attr_id;
121 uint8_t text[BTRC_MAX_ATTR_STR_LEN];
122} btrc_element_attr_val_t;
123
Satya Callojife9728d2013-08-01 03:11:11 -0700124/** Callback for the controller's supported feautres */
125typedef void (* btrc_remote_features_callback)(bt_bdaddr_t *bd_addr,
126 btrc_remote_features_t features);
127
Ravi Nagarajan482ba782013-02-26 10:34:41 -0800128/** Callback for play status request */
129typedef void (* btrc_get_play_status_callback)();
130
131/** Callback for list player application attributes (Shuffle, Repeat,...) */
132typedef void (* btrc_list_player_app_attr_callback)();
133
134/** Callback for list player application attributes (Shuffle, Repeat,...) */
135typedef void (* btrc_list_player_app_values_callback)(btrc_player_attr_t attr_id);
136
137/** Callback for getting the current player application settings value
138** num_attr: specifies the number of attribute ids contained in p_attrs
139*/
140typedef void (* btrc_get_player_app_value_callback) (uint8_t num_attr, btrc_player_attr_t *p_attrs);
141
142/** Callback for getting the player application settings attributes' text
143** num_attr: specifies the number of attribute ids contained in p_attrs
144*/
145typedef void (* btrc_get_player_app_attrs_text_callback) (uint8_t num_attr, btrc_player_attr_t *p_attrs);
146
147/** Callback for getting the player application settings values' text
148** num_attr: specifies the number of value ids contained in p_vals
149*/
150typedef void (* btrc_get_player_app_values_text_callback) (uint8_t attr_id, uint8_t num_val, uint8_t *p_vals);
151
152/** Callback for setting the player application settings values */
153typedef void (* btrc_set_player_app_value_callback) (btrc_player_settings_t *p_vals);
154
155/** Callback to fetch the get element attributes of the current song
156** num_attr: specifies the number of attributes requested in p_attrs
157*/
158typedef void (* btrc_get_element_attr_callback) (uint8_t num_attr, btrc_media_attr_t *p_attrs);
159
160/** Callback for register notification (Play state change/track change/...)
161** param: Is only valid if event_id is BTRC_EVT_PLAY_POS_CHANGED
162*/
163typedef void (* btrc_register_notification_callback) (btrc_event_id_t event_id, uint32_t param);
164
Satya Callojife9728d2013-08-01 03:11:11 -0700165/* AVRCP 1.4 Enhancements */
166/** Callback for volume change on CT
167** volume: Current volume setting on the CT (0-127)
168*/
169typedef void (* btrc_volume_change_callback) (uint8_t volume, uint8_t ctype);
170
John Dub9844812013-07-23 17:15:34 -0700171/** Callback for passthrough commands */
172typedef void (* btrc_passthrough_cmd_callback) (int id, int key_state);
173
Hemant Gupta1beebfc2014-02-07 16:33:16 +0530174typedef void (* btrc_passthrough_rsp_callback) (int id, int key_state);
175
176typedef void (* btrc_connection_state_callback) (int state, bt_bdaddr_t *bd_addr);
177
Ravi Nagarajan482ba782013-02-26 10:34:41 -0800178/** BT-RC callback structure. */
179typedef struct {
180 /** set to sizeof(BtRcCallbacks) */
181 size_t size;
Satya Callojife9728d2013-08-01 03:11:11 -0700182 btrc_remote_features_callback remote_features_cb;
Ravi Nagarajan482ba782013-02-26 10:34:41 -0800183 btrc_get_play_status_callback get_play_status_cb;
184 btrc_list_player_app_attr_callback list_player_app_attr_cb;
185 btrc_list_player_app_values_callback list_player_app_values_cb;
186 btrc_get_player_app_value_callback get_player_app_value_cb;
187 btrc_get_player_app_attrs_text_callback get_player_app_attrs_text_cb;
188 btrc_get_player_app_values_text_callback get_player_app_values_text_cb;
189 btrc_set_player_app_value_callback set_player_app_value_cb;
190 btrc_get_element_attr_callback get_element_attr_cb;
191 btrc_register_notification_callback register_notification_cb;
Satya Callojife9728d2013-08-01 03:11:11 -0700192 btrc_volume_change_callback volume_change_cb;
John Dub9844812013-07-23 17:15:34 -0700193 btrc_passthrough_cmd_callback passthrough_cmd_cb;
Hemant Gupta1beebfc2014-02-07 16:33:16 +0530194 btrc_passthrough_rsp_callback passthrough_rsp_cb;
195 btrc_connection_state_callback connection_state_cb;
Ravi Nagarajan482ba782013-02-26 10:34:41 -0800196} btrc_callbacks_t;
197
198/** Represents the standard BT-RC interface. */
199typedef struct {
200
201 /** set to sizeof(BtRcInterface) */
202 size_t size;
203 /**
204 * Register the BtRc callbacks
205 */
206 bt_status_t (*init)( btrc_callbacks_t* callbacks );
207
208 /** Respose to GetPlayStatus request. Contains the current
209 ** 1. Play status
210 ** 2. Song duration/length
211 ** 3. Song position
212 */
213 bt_status_t (*get_play_status_rsp)( btrc_play_status_t play_status, uint32_t song_len, uint32_t song_pos);
214
215 /** Lists the support player application attributes (Shuffle/Repeat/...)
216 ** num_attr: Specifies the number of attributes contained in the pointer p_attrs
217 */
218 bt_status_t (*list_player_app_attr_rsp)( int num_attr, btrc_player_attr_t *p_attrs);
219
220 /** Lists the support player application attributes (Shuffle Off/On/Group)
221 ** num_val: Specifies the number of values contained in the pointer p_vals
222 */
223 bt_status_t (*list_player_app_value_rsp)( int num_val, uint8_t *p_vals);
224
225 /** Returns the current application attribute values for each of the specified attr_id */
226 bt_status_t (*get_player_app_value_rsp)( btrc_player_settings_t *p_vals);
227
228 /** Returns the application attributes text ("Shuffle"/"Repeat"/...)
229 ** num_attr: Specifies the number of attributes' text contained in the pointer p_attrs
230 */
231 bt_status_t (*get_player_app_attr_text_rsp)( int num_attr, btrc_player_setting_text_t *p_attrs);
232
233 /** Returns the application attributes text ("Shuffle"/"Repeat"/...)
234 ** num_attr: Specifies the number of attribute values' text contained in the pointer p_vals
235 */
236 bt_status_t (*get_player_app_value_text_rsp)( int num_val, btrc_player_setting_text_t *p_vals);
237
238 /** Returns the current songs' element attributes text ("Title"/"Album"/"Artist")
239 ** num_attr: Specifies the number of attributes' text contained in the pointer p_attrs
240 */
241 bt_status_t (*get_element_attr_rsp)( uint8_t num_attr, btrc_element_attr_val_t *p_attrs);
242
243 /** Response to set player attribute request ("Shuffle"/"Repeat")
244 ** rsp_status: Status of setting the player attributes for the current media player
245 */
246 bt_status_t (*set_player_app_value_rsp)(btrc_status_t rsp_status);
247
248 /* Response to the register notification request (Play state change/track change/...).
249 ** event_id: Refers to the event_id this notification change corresponds too
250 ** type: Response type - interim/changed
251 ** p_params: Based on the event_id, this parameter should be populated
252 */
253 bt_status_t (*register_notification_rsp)(btrc_event_id_t event_id,
254 btrc_notification_type_t type,
255 btrc_register_notification_t *p_param);
256
Satya Callojife9728d2013-08-01 03:11:11 -0700257 /* AVRCP 1.4 enhancements */
258
259 /**Send current volume setting to remote side. Support limited to SetAbsoluteVolume
260 ** This can be enhanced to support Relative Volume (AVRCP 1.0).
261 ** With RelateVolume, we will send VOLUME_UP/VOLUME_DOWN opposed to absolute volume level
262 ** volume: Should be in the range 0-127. bit7 is reseved and cannot be set
263 */
264 bt_status_t (*set_volume)(uint8_t volume);
265
Hemant Gupta1beebfc2014-02-07 16:33:16 +0530266 bt_status_t (*send_pass_through_cmd) (uint8_t key_code, uint8_t key_state);
267
Ravi Nagarajan482ba782013-02-26 10:34:41 -0800268 /** Closes the interface. */
269 void (*cleanup)( void );
270} btrc_interface_t;
271
272__END_DECLS
273
Satya Callojife9728d2013-08-01 03:11:11 -0700274#endif /* ANDROID_INCLUDE_BT_RC_H */