Android Hardware Abstraction Layer
bt_rc.h
Go to the documentation of this file.
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 /* 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
28 #define BTRC_MAX_ELEM_ATTR_SIZE 7
29 
30 typedef uint8_t btrc_uid_t[BTRC_UID_SIZE];
31 
32 typedef enum {
33  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 */
38 
39 typedef enum {
40  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 */
47 
48 typedef enum {
56 
57 typedef enum {
61 
62 typedef enum {
68 
69 typedef enum {
78 
79 typedef enum {
85 
86 typedef enum {
91 
92 typedef 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 */
99 
100 typedef struct {
101  uint8_t num_attr;
102  uint8_t attr_ids[BTRC_MAX_APP_SETTINGS];
103  uint8_t attr_values[BTRC_MAX_APP_SETTINGS];
105 
106 typedef union
107 {
109  btrc_uid_t track; /* queue position in NowPlaying */
110  uint32_t song_pos;
113 
114 typedef struct {
115  uint8_t id; /* can be attr_id or value_id */
116  uint8_t text[BTRC_MAX_ATTR_STR_LEN];
118 
119 typedef struct {
120  uint32_t attr_id;
121  uint8_t text[BTRC_MAX_ATTR_STR_LEN];
123 
124 /** Callback for the controller's supported feautres */
125 typedef void (* btrc_remote_features_callback)(bt_bdaddr_t *bd_addr,
126  btrc_remote_features_t features);
127 
128 /** Callback for play status request */
129 typedef void (* btrc_get_play_status_callback)();
130 
131 /** Callback for list player application attributes (Shuffle, Repeat,...) */
133 
134 /** Callback for list player application attributes (Shuffle, Repeat,...) */
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 */
140 typedef 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 */
145 typedef 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 */
150 typedef 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 */
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 */
158 typedef 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 */
163 typedef void (* btrc_register_notification_callback) (btrc_event_id_t event_id, uint32_t param);
164 
165 /* AVRCP 1.4 Enhancements */
166 /** Callback for volume change on CT
167 ** volume: Current volume setting on the CT (0-127)
168 */
169 typedef void (* btrc_volume_change_callback) (uint8_t volume, uint8_t ctype);
170 
171 /** Callback for passthrough commands */
172 typedef void (* btrc_passthrough_cmd_callback) (int id, int key_state);
173 
174 /** BT-RC callback structure. */
175 typedef struct {
176  /** set to sizeof(BtRcCallbacks) */
177  size_t size;
191 
192 /** Represents the standard BT-RC interface. */
193 typedef struct {
194 
195  /** set to sizeof(BtRcInterface) */
196  size_t size;
197  /**
198  * Register the BtRc callbacks
199  */
200  bt_status_t (*init)( btrc_callbacks_t* callbacks );
201 
202  /** Respose to GetPlayStatus request. Contains the current
203  ** 1. Play status
204  ** 2. Song duration/length
205  ** 3. Song position
206  */
207  bt_status_t (*get_play_status_rsp)( btrc_play_status_t play_status, uint32_t song_len, uint32_t song_pos);
208 
209  /** Lists the support player application attributes (Shuffle/Repeat/...)
210  ** num_attr: Specifies the number of attributes contained in the pointer p_attrs
211  */
212  bt_status_t (*list_player_app_attr_rsp)( int num_attr, btrc_player_attr_t *p_attrs);
213 
214  /** Lists the support player application attributes (Shuffle Off/On/Group)
215  ** num_val: Specifies the number of values contained in the pointer p_vals
216  */
217  bt_status_t (*list_player_app_value_rsp)( int num_val, uint8_t *p_vals);
218 
219  /** Returns the current application attribute values for each of the specified attr_id */
220  bt_status_t (*get_player_app_value_rsp)( btrc_player_settings_t *p_vals);
221 
222  /** Returns the application attributes text ("Shuffle"/"Repeat"/...)
223  ** num_attr: Specifies the number of attributes' text contained in the pointer p_attrs
224  */
225  bt_status_t (*get_player_app_attr_text_rsp)( int num_attr, btrc_player_setting_text_t *p_attrs);
226 
227  /** Returns the application attributes text ("Shuffle"/"Repeat"/...)
228  ** num_attr: Specifies the number of attribute values' text contained in the pointer p_vals
229  */
230  bt_status_t (*get_player_app_value_text_rsp)( int num_val, btrc_player_setting_text_t *p_vals);
231 
232  /** Returns the current songs' element attributes text ("Title"/"Album"/"Artist")
233  ** num_attr: Specifies the number of attributes' text contained in the pointer p_attrs
234  */
235  bt_status_t (*get_element_attr_rsp)( uint8_t num_attr, btrc_element_attr_val_t *p_attrs);
236 
237  /** Response to set player attribute request ("Shuffle"/"Repeat")
238  ** rsp_status: Status of setting the player attributes for the current media player
239  */
240  bt_status_t (*set_player_app_value_rsp)(btrc_status_t rsp_status);
241 
242  /* Response to the register notification request (Play state change/track change/...).
243  ** event_id: Refers to the event_id this notification change corresponds too
244  ** type: Response type - interim/changed
245  ** p_params: Based on the event_id, this parameter should be populated
246  */
247  bt_status_t (*register_notification_rsp)(btrc_event_id_t event_id,
250 
251  /* AVRCP 1.4 enhancements */
252 
253  /**Send current volume setting to remote side. Support limited to SetAbsoluteVolume
254  ** This can be enhanced to support Relative Volume (AVRCP 1.0).
255  ** With RelateVolume, we will send VOLUME_UP/VOLUME_DOWN opposed to absolute volume level
256  ** volume: Should be in the range 0-127. bit7 is reseved and cannot be set
257  */
258  bt_status_t (*set_volume)(uint8_t volume);
259 
260  /** Closes the interface. */
261  void (*cleanup)( void );
263 
264 __END_DECLS
265 
266 #endif /* ANDROID_INCLUDE_BT_RC_H */