Tizen 2.1 base
[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_content.h>
19 #include <media_info_private.h>
20
21
22 int audio_meta_destroy(audio_meta_h audio)
23 {
24         int ret = MEDIA_CONTENT_ERROR_NONE;
25         audio_meta_s *_audio = (audio_meta_s*)audio;
26
27         if(_audio)
28         {
29                 SAFE_FREE(_audio->media_id);
30                 SAFE_FREE(_audio->title);
31                 SAFE_FREE(_audio->album);
32                 SAFE_FREE(_audio->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->genre))
113                 {
114                         _dst->genre = strdup(_src->genre);
115                         if(_dst->genre == 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->composer))
124                 {
125                         _dst->composer = strdup(_src->composer);
126                         if(_dst->composer == 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->year))
135                 {
136                         _dst->year = strdup(_src->year);
137                         if(_dst->year == 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->recorded_date))
146                 {
147                         _dst->recorded_date = strdup(_src->recorded_date);
148                         if(_dst->recorded_date == 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->copyright))
157                 {
158                         _dst->copyright = strdup(_src->copyright);
159                         if(_dst->copyright == 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->track_num))
168                 {
169                         _dst->track_num = strdup(_src->track_num);
170                         if(_dst->track_num == 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                 _dst->bitrate = _src->bitrate;
179                 _dst->samplerate = _src->samplerate;
180                 _dst->channel = _src->channel;
181                 _dst->duration = _src->duration;
182                 _dst->played_count = _src->played_count;
183                 _dst->played_time = _src->played_time;
184                 _dst->played_position = _src->played_position;
185
186                 *dst = (audio_meta_h)_dst;
187
188                 ret = MEDIA_CONTENT_ERROR_NONE;
189         }
190         else
191         {
192                 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
193                 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
194         }
195
196         return ret;
197 }
198
199 int audio_meta_get_media_id(audio_meta_h audio, char **media_id)
200 {
201         int ret = MEDIA_CONTENT_ERROR_NONE;
202         audio_meta_s *_audio = (audio_meta_s*)audio;
203         if(_audio)
204         {
205                 if(STRING_VALID(_audio->media_id))
206                 {
207                         *media_id = strdup(_audio->media_id);
208                         if(*media_id == NULL)
209                         {
210                                 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
211                                 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
212                         }
213                 }
214                 else
215                 {
216                         *media_id = NULL;
217                 }
218                 ret = MEDIA_CONTENT_ERROR_NONE;
219
220         }
221         else
222         {
223                 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
224                 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
225         }
226
227         return ret;
228 }
229
230 int audio_meta_get_title(audio_meta_h audio, char **title)
231 {
232         int ret = MEDIA_CONTENT_ERROR_NONE;
233         audio_meta_s *_audio = (audio_meta_s*)audio;
234         if(_audio)
235         {
236                 if(STRING_VALID(_audio->title))
237                 {
238                         *title = strdup(_audio->title);
239                         if(*title == NULL)
240                         {
241                                 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
242                                 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
243                         }
244                 }
245                 else
246                 {
247                         *title = NULL;
248                 }
249                 ret = MEDIA_CONTENT_ERROR_NONE;
250
251         }
252         else
253         {
254                 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
255                 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
256         }
257
258         return ret;
259 }
260
261 int audio_meta_get_album(audio_meta_h audio, char **album_name)
262 {
263         int ret = MEDIA_CONTENT_ERROR_NONE;
264         audio_meta_s *_audio = (audio_meta_s*)audio;
265         if(_audio)
266         {
267                 if(STRING_VALID(_audio->album))
268                 {
269                         *album_name = strdup(_audio->album);
270                         if(*album_name == NULL)
271                         {
272                                 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
273                                 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
274                         }
275                 }
276                 else
277                 {
278                         *album_name = NULL;
279                 }
280                 ret = MEDIA_CONTENT_ERROR_NONE;
281
282         }
283         else
284         {
285                 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
286                 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
287         }
288
289         return ret;
290 }
291
292 int audio_meta_get_artist(audio_meta_h audio, char **artist_name)
293 {
294         int ret = MEDIA_CONTENT_ERROR_NONE;
295         audio_meta_s *_audio = (audio_meta_s*)audio;
296
297         if(_audio)
298         {
299                 if(STRING_VALID(_audio->artist))
300                 {
301                         *artist_name = strdup(_audio->artist);
302                         if(*artist_name == NULL)
303                         {
304                                 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
305                                 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
306                         }
307                 }
308                 else
309                 {
310                         *artist_name = NULL;
311                 }
312                 ret = MEDIA_CONTENT_ERROR_NONE;
313
314         }
315         else
316         {
317                 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
318                 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
319         }
320
321         return ret;
322 }
323
324 int audio_meta_get_genre(audio_meta_h audio, char **genre_name)
325 {
326         int ret = MEDIA_CONTENT_ERROR_NONE;
327         audio_meta_s *_audio = (audio_meta_s*)audio;
328         if(_audio)
329         {
330                 if(STRING_VALID(_audio->genre))
331                 {
332                         *genre_name = strdup(_audio->genre);
333                         if(*genre_name == NULL)
334                         {
335                                 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
336                                 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
337                         }
338                 }
339                 else
340                 {
341                         *genre_name = NULL;
342                 }
343
344                 ret = MEDIA_CONTENT_ERROR_NONE;
345         }
346         else
347         {
348                 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
349                 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
350         }
351
352         return ret;
353 }
354
355 int audio_meta_get_composer(audio_meta_h audio, char **composer_name)
356 {
357         int ret = MEDIA_CONTENT_ERROR_NONE;
358         audio_meta_s *_audio = (audio_meta_s*)audio;
359         if(_audio)
360         {
361                 if(STRING_VALID(_audio->composer))
362                 {
363                         *composer_name = strdup(_audio->composer);
364                         if(*composer_name == NULL)
365                         {
366                                 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
367                                 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
368                         }
369                 }
370                 else
371                 {
372                         *composer_name = NULL;
373                 }
374
375                 ret = MEDIA_CONTENT_ERROR_NONE;
376         }
377         else
378         {
379                 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
380                 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
381         }
382
383         return ret;
384 }
385
386 int audio_meta_get_year(audio_meta_h audio, char **year)
387 {
388         int ret = MEDIA_CONTENT_ERROR_NONE;
389         audio_meta_s *_audio = (audio_meta_s*)audio;
390         if(_audio)
391         {
392                 if(STRING_VALID(_audio->year))
393                 {
394                         *year = strdup(_audio->year);
395                         if(*year == NULL)
396                         {
397                                 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
398                                 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
399                         }
400                 }
401                 else
402                 {
403                         *year = NULL;
404                 }
405
406                 ret = MEDIA_CONTENT_ERROR_NONE;
407         }
408         else
409         {
410                 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
411                 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
412         }
413
414         return ret;
415 }
416
417 int audio_meta_get_recorded_date(audio_meta_h audio, char **recorded_date)
418 {
419         int ret = MEDIA_CONTENT_ERROR_NONE;
420         audio_meta_s *_audio = (audio_meta_s*)audio;
421         if(_audio)
422         {
423                 if(STRING_VALID(_audio->recorded_date))
424                 {
425                         *recorded_date = strdup(_audio->recorded_date);
426                         if(*recorded_date == NULL)
427                         {
428                                 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
429                                 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
430                         }
431                 }
432                 else
433                 {
434                         *recorded_date = NULL;
435                 }
436
437                 ret = MEDIA_CONTENT_ERROR_NONE;
438         }
439         else
440         {
441                 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
442                 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
443         }
444
445         return ret;
446 }
447
448 int audio_meta_get_copyright(audio_meta_h audio, char **copyright)
449 {
450         int ret = MEDIA_CONTENT_ERROR_NONE;
451         audio_meta_s *_audio = (audio_meta_s*)audio;
452         if(_audio)
453         {
454                 if(STRING_VALID(_audio->copyright))
455                 {
456                         *copyright = strdup(_audio->copyright);
457                         if(*copyright == NULL)
458                         {
459                                 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
460                                 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
461                         }
462                 }
463                 else
464                 {
465                         *copyright = NULL;
466                 }
467
468                 ret = MEDIA_CONTENT_ERROR_NONE;
469         }
470         else
471         {
472                 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
473                 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
474         }
475
476         return ret;
477 }
478
479 int audio_meta_get_track_num(audio_meta_h audio, char **track_num)
480 {
481         int ret = MEDIA_CONTENT_ERROR_NONE;
482         audio_meta_s *_audio = (audio_meta_s*)audio;
483         if(_audio)
484         {
485                 if(STRING_VALID(_audio->track_num))
486                 {
487                         *track_num = strdup(_audio->track_num);
488                         if(*track_num == NULL)
489                         {
490                                 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
491                                 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
492                         }
493                 }
494                 else
495                 {
496                         *track_num = NULL;
497                 }
498
499                 ret = MEDIA_CONTENT_ERROR_NONE;
500         }
501         else
502         {
503                 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
504                 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
505         }
506
507         return ret;
508 }
509
510 int audio_meta_get_bit_rate(audio_meta_h audio, int *bit_rate)
511 {
512         int ret = MEDIA_CONTENT_ERROR_NONE;
513         audio_meta_s *_audio = (audio_meta_s*)audio;
514
515         if(_audio && bit_rate)
516         {
517                 *bit_rate = _audio->bitrate;
518                 ret = MEDIA_CONTENT_ERROR_NONE;
519         }
520         else
521         {
522                 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
523                 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
524         }
525
526         return ret;
527 }
528
529 int audio_meta_get_sample_rate(audio_meta_h audio, int *sample_rate)
530 {
531         int ret = MEDIA_CONTENT_ERROR_NONE;
532         audio_meta_s *_audio = (audio_meta_s*)audio;
533
534         if(_audio && sample_rate)
535         {
536                 *sample_rate = _audio->samplerate;
537                 ret = MEDIA_CONTENT_ERROR_NONE;
538         }
539         else
540         {
541                 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
542                 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
543         }
544
545         return ret;
546 }
547
548 int audio_meta_get_channel(audio_meta_h audio, int *channel)
549 {
550         int ret = MEDIA_CONTENT_ERROR_NONE;
551         audio_meta_s *_audio = (audio_meta_s*)audio;
552
553         if(_audio && channel)
554         {
555                 *channel = _audio->channel;
556                 ret = MEDIA_CONTENT_ERROR_NONE;
557         }
558         else
559         {
560                 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
561                 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
562         }
563
564         return ret;
565 }
566
567 int audio_meta_get_duration(audio_meta_h audio, int *duration)
568 {
569         int ret = MEDIA_CONTENT_ERROR_NONE;
570         audio_meta_s *_audio = (audio_meta_s*)audio;
571
572         if(_audio)
573         {
574                 *duration = _audio->duration;
575                 ret = MEDIA_CONTENT_ERROR_NONE;
576         }
577         else
578         {
579                 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
580                 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
581         }
582
583         return ret;
584 }
585
586 int audio_meta_get_played_count(audio_meta_h audio, int *played_count)
587 {
588         int ret = MEDIA_CONTENT_ERROR_NONE;
589         audio_meta_s *_audio = (audio_meta_s*)audio;
590
591         if(_audio)
592         {
593                 *played_count = _audio->played_count;
594                 ret = MEDIA_CONTENT_ERROR_NONE;
595         }
596         else
597         {
598                 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
599                 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
600         }
601
602         return ret;
603 }
604
605 int audio_meta_get_played_time(audio_meta_h audio, time_t* played_time)
606 {
607         int ret = MEDIA_CONTENT_ERROR_NONE;
608         audio_meta_s *_audio = (audio_meta_s*)audio;
609
610         if(_audio)
611         {
612                 *played_time = _audio->played_time;
613                 ret = MEDIA_CONTENT_ERROR_NONE;
614         }
615         else
616         {
617                 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
618                 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
619         }
620
621         return ret;
622 }
623
624 int audio_meta_get_played_position(audio_meta_h audio, int *played_position)
625 {
626         int ret = MEDIA_CONTENT_ERROR_NONE;
627         audio_meta_s *_audio = (audio_meta_s*)audio;
628
629         if(_audio)
630         {
631                 *played_position = _audio->played_position;
632                 ret = MEDIA_CONTENT_ERROR_NONE;
633         }
634         else
635         {
636                 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
637                 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
638         }
639
640         return ret;
641 }
642
643 int audio_meta_set_played_count(audio_meta_h audio, int played_count)
644 {
645         int ret = MEDIA_CONTENT_ERROR_NONE;
646
647         audio_meta_s *_audio = (audio_meta_s*)audio;
648
649         if((_audio != NULL) && (played_count >= 0))
650         {
651                 _audio->played_count = played_count;
652         }
653         else
654         {
655                 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
656                 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
657         }
658
659         return ret;
660 }
661
662 int audio_meta_set_played_time(audio_meta_h audio, time_t played_time)
663 {
664         int ret = MEDIA_CONTENT_ERROR_NONE;
665
666         audio_meta_s *_audio = (audio_meta_s*)audio;
667
668         if((_audio != NULL) && (played_time >= 0))
669         {
670                 _audio->played_time = played_time;
671         }
672         else
673         {
674                 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
675                 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
676         }
677
678         return ret;
679 }
680
681 int audio_meta_set_played_position(audio_meta_h audio, int played_position)
682 {
683         int ret = MEDIA_CONTENT_ERROR_NONE;
684         audio_meta_s *_audio = (audio_meta_s*)audio;
685
686         if((_audio != NULL) && (played_position >= 0))
687         {
688                 _audio->played_position = played_position;
689         }
690         else
691         {
692                 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
693                 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
694         }
695
696         return ret;
697 }
698
699 int audio_meta_update_to_db(audio_meta_h audio)
700 {
701         int ret = MEDIA_CONTENT_ERROR_NONE;
702         audio_meta_s *_audio = (audio_meta_s*)audio;
703         char *sql = NULL;
704
705         if(_audio != NULL && STRING_VALID(_audio->media_id))
706         {
707                 sql = sqlite3_mprintf(UPDATE_AV_META_FROM_MEDIA, _audio->played_count, _audio->played_time, _audio->played_position, _audio->media_id);
708                 ret = _content_query_sql(sql);
709                 sqlite3_free(sql);
710         }
711         else
712         {
713                 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
714                 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
715         }
716
717         return ret;
718 }