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