Modify gatt-server interface as per bluez_5.37.
[platform/core/connectivity/bluetooth-frwk.git] / include / bluetooth-media-control.h
1 /*
2  * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
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
18 #ifndef _BT_MP_CONTROL_H_
19 #define _BT_MP_CONTROL_H_
20
21 #ifdef __cplusplus
22 extern "C" {
23 #endif /*__cplusplus*/
24
25 #define BT_MEDIA_ERROR_NONE ((int)0)
26
27 #define BT_MEDIA_ERROR_BASE ((int)0)
28 #define BT_MEDIA_ERROR_INTERNAL ((int)BT_MEDIA_ERROR_BASE - 0x01)
29 #define BT_MEDIA_ERROR_ALREADY_INITIALIZED ((int)BT_MEDIA_ERROR_BASE - 0x02)
30 #define BT_MEDIA_ERROR_NOT_CONNECTED ((int)BT_MEDIA_ERROR_BASE - 0x15)
31
32 typedef enum {
33         EQUALIZER = 0x01,
34         REPEAT,
35         SHUFFLE,
36         SCAN,
37         POSITION,
38         METADATA,
39         STATUS
40 } media_player_property_type;
41
42 typedef enum {
43         EQUALIZER_OFF = 0x01,
44         EQUALIZER_ON,
45         EQUALIZER_INVALID,
46 } media_player_equalizer_status;
47
48 typedef enum {
49         REPEAT_MODE_OFF = 0x01,
50         REPEAT_SINGLE_TRACK,
51         REPEAT_ALL_TRACK,
52         REPEAT_GROUP,
53         REPEAT_INVALID,
54 } media_player_repeat_status;
55
56 typedef enum {
57         SHUFFLE_MODE_OFF = 0x01,
58         SHUFFLE_ALL_TRACK,
59         SHUFFLE_GROUP,
60         SHUFFLE_INVALID,
61 } media_player_shuffle_status;
62
63 typedef enum {
64         SCAN_MODE_OFF = 0x01,
65         SCAN_ALL_TRACK,
66         SCAN_GROUP,
67         SCAN_INVALID,
68 } media_player_scan_status;
69
70 typedef enum {
71         STATUS_STOPPED = 0x00,
72         STATUS_PLAYING,
73         STATUS_PAUSED,
74         STATUS_FORWARD_SEEK,
75         STATUS_REVERSE_SEEK,
76         STATUS_ERROR,
77         STATUS_INVALID
78 } media_player_status;
79
80 typedef enum {
81         PLAY = 0x01,
82         PAUSE,
83         STOP,
84         NEXT,
85         PREVIOUS,
86         FAST_FORWARD,
87         REWIND
88 } media_player_control_cmd;
89
90 typedef struct {
91         const char *title;
92         const char *artist;
93         const char *album;
94         const char *genre;
95         unsigned int total_tracks;
96         unsigned int number;
97         int64_t duration;
98 } media_metadata_attributes_t;
99
100 typedef struct {
101         media_player_equalizer_status equalizer;
102         media_player_repeat_status  repeat;
103         media_player_shuffle_status  shuffle;
104         media_player_scan_status scan;
105         media_player_status status;
106         unsigned int position;
107         media_metadata_attributes_t metadata;
108 } media_player_settings_t;
109
110 typedef struct {
111         int event;
112         int result;
113         void *param_data;
114         void *user_data;
115 } media_event_param_t;
116
117 typedef void (*media_cb_func_ptr)(int, media_event_param_t*, void*);
118
119
120 /**
121  * @fn int bluetooth_media_player_init(media_cb_func_ptr callback_ptr, void *user_data)
122  * @brief Initialize AVRCP service and register the callback
123  *
124  * This function is a synchronous call.
125  *
126  * @param[in]   callback_ptr - Callback function (A2DP connected / Disconnected)
127  * @param[in]   user_data - User data
128  *
129  * @return  BT_MEDIA_ERROR_NONE  - Success \n
130  *              BT_MEDIA_ERROR_ALREADY_INITIALIZED   - Already initialized \n
131  *              BT_MEDIA_ERROR_INTERNAL  - Internal error \n
132  *
133  * @remark      None
134  *
135  */
136 int bluetooth_media_player_init(media_cb_func_ptr callback_ptr,
137                                         void *user_data);
138
139 /**
140  * @fn int bluetooth_media_player_deinit(void)
141  * @brief Deinitialize AVRCP service and register the callback
142  *
143  * This function is a synchronous call.
144  *
145  * @return  BT_MEDIA_CONTROL_SUCCESS  - Success \n
146  *              BT_MEDIA_CONTROL_ERROR - Error \n
147  *
148  * @remark      None
149  *
150  */
151 int bluetooth_media_player_deinit(void);
152
153 /**
154  * @fn int bluetooth_media_player_set_properties(media_player_settings_t *setting)
155  * @brief Notifies the remote bluetooth headset with change in music player settings
156  *
157  * This function is a asynchronous call.
158  * No event for this api..
159  *
160  * @return  BT_MEDIA_CONTROL_SUCCESS  - Success \n
161  *              BT_MEDIA_CONTROL_ERROR - Error \n
162  *
163  * @exception   None
164  * @param[in]   setting - The music player properties
165  *
166  * @remark       None
167  * @see          None
168  */
169 int bluetooth_media_player_set_properties(
170                         media_player_settings_t *setting);
171
172 /**
173  * @fn int bluetooth_media_player_change_property(media_player_property_type type,
174  *                              unsigned int value);
175  * @brief Notifies the remote bluetooth headset with change in music player settings
176  *
177  * This function is a asynchronous call.
178  * No event for this api..
179  *
180  * @return  BT_MEDIA_CONTROL_SUCCESS  - Success \n
181  *              BT_MEDIA_CONTROL_ERROR - Error \n
182  *
183  * @exception   None
184  * @param[in]   type - Type of the music player property
185  *                       value - Value of the property which is changed
186  *
187  * @remark       None
188  * @see          None
189  */
190 int bluetooth_media_player_change_property(
191                         media_player_property_type type,
192                         unsigned int value);
193
194 /**
195  * @fn int bluetooth_media_player_change_track(media_metadata_attributes_t metadata)
196  * @briefNotifies the remote bluetooth headset with change in media attributes of the track
197  *
198  * This function is a asynchronous call.
199  * No event for this api..
200  *
201  * @return  BT_MEDIA_CONTROL_SUCCESS  - Success \n
202  *              BT_MEDIA_CONTROL_ERROR - Error \n
203  *
204  * @exception   None
205  * @param[in]     metadata -Meida attributes
206  *
207  * @remark       None
208  * @see          None
209  */
210 int bluetooth_media_player_change_track(
211                         media_metadata_attributes_t *metadata);
212
213 /**
214  * @fn int bluetooth_media_control_init(media_cb_func_ptr callback_ptr, void *user_data)
215  * @brief Initialize AVRCP control and register the callback
216  *
217  * This function is a synchronous call.
218  *
219  * @param[in]   callback_ptr - Callback function (AVRCP connected / Disconnected)
220  * @param[in]   user_data - User data
221  *
222  * @return  BT_MEDIA_ERROR_NONE  - Success \n
223  *              BT_MEDIA_ERROR_ALREADY_INITIALIZED   - Already initialized \n
224  *              BT_MEDIA_ERROR_INTERNAL  - Internal error \n
225  *
226  * @remark      None
227  *
228  */
229 int bluetooth_media_control_init(media_cb_func_ptr callback_ptr,
230                                                 void *user_data);
231
232 /**
233  * @fn int bluetooth_media_control_deinit(void)
234  * @brief Deinitialize AVRCP Control and deregister callback
235  *
236  * This function is a synchronous call.
237  *
238  * @return  BT_MEDIA_CONTROL_SUCCESS  - Success \n
239  *              BT_MEDIA_CONTROL_ERROR - Error \n
240  *
241  * @remark      None
242  *
243  */
244  int bluetooth_media_control_deinit(void);
245
246 /**
247  * @brief       The function bluetooth_media_control_connect is called to establish an AVRCP
248  *      control role connection with  the specified device.
249  *
250  * @param[in]   remote_address  Bluetooth device address.
251  * @return      int     Zero on Success or reason for error if any.
252  *
253  */
254 int bluetooth_media_control_connect(bluetooth_device_address_t *remote_address);
255
256 /**
257  * @brief       The function bluetooth_media_control_disconnect is called to disconnect an
258  *      existing AVRCP Control role connection with the specified device.
259  *
260  * @param[in]   remote_address  Bluetooth device address.
261  * @return      int     Zero on Success or reason for error if any.
262  *
263  */
264 int bluetooth_media_control_disconnect(bluetooth_device_address_t *remote_address);
265
266 /**
267  * @brief       The function bluetooth_media_control_command is called to send
268  *      the  AVRCP Control command like Play, Pause, FF, Rewind to the target device.
269  *
270  * @param[in]   type    media_player_control_cmd.
271  * @return      int     Zero on Success or reason for error if any.
272  *
273  */
274 int bluetooth_media_control_command(media_player_control_cmd type);
275
276 /**
277  * @fn int bluetooth_media_control_set_property(media_player_property_type type, unsigned int value)
278  * @brief Notifies the remote bluetooth target with change in music control settings
279  *
280  * This function is a asynchronous call.
281  * No event for this api.
282  *
283  * @return  BT_MEDIA_CONTROL_SUCCESS  - Success \n
284  *              BT_MEDIA_CONTROL_ERROR - Error \n
285  *
286  * @exception   None
287  * @param[in]   setting - The music control properties
288  *
289  * @remark       None
290  * @see          None
291  */
292  int bluetooth_media_control_set_property(media_player_property_type type, unsigned int value);
293
294 /**
295  * @fn int bluetooth_media_control_get_property(media_player_property_type type, unsigned int *value)
296  * @brief reads the setting of the remote bluetooth target with change in music control settings
297  *
298  * This function is a asynchronous call.
299  * No event for this api.
300  *
301  * @return  BT_MEDIA_CONTROL_SUCCESS  - Success \n
302  *              BT_MEDIA_CONTROL_ERROR - Error \n
303  *
304  * @exception   None
305  * @param[in]   setting - The music control properties
306  *
307  * @remark       None
308  * @see          None
309  */
310 int bluetooth_media_control_get_property(media_player_property_type type, unsigned int *value);
311
312 /**
313  * @fn int bluetooth_media_control_get_track_info(media_metadata_attributes_t *metadata)
314  * @brief reads the track metadata from the remote target player.
315  *
316  * This function is a asynchronous call.
317  * No event for this api.
318  *
319  * @return  BT_MEDIA_CONTROL_SUCCESS  - Success \n
320  *              BT_MEDIA_CONTROL_ERROR - Error \n
321  *
322  * @exception   None
323  * @param[in]   metadata - The music meta data information.
324  *
325  * @remark       None
326  * @see          None
327  */
328  int bluetooth_media_control_get_track_info(media_metadata_attributes_t *metadata);
329
330 #ifdef __cplusplus
331 }
332 #endif /*__cplusplus*/
333
334 #endif /*_BT_MP_CONTROL_H_*/