[ACR-432] Add for db update notification
[platform/core/api/media-content.git] / include / media_audio.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 __TIZEN_AUDIO_META_H__
19 #define __TIZEN_AUDIO_META_H__
20
21 #include <media_content_type.h>
22
23 #ifdef __cplusplus
24 extern "C" {
25 #endif /* __cplusplus */
26
27 /**
28  * @file media_audio.h
29  * @brief This file contains the audio metadata API and related functions to proceed with audio metadata. \n
30  *        Description of the audio content involves: album, artist, album_artist, author, genre and description tags. \n
31  *        Parameters of the recording are also supported such as format, bitrate, duration, size etc.
32  */
33
34 /**
35  * @addtogroup CAPI_CONTENT_MEDIA_AUDIO_META_MODULE
36  * @{
37  */
38
39 /**
40  * @brief Clones the audio metadata.
41  * @details This function copies the audio metadata handle from a source to destination.
42  *
43  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
44  *
45  * @remarks You must release the destination handle using audio_meta_destroy().
46  *
47  * @param[out] dst The destination handle to the audio metadata
48  * @param[in]  src The source handle to the audio metadata
49  *
50  * @return @c 0 on success, 
51  *         otherwise a negative error value
52  *
53  * @retval #MEDIA_CONTENT_ERROR_NONE Successful
54  * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
55  * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory
56  * @retval #MEDIA_CONTENT_ERROR_PERMISSION_DENIED Permission denied
57  *
58  * @see audio_meta_destroy()
59  */
60 int audio_meta_clone(audio_meta_h *dst, audio_meta_h src);
61
62 /**
63  * @brief Destroys the audio metadata.
64  * @details This function frees all resources related to the audio metadata handle. This handle
65  *          no longer can be used to perform any operation. A new handle has to
66  *          be created before the next use.
67  *
68  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
69  *
70  * @param[in] audio The audio metadata handle
71  *
72  * @return @c 0 on success, 
73  *         otherwise a negative error value
74  *
75  * @retval #MEDIA_CONTENT_ERROR_NONE              Successful
76  * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
77  * @retval #MEDIA_CONTENT_ERROR_PERMISSION_DENIED Permission denied
78  *
79  * @pre Get a copy of audio metadata handle handle by calling audio_meta_clone().
80  *
81  * @see audio_meta_clone()
82  */
83 int audio_meta_destroy(audio_meta_h audio);
84
85 /**
86  * @brief Gets the ID of the media of the given audio metadata.
87  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
88  *
89  * @remarks You must release @a media_id using free().
90  *
91  * @param[in]  audio    The audio metadata handle
92  * @param[out] media_id The ID of the audio
93  *
94  * @return @c 0 on success, 
95  *         otherwise a negative error value
96  *
97  * @retval #MEDIA_CONTENT_ERROR_NONE              Successful
98  * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
99  * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY     Out of memory
100  * @retval #MEDIA_CONTENT_ERROR_PERMISSION_DENIED Permission denied
101  */
102 int audio_meta_get_media_id(audio_meta_h audio, char **media_id);
103
104 /**
105  * @brief Gets the album of the given audio metadata.
106  * @details If the value is an empty string, the method returns "Unknown".
107  *
108  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
109  *
110  * @remarks You must release @a album using free().
111  *
112  * @param[in]  audio The audio metadata handle
113  * @param[out] album The album of the audio metadata
114  *
115  * @return @c 0 on success, 
116  *         otherwise a negative error value
117  *
118  * @retval #MEDIA_CONTENT_ERROR_NONE              Successful
119  * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
120  * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY     Out of memory
121  * @retval #MEDIA_CONTENT_ERROR_PERMISSION_DENIED Permission denied
122  */
123 int audio_meta_get_album(audio_meta_h audio, char **album);
124
125 /**
126  * @brief Gets the artist of the given audio metadata.
127  * @details If the value is an empty string, the method returns "Unknown".
128  *
129  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
130  *
131  * @remarks You must release @a artist using free().
132  *
133  * @param[in]  audio  The audio metadata handle
134  * @param[out] artist The artist of the audio metadata
135  *
136  * @return @c 0 on success, 
137  *         otherwise a negative error value
138  *
139  * @retval #MEDIA_CONTENT_ERROR_NONE              Successful
140  * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
141  * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY     Out of memory
142  * @retval #MEDIA_CONTENT_ERROR_PERMISSION_DENIED Permission denied
143  */
144 int audio_meta_get_artist(audio_meta_h audio, char **artist);
145
146 /**
147  * @brief Gets the album artist of the given audio metadata.
148  * @details If the value is an empty string, the method returns "Unknown".
149  *
150  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
151  *
152  * @remarks You must release @a album_artist using free().
153  *
154  * @param[in]  audio        The audio metadata handle
155  * @param[out] album_artist The album artist of the audio metadata
156  *
157  * @return @c 0 on success, 
158  *         otherwise a negative error value
159  *
160  * @retval #MEDIA_CONTENT_ERROR_NONE              Successful
161  * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
162  * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY     Out of memory
163  * @retval #MEDIA_CONTENT_ERROR_PERMISSION_DENIED Permission denied
164  */
165 int audio_meta_get_album_artist(audio_meta_h audio, char **album_artist);
166
167 /**
168  * @brief Gets the genre of the given audio metadata.
169  * @details If the value is an empty string, the method returns "Unknown".
170  *
171  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
172  *
173  * @remarks You must release @a genre using free().
174  *
175  * @param[in]  audio The audio metadata handle
176  * @param[out] genre The genre of the audio metadata
177  *
178  * @return @c 0 on success, 
179  *         otherwise a negative error value
180  *
181  * @retval #MEDIA_CONTENT_ERROR_NONE              Successful
182  * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
183  * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY     Out of memory
184  * @retval #MEDIA_CONTENT_ERROR_PERMISSION_DENIED Permission denied
185  */
186 int audio_meta_get_genre(audio_meta_h audio, char **genre);
187
188 /**
189  * @brief Gets the composer of the given audio metadata.
190  * @details If the value is an empty string, the method returns "Unknown".
191  *
192  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
193  *
194  * @remarks You must release @a composer using free().
195  *
196  * @param[in]  audio    The audio metadata handle
197  * @param[out] composer The composer of the audio metadata
198  *
199  * @return @c 0 on success, 
200  *         otherwise a negative error value
201  *
202  * @retval #MEDIA_CONTENT_ERROR_NONE              Successful
203  * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
204  * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY     Out of memory
205  * @retval #MEDIA_CONTENT_ERROR_PERMISSION_DENIED Permission denied
206  */
207 int audio_meta_get_composer(audio_meta_h audio, char **composer);
208
209 /**
210  * @brief Gets the year of the given audio metadata.
211  * @details If the value is an empty string, the method returns "Unknown".
212  *
213  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
214  *
215  * @remarks You must release @a year using free().
216  *
217  * @param[in]  audio The audio metadata handle
218  * @param[out] year  The year of the audio metadata
219  *
220  * @return @c 0 on success, 
221  *         otherwise a negative error value
222  *
223  * @retval #MEDIA_CONTENT_ERROR_NONE              Successful
224  * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
225  * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY     Out of memory
226  * @retval #MEDIA_CONTENT_ERROR_PERMISSION_DENIED Permission denied
227  */
228 int audio_meta_get_year(audio_meta_h audio, char **year);
229
230 /**
231  * @brief Gets the recorded date of the given audio metadata.
232  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
233  *
234  * @remarks You must release @a recorded_date using free().
235  *
236  * @param[in]  audio         The audio metadata handle
237  * @param[out] recorded_date The recorded date of the audio metadata
238  *
239  * @return @c 0 on success, 
240  *         otherwise a negative error value
241  *
242  * @retval #MEDIA_CONTENT_ERROR_NONE              Successful
243  * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
244  * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY     Out of memory
245  * @retval #MEDIA_CONTENT_ERROR_PERMISSION_DENIED Permission denied
246  */
247 int audio_meta_get_recorded_date(audio_meta_h audio, char **recorded_date);
248
249 /**
250  * @brief Gets the copyright notice of the given audio metadata.
251  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
252  *
253  * @remarks You must release @a copyright using free().
254  *
255  * @param[in]  audio     The audio metadata handle
256  * @param[out] copyright The copyright of the audio metadata
257  *
258  * @return @c 0 on success, 
259  *         otherwise a negative error value
260  *
261  * @retval #MEDIA_CONTENT_ERROR_NONE              Successful
262  * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
263  * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY     Out of memory
264  * @retval #MEDIA_CONTENT_ERROR_PERMISSION_DENIED Permission denied
265  */
266 int audio_meta_get_copyright(audio_meta_h audio, char **copyright);
267
268 /**
269  * @brief Gets the track number of the given audio metadata.
270  * @details If the value is an empty string, the method returns "Unknown".
271  *
272  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
273  *
274  * @remarks You must release @a track_num using free().
275  *
276  * @param[in]  audio     The audio metadata handle
277  * @param[out] track_num The audio track number of the audio metadata
278  *
279  * @return @c 0 on success, 
280  *         otherwise a negative error value
281  *
282  * @retval #MEDIA_CONTENT_ERROR_NONE              Successful
283  * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
284  * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY     Out of memory
285  * @retval #MEDIA_CONTENT_ERROR_PERMISSION_DENIED Permission denied
286  */
287 int audio_meta_get_track_num(audio_meta_h audio, char **track_num);
288
289 /**
290  * @brief Gets the bitrate of the given audio metadata in bitrate per second.
291  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
292  *
293  * @param[in]  audio    The audio metadata handle
294  * @param[out] bit_rate The audio bitrate in bit per second [bps]
295  *
296  * @return @c 0 on success, 
297  *         otherwise a negative error value
298  *
299  * @retval #MEDIA_CONTENT_ERROR_NONE              Successful
300  * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
301  * @retval #MEDIA_CONTENT_ERROR_PERMISSION_DENIED Permission denied
302  */
303 int audio_meta_get_bit_rate(audio_meta_h audio, int *bit_rate);
304
305 /**
306  * @brief Gets bit per sample of the given audio metadata.
307  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
308  *
309  * @param [in]  audio        The handle to the audio metadata
310  * @param [out] bitpersample The audio bit per sample
311  *
312  * @return @c 0 on success, 
313  *         otherwise a negative error value
314  *
315  * @retval #MEDIA_CONTENT_ERROR_NONE              Successful
316  * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
317  * @retval #MEDIA_CONTENT_ERROR_PERMISSION_DENIED Permission denied
318  */
319 int audio_meta_get_bitpersample(audio_meta_h audio, int *bitpersample);
320
321 /**
322  * @brief Gets the sample rate of the given audio metadata.
323  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
324  *
325  * @param[in]  audio       The audio metadata handle
326  * @param[out] sample_rate The audio sample rate[hz]
327  *
328  * @return @c 0 on success, 
329  *         otherwise a negative error value
330  *
331  * @retval #MEDIA_CONTENT_ERROR_NONE              Successful
332  * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
333  * @retval #MEDIA_CONTENT_ERROR_PERMISSION_DENIED Permission denied
334  */
335 int audio_meta_get_sample_rate(audio_meta_h audio, int *sample_rate);
336
337 /**
338  * @brief Gets the channel of the given audio metadata.
339  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
340  *
341  * @param[in]  audio   The audio metadata handle
342  * @param[out] channel The channel of the audio
343  *
344  * @return @c 0 on success, 
345  *         otherwise a negative error value
346  *
347  * @retval #MEDIA_CONTENT_ERROR_NONE              Successful
348  * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
349  * @retval #MEDIA_CONTENT_ERROR_PERMISSION_DENIED Permission denied
350  */
351 int audio_meta_get_channel(audio_meta_h audio, int *channel);
352
353 /**
354  * @brief Gets the track duration of the given audio metadata.
355  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
356  *
357  * @param[in]  audio    The audio metadata handle
358  * @param[out] duration The audio file duration
359  *
360  * @return @c 0 on success, 
361  *         otherwise a negative error value
362  *
363  * @retval #MEDIA_CONTENT_ERROR_NONE              Successful
364  * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
365  * @retval #MEDIA_CONTENT_ERROR_PERMISSION_DENIED Permission denied
366  */
367 int audio_meta_get_duration(audio_meta_h audio, int *duration);
368
369 /**
370  * @deprecated Deprecated since 2.4. [Use media_info_get_played_count() instead]
371  * @brief Gets the number of times the given audio has been played.
372  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
373  *
374  * @param[in]  audio        The audio metadata handle
375  * @param[out] played_count The counter of the audio played
376  *
377  * @return @c 0 on success, 
378  *         otherwise a negative error value
379  *
380  * @retval #MEDIA_CONTENT_ERROR_NONE              Successful
381  * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
382  * @retval #MEDIA_CONTENT_ERROR_PERMISSION_DENIED Permission denied
383  */
384 int audio_meta_get_played_count(audio_meta_h audio, int *played_count);
385
386 /**
387  * @deprecated Deprecated since 2.4. [Use media_info_get_played_time() instead]
388  * @brief Gets the last played time parameter of the audio.
389  *
390  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
391  *
392  * @param[in]  audio       The audio metadata handle
393  * @param[out] played_time The last played time of the audio
394  *
395  * @return @c 0 on success, 
396  *         otherwise a negative error value
397  *
398  * @retval #MEDIA_CONTENT_ERROR_NONE              Successful
399  * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
400  * @retval #MEDIA_CONTENT_ERROR_PERMISSION_DENIED Permission denied
401  */
402 int audio_meta_get_played_time(audio_meta_h audio, time_t *played_time);
403
404 /**
405  * @deprecated Deprecated since 2.4.
406  * @brief Gets the played position parameter of the audio.
407  * @details This function returns the elapsed playback position parameter of the audio as a period
408  *          starting from the beginning of the track.
409  *
410  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
411  *
412  * @param[in]  audio           The audio metadata handle
413  * @param[out] played_position The elapsed time of the audio
414  *
415  * @return @c 0 on success, 
416  *         otherwise a negative error value
417  *
418  * @retval #MEDIA_CONTENT_ERROR_NONE              Successful
419  * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
420  * @retval #MEDIA_CONTENT_ERROR_PERMISSION_DENIED Permission denied
421  */
422 int audio_meta_get_played_position(audio_meta_h audio, int *played_position);
423
424 /**
425  * @deprecated Deprecated since 2.4. [Use media_info_increase_played_count() instead]
426  * @brief Sets the played count of the audio.
427  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
428  *
429  * @param[in] audio        The audio metadata handle
430  * @param[in] played_count The played count of the audio
431  *
432  * @return @c 0 on success, 
433  *         otherwise a negative error value
434  *
435  * @retval #MEDIA_CONTENT_ERROR_NONE              Successful
436  * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
437  * @retval #MEDIA_CONTENT_ERROR_PERMISSION_DENIED Permission denied
438  *
439  * @post audio_meta_update_to_db().
440  */
441 int audio_meta_set_played_count(audio_meta_h audio, int played_count);
442
443 /**
444  * @deprecated Deprecated since 2.4. [Use media_info_set_played_time() instead]
445  * @brief Sets the last played time of the audio.
446  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
447  *
448  * @param[in] audio       The audio metadata handle
449  * @param[in] played_time The last played time of the audio
450  *
451  * @return @c 0 on success, 
452  *         otherwise a negative error value
453  *
454  * @retval #MEDIA_CONTENT_ERROR_NONE              Successful
455  * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
456  * @retval #MEDIA_CONTENT_ERROR_PERMISSION_DENIED Permission denied
457  *
458  * @post audio_meta_update_to_db().
459  */
460 int audio_meta_set_played_time(audio_meta_h audio, time_t played_time);
461
462 /**
463  * @deprecated Deprecated since 2.4.
464  * @brief Sets the played position of the audio.
465  *
466  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
467  *
468  * @remarks  It is NOT recommended to use this attribute for your application-specific purpose because this attribute can be overwritten by other applications (even 0).
469  *
470  * @param[in] audio           The audio metadata handle
471  * @param[in] played_position The played position of the audio
472  *
473  * @return @c 0 on success, 
474  *         otherwise a negative error value
475  *
476  * @retval #MEDIA_CONTENT_ERROR_NONE              Successful
477  * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
478  * @retval #MEDIA_CONTENT_ERROR_PERMISSION_DENIED Permission denied
479  *
480  * @post audio_meta_update_to_db().
481  */
482 int audio_meta_set_played_position(audio_meta_h audio, int played_position);
483
484 /**
485  * @brief Updates an audio metadata with modified attributes in the media database.
486  * @details The function updates the given audio meta in the media database. The function should be called after any change in audio attributes, to be updated to the media
487  *          database. For example, for setting the played time using audio_meta_get_played_time(), after that the audio_meta_update_to_db() function should be called to update media database.
488  *
489  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
490  *
491  * @privlevel public
492  * @privilege %http://tizen.org/privilege/content.write
493  *
494  * @remarks Do not call this function in callback function of foreach function like media_info_foreach_media_from_db().
495  *
496  * @param[in] audio The audio metadata handle
497  *
498  * @return @c 0 on success, 
499  *         otherwise a negative error value
500  *
501  * @retval #MEDIA_CONTENT_ERROR_NONE              Successful
502  * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
503  * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY     Out of memory
504  * @retval #MEDIA_CONTENT_ERROR_INVALID_OPERATION Invalid operation
505  * @retval #MEDIA_CONTENT_ERROR_DB_FAILED         DB Operation failed
506  * @retval #MEDIA_CONTENT_ERROR_DB_BUSY           DB Operation busy
507  * @retval #MEDIA_CONTENT_ERROR_NETWORK           Network fail
508  * @retval #MEDIA_CONTENT_ERROR_PERMISSION_DENIED Permission denied
509  *
510  * @pre This function requires opened connection to content service by media_content_connect().
511  *
512  * @see media_content_connect()
513  * @see audio_meta_set_played_time()
514  * @see audio_meta_set_played_count()
515  * @see audio_meta_set_played_position()
516  */
517 int audio_meta_update_to_db(audio_meta_h audio);
518
519 /**
520  *@}
521  */
522
523 #ifdef __cplusplus
524 }
525 #endif /* __cplusplus */
526
527 #endif /*__TIZEN_AUDIO_META_H__*/