Add new API(image meta/storage/playlist).
[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         {
28                 SAFE_FREE(_audio->media_id);
29                 SAFE_FREE(_audio->title);
30                 SAFE_FREE(_audio->album);
31                 SAFE_FREE(_audio->artist);
32                 SAFE_FREE(_audio->album_artist);
33                 SAFE_FREE(_audio->genre);
34                 SAFE_FREE(_audio->composer);
35                 SAFE_FREE(_audio->year);
36                 SAFE_FREE(_audio->recorded_date);
37                 SAFE_FREE(_audio->copyright);
38                 SAFE_FREE(_audio->track_num);
39                 SAFE_FREE(_audio);
40
41                 ret = MEDIA_CONTENT_ERROR_NONE;
42         }
43         else
44         {
45                 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
46                 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
47         }
48
49         return ret;
50 }
51
52 int audio_meta_clone(audio_meta_h *dst, audio_meta_h src)
53 {
54         int ret = MEDIA_CONTENT_ERROR_NONE;
55         audio_meta_s *_src = (audio_meta_s*)src;
56
57         if(_src != NULL)
58         {
59                 audio_meta_s *_dst = (audio_meta_s*)calloc(1, sizeof(audio_meta_s));
60
61                 if(_dst == NULL)
62                 {
63
64                         media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
65                         return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
66                 }
67
68                 if(STRING_VALID(_src->media_id))
69                 {
70                         _dst->media_id = strdup(_src->media_id);
71                         if(_dst->media_id == NULL)
72                         {
73                                 audio_meta_destroy((audio_meta_h)_dst);
74                                 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
75                                 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
76                         }
77                 }
78
79                 if(STRING_VALID(_src->title))
80                 {
81                         _dst->title = strdup(_src->title);
82                         if(_dst->title == NULL)
83                         {
84                                 audio_meta_destroy((audio_meta_h)_dst);
85                                 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
86                                 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
87                         }
88                 }
89
90                 if(STRING_VALID(_src->album))
91                 {
92                         _dst->album = strdup(_src->album);
93                         if(_dst->album == NULL)
94                         {
95                                 audio_meta_destroy((audio_meta_h)_dst);
96                                 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
97                                 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
98                         }
99                 }
100
101                 if(STRING_VALID(_src->artist))
102                 {
103                         _dst->artist = strdup(_src->artist);
104                         if(_dst->artist == NULL)
105                         {
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(STRING_VALID(_src->album_artist))
113                 {
114                         _dst->album_artist = strdup(_src->album_artist);
115                         if(_dst->album_artist == NULL)
116                         {
117                                 audio_meta_destroy((audio_meta_h)_dst);
118                                 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
119                                 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
120                         }
121                 }
122
123                 if(STRING_VALID(_src->genre))
124                 {
125                         _dst->genre = strdup(_src->genre);
126                         if(_dst->genre == NULL)
127                         {
128                                 audio_meta_destroy((audio_meta_h)_dst);
129                                 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
130                                 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
131                         }
132                 }
133
134                 if(STRING_VALID(_src->composer))
135                 {
136                         _dst->composer = strdup(_src->composer);
137                         if(_dst->composer == NULL)
138                         {
139                                 audio_meta_destroy((audio_meta_h)_dst);
140                                 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
141                                 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
142                         }
143                 }
144
145                 if(STRING_VALID(_src->year))
146                 {
147                         _dst->year = strdup(_src->year);
148                         if(_dst->year == NULL)
149                         {
150                                 audio_meta_destroy((audio_meta_h)_dst);
151                                 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
152                                 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
153                         }
154                 }
155
156                 if(STRING_VALID(_src->recorded_date))
157                 {
158                         _dst->recorded_date = strdup(_src->recorded_date);
159                         if(_dst->recorded_date == NULL)
160                         {
161                                 audio_meta_destroy((audio_meta_h)_dst);
162                                 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
163                                 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
164                         }
165                 }
166
167                 if(STRING_VALID(_src->copyright))
168                 {
169                         _dst->copyright = strdup(_src->copyright);
170                         if(_dst->copyright == NULL)
171                         {
172                                 audio_meta_destroy((audio_meta_h)_dst);
173                                 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
174                                 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
175                         }
176                 }
177
178                 if(STRING_VALID(_src->track_num))
179                 {
180                         _dst->track_num = strdup(_src->track_num);
181                         if(_dst->track_num == NULL)
182                         {
183                                 audio_meta_destroy((audio_meta_h)_dst);
184                                 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
185                                 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
186                         }
187                 }
188
189                 _dst->bitrate = _src->bitrate;
190                 _dst->bitpersample = _src->bitpersample;
191                 _dst->samplerate = _src->samplerate;
192                 _dst->channel = _src->channel;
193                 _dst->duration = _src->duration;
194                 _dst->played_count = _src->played_count;
195                 _dst->played_time = _src->played_time;
196                 _dst->played_position = _src->played_position;
197
198                 *dst = (audio_meta_h)_dst;
199
200                 ret = MEDIA_CONTENT_ERROR_NONE;
201         }
202         else
203         {
204                 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
205                 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
206         }
207
208         return ret;
209 }
210
211 int audio_meta_get_media_id(audio_meta_h audio, char **media_id)
212 {
213         int ret = MEDIA_CONTENT_ERROR_NONE;
214         audio_meta_s *_audio = (audio_meta_s*)audio;
215         if(_audio)
216         {
217                 if(STRING_VALID(_audio->media_id))
218                 {
219                         *media_id = strdup(_audio->media_id);
220                         if(*media_id == NULL)
221                         {
222                                 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
223                                 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
224                         }
225                 }
226                 else
227                 {
228                         *media_id = NULL;
229                 }
230                 ret = MEDIA_CONTENT_ERROR_NONE;
231
232         }
233         else
234         {
235                 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
236                 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
237         }
238
239         return ret;
240 }
241
242 int audio_meta_get_album(audio_meta_h audio, char **album_name)
243 {
244         int ret = MEDIA_CONTENT_ERROR_NONE;
245         audio_meta_s *_audio = (audio_meta_s*)audio;
246         if(_audio)
247         {
248                 if(STRING_VALID(_audio->album))
249                 {
250                         *album_name = strdup(_audio->album);
251                         if(*album_name == NULL)
252                         {
253                                 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
254                                 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
255                         }
256                 }
257                 else
258                 {
259                         *album_name = NULL;
260                 }
261                 ret = MEDIA_CONTENT_ERROR_NONE;
262
263         }
264         else
265         {
266                 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
267                 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
268         }
269
270         return ret;
271 }
272
273 int audio_meta_get_artist(audio_meta_h audio, char **artist_name)
274 {
275         int ret = MEDIA_CONTENT_ERROR_NONE;
276         audio_meta_s *_audio = (audio_meta_s*)audio;
277
278         if(_audio)
279         {
280                 if(STRING_VALID(_audio->artist))
281                 {
282                         *artist_name = strdup(_audio->artist);
283                         if(*artist_name == NULL)
284                         {
285                                 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
286                                 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
287                         }
288                 }
289                 else
290                 {
291                         *artist_name = NULL;
292                 }
293                 ret = MEDIA_CONTENT_ERROR_NONE;
294
295         }
296         else
297         {
298                 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
299                 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
300         }
301
302         return ret;
303 }
304
305 int audio_meta_get_album_artist(audio_meta_h audio, char **album_artist_name)
306 {
307         int ret = MEDIA_CONTENT_ERROR_NONE;
308         audio_meta_s *_audio = (audio_meta_s*)audio;
309
310         if(_audio)
311         {
312                 if(STRING_VALID(_audio->album_artist))
313                 {
314                         *album_artist_name = strdup(_audio->album_artist);
315                         if(*album_artist_name == NULL)
316                         {
317                                 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
318                                 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
319                         }
320                 }
321                 else
322                 {
323                         *album_artist_name = NULL;
324                 }
325                 ret = MEDIA_CONTENT_ERROR_NONE;
326
327         }
328         else
329         {
330                 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
331                 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
332         }
333
334         return ret;
335 }
336
337 int audio_meta_get_genre(audio_meta_h audio, char **genre_name)
338 {
339         int ret = MEDIA_CONTENT_ERROR_NONE;
340         audio_meta_s *_audio = (audio_meta_s*)audio;
341         if(_audio)
342         {
343                 if(STRING_VALID(_audio->genre))
344                 {
345                         *genre_name = strdup(_audio->genre);
346                         if(*genre_name == NULL)
347                         {
348                                 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
349                                 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
350                         }
351                 }
352                 else
353                 {
354                         *genre_name = NULL;
355                 }
356
357                 ret = MEDIA_CONTENT_ERROR_NONE;
358         }
359         else
360         {
361                 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
362                 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
363         }
364
365         return ret;
366 }
367
368 int audio_meta_get_composer(audio_meta_h audio, char **composer_name)
369 {
370         int ret = MEDIA_CONTENT_ERROR_NONE;
371         audio_meta_s *_audio = (audio_meta_s*)audio;
372         if(_audio)
373         {
374                 if(STRING_VALID(_audio->composer))
375                 {
376                         *composer_name = strdup(_audio->composer);
377                         if(*composer_name == NULL)
378                         {
379                                 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
380                                 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
381                         }
382                 }
383                 else
384                 {
385                         *composer_name = NULL;
386                 }
387
388                 ret = MEDIA_CONTENT_ERROR_NONE;
389         }
390         else
391         {
392                 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
393                 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
394         }
395
396         return ret;
397 }
398
399 int audio_meta_get_year(audio_meta_h audio, char **year)
400 {
401         int ret = MEDIA_CONTENT_ERROR_NONE;
402         audio_meta_s *_audio = (audio_meta_s*)audio;
403         if(_audio)
404         {
405                 if(STRING_VALID(_audio->year))
406                 {
407                         *year = strdup(_audio->year);
408                         if(*year == NULL)
409                         {
410                                 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
411                                 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
412                         }
413                 }
414                 else
415                 {
416                         *year = NULL;
417                 }
418
419                 ret = MEDIA_CONTENT_ERROR_NONE;
420         }
421         else
422         {
423                 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
424                 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
425         }
426
427         return ret;
428 }
429
430 int audio_meta_get_recorded_date(audio_meta_h audio, char **recorded_date)
431 {
432         int ret = MEDIA_CONTENT_ERROR_NONE;
433         audio_meta_s *_audio = (audio_meta_s*)audio;
434         if(_audio)
435         {
436                 if(STRING_VALID(_audio->recorded_date))
437                 {
438                         *recorded_date = strdup(_audio->recorded_date);
439                         if(*recorded_date == NULL)
440                         {
441                                 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
442                                 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
443                         }
444                 }
445                 else
446                 {
447                         *recorded_date = NULL;
448                 }
449
450                 ret = MEDIA_CONTENT_ERROR_NONE;
451         }
452         else
453         {
454                 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
455                 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
456         }
457
458         return ret;
459 }
460
461 int audio_meta_get_copyright(audio_meta_h audio, char **copyright)
462 {
463         int ret = MEDIA_CONTENT_ERROR_NONE;
464         audio_meta_s *_audio = (audio_meta_s*)audio;
465         if(_audio)
466         {
467                 if(STRING_VALID(_audio->copyright))
468                 {
469                         *copyright = strdup(_audio->copyright);
470                         if(*copyright == NULL)
471                         {
472                                 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
473                                 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
474                         }
475                 }
476                 else
477                 {
478                         *copyright = NULL;
479                 }
480
481                 ret = MEDIA_CONTENT_ERROR_NONE;
482         }
483         else
484         {
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_track_num(audio_meta_h audio, char **track_num)
493 {
494         int ret = MEDIA_CONTENT_ERROR_NONE;
495         audio_meta_s *_audio = (audio_meta_s*)audio;
496         if(_audio)
497         {
498                 if(STRING_VALID(_audio->track_num))
499                 {
500                         *track_num = strdup(_audio->track_num);
501                         if(*track_num == NULL)
502                         {
503                                 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
504                                 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
505                         }
506                 }
507                 else
508                 {
509                         *track_num = NULL;
510                 }
511
512                 ret = MEDIA_CONTENT_ERROR_NONE;
513         }
514         else
515         {
516                 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
517                 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
518         }
519
520         return ret;
521 }
522
523 int audio_meta_get_bit_rate(audio_meta_h audio, int *bit_rate)
524 {
525         int ret = MEDIA_CONTENT_ERROR_NONE;
526         audio_meta_s *_audio = (audio_meta_s*)audio;
527
528         if(_audio && bit_rate)
529         {
530                 *bit_rate = _audio->bitrate;
531                 ret = MEDIA_CONTENT_ERROR_NONE;
532         }
533         else
534         {
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_get_bitpersample(audio_meta_h audio, int *bitpersample)
543 {
544         int ret = MEDIA_CONTENT_ERROR_NONE;
545         audio_meta_s *_audio = (audio_meta_s*)audio;
546
547         if(_audio && bitpersample)
548         {
549                 *bitpersample = _audio->bitpersample;
550                 ret = MEDIA_CONTENT_ERROR_NONE;
551         }
552         else
553         {
554                 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
555                 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
556         }
557
558         return ret;
559 }
560
561 int audio_meta_get_sample_rate(audio_meta_h audio, int *sample_rate)
562 {
563         int ret = MEDIA_CONTENT_ERROR_NONE;
564         audio_meta_s *_audio = (audio_meta_s*)audio;
565
566         if(_audio && sample_rate)
567         {
568                 *sample_rate = _audio->samplerate;
569                 ret = MEDIA_CONTENT_ERROR_NONE;
570         }
571         else
572         {
573                 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
574                 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
575         }
576
577         return ret;
578 }
579
580 int audio_meta_get_channel(audio_meta_h audio, int *channel)
581 {
582         int ret = MEDIA_CONTENT_ERROR_NONE;
583         audio_meta_s *_audio = (audio_meta_s*)audio;
584
585         if(_audio && channel)
586         {
587                 *channel = _audio->channel;
588                 ret = MEDIA_CONTENT_ERROR_NONE;
589         }
590         else
591         {
592                 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
593                 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
594         }
595
596         return ret;
597 }
598
599 int audio_meta_get_duration(audio_meta_h audio, int *duration)
600 {
601         int ret = MEDIA_CONTENT_ERROR_NONE;
602         audio_meta_s *_audio = (audio_meta_s*)audio;
603
604         if(_audio)
605         {
606                 *duration = _audio->duration;
607                 ret = MEDIA_CONTENT_ERROR_NONE;
608         }
609         else
610         {
611                 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
612                 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
613         }
614
615         return ret;
616 }
617
618 int audio_meta_get_played_count(audio_meta_h audio, int *played_count)
619 {
620         int ret = MEDIA_CONTENT_ERROR_NONE;
621         audio_meta_s *_audio = (audio_meta_s*)audio;
622
623         if(_audio)
624         {
625                 *played_count = _audio->played_count;
626                 ret = MEDIA_CONTENT_ERROR_NONE;
627         }
628         else
629         {
630                 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
631                 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
632         }
633
634         return ret;
635 }
636
637 int audio_meta_get_played_time(audio_meta_h audio, time_t* played_time)
638 {
639         int ret = MEDIA_CONTENT_ERROR_NONE;
640         audio_meta_s *_audio = (audio_meta_s*)audio;
641
642         if(_audio)
643         {
644                 *played_time = _audio->played_time;
645                 ret = MEDIA_CONTENT_ERROR_NONE;
646         }
647         else
648         {
649                 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
650                 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
651         }
652
653         return ret;
654 }
655
656 int audio_meta_get_played_position(audio_meta_h audio, int *played_position)
657 {
658         int ret = MEDIA_CONTENT_ERROR_NONE;
659         audio_meta_s *_audio = (audio_meta_s*)audio;
660
661         if(_audio)
662         {
663                 *played_position = _audio->played_position;
664                 ret = MEDIA_CONTENT_ERROR_NONE;
665         }
666         else
667         {
668                 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
669                 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
670         }
671
672         return ret;
673 }
674
675 int audio_meta_set_played_count(audio_meta_h audio, int played_count)
676 {
677         int ret = MEDIA_CONTENT_ERROR_NONE;
678
679         audio_meta_s *_audio = (audio_meta_s*)audio;
680
681         if((_audio != NULL) && (played_count >= 0))
682         {
683                 _audio->played_count = played_count;
684         }
685         else
686         {
687                 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
688                 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
689         }
690
691         return ret;
692 }
693
694 int audio_meta_set_played_time(audio_meta_h audio, time_t played_time)
695 {
696         int ret = MEDIA_CONTENT_ERROR_NONE;
697
698         audio_meta_s *_audio = (audio_meta_s*)audio;
699
700         if((_audio != NULL) && (played_time >= 0))
701         {
702                 _audio->played_time = played_time;
703         }
704         else
705         {
706                 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
707                 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
708         }
709
710         return ret;
711 }
712
713 int audio_meta_set_played_position(audio_meta_h audio, int played_position)
714 {
715         int ret = MEDIA_CONTENT_ERROR_NONE;
716         audio_meta_s *_audio = (audio_meta_s*)audio;
717
718         if((_audio != NULL) && (played_position >= 0))
719         {
720                 _audio->played_position = played_position;
721         }
722         else
723         {
724                 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
725                 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
726         }
727
728         return ret;
729 }
730
731 int audio_meta_update_to_db(audio_meta_h audio)
732 {
733         int ret = MEDIA_CONTENT_ERROR_NONE;
734         audio_meta_s *_audio = (audio_meta_s*)audio;
735         char *sql = NULL;
736
737         if(_audio != NULL && STRING_VALID(_audio->media_id))
738         {
739                 char storage_id[MEDIA_CONTENT_UUID_SIZE+1] = {0,};
740                 memset(storage_id, 0x00, sizeof(storage_id));
741
742                 ret = _media_db_get_storage_id_by_media_id(_audio->media_id, storage_id);
743                 media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
744
745                 sql = sqlite3_mprintf(UPDATE_AV_META_FROM_MEDIA, storage_id, _audio->played_count, _audio->played_time, _audio->played_position, _audio->media_id);
746                 ret = _content_query_sql(sql);
747                 sqlite3_free(sql);
748         }
749         else
750         {
751                 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
752                 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
753         }
754
755         return ret;
756 }