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