42faf8ee28e2d3d4938a0155193adb5d4629b653
[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         DELAY = 0x01,
44         VOLUME
45 } media_transport_property_type;
46
47 typedef enum {
48         EQUALIZER_OFF = 0x01,
49         EQUALIZER_ON,
50         EQUALIZER_INVALID,
51 } media_player_equalizer_status;
52
53 typedef enum {
54         REPEAT_MODE_OFF = 0x01,
55         REPEAT_SINGLE_TRACK,
56         REPEAT_ALL_TRACK,
57         REPEAT_GROUP,
58         REPEAT_INVALID,
59 } media_player_repeat_status;
60
61 typedef enum {
62         SHUFFLE_MODE_OFF = 0x01,
63         SHUFFLE_ALL_TRACK,
64         SHUFFLE_GROUP,
65         SHUFFLE_INVALID,
66 } media_player_shuffle_status;
67
68 typedef enum {
69         SCAN_MODE_OFF = 0x01,
70         SCAN_ALL_TRACK,
71         SCAN_GROUP,
72         SCAN_INVALID,
73 } media_player_scan_status;
74
75 typedef enum {
76         STATUS_STOPPED = 0x00,
77         STATUS_PLAYING,
78         STATUS_PAUSED,
79         STATUS_FORWARD_SEEK,
80         STATUS_REVERSE_SEEK,
81         STATUS_ERROR,
82         STATUS_INVALID
83 } media_player_status;
84
85 typedef enum {
86         PLAY = 0x01,
87         PAUSE,
88         STOP,
89         NEXT,
90         PREVIOUS,
91         PRESS_FAST_FORWARD,
92         RELEASE_FAST_FORWARD,
93         PRESS_REWIND,
94         RELEASE_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         unsigned int 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_target_connect is called to establish an AVRCP
275  *      target role connection with  the specified device.
276  *
277  * @param[in]   remote_address  Bluetooth device address.
278  * @return      int     Zero on Success or reason for error if any.
279  *
280  */
281 int bluetooth_media_target_connect(bluetooth_device_address_t *remote_address);
282
283 /**
284  * @brief       The function bluetooth_media_target_disconnect is called to disconnect an
285  *      existing AVRCP target role connection with the specified device.
286  *
287  * @param[in]   remote_address  Bluetooth device address.
288  * @return      int     Zero on Success or reason for error if any.
289  *
290  */
291 int bluetooth_media_target_disconnect(bluetooth_device_address_t *remote_address);
292
293 /**
294  * @brief       The function bluetooth_media_control_command is called to send
295  *      the  AVRCP Control command like Play, Pause, FF, Rewind to the target device.
296  *
297  * @param[in]   type    media_player_control_cmd.
298  * @return      int     Zero on Success or reason for error if any.
299  *
300  */
301 int bluetooth_media_control_command(media_player_control_cmd type);
302
303 /**
304  * @fn int bluetooth_media_control_set_property(media_player_property_type type, unsigned int value)
305  * @brief Notifies the remote bluetooth target with change in music control settings
306  *
307  * This function is a asynchronous call.
308  * No event for this api.
309  *
310  * @return  BT_MEDIA_CONTROL_SUCCESS  - Success \n
311  *              BT_MEDIA_CONTROL_ERROR - Error \n
312  *
313  * @exception   None
314  * @param[in]   setting - The music control properties
315  *
316  * @remark       None
317  * @see None
318  */
319 int bluetooth_media_control_set_property(media_player_property_type type, unsigned int value);
320
321 /**
322  * @fn int bluetooth_media_control_get_property(media_player_property_type type, unsigned int *value)
323  * @brief reads the setting of the remote bluetooth target with change in music control settings
324  *
325  * This function is a asynchronous call.
326  * No event for this api.
327  *
328  * @return  BT_MEDIA_CONTROL_SUCCESS  - Success \n
329  *              BT_MEDIA_CONTROL_ERROR - Error \n
330  *
331  * @exception   None
332  * @param[in]   setting - The music control properties
333  *
334  * @remark       None
335  * @see None
336  */
337 int bluetooth_media_control_get_property(media_player_property_type type, unsigned int *value);
338
339 /**
340  * @fn int bluetooth_media_transport_set_property(media_transport_property_type type, unsigned int value)
341  * @brief Notifies the remote bluetooth target with change in audio transport settings
342  *
343  * This function is a asynchronous call.
344  * No event for this api.
345  *
346  * @return  BT_MEDIA_TRANSPORT_SUCCESS  - Success \n
347  *              BT_MEDIA_TRANSPORT_ERROR - Error \n
348  *
349  * @exception   None
350  * @param[in]   setting - The audio transport properties
351  *
352  * @remark       None
353  * @see None
354  */
355 int bluetooth_media_transport_set_property(media_transport_property_type type, unsigned int value);
356
357 /**
358  * @fn int bluetooth_media_control_get_track_info(media_metadata_attributes_t *metadata)
359  * @brief reads the track metadata from the remote target player.
360  *
361  * This function is a asynchronous call.
362  * No event for this api.
363  *
364  * @return  BT_MEDIA_CONTROL_SUCCESS  - Success \n
365  *              BT_MEDIA_CONTROL_ERROR - Error \n
366  *
367  * @exception   None
368  * @param[in]   metadata - The music meta data information.
369  *
370  * @remark       None
371  * @see None
372  */
373 int bluetooth_media_control_get_track_info(media_metadata_attributes_t *metadata);
374
375 #ifdef __cplusplus
376 }
377 #endif /*__cplusplus*/
378
379 #endif /*_BT_MP_CONTROL_H_*/