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