e27ce417e21a9cfada16d921d519df835b2d28c6
[platform/core/api/media-content.git] / src / media_audio.c
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 #include <media_info_private.h>
19
20
21 int audio_meta_destroy(audio_meta_h audio)
22 {
23         int ret = MEDIA_CONTENT_ERROR_NONE;
24         audio_meta_s *_audio = (audio_meta_s*)audio;
25
26         if (_audio) {
27                 SAFE_FREE(_audio->media_id);
28                 SAFE_FREE(_audio->title);
29                 SAFE_FREE(_audio->album);
30                 SAFE_FREE(_audio->artist);
31                 SAFE_FREE(_audio->album_artist);
32                 SAFE_FREE(_audio->genre);
33                 SAFE_FREE(_audio->composer);
34                 SAFE_FREE(_audio->year);
35                 SAFE_FREE(_audio->recorded_date);
36                 SAFE_FREE(_audio->copyright);
37                 SAFE_FREE(_audio->track_num);
38                 SAFE_FREE(_audio);
39
40                 ret = MEDIA_CONTENT_ERROR_NONE;
41         } else {
42                 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
43                 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
44         }
45
46         return ret;
47 }
48
49 int audio_meta_clone(audio_meta_h *dst, audio_meta_h src)
50 {
51         int ret = MEDIA_CONTENT_ERROR_NONE;
52         audio_meta_s *_src = (audio_meta_s*)src;
53
54         if (_src != NULL) {
55                 audio_meta_s *_dst = (audio_meta_s*)calloc(1, sizeof(audio_meta_s));
56                 media_content_retvm_if(_dst == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
57
58                 if (_src->media_id != NULL) {
59                         _dst->media_id = g_strdup(_src->media_id);
60                         if (_dst->media_id == NULL) {
61                                 audio_meta_destroy((audio_meta_h)_dst);
62                                 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
63                                 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
64                         }
65                 }
66
67                 if (_src->title != NULL) {
68                         _dst->title = g_strdup(_src->title);
69                         if (_dst->title == NULL) {
70                                 audio_meta_destroy((audio_meta_h)_dst);
71                                 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
72                                 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
73                         }
74                 }
75
76                 if (_src->album != NULL) {
77                         _dst->album = g_strdup(_src->album);
78                         if (_dst->album == NULL) {
79                                 audio_meta_destroy((audio_meta_h)_dst);
80                                 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
81                                 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
82                         }
83                 }
84
85                 if (_src->artist != NULL) {
86                         _dst->artist = g_strdup(_src->artist);
87                         if (_dst->artist == NULL) {
88                                 audio_meta_destroy((audio_meta_h)_dst);
89                                 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
90                                 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
91                         }
92                 }
93
94                 if (_src->album_artist != NULL) {
95                         _dst->album_artist = g_strdup(_src->album_artist);
96                         if (_dst->album_artist == NULL) {
97                                 audio_meta_destroy((audio_meta_h)_dst);
98                                 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
99                                 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
100                         }
101                 }
102
103                 if (_src->genre != NULL) {
104                         _dst->genre = g_strdup(_src->genre);
105                         if (_dst->genre == NULL) {
106                                 audio_meta_destroy((audio_meta_h)_dst);
107                                 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
108                                 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
109                         }
110                 }
111
112                 if (_src->composer != NULL) {
113                         _dst->composer = g_strdup(_src->composer);
114                         if (_dst->composer == NULL) {
115                                 audio_meta_destroy((audio_meta_h)_dst);
116                                 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
117                                 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
118                         }
119                 }
120
121                 if (_src->year != NULL) {
122                         _dst->year = g_strdup(_src->year);
123                         if (_dst->year == NULL) {
124                                 audio_meta_destroy((audio_meta_h)_dst);
125                                 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
126                                 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
127                         }
128                 }
129
130                 if (_src->recorded_date != NULL) {
131                         _dst->recorded_date = g_strdup(_src->recorded_date);
132                         if (_dst->recorded_date == NULL) {
133                                 audio_meta_destroy((audio_meta_h)_dst);
134                                 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
135                                 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
136                         }
137                 }
138
139                 if (_src->copyright != NULL) {
140                         _dst->copyright = g_strdup(_src->copyright);
141                         if (_dst->copyright == NULL) {
142                                 audio_meta_destroy((audio_meta_h)_dst);
143                                 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
144                                 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
145                         }
146                 }
147
148                 if (_src->track_num != NULL) {
149                         _dst->track_num = g_strdup(_src->track_num);
150                         if (_dst->track_num == NULL) {
151                                 audio_meta_destroy((audio_meta_h)_dst);
152                                 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
153                                 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
154                         }
155                 }
156
157                 _dst->bitrate = _src->bitrate;
158                 _dst->bitpersample = _src->bitpersample;
159                 _dst->samplerate = _src->samplerate;
160                 _dst->channel = _src->channel;
161                 _dst->duration = _src->duration;
162                 _dst->played_count = _src->played_count;
163                 _dst->played_time = _src->played_time;
164                 _dst->played_position = _src->played_position;
165
166                 *dst = (audio_meta_h)_dst;
167
168                 ret = MEDIA_CONTENT_ERROR_NONE;
169         } else {
170                 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
171                 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
172         }
173
174         return ret;
175 }
176
177 int audio_meta_get_media_id(audio_meta_h audio, char **media_id)
178 {
179         int ret = MEDIA_CONTENT_ERROR_NONE;
180         audio_meta_s *_audio = (audio_meta_s*)audio;
181         if (_audio) {
182                 if (STRING_VALID(_audio->media_id)) {
183                         *media_id = strdup(_audio->media_id);
184                         media_content_retvm_if(*media_id == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
185                 } else {
186                         *media_id = NULL;
187                 }
188                 ret = MEDIA_CONTENT_ERROR_NONE;
189
190         } else {
191                 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
192                 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
193         }
194
195         return ret;
196 }
197
198 int audio_meta_get_album(audio_meta_h audio, char **album)
199 {
200         int ret = MEDIA_CONTENT_ERROR_NONE;
201         audio_meta_s *_audio = (audio_meta_s*)audio;
202         if (_audio) {
203                 if (_audio->album != NULL) {
204                         *album = g_strdup(_audio->album);               /*album can be empty string*/
205                         media_content_retvm_if(*album == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
206                 } else {
207                         *album = NULL;
208                 }
209                 ret = MEDIA_CONTENT_ERROR_NONE;
210
211         } else {
212                 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
213                 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
214         }
215
216         return ret;
217 }
218
219 int audio_meta_get_artist(audio_meta_h audio, char **artist)
220 {
221         int ret = MEDIA_CONTENT_ERROR_NONE;
222         audio_meta_s *_audio = (audio_meta_s*)audio;
223
224         if (_audio) {
225                 if (_audio->artist != NULL) {
226                         *artist = g_strdup(_audio->artist);     /*artist can be empty string*/
227                         media_content_retvm_if(*artist == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
228                 } else {
229                         *artist = NULL;
230                 }
231                 ret = MEDIA_CONTENT_ERROR_NONE;
232
233         } else {
234                 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
235                 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
236         }
237
238         return ret;
239 }
240
241 int audio_meta_get_album_artist(audio_meta_h audio, char **album_artist)
242 {
243         int ret = MEDIA_CONTENT_ERROR_NONE;
244         audio_meta_s *_audio = (audio_meta_s*)audio;
245
246         if (_audio) {
247                 if (_audio->album_artist != NULL) {
248                         *album_artist = g_strdup(_audio->album_artist); /*album_artist can be empty string*/
249                         media_content_retvm_if(*album_artist == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
250                 } else {
251                         *album_artist = NULL;
252                 }
253                 ret = MEDIA_CONTENT_ERROR_NONE;
254
255         } else {
256                 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
257                 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
258         }
259
260         return ret;
261 }
262
263 int audio_meta_get_genre(audio_meta_h audio, char **genre)
264 {
265         int ret = MEDIA_CONTENT_ERROR_NONE;
266         audio_meta_s *_audio = (audio_meta_s*)audio;
267
268         if (_audio) {
269                 if (_audio->genre != NULL) {
270                         *genre = g_strdup(_audio->genre);       /*genre can be empty string*/
271                         media_content_retvm_if(*genre == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
272                 } else {
273                         *genre = NULL;
274                 }
275
276                 ret = MEDIA_CONTENT_ERROR_NONE;
277         } else {
278                 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
279                 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
280         }
281
282         return ret;
283 }
284
285 int audio_meta_get_composer(audio_meta_h audio, char **composer)
286 {
287         int ret = MEDIA_CONTENT_ERROR_NONE;
288         audio_meta_s *_audio = (audio_meta_s*)audio;
289
290         if (_audio) {
291                 if (_audio->composer != NULL) {
292                         *composer = g_strdup(_audio->composer); /*composer can be empty string*/
293                         media_content_retvm_if(*composer == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
294                 } else {
295                         *composer = NULL;
296                 }
297
298                 ret = MEDIA_CONTENT_ERROR_NONE;
299         } else {
300                 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
301                 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
302         }
303
304         return ret;
305 }
306
307 int audio_meta_get_year(audio_meta_h audio, char **year)
308 {
309         int ret = MEDIA_CONTENT_ERROR_NONE;
310         audio_meta_s *_audio = (audio_meta_s*)audio;
311
312         if (_audio) {
313                 if (_audio->year != NULL) {
314                         *year = g_strdup(_audio->year); /*year can be empty string*/
315                         media_content_retvm_if(*year == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
316                 } else {
317                         *year = NULL;
318                 }
319
320                 ret = MEDIA_CONTENT_ERROR_NONE;
321         } else {
322                 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
323                 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
324         }
325
326         return ret;
327 }
328
329 int audio_meta_get_recorded_date(audio_meta_h audio, char **recorded_date)
330 {
331         int ret = MEDIA_CONTENT_ERROR_NONE;
332         audio_meta_s *_audio = (audio_meta_s*)audio;
333
334         if (_audio) {
335                 if (_audio->recorded_date != NULL) {
336                         *recorded_date = g_strdup(_audio->recorded_date);
337                         media_content_retvm_if(*recorded_date == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
338                 } else {
339                         *recorded_date = NULL;
340                 }
341
342                 ret = MEDIA_CONTENT_ERROR_NONE;
343         } else {
344                 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
345                 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
346         }
347
348         return ret;
349 }
350
351 int audio_meta_get_copyright(audio_meta_h audio, char **copyright)
352 {
353         int ret = MEDIA_CONTENT_ERROR_NONE;
354         audio_meta_s *_audio = (audio_meta_s*)audio;
355
356         if (_audio) {
357                 if (_audio->copyright != NULL) {
358                         *copyright = g_strdup(_audio->copyright);       /*copyright can be empty string*/
359                         media_content_retvm_if(*copyright == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
360                 } else {
361                         *copyright = NULL;
362                 }
363
364                 ret = MEDIA_CONTENT_ERROR_NONE;
365         } else {
366                 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
367                 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
368         }
369
370         return ret;
371 }
372
373 int audio_meta_get_track_num(audio_meta_h audio, char **track_num)
374 {
375         int ret = MEDIA_CONTENT_ERROR_NONE;
376         audio_meta_s *_audio = (audio_meta_s*)audio;
377
378         if (_audio) {
379                 if (_audio->track_num != NULL) {
380                         *track_num = g_strdup(_audio->track_num);       /*track_num can be empty string*/
381                         media_content_retvm_if(*track_num == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
382                 } else {
383                         *track_num = NULL;
384                 }
385
386                 ret = MEDIA_CONTENT_ERROR_NONE;
387         } else {
388                 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
389                 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
390         }
391
392         return ret;
393 }
394
395 int audio_meta_get_bit_rate(audio_meta_h audio, int *bit_rate)
396 {
397         int ret = MEDIA_CONTENT_ERROR_NONE;
398         audio_meta_s *_audio = (audio_meta_s*)audio;
399
400         if (_audio && bit_rate) {
401                 *bit_rate = _audio->bitrate;
402                 ret = MEDIA_CONTENT_ERROR_NONE;
403         } else {
404                 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
405                 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
406         }
407
408         return ret;
409 }
410
411 int audio_meta_get_bitpersample(audio_meta_h audio, int *bitpersample)
412 {
413         int ret = MEDIA_CONTENT_ERROR_NONE;
414         audio_meta_s *_audio = (audio_meta_s*)audio;
415
416         if (_audio && bitpersample) {
417                 *bitpersample = _audio->bitpersample;
418                 ret = MEDIA_CONTENT_ERROR_NONE;
419         } else {
420                 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
421                 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
422         }
423
424         return ret;
425 }
426
427 int audio_meta_get_sample_rate(audio_meta_h audio, int *sample_rate)
428 {
429         int ret = MEDIA_CONTENT_ERROR_NONE;
430         audio_meta_s *_audio = (audio_meta_s*)audio;
431
432         if (_audio && sample_rate) {
433                 *sample_rate = _audio->samplerate;
434                 ret = MEDIA_CONTENT_ERROR_NONE;
435         } else {
436                 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
437                 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
438         }
439
440         return ret;
441 }
442
443 int audio_meta_get_channel(audio_meta_h audio, int *channel)
444 {
445         int ret = MEDIA_CONTENT_ERROR_NONE;
446         audio_meta_s *_audio = (audio_meta_s*)audio;
447
448         if (_audio && channel) {
449                 *channel = _audio->channel;
450                 ret = MEDIA_CONTENT_ERROR_NONE;
451         } else {
452                 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
453                 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
454         }
455
456         return ret;
457 }
458
459 int audio_meta_get_duration(audio_meta_h audio, int *duration)
460 {
461         int ret = MEDIA_CONTENT_ERROR_NONE;
462         audio_meta_s *_audio = (audio_meta_s*)audio;
463
464         if (_audio) {
465                 *duration = _audio->duration;
466                 ret = MEDIA_CONTENT_ERROR_NONE;
467         } else {
468                 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
469                 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
470         }
471
472         return ret;
473 }
474
475 int audio_meta_get_played_count(audio_meta_h audio, int *played_count)
476 {
477         int ret = MEDIA_CONTENT_ERROR_NONE;
478         media_content_warn("DEPRECATION WARNING: audio_meta_get_played_count() is deprecated and will be removed from next release. Use media_info_get_played_count() instead.");
479         audio_meta_s *_audio = (audio_meta_s*)audio;
480
481         if (_audio && played_count) {
482                 *played_count = _audio->played_count;
483                 ret = MEDIA_CONTENT_ERROR_NONE;
484         } else {
485                 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
486                 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
487         }
488
489         return ret;
490 }
491
492 int audio_meta_get_played_time(audio_meta_h audio, time_t* played_time)
493 {
494         int ret = MEDIA_CONTENT_ERROR_NONE;
495         media_content_warn("DEPRECATION WARNING: audio_meta_get_played_time() is deprecated and will be removed from next release. Use media_info_get_played_time() instead.");
496         audio_meta_s *_audio = (audio_meta_s*)audio;
497
498         if (_audio) {
499                 *played_time = _audio->played_time;
500                 ret = MEDIA_CONTENT_ERROR_NONE;
501         } else {
502                 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
503                 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
504         }
505
506         return ret;
507 }
508
509 int audio_meta_get_played_position(audio_meta_h audio, int *played_position)
510 {
511         int ret = MEDIA_CONTENT_ERROR_NONE;
512         media_content_warn("DEPRECATION WARNING: audio_meta_get_played_position() is deprecated and will be removed from next release.");
513         audio_meta_s *_audio = (audio_meta_s*)audio;
514
515         if (_audio) {
516                 *played_position = _audio->played_position;
517                 ret = MEDIA_CONTENT_ERROR_NONE;
518         } else {
519                 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
520                 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
521         }
522
523         return ret;
524 }
525
526 int audio_meta_set_played_count(audio_meta_h audio, int played_count)
527 {
528         int ret = MEDIA_CONTENT_ERROR_NONE;
529         media_content_warn("DEPRECATION WARNING: audio_meta_set_played_count() is deprecated and will be removed from next release. Use media_info_increase_played_count() instead.");
530         audio_meta_s *_audio = (audio_meta_s*)audio;
531
532         if ((_audio != NULL) && (played_count >= 0)) {
533                 _audio->played_count = played_count;
534         } else {
535                 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
536                 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
537         }
538
539         return ret;
540 }
541
542 int audio_meta_set_played_time(audio_meta_h audio, time_t played_time)
543 {
544         int ret = MEDIA_CONTENT_ERROR_NONE;
545         media_content_warn("DEPRECATION WARNING: audio_meta_set_played_time() is deprecated and will be removed from next release. Use media_info_set_played_time() instead.");
546         audio_meta_s *_audio = (audio_meta_s*)audio;
547
548         if ((_audio != NULL) && (played_time >= 0)) {
549                 _audio->played_time = played_time;
550         } else {
551                 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
552                 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
553         }
554
555         return ret;
556 }
557
558 int audio_meta_set_played_position(audio_meta_h audio, int played_position)
559 {
560         int ret = MEDIA_CONTENT_ERROR_NONE;
561         media_content_warn("DEPRECATION WARNING: audio_meta_set_played_position() is deprecated and will be removed from next release.");
562         audio_meta_s *_audio = (audio_meta_s*)audio;
563
564         if ((_audio != NULL) && (played_position >= 0)) {
565                 _audio->played_position = played_position;
566         } else {
567                 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
568                 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
569         }
570
571         return ret;
572 }
573
574 int audio_meta_update_to_db(audio_meta_h audio)
575 {
576         int ret = MEDIA_CONTENT_ERROR_NONE;
577         audio_meta_s *_audio = (audio_meta_s*)audio;
578         char *sql = NULL;
579
580         if (_audio != NULL && STRING_VALID(_audio->media_id)) {
581                 char storage_id[MEDIA_CONTENT_UUID_SIZE+1] = {0, };
582                 memset(storage_id, 0x00, sizeof(storage_id));
583
584                 ret = _media_db_get_storage_id_by_media_id(_audio->media_id, storage_id);
585                 media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
586
587                 sql = sqlite3_mprintf(UPDATE_AV_META_FROM_MEDIA, storage_id, _audio->played_count, _audio->played_time, _audio->played_position, _audio->media_id);
588                 ret = _content_query_sql(sql);
589                 SQLITE3_SAFE_FREE(sql);
590         } else {
591                 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
592                 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
593         }
594
595         return ret;
596 }