blob: 0898133c80c1b838303dc22eb8c381d5d1e48eee [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 {
33 BTRC_PLAYSTATE_STOPPED = 0x00, /* Stopped */
34 BTRC_PLAYSTATE_PLAYING = 0x01, /* Playing */
35 BTRC_PLAYSTATE_PAUSED = 0x02, /* Paused */
36 BTRC_PLAYSTATE_FWD_SEEK = 0x03, /* Fwd Seek*/
37 BTRC_PLAYSTATE_REV_SEEK = 0x04, /* Rev Seek*/
38 BTRC_PLAYSTATE_ERROR = 0xFF, /* Error */
39} btrc_play_status_t;
40
41typedef enum {
42 BTRC_EVT_PLAY_STATUS_CHANGED = 0x01,
43 BTRC_EVT_TRACK_CHANGE = 0x02,
44 BTRC_EVT_TRACK_REACHED_END = 0x03,
45 BTRC_EVT_TRACK_REACHED_START = 0x04,
46 BTRC_EVT_PLAY_POS_CHANGED = 0x05,
47 BTRC_EVT_APP_SETTINGS_CHANGED = 0x08,
48} btrc_event_id_t;
49
50typedef enum {
51 BTRC_NOTIFICATION_TYPE_INTERIM = 0,
52 BTRC_NOTIFICATION_TYPE_CHANGED = 1,
53} btrc_notification_type_t;
54
55typedef enum {
56 BTRC_PLAYER_ATTR_EQUALIZER = 0x01,
57 BTRC_PLAYER_ATTR_REPEAT = 0x02,
58 BTRC_PLAYER_ATTR_SHUFFLE = 0x03,
59 BTRC_PLAYER_ATTR_SCAN = 0x04,
60} btrc_player_attr_t;
61
62typedef enum {
63 BTRC_MEDIA_ATTR_TITLE = 0x01,
64 BTRC_MEDIA_ATTR_ARTIST = 0x02,
65 BTRC_MEDIA_ATTR_ALBUM = 0x03,
66 BTRC_MEDIA_ATTR_TRACK_NUM = 0x04,
67 BTRC_MEDIA_ATTR_NUM_TRACKS = 0x05,
68 BTRC_MEDIA_ATTR_GENRE = 0x06,
69 BTRC_MEDIA_ATTR_PLAYING_TIME = 0x07,
70} btrc_media_attr_t;
71
72typedef enum {
73 BTRC_PLAYER_VAL_OFF_REPEAT = 0x01,
74 BTRC_PLAYER_VAL_SINGLE_REPEAT = 0x02,
75 BTRC_PLAYER_VAL_ALL_REPEAT = 0x03,
76 BTRC_PLAYER_VAL_GROUP_REPEAT = 0x04
77} btrc_player_repeat_val_t;
78
79typedef enum {
80 BTRC_PLAYER_VAL_OFF_SHUFFLE = 0x01,
81 BTRC_PLAYER_VAL_ALL_SHUFFLE = 0x02,
82 BTRC_PLAYER_VAL_GROUP_SHUFFLE = 0x03
83} btrc_player_shuffle_val_t;
84
85typedef enum {
86 BTRC_STS_BAD_CMD = 0x00, /* Invalid command */
87 BTRC_STS_BAD_PARAM = 0x01, /* Invalid parameter */
88 BTRC_STS_NOT_FOUND = 0x02, /* Specified parameter is wrong or not found */
89 BTRC_STS_INTERNAL_ERR = 0x03, /* Internal Error */
90 BTRC_STS_NO_ERROR = 0x04 /* Operation Success */
91} btrc_status_t;
92
93typedef struct {
94 uint8_t num_attr;
95 uint8_t attr_ids[BTRC_MAX_APP_SETTINGS];
96 uint8_t attr_values[BTRC_MAX_APP_SETTINGS];
97} btrc_player_settings_t;
98
99typedef union
100{
101 btrc_play_status_t play_status;
102 btrc_uid_t track; /* queue position in NowPlaying */
103 uint32_t song_pos;
104 btrc_player_settings_t player_setting;
105} btrc_register_notification_t;
106
107typedef struct {
108 uint8_t id; /* can be attr_id or value_id */
109 uint8_t text[BTRC_MAX_ATTR_STR_LEN];
110} btrc_player_setting_text_t;
111
112typedef struct {
113 uint32_t attr_id;
114 uint8_t text[BTRC_MAX_ATTR_STR_LEN];
115} btrc_element_attr_val_t;
116
117/** Callback for play status request */
118typedef void (* btrc_get_play_status_callback)();
119
120/** Callback for list player application attributes (Shuffle, Repeat,...) */
121typedef void (* btrc_list_player_app_attr_callback)();
122
123/** Callback for list player application attributes (Shuffle, Repeat,...) */
124typedef void (* btrc_list_player_app_values_callback)(btrc_player_attr_t attr_id);
125
126/** Callback for getting the current player application settings value
127** num_attr: specifies the number of attribute ids contained in p_attrs
128*/
129typedef void (* btrc_get_player_app_value_callback) (uint8_t num_attr, btrc_player_attr_t *p_attrs);
130
131/** Callback for getting the player application settings attributes' text
132** num_attr: specifies the number of attribute ids contained in p_attrs
133*/
134typedef void (* btrc_get_player_app_attrs_text_callback) (uint8_t num_attr, btrc_player_attr_t *p_attrs);
135
136/** Callback for getting the player application settings values' text
137** num_attr: specifies the number of value ids contained in p_vals
138*/
139typedef void (* btrc_get_player_app_values_text_callback) (uint8_t attr_id, uint8_t num_val, uint8_t *p_vals);
140
141/** Callback for setting the player application settings values */
142typedef void (* btrc_set_player_app_value_callback) (btrc_player_settings_t *p_vals);
143
144/** Callback to fetch the get element attributes of the current song
145** num_attr: specifies the number of attributes requested in p_attrs
146*/
147typedef void (* btrc_get_element_attr_callback) (uint8_t num_attr, btrc_media_attr_t *p_attrs);
148
149/** Callback for register notification (Play state change/track change/...)
150** param: Is only valid if event_id is BTRC_EVT_PLAY_POS_CHANGED
151*/
152typedef void (* btrc_register_notification_callback) (btrc_event_id_t event_id, uint32_t param);
153
John Dub9844812013-07-23 17:15:34 -0700154/** Callback for passthrough commands */
155typedef void (* btrc_passthrough_cmd_callback) (int id, int key_state);
156
Ravi Nagarajan482ba782013-02-26 10:34:41 -0800157/** BT-RC callback structure. */
158typedef struct {
159 /** set to sizeof(BtRcCallbacks) */
160 size_t size;
161 btrc_get_play_status_callback get_play_status_cb;
162 btrc_list_player_app_attr_callback list_player_app_attr_cb;
163 btrc_list_player_app_values_callback list_player_app_values_cb;
164 btrc_get_player_app_value_callback get_player_app_value_cb;
165 btrc_get_player_app_attrs_text_callback get_player_app_attrs_text_cb;
166 btrc_get_player_app_values_text_callback get_player_app_values_text_cb;
167 btrc_set_player_app_value_callback set_player_app_value_cb;
168 btrc_get_element_attr_callback get_element_attr_cb;
169 btrc_register_notification_callback register_notification_cb;
John Dub9844812013-07-23 17:15:34 -0700170 btrc_passthrough_cmd_callback passthrough_cmd_cb;
Ravi Nagarajan482ba782013-02-26 10:34:41 -0800171} btrc_callbacks_t;
172
173/** Represents the standard BT-RC interface. */
174typedef struct {
175
176 /** set to sizeof(BtRcInterface) */
177 size_t size;
178 /**
179 * Register the BtRc callbacks
180 */
181 bt_status_t (*init)( btrc_callbacks_t* callbacks );
182
183 /** Respose to GetPlayStatus request. Contains the current
184 ** 1. Play status
185 ** 2. Song duration/length
186 ** 3. Song position
187 */
188 bt_status_t (*get_play_status_rsp)( btrc_play_status_t play_status, uint32_t song_len, uint32_t song_pos);
189
190 /** Lists the support player application attributes (Shuffle/Repeat/...)
191 ** num_attr: Specifies the number of attributes contained in the pointer p_attrs
192 */
193 bt_status_t (*list_player_app_attr_rsp)( int num_attr, btrc_player_attr_t *p_attrs);
194
195 /** Lists the support player application attributes (Shuffle Off/On/Group)
196 ** num_val: Specifies the number of values contained in the pointer p_vals
197 */
198 bt_status_t (*list_player_app_value_rsp)( int num_val, uint8_t *p_vals);
199
200 /** Returns the current application attribute values for each of the specified attr_id */
201 bt_status_t (*get_player_app_value_rsp)( btrc_player_settings_t *p_vals);
202
203 /** Returns the application attributes text ("Shuffle"/"Repeat"/...)
204 ** num_attr: Specifies the number of attributes' text contained in the pointer p_attrs
205 */
206 bt_status_t (*get_player_app_attr_text_rsp)( int num_attr, btrc_player_setting_text_t *p_attrs);
207
208 /** Returns the application attributes text ("Shuffle"/"Repeat"/...)
209 ** num_attr: Specifies the number of attribute values' text contained in the pointer p_vals
210 */
211 bt_status_t (*get_player_app_value_text_rsp)( int num_val, btrc_player_setting_text_t *p_vals);
212
213 /** Returns the current songs' element attributes text ("Title"/"Album"/"Artist")
214 ** num_attr: Specifies the number of attributes' text contained in the pointer p_attrs
215 */
216 bt_status_t (*get_element_attr_rsp)( uint8_t num_attr, btrc_element_attr_val_t *p_attrs);
217
218 /** Response to set player attribute request ("Shuffle"/"Repeat")
219 ** rsp_status: Status of setting the player attributes for the current media player
220 */
221 bt_status_t (*set_player_app_value_rsp)(btrc_status_t rsp_status);
222
223 /* Response to the register notification request (Play state change/track change/...).
224 ** event_id: Refers to the event_id this notification change corresponds too
225 ** type: Response type - interim/changed
226 ** p_params: Based on the event_id, this parameter should be populated
227 */
228 bt_status_t (*register_notification_rsp)(btrc_event_id_t event_id,
229 btrc_notification_type_t type,
230 btrc_register_notification_t *p_param);
231
232 /** Closes the interface. */
233 void (*cleanup)( void );
234} btrc_interface_t;
235
236__END_DECLS
237
John Dub9844812013-07-23 17:15:34 -0700238#endif /* ANDROID_INCLUDE_BT_RC_H */