Remove media_type condition to support not only cloud but also normal content
[platform/core/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 #include <media_info.h>
18 #include <media-thumbnail.h>
19 #include <media_info_private.h>
20 #include <media_util_private.h>
21
22 static void __media_info_insert_completed_cb(media_request_result_s *result, void *user_data);
23 static void __media_info_thumbnail_completed_cb(int error, const char *path, void *user_data);
24 static bool __media_info_delete_batch_cb(media_info_h media, void *user_data);
25 static int __media_info_insert_batch(media_batch_insert_e insert_type, const char **path_array, unsigned int array_length, media_insert_completed_cb completed_cb, void *user_data);
26
27 static int __media_info_get_media_path_by_id_from_db(const char *media_id, char **path)
28 {
29         int ret = MEDIA_CONTENT_ERROR_NONE;
30         sqlite3_stmt *stmt = NULL;
31         char *select_query = NULL;
32
33         media_content_retvm_if(!STRING_VALID(media_id), MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "invalid media_id");
34
35         select_query = sqlite3_mprintf(SELECT_MEDIA_PATH_BY_ID, media_id);
36
37         ret = _content_query_prepare(&stmt, select_query, NULL, NULL);
38         SQLITE3_SAFE_FREE(select_query);
39         media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
40
41         if(sqlite3_step(stmt) == SQLITE_ROW)
42         {
43                 if(STRING_VALID((const char *)sqlite3_column_text(stmt, 0)))
44                         *path = strdup((const char *)sqlite3_column_text(stmt, 0));
45         } else {
46                 media_content_error("There's no media with this ID : %s", media_id);
47                 *path = NULL;
48                 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
49         }
50
51         SQLITE3_FINALIZE(stmt);
52
53         return ret;
54 }
55
56 static void __media_info_insert_completed_cb(media_request_result_s *result, void *user_data)
57 {
58         int ret = MEDIA_CONTENT_ERROR_NONE;
59         media_insert_cb_s *_cb_data = (media_insert_cb_s *)user_data;
60
61         if (_cb_data) {
62                 if (result) {
63                         ret = _content_error_capi(MEDIA_CONTENT_TYPE, result->result);
64                 }
65
66                 if (_cb_data->insert_completed_cb)
67                         _cb_data->insert_completed_cb(ret, _cb_data->user_data);
68
69                 if (STRING_VALID(_cb_data->insert_list_path)) {
70                         if (unlink(_cb_data->insert_list_path) < 0) {
71                                 media_content_stderror("failed to delete");
72                         }
73                         SAFE_FREE(_cb_data->insert_list_path);
74                 }
75         }
76
77         SAFE_FREE(_cb_data);
78
79         return;
80 }
81
82 static void __media_info_thumbnail_completed_cb(int error, const char *path, void *user_data)
83 {
84         int error_value = MEDIA_CONTENT_ERROR_NONE;
85
86         media_thumbnail_cb_s *_thumb_cb = (media_thumbnail_cb_s *)user_data;
87         media_info_s *media = NULL;
88
89         if(_thumb_cb != NULL)
90         {
91                 media = _thumb_cb->handle;
92                 if((media != NULL) && STRING_VALID(path))
93                 {
94                         SAFE_FREE(media->thumbnail_path);
95                         media->thumbnail_path = strdup(path);
96                 }
97
98                 media_content_debug("error [%d], thumbnail_path [%s]", error, path);
99                 error_value = _content_error_capi(MEDIA_THUMBNAIL_TYPE, error);
100                 if (_thumb_cb->thumbnail_completed_cb)
101                         _thumb_cb->thumbnail_completed_cb(error_value, path, _thumb_cb->user_data);
102         }
103
104         SAFE_FREE(_thumb_cb);
105
106         return;
107 }
108
109 static bool __media_info_delete_batch_cb(media_info_h media, void *user_data)
110 {
111         int err = MEDIA_CONTENT_ERROR_NONE;
112         char *thumb_path = NULL;
113         media_content_type_e media_type = 0;
114         GArray *thumb_list = (GArray *)user_data;
115
116         if(media == NULL)
117         {
118                 media_content_debug("NO Item");
119                 return true;
120         }
121
122         err = media_info_get_media_type(media, &media_type);
123         if (err == MEDIA_CONTENT_ERROR_NONE) {
124                 media_content_debug("media_type : [%d]", media_type);
125
126                 media_info_get_thumbnail_path(media, &thumb_path);
127                 if (STRING_VALID(thumb_path)) {
128                         if (strncmp(MEDIA_CONTENT_THUMB_DEFAULT_PATH, thumb_path, strlen(MEDIA_CONTENT_THUMB_DEFAULT_PATH)) != 0) {
129                                 g_array_append_val(thumb_list, thumb_path);
130                         }
131                 }
132         } else {
133                 media_content_error("media_info_get_media_type failed");
134         }
135
136         return true;
137 }
138
139 static int __media_info_insert_batch(media_batch_insert_e insert_type, const char **path_array,
140                                         unsigned int array_length,
141                                         media_insert_completed_cb completed_cb,
142                                         void *user_data)
143 {
144         int ret = MEDIA_CONTENT_ERROR_NONE;
145         FILE *fp = NULL;
146         char list_path[255] = {0, };
147         unsigned int idx = 0;
148         int nwrites = 0;
149
150         for (idx = 0; idx < BATCH_REQUEST_MAX; idx++) {
151                 snprintf(list_path, sizeof(list_path), "%s/request-%ld-%d", MEDIA_CONTENT_INSERT_FILES_PATH, media_content_gettid(), idx);
152
153                 if (g_file_test(list_path, G_FILE_TEST_EXISTS | G_FILE_TEST_IS_REGULAR)) {
154                         memset(list_path, 0x00, sizeof(list_path));
155                         continue;
156                 } else {
157                         media_content_debug("The request file list path : %s", list_path);
158                         break;
159                 }
160         }
161
162         if (idx == BATCH_REQUEST_MAX) {
163                 media_content_error("Too many batch request for one thread");
164                 return MEDIA_CONTENT_ERROR_DB_BUSY;
165         }
166
167         fp = fopen(list_path, "w");
168         if (fp == NULL) {
169                 media_content_error("failed to open file : [%s]", list_path);
170                 media_content_stderror("failed to open file");
171                 return MEDIA_CONTENT_ERROR_INVALID_OPERATION;
172         }
173
174         for (idx = 0; idx < array_length; idx++) {
175                 if (STRING_VALID(path_array[idx])) {
176                         int size = strlen(path_array[idx]);
177
178                         ret = _media_util_check_file_exist(path_array[idx]);
179                         if (ret != MEDIA_CONTENT_ERROR_NONE) {
180                                 fclose(fp);
181                                 if (unlink(list_path) < 0) {
182                                         media_content_stderror("failed to delete");
183                                 }
184                                 return ret;
185                         }
186
187                         nwrites = fwrite(path_array[idx], 1, size, fp);
188                         if (nwrites != size) {
189                                 media_content_stderror("failed to write");
190                                 fclose(fp);
191                                 if (unlink(list_path) < 0) {
192                                         media_content_stderror("failed to delete");
193                                 }
194                                 return MEDIA_CONTENT_ERROR_INVALID_OPERATION;
195                         }
196
197                         nwrites = fwrite("\n", 1, 1, fp);
198                         if (nwrites != 1) {
199                                 media_content_stderror("failed to write");
200                                 fclose(fp);
201                                 if (unlink(list_path) < 0) {
202                                         media_content_stderror("failed to delete");
203                                 }
204                                 return MEDIA_CONTENT_ERROR_INVALID_OPERATION;
205                         }
206                 } else {
207                         media_content_error("path[%d] is invalid string", idx);
208                 }
209         }
210
211         fclose(fp);
212
213         media_insert_cb_s *_cb_data = (media_insert_cb_s *)calloc(1, sizeof(media_insert_cb_s));
214         media_content_retvm_if(_cb_data == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
215
216         _cb_data->insert_completed_cb = completed_cb;
217         _cb_data->user_data = user_data;
218         _cb_data->insert_list_path = strdup(list_path);
219
220         if(insert_type == MEDIA_BATCH_INSERT_NORMAL)
221                 ret = media_files_register(list_path, __media_info_insert_completed_cb, _cb_data, tzplatform_getuid(TZ_USER_NAME));
222         else if(insert_type == MEDIA_BATCH_INSERT_BURSTSHOT)
223                 ret = media_burstshot_register(list_path, __media_info_insert_completed_cb, _cb_data, tzplatform_getuid(TZ_USER_NAME));
224         else
225                 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
226
227         if (ret != MEDIA_CONTENT_ERROR_NONE) {
228                 media_content_error("media_files_register failed : %d", ret);
229                 if (unlink(list_path) < 0) {
230                         media_content_stderror("failed to delete");
231                 }
232                 return _content_error_capi(MEDIA_CONTENT_TYPE, ret);
233         }
234
235         return ret;
236 }
237
238 void _media_info_item_get_detail(sqlite3_stmt* stmt, media_info_h media)
239 {
240         media_info_s *_media = (media_info_s*)media;
241
242         if(STRING_VALID((const char *)sqlite3_column_text(stmt, MEDIA_INFO_UUID)))
243                 _media->media_id = strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_UUID));
244
245         if(STRING_VALID((const char *)sqlite3_column_text(stmt, MEDIA_INFO_PATH)))
246                 _media->file_path = strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_PATH));
247
248         if(STRING_VALID((const char *)sqlite3_column_text(stmt, MEDIA_INFO_FILE_NAME)))
249                 _media->display_name = strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_FILE_NAME));
250
251         _media->media_type = (int)sqlite3_column_int(stmt, MEDIA_INFO_TYPE);
252
253         if(STRING_VALID((const char *)sqlite3_column_text(stmt, MEDIA_INFO_MIME_TYPE)))
254                 _media->mime_type = strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_MIME_TYPE));
255
256         _media->size = (unsigned long long)sqlite3_column_int64(stmt, MEDIA_INFO_SIZE);
257
258         _media->added_time = (int)sqlite3_column_int(stmt, MEDIA_INFO_ADDED_TIME);
259
260         _media->modified_time = (int)sqlite3_column_int(stmt, MEDIA_INFO_MODIFIED_TIME);
261
262         if(STRING_VALID((const char *)sqlite3_column_text(stmt, MEDIA_INFO_THUMBNAIL_PATH)))
263                 _media->thumbnail_path= strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_THUMBNAIL_PATH));
264
265         if(STRING_VALID((const char *)sqlite3_column_text(stmt, MEDIA_INFO_DESCRIPTION)))
266                 _media->description = strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_DESCRIPTION));
267
268         _media->rating = (int)sqlite3_column_int(stmt, MEDIA_INFO_RATING);
269
270         _media->favourite = (int)sqlite3_column_int(stmt, MEDIA_INFO_FAVOURITE);
271
272         if(STRING_VALID((const char *)sqlite3_column_text(stmt, MEDIA_INFO_AUTHOR)))
273                 _media->author = strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_AUTHOR));
274
275         if(STRING_VALID((const char *)sqlite3_column_text(stmt, MEDIA_INFO_PROVIDER)))
276                 _media->provider = strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_PROVIDER));
277
278         if(STRING_VALID((const char *)sqlite3_column_text(stmt, MEDIA_INFO_CONTENT_NAME)))
279                 _media->content_name = strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_CONTENT_NAME));
280
281         if(STRING_VALID((const char *)sqlite3_column_text(stmt, MEDIA_INFO_CATEGORY)))
282                 _media->category = strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_CATEGORY));
283
284         if(STRING_VALID((const char *)sqlite3_column_text(stmt, MEDIA_INFO_LOCATION_TAG)))
285                 _media->location_tag = strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_LOCATION_TAG));
286
287         if(STRING_VALID((const char *)sqlite3_column_text(stmt, MEDIA_INFO_AGE_RATING)))
288                 _media->age_rating = strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_AGE_RATING));
289
290         if(STRING_VALID((const char *)sqlite3_column_text(stmt, MEDIA_INFO_KEYWORD)))
291                 _media->keyword = strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_KEYWORD));
292
293         _media->is_drm = (int)sqlite3_column_int(stmt, MEDIA_INFO_IS_DRM);
294
295         _media->storage_type = (int)sqlite3_column_int(stmt, MEDIA_INFO_STORAGE_TYPE);
296
297         _media->longitude = (double)sqlite3_column_double(stmt, MEDIA_INFO_LONGITUDE);
298         _media->latitude = (double)sqlite3_column_double(stmt, MEDIA_INFO_LATITUDE);
299         _media->altitude = (double)sqlite3_column_double(stmt, MEDIA_INFO_ALTITUDE);
300
301         _media->played_count = sqlite3_column_int(stmt, MEDIA_INFO_PLAYED_COUNT);
302         _media->played_time = sqlite3_column_int(stmt, MEDIA_INFO_LAST_PLAYED_TIME);
303         _media->played_position = sqlite3_column_int(stmt, MEDIA_INFO_LAST_PLAYED_POSITION);
304
305         if(STRING_VALID((const char *)sqlite3_column_text(stmt, MEDIA_INFO_TITLE)))
306                 _media->title = strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_TITLE));
307
308         _media->timeline = (double)sqlite3_column_double(stmt, MEDIA_INFO_TIMELINE);
309
310         if(STRING_VALID((const char *)sqlite3_column_text(stmt, MEDIA_INFO_WEATHER)))
311                 _media->weather = strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_WEATHER));
312
313         _media->sync_status = (int)sqlite3_column_int(stmt, MEDIA_INFO_SYNC_STATUS);
314
315         if(STRING_VALID((const char *)sqlite3_column_text(stmt, MEDIA_INFO_STORAGE_UUID)))
316                 _media->storage_uuid = strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_STORAGE_UUID));
317
318         if(_media->media_type == MEDIA_CONTENT_TYPE_IMAGE) {
319                 _media->image_meta = (image_meta_s *)calloc(1, sizeof(image_meta_s));
320                 if(_media->image_meta) {
321                         if(STRING_VALID(_media->media_id))
322                                 _media->image_meta->media_id = strdup(_media->media_id);
323
324                         _media->image_meta->width = sqlite3_column_int(stmt, MEDIA_INFO_WIDTH);
325                         _media->image_meta->height = sqlite3_column_int(stmt, MEDIA_INFO_HEIGHT);
326                         _media->image_meta->fnumber = (double)sqlite3_column_double(stmt, MEDIA_INFO_FNUMBER);
327                         _media->image_meta->iso = sqlite3_column_int(stmt, MEDIA_INFO_ISO);
328
329                         if(STRING_VALID((const char *)sqlite3_column_text(stmt, MEDIA_INFO_DATETAKEN)))
330                                 _media->image_meta->date_taken = strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_DATETAKEN));
331
332                         _media->image_meta->orientation = sqlite3_column_int(stmt, MEDIA_INFO_ORIENTATION);
333
334                         if(STRING_VALID((const char *)sqlite3_column_text(stmt, MEDIA_INFO_TITLE)))
335                                 _media->image_meta->title = strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_TITLE));
336
337                         if(STRING_VALID((const char *)sqlite3_column_text(stmt, MEDIA_INFO_BURST_ID)))
338                                 _media->image_meta->burst_id = strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_BURST_ID));
339
340                         if(STRING_VALID((const char *)sqlite3_column_text(stmt, MEDIA_INFO_WEATHER)))
341                                 _media->image_meta->weather = strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_WEATHER));
342
343                         if(STRING_VALID((const char *)sqlite3_column_text(stmt, MEDIA_INFO_EXPOSURE_TIME)))
344                                 _media->image_meta->exposure_time = strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_EXPOSURE_TIME));
345
346                         if(STRING_VALID((const char *)sqlite3_column_text(stmt, MEDIA_INFO_MODEL)))
347                                 _media->image_meta->model = strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_MODEL));
348                 }
349
350         } else if(_media->media_type == MEDIA_CONTENT_TYPE_VIDEO) {
351                 _media->video_meta = (video_meta_s *)calloc(1, sizeof(video_meta_s));
352                 if(_media->video_meta) {
353                         if(STRING_VALID(_media->media_id))
354                                 _media->video_meta->media_id = strdup(_media->media_id);
355
356                         _media->video_meta->width = sqlite3_column_int(stmt, MEDIA_INFO_WIDTH);
357                         _media->video_meta->height = sqlite3_column_int(stmt, MEDIA_INFO_HEIGHT);
358
359                         if(STRING_VALID((const char *)sqlite3_column_text(stmt, MEDIA_INFO_TITLE)))
360                                 _media->video_meta->title = strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_TITLE));
361
362                         if(STRING_VALID((const char *)sqlite3_column_text(stmt, MEDIA_INFO_ALBUM)))
363                                 _media->video_meta->album = strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_ALBUM));
364
365                         if(STRING_VALID((const char *)sqlite3_column_text(stmt, MEDIA_INFO_ARTIST)))
366                                 _media->video_meta->artist = strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_ARTIST));
367
368                         if(STRING_VALID((const char *)sqlite3_column_text(stmt, MEDIA_INFO_ALBUM_ARTIST)))
369                                 _media->video_meta->album_artist = strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_ALBUM_ARTIST));
370
371                         if(STRING_VALID((const char *)sqlite3_column_text(stmt, MEDIA_INFO_GENRE)))
372                                 _media->video_meta->genre = strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_GENRE));
373
374                         if(STRING_VALID((const char *)sqlite3_column_text(stmt, MEDIA_INFO_COMPOSER)))
375                                 _media->video_meta->composer = strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_COMPOSER));
376
377                         if(STRING_VALID((const char *)sqlite3_column_text(stmt, MEDIA_INFO_YEAR)))
378                                 _media->video_meta->year = strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_YEAR));
379
380                         if(STRING_VALID((const char *)sqlite3_column_text(stmt, MEDIA_INFO_RECORDED_DATE)))
381                                 _media->video_meta->recorded_date = strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_RECORDED_DATE));
382
383                         if(STRING_VALID((const char *)sqlite3_column_text(stmt, MEDIA_INFO_COPYRIGHT)))
384                                 _media->video_meta->copyright = strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_COPYRIGHT));
385
386                         if(STRING_VALID((const char *)sqlite3_column_text(stmt, MEDIA_INFO_TRACK_NUM)))
387                                 _media->video_meta->track_num = strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_TRACK_NUM));
388
389                         _media->video_meta->bitrate = sqlite3_column_int(stmt, MEDIA_INFO_BITRATE);
390                         _media->video_meta->duration = sqlite3_column_int(stmt, MEDIA_INFO_DURATION);
391                         _media->video_meta->played_count = sqlite3_column_int(stmt, MEDIA_INFO_PLAYED_COUNT);
392                         _media->video_meta->played_time = sqlite3_column_int(stmt, MEDIA_INFO_LAST_PLAYED_TIME);
393                         _media->video_meta->played_position = sqlite3_column_int(stmt, MEDIA_INFO_LAST_PLAYED_POSITION);
394                 }
395
396         }
397         else if((_media->media_type == MEDIA_CONTENT_TYPE_MUSIC) || (_media->media_type == MEDIA_CONTENT_TYPE_SOUND)) {
398                 _media->audio_meta = (audio_meta_s *)calloc(1, sizeof(audio_meta_s));
399                 if(_media->audio_meta) {
400                         if(STRING_VALID(_media->media_id))
401                                 _media->audio_meta->media_id = strdup(_media->media_id);
402
403                         if(STRING_VALID((const char *)sqlite3_column_text(stmt, MEDIA_INFO_TITLE)))
404                                 _media->audio_meta->title = strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_TITLE));
405
406                         if(STRING_VALID((const char *)sqlite3_column_text(stmt, MEDIA_INFO_ALBUM)))
407                                 _media->audio_meta->album = strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_ALBUM));
408
409                         if(STRING_VALID((const char *)sqlite3_column_text(stmt, MEDIA_INFO_ARTIST)))
410                                 _media->audio_meta->artist = strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_ARTIST));
411
412                         if(STRING_VALID((const char *)sqlite3_column_text(stmt, MEDIA_INFO_ALBUM_ARTIST)))
413                                 _media->audio_meta->album_artist = strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_ALBUM_ARTIST));
414
415                         if(STRING_VALID((const char *)sqlite3_column_text(stmt, MEDIA_INFO_GENRE)))
416                                 _media->audio_meta->genre = strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_GENRE));
417
418                         if(STRING_VALID((const char *)sqlite3_column_text(stmt, MEDIA_INFO_COMPOSER)))
419                                 _media->audio_meta->composer = strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_COMPOSER));
420
421                         if(STRING_VALID((const char *)sqlite3_column_text(stmt, MEDIA_INFO_YEAR)))
422                                 _media->audio_meta->year = strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_YEAR));
423
424                         if(STRING_VALID((const char *)sqlite3_column_text(stmt, MEDIA_INFO_RECORDED_DATE)))
425                                 _media->audio_meta->recorded_date = strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_RECORDED_DATE));
426
427                         if(STRING_VALID((const char *)sqlite3_column_text(stmt, MEDIA_INFO_COPYRIGHT)))
428                                 _media->audio_meta->copyright = strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_COPYRIGHT));
429
430                         if(STRING_VALID((const char *)sqlite3_column_text(stmt, MEDIA_INFO_TRACK_NUM)))
431                                 _media->audio_meta->track_num = strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_TRACK_NUM));
432
433                         _media->audio_meta->bitrate = sqlite3_column_int(stmt, MEDIA_INFO_BITRATE);
434                         _media->audio_meta->bitpersample = sqlite3_column_int(stmt, MEDIA_INFO_BITPERSAMPLE);
435                         _media->audio_meta->duration = sqlite3_column_int(stmt, MEDIA_INFO_DURATION);
436                         _media->audio_meta->played_count = sqlite3_column_int(stmt, MEDIA_INFO_PLAYED_COUNT);
437                         _media->audio_meta->played_time = sqlite3_column_int(stmt, MEDIA_INFO_LAST_PLAYED_TIME);
438                         _media->audio_meta->played_position = sqlite3_column_int(stmt, MEDIA_INFO_LAST_PLAYED_POSITION);
439                         _media->audio_meta->samplerate = sqlite3_column_int(stmt, MEDIA_INFO_SAMPLERATE);
440                         _media->audio_meta->channel = sqlite3_column_int(stmt, MEDIA_INFO_CHANNEL);
441                 }
442         }
443 }
444
445 int _media_info_get_media_info_from_db(const char *path, const char *storage_id, media_info_h media)
446 {
447         int ret = MEDIA_CONTENT_ERROR_NONE;
448         sqlite3_stmt *stmt = NULL;
449         char *select_query = NULL;
450         media_info_s *_media = (media_info_s*)media;
451
452         media_content_retvm_if(_media == NULL, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "invalid media");
453
454         select_query = sqlite3_mprintf(SELECT_MEDIA_BY_PATH, storage_id, path);
455
456         ret = _content_query_prepare(&stmt, select_query, NULL, NULL);
457         SQLITE3_SAFE_FREE(select_query);
458         media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
459
460         if(sqlite3_step(stmt) == SQLITE_ROW)
461         {
462                 _media_info_item_get_detail(stmt, (media_info_h)_media);
463         } else {
464                 media_content_error("There's no media!!");
465                 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
466         }
467
468         SQLITE3_FINALIZE(stmt);
469
470         return ret;
471 }
472
473 int media_info_insert_to_db(const char *path, media_info_h *info)
474 {
475         bool ignore_file = FALSE;
476         bool ignore_dir = FALSE;
477         char *folder_path = NULL;
478         char storage_id[MEDIA_CONTENT_UUID_SIZE+1] = {0, };
479         int ret = MEDIA_CONTENT_ERROR_NONE;
480
481         media_content_retvm_if(!STRING_VALID(path), MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "invalid path");
482         media_content_retvm_if(info == NULL, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "invalid info");
483
484         ret = _media_util_check_ignore_file(path, &ignore_file);
485         media_content_retvm_if(ignore_file == TRUE, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid path");
486
487         ret = _media_util_check_file_exist(path);
488         media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
489
490         folder_path = g_path_get_dirname(path);
491         ret = _media_util_check_ignore_dir(folder_path, &ignore_dir);
492         SAFE_FREE(folder_path);
493
494         media_content_retvm_if(ignore_dir == TRUE, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid folder path");
495
496         memset(storage_id, 0x00, sizeof(storage_id));
497         ret = media_svc_get_storage_id(_content_get_db_handle(), path, storage_id);
498         if(ret != MS_MEDIA_ERR_NONE)
499         {
500                 media_content_error("media_svc_get_storage_id failed : %d", ret);
501                 return _content_error_capi(MEDIA_CONTENT_TYPE, ret);
502         }
503
504         ret = media_svc_check_item_exist_by_path(_content_get_db_handle(), storage_id, path);
505         if (ret == MS_MEDIA_ERR_DB_NO_RECORD) {
506                 media_content_sec_debug("media_svc_check_item_exist_by_path : no record : %s", path);
507
508                 media_svc_storage_type_e storage_type = 0;
509
510                 ret = media_svc_get_storage_type(path, &storage_type, tzplatform_getuid(TZ_USER_NAME));
511                 if(ret != MS_MEDIA_ERR_NONE) {
512                         media_content_sec_error("media_svc_get_storage_type failed : %d", ret);
513                         return _content_error_capi(MEDIA_CONTENT_TYPE, ret);
514                 }
515
516                 ret = media_svc_insert_item_immediately(_content_get_db_handle(), storage_id, storage_type, path, tzplatform_getuid(TZ_USER_NAME));
517
518                 if(ret != MS_MEDIA_ERR_NONE) {
519                         if (ret == MS_MEDIA_ERR_DB_CONSTRAINT_FAIL) {
520                                 media_content_sec_error("This item is already inserted. This may be normal operation because other process already did this (%s)", path);
521                                 ret = MEDIA_CONTENT_ERROR_NONE;
522                         } else {
523                                 media_content_sec_error("media_svc_insert_item_immediately failed : %d (%s)", ret, path);
524                         }
525
526                         return _content_error_capi(MEDIA_CONTENT_TYPE, ret);
527                 }
528         } else if (ret != MS_MEDIA_ERR_NONE) {
529                 media_content_sec_error("media_svc_check_item_exist_by_path failed : %d (%s)", ret, path);
530                 return _content_error_capi(MEDIA_CONTENT_TYPE, ret);
531         }
532
533         media_info_s *_media = (media_info_s*)calloc(1, sizeof(media_info_s));
534         media_content_retvm_if(_media == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
535
536         ret = _media_info_get_media_info_from_db(path, DEFAULT_MEDIA_STORAGE_ID, (media_info_h)_media);
537
538         *info = (media_info_h)_media;
539         return ret;
540 }
541
542 int media_info_insert_batch_to_db(
543                                         const char **path_array,
544                                         unsigned int array_length,
545                                         media_insert_completed_cb completed_cb,
546                                         void *user_data)
547 {
548         media_content_retvm_if(path_array == NULL, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid path_array");
549         media_content_retvm_if(array_length <= 0, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid array_length");
550
551         return __media_info_insert_batch(MEDIA_BATCH_INSERT_NORMAL, path_array, array_length, completed_cb, user_data);
552 }
553
554 int media_info_insert_burst_shot_to_db(const char **path_array, unsigned int array_length, media_insert_burst_shot_completed_cb callback, void *user_data)
555 {
556         media_content_retvm_if(path_array == NULL, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid path_array");
557         media_content_retvm_if(array_length <= 0, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid array_length");
558
559         return __media_info_insert_batch(MEDIA_BATCH_INSERT_BURSTSHOT, path_array, array_length, callback, user_data);
560 }
561
562 int media_info_delete_from_db(const char *media_id)
563 {
564         int ret = MEDIA_CONTENT_ERROR_NONE;
565         char *path = NULL;
566         char storage_id[MEDIA_CONTENT_UUID_SIZE+1] = {0, };
567
568         if(!STRING_VALID(media_id))
569         {
570                 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
571                 return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
572         }
573
574         memset(storage_id, 0x00, sizeof(storage_id));
575
576         ret = __media_info_get_media_path_by_id_from_db(media_id, &path);
577         if(ret != MEDIA_CONTENT_ERROR_NONE) {
578                 media_content_error("__media_info_get_media_path_by_id_from_db failed : %d", ret);
579                 SAFE_FREE(path);
580                 return ret;
581         }
582
583         ret = _media_db_get_storage_id_by_media_id(media_id, storage_id);
584         if(ret != MEDIA_CONTENT_ERROR_NONE) {
585                 media_content_error("_media_db_get_storage_id_by_media_id failed : %d", ret);
586                 SAFE_FREE(path);
587                 return ret;
588         }
589
590         ret = media_svc_delete_item_by_path(_content_get_db_handle(), storage_id, path, tzplatform_getuid(TZ_USER_NAME));
591         SAFE_FREE(path);
592
593         return _content_error_capi(MEDIA_CONTENT_TYPE, ret);
594 }
595
596 static int __media_info_delete_thumb_from_list(GArray *thumb_list)
597 {
598         int i = 0;
599         int list_len = 0;
600         char *thumb_path = NULL;
601
602         if (thumb_list != NULL) {
603
604                 list_len = thumb_list->len;
605
606                 for (i = 0; i < list_len; i ++) {
607                         thumb_path = g_array_index(thumb_list, char*, i);
608                         media_content_debug("thumb path [%s]", thumb_path);
609                         if (unlink(thumb_path) < 0) {
610                                 media_content_stderror("failed to delete");
611                         }
612                 }
613         }
614         return MEDIA_CONTENT_ERROR_NONE;
615 }
616
617 static int __media_info_release_thumb_list(GArray *thumb_list)
618 {
619         int i = 0;
620         int list_len = 0;
621         char *thumb_path = NULL;
622
623         if (thumb_list != NULL) {
624
625                 list_len = thumb_list->len;
626
627                 for (i = 0; i < list_len; i ++) {
628                         thumb_path = g_array_index(thumb_list, char*, 0);
629                         g_array_remove_index(thumb_list,0);
630                         SAFE_FREE(thumb_path);
631                 }
632
633                 g_array_free(thumb_list, FALSE);
634         }
635
636         return MEDIA_CONTENT_ERROR_NONE;
637 }
638
639 int media_info_delete_batch_from_db(filter_h filter)
640 {
641         int ret = MEDIA_CONTENT_ERROR_NONE;
642
643         char *query_string = NULL;
644         filter_s *_filter = NULL;
645         attribute_h attr;
646         char *condition_query = NULL;
647         GArray *thumb_list = NULL;
648
649         media_content_retvm_if(filter == NULL, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid filter");
650
651         thumb_list = g_array_new(FALSE, FALSE, sizeof(char*));
652
653         /* Delete thumbnail of each item */
654         ret = _media_db_get_group_item(NULL, filter, __media_info_delete_batch_cb, thumb_list, MEDIA_GROUP_NONE);
655
656         _filter = (filter_s*)filter;
657         attr = _content_get_attirbute_handle();
658
659         if(_filter->condition)
660         {
661                 ret = _media_filter_attribute_generate(attr, _filter->condition, _filter->condition_collate_type, &condition_query);
662                 if (ret != MEDIA_CONTENT_ERROR_NONE) {
663                         __media_info_release_thumb_list(thumb_list);
664                         return ret;
665                 }
666         }
667
668         if(STRING_VALID(condition_query))
669         {
670                 if (_filter->storage_id == NULL) {
671                         /*FIX ME*/
672                         query_string = sqlite3_mprintf(DELETE_MEDIA_FROM_MEDIA_BATCH, "media", condition_query);
673                 } else {
674                         query_string = sqlite3_mprintf(DELETE_MEDIA_FROM_MEDIA_BATCH, _filter->storage_id, condition_query);
675                 }
676         }
677         else
678         {
679                 SAFE_FREE(condition_query);
680                 __media_info_release_thumb_list(thumb_list);
681
682                 return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
683         }
684
685         ret = _content_query_sql(query_string);
686         if (ret == MEDIA_CONTENT_ERROR_NONE) {
687                 /*  Send notification for this
688                         In this case, send noti for internal storage and external storage
689                 */
690                 media_content_debug("Batch deletion is successfull. Send notification for this");
691                 if (_filter->storage_id != NULL) {
692                         char *storage_path = NULL;
693                         media_svc_get_storage_path(_content_get_db_handle(), _filter->storage_id, &storage_path);
694                         if (STRING_VALID(storage_path))
695                                 media_svc_publish_noti(_content_get_db_handle(), MS_MEDIA_ITEM_DIRECTORY, MS_MEDIA_ITEM_UPDATE, storage_path, -1, NULL, NULL);
696
697                         SAFE_FREE(storage_path);
698                 } else {
699                         /*FIX ME*/
700                         media_svc_publish_noti(_content_get_db_handle(), MS_MEDIA_ITEM_DIRECTORY, MS_MEDIA_ITEM_UPDATE, MEDIA_ROOT_PATH_INTERNAL, -1, NULL, NULL);
701                         media_svc_publish_noti(_content_get_db_handle(), MS_MEDIA_ITEM_DIRECTORY, MS_MEDIA_ITEM_UPDATE, MEDIA_ROOT_PATH_SDCARD, -1, NULL, NULL);
702                 }
703
704                 __media_info_delete_thumb_from_list(thumb_list);
705                 __media_info_release_thumb_list(thumb_list);
706         }
707
708         SAFE_FREE(condition_query);
709         SQLITE3_SAFE_FREE(query_string);
710
711         return ret;
712 }
713
714 int media_info_destroy(media_info_h media)
715 {
716         int ret = MEDIA_CONTENT_ERROR_NONE;
717         media_info_s *_media = (media_info_s*)media;
718
719         if(_media)
720         {
721                 SAFE_FREE(_media->media_id);
722                 SAFE_FREE(_media->file_path);
723                 SAFE_FREE(_media->display_name);
724                 SAFE_FREE(_media->mime_type);
725                 SAFE_FREE(_media->thumbnail_path);
726                 SAFE_FREE(_media->description);
727                 SAFE_FREE(_media->author);
728                 SAFE_FREE(_media->provider);
729                 SAFE_FREE(_media->content_name);
730                 SAFE_FREE(_media->category);
731                 SAFE_FREE(_media->location_tag);
732                 SAFE_FREE(_media->age_rating);
733                 SAFE_FREE(_media->keyword);
734                 SAFE_FREE(_media->title);
735                 SAFE_FREE(_media->weather);
736                 SAFE_FREE(_media->storage_uuid);
737
738                 if(_media->image_meta) {
739                         SAFE_FREE(_media->image_meta->media_id);
740                         SAFE_FREE(_media->image_meta->date_taken);
741                         SAFE_FREE(_media->image_meta->burst_id);
742                         SAFE_FREE(_media->image_meta->exposure_time);
743                         SAFE_FREE(_media->image_meta->model);
744                         SAFE_FREE(_media->image_meta->title);
745                         SAFE_FREE(_media->image_meta->weather);
746
747                         SAFE_FREE(_media->image_meta);
748                 }
749
750                 if(_media->video_meta) {
751                         SAFE_FREE(_media->video_meta->media_id);
752                         SAFE_FREE(_media->video_meta->title);
753                         SAFE_FREE(_media->video_meta->album);
754                         SAFE_FREE(_media->video_meta->artist);
755                         SAFE_FREE(_media->video_meta->album_artist);
756                         SAFE_FREE(_media->video_meta->genre);
757                         SAFE_FREE(_media->video_meta->composer);
758                         SAFE_FREE(_media->video_meta->year);
759                         SAFE_FREE(_media->video_meta->recorded_date);
760                         SAFE_FREE(_media->video_meta->copyright);
761                         SAFE_FREE(_media->video_meta->track_num);
762
763                         SAFE_FREE(_media->video_meta);
764                 }
765
766                 if(_media->audio_meta) {
767                         SAFE_FREE(_media->audio_meta->media_id);
768                         SAFE_FREE(_media->audio_meta->title);
769                         SAFE_FREE(_media->audio_meta->album);
770                         SAFE_FREE(_media->audio_meta->artist);
771                         SAFE_FREE(_media->audio_meta->album_artist);
772                         SAFE_FREE(_media->audio_meta->genre);
773                         SAFE_FREE(_media->audio_meta->composer);
774                         SAFE_FREE(_media->audio_meta->year);
775                         SAFE_FREE(_media->audio_meta->recorded_date);
776                         SAFE_FREE(_media->audio_meta->copyright);
777                         SAFE_FREE(_media->audio_meta->track_num);
778
779                         SAFE_FREE(_media->audio_meta);
780                 }
781
782                 SAFE_FREE(_media);
783
784                 ret = MEDIA_CONTENT_ERROR_NONE;
785         }
786         else
787         {
788                 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
789                 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
790         }
791
792         return ret;
793 }
794
795 int media_info_clone(media_info_h *dst, media_info_h src)
796 {
797         int ret = MEDIA_CONTENT_ERROR_NONE;
798         media_info_s *_src = (media_info_s*)src;
799
800
801         if(_src != NULL)
802         {
803                 media_info_s *_dst = (media_info_s*)calloc(1, sizeof(media_info_s));
804                 media_content_retvm_if(_dst == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
805
806                 if(STRING_VALID(_src->media_id))
807                 {
808                         _dst->media_id = strdup(_src->media_id);
809                         if(_dst->media_id == 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                 if(STRING_VALID(_src->file_path))
817                 {
818                         _dst->file_path = strdup(_src->file_path);
819                         if(_dst->file_path == NULL)
820                         {
821                                 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
822                                 media_info_destroy((media_info_h)_dst);
823                                 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
824                         }
825                 }
826                 if(STRING_VALID(_src->display_name))
827                 {
828                         _dst->display_name = strdup(_src->display_name);
829                         if(_dst->display_name == NULL)
830                         {
831                                 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
832                                 media_info_destroy((media_info_h)_dst);
833                                 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
834                         }
835                 }
836                 if(STRING_VALID(_src->mime_type))
837                 {
838                         _dst->mime_type = strdup(_src->mime_type);
839                         if(_dst->mime_type == NULL)
840                         {
841                                 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
842                                 media_info_destroy((media_info_h)_dst);
843                                 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
844                         }
845                 }
846                 if(STRING_VALID(_src->thumbnail_path))
847                 {
848                         _dst->thumbnail_path = strdup(_src->thumbnail_path);
849                         if(_dst->thumbnail_path == NULL)
850                         {
851                                 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
852                                 media_info_destroy((media_info_h)_dst);
853                                 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
854                         }
855                 }
856                 if(STRING_VALID(_src->description))
857                 {
858                         _dst->description = strdup(_src->description);
859                         if(_dst->description == NULL)
860                         {
861                                 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
862                                 media_info_destroy((media_info_h)_dst);
863                                 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
864                         }
865                 }
866
867                 if(STRING_VALID(_src->weather))
868                 {
869                         _dst->weather = strdup(_src->weather);
870                         if(_dst->weather == NULL)
871                         {
872                                 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
873                                 media_info_destroy((media_info_h)_dst);
874                                 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
875                         }
876                 }
877
878                 if(STRING_VALID(_src->title))
879                 {
880                         _dst->title = strdup(_src->title);
881                         if(_dst->title == NULL)
882                         {
883                                 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
884                                 media_info_destroy((media_info_h)_dst);
885                                 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
886                         }
887                 }
888                 if(STRING_VALID(_src->author))
889                 {
890                         _dst->author = strdup(_src->author);
891                         if(_dst->author == NULL)
892                         {
893                                 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
894                                 media_info_destroy((media_info_h)_dst);
895                                 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
896                         }
897                 }
898                 if(STRING_VALID(_src->provider))
899                 {
900                         _dst->provider = strdup(_src->provider);
901                         if(_dst->provider == NULL)
902                         {
903                                 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
904                                 media_info_destroy((media_info_h)_dst);
905                                 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
906                         }
907                 }
908                 if(STRING_VALID(_src->content_name))
909                 {
910                         _dst->content_name = strdup(_src->content_name);
911                         if(_dst->content_name == NULL)
912                         {
913                                 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
914                                 media_info_destroy((media_info_h)_dst);
915                                 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
916                         }
917                 }
918                 if(STRING_VALID(_src->category))
919                 {
920                         _dst->category = strdup(_src->category);
921                         if(_dst->category == NULL)
922                         {
923                                 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
924                                 media_info_destroy((media_info_h)_dst);
925                                 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
926                         }
927                 }
928                 if(STRING_VALID(_src->location_tag))
929                 {
930                         _dst->location_tag = strdup(_src->location_tag);
931                         if(_dst->location_tag == NULL)
932                         {
933                                 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
934                                 media_info_destroy((media_info_h)_dst);
935                                 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
936                         }
937                 }
938                 if(STRING_VALID(_src->age_rating))
939                 {
940                         _dst->age_rating = strdup(_src->age_rating);
941                         if(_dst->age_rating == NULL)
942                         {
943                                 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
944                                 media_info_destroy((media_info_h)_dst);
945                                 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
946                         }
947                 }
948                 if(STRING_VALID(_src->keyword))
949                 {
950                         _dst->keyword = strdup(_src->keyword);
951                         if(_dst->keyword == NULL)
952                         {
953                                 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
954                                 media_info_destroy((media_info_h)_dst);
955                                 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
956                         }
957                 }
958
959                 if(STRING_VALID(_src->storage_uuid))
960                 {
961                         _dst->storage_uuid = strdup(_src->storage_uuid);
962                         if(_dst->storage_uuid == NULL)
963                         {
964                                 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
965                                 media_info_destroy((media_info_h)_dst);
966                                 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
967                         }
968                 }
969
970                 _dst->media_type = _src->media_type;
971                 _dst->size = _src->size;
972                 _dst->added_time = _src->added_time;
973                 _dst->modified_time = _src->modified_time;
974                 _dst->timeline = _src->timeline;
975                 _dst->longitude = _src->longitude;
976                 _dst->latitude = _src->latitude;
977                 _dst->altitude = _src->altitude;
978                 _dst->rating = _src->rating;
979                 _dst->favourite = _src->favourite;
980                 _dst->is_drm = _src->is_drm;
981                 _dst->storage_type = _src->storage_type;
982                 _dst->played_count = _src->played_count;
983                 _dst->played_time = _src->played_time;
984                 _dst->played_position = _src->played_position;
985                 _dst->sync_status = _src->sync_status;
986
987                 if(_src->media_type == MEDIA_CONTENT_TYPE_IMAGE && _src->image_meta) {
988                         _dst->image_meta = (image_meta_s *)calloc(1, sizeof(image_meta_s));
989                         if(_dst->image_meta == NULL)
990                         {
991                                 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
992                                 media_info_destroy((media_info_h)_dst);
993                                 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
994                         }
995
996                         if(STRING_VALID(_src->image_meta->media_id))
997                         {
998                                 _dst->image_meta->media_id = strdup(_src->image_meta->media_id);
999                                 if(_dst->image_meta->media_id == NULL)
1000                                 {
1001                                         media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
1002                                         media_info_destroy((media_info_h)_dst);
1003                                         return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
1004                                 }
1005                         }
1006
1007                         if(STRING_VALID(_src->image_meta->date_taken))
1008                         {
1009                                 _dst->image_meta->date_taken = strdup(_src->image_meta->date_taken);
1010                                 if(_dst->image_meta->date_taken == NULL)
1011                                 {
1012                                         media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
1013                                         media_info_destroy((media_info_h)_dst);
1014                                         return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
1015                                 }
1016                         }
1017
1018                         if(STRING_VALID(_src->image_meta->burst_id))
1019                         {
1020                                 _dst->image_meta->burst_id = strdup(_src->image_meta->burst_id);
1021                                 if(_dst->image_meta->burst_id == NULL)
1022                                 {
1023                                         media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
1024                                         media_info_destroy((media_info_h)_dst);
1025                                         return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
1026                                 }
1027                         }
1028
1029                         if(STRING_VALID(_src->image_meta->weather))
1030                         {
1031                                 _dst->image_meta->weather = strdup(_src->image_meta->weather);
1032                                 if(_dst->image_meta->weather == NULL)
1033                                 {
1034                                         media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
1035                                         media_info_destroy((media_info_h)_dst);
1036                                         return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
1037                                 }
1038                         }
1039
1040                         if(STRING_VALID(_src->image_meta->exposure_time))
1041                         {
1042                                 _dst->image_meta->exposure_time = strdup(_src->image_meta->exposure_time);
1043                                 if(_dst->image_meta->exposure_time == NULL)
1044                                 {
1045                                         media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
1046                                         media_info_destroy((media_info_h)_dst);
1047                                         return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
1048                                 }
1049                         }
1050
1051                         if(STRING_VALID(_src->image_meta->model))
1052                         {
1053                                 _dst->image_meta->model = strdup(_src->image_meta->model);
1054                                 if(_dst->image_meta->model == NULL)
1055                                 {
1056                                         media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
1057                                         media_info_destroy((media_info_h)_dst);
1058                                         return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
1059                                 }
1060                         }
1061
1062                         _dst->image_meta->fnumber = _src->image_meta->fnumber;
1063                         _dst->image_meta->iso = _src->image_meta->iso;
1064                         _dst->image_meta->width = _src->image_meta->width;
1065                         _dst->image_meta->height = _src->image_meta->height;
1066                         _dst->image_meta->orientation = _src->image_meta->orientation;
1067
1068                 } else if(_src->media_type == MEDIA_CONTENT_TYPE_VIDEO && _src->video_meta) {
1069                         _dst->video_meta = (video_meta_s *)calloc(1, sizeof(video_meta_s));
1070                         if(_dst->video_meta == NULL)
1071                         {
1072                                 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
1073                                 media_info_destroy((media_info_h)_dst);
1074                                 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
1075                         }
1076
1077                         if(STRING_VALID(_src->video_meta->media_id))
1078                         {
1079                                 _dst->video_meta->media_id = strdup(_src->video_meta->media_id);
1080                                 if(_dst->video_meta->media_id == NULL)
1081                                 {
1082                                         media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
1083                                         media_info_destroy((media_info_h)_dst);
1084                                         return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
1085                                 }
1086                         }
1087                         if(STRING_VALID(_src->video_meta->title))
1088                         {
1089                                 _dst->video_meta->title = strdup(_src->video_meta->title);
1090                                 if(_dst->video_meta->title == NULL)
1091                                 {
1092                                         media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
1093                                         media_info_destroy((media_info_h)_dst);
1094                                         return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
1095                                 }
1096                         }
1097                         if(STRING_VALID(_src->video_meta->album))
1098                         {
1099                                 _dst->video_meta->album = strdup(_src->video_meta->album);
1100                                 if(_dst->video_meta->album == NULL)
1101                                 {
1102                                         media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
1103                                         media_info_destroy((media_info_h)_dst);
1104                                         return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
1105                                 }
1106                         }
1107                         if(STRING_VALID(_src->video_meta->artist))
1108                         {
1109                                 _dst->video_meta->artist = strdup(_src->video_meta->artist);
1110                                 if(_dst->video_meta->artist == NULL)
1111                                 {
1112                                         media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
1113                                         media_info_destroy((media_info_h)_dst);
1114                                         return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
1115                                 }
1116                         }
1117                         if(STRING_VALID(_src->video_meta->album_artist))
1118                         {
1119                                 _dst->video_meta->album_artist = strdup(_src->video_meta->album_artist);
1120                                 if(_dst->video_meta->album_artist == NULL)
1121                                 {
1122                                         media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
1123                                         media_info_destroy((media_info_h)_dst);
1124                                         return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
1125                                 }
1126                         }
1127                         if(STRING_VALID(_src->video_meta->genre))
1128                         {
1129                                 _dst->video_meta->genre = strdup(_src->video_meta->genre);
1130                                 if(_dst->video_meta->genre == NULL)
1131                                 {
1132                                         media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
1133                                         media_info_destroy((media_info_h)_dst);
1134                                         return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
1135                                 }
1136                         }
1137                         if(STRING_VALID(_src->video_meta->composer))
1138                         {
1139                                 _dst->video_meta->composer = strdup(_src->video_meta->composer);
1140                                 if(_dst->video_meta->composer == NULL)
1141                                 {
1142                                         media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
1143                                         media_info_destroy((media_info_h)_dst);
1144                                         return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
1145                                 }
1146                         }
1147                         if(STRING_VALID(_src->video_meta->year))
1148                         {
1149                                 _dst->video_meta->year = strdup(_src->video_meta->year);
1150                                 if(_dst->video_meta->year == NULL)
1151                                 {
1152                                         media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
1153                                         media_info_destroy((media_info_h)_dst);
1154                                         return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
1155                                 }
1156                         }
1157                         if(STRING_VALID(_src->video_meta->recorded_date))
1158                         {
1159                                 _dst->video_meta->recorded_date = strdup(_src->video_meta->recorded_date);
1160                                 if(_dst->video_meta->recorded_date == NULL)
1161                                 {
1162                                         media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
1163                                         media_info_destroy((media_info_h)_dst);
1164                                         return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
1165                                 }
1166                         }
1167                         if(STRING_VALID(_src->video_meta->copyright))
1168                         {
1169                                 _dst->video_meta->copyright = strdup(_src->video_meta->copyright);
1170                                 if(_dst->video_meta->copyright == NULL)
1171                                 {
1172                                         media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
1173                                         media_info_destroy((media_info_h)_dst);
1174                                         return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
1175                                 }
1176                         }
1177                         if(STRING_VALID(_src->video_meta->track_num))
1178                         {
1179                                 _dst->video_meta->track_num = strdup(_src->video_meta->track_num);
1180                                 if(_dst->video_meta->track_num == NULL)
1181                                 {
1182                                         media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
1183                                         media_info_destroy((media_info_h)_dst);
1184                                         return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
1185                                 }
1186                         }
1187
1188                         _dst->video_meta->width = _src->video_meta->width;
1189                         _dst->video_meta->height = _src->video_meta->height;
1190                         _dst->video_meta->duration = _src->video_meta->duration;
1191                         _dst->video_meta->bitrate = _src->video_meta->bitrate;
1192                         _dst->video_meta->played_count = _src->video_meta->played_count;
1193                         _dst->video_meta->played_time = _src->video_meta->played_time;
1194                         _dst->video_meta->played_position = _src->video_meta->played_position;
1195
1196                 } else if((_src->media_type == MEDIA_CONTENT_TYPE_MUSIC || _src->media_type == MEDIA_CONTENT_TYPE_SOUND) && _src->audio_meta) {
1197                         _dst->audio_meta = (audio_meta_s *)calloc(1, sizeof(audio_meta_s));
1198                         if(_dst->audio_meta == NULL)
1199                         {
1200                                 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
1201                                 media_info_destroy((media_info_h)_dst);
1202                                 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
1203                         }
1204
1205                         if(STRING_VALID(_src->audio_meta->media_id))
1206                         {
1207                                 _dst->audio_meta->media_id = strdup(_src->audio_meta->media_id);
1208                                 if(_dst->audio_meta->media_id == NULL)
1209                                 {
1210                                         media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
1211                                         media_info_destroy((media_info_h)_dst);
1212                                         return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
1213                                 }
1214                         }
1215                         if(STRING_VALID(_src->audio_meta->title))
1216                         {
1217                                 _dst->audio_meta->title = strdup(_src->audio_meta->title);
1218                                 if(_dst->audio_meta->title == NULL)
1219                                 {
1220                                         media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
1221                                         media_info_destroy((media_info_h)_dst);
1222                                         return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
1223                                 }
1224                         }
1225                         if(STRING_VALID(_src->audio_meta->album))
1226                         {
1227                                 _dst->audio_meta->album = strdup(_src->audio_meta->album);
1228                                 if(_dst->audio_meta->album == NULL)
1229                                 {
1230                                         media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
1231                                         media_info_destroy((media_info_h)_dst);
1232                                         return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
1233                                 }
1234                         }
1235                         if(STRING_VALID(_src->audio_meta->artist))
1236                         {
1237                                 _dst->audio_meta->artist = strdup(_src->audio_meta->artist);
1238                                 if(_dst->audio_meta->artist == NULL)
1239                                 {
1240                                         media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
1241                                         media_info_destroy((media_info_h)_dst);
1242                                         return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
1243                                 }
1244                         }
1245                         if(STRING_VALID(_src->audio_meta->album_artist))
1246                         {
1247                                 _dst->audio_meta->album_artist = strdup(_src->audio_meta->album_artist);
1248                                 if(_dst->audio_meta->album_artist == NULL)
1249                                 {
1250                                         media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
1251                                         media_info_destroy((media_info_h)_dst);
1252                                         return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
1253                                 }
1254                         }
1255                         if(STRING_VALID(_src->audio_meta->genre))
1256                         {
1257                                 _dst->audio_meta->genre = strdup(_src->audio_meta->genre);
1258                                 if(_dst->audio_meta->genre == NULL)
1259                                 {
1260                                         media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
1261                                         media_info_destroy((media_info_h)_dst);
1262                                         return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
1263                                 }
1264                         }
1265                         if(STRING_VALID(_src->audio_meta->composer))
1266                         {
1267                                 _dst->audio_meta->composer = strdup(_src->audio_meta->composer);
1268                                 if(_dst->audio_meta->composer == NULL)
1269                                 {
1270                                         media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
1271                                         media_info_destroy((media_info_h)_dst);
1272                                         return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
1273                                 }
1274                         }
1275                         if(STRING_VALID(_src->audio_meta->year))
1276                         {
1277                                 _dst->audio_meta->year = strdup(_src->audio_meta->year);
1278                                 if(_dst->audio_meta->year == NULL)
1279                                 {
1280                                         media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
1281                                         media_info_destroy((media_info_h)_dst);
1282                                         return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
1283                                 }
1284                         }
1285                         if(STRING_VALID(_src->audio_meta->recorded_date))
1286                         {
1287                                 _dst->audio_meta->recorded_date = strdup(_src->audio_meta->recorded_date);
1288                                 if(_dst->audio_meta->recorded_date == NULL)
1289                                 {
1290                                         media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
1291                                         media_info_destroy((media_info_h)_dst);
1292                                         return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
1293                                 }
1294                         }
1295                         if(STRING_VALID(_src->audio_meta->copyright))
1296                         {
1297                                 _dst->audio_meta->copyright = strdup(_src->audio_meta->copyright);
1298                                 if(_dst->audio_meta->copyright == NULL)
1299                                 {
1300                                         media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
1301                                         media_info_destroy((media_info_h)_dst);
1302                                         return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
1303                                 }
1304                         }
1305                         if(STRING_VALID(_src->audio_meta->track_num))
1306                         {
1307                                 _dst->audio_meta->track_num = strdup(_src->audio_meta->track_num);
1308                                 if(_dst->audio_meta->track_num == NULL)
1309                                 {
1310                                         media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
1311                                         media_info_destroy((media_info_h)_dst);
1312                                         return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
1313                                 }
1314                         }
1315
1316                         _dst->audio_meta->channel = _src->audio_meta->channel;
1317                         _dst->audio_meta->samplerate = _src->audio_meta->samplerate;
1318                         _dst->audio_meta->duration = _src->audio_meta->duration;
1319                         _dst->audio_meta->bitrate = _src->audio_meta->bitrate;
1320                         _dst->audio_meta->bitpersample = _src->audio_meta->bitpersample;
1321                         _dst->audio_meta->played_count = _src->audio_meta->played_count;
1322                         _dst->audio_meta->played_time = _src->audio_meta->played_time;
1323                         _dst->audio_meta->played_position = _src->audio_meta->played_position;
1324
1325                 }
1326                 *dst = (media_info_h)_dst;
1327
1328                 ret = MEDIA_CONTENT_ERROR_NONE;
1329         }
1330         else
1331         {
1332                 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1333                 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1334         }
1335
1336         return ret;
1337 }
1338
1339 int media_info_get_media_count_from_db(filter_h filter, int *media_count)
1340 {
1341         int ret = MEDIA_CONTENT_ERROR_NONE;
1342
1343         if(media_count == NULL)
1344         {
1345                 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1346                 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1347
1348                 return ret;
1349         }
1350
1351         ret = _media_db_get_group_item_count(NULL, filter, MEDIA_GROUP_NONE, media_count);
1352
1353         return ret;
1354 }
1355
1356 int media_info_foreach_media_from_db(filter_h filter, media_info_cb callback, void *user_data)
1357 {
1358         int ret = MEDIA_CONTENT_ERROR_NONE;
1359
1360         media_content_retvm_if(callback == NULL, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid callback");
1361
1362         ret = _media_db_get_group_item(NULL, filter, callback, user_data, MEDIA_GROUP_NONE);
1363
1364         return ret;
1365 }
1366
1367 int media_info_get_tag_count_from_db(const char *media_id, filter_h filter, int *tag_count)
1368 {
1369         int ret = MEDIA_CONTENT_ERROR_NONE;
1370
1371         if(STRING_VALID(media_id) && tag_count)
1372         {
1373                 ret = _media_db_get_group_item_count(media_id, filter, MEDIA_GROUP_TAG_BY_MEDIA_ID, tag_count);
1374         }
1375         else
1376         {
1377                 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1378                 return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1379         }
1380
1381         return ret;
1382 }
1383
1384 int media_info_foreach_tag_from_db(const char *media_id, filter_h filter, media_tag_cb callback, void *user_data)
1385 {
1386         int ret = MEDIA_CONTENT_ERROR_NONE;
1387
1388         if((callback != NULL) && STRING_VALID(media_id))
1389         {
1390                 ret = _media_db_get_tag(media_id, filter, callback, user_data);
1391         }
1392         else
1393         {
1394                 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1395                 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1396         }
1397
1398         return ret;
1399 }
1400
1401 int media_info_get_bookmark_count_from_db(const char *media_id, filter_h filter, int *bookmark_count)
1402 {
1403         int ret = MEDIA_CONTENT_ERROR_NONE;
1404
1405         if(STRING_VALID(media_id) && bookmark_count)
1406         {
1407                 ret = _media_db_get_group_item_count(media_id, filter, MEDIA_GROUP_BOOKMARK_BY_MEDIA_ID, bookmark_count);
1408         }
1409         else
1410         {
1411                 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1412                 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1413         }
1414
1415         return ret;
1416 }
1417
1418 int media_info_foreach_bookmark_from_db (const char *media_id, filter_h filter, media_bookmark_cb callback, void *user_data)
1419 {
1420         int ret = MEDIA_CONTENT_ERROR_NONE;
1421
1422         if((callback != NULL) && STRING_VALID(media_id))
1423         {
1424                 ret = _media_db_get_bookmark(media_id, filter, callback, user_data);
1425         }
1426         else
1427         {
1428                 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1429                 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1430         }
1431
1432         return ret;
1433 }
1434
1435 int media_info_get_face_count_from_db(const char *media_id, filter_h filter, int *face_count)
1436 {
1437         int ret = MEDIA_CONTENT_ERROR_NONE;
1438
1439         if(STRING_VALID(media_id) && face_count)
1440         {
1441                 ret = _media_db_get_group_item_count(media_id, filter, MEDIA_GROUP_FACE_BY_MEDIA_ID, face_count);
1442         }
1443         else
1444         {
1445                 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1446                 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1447         }
1448
1449         return ret;
1450 }
1451
1452 int media_info_foreach_face_from_db (const char *media_id, filter_h filter, media_face_cb callback, void *user_data)
1453 {
1454         int ret = MEDIA_CONTENT_ERROR_NONE;
1455
1456         if((callback != NULL) && STRING_VALID(media_id))
1457         {
1458                 ret = _media_db_get_face(media_id, filter, callback, user_data);
1459         }
1460         else
1461         {
1462                 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1463                 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1464         }
1465
1466         return ret;
1467 }
1468
1469 int media_info_get_image(media_info_h media, image_meta_h *image)
1470 {
1471         int ret = MEDIA_CONTENT_ERROR_NONE;
1472
1473         media_info_s *_media = (media_info_s*)media;
1474
1475         media_content_retvm_if(_media == NULL, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid media");
1476         media_content_retvm_if(_media->media_type != MEDIA_CONTENT_TYPE_IMAGE, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid media_type");
1477         media_content_retvm_if(_media->image_meta == NULL, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid image_meta");
1478
1479         image_meta_s *_image = (image_meta_s*)calloc(1, sizeof(image_meta_s));
1480         media_content_retvm_if(_image == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
1481
1482         if(STRING_VALID(_media->media_id)) {
1483                 _image->media_id = strdup(_media->media_id);
1484         }
1485
1486         _image->width = _media->image_meta->width;
1487         _image->height = _media->image_meta->height;
1488         _image->orientation = _media->image_meta->orientation;
1489         _image->fnumber = _media->image_meta->fnumber;
1490         _image->iso = _media->image_meta->iso;
1491
1492         if(STRING_VALID(_media->image_meta->date_taken)) {
1493                 _image->date_taken = strdup(_media->image_meta->date_taken);
1494         }
1495
1496         if(STRING_VALID(_media->image_meta->title)) {
1497                 _image->title = strdup(_media->image_meta->title);
1498         }
1499
1500         if(STRING_VALID(_media->image_meta->burst_id)) {
1501                 _image->burst_id = strdup(_media->image_meta->burst_id);
1502         }
1503
1504         if(STRING_VALID(_media->image_meta->weather)) {
1505                 _image->weather = strdup(_media->image_meta->weather);
1506         }
1507
1508         if(STRING_VALID(_media->image_meta->exposure_time)) {
1509                 _image->exposure_time = strdup(_media->image_meta->exposure_time);
1510         }
1511
1512         if(STRING_VALID(_media->image_meta->model)) {
1513                 _image->model = strdup(_media->image_meta->model);
1514         }
1515
1516         *image = (image_meta_h)_image;
1517
1518         return ret;
1519 }
1520
1521 int media_info_get_video(media_info_h media, video_meta_h *video)
1522 {
1523         int ret = MEDIA_CONTENT_ERROR_NONE;
1524
1525         media_info_s *_media = (media_info_s*)media;
1526
1527         media_content_retvm_if(_media == NULL, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid media");
1528         media_content_retvm_if(_media->media_type != MEDIA_CONTENT_TYPE_VIDEO, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid media_type");
1529         media_content_retvm_if(_media->video_meta == NULL, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid video_meta");
1530
1531         video_meta_s *_video = (video_meta_s*)calloc(1, sizeof(video_meta_s));
1532         media_content_retvm_if(_video == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
1533
1534         if(STRING_VALID(_media->media_id)) {
1535                 _video->media_id = strdup(_media->media_id);
1536         }
1537
1538         if(STRING_VALID(_media->video_meta->title)) {
1539                 _video->title = strdup(_media->video_meta->title);
1540         }
1541         if(STRING_VALID(_media->video_meta->album)) {
1542                 _video->album = strdup(_media->video_meta->album);
1543         }
1544         if(STRING_VALID(_media->video_meta->artist)) {
1545                 _video->artist = strdup(_media->video_meta->artist);
1546         }
1547         if(STRING_VALID(_media->video_meta->album_artist)) {
1548                 _video->album_artist = strdup(_media->video_meta->album_artist);
1549         }
1550         if(STRING_VALID(_media->video_meta->genre)) {
1551                 _video->genre = strdup(_media->video_meta->genre);
1552         }
1553         if(STRING_VALID(_media->video_meta->composer)) {
1554                 _video->composer = strdup(_media->video_meta->composer);
1555         }
1556         if(STRING_VALID(_media->video_meta->year)) {
1557                 _video->year = strdup(_media->video_meta->year);
1558         }
1559         if(STRING_VALID(_media->video_meta->recorded_date)) {
1560                 _video->recorded_date = strdup(_media->video_meta->recorded_date);
1561         }
1562         if(STRING_VALID(_media->video_meta->copyright)) {
1563                 _video->copyright = strdup(_media->video_meta->copyright);
1564         }
1565         if(STRING_VALID(_media->video_meta->track_num)) {
1566                 _video->track_num = strdup(_media->video_meta->track_num);
1567         }
1568
1569         _video->width = _media->video_meta->width;
1570         _video->height = _media->video_meta->height;
1571         _video->duration = _media->video_meta->duration;
1572         _video->bitrate = _media->video_meta->bitrate;
1573         _video->played_count = _media->video_meta->played_count;
1574         _video->played_time = _media->video_meta->played_time;
1575         _video->played_position = _media->video_meta->played_position;
1576
1577         *video = (video_meta_h)_video;
1578
1579         return ret;
1580 }
1581
1582 int media_info_get_audio(media_info_h media, audio_meta_h *audio)
1583 {
1584         int ret = MEDIA_CONTENT_ERROR_NONE;
1585
1586         media_info_s *_media = (media_info_s*)media;
1587
1588
1589         media_content_retvm_if(_media == NULL, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid media");
1590         media_content_retvm_if(_media->media_type != MEDIA_CONTENT_TYPE_MUSIC && _media->media_type != MEDIA_CONTENT_TYPE_SOUND, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid media_type");
1591         media_content_retvm_if(_media->audio_meta == NULL, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid audio_meta");
1592
1593         audio_meta_s *_audio = (audio_meta_s*)calloc(1, sizeof(audio_meta_s));
1594         media_content_retvm_if(_audio == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
1595
1596         if(STRING_VALID(_media->media_id)) {
1597                 _audio->media_id = strdup(_media->media_id);
1598         }
1599
1600         if(STRING_VALID(_media->audio_meta->title)) {
1601                 _audio->title = strdup(_media->audio_meta->title);
1602         }
1603         if(STRING_VALID(_media->audio_meta->album)) {
1604                 _audio->album = strdup(_media->audio_meta->album);
1605         }
1606         if(STRING_VALID(_media->audio_meta->artist)) {
1607                 _audio->artist = strdup(_media->audio_meta->artist);
1608         }
1609         if(STRING_VALID(_media->audio_meta->album_artist)) {
1610                 _audio->album_artist = strdup(_media->audio_meta->album_artist);
1611         }
1612         if(STRING_VALID(_media->audio_meta->genre)) {
1613                 _audio->genre = strdup(_media->audio_meta->genre);
1614         }
1615         if(STRING_VALID(_media->audio_meta->composer)) {
1616                 _audio->composer = strdup(_media->audio_meta->composer);
1617         }
1618         if(STRING_VALID(_media->audio_meta->year)) {
1619                 _audio->year = strdup(_media->audio_meta->year);
1620         }
1621         if(STRING_VALID(_media->audio_meta->recorded_date)) {
1622                 _audio->recorded_date = strdup(_media->audio_meta->recorded_date);
1623         }
1624         if(STRING_VALID(_media->audio_meta->copyright)) {
1625                 _audio->copyright = strdup(_media->audio_meta->copyright);
1626         }
1627         if(STRING_VALID(_media->audio_meta->track_num)) {
1628                 _audio->track_num = strdup(_media->audio_meta->track_num);
1629         }
1630
1631         _audio->duration = _media->audio_meta->duration;
1632         _audio->bitrate = _media->audio_meta->bitrate;
1633         _audio->bitpersample = _media->audio_meta->bitpersample;
1634         _audio->samplerate = _media->audio_meta->samplerate;
1635         _audio->channel = _media->audio_meta->channel;
1636         _audio->played_time = _media->audio_meta->played_time;
1637         _audio->played_count = _media->audio_meta->played_count;
1638         _audio->played_position = _media->audio_meta->played_position;
1639
1640         *audio = (audio_meta_h)_audio;
1641
1642         return ret;
1643 }
1644
1645 int media_info_get_media_id(media_info_h media, char **media_id)
1646 {
1647         int ret = MEDIA_CONTENT_ERROR_NONE;
1648         media_info_s *_media = (media_info_s*)media;
1649
1650         if(_media && media_id)
1651         {
1652                 if(STRING_VALID(_media->media_id))
1653                 {
1654                         *media_id = strdup(_media->media_id);
1655                         media_content_retvm_if(*media_id == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
1656                 }
1657                 else
1658                 {
1659                         *media_id = NULL;
1660                 }
1661                 ret = MEDIA_CONTENT_ERROR_NONE;
1662         }
1663         else
1664         {
1665                 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1666                 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1667         }
1668
1669         return ret;
1670 }
1671
1672 int media_info_get_file_path(media_info_h media, char **path)
1673 {
1674         int ret = MEDIA_CONTENT_ERROR_NONE;
1675         media_info_s *_media = (media_info_s*)media;
1676
1677         if(_media && path)
1678         {
1679                 if(STRING_VALID(_media->file_path))
1680                 {
1681                         *path = strdup(_media->file_path);
1682                         media_content_retvm_if(*path == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
1683                 }
1684                 else
1685                 {
1686                         *path = NULL;
1687                 }
1688                 ret = MEDIA_CONTENT_ERROR_NONE;
1689
1690         }
1691         else
1692         {
1693                 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1694                 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1695         }
1696
1697         return ret;
1698 }
1699
1700 int media_info_get_display_name(media_info_h media, char **name)
1701 {
1702         int ret = MEDIA_CONTENT_ERROR_NONE;
1703         media_info_s *_media = (media_info_s*)media;
1704         if(_media && name)
1705         {
1706                 if(STRING_VALID(_media->display_name))
1707                 {
1708                         *name = strdup(_media->display_name);
1709                         media_content_retvm_if(*name == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
1710                 }
1711                 else
1712                 {
1713                         *name = NULL;
1714                 }
1715                 ret = MEDIA_CONTENT_ERROR_NONE;
1716
1717         }
1718         else
1719         {
1720                 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1721                 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1722         }
1723
1724         return ret;
1725 }
1726
1727 int media_info_get_media_type(media_info_h media, media_content_type_e *type)
1728 {
1729         int ret = MEDIA_CONTENT_ERROR_NONE;
1730         media_info_s *_media = (media_info_s*)media;
1731         if(_media && type)
1732         {
1733                 *type = _media->media_type;
1734                 ret = MEDIA_CONTENT_ERROR_NONE;
1735         }
1736         else
1737         {
1738                 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1739                 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1740         }
1741
1742         return ret;
1743 }
1744
1745 int media_info_get_mime_type(media_info_h media, char **mime_type)
1746 {
1747         int ret = MEDIA_CONTENT_ERROR_NONE;
1748         media_info_s *_media = (media_info_s*)media;
1749
1750         if(_media && mime_type)
1751         {
1752                 if(STRING_VALID(_media->mime_type))
1753                 {
1754                         *mime_type = strdup(_media->mime_type);
1755                         media_content_retvm_if(*mime_type == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
1756                 }
1757                 else
1758                 {
1759                         *mime_type = NULL;
1760                 }
1761                 ret = MEDIA_CONTENT_ERROR_NONE;
1762         }
1763         else
1764         {
1765                 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1766                 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1767         }
1768
1769         return ret;
1770 }
1771
1772 int media_info_get_size(media_info_h media, unsigned long long *size)
1773 {
1774         int ret = MEDIA_CONTENT_ERROR_NONE;
1775         media_info_s *_media = (media_info_s*)media;
1776
1777         if(_media && size)
1778         {
1779                 *size = _media->size;
1780                 ret = MEDIA_CONTENT_ERROR_NONE;
1781         }
1782         else
1783         {
1784                 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1785                 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1786         }
1787
1788         return ret;
1789 }
1790
1791 int media_info_get_added_time(media_info_h media, time_t *added_time)
1792 {
1793         int ret = MEDIA_CONTENT_ERROR_NONE;
1794         media_info_s *_media = (media_info_s*)media;
1795         if(_media && added_time)
1796         {
1797                 *added_time = _media->added_time;
1798                 ret = MEDIA_CONTENT_ERROR_NONE;
1799         }
1800         else
1801         {
1802                 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1803                 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1804         }
1805
1806         return ret;
1807 }
1808
1809 int media_info_get_modified_time(media_info_h media, time_t* time)
1810 {
1811         int ret = MEDIA_CONTENT_ERROR_NONE;
1812         media_info_s *_media = (media_info_s*)media;
1813         if(_media && time)
1814         {
1815                 *time = _media->modified_time;
1816                 ret = MEDIA_CONTENT_ERROR_NONE;
1817         }
1818         else
1819         {
1820                 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1821                 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1822         }
1823
1824         return ret;
1825 }
1826
1827 int media_info_get_timeline(media_info_h media, time_t* time)
1828 {
1829         int ret = MEDIA_CONTENT_ERROR_NONE;
1830         media_info_s *_media = (media_info_s*)media;
1831         if(_media && time)
1832         {
1833                 *time = _media->timeline;
1834                 ret = MEDIA_CONTENT_ERROR_NONE;
1835         }
1836         else
1837         {
1838                 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1839                 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1840         }
1841
1842         return ret;
1843 }
1844
1845 int media_info_get_thumbnail_path(media_info_h media, char **path)
1846 {
1847         int ret = MEDIA_CONTENT_ERROR_NONE;
1848         media_info_s *_media = (media_info_s*)media;
1849         if(_media && path)
1850         {
1851                 if(STRING_VALID(_media->thumbnail_path))
1852                 {
1853                         *path = strdup(_media->thumbnail_path);
1854                         media_content_retvm_if(*path == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
1855                 }
1856                 else
1857                 {
1858                         *path = NULL;
1859                 }
1860                 ret = MEDIA_CONTENT_ERROR_NONE;
1861
1862         }
1863         else
1864         {
1865                 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1866                 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1867         }
1868
1869         return ret;
1870 }
1871
1872 int media_info_get_title(media_info_h media, char **title)
1873 {
1874         int ret = MEDIA_CONTENT_ERROR_NONE;
1875         media_info_s *_media = (media_info_s*)media;
1876
1877         if(_media && title)
1878         {
1879                 if(STRING_VALID(_media->title))
1880                 {
1881                         *title = strdup(_media->title);
1882                         media_content_retvm_if(*title == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
1883                 }
1884                 else
1885                 {
1886                         *title = NULL;
1887                 }
1888                 ret = MEDIA_CONTENT_ERROR_NONE;
1889         }
1890         else
1891         {
1892                 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1893                 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1894         }
1895
1896         return ret;
1897 }
1898
1899 int media_info_get_description(media_info_h media, char **description)
1900 {
1901         int ret = MEDIA_CONTENT_ERROR_NONE;
1902         media_info_s *_media = (media_info_s*)media;
1903
1904         if(_media && description)
1905         {
1906                 if(STRING_VALID(_media->description))
1907                 {
1908                         *description = strdup(_media->description);
1909                         media_content_retvm_if(*description == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
1910                 }
1911                 else
1912                 {
1913                         *description = NULL;
1914                 }
1915                 ret = MEDIA_CONTENT_ERROR_NONE;
1916         }
1917         else
1918         {
1919                 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1920                 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1921         }
1922
1923         return ret;
1924 }
1925
1926 int media_info_get_longitude(media_info_h media, double* longitude)
1927 {
1928         int ret = MEDIA_CONTENT_ERROR_NONE;
1929         media_info_s *_media = (media_info_s*)media;
1930
1931         if(_media && longitude)
1932         {
1933                 *longitude = _media->longitude;
1934                 ret = MEDIA_CONTENT_ERROR_NONE;
1935         }
1936         else
1937         {
1938                 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1939                 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1940         }
1941
1942         return ret;
1943 }
1944 int media_info_get_latitude(media_info_h media, double* latitude)
1945 {
1946         int ret = MEDIA_CONTENT_ERROR_NONE;
1947         media_info_s *_media = (media_info_s*)media;
1948
1949         if(_media && latitude)
1950         {
1951                 *latitude = _media->latitude;
1952                 ret = MEDIA_CONTENT_ERROR_NONE;
1953         }
1954         else
1955         {
1956                 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1957                 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1958         }
1959
1960         return ret;
1961 }
1962
1963 int media_info_get_altitude(media_info_h media, double *altitude)
1964 {
1965         int ret = MEDIA_CONTENT_ERROR_NONE;
1966         media_info_s *_media = (media_info_s*)media;
1967
1968         if(_media && altitude)
1969         {
1970                 *altitude = _media->altitude;
1971                 ret = MEDIA_CONTENT_ERROR_NONE;
1972         }
1973         else
1974         {
1975                 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1976                 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1977         }
1978
1979         return ret;
1980 }
1981
1982 int media_info_get_weather(media_info_h media, char **weather)
1983 {
1984         int ret = MEDIA_CONTENT_ERROR_NONE;
1985         media_info_s *_media = (media_info_s*)media;
1986
1987         if(_media && weather)
1988         {
1989                 if(STRING_VALID(_media->weather))
1990                 {
1991                         *weather = strdup(_media->weather);
1992                         media_content_retvm_if(*weather == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
1993                 }
1994                 else
1995                 {
1996                         *weather = NULL;
1997                 }
1998                 ret = MEDIA_CONTENT_ERROR_NONE;
1999         }
2000         else
2001         {
2002                 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
2003                 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
2004         }
2005
2006         return ret;
2007 }
2008
2009 int media_info_get_rating(media_info_h media, int *rating)
2010 {
2011         int ret = MEDIA_CONTENT_ERROR_NONE;
2012         media_info_s *_media = (media_info_s*)media;
2013
2014         if(_media && rating)
2015         {
2016                 *rating = _media->rating;
2017                 ret = MEDIA_CONTENT_ERROR_NONE;
2018         }
2019         else
2020         {
2021                 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
2022                 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
2023         }
2024
2025         return ret;
2026 }
2027
2028 int media_info_get_favorite(media_info_h media, bool* favorite)
2029 {
2030         int ret = MEDIA_CONTENT_ERROR_NONE;
2031         media_info_s *_media = (media_info_s*)media;
2032
2033         if(_media && favorite)
2034         {
2035
2036                 *favorite = _media->favourite;
2037                 ret = MEDIA_CONTENT_ERROR_NONE;
2038         }
2039         else
2040         {
2041                 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
2042                 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
2043         }
2044
2045         return ret;
2046 }
2047
2048 int media_info_get_author(media_info_h media, char **author)
2049 {
2050         int ret = MEDIA_CONTENT_ERROR_NONE;
2051         media_info_s *_media = (media_info_s*)media;
2052
2053         if(_media && author)
2054         {
2055                 if(STRING_VALID(_media->author))
2056                 {
2057                         *author = strdup(_media->author);
2058                         media_content_retvm_if(*author == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
2059                 }
2060                 else
2061                 {
2062                         *author = NULL;
2063                 }
2064                 ret = MEDIA_CONTENT_ERROR_NONE;
2065         }
2066         else
2067         {
2068                 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
2069                 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
2070         }
2071
2072         return ret;
2073 }
2074
2075 int media_info_get_provider(media_info_h media, char **provider)
2076 {
2077         int ret = MEDIA_CONTENT_ERROR_NONE;
2078         media_info_s *_media = (media_info_s*)media;
2079
2080         if(_media && provider)
2081         {
2082                 if(STRING_VALID(_media->provider))
2083                 {
2084                         *provider = strdup(_media->provider);
2085                         media_content_retvm_if(*provider == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
2086                 }
2087                 else
2088                 {
2089                         *provider = NULL;
2090                 }
2091                 ret = MEDIA_CONTENT_ERROR_NONE;
2092         }
2093         else
2094         {
2095                 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
2096                 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
2097         }
2098
2099         return ret;
2100 }
2101
2102 int media_info_get_content_name(media_info_h media, char **content_name)
2103 {
2104         int ret = MEDIA_CONTENT_ERROR_NONE;
2105         media_info_s *_media = (media_info_s*)media;
2106
2107         if(_media && content_name)
2108         {
2109                 if(STRING_VALID(_media->content_name))
2110                 {
2111                         *content_name = strdup(_media->content_name);
2112                         media_content_retvm_if(*content_name == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
2113                 }
2114                 else
2115                 {
2116                         *content_name = NULL;
2117                 }
2118                 ret = MEDIA_CONTENT_ERROR_NONE;
2119         }
2120         else
2121         {
2122                 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
2123                 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
2124         }
2125
2126         return ret;
2127 }
2128
2129 int media_info_get_category(media_info_h media, char **category)
2130 {
2131         int ret = MEDIA_CONTENT_ERROR_NONE;
2132         media_info_s *_media = (media_info_s*)media;
2133
2134         if(_media && category)
2135         {
2136                 if(STRING_VALID(_media->category))
2137                 {
2138                         *category = strdup(_media->category);
2139                         media_content_retvm_if(*category == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
2140                 }
2141                 else
2142                 {
2143                         *category = NULL;
2144                 }
2145                 ret = MEDIA_CONTENT_ERROR_NONE;
2146         }
2147         else
2148         {
2149                 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
2150                 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
2151         }
2152
2153         return ret;
2154 }
2155
2156 int media_info_get_location_tag(media_info_h media, char **location_tag)
2157 {
2158         int ret = MEDIA_CONTENT_ERROR_NONE;
2159         media_info_s *_media = (media_info_s*)media;
2160
2161         if(_media && location_tag)
2162         {
2163                 if(STRING_VALID(_media->location_tag))
2164                 {
2165                         *location_tag = strdup(_media->location_tag);
2166                         media_content_retvm_if(*location_tag == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
2167                 }
2168                 else
2169                 {
2170                         *location_tag = NULL;
2171                 }
2172                 ret = MEDIA_CONTENT_ERROR_NONE;
2173         }
2174         else
2175         {
2176                 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
2177                 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
2178         }
2179
2180         return ret;
2181 }
2182
2183 int media_info_get_age_rating(media_info_h media, char **age_rating)
2184 {
2185         int ret = MEDIA_CONTENT_ERROR_NONE;
2186         media_info_s *_media = (media_info_s*)media;
2187
2188         if(_media && age_rating)
2189         {
2190                 if(STRING_VALID(_media->age_rating))
2191                 {
2192                         *age_rating = strdup(_media->age_rating);
2193                         media_content_retvm_if(*age_rating == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
2194                 }
2195                 else
2196                 {
2197                         *age_rating = NULL;
2198                 }
2199                 ret = MEDIA_CONTENT_ERROR_NONE;
2200         }
2201         else
2202         {
2203                 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
2204                 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
2205         }
2206
2207         return ret;
2208 }
2209
2210 int media_info_get_keyword(media_info_h media, char **keyword)
2211 {
2212         int ret = MEDIA_CONTENT_ERROR_NONE;
2213         media_info_s *_media = (media_info_s*)media;
2214
2215         if(_media && keyword)
2216         {
2217                 if(STRING_VALID(_media->keyword))
2218                 {
2219                         *keyword = strdup(_media->keyword);
2220                         media_content_retvm_if(*keyword == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
2221                 }
2222                 else
2223                 {
2224                         *keyword = NULL;
2225                 }
2226                 ret = MEDIA_CONTENT_ERROR_NONE;
2227         }
2228         else
2229         {
2230                 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
2231                 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
2232         }
2233
2234         return ret;
2235 }
2236
2237 int media_info_get_storage_id(media_info_h media, char **storage_id)
2238 {
2239         int ret = MEDIA_CONTENT_ERROR_NONE;
2240         media_info_s *_media = (media_info_s*)media;
2241
2242         if(_media && storage_id)
2243         {
2244                 if(STRING_VALID(_media->storage_uuid))
2245                 {
2246                         *storage_id = strdup(_media->storage_uuid);
2247                         media_content_retvm_if(*storage_id == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
2248                 }
2249                 else
2250                 {
2251                         *storage_id = NULL;
2252                 }
2253                 ret = MEDIA_CONTENT_ERROR_NONE;
2254         }
2255         else
2256         {
2257                 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
2258                 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
2259         }
2260
2261         return ret;
2262 }
2263
2264 int media_info_is_drm(media_info_h media, bool *is_drm)
2265 {
2266         int ret = MEDIA_CONTENT_ERROR_NONE;
2267         media_info_s *_media = (media_info_s*)media;
2268
2269         if(_media)
2270         {
2271                 *is_drm = _media->is_drm;
2272                 ret = MEDIA_CONTENT_ERROR_NONE;
2273         }
2274         else
2275         {
2276                 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
2277                 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
2278         }
2279
2280         return ret;
2281 }
2282
2283 int media_info_get_storage_type(media_info_h media, media_content_storage_e *storage_type)
2284 {
2285         int ret = MEDIA_CONTENT_ERROR_NONE;
2286         media_info_s *_media = (media_info_s*)media;
2287
2288         if(_media && storage_type)
2289         {
2290                 *storage_type = _media->storage_type;
2291                 ret = MEDIA_CONTENT_ERROR_NONE;
2292         }
2293         else
2294         {
2295                 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
2296                 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
2297         }
2298
2299         return ret;
2300 }
2301
2302 int media_info_get_played_count(media_info_h media, int *played_count)
2303 {
2304         int ret = MEDIA_CONTENT_ERROR_NONE;
2305         media_info_s *_media = (media_info_s*)media;
2306
2307         if(_media)
2308         {
2309                 *played_count = _media->played_count;
2310                 ret = MEDIA_CONTENT_ERROR_NONE;
2311         }
2312         else
2313         {
2314                 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
2315                 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
2316         }
2317
2318         return ret;
2319 }
2320
2321 int media_info_get_played_time(media_info_h media, time_t* played_time)
2322 {
2323         int ret = MEDIA_CONTENT_ERROR_NONE;
2324         media_info_s *_media = (media_info_s*)media;
2325
2326         if(_media)
2327         {
2328                 *played_time = _media->played_time;
2329                 ret = MEDIA_CONTENT_ERROR_NONE;
2330         }
2331         else
2332         {
2333                 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
2334                 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
2335         }
2336
2337         return ret;
2338 }
2339
2340 int media_info_increase_played_count(media_info_h media)
2341 {
2342         int ret = MEDIA_CONTENT_ERROR_NONE;
2343
2344         media_info_s *_media = (media_info_s*)media;
2345
2346         if(_media)
2347         {
2348                 _media->played_count += 1;
2349         }
2350         else
2351         {
2352                 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
2353                 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
2354         }
2355
2356         return ret;
2357 }
2358
2359 int media_info_set_played_time(media_info_h media)
2360 {
2361         int ret = MEDIA_CONTENT_ERROR_NONE;
2362         time_t current_time;
2363
2364         media_info_s *_media = (media_info_s*)media;
2365
2366         if(_media != NULL)
2367         {
2368                 time(&current_time);
2369                 _media->played_time = current_time;
2370         }
2371         else
2372         {
2373                 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
2374                 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
2375         }
2376
2377         return ret;
2378 }
2379
2380 int media_info_get_media_from_db(const char *media_id, media_info_h *media)
2381 {
2382         int ret = MEDIA_CONTENT_ERROR_NONE;
2383         char select_query[DEFAULT_QUERY_SIZE];
2384         char storage_id[MEDIA_CONTENT_UUID_SIZE+1] = {0, };
2385         sqlite3_stmt *stmt = NULL;
2386
2387         if(!STRING_VALID(media_id) || (media == NULL))
2388         {
2389                 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
2390                 return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
2391         }
2392
2393         memset(select_query, 0x00, sizeof(select_query));
2394         memset(storage_id, 0x00, sizeof(storage_id));
2395
2396         ret = _media_db_get_storage_id_by_media_id(media_id, storage_id);
2397         media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
2398
2399         snprintf(select_query, sizeof(select_query), SELECT_MEDIA_FROM_MEDIA, storage_id, media_id);
2400
2401         ret = _content_query_prepare(&stmt, select_query, NULL, NULL);
2402         media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
2403
2404         media_info_s *_media = NULL;
2405
2406         while(sqlite3_step(stmt) == SQLITE_ROW)
2407         {
2408                 if(_media)
2409                         media_info_destroy((media_info_h)_media);
2410
2411                 _media = (media_info_s*)calloc(1, sizeof(media_info_s));
2412
2413                 if(_media == NULL)
2414                 {
2415                         media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
2416                         SQLITE3_FINALIZE(stmt);
2417                         return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
2418                 }
2419
2420                 _media_info_item_get_detail(stmt, (media_info_h)_media);
2421
2422                 *media = (media_info_h)_media;
2423         }
2424
2425         SQLITE3_FINALIZE(stmt);
2426
2427         return ret;
2428 }
2429
2430 int media_info_set_display_name(media_info_h media, const char *display_name)
2431 {
2432         int ret = MEDIA_CONTENT_ERROR_NONE;
2433         media_info_s *_media = (media_info_s*)media;
2434
2435         if(_media != NULL && STRING_VALID(display_name))
2436         {
2437                 SAFE_FREE(_media->display_name);
2438
2439                 _media->display_name = strdup(display_name);
2440                 media_content_retvm_if(_media->display_name == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
2441         }
2442         else
2443         {
2444                 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
2445                 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
2446         }
2447
2448         return ret;
2449 }
2450
2451 int media_info_set_description(media_info_h media, const char *description)
2452 {
2453         int ret = MEDIA_CONTENT_ERROR_NONE;
2454         media_info_s *_media = (media_info_s*)media;
2455
2456         if(_media != NULL)
2457         {
2458                 SAFE_FREE(_media->description);
2459
2460                 if(STRING_VALID(description))
2461                 {
2462                         _media->description = strdup(description);
2463                         media_content_retvm_if(_media->description == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
2464                 }
2465                 else
2466                 {
2467                         _media->description = NULL;
2468                 }
2469         }
2470         else
2471         {
2472                 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
2473                 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
2474         }
2475
2476         return ret;
2477 }
2478
2479 int media_info_set_longitude(media_info_h media, double longitude)
2480 {
2481         int ret = MEDIA_CONTENT_ERROR_NONE;
2482         media_info_s *_media = (media_info_s*)media;
2483
2484         if(_media != NULL)
2485         {
2486                 _media->longitude = longitude;
2487         }
2488         else
2489         {
2490                 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
2491                 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
2492         }
2493
2494         return ret;
2495 }
2496
2497 int media_info_set_latitude(media_info_h media, double latitude)
2498 {
2499         int ret = MEDIA_CONTENT_ERROR_NONE;
2500         media_info_s *_media = (media_info_s*)media;
2501
2502         if(_media != NULL)
2503         {
2504                 _media->latitude = latitude;
2505         }
2506         else
2507         {
2508                 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
2509                 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
2510         }
2511
2512         return ret;
2513 }
2514
2515 int media_info_set_altitude(media_info_h media, double altitude)
2516 {
2517         int ret = MEDIA_CONTENT_ERROR_NONE;
2518         media_info_s *_media = (media_info_s*)media;
2519
2520         if(_media != NULL)
2521         {
2522                 _media->altitude = altitude;
2523         }
2524         else
2525         {
2526                 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
2527                 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
2528         }
2529
2530         return ret;
2531 }
2532
2533 int media_info_set_weather(media_info_h media, const char *weather)
2534 {
2535         int ret = MEDIA_CONTENT_ERROR_NONE;
2536         media_info_s *_media = (media_info_s*)media;
2537
2538         if(_media != NULL)
2539         {
2540                 SAFE_FREE(_media->weather);
2541
2542                 if(STRING_VALID(weather))
2543                 {
2544                         _media->weather = strdup(weather);
2545                         media_content_retvm_if(_media->weather == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
2546                 }
2547                 else
2548                 {
2549                         _media->weather = NULL;
2550                 }
2551         }
2552         else
2553         {
2554                 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
2555                 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
2556         }
2557
2558         return ret;
2559 }
2560
2561 int media_info_set_rating(media_info_h media, int rating)
2562 {
2563         int ret = MEDIA_CONTENT_ERROR_NONE;
2564         media_info_s *_media = (media_info_s*)media;
2565
2566         if(_media != NULL)
2567         {
2568                 _media->rating = rating;
2569         }
2570         else
2571         {
2572                 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
2573                 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
2574         }
2575
2576         return ret;
2577 }
2578
2579 int media_info_set_added_time(media_info_h media, time_t added_time)
2580 {
2581         int ret = MEDIA_CONTENT_ERROR_NONE;
2582
2583         media_info_s *_media = (media_info_s*)media;
2584
2585         if((_media != NULL) && (added_time >= 0))
2586         {
2587                 _media->added_time = added_time;
2588         }
2589         else
2590         {
2591                 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
2592                 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
2593         }
2594
2595         return ret;
2596 }
2597
2598 int media_info_set_favorite(media_info_h media, bool favorite)
2599 {
2600         int ret = MEDIA_CONTENT_ERROR_NONE;
2601         media_info_s *_media = (media_info_s*)media;
2602
2603         if(_media != NULL)
2604         {
2605                 if(favorite == TRUE)
2606                 {
2607                         time(&_media->favourite);
2608                 }
2609                 else
2610                 {
2611                         _media->favourite = 0;
2612                 }
2613         }
2614         else
2615         {
2616                 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
2617                 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
2618         }
2619
2620         return ret;
2621 }
2622
2623 int media_info_set_author(media_info_h media, const char *author)
2624 {
2625         int ret = MEDIA_CONTENT_ERROR_NONE;
2626         media_info_s *_media = (media_info_s*)media;
2627
2628         if(_media != NULL)
2629         {
2630                 if(STRING_VALID(author))
2631                 {
2632                         _media->author = strdup(author);
2633                         media_content_retvm_if(_media->author == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
2634                 }
2635                 else
2636                 {
2637                         _media->author = NULL;
2638                 }
2639         }
2640         else
2641         {
2642                 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
2643                 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
2644         }
2645
2646         return ret;
2647 }
2648
2649 int media_info_set_provider(media_info_h media, const char *provider)
2650 {
2651         int ret = MEDIA_CONTENT_ERROR_NONE;
2652         media_info_s *_media = (media_info_s*)media;
2653
2654         if(_media != NULL)
2655         {
2656                 SAFE_FREE(_media->provider);
2657
2658                 if(STRING_VALID(provider))
2659                 {
2660                         _media->provider = strdup(provider);
2661                         media_content_retvm_if(_media->provider == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
2662                 }
2663                 else
2664                 {
2665                         _media->provider = NULL;
2666                 }
2667         }
2668         else
2669         {
2670                 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
2671                 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
2672         }
2673
2674         return ret;
2675 }
2676
2677 int media_info_set_content_name(media_info_h media, const char *content_name)
2678 {
2679         int ret = MEDIA_CONTENT_ERROR_NONE;
2680         media_info_s *_media = (media_info_s*)media;
2681
2682         if(_media != NULL)
2683         {
2684                 SAFE_FREE(_media->content_name);
2685
2686                 if(STRING_VALID(content_name))
2687                 {
2688                         _media->content_name = strdup(content_name);
2689                         media_content_retvm_if(_media->content_name == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
2690                 }
2691                 else
2692                 {
2693                         _media->content_name = NULL;
2694                 }
2695         }
2696         else
2697         {
2698                 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
2699                 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
2700         }
2701
2702         return ret;
2703 }
2704
2705 int media_info_set_category(media_info_h media, const char *category)
2706 {
2707         int ret = MEDIA_CONTENT_ERROR_NONE;
2708         media_info_s *_media = (media_info_s*)media;
2709
2710         if(_media != NULL)
2711         {
2712                 SAFE_FREE(_media->category);
2713
2714                 if(STRING_VALID(category))
2715                 {
2716                         _media->category = strdup(category);
2717                         media_content_retvm_if(_media->category == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
2718                 }
2719                 else
2720                 {
2721                         _media->category = NULL;
2722                 }
2723         }
2724         else
2725         {
2726                 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
2727                 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
2728         }
2729
2730         return ret;
2731 }
2732
2733 int media_info_set_location_tag(media_info_h media, const char *location_tag)
2734 {
2735         int ret = MEDIA_CONTENT_ERROR_NONE;
2736         media_info_s *_media = (media_info_s*)media;
2737
2738         if(_media != NULL)
2739         {
2740                 SAFE_FREE(_media->location_tag);
2741
2742                 if(STRING_VALID(location_tag))
2743                 {
2744                         _media->location_tag = strdup(location_tag);
2745                         media_content_retvm_if(_media->location_tag == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
2746                 }
2747                 else
2748                 {
2749                         _media->location_tag = NULL;
2750                 }
2751         }
2752         else
2753         {
2754                 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
2755                 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
2756         }
2757
2758         return ret;
2759 }
2760
2761 int media_info_set_age_rating(media_info_h media, const char *age_rating)
2762 {
2763         int ret = MEDIA_CONTENT_ERROR_NONE;
2764         media_info_s *_media = (media_info_s*)media;
2765
2766         if(_media != NULL)
2767         {
2768                 SAFE_FREE(_media->age_rating);
2769
2770                 if(STRING_VALID(age_rating))
2771                 {
2772                         _media->age_rating = strdup(age_rating);
2773                         media_content_retvm_if(_media->age_rating == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
2774                 }
2775                 else
2776                 {
2777                         _media->age_rating = NULL;
2778                 }
2779         }
2780         else
2781         {
2782                 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
2783                 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
2784         }
2785
2786         return ret;
2787 }
2788
2789 int media_info_set_keyword(media_info_h media, const char *keyword)
2790 {
2791         int ret = MEDIA_CONTENT_ERROR_NONE;
2792         media_info_s *_media = (media_info_s*)media;
2793
2794         if(_media != NULL)
2795         {
2796                 SAFE_FREE(_media->keyword);
2797
2798                 if(STRING_VALID(keyword))
2799                 {
2800                         _media->keyword = strdup(keyword);
2801                         media_content_retvm_if(_media->keyword == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
2802                 }
2803                 else
2804                 {
2805                         _media->keyword = NULL;
2806                 }
2807         }
2808         else
2809         {
2810                 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
2811                 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
2812         }
2813
2814         return ret;
2815 }
2816
2817 int media_info_update_to_db(media_info_h media)
2818 {
2819         int ret = MEDIA_CONTENT_ERROR_NONE;
2820         media_info_s *_media = (media_info_s*)media;
2821         char *set_sql = NULL;
2822         char *sql = NULL;
2823
2824         if(_media != NULL && STRING_VALID(_media->media_id))
2825         {
2826                 /* This sql is due to sqlite3_mprintf's wrong operation when using floating point in the text format */
2827                 /* This code will be removed when sqlite3_mprintf works clearly */
2828                 char *test_sql = sqlite3_mprintf("%f, %f, %f", _media->longitude, _media->latitude, _media->altitude);
2829                 SQLITE3_SAFE_FREE(test_sql);
2830
2831                 /*Update Pinyin If Support Pinyin*/
2832                 char *file_name_pinyin = NULL;
2833                 char *description_pinyin = NULL;
2834                 char *author_pinyin = NULL;
2835                 char *provider_pinyin = NULL;
2836                 char *content_name_pinyin = NULL;
2837                 char *category_pinyin = NULL;
2838                 char *location_tag_pinyin = NULL;
2839                 char *age_rating_pinyin = NULL;
2840                 char *keyword_pinyin = NULL;
2841                 bool pinyin_support = FALSE;
2842
2843                 /*Update Pinyin If Support Pinyin*/
2844                 media_svc_check_pinyin_support(&pinyin_support);
2845                 if(pinyin_support)
2846                 {
2847                         if(STRING_VALID(_media->display_name))
2848                                 media_svc_get_pinyin(_content_get_db_handle(), _media->display_name, &file_name_pinyin);
2849                         if(STRING_VALID(_media->description))
2850                                 media_svc_get_pinyin(_content_get_db_handle(), _media->description, &description_pinyin);
2851                         if(STRING_VALID(_media->author))
2852                                 media_svc_get_pinyin(_content_get_db_handle(), _media->author, &author_pinyin);
2853                         if(STRING_VALID(_media->provider))
2854                                 media_svc_get_pinyin(_content_get_db_handle(), _media->provider, &provider_pinyin);
2855                         if(STRING_VALID(_media->content_name))
2856                                 media_svc_get_pinyin(_content_get_db_handle(), _media->content_name, &content_name_pinyin);
2857                         if(STRING_VALID(_media->category))
2858                                 media_svc_get_pinyin(_content_get_db_handle(), _media->category, &category_pinyin);
2859                         if(STRING_VALID(_media->location_tag))
2860                                 media_svc_get_pinyin(_content_get_db_handle(), _media->location_tag, &location_tag_pinyin);
2861                         if(STRING_VALID(_media->age_rating))
2862                                 media_svc_get_pinyin(_content_get_db_handle(), _media->age_rating, &age_rating_pinyin);
2863                         if(STRING_VALID(_media->keyword))
2864                                 media_svc_get_pinyin(_content_get_db_handle(), _media->keyword, &keyword_pinyin);
2865                 }
2866
2867                 set_sql = sqlite3_mprintf("file_name=%Q, added_time=%d, description=%Q, longitude=%f, latitude=%f, altitude=%f, \
2868                         played_count=%d, last_played_time=%d, last_played_position=%d, \
2869                         rating=%d, favourite=%d, author=%Q, provider=%Q, content_name=%Q, category=%Q, location_tag=%Q, age_rating=%Q, keyword=%Q, weather=%Q, sync_status=%d, \
2870                         file_name_pinyin=%Q, description_pinyin=%Q, author_pinyin=%Q, provider_pinyin=%Q, content_name_pinyin=%Q, category_pinyin=%Q, location_tag_pinyin=%Q, age_rating_pinyin=%Q, keyword_pinyin=%Q, title=%Q",
2871                         _media->display_name, _media->added_time, _media->description, _media->longitude, _media->latitude, _media->altitude, _media->played_count, _media->played_time, _media->played_position, _media->rating, _media->favourite,
2872                         _media->author, _media->provider, _media->content_name, _media->category, _media->location_tag, _media->age_rating, _media->keyword, _media->weather, _media->sync_status,
2873                         file_name_pinyin, description_pinyin, author_pinyin, provider_pinyin, content_name_pinyin, category_pinyin, location_tag_pinyin, age_rating_pinyin, keyword_pinyin, _media->title);
2874
2875                 sql = sqlite3_mprintf("UPDATE %Q SET %s WHERE media_uuid=%Q", _media->storage_uuid, set_sql, _media->media_id);
2876
2877                 ret = _content_query_sql(sql);
2878                 SQLITE3_SAFE_FREE(set_sql);
2879                 SQLITE3_SAFE_FREE(sql);
2880
2881                 SAFE_FREE(description_pinyin);
2882                 SAFE_FREE(author_pinyin);
2883                 SAFE_FREE(provider_pinyin);
2884                 SAFE_FREE(content_name_pinyin);
2885                 SAFE_FREE(category_pinyin);
2886                 SAFE_FREE(location_tag_pinyin);
2887                 SAFE_FREE(age_rating_pinyin);
2888                 SAFE_FREE(keyword_pinyin);
2889
2890                 if(_media->storage_type == MEDIA_CONTENT_STORAGE_CLOUD)
2891                 {
2892                         set_sql = NULL;
2893                         sql = NULL;
2894
2895                         if(_media->media_type == MEDIA_CONTENT_TYPE_VIDEO)
2896                         {
2897                                 set_sql = sqlite3_mprintf("title=%Q, album=%Q, artist=%Q, genre=%Q, duration=%d, width=%d, height=%d", \
2898                                 _media->title, _media->video_meta->album, _media->video_meta->artist, _media->video_meta->genre, _media->video_meta->duration, _media->video_meta->width, _media->video_meta->height);
2899                         }
2900                         else if((_media->media_type == MEDIA_CONTENT_TYPE_MUSIC) || (_media->media_type == MEDIA_CONTENT_TYPE_SOUND))
2901                         {
2902                                 set_sql = sqlite3_mprintf("title=%Q, album=%Q, artist=%Q, genre=%Q, duration=%d", \
2903                                 _media->title, _media->audio_meta->album, _media->audio_meta->artist, _media->audio_meta->genre, _media->audio_meta->duration);
2904                         }
2905                         else if(_media->media_type == MEDIA_CONTENT_TYPE_IMAGE)
2906                         {
2907                                 set_sql = sqlite3_mprintf("title=%Q, width=%d, height=%d", _media->title, _media->image_meta->width, _media->image_meta->height);
2908                         }
2909                         else
2910                         {
2911                                 set_sql = sqlite3_mprintf("title=%Q", _media->title);
2912                         }
2913
2914                         sql = sqlite3_mprintf("UPDATE %Q SET %s WHERE media_uuid=%Q", _media->storage_uuid, set_sql, _media->media_id);
2915
2916                         ret = _content_query_sql(sql);
2917
2918                         SQLITE3_SAFE_FREE(set_sql);
2919                         SQLITE3_SAFE_FREE(sql);
2920                 }
2921
2922                 if (ret == MEDIA_CONTENT_ERROR_NONE) {
2923                         /*  Send notification for this update */
2924                         media_content_debug("Update is successfull. Send notification for this");
2925                         if (_media->file_path && _media->mime_type) {
2926                                 media_svc_publish_noti(_content_get_db_handle(), MS_MEDIA_ITEM_FILE, MS_MEDIA_ITEM_UPDATE, _media->file_path, _media->media_type, _media->media_id, _media->mime_type);
2927                         } else {
2928                                 media_content_error("Can't Send Noti : path or mime type is NULL");
2929                         }
2930                 }
2931         }
2932         else
2933         {
2934                 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
2935                 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
2936         }
2937
2938         return ret;
2939 }
2940
2941 int media_info_refresh_metadata_to_db(const char *media_id)
2942 {
2943         int ret = MEDIA_CONTENT_ERROR_NONE;
2944         media_info_h media = NULL;
2945         char *file_path = NULL;
2946         media_content_storage_e storage_type = 0;
2947         char storage_id[MEDIA_CONTENT_UUID_SIZE+1] = {0, };
2948
2949         if(!STRING_VALID(media_id))
2950         {
2951                 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
2952                 return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
2953         }
2954
2955         ret = media_info_get_media_from_db(media_id, &media);
2956         if(ret != MEDIA_CONTENT_ERROR_NONE)
2957         {
2958                 media_info_destroy(media);
2959                 return ret;
2960         }
2961
2962         ret = media_info_get_storage_type(media, &storage_type);
2963         if(ret != MEDIA_CONTENT_ERROR_NONE)
2964         {
2965                 media_info_destroy(media);
2966                 return ret;
2967         }
2968
2969         if(storage_type == MEDIA_CONTENT_STORAGE_CLOUD)
2970         {
2971                 media_info_destroy(media);
2972                 media_content_error("Can't refresh cloud content!!");
2973                 return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
2974         }
2975
2976         ret = media_info_get_file_path(media, &file_path);
2977         if(ret != MEDIA_CONTENT_ERROR_NONE)
2978         {
2979                 media_info_destroy(media);
2980                 return ret;
2981         }
2982
2983         ret = _media_util_check_file_exist(file_path);
2984         if (ret != MEDIA_CONTENT_ERROR_NONE) {
2985                 SAFE_FREE(file_path);
2986                 media_info_destroy(media);
2987                 return ret;
2988         }
2989
2990         memset(storage_id, 0x00, sizeof(storage_id));
2991         ret = media_svc_get_storage_id(_content_get_db_handle(), file_path, storage_id);
2992         if(ret != MS_MEDIA_ERR_NONE)
2993         {
2994                 media_content_error("media_svc_get_storage_id failed : %d", ret);
2995                 SAFE_FREE(file_path);
2996                 media_info_destroy(media);
2997                 return _content_error_capi(MEDIA_CONTENT_TYPE, ret);
2998         }
2999
3000         ret = media_svc_refresh_item(_content_get_db_handle(), storage_id, storage_type, file_path, tzplatform_getuid(TZ_USER_NAME));
3001         if (ret != MS_MEDIA_ERR_NONE)
3002         {
3003                 ret = _content_error_capi(MEDIA_CONTENT_TYPE, ret);
3004         }
3005
3006         SAFE_FREE(file_path);
3007         media_info_destroy(media);
3008
3009         return ret;
3010 }
3011
3012 int media_info_move_to_db(media_info_h media, const char* dst_path)
3013 {
3014         int ret = MEDIA_CONTENT_ERROR_NONE;
3015         bool ignore_file = FALSE;
3016         bool ignore_dir = FALSE;
3017         char *folder_path = NULL;
3018         media_svc_storage_type_e src_storage_type = 0;
3019         media_svc_storage_type_e dst_storage_type = 0;
3020         char storage_id[MEDIA_CONTENT_UUID_SIZE+1] = {0, };
3021
3022         media_content_retvm_if(media == NULL, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "invalid media");
3023         media_content_retvm_if(!STRING_VALID(dst_path), MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "invalid dst_path");
3024
3025         media_info_s *_media = (media_info_s*)media;
3026
3027         ret = _media_util_check_ignore_file(dst_path, &ignore_file);
3028         media_content_retvm_if(ignore_file == TRUE, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid path");
3029
3030         ret = _media_util_check_file_exist(dst_path);
3031         media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
3032
3033         folder_path = g_path_get_dirname(dst_path);
3034         ret = _media_util_check_ignore_dir(folder_path, &ignore_dir);
3035         SAFE_FREE(folder_path);
3036
3037         media_content_retvm_if(ignore_dir == TRUE, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid folder path");
3038
3039         ret = media_svc_get_storage_type(_media->file_path, &src_storage_type, tzplatform_getuid(TZ_USER_NAME));
3040         if(ret != MS_MEDIA_ERR_NONE)
3041         {
3042                 media_content_sec_error("media_svc_get_storage_type failed : %d", ret);
3043                 return _content_error_capi(MEDIA_CONTENT_TYPE, ret);
3044         }
3045
3046         ret = media_svc_get_storage_type(dst_path, &dst_storage_type, tzplatform_getuid(TZ_USER_NAME));
3047         if(ret != MS_MEDIA_ERR_NONE)
3048         {
3049                 media_content_sec_error("media_svc_get_storage_type failed : %d", ret);
3050                 return _content_error_capi(MEDIA_CONTENT_TYPE, ret);
3051         }
3052
3053         memset(storage_id, 0x00, sizeof(storage_id));
3054         ret = media_svc_get_storage_id(_content_get_db_handle(), _media->file_path, storage_id);
3055         if(ret != MS_MEDIA_ERR_NONE)
3056         {
3057                 media_content_error("media_svc_get_storage_id failed : %d", ret);
3058                 return _content_error_capi(MEDIA_CONTENT_TYPE, ret);
3059         }
3060
3061         ret = media_svc_move_item(_content_get_db_handle(), storage_id, src_storage_type, _media->file_path, dst_storage_type, dst_path, tzplatform_getuid(TZ_USER_NAME));
3062         return _content_error_capi(MEDIA_CONTENT_TYPE, ret);
3063 }
3064
3065 int media_info_create_thumbnail(media_info_h media, media_thumbnail_completed_cb callback, void *user_data)
3066 {
3067         int ret = MEDIA_CONTENT_ERROR_NONE;
3068         media_info_s *_media = (media_info_s*)media;
3069
3070         if(_media != NULL && STRING_VALID(_media->media_id) && STRING_VALID(_media->file_path))
3071         {
3072                 media_thumbnail_cb_s *_thumb_cb = (media_thumbnail_cb_s*)calloc(1, sizeof(media_thumbnail_cb_s));
3073                 media_content_retvm_if(_thumb_cb == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
3074
3075                 _thumb_cb->handle = _media;
3076                 _thumb_cb->user_data = user_data;
3077                 _thumb_cb->thumbnail_completed_cb = callback;
3078
3079                 ret = thumbnail_request_from_db_async(_media->file_path, (ThumbFunc)__media_info_thumbnail_completed_cb, (void *)_thumb_cb, tzplatform_getuid(TZ_USER_NAME));
3080                 ret = _content_error_capi(MEDIA_THUMBNAIL_TYPE, ret);
3081         }
3082         else
3083         {
3084                 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
3085                 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
3086         }
3087
3088         return ret;
3089 }
3090
3091 int media_info_cancel_thumbnail(media_info_h media)
3092 {
3093         int ret = MEDIA_CONTENT_ERROR_NONE;
3094         media_info_s *_media = (media_info_s*)media;
3095
3096         if(_media != NULL && STRING_VALID(_media->media_id) && STRING_VALID(_media->file_path))
3097         {
3098                 ret = thumbnail_request_cancel_media(_media->file_path);
3099                 ret = _content_error_capi(MEDIA_THUMBNAIL_TYPE, ret);
3100         }
3101         else
3102         {
3103                 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
3104                 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
3105         }
3106
3107         return ret;
3108 }
3109
3110 static int __media_info_map_data_usr_to_svc(media_info_s *media, media_svc_content_info_s **service_content, media_content_storage_e storage_type)
3111 {
3112         media_content_retvm_if(media == NULL, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid handle");
3113
3114         media_svc_content_info_s *svc_content_info = calloc(1, sizeof(media_svc_content_info_s));
3115         media_content_retvm_if(svc_content_info == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
3116
3117         svc_content_info->path = g_strdup(media->file_path);
3118         svc_content_info->media_type = media->media_type;
3119         svc_content_info->mime_type = g_strdup(media->mime_type);
3120         svc_content_info->size = media->size;
3121         svc_content_info->storage_type = storage_type;
3122         svc_content_info->storage_uuid = g_strdup(media->storage_uuid);
3123
3124         svc_content_info->added_time = media->added_time;
3125         svc_content_info->modified_time = media->modified_time;
3126         svc_content_info->thumbnail_path = g_strdup(media->thumbnail_path);
3127         svc_content_info->is_drm = media->is_drm;
3128
3129         svc_content_info->media_meta.title = g_strdup(media->title);
3130         svc_content_info->media_meta.rating = media->rating;
3131         svc_content_info->media_meta.description = g_strdup(media->description);
3132         svc_content_info->media_meta.longitude = media->longitude;
3133         svc_content_info->media_meta.latitude = media->latitude;
3134         svc_content_info->media_meta.altitude = media->altitude;
3135         svc_content_info->media_meta.weather = g_strdup(media->weather);
3136
3137         svc_content_info->media_meta.album = g_strdup(media->audio_meta->album);
3138         svc_content_info->media_meta.artist = g_strdup(media->audio_meta->artist);
3139         svc_content_info->media_meta.genre = g_strdup(media->audio_meta->genre);
3140         svc_content_info->media_meta.recorded_date = g_strdup(media->audio_meta->recorded_date);
3141
3142         if(storage_type == MEDIA_CONTENT_STORAGE_CLOUD) {
3143                 switch(media->media_type)
3144                 {
3145                         case MEDIA_CONTENT_TYPE_IMAGE:
3146                                 svc_content_info->media_meta.width = media->image_meta->width;
3147                                 svc_content_info->media_meta.height = media->image_meta->height;
3148                                 svc_content_info->media_meta.datetaken = g_strdup(media->image_meta->date_taken);
3149                                 svc_content_info->media_meta.orientation = media->image_meta->orientation;
3150                                 break;
3151                         case MEDIA_CONTENT_TYPE_VIDEO:
3152                                 svc_content_info->media_meta.album_artist = g_strdup(media->audio_meta->album_artist);
3153                                 svc_content_info->media_meta.composer = g_strdup(media->audio_meta->composer);
3154                                 svc_content_info->media_meta.year = g_strdup(media->audio_meta->year);
3155                                 svc_content_info->media_meta.copyright = g_strdup(media->audio_meta->copyright);
3156                                 svc_content_info->media_meta.track_num = g_strdup(media->audio_meta->track_num);
3157                                 svc_content_info->media_meta.bitrate = media->audio_meta->bitrate;
3158                                 svc_content_info->media_meta.duration = media->audio_meta->duration;
3159                                 svc_content_info->media_meta.width = media->image_meta->width;
3160                                 svc_content_info->media_meta.height = media->image_meta->height;
3161                                 break;
3162                         case MEDIA_CONTENT_TYPE_SOUND:
3163                         case MEDIA_CONTENT_TYPE_MUSIC:
3164                                 svc_content_info->media_meta.album_artist = g_strdup(media->audio_meta->album_artist);
3165                                 svc_content_info->media_meta.composer = g_strdup(media->audio_meta->composer);
3166                                 svc_content_info->media_meta.year = g_strdup(media->audio_meta->year);
3167                                 svc_content_info->media_meta.copyright = g_strdup(media->audio_meta->copyright);
3168                                 svc_content_info->media_meta.track_num = g_strdup(media->audio_meta->track_num);
3169                                 svc_content_info->media_meta.bitrate = media->audio_meta->bitrate;
3170                                 svc_content_info->media_meta.duration = media->audio_meta->duration;
3171                                 svc_content_info->media_meta.channel = media->audio_meta->channel;
3172                                 svc_content_info->media_meta.samplerate = media->audio_meta->samplerate;
3173                                 break;
3174                         case MEDIA_CONTENT_TYPE_OTHERS:
3175                         default:
3176                                 break;
3177                 }
3178         }
3179
3180         *service_content = svc_content_info;
3181
3182         return MEDIA_CONTENT_ERROR_NONE;
3183 }
3184
3185 static int __media_info_set_str_data(media_info_h media, media_info_item_e data_type, const char *str_data)
3186 {
3187         media_info_s *_media = (media_info_s*)media;
3188
3189         media_content_retvm_if(_media == NULL, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid media");
3190
3191         switch(data_type)
3192         {
3193                 case MEDIA_INFO_PATH:
3194                         SAFE_FREE(_media->file_path);
3195                         if(STRING_VALID(str_data))
3196                         {
3197                                 _media->file_path = strdup(str_data);
3198                                 media_content_retvm_if(_media->file_path == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
3199                         }
3200                         else
3201                         {
3202                                 _media->file_path = NULL;
3203                         }
3204                         break;
3205                 case MEDIA_INFO_MIME_TYPE:
3206                         SAFE_FREE(_media->mime_type);
3207                         if(STRING_VALID(str_data))
3208                         {
3209                                 _media->mime_type = strdup(str_data);
3210                                 media_content_retvm_if(_media->mime_type == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
3211                         }
3212                         else
3213                         {
3214                                 _media->mime_type = NULL;
3215                         }
3216                         break;
3217                 case MEDIA_INFO_THUMBNAIL_PATH:
3218                         SAFE_FREE(_media->thumbnail_path);
3219                         if(STRING_VALID(str_data))
3220                         {
3221                                 _media->thumbnail_path = strdup(str_data);
3222                                 media_content_retvm_if(_media->thumbnail_path == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
3223                         }
3224                         else
3225                         {
3226                                 _media->thumbnail_path = NULL;
3227                         }
3228                         break;
3229                 case MEDIA_INFO_TITLE:
3230                         SAFE_FREE(_media->title);
3231                         if(STRING_VALID(str_data))
3232                         {
3233                                 _media->title = strdup(str_data);
3234                                 media_content_retvm_if(_media->title == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
3235                         }
3236                         else
3237                         {
3238                                 _media->title = NULL;
3239                         }
3240                         break;
3241                 case MEDIA_INFO_STORAGE_UUID:
3242                         SAFE_FREE(_media->storage_uuid);
3243                         if(STRING_VALID(str_data))
3244                         {
3245                                 _media->storage_uuid = strdup(str_data);
3246                                 media_content_retvm_if(_media->storage_uuid == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
3247                         }
3248                         else
3249                         {
3250                                 _media->storage_uuid = NULL;
3251                         }
3252                         break;
3253                 case MEDIA_INFO_ALBUM:
3254                         //if(_media->media_type == MEDIA_CONTENT_TYPE_VIDEO)
3255                         {
3256                                 SAFE_FREE(_media->video_meta->album);
3257                                 if(STRING_VALID(str_data))
3258                                 {
3259                                         _media->video_meta->album = strdup(str_data);
3260                                         media_content_retvm_if(_media->video_meta->album == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
3261                                 }
3262                                 else
3263                                 {
3264                                         _media->video_meta->album = NULL;
3265                                 }
3266                         }
3267                         //else if((_media->media_type == MEDIA_CONTENT_TYPE_MUSIC) || (_media->media_type == MEDIA_CONTENT_TYPE_SOUND))
3268                         {
3269                                 SAFE_FREE(_media->audio_meta->album);
3270                                 if(STRING_VALID(str_data))
3271                                 {
3272                                         _media->audio_meta->album = strdup(str_data);
3273                                         media_content_retvm_if(_media->audio_meta->album == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
3274                                 }
3275                                 else
3276                                 {
3277                                         _media->audio_meta->album = NULL;
3278                                 }
3279                         }
3280                         break;
3281                 case MEDIA_INFO_ARTIST:
3282                         //if(_media->media_type == MEDIA_CONTENT_TYPE_VIDEO)
3283                         {
3284                                 SAFE_FREE(_media->video_meta->artist);
3285                                 if(STRING_VALID(str_data))
3286                                 {
3287                                         _media->video_meta->artist = strdup(str_data);
3288                                         media_content_retvm_if(_media->video_meta->artist == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
3289                                 }
3290                                 else
3291                                 {
3292                                         _media->video_meta->artist = NULL;
3293                                 }
3294                         }
3295                         //else if((_media->media_type == MEDIA_CONTENT_TYPE_MUSIC) || (_media->media_type == MEDIA_CONTENT_TYPE_SOUND))
3296                         {
3297                                 SAFE_FREE(_media->audio_meta->artist);
3298                                 if(STRING_VALID(str_data))
3299                                 {
3300                                         _media->audio_meta->artist = strdup(str_data);
3301                                         media_content_retvm_if(_media->audio_meta->artist == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
3302                                 }
3303                                 else
3304                                 {
3305                                         _media->audio_meta->artist = NULL;
3306                                 }
3307                         }
3308                         break;
3309                 case MEDIA_INFO_GENRE:
3310                         //if(_media->media_type == MEDIA_CONTENT_TYPE_VIDEO)
3311                         {
3312                                 SAFE_FREE(_media->video_meta->genre);
3313                                 if(STRING_VALID(str_data))
3314                                 {
3315                                         _media->video_meta->genre = strdup(str_data);
3316                                         media_content_retvm_if(_media->video_meta->genre == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
3317                                 }
3318                                 else
3319                                 {
3320                                         _media->video_meta->genre = NULL;
3321                                 }
3322                         }
3323                         //else if((_media->media_type == MEDIA_CONTENT_TYPE_MUSIC) || (_media->media_type == MEDIA_CONTENT_TYPE_SOUND))
3324                         {
3325                                 SAFE_FREE(_media->audio_meta->genre);
3326                                 if(STRING_VALID(str_data))
3327                                 {
3328                                         _media->audio_meta->genre = strdup(str_data);
3329                                         media_content_retvm_if(_media->audio_meta->genre == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
3330                                 }
3331                                 else
3332                                 {
3333                                         _media->audio_meta->genre = NULL;
3334                                 }
3335                         }
3336                         break;
3337                 case MEDIA_INFO_RECORDED_DATE:
3338                         //if(_media->media_type == MEDIA_CONTENT_TYPE_VIDEO)
3339                         {
3340                                 SAFE_FREE(_media->video_meta->recorded_date);
3341                                 if(STRING_VALID(str_data))
3342                                 {
3343                                         _media->video_meta->recorded_date = strdup(str_data);
3344                                         media_content_retvm_if(_media->video_meta->recorded_date == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
3345                                 }
3346                                 else
3347                                 {
3348                                         _media->video_meta->recorded_date = NULL;
3349                                 }
3350                         }
3351                         //else if((_media->media_type == MEDIA_CONTENT_TYPE_MUSIC) || (_media->media_type == MEDIA_CONTENT_TYPE_SOUND))
3352                         {
3353                                 SAFE_FREE(_media->audio_meta->recorded_date);
3354                                 if(STRING_VALID(str_data))
3355                                 {
3356                                         _media->audio_meta->recorded_date = strdup(str_data);
3357                                         media_content_retvm_if(_media->audio_meta->recorded_date == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
3358                                 }
3359                                 else
3360                                 {
3361                                         _media->audio_meta->recorded_date = NULL;
3362                                 }
3363                         }
3364                         break;
3365                 default:
3366                         media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
3367                         return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
3368         }
3369
3370         return MEDIA_CONTENT_ERROR_NONE;
3371 }
3372
3373 int media_info_insert_to_db_with_data(media_info_h media, media_info_h *info)
3374 {
3375         int ret = MEDIA_CONTENT_ERROR_NONE;
3376
3377         media_info_s *_media = (media_info_s*)media;
3378
3379         media_content_retvm_if(_media == NULL, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid media");
3380         media_content_retvm_if(!STRING_VALID(_media->file_path), MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid file_path");
3381         media_content_retvm_if(!STRING_VALID(_media->storage_uuid), MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid storage_uuid");
3382         media_content_retvm_if(_media->storage_type < 0, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid storage_type [%d]", _media->storage_type);
3383
3384         /* Cloud Item should be filled whole info*/
3385         if (_media->storage_type == MEDIA_CONTENT_STORAGE_CLOUD) {
3386                 media_content_retvm_if(!STRING_VALID(_media->mime_type), MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid mime_type");
3387                 media_content_retvm_if(!STRING_VALID(_media->title), MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid title");
3388                 media_content_retvm_if(_media->size <= 0, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid size [%d]", _media->size);
3389                 media_content_retvm_if(_media->modified_time <= 0, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid modified_time [%d]", _media->modified_time);
3390
3391                 if ((_media->media_type < MEDIA_CONTENT_TYPE_IMAGE) || (_media->media_type > MEDIA_CONTENT_TYPE_OTHERS))
3392                 {
3393                         media_content_error("invalid media type [%d]", _media->media_type);
3394                         return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
3395                 }
3396         }
3397
3398         media_content_sec_debug("storage[%d], path[%s], media_type[%d]", _media->storage_type, _media->file_path, _media->media_type);
3399
3400         media_svc_content_info_s *svc_content_info = NULL;
3401
3402         ret = __media_info_map_data_usr_to_svc(_media, &svc_content_info, _media->storage_type);
3403         media_content_retvm_if(ret != MEDIA_CONTENT_ERROR_NONE, ret, "__media_info_map_data_usr_to_svc fail");
3404
3405         ret = media_svc_insert_item_immediately_with_data(_content_get_db_handle(), svc_content_info, tzplatform_getuid(TZ_USER_NAME));
3406         if(ret != MS_MEDIA_ERR_NONE) {
3407                 media_content_sec_error("media_svc_insert_item_immediately_with_data failed : %d (%s)", ret, _media->file_path);
3408                 media_svc_destroy_content_info(svc_content_info);
3409                 SAFE_FREE(svc_content_info);
3410                 return _content_error_capi(MEDIA_CONTENT_TYPE, ret);
3411         }
3412         /*free the svc_content_info*/
3413         media_svc_destroy_content_info(svc_content_info);
3414         SAFE_FREE(svc_content_info);
3415
3416         if(info != NULL)
3417         {
3418                 media_info_s *_get_media = (media_info_s*)calloc(1, sizeof(media_info_s));
3419                 media_content_retvm_if(_get_media == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
3420
3421                 ret = _media_info_get_media_info_from_db(_media->file_path, _media->storage_uuid, (media_info_h)_get_media);
3422
3423                 *info = (media_info_h)_get_media;
3424         }
3425
3426         return ret;
3427 }
3428
3429 int media_info_create(const char *path, media_info_h *media)
3430 {
3431         int ret = MEDIA_CONTENT_ERROR_NONE;
3432         char storage_id[MEDIA_CONTENT_UUID_SIZE+1] = {0, };
3433         media_svc_storage_type_e storage_type = 0;
3434
3435         media_content_retvm_if(!STRING_VALID(path), MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid path");
3436         media_content_retvm_if(media == NULL, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid media");
3437
3438         memset(storage_id, 0x00, sizeof(storage_id));
3439
3440         if (strstr(MEDIA_ROOT_PATH_CLOUD, path) == NULL) {
3441                 bool ignore_file = FALSE;
3442                 bool ignore_dir = FALSE;
3443                 char *folder_path = NULL;
3444
3445                 ret = _media_util_check_ignore_file(path, &ignore_file);
3446                 media_content_retvm_if(ignore_file == TRUE, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid path");
3447
3448                 ret = _media_util_check_file_exist(path);
3449                 media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
3450
3451                 folder_path = g_path_get_dirname(path);
3452                 ret = _media_util_check_ignore_dir(folder_path, &ignore_dir);
3453                 SAFE_FREE(folder_path);
3454                 media_content_retvm_if(ignore_dir == TRUE, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid folder path");
3455
3456                 ret = media_svc_get_storage_id(_content_get_db_handle(), path, storage_id);
3457                 if(ret != MS_MEDIA_ERR_NONE)
3458                 {
3459                         media_content_error("media_svc_get_storage_id failed : %d", ret);
3460                         return _content_error_capi(MEDIA_CONTENT_TYPE, ret);
3461                 }
3462
3463                 ret = media_svc_get_storage_type(path, &storage_type, tzplatform_getuid(TZ_USER_NAME));
3464                 if(ret != MS_MEDIA_ERR_NONE) {
3465                         media_content_sec_error("media_svc_get_storage_type failed : %d", ret);
3466                         return _content_error_capi(MEDIA_CONTENT_TYPE, ret);
3467                 }
3468         }
3469
3470         media_info_s *_media = (media_info_s*)calloc(1,sizeof(media_info_s));
3471         media_content_retvm_if(_media == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
3472
3473         _media->audio_meta = (audio_meta_s *)calloc(1, sizeof(audio_meta_s));
3474         if(_media->audio_meta == NULL)
3475         {
3476                 SAFE_FREE(_media);
3477                 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
3478                 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
3479         }
3480
3481         _media->video_meta = (video_meta_s *)calloc(1, sizeof(video_meta_s));
3482         if(_media->video_meta == NULL)
3483         {
3484                 SAFE_FREE(_media->audio_meta);
3485                 SAFE_FREE(_media);
3486                 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
3487                 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
3488         }
3489
3490         _media->image_meta = (image_meta_s *)calloc(1, sizeof(image_meta_s));
3491         if(_media->image_meta == NULL)
3492         {
3493                 SAFE_FREE(_media->audio_meta);
3494                 SAFE_FREE(_media->video_meta);
3495                 SAFE_FREE(_media);
3496                 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
3497                 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
3498         }
3499
3500         _media->file_path = g_strdup(path);
3501         _media->storage_type = -1;
3502         _media->media_type = -1;
3503         _media->modified_time = -1;
3504         _media->size = -1;
3505
3506         if(STRING_VALID(storage_id)) {
3507                 _media->storage_uuid = g_strdup(storage_id);
3508                 _media->storage_type = storage_type;
3509         }
3510
3511         *media = (media_info_h)_media;
3512
3513         return ret;
3514 }
3515
3516 int media_info_create_handle(media_info_h *media)
3517 {
3518         int ret = MEDIA_CONTENT_ERROR_NONE;
3519
3520         media_content_retvm_if(media == NULL, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid handle");
3521
3522         media_info_s *_media = (media_info_s*)calloc(1,sizeof(media_info_s));
3523         media_content_retvm_if(_media == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
3524
3525         _media->audio_meta = (audio_meta_s *)calloc(1, sizeof(audio_meta_s));
3526         if(_media->audio_meta == NULL)
3527         {
3528                 SAFE_FREE(_media);
3529                 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
3530                 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
3531         }
3532
3533         _media->video_meta = (video_meta_s *)calloc(1, sizeof(video_meta_s));
3534         if(_media->video_meta == NULL)
3535         {
3536                 SAFE_FREE(_media->audio_meta);
3537                 SAFE_FREE(_media);
3538                 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
3539                 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
3540         }
3541
3542         _media->image_meta = (image_meta_s *)calloc(1, sizeof(image_meta_s));
3543         if(_media->image_meta == NULL)
3544         {
3545                 SAFE_FREE(_media->audio_meta);
3546                 SAFE_FREE(_media->video_meta);
3547                 SAFE_FREE(_media);
3548                 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
3549                 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
3550         }
3551
3552         _media->storage_type = -1;
3553         _media->media_type = -1;
3554         _media->modified_time = -1;
3555         _media->size = -1;
3556
3557         *media = (media_info_h)_media;
3558
3559         return ret;
3560 }
3561
3562 int media_info_set_path(media_info_h media, const char *path)
3563 {
3564         return __media_info_set_str_data(media, MEDIA_INFO_PATH, path);
3565 }
3566
3567 int media_info_set_mime_type(media_info_h media, const char *mime_type)
3568 {
3569         return __media_info_set_str_data(media, MEDIA_INFO_MIME_TYPE, mime_type);
3570 }
3571
3572 int media_info_set_title(media_info_h media, const char *title)
3573 {
3574         return __media_info_set_str_data(media, MEDIA_INFO_TITLE, title);
3575 }
3576
3577 int media_info_set_album(media_info_h media, const char *album)
3578 {
3579         return __media_info_set_str_data(media, MEDIA_INFO_ALBUM, album);
3580 }
3581
3582 int media_info_set_artist(media_info_h media, const char *artist)
3583 {
3584         return __media_info_set_str_data(media, MEDIA_INFO_ARTIST, artist);
3585 }
3586
3587 int media_info_set_genre(media_info_h media, const char *genre)
3588 {
3589         return __media_info_set_str_data(media, MEDIA_INFO_GENRE, genre);
3590 }
3591
3592 int media_info_set_recorded_date(media_info_h media, const char *recorded_date)
3593 {
3594         return __media_info_set_str_data(media, MEDIA_INFO_RECORDED_DATE, recorded_date);
3595 }
3596
3597 int media_info_set_thumbnail_path(media_info_h media, const char *thumbnail_path)
3598 {
3599         return __media_info_set_str_data(media, MEDIA_INFO_THUMBNAIL_PATH, thumbnail_path);
3600 }
3601
3602 int media_info_set_storage_id(media_info_h media, const char *storage_id)
3603 {
3604         return __media_info_set_str_data(media, MEDIA_INFO_STORAGE_UUID, storage_id);
3605 }
3606
3607 int media_info_set_size(media_info_h media, unsigned long long size)
3608 {
3609         media_info_s *_media = (media_info_s*)media;
3610
3611         media_content_retvm_if(_media == NULL, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid media");
3612
3613         _media->size = size;
3614
3615         return MEDIA_CONTENT_ERROR_NONE;
3616 }
3617
3618 int media_info_set_modified_time(media_info_h media, time_t modified_time)
3619 {
3620         media_info_s *_media = (media_info_s*)media;
3621
3622         media_content_retvm_if(_media == NULL, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid media");
3623
3624         _media->modified_time = modified_time;
3625
3626         return MEDIA_CONTENT_ERROR_NONE;
3627 }
3628
3629 int media_info_set_media_type(media_info_h media, media_content_type_e type)
3630 {
3631         media_info_s *_media = (media_info_s*)media;
3632
3633         media_content_retvm_if(_media == NULL, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid media");
3634
3635         _media->media_type = type;
3636
3637         return MEDIA_CONTENT_ERROR_NONE;
3638 }
3639
3640 int media_info_set_duration(media_info_h media, int duration)
3641 {
3642         media_info_s *_media = (media_info_s*)media;
3643
3644         media_content_retvm_if(_media == NULL, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid media");
3645
3646         if(_media->media_type == MEDIA_CONTENT_TYPE_VIDEO)
3647                 _media->video_meta->duration = duration;
3648         else if((_media->media_type == MEDIA_CONTENT_TYPE_MUSIC) || (_media->media_type == MEDIA_CONTENT_TYPE_SOUND))
3649                 _media->audio_meta->duration = duration;
3650         else
3651         {
3652                 media_content_error("Invalid media type");
3653                 return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
3654         }
3655
3656         return MEDIA_CONTENT_ERROR_NONE;
3657 }
3658
3659 int media_info_set_width(media_info_h media, int width)
3660 {
3661         media_info_s *_media = (media_info_s*)media;
3662
3663         media_content_retvm_if(_media == NULL, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid media");
3664
3665         if(_media->media_type == MEDIA_CONTENT_TYPE_VIDEO)
3666                 _media->video_meta->width = width;
3667         else if(_media->media_type == MEDIA_CONTENT_TYPE_IMAGE)
3668                 _media->image_meta->width = width;
3669         else
3670         {
3671                 media_content_error("Invalid media type");
3672                 return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
3673         }
3674
3675         return MEDIA_CONTENT_ERROR_NONE;
3676 }
3677
3678 int media_info_set_height(media_info_h media, int height)
3679 {
3680         media_info_s *_media = (media_info_s*)media;
3681
3682         media_content_retvm_if(_media == NULL, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid media");
3683
3684         if(_media->media_type == MEDIA_CONTENT_TYPE_VIDEO)
3685                 _media->video_meta->height = height;
3686         else if(_media->media_type == MEDIA_CONTENT_TYPE_IMAGE)
3687                 _media->image_meta->height = height;
3688         else
3689         {
3690                 media_content_error("Invalid media type");
3691                 return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
3692         }
3693
3694         return MEDIA_CONTENT_ERROR_NONE;
3695 }
3696
3697 int media_info_set_storage_type(media_info_h media, media_content_storage_e storage_type)
3698 {
3699         media_info_s *_media = (media_info_s*)media;
3700
3701         media_content_retvm_if(_media == NULL, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid media");
3702
3703         _media->storage_type = storage_type;
3704
3705         return MEDIA_CONTENT_ERROR_NONE;
3706 }