update bug patch
[framework/api/media-content.git] / src / media_info.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-thumbnail.h>
20 #include <media_info_private.h>
21 #include <media_util_private.h>
22 #include <media-svc.h>
23 #include <media-util-register.h>
24 #include <media-util-err.h>
25
26
27 static int __media_info_get_media_info_from_db(char *path, media_info_h media);
28 static void __media_info_thumbnail_completed_cb(int error, const char *path, void *user_data);
29
30 static int __media_info_get_media_info_from_db(char *path, media_info_h media)
31 {
32         int ret = MEDIA_CONTENT_ERROR_NONE;
33         sqlite3_stmt *stmt = NULL;
34         char *select_query = NULL;
35         media_info_s *_media = (media_info_s*)media;
36
37         if(_media == NULL)
38         {
39                 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
40                 return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
41         }
42
43         select_query = sqlite3_mprintf(SELECT_MEDIA_BY_PATH, path);
44
45         ret = _content_query_prepare(&stmt, select_query, NULL, NULL);
46         sqlite3_free(select_query);
47         media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
48
49         if(sqlite3_step(stmt) == SQLITE_ROW)
50         {
51                 _media_info_item_get_detail(stmt, (media_info_h)_media);
52                 media_content_debug("New Media ID: %s", _media->media_id);
53         } else {
54                 media_content_debug("There's no media!!");
55         }
56 /*
57         while(sqlite3_step(stmt) == SQLITE_ROW)
58         {
59                 _media_info_item_get_detail(stmt, (media_info_h)_media);
60                 media_content_debug("New Media ID: %s", _media->media_id);
61         }
62 */
63         SQLITE3_FINALIZE(stmt);
64
65         return ret;
66 }
67
68 static void __media_info_thumbnail_completed_cb(int error, const char *path, void *user_data)
69 {
70         int error_value = MEDIA_CONTENT_ERROR_NONE;
71
72         media_thumbnail_cb_s *_thumb_cb = (media_thumbnail_cb_s *)user_data;
73         media_info_s *media = NULL;
74
75         if(_thumb_cb != NULL)
76         {
77                 media = _thumb_cb->handle;
78                 if((media != NULL) && STRING_VALID(path))
79                 {
80                         SAFE_FREE(media->thumbnail_path);
81                         media->thumbnail_path = strdup(path);
82                 }
83
84                 media_content_debug("error [%d], thumbnail_path [%s]", error, path);
85                 error_value = _content_error_capi(MEDIA_THUMBNAIL_TYPE, error);
86                 _thumb_cb->thumbnail_completed_cb(error_value, path, _thumb_cb->user_data);
87         }
88
89         SAFE_FREE(_thumb_cb);
90
91         return;
92 }
93
94 void _media_info_item_get_detail(sqlite3_stmt* stmt, media_info_h media)
95 {
96 //#define MEDIA_INFO_ITEM "media_uuid, path, file_name, media_type, mime_type, size, added_time, modified_time, thumbnail_path, description,
97 //                                                      rating, favourite, author, provider, content_name, category, location_tag, age_rating, keyword, is_drm, storage_type, longitude, latitude, altitude, width, height, datetaken, orientation, title, album, artist, genre, composer, year, recorded_date, copyright, track_num, bitrate, duration, played_count, last_played_time, last_played_position, samplerate, channel"
98
99         media_info_s *_media = (media_info_s*)media;
100
101         if(STRING_VALID((const char *)sqlite3_column_text(stmt, 0)))
102                 _media->media_id = strdup((const char *)sqlite3_column_text(stmt, 0));
103
104         if(STRING_VALID((const char *)sqlite3_column_text(stmt, 1)))
105                 _media->file_path = strdup((const char *)sqlite3_column_text(stmt, 1));
106
107         if(STRING_VALID((const char *)sqlite3_column_text(stmt, 2)))
108                 _media->display_name = strdup((const char *)sqlite3_column_text(stmt, 2));
109
110         _media->media_type = (int)sqlite3_column_int(stmt, 3);
111
112         if(STRING_VALID((const char *)sqlite3_column_text(stmt, 4)))
113                 _media->mime_type = strdup((const char *)sqlite3_column_text(stmt, 4));
114
115         _media->size = (unsigned long long)sqlite3_column_int64(stmt, 5);
116
117         _media->added_time = (int)sqlite3_column_int(stmt, 6);
118
119         _media->modified_time = (int)sqlite3_column_int(stmt, 7);
120
121         if(STRING_VALID((const char *)sqlite3_column_text(stmt, 8)))
122                 _media->thumbnail_path= strdup((const char *)sqlite3_column_text(stmt, 8));
123
124         if(STRING_VALID((const char *)sqlite3_column_text(stmt, 9)))
125                 _media->description = strdup((const char *)sqlite3_column_text(stmt, 9));
126
127         _media->rating = (int)sqlite3_column_int(stmt,10);
128
129         _media->favourite = (int)sqlite3_column_int(stmt, 11);
130
131         if(STRING_VALID((const char *)sqlite3_column_text(stmt, 12)))
132                 _media->author = strdup((const char *)sqlite3_column_text(stmt, 12));
133
134         if(STRING_VALID((const char *)sqlite3_column_text(stmt, 13)))
135                 _media->provider = strdup((const char *)sqlite3_column_text(stmt, 13));
136
137         if(STRING_VALID((const char *)sqlite3_column_text(stmt, 14)))
138                 _media->content_name = strdup((const char *)sqlite3_column_text(stmt, 14));
139
140         if(STRING_VALID((const char *)sqlite3_column_text(stmt, 15)))
141                 _media->category = strdup((const char *)sqlite3_column_text(stmt, 15));
142
143         if(STRING_VALID((const char *)sqlite3_column_text(stmt, 16)))
144                 _media->location_tag = strdup((const char *)sqlite3_column_text(stmt, 16));
145
146         if(STRING_VALID((const char *)sqlite3_column_text(stmt, 17)))
147                 _media->age_rating = strdup((const char *)sqlite3_column_text(stmt, 17));
148
149         if(STRING_VALID((const char *)sqlite3_column_text(stmt, 18)))
150                 _media->keyword = strdup((const char *)sqlite3_column_text(stmt, 18));
151
152         _media->is_drm = (int)sqlite3_column_int(stmt, 19);
153
154         _media->storage_type = (int)sqlite3_column_int(stmt, 20);
155
156         _media->longitude = (double)sqlite3_column_double(stmt, 21);
157         _media->latitude = (double)sqlite3_column_double(stmt, 22);
158         _media->altitude = (double)sqlite3_column_double(stmt, 23);
159
160         if(_media->media_type == MEDIA_CONTENT_TYPE_IMAGE) {
161                 _media->image_meta = (image_meta_s *)calloc(1, sizeof(image_meta_s));
162                 if(_media->image_meta) {
163                         if(STRING_VALID(_media->media_id))
164                                 _media->image_meta->media_id = strdup(_media->media_id);
165
166                         _media->image_meta->width = sqlite3_column_int(stmt, 24);
167                         _media->image_meta->height = sqlite3_column_int(stmt, 25);
168
169                         if(STRING_VALID((const char *)sqlite3_column_text(stmt, 26)))
170                                 _media->image_meta->date_taken = strdup((const char *)sqlite3_column_text(stmt, 26));
171                 
172                         _media->image_meta->orientation = sqlite3_column_int(stmt, 27);
173                 }
174
175         } else if(_media->media_type == MEDIA_CONTENT_TYPE_VIDEO) {
176                 _media->video_meta = (video_meta_s *)calloc(1, sizeof(video_meta_s));
177                 if(_media->video_meta) {
178                         if(STRING_VALID(_media->media_id))
179                                 _media->video_meta->media_id = strdup(_media->media_id);
180
181                         if(STRING_VALID((const char *)sqlite3_column_text(stmt, 28)))
182                                 _media->video_meta->title = strdup((const char *)sqlite3_column_text(stmt, 28));
183
184                         if(STRING_VALID((const char *)sqlite3_column_text(stmt, 29)))
185                                 _media->video_meta->album = strdup((const char *)sqlite3_column_text(stmt, 29));
186
187                         if(STRING_VALID((const char *)sqlite3_column_text(stmt, 30)))
188                                 _media->video_meta->artist = strdup((const char *)sqlite3_column_text(stmt, 30));
189
190                         if(STRING_VALID((const char *)sqlite3_column_text(stmt, 31)))
191                                 _media->video_meta->genre = strdup((const char *)sqlite3_column_text(stmt, 31));
192
193                         if(STRING_VALID((const char *)sqlite3_column_text(stmt, 32)))
194                                 _media->video_meta->composer = strdup((const char *)sqlite3_column_text(stmt, 32));
195
196                         if(STRING_VALID((const char *)sqlite3_column_text(stmt, 33)))
197                                 _media->video_meta->year = strdup((const char *)sqlite3_column_text(stmt, 33));
198
199                         if(STRING_VALID((const char *)sqlite3_column_text(stmt, 34)))
200                                 _media->video_meta->recorded_date = strdup((const char *)sqlite3_column_text(stmt, 34));
201
202                         if(STRING_VALID((const char *)sqlite3_column_text(stmt, 35)))
203                                 _media->video_meta->copyright = strdup((const char *)sqlite3_column_text(stmt, 35));
204
205                         if(STRING_VALID((const char *)sqlite3_column_text(stmt, 36)))
206                                 _media->video_meta->track_num = strdup((const char *)sqlite3_column_text(stmt, 36));
207
208                         _media->video_meta->bitrate = sqlite3_column_int(stmt, 37);
209                         _media->video_meta->duration = sqlite3_column_int(stmt, 38);
210                         _media->video_meta->played_count = sqlite3_column_int(stmt, 39);
211                         _media->video_meta->played_time = sqlite3_column_int(stmt, 40);
212                         _media->video_meta->played_position = sqlite3_column_int(stmt, 41);
213                         _media->video_meta->width = sqlite3_column_int(stmt, 24);
214                         _media->video_meta->height = sqlite3_column_int(stmt, 25);
215                 }
216
217         }
218         else if((_media->media_type == MEDIA_CONTENT_TYPE_MUSIC) || (_media->media_type == MEDIA_CONTENT_TYPE_SOUND)) {
219                 _media->audio_meta = (audio_meta_s *)calloc(1, sizeof(audio_meta_s));
220                 if(_media->audio_meta) {
221                         if(STRING_VALID(_media->media_id))
222                                 _media->audio_meta->media_id = strdup(_media->media_id);
223
224                         if(STRING_VALID((const char *)sqlite3_column_text(stmt, 28)))
225                                 _media->audio_meta->title = strdup((const char *)sqlite3_column_text(stmt, 28));
226
227                         if(STRING_VALID((const char *)sqlite3_column_text(stmt, 29)))
228                                 _media->audio_meta->album = strdup((const char *)sqlite3_column_text(stmt, 29));
229
230                         if(STRING_VALID((const char *)sqlite3_column_text(stmt, 30)))
231                                 _media->audio_meta->artist = strdup((const char *)sqlite3_column_text(stmt, 30));
232
233                         if(STRING_VALID((const char *)sqlite3_column_text(stmt, 31)))
234                                 _media->audio_meta->genre = strdup((const char *)sqlite3_column_text(stmt, 31));
235
236                         if(STRING_VALID((const char *)sqlite3_column_text(stmt, 32)))
237                                 _media->audio_meta->composer = strdup((const char *)sqlite3_column_text(stmt, 32));
238
239                         if(STRING_VALID((const char *)sqlite3_column_text(stmt, 33)))
240                                 _media->audio_meta->year = strdup((const char *)sqlite3_column_text(stmt, 33));
241
242                         if(STRING_VALID((const char *)sqlite3_column_text(stmt, 34)))
243                                 _media->audio_meta->recorded_date = strdup((const char *)sqlite3_column_text(stmt, 34));
244
245                         if(STRING_VALID((const char *)sqlite3_column_text(stmt, 35)))
246                                 _media->audio_meta->copyright = strdup((const char *)sqlite3_column_text(stmt, 35));
247
248                         if(STRING_VALID((const char *)sqlite3_column_text(stmt, 36)))
249                                 _media->audio_meta->track_num = strdup((const char *)sqlite3_column_text(stmt, 36));
250
251                         _media->audio_meta->bitrate = sqlite3_column_int(stmt, 37);
252                         _media->audio_meta->duration = sqlite3_column_int(stmt, 38);
253                         _media->audio_meta->played_count = sqlite3_column_int(stmt, 39);
254                         _media->audio_meta->played_time = sqlite3_column_int(stmt, 40);
255                         _media->audio_meta->played_position = sqlite3_column_int(stmt, 41);
256                         _media->audio_meta->samplerate = sqlite3_column_int(stmt, 42);
257                         _media->audio_meta->channel = sqlite3_column_int(stmt, 43);
258                 }
259
260         }
261 }
262
263 int media_info_insert_to_db (const char *path, media_info_h *info)
264 {
265         int ret = MEDIA_CONTENT_ERROR_NONE;
266
267         if(!STRING_VALID(path))
268         {
269                 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
270                 return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
271         }
272
273         if(info == NULL)
274         {
275                 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
276                 return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
277         }
278
279         media_content_debug("Register: %s", path);
280         ret = media_file_register(path);
281         if(ret != MS_MEDIA_ERR_NONE)
282         {
283                 media_content_error("media_file_register failed");
284                 return _content_error_capi(MEDIA_REGISTER_TYPE, ret);
285         }
286
287         media_info_s *_media = (media_info_s*)calloc(1, sizeof(media_info_s));
288         if(_media == NULL)
289         {
290                 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
291                 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
292         }
293
294         _media->file_path = strdup(path);
295         if(_media->file_path == NULL)
296         {
297                 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
298                 SAFE_FREE(_media);
299                 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
300         }
301
302         ret = __media_info_get_media_info_from_db(_media->file_path, (media_info_h)_media);
303
304         *info = (media_info_h)_media;
305
306         return ret;
307 }
308
309 int media_info_delete_from_db(const char *media_id)
310 {
311         int ret = MEDIA_CONTENT_ERROR_NONE;
312
313         char *query_string = NULL;
314
315         if(!STRING_VALID(media_id))
316         {
317                 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
318                 return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
319         }
320
321         query_string = sqlite3_mprintf(DELETE_MEDIA_FROM_MEDIA, media_id);
322
323         ret = _content_query_sql(query_string);
324
325         sqlite3_free(query_string);
326
327         return ret;
328 }
329
330 int media_info_destroy(media_info_h media)
331 {
332         int ret = MEDIA_CONTENT_ERROR_NONE;
333         media_info_s *_media = (media_info_s*)media;
334
335         if(_media)
336         {
337                 SAFE_FREE(_media->media_id);
338                 SAFE_FREE(_media->file_path);
339                 SAFE_FREE(_media->display_name);
340                 SAFE_FREE(_media->mime_type);
341                 SAFE_FREE(_media->thumbnail_path);
342                 SAFE_FREE(_media->description);
343                 SAFE_FREE(_media->author);
344                 SAFE_FREE(_media->provider);
345                 SAFE_FREE(_media->content_name);
346                 SAFE_FREE(_media->category);
347                 SAFE_FREE(_media->location_tag);
348                 SAFE_FREE(_media->age_rating);
349                 SAFE_FREE(_media->keyword);
350
351                 if(_media->image_meta) {
352                         SAFE_FREE(_media->image_meta->media_id);
353                         SAFE_FREE(_media->image_meta->date_taken);
354
355                         SAFE_FREE(_media->image_meta);
356                 } else if(_media->video_meta) {
357                         SAFE_FREE(_media->video_meta->media_id);
358                         SAFE_FREE(_media->video_meta->title);
359                         SAFE_FREE(_media->video_meta->album);
360                         SAFE_FREE(_media->video_meta->artist);
361                         SAFE_FREE(_media->video_meta->genre);
362                         SAFE_FREE(_media->video_meta->composer);
363                         SAFE_FREE(_media->video_meta->year);
364                         SAFE_FREE(_media->video_meta->recorded_date);
365                         SAFE_FREE(_media->video_meta->copyright);
366                         SAFE_FREE(_media->video_meta->track_num);
367
368                         SAFE_FREE(_media->video_meta);
369                 } else if(_media->audio_meta) {
370                         SAFE_FREE(_media->audio_meta->media_id);
371                         SAFE_FREE(_media->audio_meta->title);
372                         SAFE_FREE(_media->audio_meta->album);
373                         SAFE_FREE(_media->audio_meta->artist);
374                         SAFE_FREE(_media->audio_meta->genre);
375                         SAFE_FREE(_media->audio_meta->composer);
376                         SAFE_FREE(_media->audio_meta->year);
377                         SAFE_FREE(_media->audio_meta->recorded_date);
378                         SAFE_FREE(_media->audio_meta->copyright);
379                         SAFE_FREE(_media->audio_meta->track_num);
380
381                         SAFE_FREE(_media->audio_meta);
382                 }
383
384                 SAFE_FREE(_media);
385
386                 ret = MEDIA_CONTENT_ERROR_NONE;
387         }
388         else
389         {
390                 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
391                 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
392         }
393
394         return ret;
395 }
396
397 int media_info_clone(media_info_h *dst, media_info_h src)
398 {
399         int ret = MEDIA_CONTENT_ERROR_NONE;
400         media_info_s *_src = (media_info_s*)src;
401
402
403         if(_src != NULL)
404         {
405                 media_info_s *_dst = (media_info_s*)calloc(1, sizeof(media_info_s));
406
407                 if(_dst == NULL)
408                 {
409                         media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
410                         return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
411                 }
412
413                 if(STRING_VALID(_src->media_id))
414                 {
415                         _dst->media_id = strdup(_src->media_id);
416                         if(_dst->media_id == NULL)
417                         {
418                                 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
419                                 media_info_destroy((media_info_h)_dst);
420                                 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
421                         }
422                 }
423                 if(STRING_VALID(_src->file_path))
424                 {
425                         _dst->file_path = strdup(_src->file_path);
426                         if(_dst->file_path == NULL)
427                         {
428                                 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
429                                 media_info_destroy((media_info_h)_dst);
430                                 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
431                         }
432                 }
433                 if(STRING_VALID(_src->display_name))
434                 {
435                         _dst->display_name = strdup(_src->display_name);
436                         if(_dst->display_name == NULL)
437                         {
438                                 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
439                                 media_info_destroy((media_info_h)_dst);
440                                 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
441                         }
442                 }
443                 if(STRING_VALID(_src->mime_type))
444                 {
445                         _dst->mime_type = strdup(_src->mime_type);
446                         if(_dst->mime_type == NULL)
447                         {
448                                 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
449                                 media_info_destroy((media_info_h)_dst);
450                                 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
451                         }
452                 }
453                 if(STRING_VALID(_src->thumbnail_path))
454                 {
455                         _dst->thumbnail_path = strdup(_src->thumbnail_path);
456                         if(_dst->thumbnail_path == NULL)
457                         {
458                                 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
459                                 media_info_destroy((media_info_h)_dst);
460                                 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
461                         }
462                 }
463                 if(STRING_VALID(_src->description))
464                 {
465                         _dst->description = strdup(_src->description);
466                         if(_dst->description == NULL)
467                         {
468                                 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
469                                 media_info_destroy((media_info_h)_dst);
470                                 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
471                         }
472                 }
473                 if(STRING_VALID(_src->author))
474                 {
475                         _dst->author = strdup(_src->author);
476                         if(_dst->author == NULL)
477                         {
478                                 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
479                                 media_info_destroy((media_info_h)_dst);
480                                 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
481                         }
482                 }
483                 if(STRING_VALID(_src->provider))
484                 {
485                         _dst->provider = strdup(_src->provider);
486                         if(_dst->provider == NULL)
487                         {
488                                 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
489                                 media_info_destroy((media_info_h)_dst);
490                                 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
491                         }
492                 }
493                 if(STRING_VALID(_src->content_name))
494                 {
495                         _dst->content_name = strdup(_src->content_name);
496                         if(_dst->content_name == NULL)
497                         {
498                                 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
499                                 media_info_destroy((media_info_h)_dst);
500                                 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
501                         }
502                 }
503                 if(STRING_VALID(_src->category))
504                 {
505                         _dst->category = strdup(_src->category);
506                         if(_dst->category == NULL)
507                         {
508                                 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
509                                 media_info_destroy((media_info_h)_dst);
510                                 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
511                         }
512                 }
513                 if(STRING_VALID(_src->location_tag))
514                 {
515                         _dst->location_tag = strdup(_src->location_tag);
516                         if(_dst->location_tag == NULL)
517                         {
518                                 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
519                                 media_info_destroy((media_info_h)_dst);
520                                 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
521                         }
522                 }
523                 if(STRING_VALID(_src->age_rating))
524                 {
525                         _dst->age_rating = strdup(_src->age_rating);
526                         if(_dst->age_rating == NULL)
527                         {
528                                 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
529                                 media_info_destroy((media_info_h)_dst);
530                                 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
531                         }
532                 }
533                 if(STRING_VALID(_src->keyword))
534                 {
535                         _dst->keyword = strdup(_src->keyword);
536                         if(_dst->keyword == NULL)
537                         {
538                                 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
539                                 media_info_destroy((media_info_h)_dst);
540                                 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
541                         }
542                 }
543
544                 _dst->media_type = _src->media_type;
545                 _dst->size = _src->size;
546                 _dst->added_time = _src->added_time;
547                 _dst->modified_time = _src->modified_time;
548                 _dst->longitude = _src->longitude;
549                 _dst->latitude = _src->latitude;
550                 _dst->altitude = _src->altitude;
551                 _dst->rating = _src->rating;
552                 _dst->favourite = _src->favourite;
553                 _dst->is_drm = _src->is_drm;
554
555                 if(_src->media_type == MEDIA_CONTENT_TYPE_IMAGE && _src->image_meta) {
556                         _dst->image_meta = (image_meta_s *)calloc(1, sizeof(image_meta_s));
557                         if(_dst->image_meta == NULL)
558                         {
559                                 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
560                                 media_info_destroy((media_info_h)_dst);
561                                 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
562                         }
563
564                         if(STRING_VALID(_src->image_meta->media_id))
565                         {
566                                 _dst->image_meta->media_id = strdup(_src->image_meta->media_id);
567                                 if(_dst->image_meta->media_id == NULL)
568                                 {
569                                         media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
570                                         media_info_destroy((media_info_h)_dst);
571                                         return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
572                                 }
573                         }
574                         if(STRING_VALID(_src->image_meta->date_taken))
575                         {
576                                 _dst->image_meta->date_taken = strdup(_src->image_meta->date_taken);
577                                 if(_dst->image_meta->date_taken == NULL)
578                                 {
579                                         media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
580                                         media_info_destroy((media_info_h)_dst);
581                                         return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
582                                 }
583                         }
584
585                         _dst->image_meta->width = _src->image_meta->width;
586                         _dst->image_meta->height = _src->image_meta->height;
587                         _dst->image_meta->orientation = _src->image_meta->orientation;
588
589                 } else if(_src->media_type == MEDIA_CONTENT_TYPE_VIDEO && _src->video_meta) {
590                         _dst->video_meta = (video_meta_s *)calloc(1, sizeof(video_meta_s));
591                         if(_dst->video_meta == NULL)
592                         {
593                                 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
594                                 media_info_destroy((media_info_h)_dst);
595                                 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
596                         }
597
598                         if(STRING_VALID(_src->video_meta->media_id))
599                         {
600                                 _dst->video_meta->media_id = strdup(_src->video_meta->media_id);
601                                 if(_dst->video_meta->media_id == NULL)
602                                 {
603                                         media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
604                                         media_info_destroy((media_info_h)_dst);
605                                         return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
606                                 }
607                         }
608                         if(STRING_VALID(_src->video_meta->title))
609                         {
610                                 _dst->video_meta->title = strdup(_src->video_meta->title);
611                                 if(_dst->video_meta->title == NULL)
612                                 {
613                                         media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
614                                         media_info_destroy((media_info_h)_dst);
615                                         return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
616                                 }
617                         }
618                         if(STRING_VALID(_src->video_meta->album))
619                         {
620                                 _dst->video_meta->album = strdup(_src->video_meta->album);
621                                 if(_dst->video_meta->album == NULL)
622                                 {
623                                         media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
624                                         media_info_destroy((media_info_h)_dst);
625                                         return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
626                                 }
627                         }
628                         if(STRING_VALID(_src->video_meta->artist))
629                         {
630                                 _dst->video_meta->artist = strdup(_src->video_meta->artist);
631                                 if(_dst->video_meta->artist == NULL)
632                                 {
633                                         media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
634                                         media_info_destroy((media_info_h)_dst);
635                                         return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
636                                 }
637                         }
638                         if(STRING_VALID(_src->video_meta->genre))
639                         {
640                                 _dst->video_meta->genre = strdup(_src->video_meta->genre);
641                                 if(_dst->video_meta->genre == NULL)
642                                 {
643                                         media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
644                                         media_info_destroy((media_info_h)_dst);
645                                         return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
646                                 }
647                         }
648                         if(STRING_VALID(_src->video_meta->composer))
649                         {
650                                 _dst->video_meta->composer = strdup(_src->video_meta->composer);
651                                 if(_dst->video_meta->composer == NULL)
652                                 {
653                                         media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
654                                         media_info_destroy((media_info_h)_dst);
655                                         return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
656                                 }
657                         }
658                         if(STRING_VALID(_src->video_meta->year))
659                         {
660                                 _dst->video_meta->year = strdup(_src->video_meta->year);
661                                 if(_dst->video_meta->year == NULL)
662                                 {
663                                         media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
664                                         media_info_destroy((media_info_h)_dst);
665                                         return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
666                                 }
667                         }
668                         if(STRING_VALID(_src->video_meta->recorded_date))
669                         {
670                                 _dst->video_meta->recorded_date = strdup(_src->video_meta->recorded_date);
671                                 if(_dst->video_meta->recorded_date == NULL)
672                                 {
673                                         media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
674                                         media_info_destroy((media_info_h)_dst);
675                                         return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
676                                 }
677                         }
678                         if(STRING_VALID(_src->video_meta->copyright))
679                         {
680                                 _dst->video_meta->copyright = strdup(_src->video_meta->copyright);
681                                 if(_dst->video_meta->copyright == NULL)
682                                 {
683                                         media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
684                                         media_info_destroy((media_info_h)_dst);
685                                         return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
686                                 }
687                         }
688                         if(STRING_VALID(_src->video_meta->track_num))
689                         {
690                                 _dst->video_meta->track_num = strdup(_src->video_meta->track_num);
691                                 if(_dst->video_meta->year == NULL)
692                                 {
693                                         media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
694                                         media_info_destroy((media_info_h)_dst);
695                                         return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
696                                 }
697                         }
698
699                         _dst->video_meta->width = _src->video_meta->width;
700                         _dst->video_meta->height = _src->video_meta->height;
701                         _dst->video_meta->duration = _src->video_meta->duration;
702                         _dst->video_meta->bitrate = _src->video_meta->bitrate;
703                         _dst->video_meta->played_count = _src->video_meta->played_count;
704                         _dst->video_meta->played_time = _src->video_meta->played_time;
705                         _dst->video_meta->played_position = _src->video_meta->played_position;
706
707                 } else if((_src->media_type == MEDIA_CONTENT_TYPE_MUSIC || _src->media_type == MEDIA_CONTENT_TYPE_SOUND) && _src->audio_meta) {
708                         _dst->audio_meta = (audio_meta_s *)calloc(1, sizeof(audio_meta_s));
709                         if(_dst->audio_meta == NULL)
710                         {
711                                 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
712                                 media_info_destroy((media_info_h)_dst);
713                                 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
714                         }
715
716                         if(STRING_VALID(_src->audio_meta->media_id))
717                         {
718                                 _dst->audio_meta->media_id = strdup(_src->audio_meta->media_id);
719                                 if(_dst->audio_meta->media_id == NULL)
720                                 {
721                                         media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
722                                         media_info_destroy((media_info_h)_dst);
723                                         return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
724                                 }
725                         }
726                         if(STRING_VALID(_src->audio_meta->title))
727                         {
728                                 _dst->audio_meta->title = strdup(_src->audio_meta->title);
729                                 if(_dst->audio_meta->title == NULL)
730                                 {
731                                         media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
732                                         media_info_destroy((media_info_h)_dst);
733                                         return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
734                                 }
735                         }
736                         if(STRING_VALID(_src->audio_meta->album))
737                         {
738                                 _dst->audio_meta->album = strdup(_src->audio_meta->album);
739                                 if(_dst->audio_meta->album == NULL)
740                                 {
741                                         media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
742                                         media_info_destroy((media_info_h)_dst);
743                                         return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
744                                 }
745                         }
746                         if(STRING_VALID(_src->audio_meta->artist))
747                         {
748                                 _dst->audio_meta->artist = strdup(_src->audio_meta->artist);
749                                 if(_dst->audio_meta->artist == NULL)
750                                 {
751                                         media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
752                                         media_info_destroy((media_info_h)_dst);
753                                         return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
754                                 }
755                         }
756                         if(STRING_VALID(_src->audio_meta->genre))
757                         {
758                                 _dst->audio_meta->genre = strdup(_src->audio_meta->genre);
759                                 if(_dst->audio_meta->genre == NULL)
760                                 {
761                                         media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
762                                         media_info_destroy((media_info_h)_dst);
763                                         return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
764                                 }
765                         }
766                         if(STRING_VALID(_src->audio_meta->composer))
767                         {
768                                 _dst->audio_meta->composer = strdup(_src->audio_meta->composer);
769                                 if(_dst->audio_meta->composer == NULL)
770                                 {
771                                         media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
772                                         media_info_destroy((media_info_h)_dst);
773                                         return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
774                                 }
775                         }
776                         if(STRING_VALID(_src->audio_meta->year))
777                         {
778                                 _dst->audio_meta->year = strdup(_src->audio_meta->year);
779                                 if(_dst->audio_meta->year == NULL)
780                                 {
781                                         media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
782                                         media_info_destroy((media_info_h)_dst);
783                                         return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
784                                 }
785                         }
786                         if(STRING_VALID(_src->audio_meta->recorded_date))
787                         {
788                                 _dst->audio_meta->recorded_date = strdup(_src->audio_meta->recorded_date);
789                                 if(_dst->audio_meta->recorded_date == NULL)
790                                 {
791                                         media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
792                                         media_info_destroy((media_info_h)_dst);
793                                         return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
794                                 }
795                         }
796                         if(STRING_VALID(_src->audio_meta->copyright))
797                         {
798                                 _dst->audio_meta->copyright = strdup(_src->audio_meta->copyright);
799                                 if(_dst->audio_meta->copyright == NULL)
800                                 {
801                                         media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
802                                         media_info_destroy((media_info_h)_dst);
803                                         return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
804                                 }
805                         }
806                         if(STRING_VALID(_src->audio_meta->track_num))
807                         {
808                                 _dst->audio_meta->track_num = strdup(_src->audio_meta->track_num);
809                                 if(_dst->audio_meta->year == NULL)
810                                 {
811                                         media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
812                                         media_info_destroy((media_info_h)_dst);
813                                         return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
814                                 }
815                         }
816
817                         _dst->audio_meta->channel = _src->audio_meta->channel;
818                         _dst->audio_meta->samplerate = _src->audio_meta->samplerate;
819                         _dst->audio_meta->duration = _src->audio_meta->duration;
820                         _dst->audio_meta->bitrate = _src->audio_meta->bitrate;
821                         _dst->audio_meta->played_count = _src->audio_meta->played_count;
822                         _dst->audio_meta->played_time = _src->audio_meta->played_time;
823                         _dst->audio_meta->played_position = _src->audio_meta->played_position;
824
825                 }
826                 *dst = (media_info_h)_dst;
827
828                 ret = MEDIA_CONTENT_ERROR_NONE;
829         }
830         else
831         {
832                 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
833                 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
834         }
835
836         return ret;
837 }
838
839 int media_info_get_media_count_from_db(filter_h filter, int *media_count)
840 {
841         int ret = MEDIA_CONTENT_ERROR_NONE;
842
843         media_content_debug_func();
844
845         if(media_count == NULL)
846         {
847                 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
848                 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
849
850                 return ret;
851         }
852
853         ret = _media_db_get_group_item_count(NULL, filter, MEDIA_GROUP_NONE, media_count);
854
855         return ret;
856 }
857
858 int media_info_foreach_media_from_db(filter_h filter, media_info_cb callback, void *user_data)
859 {
860         int ret = MEDIA_CONTENT_ERROR_NONE;
861
862         media_content_debug_func();
863
864         if(callback == NULL)
865         {
866                 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
867                 return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
868         }
869
870         ret = _media_db_get_group_item(NULL, filter, callback, user_data, MEDIA_GROUP_NONE);
871
872         return ret;
873 }
874
875 int media_info_get_tag_count_from_db(const char *media_id, filter_h filter, int *tag_count)
876 {
877         int ret = MEDIA_CONTENT_ERROR_NONE;
878
879         media_content_debug_func();
880
881         if(STRING_VALID(media_id) && tag_count)
882         {
883                 ret = _media_db_get_group_item_count(media_id, filter, MEDIA_GROUP_TAG_BY_MEDIA_ID, tag_count);
884         }
885         else
886         {
887                 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
888                 return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
889         }
890
891         return ret;
892 }
893
894 int media_info_foreach_tag_from_db(const char *media_id, filter_h filter, media_tag_cb callback, void *user_data)
895 {
896         int ret = MEDIA_CONTENT_ERROR_NONE;
897
898         media_content_debug_func();
899
900         if((callback != NULL) && STRING_VALID(media_id))
901         {
902                 ret = _media_db_get_tag(media_id, filter, callback, user_data);
903         }
904         else
905         {
906                 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
907                 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
908         }
909
910         return ret;
911 }
912
913 int media_info_get_bookmark_count_from_db(const char *media_id, filter_h filter, int *bookmark_count)
914 {
915         int ret = MEDIA_CONTENT_ERROR_NONE;
916
917         media_content_debug_func();
918
919         if(STRING_VALID(media_id) && bookmark_count)
920         {
921                 ret = _media_db_get_group_item_count(media_id, filter, MEDIA_GROUP_BOOKMARK_BY_MEDIA_ID, bookmark_count);
922         }
923         else
924         {
925                 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
926                 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
927         }
928
929         return ret;
930 }
931
932 int media_info_foreach_bookmark_from_db (const char *media_id, filter_h filter, media_bookmark_cb callback, void *user_data)
933 {
934         int ret = MEDIA_CONTENT_ERROR_NONE;
935
936         media_content_debug_func();
937
938         if((callback != NULL) && STRING_VALID(media_id))
939         {
940                 ret = _media_db_get_bookmark(media_id, filter, callback, user_data);
941         }
942         else
943         {
944                 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
945                 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
946         }
947
948         return ret;
949 }
950
951 int media_info_get_image(media_info_h media, image_meta_h *image)
952 {
953         int ret = MEDIA_CONTENT_ERROR_NONE;
954
955         media_info_s *_media = (media_info_s*)media;
956         media_content_debug_func();
957
958         if(_media == NULL)
959         {
960                 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
961                 return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
962         }
963
964         if(_media->media_type != MEDIA_CONTENT_TYPE_IMAGE)
965         {
966                 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
967                 return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
968         }
969
970         if(_media->image_meta == NULL)
971         {
972                 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
973                 return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
974         }
975
976         image_meta_s *_image = (image_meta_s*)calloc(1, sizeof(image_meta_s));
977
978         if(_image == NULL)
979         {
980                 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
981                 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
982         }
983
984         if(STRING_VALID(_media->media_id)) {
985                 _image->media_id = strdup(_media->media_id);
986         }
987
988         _image->width = _media->image_meta->width;
989         _image->height = _media->image_meta->height;
990         _image->orientation = _media->image_meta->orientation;
991
992         if(STRING_VALID(_media->image_meta->date_taken)) {
993                 _image->date_taken = strdup(_media->image_meta->date_taken);
994         }
995
996         *image = (image_meta_h)_image;
997
998         return ret;
999 }
1000
1001 int media_info_get_video(media_info_h media, video_meta_h *video)
1002 {
1003         int ret = MEDIA_CONTENT_ERROR_NONE;
1004
1005         media_info_s *_media = (media_info_s*)media;
1006         media_content_debug_func();
1007
1008         if(_media == NULL)
1009         {
1010                 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1011                 return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1012         }
1013
1014         if(_media->media_type != MEDIA_CONTENT_TYPE_VIDEO)
1015         {
1016                 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1017                 return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1018         }
1019
1020         if(_media->video_meta == NULL)
1021         {
1022                 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1023                 return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1024         }
1025
1026         video_meta_s *_video = (video_meta_s*)calloc(1, sizeof(video_meta_s));
1027
1028         if(_video == NULL)
1029         {
1030                 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
1031                 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
1032         }
1033
1034         if(STRING_VALID(_media->media_id)) {
1035                 _video->media_id = strdup(_media->media_id);
1036         }
1037
1038         if(STRING_VALID(_media->video_meta->title)) {
1039                 _video->title = strdup(_media->video_meta->title);
1040         }
1041         if(STRING_VALID(_media->video_meta->album)) {
1042                 _video->album = strdup(_media->video_meta->album);
1043         }
1044         if(STRING_VALID(_media->video_meta->artist)) {
1045                 _video->artist = strdup(_media->video_meta->artist);
1046         }
1047         if(STRING_VALID(_media->video_meta->genre)) {
1048                 _video->genre = strdup(_media->video_meta->genre);
1049         }
1050         if(STRING_VALID(_media->video_meta->composer)) {
1051                 _video->composer = strdup(_media->video_meta->composer);
1052         }
1053         if(STRING_VALID(_media->video_meta->year)) {
1054                 _video->year = strdup(_media->video_meta->year);
1055         }
1056         if(STRING_VALID(_media->video_meta->recorded_date)) {
1057                 _video->recorded_date = strdup(_media->video_meta->recorded_date);
1058         }
1059         if(STRING_VALID(_media->video_meta->copyright)) {
1060                 _video->copyright = strdup(_media->video_meta->copyright);
1061         }
1062         if(STRING_VALID(_media->video_meta->track_num)) {
1063                 _video->track_num = strdup(_media->video_meta->track_num);
1064         }
1065
1066         _video->width = _media->video_meta->width;
1067         _video->height = _media->video_meta->height;
1068         _video->duration = _media->video_meta->duration;
1069         _video->bitrate = _media->video_meta->bitrate;
1070         _video->played_count = _media->video_meta->played_count;
1071         _video->played_time = _media->video_meta->played_time;
1072         _video->played_position = _media->video_meta->played_position;
1073
1074         *video = (video_meta_h)_video;
1075
1076         return ret;
1077 }
1078
1079 int media_info_get_audio(media_info_h media, audio_meta_h *audio)
1080 {
1081         int ret = MEDIA_CONTENT_ERROR_NONE;
1082
1083         media_info_s *_media = (media_info_s*)media;
1084         media_content_debug_func();
1085
1086         if(_media == NULL)
1087         {
1088                 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1089                 return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1090         }
1091
1092         if(_media->media_type != MEDIA_CONTENT_TYPE_MUSIC && _media->media_type != MEDIA_CONTENT_TYPE_SOUND)
1093         {
1094                 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1095                 return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1096         }
1097
1098         if(_media->audio_meta == NULL)
1099         {
1100                 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1101                 return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1102         }
1103
1104         audio_meta_s *_audio = (audio_meta_s*)calloc(1, sizeof(audio_meta_s));
1105
1106         if(_audio == NULL)
1107         {
1108                 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
1109                 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
1110         }
1111
1112         if(STRING_VALID(_media->media_id)) {
1113                 _audio->media_id = strdup(_media->media_id);
1114         }
1115
1116         if(STRING_VALID(_media->audio_meta->title)) {
1117                 _audio->title = strdup(_media->audio_meta->title);
1118         }
1119         if(STRING_VALID(_media->audio_meta->album)) {
1120                 _audio->album = strdup(_media->audio_meta->album);
1121         }
1122         if(STRING_VALID(_media->audio_meta->artist)) {
1123                 _audio->artist = strdup(_media->audio_meta->artist);
1124         }
1125         if(STRING_VALID(_media->audio_meta->genre)) {
1126                 _audio->genre = strdup(_media->audio_meta->genre);
1127         }
1128         if(STRING_VALID(_media->audio_meta->composer)) {
1129                 _audio->composer = strdup(_media->audio_meta->composer);
1130         }
1131         if(STRING_VALID(_media->audio_meta->year)) {
1132                 _audio->year = strdup(_media->audio_meta->year);
1133         }
1134         if(STRING_VALID(_media->audio_meta->recorded_date)) {
1135                 _audio->recorded_date = strdup(_media->audio_meta->recorded_date);
1136         }
1137         if(STRING_VALID(_media->audio_meta->copyright)) {
1138                 _audio->copyright = strdup(_media->audio_meta->copyright);
1139         }
1140         if(STRING_VALID(_media->audio_meta->track_num)) {
1141                 _audio->track_num = strdup(_media->audio_meta->track_num);
1142         }
1143
1144         _audio->duration = _media->audio_meta->duration;
1145         _audio->bitrate = _media->audio_meta->bitrate;
1146         _audio->samplerate = _media->audio_meta->samplerate;
1147         _audio->channel = _media->audio_meta->channel;
1148         _audio->played_time = _media->audio_meta->played_time;
1149         _audio->played_count = _media->audio_meta->played_count;
1150         _audio->played_position = _media->audio_meta->played_position;
1151
1152         *audio = (audio_meta_h)_audio;
1153
1154         return ret;
1155 }
1156
1157 int media_info_get_media_id(media_info_h media, char **media_id)
1158 {
1159         int ret = MEDIA_CONTENT_ERROR_NONE;
1160         media_info_s *_media = (media_info_s*)media;
1161
1162         if(_media && media_id)
1163         {
1164                 if(STRING_VALID(_media->media_id))
1165                 {
1166                         *media_id = strdup(_media->media_id);
1167                         if(*media_id == NULL)
1168                         {
1169                                 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
1170                                 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
1171                         }
1172                 }
1173                 else
1174                 {
1175                         *media_id = NULL;
1176                 }
1177                 ret = MEDIA_CONTENT_ERROR_NONE;
1178         }
1179         else
1180         {
1181                 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1182                 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1183         }
1184
1185         return ret;
1186 }
1187
1188 int media_info_get_file_path(media_info_h media, char **path)
1189 {
1190         int ret = MEDIA_CONTENT_ERROR_NONE;
1191         media_info_s *_media = (media_info_s*)media;
1192
1193         if(_media && path)
1194         {
1195                 if(STRING_VALID(_media->file_path))
1196                 {
1197                         *path = strdup(_media->file_path);
1198                         if(*path == NULL)
1199                         {
1200                                 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
1201                                 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
1202                         }
1203                 }
1204                 else
1205                 {
1206                         *path = NULL;
1207                 }
1208                 ret = MEDIA_CONTENT_ERROR_NONE;
1209
1210         }
1211         else
1212         {
1213                 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1214                 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1215         }
1216
1217         return ret;
1218 }
1219
1220 int media_info_get_display_name(media_info_h media, char **name)
1221 {
1222         int ret = MEDIA_CONTENT_ERROR_NONE;
1223         media_info_s *_media = (media_info_s*)media;
1224         if(_media && name)
1225         {
1226                 if(STRING_VALID(_media->display_name))
1227                 {
1228                         *name = strdup(_media->display_name);
1229                         if(*name == NULL)
1230                         {
1231                                 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
1232                                 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
1233                         }
1234                 }
1235                 else
1236                 {
1237                         *name = NULL;
1238                 }
1239                 ret = MEDIA_CONTENT_ERROR_NONE;
1240
1241         }
1242         else
1243         {
1244                 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1245                 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1246         }
1247
1248         return ret;
1249 }
1250
1251 int media_info_get_media_type(media_info_h media, media_content_type_e *type)
1252 {
1253         int ret = MEDIA_CONTENT_ERROR_NONE;
1254         media_info_s *_media = (media_info_s*)media;
1255         if(_media && type)
1256         {
1257                 *type = _media->media_type;
1258                 ret = MEDIA_CONTENT_ERROR_NONE;
1259         }
1260         else
1261         {
1262                 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1263                 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1264         }
1265
1266         return ret;
1267 }
1268
1269 int media_info_get_mime_type(media_info_h media, char **mime_type)
1270 {
1271         int ret = MEDIA_CONTENT_ERROR_NONE;
1272         media_info_s *_media = (media_info_s*)media;
1273
1274         if(_media && mime_type)
1275         {
1276                 if(STRING_VALID(_media->mime_type))
1277                 {
1278                         *mime_type = strdup(_media->mime_type);
1279                         if(*mime_type == NULL)
1280                         {
1281                                 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
1282                                 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
1283                         }
1284                 }
1285                 else
1286                 {
1287                         *mime_type = NULL;
1288                 }
1289                 ret = MEDIA_CONTENT_ERROR_NONE;
1290         }
1291         else
1292         {
1293                 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1294                 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1295         }
1296
1297         return ret;
1298 }
1299
1300 int media_info_get_size(media_info_h media, unsigned long long *size)
1301 {
1302         int ret = MEDIA_CONTENT_ERROR_NONE;
1303         media_info_s *_media = (media_info_s*)media;
1304
1305         if(_media && size)
1306         {
1307                 *size = _media->size;
1308                 ret = MEDIA_CONTENT_ERROR_NONE;
1309         }
1310         else
1311         {
1312                 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1313                 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1314         }
1315
1316         return ret;
1317 }
1318
1319 int media_info_get_added_time(media_info_h media, time_t *added_time)
1320 {
1321         int ret = MEDIA_CONTENT_ERROR_NONE;
1322         media_info_s *_media = (media_info_s*)media;
1323         if(_media && added_time)
1324         {
1325                 *added_time = _media->added_time;
1326                 ret = MEDIA_CONTENT_ERROR_NONE;
1327         }
1328         else
1329         {
1330                 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1331                 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1332         }
1333
1334         return ret;
1335 }
1336
1337 int media_info_get_modified_time(media_info_h media, time_t* time)
1338 {
1339         int ret = MEDIA_CONTENT_ERROR_NONE;
1340         media_info_s *_media = (media_info_s*)media;
1341         if(_media && time)
1342         {
1343                 *time = _media->modified_time;
1344                 ret = MEDIA_CONTENT_ERROR_NONE;
1345         }
1346         else
1347         {
1348                 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1349                 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1350         }
1351
1352         return ret;
1353 }
1354
1355 int media_info_get_thumbnail_path(media_info_h media, char **path)
1356 {
1357         int ret = MEDIA_CONTENT_ERROR_NONE;
1358         media_info_s *_media = (media_info_s*)media;
1359         if(_media && path)
1360         {
1361                 if(STRING_VALID(_media->thumbnail_path))
1362                 {
1363                         *path = strdup(_media->thumbnail_path);
1364                         if(*path == NULL)
1365                         {
1366                                 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
1367                                 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
1368                         }
1369                 }
1370                 else
1371                 {
1372                         *path = NULL;
1373                 }
1374                 ret = MEDIA_CONTENT_ERROR_NONE;
1375
1376         }
1377         else
1378         {
1379                 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1380                 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1381         }
1382
1383         return ret;
1384 }
1385
1386 int media_info_get_description(media_info_h media, char **description)
1387 {
1388         int ret = MEDIA_CONTENT_ERROR_NONE;
1389         media_info_s *_media = (media_info_s*)media;
1390
1391         if(_media && description)
1392         {
1393                 if(STRING_VALID(_media->description))
1394                 {
1395                         *description = strdup(_media->description);
1396                         if(*description == NULL)
1397                         {
1398                                 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
1399                                 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
1400                         }
1401                 }
1402                 else
1403                 {
1404                         *description = NULL;
1405                 }
1406                 ret = MEDIA_CONTENT_ERROR_NONE;
1407         }
1408         else
1409         {
1410                 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1411                 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1412         }
1413
1414         return ret;
1415 }
1416
1417 int media_info_get_longitude(media_info_h media, double* longitude)
1418 {
1419         int ret = MEDIA_CONTENT_ERROR_NONE;
1420         media_info_s *_media = (media_info_s*)media;
1421
1422         if(_media && longitude)
1423         {
1424                 *longitude = _media->longitude;
1425                 ret = MEDIA_CONTENT_ERROR_NONE;
1426         }
1427         else
1428         {
1429                 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1430                 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1431         }
1432
1433         return ret;
1434 }
1435 int media_info_get_latitude(media_info_h media, double* latitude)
1436 {
1437         int ret = MEDIA_CONTENT_ERROR_NONE;
1438         media_info_s *_media = (media_info_s*)media;
1439
1440         if(_media && latitude)
1441         {
1442                 *latitude = _media->latitude;
1443                 ret = MEDIA_CONTENT_ERROR_NONE;
1444         }
1445         else
1446         {
1447                 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1448                 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1449         }
1450
1451         return ret;
1452 }
1453
1454 int media_info_get_altitude(media_info_h media, double *altitude)
1455 {
1456         int ret = MEDIA_CONTENT_ERROR_NONE;
1457         media_info_s *_media = (media_info_s*)media;
1458
1459         if(_media && altitude)
1460         {
1461                 *altitude = _media->altitude;
1462                 ret = MEDIA_CONTENT_ERROR_NONE;
1463         }
1464         else
1465         {
1466                 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1467                 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1468         }
1469
1470         return ret;
1471 }
1472
1473 int media_info_get_rating(media_info_h media, int *rating)
1474 {
1475         int ret = MEDIA_CONTENT_ERROR_NONE;
1476         media_info_s *_media = (media_info_s*)media;
1477
1478         if(_media && rating)
1479         {
1480                 *rating = _media->rating;
1481                 ret = MEDIA_CONTENT_ERROR_NONE;
1482         }
1483         else
1484         {
1485                 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1486                 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1487         }
1488
1489         return ret;
1490 }
1491
1492 int media_info_get_favorite(media_info_h media, bool* favorite)
1493 {
1494         int ret = MEDIA_CONTENT_ERROR_NONE;
1495         media_info_s *_media = (media_info_s*)media;
1496
1497         if(_media && favorite)
1498         {
1499
1500                 *favorite = _media->favourite;
1501                 ret = MEDIA_CONTENT_ERROR_NONE;
1502         }
1503         else
1504         {
1505                 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1506                 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1507         }
1508
1509         return ret;
1510 }
1511
1512 int media_info_get_author(media_info_h media, char **author)
1513 {
1514         int ret = MEDIA_CONTENT_ERROR_NONE;
1515         media_info_s *_media = (media_info_s*)media;
1516
1517         if(_media && author)
1518         {
1519                 if(STRING_VALID(_media->author))
1520                 {
1521                         *author = strdup(_media->author);
1522                         if(*author == NULL)
1523                         {
1524                                 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
1525                                 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
1526                         }
1527                 }
1528                 else
1529                 {
1530                         *author = NULL;
1531                 }
1532                 ret = MEDIA_CONTENT_ERROR_NONE;
1533         }
1534         else
1535         {
1536                 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1537                 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1538         }
1539
1540         return ret;
1541 }
1542
1543 int media_info_get_provider(media_info_h media, char **provider)
1544 {
1545         int ret = MEDIA_CONTENT_ERROR_NONE;
1546         media_info_s *_media = (media_info_s*)media;
1547
1548         if(_media && provider)
1549         {
1550                 if(STRING_VALID(_media->provider))
1551                 {
1552                         *provider = strdup(_media->provider);
1553                         if(*provider == NULL)
1554                         {
1555                                 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
1556                                 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
1557                         }
1558                 }
1559                 else
1560                 {
1561                         *provider = NULL;
1562                 }
1563                 ret = MEDIA_CONTENT_ERROR_NONE;
1564         }
1565         else
1566         {
1567                 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1568                 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1569         }
1570
1571         return ret;
1572 }
1573
1574 int media_info_get_content_name(media_info_h media, char **content_name)
1575 {
1576         int ret = MEDIA_CONTENT_ERROR_NONE;
1577         media_info_s *_media = (media_info_s*)media;
1578
1579         if(_media && content_name)
1580         {
1581                 if(STRING_VALID(_media->content_name))
1582                 {
1583                         *content_name = strdup(_media->content_name);
1584                         if(*content_name == NULL)
1585                         {
1586                                 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
1587                                 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
1588                         }
1589                 }
1590                 else
1591                 {
1592                         *content_name = NULL;
1593                 }
1594                 ret = MEDIA_CONTENT_ERROR_NONE;
1595         }
1596         else
1597         {
1598                 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1599                 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1600         }
1601
1602         return ret;
1603 }
1604
1605 int media_info_get_category(media_info_h media, char **category)
1606 {
1607         int ret = MEDIA_CONTENT_ERROR_NONE;
1608         media_info_s *_media = (media_info_s*)media;
1609
1610         if(_media && category)
1611         {
1612                 if(STRING_VALID(_media->category))
1613                 {
1614                         *category = strdup(_media->category);
1615                         if(*category == NULL)
1616                         {
1617                                 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
1618                                 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
1619                         }
1620                 }
1621                 else
1622                 {
1623                         *category = NULL;
1624                 }
1625                 ret = MEDIA_CONTENT_ERROR_NONE;
1626         }
1627         else
1628         {
1629                 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1630                 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1631         }
1632
1633         return ret;
1634 }
1635
1636 int media_info_get_location_tag(media_info_h media, char **location_tag)
1637 {
1638         int ret = MEDIA_CONTENT_ERROR_NONE;
1639         media_info_s *_media = (media_info_s*)media;
1640
1641         if(_media && location_tag)
1642         {
1643                 if(STRING_VALID(_media->location_tag))
1644                 {
1645                         *location_tag = strdup(_media->location_tag);
1646                         if(*location_tag == NULL)
1647                         {
1648                                 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
1649                                 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
1650                         }
1651                 }
1652                 else
1653                 {
1654                         *location_tag = NULL;
1655                 }
1656                 ret = MEDIA_CONTENT_ERROR_NONE;
1657         }
1658         else
1659         {
1660                 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1661                 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1662         }
1663
1664         return ret;
1665 }
1666
1667 int media_info_get_age_rating(media_info_h media, char **age_rating)
1668 {
1669         int ret = MEDIA_CONTENT_ERROR_NONE;
1670         media_info_s *_media = (media_info_s*)media;
1671
1672         if(_media && age_rating)
1673         {
1674                 if(STRING_VALID(_media->age_rating))
1675                 {
1676                         *age_rating = strdup(_media->age_rating);
1677                         if(*age_rating == NULL)
1678                         {
1679                                 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
1680                                 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
1681                         }
1682                 }
1683                 else
1684                 {
1685                         *age_rating = NULL;
1686                 }
1687                 ret = MEDIA_CONTENT_ERROR_NONE;
1688         }
1689         else
1690         {
1691                 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1692                 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1693         }
1694
1695         return ret;
1696 }
1697
1698 int media_info_get_keyword(media_info_h media, char **keyword)
1699 {
1700         int ret = MEDIA_CONTENT_ERROR_NONE;
1701         media_info_s *_media = (media_info_s*)media;
1702
1703         if(_media && keyword)
1704         {
1705                 if(STRING_VALID(_media->keyword))
1706                 {
1707                         *keyword = strdup(_media->keyword);
1708                         if(*keyword == NULL)
1709                         {
1710                                 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
1711                                 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
1712                         }
1713                 }
1714                 else
1715                 {
1716                         *keyword = NULL;
1717                 }
1718                 ret = MEDIA_CONTENT_ERROR_NONE;
1719         }
1720         else
1721         {
1722                 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1723                 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1724         }
1725
1726         return ret;
1727 }
1728
1729 int media_info_is_drm(media_info_h media, bool *is_drm)
1730 {
1731         int ret = MEDIA_CONTENT_ERROR_NONE;
1732         media_info_s *_media = (media_info_s*)media;
1733
1734         if(_media)
1735         {
1736                 *is_drm = _media->is_drm;
1737                 ret = MEDIA_CONTENT_ERROR_NONE;
1738         }
1739         else
1740         {
1741                 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1742                 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1743         }
1744
1745         return ret;
1746 }
1747
1748 int media_info_get_storage_type(media_info_h media, media_content_storage_e *storage_type)
1749 {
1750         int ret = MEDIA_CONTENT_ERROR_NONE;
1751         media_info_s *_media = (media_info_s*)media;
1752
1753         if(_media && storage_type)
1754         {
1755                 *storage_type = _media->storage_type;
1756                 ret = MEDIA_CONTENT_ERROR_NONE;
1757         }
1758         else
1759         {
1760                 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1761                 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1762         }
1763
1764         return ret;
1765 }
1766
1767 int media_info_get_media_from_db(const char *media_id, media_info_h *media)
1768 {
1769         int ret = MEDIA_CONTENT_ERROR_NONE;
1770         char select_query[DEFAULT_QUERY_SIZE];
1771         sqlite3_stmt *stmt = NULL;
1772
1773         if(!STRING_VALID(media_id) || (media == NULL))
1774         {
1775                 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1776                 return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1777         }
1778
1779         memset(select_query, 0x00, sizeof(select_query));
1780
1781         snprintf(select_query, sizeof(select_query), SELECT_MEDIA_FROM_MEDIA, media_id);
1782         ret = _content_query_prepare(&stmt, select_query, NULL, NULL);
1783         media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
1784
1785         while(sqlite3_step(stmt) == SQLITE_ROW)
1786         {
1787                 media_info_s *_media = (media_info_s*)calloc(1, sizeof(media_info_s));
1788
1789                 if(_media == NULL)
1790                 {
1791                         media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
1792                         SQLITE3_FINALIZE(stmt);
1793                         return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
1794                 }
1795
1796                 _media_info_item_get_detail(stmt, (media_info_h)_media);
1797
1798                 *media = (media_info_h)_media;
1799         }
1800
1801         SQLITE3_FINALIZE(stmt);
1802
1803         return ret;
1804 }
1805
1806 int media_info_set_display_name(media_info_h media, const char *display_name)
1807 {
1808         int ret = MEDIA_CONTENT_ERROR_NONE;
1809         media_info_s *_media = (media_info_s*)media;
1810
1811         if(_media != NULL && STRING_VALID(display_name))
1812         {
1813                 SAFE_FREE(_media->display_name);
1814
1815                 _media->display_name = strdup(display_name);
1816                 if(_media->display_name == NULL)
1817                 {
1818                         media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
1819                         return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
1820                 }
1821         }
1822         else
1823         {
1824                 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1825                 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1826         }
1827
1828         return ret;
1829 }
1830
1831 int media_info_set_description(media_info_h media, const char *description)
1832 {
1833         int ret = MEDIA_CONTENT_ERROR_NONE;
1834         media_info_s *_media = (media_info_s*)media;
1835
1836         if(_media != NULL)
1837         {
1838                 SAFE_FREE(_media->description);
1839
1840                 if(STRING_VALID(description))
1841                 {
1842                         _media->description = strdup(description);
1843
1844                         if(_media->description == NULL)
1845                         {
1846                                 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
1847                                 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
1848                         }
1849                 }
1850                 else
1851                 {
1852                         _media->description = NULL;
1853                 }
1854         }
1855         else
1856         {
1857                 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1858                 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1859         }
1860
1861         return ret;
1862 }
1863
1864 int media_info_set_longitude(media_info_h media, double longitude)
1865 {
1866         int ret = MEDIA_CONTENT_ERROR_NONE;
1867         media_info_s *_media = (media_info_s*)media;
1868
1869         if(_media != NULL)
1870         {
1871                 _media->longitude = longitude;
1872         }
1873         else
1874         {
1875                 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1876                 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1877         }
1878
1879         return ret;
1880 }
1881
1882 int media_info_set_latitude(media_info_h media, double latitude)
1883 {
1884         int ret = MEDIA_CONTENT_ERROR_NONE;
1885         media_info_s *_media = (media_info_s*)media;
1886
1887         if(_media != NULL)
1888         {
1889                 _media->latitude = latitude;
1890         }
1891         else
1892         {
1893                 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1894                 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1895         }
1896
1897         return ret;
1898 }
1899
1900 int media_info_set_altitude(media_info_h media, double altitude)
1901 {
1902         int ret = MEDIA_CONTENT_ERROR_NONE;
1903         media_info_s *_media = (media_info_s*)media;
1904
1905         if(_media != NULL)
1906         {
1907                 _media->altitude = altitude;
1908         }
1909         else
1910         {
1911                 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1912                 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1913         }
1914
1915         return ret;
1916 }
1917
1918 int media_info_set_rating(media_info_h media, int rating)
1919 {
1920         int ret = MEDIA_CONTENT_ERROR_NONE;
1921         media_info_s *_media = (media_info_s*)media;
1922
1923         if(_media != NULL)
1924         {
1925                 _media->rating = rating;
1926         }
1927         else
1928         {
1929                 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1930                 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1931         }
1932
1933         return ret;
1934 }
1935
1936 int media_info_set_added_time(media_info_h media, time_t added_time)
1937 {
1938         int ret = MEDIA_CONTENT_ERROR_NONE;
1939
1940         media_info_s *_media = (media_info_s*)media;
1941
1942         if((_media != NULL) && (added_time >= 0))
1943         {
1944                 _media->added_time = added_time;
1945         }
1946         else
1947         {
1948                 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1949                 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1950         }
1951
1952         return ret;
1953 }
1954
1955 int media_info_set_favorite(media_info_h media, bool favorite)
1956 {
1957         int ret = MEDIA_CONTENT_ERROR_NONE;
1958         media_info_s *_media = (media_info_s*)media;
1959
1960         if(_media != NULL)
1961         {
1962                 _media->favourite = favorite;
1963         }
1964         else
1965         {
1966                 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1967                 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1968         }
1969
1970         return ret;
1971 }
1972
1973 int media_info_set_author(media_info_h media, const char *author)
1974 {
1975         int ret = MEDIA_CONTENT_ERROR_NONE;
1976         media_info_s *_media = (media_info_s*)media;
1977
1978         if(_media != NULL)
1979         {
1980                 if(STRING_VALID(author))
1981                 {
1982                         _media->author = strdup(author);
1983                         if(_media->author == NULL)
1984                         {
1985                                 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
1986                                 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
1987                         }
1988                 }
1989                 else
1990                 {
1991                         _media->author = NULL;
1992                 }
1993         }
1994         else
1995         {
1996                 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1997                 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1998         }
1999
2000         return ret;
2001 }
2002
2003 int media_info_set_provider(media_info_h media, const char *provider)
2004 {
2005         int ret = MEDIA_CONTENT_ERROR_NONE;
2006         media_info_s *_media = (media_info_s*)media;
2007
2008         if(_media != NULL)
2009         {
2010                 SAFE_FREE(_media->provider);
2011
2012                 if(STRING_VALID(provider))
2013                 {
2014                         _media->provider = strdup(provider);
2015                         if(_media->provider == NULL)
2016                         {
2017                                 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
2018                                 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
2019                         }
2020                 }
2021                 else
2022                 {
2023                         _media->provider = NULL;
2024                 }
2025         }
2026         else
2027         {
2028                 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
2029                 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
2030         }
2031
2032         return ret;
2033 }
2034
2035 int media_info_set_content_name(media_info_h media, const char *content_name)
2036 {
2037         int ret = MEDIA_CONTENT_ERROR_NONE;
2038         media_info_s *_media = (media_info_s*)media;
2039
2040         if(_media != NULL)
2041         {
2042                 SAFE_FREE(_media->content_name);
2043
2044                 if(STRING_VALID(content_name))
2045                 {
2046                         _media->content_name = strdup(content_name);
2047                         if(_media->content_name == NULL)
2048                         {
2049                                 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
2050                                 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
2051                         }
2052                 }
2053                 else
2054                 {
2055                         _media->content_name = NULL;
2056                 }
2057         }
2058         else
2059         {
2060                 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
2061                 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
2062         }
2063
2064         return ret;
2065 }
2066
2067 int media_info_set_category(media_info_h media, const char *category)
2068 {
2069         int ret = MEDIA_CONTENT_ERROR_NONE;
2070         media_info_s *_media = (media_info_s*)media;
2071
2072         if(_media != NULL)
2073         {
2074                 SAFE_FREE(_media->category);
2075
2076                 if(STRING_VALID(category))
2077                 {
2078                         _media->category = strdup(category);
2079                         if(_media->category == NULL)
2080                         {
2081                                 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
2082                                 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
2083                         }
2084                 }
2085                 else
2086                 {
2087                         _media->category = NULL;
2088                 }
2089         }
2090         else
2091         {
2092                 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
2093                 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
2094         }
2095
2096         return ret;
2097 }
2098
2099 int media_info_set_location_tag(media_info_h media, const char *location_tag)
2100 {
2101         int ret = MEDIA_CONTENT_ERROR_NONE;
2102         media_info_s *_media = (media_info_s*)media;
2103
2104         if(_media != NULL)
2105         {
2106                 SAFE_FREE(_media->location_tag);
2107
2108                 if(STRING_VALID(location_tag))
2109                 {
2110                         _media->location_tag = strdup(location_tag);
2111                         if(_media->location_tag == NULL)
2112                         {
2113                                 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
2114                                 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
2115                         }
2116                 }
2117                 else
2118                 {
2119                         _media->location_tag = NULL;
2120                 }
2121         }
2122         else
2123         {
2124                 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
2125                 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
2126         }
2127
2128         return ret;
2129 }
2130
2131 int media_info_set_age_rating(media_info_h media, const char *age_rating)
2132 {
2133         int ret = MEDIA_CONTENT_ERROR_NONE;
2134         media_info_s *_media = (media_info_s*)media;
2135
2136         if(_media != NULL)
2137         {
2138                 SAFE_FREE(_media->age_rating);
2139
2140                 if(STRING_VALID(age_rating))
2141                 {
2142                         _media->age_rating = strdup(age_rating);
2143                         if(_media->age_rating == NULL)
2144                         {
2145                                 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
2146                                 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
2147                         }
2148                 }
2149                 else
2150                 {
2151                         _media->age_rating = NULL;
2152                 }
2153         }
2154         else
2155         {
2156                 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
2157                 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
2158         }
2159
2160         return ret;
2161 }
2162
2163 int media_info_set_keyword(media_info_h media, const char *keyword)
2164 {
2165         int ret = MEDIA_CONTENT_ERROR_NONE;
2166         media_info_s *_media = (media_info_s*)media;
2167
2168         if(_media != NULL)
2169         {
2170                 SAFE_FREE(_media->keyword);
2171
2172                 if(STRING_VALID(keyword))
2173                 {
2174                         _media->keyword = strdup(keyword);
2175                         if(_media->keyword == NULL)
2176                         {
2177                                 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
2178                                 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
2179                         }
2180                 }
2181                 else
2182                 {
2183                         _media->keyword = NULL;
2184                 }
2185         }
2186         else
2187         {
2188                 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
2189                 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
2190         }
2191
2192         return ret;
2193 }
2194
2195 int media_info_update_to_db(media_info_h media)
2196 {
2197         int ret = MEDIA_CONTENT_ERROR_NONE;
2198         int len = 0;
2199         media_info_s *_media = (media_info_s*)media;
2200         char *set_sql = NULL;
2201         char sql[MAX_QUERY_SIZE];
2202         memset(sql, '\0', sizeof(sql));
2203
2204         if(_media != NULL && STRING_VALID(_media->media_id))
2205         {
2206                 set_sql = sqlite3_mprintf("file_name=%Q, added_time=%d, description=%Q, longitude=%f, latitude=%f, altitude=%f, \
2207                         rating=%d, favourite=%d, author=%Q, provider=%Q, content_name=%Q, category=%Q, location_tag=%Q, age_rating=%Q, keyword=%Q",
2208                         _media->display_name, _media->added_time, _media->description, _media->longitude, _media->latitude, _media->altitude, _media->rating, _media->favourite,
2209                         _media->author, _media->provider, _media->content_name, _media->category, _media->location_tag, _media->age_rating, _media->keyword);
2210
2211                 len = snprintf(sql, sizeof(sql), "UPDATE %s SET %s WHERE media_uuid='%s'", DB_TABLE_MEDIA, set_sql, _media->media_id);
2212                 sqlite3_free(set_sql);
2213                 if (len > 0) {
2214                         sql[len] = '\0';
2215                 } else {
2216                         media_content_error("snprintf failed");
2217                         return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
2218                 }
2219
2220                 ret = _content_query_sql(sql);
2221         }
2222         else
2223         {
2224                 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
2225                 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
2226         }
2227
2228         return ret;
2229 }
2230
2231 int media_info_refresh_metadata_to_db(const char *media_id)
2232 {
2233         int ret = MEDIA_CONTENT_ERROR_NONE;
2234         media_info_h media;
2235         char *file_path = NULL;
2236         media_content_type_e media_type = 0;
2237         media_content_storage_e storage_type = 0;
2238
2239         if(!STRING_VALID(media_id))
2240         {
2241                 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
2242                 return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
2243         }
2244
2245         ret = media_info_get_media_from_db(media_id, &media);
2246         media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
2247
2248         ret = media_info_get_media_type(media, &media_type);
2249         if(ret != MEDIA_CONTENT_ERROR_NONE)
2250         {
2251                 media_info_destroy(media);
2252                 return ret;
2253         }
2254
2255         ret = media_info_get_storage_type(media, &storage_type);
2256         if(ret != MEDIA_CONTENT_ERROR_NONE)
2257         {
2258                 media_info_destroy(media);
2259                 return ret;
2260         }
2261
2262         ret = media_info_get_file_path(media, &file_path);
2263         if(ret != MEDIA_CONTENT_ERROR_NONE)
2264         {
2265                 media_info_destroy(media);
2266                 return ret;
2267         }
2268
2269         ret = media_svc_refresh_item(_content_get_db_handle(), storage_type, file_path, media_type);
2270
2271         SAFE_FREE(file_path);
2272         media_info_destroy(media);
2273
2274         return ret;
2275 }
2276
2277 int media_info_move_to_db(media_info_h media, const char* dst_path)
2278 {
2279         int ret = MEDIA_CONTENT_ERROR_NONE;
2280
2281         int src_storage_type = 0;
2282         int dst_storage_type = 0;
2283
2284         if(media == NULL || !STRING_VALID(dst_path))
2285         {
2286                 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
2287                 return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
2288         }
2289
2290         media_info_s *_media = (media_info_s*)media;
2291
2292         ret = _media_util_get_store_type_by_path(_media->file_path, &src_storage_type);
2293         media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
2294         ret = _media_util_get_store_type_by_path(dst_path, &dst_storage_type);
2295         media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
2296
2297         ret = media_svc_move_item(_content_get_db_handle(), src_storage_type, _media->file_path, dst_storage_type, dst_path);
2298         return _content_error_capi(MEDIA_CONTENT_TYPE, ret);
2299 }
2300
2301 int media_info_move_media_to_db(media_info_h media, const char* dst_path)
2302 {
2303         int ret = MEDIA_CONTENT_ERROR_NONE;
2304
2305         int src_storage_type = 0;
2306         int dst_storage_type = 0;
2307
2308         if(media == NULL || !STRING_VALID(dst_path))
2309         {
2310                 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
2311                 return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
2312         }
2313
2314         media_info_s *_media = (media_info_s*)media;
2315
2316         ret = _media_util_get_store_type_by_path(_media->file_path, &src_storage_type);
2317         media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
2318         ret = _media_util_get_store_type_by_path(dst_path, &dst_storage_type);
2319         media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
2320
2321         ret = media_svc_move_item(_content_get_db_handle(), src_storage_type, _media->file_path, dst_storage_type, dst_path);
2322         return _content_error_capi(MEDIA_CONTENT_TYPE, ret);
2323 }
2324
2325 int media_info_create_thumbnail(media_info_h media, media_thumbnail_completed_cb callback, void *user_data)
2326 {
2327         int ret = MEDIA_CONTENT_ERROR_NONE;
2328         media_info_s *_media = (media_info_s*)media;
2329
2330         if(_media != NULL && STRING_VALID(_media->media_id) && STRING_VALID(_media->file_path))
2331         {
2332                 media_thumbnail_cb_s *_thumb_cb = (media_thumbnail_cb_s*)calloc(1, sizeof(media_thumbnail_cb_s));
2333                 _thumb_cb->handle = _media;
2334                 _thumb_cb->user_data = user_data;
2335                 _thumb_cb->thumbnail_completed_cb = callback;
2336
2337                 ret = thumbnail_request_from_db_async(_media->file_path, (ThumbFunc)__media_info_thumbnail_completed_cb, (void *)_thumb_cb);
2338                 _content_error_capi(MEDIA_THUMBNAIL_TYPE, ret);
2339         }
2340         else
2341         {
2342                 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
2343                 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
2344         }
2345
2346         return ret;
2347 }