Fix mem leak
[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         VOLUME_UP,
96         VOLUME_DOWN
97 } media_player_control_cmd;
98
99 typedef struct {
100         const char *title;
101         const char *artist;
102         const char *album;
103         const char *genre;
104         unsigned int total_tracks;
105         unsigned int number;
106         unsigned int duration;
107 } media_metadata_attributes_t;
108
109 typedef struct {
110         media_player_equalizer_status equalizer;
111         media_player_repeat_status  repeat;
112         media_player_shuffle_status  shuffle;
113         media_player_scan_status scan;
114         media_player_status status;
115         unsigned int position;
116         media_metadata_attributes_t metadata;
117 } media_player_settings_t;
118
119 typedef struct {
120         int event;
121         int result;
122         void *param_data;
123         void *user_data;
124 } media_event_param_t;
125
126 typedef void (*media_cb_func_ptr)(int, media_event_param_t*, void*);
127
128
129 /**
130  * @fn int bluetooth_media_player_init(media_cb_func_ptr callback_ptr, void *user_data)
131  * @brief Initialize AVRCP service and register the callback
132  *
133  * This function is a synchronous call.
134  *
135  * @param[in]   callback_ptr - Callback function (A2DP connected / Disconnected)
136  * @param[in]   user_data - User data
137  *
138  * @return  BT_MEDIA_ERROR_NONE  - Success \n
139  *              BT_MEDIA_ERROR_ALREADY_INITIALIZED   - Already initialized \n
140  *              BT_MEDIA_ERROR_INTERNAL  - Internal error \n
141  *
142  * @remark      None
143  *
144  */
145 int bluetooth_media_player_init(media_cb_func_ptr callback_ptr,
146                                         void *user_data);
147
148 /**
149  * @fn int bluetooth_media_player_deinit(void)
150  * @brief Deinitialize AVRCP service and register the callback
151  *
152  * This function is a synchronous call.
153  *
154  * @return  BT_MEDIA_CONTROL_SUCCESS  - Success \n
155  *              BT_MEDIA_CONTROL_ERROR - Error \n
156  *
157  * @remark      None
158  *
159  */
160 int bluetooth_media_player_deinit(void);
161
162 /**
163  * @fn int bluetooth_media_player_set_properties(media_player_settings_t *setting)
164  * @brief Notifies the remote bluetooth headset with change in music player settings
165  *
166  * This function is a asynchronous call.
167  * No event for this api..
168  *
169  * @return  BT_MEDIA_CONTROL_SUCCESS  - Success \n
170  *              BT_MEDIA_CONTROL_ERROR - Error \n
171  *
172  * @exception   None
173  * @param[in]   setting - The music player properties
174  *
175  * @remark       None
176  * @see None
177  */
178 int bluetooth_media_player_set_properties(
179                         media_player_settings_t *setting);
180
181 /**
182  * @fn int bluetooth_media_player_change_property(media_player_property_type type,
183  *                              unsigned int value);
184  * @brief Notifies the remote bluetooth headset with change in music player settings
185  *
186  * This function is a asynchronous call.
187  * No event for this api..
188  *
189  * @return  BT_MEDIA_CONTROL_SUCCESS  - Success \n
190  *              BT_MEDIA_CONTROL_ERROR - Error \n
191  *
192  * @exception   None
193  * @param[in]   type - Type of the music player property
194  *                       value - Value of the property which is changed
195  *
196  * @remark       None
197  * @see None
198  */
199 int bluetooth_media_player_change_property(
200                         media_player_property_type type,
201                         unsigned int value);
202
203 /**
204  * @fn int bluetooth_media_player_change_track(media_metadata_attributes_t metadata)
205  * @briefNotifies the remote bluetooth headset with change in media attributes of the track
206  *
207  * This function is a asynchronous call.
208  * No event for this api..
209  *
210  * @return  BT_MEDIA_CONTROL_SUCCESS  - Success \n
211  *              BT_MEDIA_CONTROL_ERROR - Error \n
212  *
213  * @exception   None
214  * @param[in]   metadata -Meida attributes
215  *
216  * @remark       None
217  * @see None
218  */
219 int bluetooth_media_player_change_track(
220                         media_metadata_attributes_t *metadata);
221
222 /**
223  * @fn int bluetooth_media_control_init(media_cb_func_ptr callback_ptr, void *user_data)
224  * @brief Initialize AVRCP control and register the callback
225  *
226  * This function is a synchronous call.
227  *
228  * @param[in]   callback_ptr - Callback function (AVRCP connected / Disconnected)
229  * @param[in]   user_data - User data
230  *
231  * @return  BT_MEDIA_ERROR_NONE  - Success \n
232  *              BT_MEDIA_ERROR_ALREADY_INITIALIZED   - Already initialized \n
233  *              BT_MEDIA_ERROR_INTERNAL  - Internal error \n
234  *
235  * @remark      None
236  *
237  */
238 int bluetooth_media_control_init(media_cb_func_ptr callback_ptr,
239                                                 void *user_data);
240
241 /**
242  * @fn int bluetooth_media_control_deinit(void)
243  * @brief Deinitialize AVRCP Control and deregister callback
244  *
245  * This function is a synchronous call.
246  *
247  * @return  BT_MEDIA_CONTROL_SUCCESS  - Success \n
248  *              BT_MEDIA_CONTROL_ERROR - Error \n
249  *
250  * @remark      None
251  *
252  */
253 int bluetooth_media_control_deinit(void);
254
255 /**
256  * @brief       The function bluetooth_media_control_connect is called to establish an AVRCP
257  *      control role connection with  the specified device.
258  *
259  * @param[in]   remote_address  Bluetooth device address.
260  * @return      int     Zero on Success or reason for error if any.
261  *
262  */
263 int bluetooth_media_control_connect(bluetooth_device_address_t *remote_address);
264
265 /**
266  * @brief       The function bluetooth_media_control_disconnect is called to disconnect an
267  *      existing AVRCP Control role connection with the specified device.
268  *
269  * @param[in]   remote_address  Bluetooth device address.
270  * @return      int     Zero on Success or reason for error if any.
271  *
272  */
273 int bluetooth_media_control_disconnect(bluetooth_device_address_t *remote_address);
274
275 /**
276  * @brief       The function bluetooth_media_target_connect is called to establish an AVRCP
277  *      target role connection with  the specified device.
278  *
279  * @param[in]   remote_address  Bluetooth device address.
280  * @return      int     Zero on Success or reason for error if any.
281  *
282  */
283 int bluetooth_media_target_connect(bluetooth_device_address_t *remote_address);
284
285 /**
286  * @brief       The function bluetooth_media_target_disconnect is called to disconnect an
287  *      existing AVRCP target role connection with the specified device.
288  *
289  * @param[in]   remote_address  Bluetooth device address.
290  * @return      int     Zero on Success or reason for error if any.
291  *
292  */
293 int bluetooth_media_target_disconnect(bluetooth_device_address_t *remote_address);
294
295 /**
296  * @brief       The function bluetooth_media_control_command is called to send
297  *      the  AVRCP Control command like Play, Pause, FF, Rewind to the target device.
298  *
299  * @param[in]   type    media_player_control_cmd.
300  * @return      int     Zero on Success or reason for error if any.
301  *
302  */
303 int bluetooth_media_control_command(media_player_control_cmd type);
304
305 /**
306  * @brief       The function bluetooth_media_control_command_to_dest is called to send
307  *      the  AVRCP Control command like Play, Pause, FF, Rewind to the specific target device.
308  *
309  * @param[in]   type    media_player_control_cmd.
310  * @param[in]   remote_address  Bluetooth device address.
311  * @return      int     Zero on Success or reason for error if any.
312  *
313  */
314 int bluetooth_media_control_command_to_dest(media_player_control_cmd type,
315                                         bluetooth_device_address_t *remote_address);
316
317 /**
318  * @fn int bluetooth_media_control_set_property(media_player_property_type type, unsigned int value)
319  * @brief Notifies the remote bluetooth target with change in music control settings
320  *
321  * This function is a asynchronous call.
322  * No event for this api.
323  *
324  * @return  BT_MEDIA_CONTROL_SUCCESS  - Success \n
325  *              BT_MEDIA_CONTROL_ERROR - Error \n
326  *
327  * @exception   None
328  * @param[in]   setting - The music control properties
329  *
330  * @remark       None
331  * @see None
332  */
333 int bluetooth_media_control_set_property(media_player_property_type type, unsigned int value);
334
335 /**
336  * @fn int bluetooth_media_control_get_property(media_player_property_type type, unsigned int *value)
337  * @brief reads the setting of the remote bluetooth target with change in music control settings
338  *
339  * This function is a asynchronous call.
340  * No event for this api.
341  *
342  * @return  BT_MEDIA_CONTROL_SUCCESS  - Success \n
343  *              BT_MEDIA_CONTROL_ERROR - Error \n
344  *
345  * @exception   None
346  * @param[in]   setting - The music control properties
347  *
348  * @remark       None
349  * @see None
350  */
351 int bluetooth_media_control_get_property(media_player_property_type type, unsigned int *value);
352
353 /**
354  * @fn int bluetooth_media_transport_set_property(media_transport_property_type type, unsigned int value)
355  * @brief Notifies the remote bluetooth target with change in audio transport settings
356  *
357  * This function is a asynchronous call.
358  * No event for this api.
359  *
360  * @return  BT_MEDIA_TRANSPORT_SUCCESS  - Success \n
361  *              BT_MEDIA_TRANSPORT_ERROR - Error \n
362  *
363  * @exception   None
364  * @param[in]   setting - The audio transport properties
365  *
366  * @remark       None
367  * @see None
368  */
369 int bluetooth_media_transport_set_property(media_transport_property_type type, unsigned int value);
370
371 /**
372  * @fn int bluetooth_media_control_get_track_info(media_metadata_attributes_t *metadata)
373  * @brief reads the track metadata from the remote target player.
374  *
375  * This function is a asynchronous call.
376  * No event for this api.
377  *
378  * @return  BT_MEDIA_CONTROL_SUCCESS  - Success \n
379  *              BT_MEDIA_CONTROL_ERROR - Error \n
380  *
381  * @exception   None
382  * @param[in]   metadata - The music meta data information.
383  *
384  * @remark       None
385  * @see None
386  */
387 int bluetooth_media_control_get_track_info(media_metadata_attributes_t *metadata);
388
389 #ifdef __cplusplus
390 }
391 #endif /*__cplusplus*/
392
393 #endif /*_BT_MP_CONTROL_H_*/