2 * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 #include <media_info.h>
18 #include <media-thumbnail.h>
19 #include <media_info_private.h>
20 #include <media_util_private.h>
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);
27 static int __media_info_get_media_path_by_id_from_db(const char *media_id, char **path)
29 int ret = MEDIA_CONTENT_ERROR_NONE;
30 sqlite3_stmt *stmt = NULL;
31 char *select_query = NULL;
33 media_content_retvm_if(!STRING_VALID(media_id), MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "invalid media_id");
35 select_query = sqlite3_mprintf(SELECT_MEDIA_PATH_BY_ID, media_id);
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);
41 if (sqlite3_step(stmt) == SQLITE_ROW) {
42 *path = g_strdup((const char *)sqlite3_column_text(stmt, 0));
44 media_content_error("There's no media with this ID : %s", media_id);
46 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
49 SQLITE3_FINALIZE(stmt);
54 static void __media_info_insert_completed_cb(media_request_result_s *result, void *user_data)
56 int ret = MEDIA_CONTENT_ERROR_NONE;
57 media_insert_cb_s *_cb_data = (media_insert_cb_s *)user_data;
61 ret = _content_error_capi(MEDIA_CONTENT_TYPE, result->result);
63 if (_cb_data->insert_completed_cb)
64 _cb_data->insert_completed_cb(ret, _cb_data->user_data);
66 if (STRING_VALID(_cb_data->insert_list_path)) {
67 if (unlink(_cb_data->insert_list_path) < 0)
68 media_content_stderror("failed to delete");
69 SAFE_FREE(_cb_data->insert_list_path);
78 static void __media_info_thumbnail_completed_cb(int error, const char *path, void *user_data)
80 int error_value = MEDIA_CONTENT_ERROR_NONE;
82 media_thumbnail_cb_s *_thumb_cb = (media_thumbnail_cb_s *)user_data;
83 media_info_s *media = NULL;
85 if (_thumb_cb != NULL) {
86 media = _thumb_cb->handle;
87 if ((media != NULL) && STRING_VALID(path)) {
88 SAFE_FREE(media->thumbnail_path);
89 media->thumbnail_path = g_strdup(path);
92 media_content_debug("error [%d], thumbnail_path [%s]", error, path);
93 error_value = _content_error_capi(MEDIA_THUMBNAIL_TYPE, error);
94 if (_thumb_cb->thumbnail_completed_cb)
95 _thumb_cb->thumbnail_completed_cb(error_value, path, _thumb_cb->user_data);
103 static bool __media_info_delete_batch_cb(media_info_h media, void *user_data)
105 int err = MEDIA_CONTENT_ERROR_NONE;
106 char *thumb_path = NULL;
107 media_content_type_e media_type = 0;
108 GArray *thumb_list = (GArray *)user_data;
111 media_content_debug("NO Item");
115 err = media_info_get_media_type(media, &media_type);
116 if (err == MEDIA_CONTENT_ERROR_NONE) {
117 media_content_debug("media_type : [%d]", media_type);
119 media_info_get_thumbnail_path(media, &thumb_path);
120 if (STRING_VALID(thumb_path) && STRING_VALID(MEDIA_CONTENT_THUMB_DEFAULT_PATH)) {
121 if (strncmp(MEDIA_CONTENT_THUMB_DEFAULT_PATH, thumb_path, strlen(MEDIA_CONTENT_THUMB_DEFAULT_PATH)) != 0)
122 g_array_append_val(thumb_list, thumb_path);
125 media_content_error("media_info_get_media_type failed");
131 static int __media_info_insert_batch(media_batch_insert_e insert_type, const char **path_array,
132 unsigned int array_length,
133 media_insert_completed_cb completed_cb,
136 int ret = MEDIA_CONTENT_ERROR_NONE;
138 char list_path[255] = {0, };
139 unsigned int idx = 0;
142 for (idx = 0; idx < BATCH_REQUEST_MAX; idx++) {
143 snprintf(list_path, sizeof(list_path), "%s/request-%ld-%d", MEDIA_CONTENT_INSERT_FILES_PATH, media_content_gettid(), idx);
145 if (g_file_test(list_path, G_FILE_TEST_EXISTS | G_FILE_TEST_IS_REGULAR)) {
146 memset(list_path, 0x00, sizeof(list_path));
149 media_content_debug("The request file list path : %s", list_path);
154 if (idx == BATCH_REQUEST_MAX) {
155 media_content_error("Too many batch request for one thread");
156 return MEDIA_CONTENT_ERROR_DB_BUSY;
159 fp = fopen(list_path, "w");
161 media_content_error("failed to open file : [%s]", list_path);
162 media_content_stderror("failed to open file");
163 return MEDIA_CONTENT_ERROR_INVALID_OPERATION;
166 for (idx = 0; idx < array_length; idx++) {
167 if (STRING_VALID(path_array[idx])) {
168 int size = strlen(path_array[idx]);
170 ret = _media_util_check_file_exist(path_array[idx]);
171 if (ret != MEDIA_CONTENT_ERROR_NONE) {
173 if (unlink(list_path) < 0)
174 media_content_stderror("failed to delete");
178 nwrites = fwrite(path_array[idx], 1, size, fp);
179 if (nwrites != size) {
180 media_content_stderror("failed to write");
182 if (unlink(list_path) < 0)
183 media_content_stderror("failed to delete");
184 return MEDIA_CONTENT_ERROR_INVALID_OPERATION;
187 nwrites = fwrite("\n", 1, 1, fp);
189 media_content_stderror("failed to write");
191 if (unlink(list_path) < 0)
192 media_content_stderror("failed to delete");
193 return MEDIA_CONTENT_ERROR_INVALID_OPERATION;
196 media_content_error("path[%d] is invalid string", idx);
202 media_insert_cb_s *_cb_data = (media_insert_cb_s *)calloc(1, sizeof(media_insert_cb_s));
203 media_content_retvm_if(_cb_data == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
205 _cb_data->insert_completed_cb = completed_cb;
206 _cb_data->user_data = user_data;
207 _cb_data->insert_list_path = g_strdup(list_path);
209 if (insert_type == MEDIA_BATCH_INSERT_NORMAL)
210 ret = media_files_register(list_path, __media_info_insert_completed_cb, _cb_data, tzplatform_getuid(TZ_USER_NAME));
211 else if (insert_type == MEDIA_BATCH_INSERT_BURSTSHOT)
212 ret = media_burstshot_register(list_path, __media_info_insert_completed_cb, _cb_data, tzplatform_getuid(TZ_USER_NAME));
214 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
216 if (ret != MEDIA_CONTENT_ERROR_NONE) {
217 media_content_error("media_files_register failed : %d", ret);
218 if (unlink(list_path) < 0)
219 media_content_stderror("failed to delete");
220 return _content_error_capi(MEDIA_CONTENT_TYPE, ret);
226 void _media_info_item_get_detail(sqlite3_stmt* stmt, media_info_h media)
228 media_info_s *_media = (media_info_s*)media;
230 _media->media_id = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_UUID));
231 _media->file_path = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_PATH));
232 _media->display_name = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_FILE_NAME));
233 _media->media_type = (int)sqlite3_column_int(stmt, MEDIA_INFO_TYPE);
234 _media->mime_type = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_MIME_TYPE));
235 _media->size = (unsigned long long)sqlite3_column_int64(stmt, MEDIA_INFO_SIZE);
236 _media->added_time = (int)sqlite3_column_int(stmt, MEDIA_INFO_ADDED_TIME);
237 _media->modified_time = (int)sqlite3_column_int(stmt, MEDIA_INFO_MODIFIED_TIME);
238 _media->thumbnail_path = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_THUMBNAIL_PATH));
239 _media->description = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_DESCRIPTION));
240 _media->rating = (int)sqlite3_column_int(stmt, MEDIA_INFO_RATING);
241 _media->favourite = (int)sqlite3_column_int(stmt, MEDIA_INFO_FAVOURITE);
242 _media->author = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_AUTHOR));
243 _media->provider = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_PROVIDER));
244 _media->content_name = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_CONTENT_NAME));
245 _media->category = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_CATEGORY));
246 _media->location_tag = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_LOCATION_TAG));
247 _media->age_rating = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_AGE_RATING));
248 _media->keyword = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_KEYWORD));
249 _media->is_drm = (int)sqlite3_column_int(stmt, MEDIA_INFO_IS_DRM);
250 _media->storage_type = (int)sqlite3_column_int(stmt, MEDIA_INFO_STORAGE_TYPE);
251 _media->longitude = (double)sqlite3_column_double(stmt, MEDIA_INFO_LONGITUDE);
252 _media->latitude = (double)sqlite3_column_double(stmt, MEDIA_INFO_LATITUDE);
253 _media->altitude = (double)sqlite3_column_double(stmt, MEDIA_INFO_ALTITUDE);
254 _media->played_count = sqlite3_column_int(stmt, MEDIA_INFO_PLAYED_COUNT);
255 _media->played_time = sqlite3_column_int(stmt, MEDIA_INFO_LAST_PLAYED_TIME);
256 _media->played_position = sqlite3_column_int(stmt, MEDIA_INFO_LAST_PLAYED_POSITION);
257 _media->title = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_TITLE));
258 _media->timeline = (double)sqlite3_column_double(stmt, MEDIA_INFO_TIMELINE);
259 _media->weather = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_WEATHER));
260 _media->sync_status = (int)sqlite3_column_int(stmt, MEDIA_INFO_SYNC_STATUS);
261 _media->storage_uuid = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_STORAGE_UUID));
263 if (_media->media_type == MEDIA_CONTENT_TYPE_IMAGE) {
264 _media->image_meta = (image_meta_s *)calloc(1, sizeof(image_meta_s));
265 if (_media->image_meta) {
266 _media->image_meta->media_id = g_strdup(_media->media_id);
267 _media->image_meta->width = sqlite3_column_int(stmt, MEDIA_INFO_WIDTH);
268 _media->image_meta->height = sqlite3_column_int(stmt, MEDIA_INFO_HEIGHT);
269 _media->image_meta->fnumber = (double)sqlite3_column_double(stmt, MEDIA_INFO_FNUMBER);
270 _media->image_meta->iso = sqlite3_column_int(stmt, MEDIA_INFO_ISO);
271 _media->image_meta->date_taken = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_DATETAKEN));
272 _media->image_meta->orientation = sqlite3_column_int(stmt, MEDIA_INFO_ORIENTATION);
273 _media->image_meta->title = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_TITLE));
274 _media->image_meta->burst_id = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_BURST_ID));
275 _media->image_meta->weather = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_WEATHER));
276 _media->image_meta->exposure_time = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_EXPOSURE_TIME));
277 _media->image_meta->model = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_MODEL));
279 } else if (_media->media_type == MEDIA_CONTENT_TYPE_VIDEO) {
280 _media->video_meta = (video_meta_s *)calloc(1, sizeof(video_meta_s));
281 if (_media->video_meta) {
282 _media->video_meta->media_id = g_strdup(_media->media_id);
283 _media->video_meta->width = sqlite3_column_int(stmt, MEDIA_INFO_WIDTH);
284 _media->video_meta->height = sqlite3_column_int(stmt, MEDIA_INFO_HEIGHT);
285 _media->video_meta->title = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_TITLE));
286 _media->video_meta->album = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_ALBUM));
287 _media->video_meta->artist = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_ARTIST));
288 _media->video_meta->album_artist = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_ALBUM_ARTIST));
289 _media->video_meta->genre = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_GENRE));
290 _media->video_meta->composer = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_COMPOSER));
291 _media->video_meta->year = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_YEAR));
292 _media->video_meta->recorded_date = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_RECORDED_DATE));
293 _media->video_meta->copyright = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_COPYRIGHT));
294 _media->video_meta->track_num = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_TRACK_NUM));
295 _media->video_meta->bitrate = sqlite3_column_int(stmt, MEDIA_INFO_BITRATE);
296 _media->video_meta->duration = sqlite3_column_int(stmt, MEDIA_INFO_DURATION);
297 _media->video_meta->played_count = sqlite3_column_int(stmt, MEDIA_INFO_PLAYED_COUNT);
298 _media->video_meta->played_time = sqlite3_column_int(stmt, MEDIA_INFO_LAST_PLAYED_TIME);
299 _media->video_meta->played_position = sqlite3_column_int(stmt, MEDIA_INFO_LAST_PLAYED_POSITION);
302 } else if ((_media->media_type == MEDIA_CONTENT_TYPE_MUSIC) || (_media->media_type == MEDIA_CONTENT_TYPE_SOUND)) {
303 _media->audio_meta = (audio_meta_s *)calloc(1, sizeof(audio_meta_s));
304 if (_media->audio_meta) {
305 _media->audio_meta->media_id = g_strdup(_media->media_id);
306 _media->audio_meta->title = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_TITLE));
307 _media->audio_meta->album = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_ALBUM));
308 _media->audio_meta->artist = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_ARTIST));
309 _media->audio_meta->album_artist = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_ALBUM_ARTIST));
310 _media->audio_meta->genre = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_GENRE));
311 _media->audio_meta->composer = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_COMPOSER));
312 _media->audio_meta->year = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_YEAR));
313 _media->audio_meta->recorded_date = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_RECORDED_DATE));
314 _media->audio_meta->copyright = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_COPYRIGHT));
315 _media->audio_meta->track_num = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_TRACK_NUM));
316 _media->audio_meta->bitrate = sqlite3_column_int(stmt, MEDIA_INFO_BITRATE);
317 _media->audio_meta->bitpersample = sqlite3_column_int(stmt, MEDIA_INFO_BITPERSAMPLE);
318 _media->audio_meta->duration = sqlite3_column_int(stmt, MEDIA_INFO_DURATION);
319 _media->audio_meta->played_count = sqlite3_column_int(stmt, MEDIA_INFO_PLAYED_COUNT);
320 _media->audio_meta->played_time = sqlite3_column_int(stmt, MEDIA_INFO_LAST_PLAYED_TIME);
321 _media->audio_meta->played_position = sqlite3_column_int(stmt, MEDIA_INFO_LAST_PLAYED_POSITION);
322 _media->audio_meta->samplerate = sqlite3_column_int(stmt, MEDIA_INFO_SAMPLERATE);
323 _media->audio_meta->channel = sqlite3_column_int(stmt, MEDIA_INFO_CHANNEL);
328 int _media_info_get_media_info_from_db(const char *path, const char *storage_id, media_info_h media)
330 int ret = MEDIA_CONTENT_ERROR_NONE;
331 sqlite3_stmt *stmt = NULL;
332 char *select_query = NULL;
333 media_info_s *_media = (media_info_s*)media;
335 media_content_retvm_if(_media == NULL, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "invalid media");
337 select_query = sqlite3_mprintf(SELECT_MEDIA_BY_PATH, storage_id, path);
339 ret = _content_query_prepare(&stmt, select_query, NULL, NULL);
340 SQLITE3_SAFE_FREE(select_query);
341 media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
343 if (sqlite3_step(stmt) == SQLITE_ROW) {
344 _media_info_item_get_detail(stmt, (media_info_h)_media);
346 media_content_error("There's no media!!");
347 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
350 SQLITE3_FINALIZE(stmt);
355 int media_info_insert_to_db(const char *path, media_info_h *info)
357 bool ignore_file = FALSE;
358 bool ignore_dir = FALSE;
359 char *folder_path = NULL;
360 char storage_id[MEDIA_CONTENT_UUID_SIZE+1] = {0, };
361 int ret = MEDIA_CONTENT_ERROR_NONE;
363 media_content_retvm_if(!STRING_VALID(path), MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "invalid path");
364 media_content_retvm_if(info == NULL, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "invalid info");
366 ret = _media_util_check_ignore_file(path, &ignore_file);
367 media_content_retvm_if(ignore_file == TRUE, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid path");
369 ret = _media_util_check_file_exist(path);
370 media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
372 folder_path = g_path_get_dirname(path);
373 ret = _media_util_check_ignore_dir(folder_path, &ignore_dir);
374 SAFE_FREE(folder_path);
376 media_content_retvm_if(ignore_dir == TRUE, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid folder path");
378 memset(storage_id, 0x00, sizeof(storage_id));
379 ret = media_svc_get_storage_id(_content_get_db_handle(), path, storage_id);
380 if (ret != MS_MEDIA_ERR_NONE) {
381 media_content_error("media_svc_get_storage_id failed : %d", ret);
382 return _content_error_capi(MEDIA_CONTENT_TYPE, ret);
385 ret = media_svc_check_item_exist_by_path(_content_get_db_handle(), storage_id, path);
386 if (ret == MS_MEDIA_ERR_DB_NO_RECORD) {
387 media_content_sec_debug("media_svc_check_item_exist_by_path : no record : %s", path);
389 media_svc_storage_type_e storage_type = 0;
391 ret = media_svc_get_storage_type(path, &storage_type, tzplatform_getuid(TZ_USER_NAME));
392 if (ret != MS_MEDIA_ERR_NONE) {
393 media_content_sec_error("media_svc_get_storage_type failed : %d", ret);
394 return _content_error_capi(MEDIA_CONTENT_TYPE, ret);
397 ret = media_svc_insert_item_immediately(_content_get_db_handle(), storage_id, storage_type, path, tzplatform_getuid(TZ_USER_NAME));
399 if (ret != MS_MEDIA_ERR_NONE) {
400 if (ret == MS_MEDIA_ERR_DB_CONSTRAINT_FAIL) {
401 media_content_sec_error("This item is already inserted. This may be normal operation because other process already did this (%s)", path);
402 ret = MEDIA_CONTENT_ERROR_NONE;
404 media_content_sec_error("media_svc_insert_item_immediately failed : %d (%s)", ret, path);
407 return _content_error_capi(MEDIA_CONTENT_TYPE, ret);
409 } else if (ret != MS_MEDIA_ERR_NONE) {
410 media_content_sec_error("media_svc_check_item_exist_by_path failed : %d (%s)", ret, path);
411 return _content_error_capi(MEDIA_CONTENT_TYPE, ret);
414 media_info_s *_media = (media_info_s*)calloc(1, sizeof(media_info_s));
415 media_content_retvm_if(_media == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
417 ret = _media_info_get_media_info_from_db(path, DEFAULT_MEDIA_STORAGE_ID, (media_info_h)_media);
419 *info = (media_info_h)_media;
423 int media_info_insert_batch_to_db(
424 const char **path_array,
425 unsigned int array_length,
426 media_insert_completed_cb completed_cb,
429 media_content_retvm_if(path_array == NULL, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid path_array");
430 media_content_retvm_if(array_length <= 0, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid array_length");
432 return __media_info_insert_batch(MEDIA_BATCH_INSERT_NORMAL, path_array, array_length, completed_cb, user_data);
435 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)
437 media_content_retvm_if(path_array == NULL, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid path_array");
438 media_content_retvm_if(array_length <= 0, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid array_length");
440 return __media_info_insert_batch(MEDIA_BATCH_INSERT_BURSTSHOT, path_array, array_length, callback, user_data);
443 int media_info_delete_from_db(const char *media_id)
445 int ret = MEDIA_CONTENT_ERROR_NONE;
447 char storage_id[MEDIA_CONTENT_UUID_SIZE+1] = {0, };
449 if (!STRING_VALID(media_id)) {
450 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
451 return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
454 memset(storage_id, 0x00, sizeof(storage_id));
456 ret = __media_info_get_media_path_by_id_from_db(media_id, &path);
457 if (ret != MEDIA_CONTENT_ERROR_NONE) {
458 media_content_error("__media_info_get_media_path_by_id_from_db failed : %d", ret);
463 ret = _media_db_get_storage_id_by_media_id(media_id, storage_id);
464 if (ret != MEDIA_CONTENT_ERROR_NONE) {
465 media_content_error("_media_db_get_storage_id_by_media_id failed : %d", ret);
470 ret = media_svc_delete_item_by_path(_content_get_db_handle(), storage_id, path, tzplatform_getuid(TZ_USER_NAME));
473 return _content_error_capi(MEDIA_CONTENT_TYPE, ret);
476 static int __media_info_delete_thumb_from_list(GArray *thumb_list)
480 char *thumb_path = NULL;
482 if (thumb_list != NULL) {
483 list_len = thumb_list->len;
484 for (i = 0; i < list_len; i++) {
485 thumb_path = g_array_index(thumb_list, char*, i);
486 media_content_debug("thumb path [%s]", thumb_path);
487 if (unlink(thumb_path) < 0)
488 media_content_stderror("failed to delete");
491 return MEDIA_CONTENT_ERROR_NONE;
494 static int __media_info_release_thumb_list(GArray *thumb_list)
498 char *thumb_path = NULL;
500 if (thumb_list != NULL) {
501 list_len = thumb_list->len;
502 for (i = 0; i < list_len; i++) {
503 thumb_path = g_array_index(thumb_list, char*, 0);
504 g_array_remove_index(thumb_list, 0);
505 SAFE_FREE(thumb_path);
508 g_array_free(thumb_list, FALSE);
511 return MEDIA_CONTENT_ERROR_NONE;
514 int media_info_delete_batch_from_db(filter_h filter)
516 int ret = MEDIA_CONTENT_ERROR_NONE;
518 char *query_string = NULL;
519 filter_s *_filter = NULL;
521 char *condition_query = NULL;
522 GArray *thumb_list = NULL;
524 media_content_retvm_if(filter == NULL, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid filter");
526 thumb_list = g_array_new(FALSE, FALSE, sizeof(char*));
528 /* Delete thumbnail of each item */
529 ret = _media_db_get_group_item(NULL, filter, __media_info_delete_batch_cb, thumb_list, MEDIA_GROUP_NONE);
531 _filter = (filter_s*)filter;
532 attr = _content_get_attirbute_handle();
534 if (_filter->condition) {
535 ret = _media_filter_attribute_generate(attr, _filter->condition, _filter->condition_collate_type, &condition_query);
536 if (ret != MEDIA_CONTENT_ERROR_NONE) {
537 __media_info_release_thumb_list(thumb_list);
542 if (STRING_VALID(condition_query)) {
543 if (_filter->storage_id == NULL) {
545 query_string = sqlite3_mprintf(DELETE_MEDIA_FROM_MEDIA_BATCH, "media", condition_query);
547 query_string = sqlite3_mprintf(DELETE_MEDIA_FROM_MEDIA_BATCH, _filter->storage_id, condition_query);
550 SAFE_FREE(condition_query);
551 __media_info_release_thumb_list(thumb_list);
553 return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
556 ret = _content_query_sql(query_string);
557 if (ret == MEDIA_CONTENT_ERROR_NONE) {
558 /* Send notification for this
559 In this case, send noti for internal storage and external storage
561 media_content_debug("Batch deletion is successfull. Send notification for this");
562 if (_filter->storage_id != NULL) {
563 char *storage_path = NULL;
564 media_svc_get_storage_path(_content_get_db_handle(), _filter->storage_id, &storage_path);
565 if (STRING_VALID(storage_path))
566 media_svc_publish_noti(MS_MEDIA_ITEM_DIRECTORY, MS_MEDIA_ITEM_UPDATE, storage_path, -1, NULL, NULL);
568 SAFE_FREE(storage_path);
571 media_svc_publish_noti(MS_MEDIA_ITEM_DIRECTORY, MS_MEDIA_ITEM_UPDATE, MEDIA_ROOT_PATH_INTERNAL, -1, NULL, NULL);
572 media_svc_publish_noti(MS_MEDIA_ITEM_DIRECTORY, MS_MEDIA_ITEM_UPDATE, MEDIA_ROOT_PATH_SDCARD, -1, NULL, NULL);
575 __media_info_delete_thumb_from_list(thumb_list);
576 __media_info_release_thumb_list(thumb_list);
579 SAFE_FREE(condition_query);
580 SQLITE3_SAFE_FREE(query_string);
585 int media_info_destroy(media_info_h media)
587 int ret = MEDIA_CONTENT_ERROR_NONE;
588 media_info_s *_media = (media_info_s*)media;
591 SAFE_FREE(_media->media_id);
592 SAFE_FREE(_media->file_path);
593 SAFE_FREE(_media->display_name);
594 SAFE_FREE(_media->mime_type);
595 SAFE_FREE(_media->thumbnail_path);
596 SAFE_FREE(_media->description);
597 SAFE_FREE(_media->author);
598 SAFE_FREE(_media->provider);
599 SAFE_FREE(_media->content_name);
600 SAFE_FREE(_media->category);
601 SAFE_FREE(_media->location_tag);
602 SAFE_FREE(_media->age_rating);
603 SAFE_FREE(_media->keyword);
604 SAFE_FREE(_media->title);
605 SAFE_FREE(_media->weather);
606 SAFE_FREE(_media->storage_uuid);
608 if (_media->image_meta) {
609 SAFE_FREE(_media->image_meta->media_id);
610 SAFE_FREE(_media->image_meta->date_taken);
611 SAFE_FREE(_media->image_meta->burst_id);
612 SAFE_FREE(_media->image_meta->exposure_time);
613 SAFE_FREE(_media->image_meta->model);
614 SAFE_FREE(_media->image_meta->title);
615 SAFE_FREE(_media->image_meta->weather);
617 SAFE_FREE(_media->image_meta);
620 if (_media->video_meta) {
621 SAFE_FREE(_media->video_meta->media_id);
622 SAFE_FREE(_media->video_meta->title);
623 SAFE_FREE(_media->video_meta->album);
624 SAFE_FREE(_media->video_meta->artist);
625 SAFE_FREE(_media->video_meta->album_artist);
626 SAFE_FREE(_media->video_meta->genre);
627 SAFE_FREE(_media->video_meta->composer);
628 SAFE_FREE(_media->video_meta->year);
629 SAFE_FREE(_media->video_meta->recorded_date);
630 SAFE_FREE(_media->video_meta->copyright);
631 SAFE_FREE(_media->video_meta->track_num);
633 SAFE_FREE(_media->video_meta);
636 if (_media->audio_meta) {
637 SAFE_FREE(_media->audio_meta->media_id);
638 SAFE_FREE(_media->audio_meta->title);
639 SAFE_FREE(_media->audio_meta->album);
640 SAFE_FREE(_media->audio_meta->artist);
641 SAFE_FREE(_media->audio_meta->album_artist);
642 SAFE_FREE(_media->audio_meta->genre);
643 SAFE_FREE(_media->audio_meta->composer);
644 SAFE_FREE(_media->audio_meta->year);
645 SAFE_FREE(_media->audio_meta->recorded_date);
646 SAFE_FREE(_media->audio_meta->copyright);
647 SAFE_FREE(_media->audio_meta->track_num);
649 SAFE_FREE(_media->audio_meta);
654 ret = MEDIA_CONTENT_ERROR_NONE;
656 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
657 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
663 int media_info_clone(media_info_h *dst, media_info_h src)
665 int ret = MEDIA_CONTENT_ERROR_NONE;
666 media_info_s *_src = (media_info_s*)src;
669 media_info_s *_dst = (media_info_s*)calloc(1, sizeof(media_info_s));
670 media_content_retvm_if(_dst == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
672 if (_src->media_id) {
673 _dst->media_id = g_strdup(_src->media_id);
674 if (_dst->media_id == NULL) {
675 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
676 media_info_destroy((media_info_h)_dst);
677 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
680 if (_src->file_path) {
681 _dst->file_path = g_strdup(_src->file_path);
682 if (_dst->file_path == NULL) {
683 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
684 media_info_destroy((media_info_h)_dst);
685 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
688 if (_src->display_name != NULL) {
689 _dst->display_name = g_strdup(_src->display_name);
690 if (_dst->display_name == NULL) {
691 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
692 media_info_destroy((media_info_h)_dst);
693 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
696 if (_src->mime_type) {
697 _dst->mime_type = g_strdup(_src->mime_type);
698 if (_dst->mime_type == NULL) {
699 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
700 media_info_destroy((media_info_h)_dst);
701 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
704 if (_src->thumbnail_path != NULL) {
705 _dst->thumbnail_path = g_strdup(_src->thumbnail_path);
706 if (_dst->thumbnail_path == NULL) {
707 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
708 media_info_destroy((media_info_h)_dst);
709 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
712 if (_src->description != NULL) {
713 _dst->description = g_strdup(_src->description);
714 if (_dst->description == NULL) {
715 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
716 media_info_destroy((media_info_h)_dst);
717 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
721 if (_src->weather != NULL) {
722 _dst->weather = g_strdup(_src->weather);
723 if (_dst->weather == NULL) {
724 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
725 media_info_destroy((media_info_h)_dst);
726 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
730 if (_src->title != NULL) {
731 _dst->title = g_strdup(_src->title);
732 if (_dst->title == NULL) {
733 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
734 media_info_destroy((media_info_h)_dst);
735 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
738 if (_src->author != NULL) {
739 _dst->author = g_strdup(_src->author);
740 if (_dst->author == NULL) {
741 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
742 media_info_destroy((media_info_h)_dst);
743 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
746 if (_src->provider != NULL) {
747 _dst->provider = g_strdup(_src->provider);
748 if (_dst->provider == NULL) {
749 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
750 media_info_destroy((media_info_h)_dst);
751 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
754 if (_src->content_name != NULL) {
755 _dst->content_name = g_strdup(_src->content_name);
756 if (_dst->content_name == NULL) {
757 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
758 media_info_destroy((media_info_h)_dst);
759 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
762 if (_src->category != NULL) {
763 _dst->category = g_strdup(_src->category);
764 if (_dst->category == NULL) {
765 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
766 media_info_destroy((media_info_h)_dst);
767 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
770 if (_src->location_tag != NULL) {
771 _dst->location_tag = g_strdup(_src->location_tag);
772 if (_dst->location_tag == NULL) {
773 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
774 media_info_destroy((media_info_h)_dst);
775 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
778 if (_src->age_rating != NULL) {
779 _dst->age_rating = g_strdup(_src->age_rating);
780 if (_dst->age_rating == NULL) {
781 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
782 media_info_destroy((media_info_h)_dst);
783 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
786 if (_src->keyword != NULL) {
787 _dst->keyword = g_strdup(_src->keyword);
788 if (_dst->keyword == NULL) {
789 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
790 media_info_destroy((media_info_h)_dst);
791 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
795 if (_src->storage_uuid != NULL) {
796 _dst->storage_uuid = g_strdup(_src->storage_uuid);
797 if (_dst->storage_uuid == NULL) {
798 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
799 media_info_destroy((media_info_h)_dst);
800 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
804 _dst->media_type = _src->media_type;
805 _dst->size = _src->size;
806 _dst->added_time = _src->added_time;
807 _dst->modified_time = _src->modified_time;
808 _dst->timeline = _src->timeline;
809 _dst->longitude = _src->longitude;
810 _dst->latitude = _src->latitude;
811 _dst->altitude = _src->altitude;
812 _dst->rating = _src->rating;
813 _dst->favourite = _src->favourite;
814 _dst->is_drm = _src->is_drm;
815 _dst->storage_type = _src->storage_type;
816 _dst->played_count = _src->played_count;
817 _dst->played_time = _src->played_time;
818 _dst->played_position = _src->played_position;
819 _dst->sync_status = _src->sync_status;
820 _dst->request_id = _src->request_id;
822 if (_src->media_type == MEDIA_CONTENT_TYPE_IMAGE && _src->image_meta) {
823 _dst->image_meta = (image_meta_s *)calloc(1, sizeof(image_meta_s));
824 if (_dst->image_meta == NULL) {
825 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
826 media_info_destroy((media_info_h)_dst);
827 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
830 if (_src->image_meta->media_id != NULL) {
831 _dst->image_meta->media_id = g_strdup(_src->image_meta->media_id);
832 if (_dst->image_meta->media_id == NULL) {
833 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
834 media_info_destroy((media_info_h)_dst);
835 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
839 if (_src->image_meta->date_taken != NULL) {
840 _dst->image_meta->date_taken = g_strdup(_src->image_meta->date_taken);
841 if (_dst->image_meta->date_taken == NULL) {
842 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
843 media_info_destroy((media_info_h)_dst);
844 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
848 if (_src->image_meta->burst_id != NULL) {
849 _dst->image_meta->burst_id = g_strdup(_src->image_meta->burst_id);
850 if (_dst->image_meta->burst_id == NULL) {
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;
857 if (_src->image_meta->weather != NULL) {
858 _dst->image_meta->weather = g_strdup(_src->image_meta->weather);
859 if (_dst->image_meta->weather == NULL) {
860 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
861 media_info_destroy((media_info_h)_dst);
862 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
866 if (_src->image_meta->exposure_time != NULL) {
867 _dst->image_meta->exposure_time = g_strdup(_src->image_meta->exposure_time);
868 if (_dst->image_meta->exposure_time == NULL) {
869 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
870 media_info_destroy((media_info_h)_dst);
871 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
875 if (_src->image_meta->model != NULL) {
876 _dst->image_meta->model = g_strdup(_src->image_meta->model);
877 if (_dst->image_meta->model == NULL) {
878 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
879 media_info_destroy((media_info_h)_dst);
880 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
884 _dst->image_meta->fnumber = _src->image_meta->fnumber;
885 _dst->image_meta->iso = _src->image_meta->iso;
886 _dst->image_meta->width = _src->image_meta->width;
887 _dst->image_meta->height = _src->image_meta->height;
888 _dst->image_meta->orientation = _src->image_meta->orientation;
890 } else if (_src->media_type == MEDIA_CONTENT_TYPE_VIDEO && _src->video_meta) {
891 _dst->video_meta = (video_meta_s *)calloc(1, sizeof(video_meta_s));
892 if (_dst->video_meta == NULL) {
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;
898 if (_src->video_meta->media_id != NULL) {
899 _dst->video_meta->media_id = g_strdup(_src->video_meta->media_id);
900 if (_dst->video_meta->media_id == NULL) {
901 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
902 media_info_destroy((media_info_h)_dst);
903 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
906 if (_src->video_meta->title != NULL) {
907 _dst->video_meta->title = g_strdup(_src->video_meta->title);
908 if (_dst->video_meta->title == NULL) {
909 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
910 media_info_destroy((media_info_h)_dst);
911 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
914 if (_src->video_meta->album != NULL) {
915 _dst->video_meta->album = g_strdup(_src->video_meta->album);
916 if (_dst->video_meta->album == NULL) {
917 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
918 media_info_destroy((media_info_h)_dst);
919 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
922 if (_src->video_meta->artist != NULL) {
923 _dst->video_meta->artist = g_strdup(_src->video_meta->artist);
924 if (_dst->video_meta->artist == NULL) {
925 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
926 media_info_destroy((media_info_h)_dst);
927 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
930 if (_src->video_meta->album_artist != NULL) {
931 _dst->video_meta->album_artist = g_strdup(_src->video_meta->album_artist);
932 if (_dst->video_meta->album_artist == NULL) {
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;
938 if (_src->video_meta->genre != NULL) {
939 _dst->video_meta->genre = g_strdup(_src->video_meta->genre);
940 if (_dst->video_meta->genre == NULL) {
941 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
942 media_info_destroy((media_info_h)_dst);
943 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
946 if (_src->video_meta->composer != NULL) {
947 _dst->video_meta->composer = g_strdup(_src->video_meta->composer);
948 if (_dst->video_meta->composer == NULL) {
949 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
950 media_info_destroy((media_info_h)_dst);
951 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
954 if (_src->video_meta->year != NULL) {
955 _dst->video_meta->year = g_strdup(_src->video_meta->year);
956 if (_dst->video_meta->year == NULL) {
957 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
958 media_info_destroy((media_info_h)_dst);
959 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
962 if (_src->video_meta->recorded_date != NULL) {
963 _dst->video_meta->recorded_date = g_strdup(_src->video_meta->recorded_date);
964 if (_dst->video_meta->recorded_date == NULL) {
965 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
966 media_info_destroy((media_info_h)_dst);
967 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
970 if (_src->video_meta->copyright != NULL) {
971 _dst->video_meta->copyright = g_strdup(_src->video_meta->copyright);
972 if (_dst->video_meta->copyright == NULL) {
973 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
974 media_info_destroy((media_info_h)_dst);
975 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
978 if (_src->video_meta->track_num != NULL) {
979 _dst->video_meta->track_num = g_strdup(_src->video_meta->track_num);
980 if (_dst->video_meta->track_num == NULL) {
981 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
982 media_info_destroy((media_info_h)_dst);
983 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
987 _dst->video_meta->width = _src->video_meta->width;
988 _dst->video_meta->height = _src->video_meta->height;
989 _dst->video_meta->duration = _src->video_meta->duration;
990 _dst->video_meta->bitrate = _src->video_meta->bitrate;
991 _dst->video_meta->played_count = _src->video_meta->played_count;
992 _dst->video_meta->played_time = _src->video_meta->played_time;
993 _dst->video_meta->played_position = _src->video_meta->played_position;
995 } else if ((_src->media_type == MEDIA_CONTENT_TYPE_MUSIC || _src->media_type == MEDIA_CONTENT_TYPE_SOUND) && _src->audio_meta) {
996 _dst->audio_meta = (audio_meta_s *)calloc(1, sizeof(audio_meta_s));
997 if (_dst->audio_meta == NULL) {
998 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
999 media_info_destroy((media_info_h)_dst);
1000 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
1003 if (_src->audio_meta->media_id != NULL) {
1004 _dst->audio_meta->media_id = g_strdup(_src->audio_meta->media_id);
1005 if (_dst->audio_meta->media_id == NULL) {
1006 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
1007 media_info_destroy((media_info_h)_dst);
1008 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
1011 if (_src->audio_meta->title != NULL) {
1012 _dst->audio_meta->title = g_strdup(_src->audio_meta->title);
1013 if (_dst->audio_meta->title == NULL) {
1014 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
1015 media_info_destroy((media_info_h)_dst);
1016 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
1019 if (_src->audio_meta->album != NULL) {
1020 _dst->audio_meta->album = g_strdup(_src->audio_meta->album);
1021 if (_dst->audio_meta->album == NULL) {
1022 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
1023 media_info_destroy((media_info_h)_dst);
1024 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
1027 if (_src->audio_meta->artist != NULL) {
1028 _dst->audio_meta->artist = g_strdup(_src->audio_meta->artist);
1029 if (_dst->audio_meta->artist == NULL) {
1030 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
1031 media_info_destroy((media_info_h)_dst);
1032 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
1035 if (_src->audio_meta->album_artist != NULL) {
1036 _dst->audio_meta->album_artist = g_strdup(_src->audio_meta->album_artist);
1037 if (_dst->audio_meta->album_artist == NULL) {
1038 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
1039 media_info_destroy((media_info_h)_dst);
1040 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
1043 if (_src->audio_meta->genre != NULL) {
1044 _dst->audio_meta->genre = g_strdup(_src->audio_meta->genre);
1045 if (_dst->audio_meta->genre == NULL) {
1046 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
1047 media_info_destroy((media_info_h)_dst);
1048 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
1051 if (_src->audio_meta->composer != NULL) {
1052 _dst->audio_meta->composer = g_strdup(_src->audio_meta->composer);
1053 if (_dst->audio_meta->composer == NULL) {
1054 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
1055 media_info_destroy((media_info_h)_dst);
1056 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
1059 if (_src->audio_meta->year != NULL) {
1060 _dst->audio_meta->year = g_strdup(_src->audio_meta->year);
1061 if (_dst->audio_meta->year == NULL) {
1062 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
1063 media_info_destroy((media_info_h)_dst);
1064 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
1067 if (_src->audio_meta->recorded_date != NULL) {
1068 _dst->audio_meta->recorded_date = g_strdup(_src->audio_meta->recorded_date);
1069 if (_dst->audio_meta->recorded_date == NULL) {
1070 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
1071 media_info_destroy((media_info_h)_dst);
1072 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
1075 if (_src->audio_meta->copyright != NULL) {
1076 _dst->audio_meta->copyright = g_strdup(_src->audio_meta->copyright);
1077 if (_dst->audio_meta->copyright == NULL) {
1078 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
1079 media_info_destroy((media_info_h)_dst);
1080 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
1083 if (_src->audio_meta->track_num != NULL) {
1084 _dst->audio_meta->track_num = g_strdup(_src->audio_meta->track_num);
1085 if (_dst->audio_meta->track_num == NULL) {
1086 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
1087 media_info_destroy((media_info_h)_dst);
1088 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
1092 _dst->audio_meta->channel = _src->audio_meta->channel;
1093 _dst->audio_meta->samplerate = _src->audio_meta->samplerate;
1094 _dst->audio_meta->duration = _src->audio_meta->duration;
1095 _dst->audio_meta->bitrate = _src->audio_meta->bitrate;
1096 _dst->audio_meta->bitpersample = _src->audio_meta->bitpersample;
1097 _dst->audio_meta->played_count = _src->audio_meta->played_count;
1098 _dst->audio_meta->played_time = _src->audio_meta->played_time;
1099 _dst->audio_meta->played_position = _src->audio_meta->played_position;
1101 *dst = (media_info_h)_dst;
1103 ret = MEDIA_CONTENT_ERROR_NONE;
1105 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1106 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1112 int media_info_get_media_count_from_db(filter_h filter, int *media_count)
1114 int ret = MEDIA_CONTENT_ERROR_NONE;
1116 if (media_count == NULL) {
1117 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1118 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1123 ret = _media_db_get_group_item_count(NULL, filter, MEDIA_GROUP_NONE, media_count);
1128 int media_info_foreach_media_from_db(filter_h filter, media_info_cb callback, void *user_data)
1130 int ret = MEDIA_CONTENT_ERROR_NONE;
1132 media_content_retvm_if(callback == NULL, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid callback");
1134 ret = _media_db_get_group_item(NULL, filter, callback, user_data, MEDIA_GROUP_NONE);
1139 int media_info_get_tag_count_from_db(const char *media_id, filter_h filter, int *tag_count)
1141 int ret = MEDIA_CONTENT_ERROR_NONE;
1143 if (STRING_VALID(media_id) && tag_count) {
1144 ret = _media_db_get_group_item_count(media_id, filter, MEDIA_GROUP_TAG_BY_MEDIA_ID, tag_count);
1146 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1147 return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1153 int media_info_foreach_tag_from_db(const char *media_id, filter_h filter, media_tag_cb callback, void *user_data)
1155 int ret = MEDIA_CONTENT_ERROR_NONE;
1157 if ((callback != NULL) && STRING_VALID(media_id)) {
1158 ret = _media_db_get_tag(media_id, filter, callback, user_data);
1160 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1161 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1167 int media_info_get_bookmark_count_from_db(const char *media_id, filter_h filter, int *bookmark_count)
1169 int ret = MEDIA_CONTENT_ERROR_NONE;
1171 if (STRING_VALID(media_id) && bookmark_count) {
1172 ret = _media_db_get_group_item_count(media_id, filter, MEDIA_GROUP_BOOKMARK_BY_MEDIA_ID, bookmark_count);
1174 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1175 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1181 int media_info_foreach_bookmark_from_db(const char *media_id, filter_h filter, media_bookmark_cb callback, void *user_data)
1183 int ret = MEDIA_CONTENT_ERROR_NONE;
1185 if ((callback != NULL) && STRING_VALID(media_id)) {
1186 ret = _media_db_get_bookmark(media_id, filter, callback, user_data);
1188 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1189 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1195 int media_info_get_face_count_from_db(const char *media_id, filter_h filter, int *face_count)
1197 int ret = MEDIA_CONTENT_ERROR_NONE;
1199 if (STRING_VALID(media_id) && face_count) {
1200 ret = _media_db_get_group_item_count(media_id, filter, MEDIA_GROUP_FACE_BY_MEDIA_ID, face_count);
1202 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1203 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1209 int media_info_foreach_face_from_db(const char *media_id, filter_h filter, media_face_cb callback, void *user_data)
1211 int ret = MEDIA_CONTENT_ERROR_NONE;
1213 if ((callback != NULL) && STRING_VALID(media_id)) {
1214 ret = _media_db_get_face(media_id, filter, callback, user_data);
1216 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1217 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1223 int media_info_get_image(media_info_h media, image_meta_h *image)
1225 int ret = MEDIA_CONTENT_ERROR_NONE;
1227 media_info_s *_media = (media_info_s*)media;
1229 media_content_retvm_if(_media == NULL, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid media");
1230 media_content_retvm_if(_media->media_type != MEDIA_CONTENT_TYPE_IMAGE, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid media_type");
1231 media_content_retvm_if(_media->image_meta == NULL, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid image_meta");
1233 image_meta_s *_image = (image_meta_s*)calloc(1, sizeof(image_meta_s));
1234 media_content_retvm_if(_image == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
1236 _image->media_id = g_strdup(_media->media_id);
1237 _image->width = _media->image_meta->width;
1238 _image->height = _media->image_meta->height;
1239 _image->orientation = _media->image_meta->orientation;
1240 _image->fnumber = _media->image_meta->fnumber;
1241 _image->iso = _media->image_meta->iso;
1242 _image->date_taken = g_strdup(_media->image_meta->date_taken);
1243 _image->title = g_strdup(_media->image_meta->title);
1244 _image->burst_id = g_strdup(_media->image_meta->burst_id);
1245 _image->weather = g_strdup(_media->image_meta->weather);
1246 _image->exposure_time = g_strdup(_media->image_meta->exposure_time);
1247 _image->model = g_strdup(_media->image_meta->model);
1249 *image = (image_meta_h)_image;
1254 int media_info_get_video(media_info_h media, video_meta_h *video)
1256 int ret = MEDIA_CONTENT_ERROR_NONE;
1258 media_info_s *_media = (media_info_s*)media;
1260 media_content_retvm_if(_media == NULL, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid media");
1261 media_content_retvm_if(_media->media_type != MEDIA_CONTENT_TYPE_VIDEO, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid media_type");
1262 media_content_retvm_if(_media->video_meta == NULL, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid video_meta");
1264 video_meta_s *_video = (video_meta_s*)calloc(1, sizeof(video_meta_s));
1265 media_content_retvm_if(_video == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
1267 _video->media_id = g_strdup(_media->media_id);
1268 _video->title = g_strdup(_media->video_meta->title);
1269 _video->album = g_strdup(_media->video_meta->album);
1270 _video->artist = g_strdup(_media->video_meta->artist);
1271 _video->album_artist = g_strdup(_media->video_meta->album_artist);
1272 _video->genre = g_strdup(_media->video_meta->genre);
1273 _video->composer = g_strdup(_media->video_meta->composer);
1274 _video->year = g_strdup(_media->video_meta->year);
1275 _video->recorded_date = g_strdup(_media->video_meta->recorded_date);
1276 _video->copyright = g_strdup(_media->video_meta->copyright);
1277 _video->track_num = g_strdup(_media->video_meta->track_num);
1279 _video->width = _media->video_meta->width;
1280 _video->height = _media->video_meta->height;
1281 _video->duration = _media->video_meta->duration;
1282 _video->bitrate = _media->video_meta->bitrate;
1283 _video->played_count = _media->video_meta->played_count;
1284 _video->played_time = _media->video_meta->played_time;
1285 _video->played_position = _media->video_meta->played_position;
1287 *video = (video_meta_h)_video;
1292 int media_info_get_audio(media_info_h media, audio_meta_h *audio)
1294 int ret = MEDIA_CONTENT_ERROR_NONE;
1296 media_info_s *_media = (media_info_s*)media;
1298 media_content_retvm_if(_media == NULL, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid media");
1299 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");
1300 media_content_retvm_if(_media->audio_meta == NULL, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid audio_meta");
1302 audio_meta_s *_audio = (audio_meta_s*)calloc(1, sizeof(audio_meta_s));
1303 media_content_retvm_if(_audio == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
1305 _audio->media_id = g_strdup(_media->media_id);
1306 _audio->title = g_strdup(_media->audio_meta->title);
1307 _audio->album = g_strdup(_media->audio_meta->album);
1308 _audio->artist = g_strdup(_media->audio_meta->artist);
1309 _audio->album_artist = g_strdup(_media->audio_meta->album_artist);
1310 _audio->genre = g_strdup(_media->audio_meta->genre);
1311 _audio->composer = g_strdup(_media->audio_meta->composer);
1312 _audio->year = g_strdup(_media->audio_meta->year);
1313 _audio->recorded_date = g_strdup(_media->audio_meta->recorded_date);
1314 _audio->copyright = g_strdup(_media->audio_meta->copyright);
1315 _audio->track_num = g_strdup(_media->audio_meta->track_num);
1317 _audio->duration = _media->audio_meta->duration;
1318 _audio->bitrate = _media->audio_meta->bitrate;
1319 _audio->bitpersample = _media->audio_meta->bitpersample;
1320 _audio->samplerate = _media->audio_meta->samplerate;
1321 _audio->channel = _media->audio_meta->channel;
1322 _audio->played_time = _media->audio_meta->played_time;
1323 _audio->played_count = _media->audio_meta->played_count;
1324 _audio->played_position = _media->audio_meta->played_position;
1326 *audio = (audio_meta_h)_audio;
1331 int media_info_get_media_id(media_info_h media, char **media_id)
1333 int ret = MEDIA_CONTENT_ERROR_NONE;
1334 media_info_s *_media = (media_info_s*)media;
1336 if (_media && media_id) {
1337 if (STRING_VALID(_media->media_id)) {
1338 *media_id = strdup(_media->media_id);
1339 media_content_retvm_if(*media_id == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
1343 ret = MEDIA_CONTENT_ERROR_NONE;
1345 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1346 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1352 int media_info_get_file_path(media_info_h media, char **path)
1354 int ret = MEDIA_CONTENT_ERROR_NONE;
1355 media_info_s *_media = (media_info_s*)media;
1357 if (_media && path) {
1358 if (STRING_VALID(_media->file_path)) {
1359 *path = strdup(_media->file_path);
1360 media_content_retvm_if(*path == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
1364 ret = MEDIA_CONTENT_ERROR_NONE;
1367 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1368 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1374 int media_info_get_display_name(media_info_h media, char **name)
1376 int ret = MEDIA_CONTENT_ERROR_NONE;
1377 media_info_s *_media = (media_info_s*)media;
1378 if (_media && name) {
1379 if (_media->display_name != NULL) {
1380 *name = g_strdup(_media->display_name);
1381 media_content_retvm_if(*name == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
1385 ret = MEDIA_CONTENT_ERROR_NONE;
1388 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1389 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1395 int media_info_get_media_type(media_info_h media, media_content_type_e *type)
1397 int ret = MEDIA_CONTENT_ERROR_NONE;
1398 media_info_s *_media = (media_info_s*)media;
1399 if (_media && type) {
1400 *type = _media->media_type;
1401 ret = MEDIA_CONTENT_ERROR_NONE;
1403 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1404 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1410 int media_info_get_mime_type(media_info_h media, char **mime_type)
1412 int ret = MEDIA_CONTENT_ERROR_NONE;
1413 media_info_s *_media = (media_info_s*)media;
1415 if (_media && mime_type) {
1416 if (STRING_VALID(_media->mime_type)) {
1417 *mime_type = strdup(_media->mime_type);
1418 media_content_retvm_if(*mime_type == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
1422 ret = MEDIA_CONTENT_ERROR_NONE;
1424 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1425 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1431 int media_info_get_size(media_info_h media, unsigned long long *size)
1433 int ret = MEDIA_CONTENT_ERROR_NONE;
1434 media_info_s *_media = (media_info_s*)media;
1436 if (_media && size) {
1437 *size = _media->size;
1438 ret = MEDIA_CONTENT_ERROR_NONE;
1440 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1441 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1447 int media_info_get_added_time(media_info_h media, time_t *added_time)
1449 int ret = MEDIA_CONTENT_ERROR_NONE;
1450 media_info_s *_media = (media_info_s*)media;
1451 if (_media && added_time) {
1452 *added_time = _media->added_time;
1453 ret = MEDIA_CONTENT_ERROR_NONE;
1455 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1456 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1462 int media_info_get_modified_time(media_info_h media, time_t* time)
1464 int ret = MEDIA_CONTENT_ERROR_NONE;
1465 media_info_s *_media = (media_info_s*)media;
1466 if (_media && time) {
1467 *time = _media->modified_time;
1468 ret = MEDIA_CONTENT_ERROR_NONE;
1470 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1471 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1477 int media_info_get_timeline(media_info_h media, time_t* time)
1479 int ret = MEDIA_CONTENT_ERROR_NONE;
1480 media_info_s *_media = (media_info_s*)media;
1481 if (_media && time) {
1482 *time = _media->timeline;
1483 ret = MEDIA_CONTENT_ERROR_NONE;
1485 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1486 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1492 int media_info_get_thumbnail_path(media_info_h media, char **path)
1494 int ret = MEDIA_CONTENT_ERROR_NONE;
1495 media_info_s *_media = (media_info_s*)media;
1496 if (_media && path) {
1497 if (_media->thumbnail_path != NULL) {
1498 *path = g_strdup(_media->thumbnail_path);
1499 media_content_retvm_if(*path == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
1503 ret = MEDIA_CONTENT_ERROR_NONE;
1506 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1507 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1513 int media_info_get_title(media_info_h media, char **title)
1515 int ret = MEDIA_CONTENT_ERROR_NONE;
1516 media_info_s *_media = (media_info_s*)media;
1518 if (_media && title) { /*title can be empty string*/
1519 if (_media->title != NULL) {
1520 *title = g_strdup(_media->title);
1521 media_content_retvm_if(*title == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
1525 ret = MEDIA_CONTENT_ERROR_NONE;
1527 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1528 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1534 int media_info_get_description(media_info_h media, char **description)
1536 int ret = MEDIA_CONTENT_ERROR_NONE;
1537 media_info_s *_media = (media_info_s*)media;
1539 if (_media && description) {
1540 if (_media->description != NULL) { /*description can be empty string*/
1541 *description = g_strdup(_media->description);
1542 media_content_retvm_if(*description == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
1544 *description = NULL;
1546 ret = MEDIA_CONTENT_ERROR_NONE;
1548 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1549 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1555 int media_info_get_longitude(media_info_h media, double* longitude)
1557 int ret = MEDIA_CONTENT_ERROR_NONE;
1558 media_info_s *_media = (media_info_s*)media;
1560 if (_media && longitude) {
1561 *longitude = _media->longitude;
1562 ret = MEDIA_CONTENT_ERROR_NONE;
1564 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1565 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1570 int media_info_get_latitude(media_info_h media, double* latitude)
1572 int ret = MEDIA_CONTENT_ERROR_NONE;
1573 media_info_s *_media = (media_info_s*)media;
1575 if (_media && latitude) {
1576 *latitude = _media->latitude;
1577 ret = MEDIA_CONTENT_ERROR_NONE;
1579 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1580 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1586 int media_info_get_altitude(media_info_h media, double *altitude)
1588 int ret = MEDIA_CONTENT_ERROR_NONE;
1589 media_info_s *_media = (media_info_s*)media;
1591 if (_media && altitude) {
1592 *altitude = _media->altitude;
1593 ret = MEDIA_CONTENT_ERROR_NONE;
1595 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1596 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1602 int media_info_get_weather(media_info_h media, char **weather)
1604 int ret = MEDIA_CONTENT_ERROR_NONE;
1605 media_info_s *_media = (media_info_s*)media;
1607 if (_media && weather) {
1608 if (_media->weather != NULL) {
1609 *weather = strdup(_media->weather);
1610 media_content_retvm_if(*weather == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
1614 ret = MEDIA_CONTENT_ERROR_NONE;
1616 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1617 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1623 int media_info_get_rating(media_info_h media, int *rating)
1625 int ret = MEDIA_CONTENT_ERROR_NONE;
1626 media_info_s *_media = (media_info_s*)media;
1628 if (_media && rating) {
1629 *rating = _media->rating;
1630 ret = MEDIA_CONTENT_ERROR_NONE;
1632 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1633 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1639 int media_info_get_favorite(media_info_h media, bool* favorite)
1641 int ret = MEDIA_CONTENT_ERROR_NONE;
1642 media_info_s *_media = (media_info_s*)media;
1644 if (_media && favorite) {
1645 *favorite = _media->favourite;
1646 ret = MEDIA_CONTENT_ERROR_NONE;
1648 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1649 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1655 int media_info_get_author(media_info_h media, char **author)
1657 int ret = MEDIA_CONTENT_ERROR_NONE;
1658 media_info_s *_media = (media_info_s*)media;
1660 if (_media && author) {
1661 if (_media->author != NULL) {
1662 *author = strdup(_media->author);
1663 media_content_retvm_if(*author == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
1667 ret = MEDIA_CONTENT_ERROR_NONE;
1669 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1670 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1676 int media_info_get_provider(media_info_h media, char **provider)
1678 int ret = MEDIA_CONTENT_ERROR_NONE;
1679 media_info_s *_media = (media_info_s*)media;
1681 if (_media && provider) {
1682 if (_media->provider != NULL) {
1683 *provider = strdup(_media->provider);
1684 media_content_retvm_if(*provider == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
1688 ret = MEDIA_CONTENT_ERROR_NONE;
1690 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1691 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1697 int media_info_get_content_name(media_info_h media, char **content_name)
1699 int ret = MEDIA_CONTENT_ERROR_NONE;
1700 media_info_s *_media = (media_info_s*)media;
1702 if (_media && content_name) {
1703 if (_media->content_name != NULL) {
1704 *content_name = strdup(_media->content_name);
1705 media_content_retvm_if(*content_name == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
1707 *content_name = NULL;
1709 ret = MEDIA_CONTENT_ERROR_NONE;
1711 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1712 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1718 int media_info_get_category(media_info_h media, char **category)
1720 int ret = MEDIA_CONTENT_ERROR_NONE;
1721 media_info_s *_media = (media_info_s*)media;
1723 if (_media && category) {
1724 if (_media->category != NULL) {
1725 *category = strdup(_media->category);
1726 media_content_retvm_if(*category == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
1730 ret = MEDIA_CONTENT_ERROR_NONE;
1732 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1733 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1739 int media_info_get_location_tag(media_info_h media, char **location_tag)
1741 int ret = MEDIA_CONTENT_ERROR_NONE;
1742 media_info_s *_media = (media_info_s*)media;
1744 if (_media && location_tag) {
1745 if (_media->location_tag != NULL) {
1746 *location_tag = strdup(_media->location_tag);
1747 media_content_retvm_if(*location_tag == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
1749 *location_tag = NULL;
1751 ret = MEDIA_CONTENT_ERROR_NONE;
1753 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1754 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1760 int media_info_get_age_rating(media_info_h media, char **age_rating)
1762 int ret = MEDIA_CONTENT_ERROR_NONE;
1763 media_info_s *_media = (media_info_s*)media;
1765 if (_media && age_rating) {
1766 if (_media->age_rating != NULL) {
1767 *age_rating = strdup(_media->age_rating);
1768 media_content_retvm_if(*age_rating == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
1772 ret = MEDIA_CONTENT_ERROR_NONE;
1774 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1775 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1781 int media_info_get_keyword(media_info_h media, char **keyword)
1783 int ret = MEDIA_CONTENT_ERROR_NONE;
1784 media_info_s *_media = (media_info_s*)media;
1786 if (_media && keyword) {
1787 if (_media->keyword != NULL) {
1788 *keyword = strdup(_media->keyword);
1789 media_content_retvm_if(*keyword == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
1793 ret = MEDIA_CONTENT_ERROR_NONE;
1795 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1796 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1802 int media_info_get_storage_id(media_info_h media, char **storage_id)
1804 int ret = MEDIA_CONTENT_ERROR_NONE;
1805 media_info_s *_media = (media_info_s*)media;
1807 if (_media && storage_id) {
1808 if (STRING_VALID(_media->storage_uuid)) {
1809 *storage_id = strdup(_media->storage_uuid);
1810 media_content_retvm_if(*storage_id == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
1814 ret = MEDIA_CONTENT_ERROR_NONE;
1816 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1817 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1823 int media_info_is_drm(media_info_h media, bool *is_drm)
1825 int ret = MEDIA_CONTENT_ERROR_NONE;
1826 media_info_s *_media = (media_info_s*)media;
1829 *is_drm = _media->is_drm;
1830 ret = MEDIA_CONTENT_ERROR_NONE;
1832 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1833 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1839 int media_info_get_storage_type(media_info_h media, media_content_storage_e *storage_type)
1841 int ret = MEDIA_CONTENT_ERROR_NONE;
1842 media_info_s *_media = (media_info_s*)media;
1844 if (_media && storage_type) {
1845 *storage_type = _media->storage_type;
1846 ret = MEDIA_CONTENT_ERROR_NONE;
1848 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1849 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1855 int media_info_get_played_count(media_info_h media, int *played_count)
1857 int ret = MEDIA_CONTENT_ERROR_NONE;
1858 media_info_s *_media = (media_info_s*)media;
1861 *played_count = _media->played_count;
1862 ret = MEDIA_CONTENT_ERROR_NONE;
1864 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1865 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1871 int media_info_get_played_time(media_info_h media, time_t* played_time)
1873 int ret = MEDIA_CONTENT_ERROR_NONE;
1874 media_info_s *_media = (media_info_s*)media;
1877 *played_time = _media->played_time;
1878 ret = MEDIA_CONTENT_ERROR_NONE;
1880 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1881 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1887 int media_info_increase_played_count(media_info_h media)
1889 int ret = MEDIA_CONTENT_ERROR_NONE;
1891 media_info_s *_media = (media_info_s*)media;
1894 _media->played_count += 1;
1896 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1897 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1903 int media_info_set_played_time(media_info_h media)
1905 int ret = MEDIA_CONTENT_ERROR_NONE;
1906 time_t current_time;
1908 media_info_s *_media = (media_info_s*)media;
1910 if (_media != NULL) {
1911 time(¤t_time);
1912 _media->played_time = current_time;
1914 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1915 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1921 int media_info_get_media_from_db(const char *media_id, media_info_h *media)
1923 int ret = MEDIA_CONTENT_ERROR_NONE;
1924 char select_query[DEFAULT_QUERY_SIZE];
1925 char storage_id[MEDIA_CONTENT_UUID_SIZE+1] = {0, };
1926 sqlite3_stmt *stmt = NULL;
1928 if (!STRING_VALID(media_id) || (media == NULL)) {
1929 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1930 return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1933 memset(select_query, 0x00, sizeof(select_query));
1934 memset(storage_id, 0x00, sizeof(storage_id));
1936 ret = _media_db_get_storage_id_by_media_id(media_id, storage_id);
1937 media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
1939 snprintf(select_query, sizeof(select_query), SELECT_MEDIA_FROM_MEDIA, storage_id, media_id);
1941 ret = _content_query_prepare(&stmt, select_query, NULL, NULL);
1942 media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
1944 media_info_s *_media = NULL;
1946 while (sqlite3_step(stmt) == SQLITE_ROW) {
1948 media_info_destroy((media_info_h)_media);
1950 _media = (media_info_s*)calloc(1, sizeof(media_info_s));
1952 if (_media == NULL) {
1953 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
1954 SQLITE3_FINALIZE(stmt);
1955 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
1958 _media_info_item_get_detail(stmt, (media_info_h)_media);
1960 *media = (media_info_h)_media;
1963 SQLITE3_FINALIZE(stmt);
1968 int media_info_set_display_name(media_info_h media, const char *display_name)
1970 int ret = MEDIA_CONTENT_ERROR_NONE;
1971 media_info_s *_media = (media_info_s*)media;
1973 if (_media != NULL && STRING_VALID(display_name)) {
1974 SAFE_FREE(_media->display_name);
1976 _media->display_name = strdup(display_name);
1977 media_content_retvm_if(_media->display_name == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
1979 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1980 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1986 int media_info_set_description(media_info_h media, const char *description)
1988 int ret = MEDIA_CONTENT_ERROR_NONE;
1989 media_info_s *_media = (media_info_s*)media;
1991 if (_media != NULL) {
1992 SAFE_FREE(_media->description);
1994 if (STRING_VALID(description)) {
1995 _media->description = strdup(description);
1996 media_content_retvm_if(_media->description == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
1998 _media->description = NULL;
2001 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
2002 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
2008 int media_info_set_longitude(media_info_h media, double longitude)
2010 int ret = MEDIA_CONTENT_ERROR_NONE;
2011 media_info_s *_media = (media_info_s*)media;
2013 if (_media != NULL) {
2014 _media->longitude = longitude;
2016 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
2017 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
2023 int media_info_set_latitude(media_info_h media, double latitude)
2025 int ret = MEDIA_CONTENT_ERROR_NONE;
2026 media_info_s *_media = (media_info_s*)media;
2028 if (_media != NULL) {
2029 _media->latitude = latitude;
2031 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
2032 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
2038 int media_info_set_altitude(media_info_h media, double altitude)
2040 int ret = MEDIA_CONTENT_ERROR_NONE;
2041 media_info_s *_media = (media_info_s*)media;
2043 if (_media != NULL) {
2044 _media->altitude = altitude;
2046 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
2047 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
2053 int media_info_set_weather(media_info_h media, const char *weather)
2055 int ret = MEDIA_CONTENT_ERROR_NONE;
2056 media_info_s *_media = (media_info_s*)media;
2058 if (_media != NULL) {
2059 SAFE_FREE(_media->weather);
2061 if (STRING_VALID(weather)) {
2062 _media->weather = strdup(weather);
2063 media_content_retvm_if(_media->weather == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
2065 _media->weather = NULL;
2068 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
2069 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
2075 int media_info_set_rating(media_info_h media, int rating)
2077 int ret = MEDIA_CONTENT_ERROR_NONE;
2078 media_info_s *_media = (media_info_s*)media;
2080 if (_media != NULL) {
2081 _media->rating = rating;
2083 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
2084 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
2090 int media_info_set_added_time(media_info_h media, time_t added_time)
2092 int ret = MEDIA_CONTENT_ERROR_NONE;
2094 media_info_s *_media = (media_info_s*)media;
2096 if ((_media != NULL) && (added_time >= 0)) {
2097 _media->added_time = added_time;
2099 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
2100 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
2106 int media_info_set_favorite(media_info_h media, bool favorite)
2108 int ret = MEDIA_CONTENT_ERROR_NONE;
2109 media_info_s *_media = (media_info_s*)media;
2111 if (_media != NULL) {
2112 if (favorite == TRUE)
2113 time(&_media->favourite);
2115 _media->favourite = 0;
2117 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
2118 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
2124 int media_info_set_author(media_info_h media, const char *author)
2126 int ret = MEDIA_CONTENT_ERROR_NONE;
2127 media_info_s *_media = (media_info_s*)media;
2129 if (_media != NULL) {
2130 if (STRING_VALID(author)) {
2131 _media->author = strdup(author);
2132 media_content_retvm_if(_media->author == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
2134 _media->author = NULL;
2137 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
2138 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
2144 int media_info_set_provider(media_info_h media, const char *provider)
2146 int ret = MEDIA_CONTENT_ERROR_NONE;
2147 media_info_s *_media = (media_info_s*)media;
2149 if (_media != NULL) {
2150 SAFE_FREE(_media->provider);
2152 if (STRING_VALID(provider)) {
2153 _media->provider = strdup(provider);
2154 media_content_retvm_if(_media->provider == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
2156 _media->provider = NULL;
2159 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
2160 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
2166 int media_info_set_content_name(media_info_h media, const char *content_name)
2168 int ret = MEDIA_CONTENT_ERROR_NONE;
2169 media_info_s *_media = (media_info_s*)media;
2171 if (_media != NULL) {
2172 SAFE_FREE(_media->content_name);
2174 if (STRING_VALID(content_name)) {
2175 _media->content_name = strdup(content_name);
2176 media_content_retvm_if(_media->content_name == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
2178 _media->content_name = NULL;
2181 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
2182 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
2188 int media_info_set_category(media_info_h media, const char *category)
2190 int ret = MEDIA_CONTENT_ERROR_NONE;
2191 media_info_s *_media = (media_info_s*)media;
2193 if (_media != NULL) {
2194 SAFE_FREE(_media->category);
2196 if (STRING_VALID(category)) {
2197 _media->category = strdup(category);
2198 media_content_retvm_if(_media->category == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
2200 _media->category = NULL;
2203 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
2204 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
2210 int media_info_set_location_tag(media_info_h media, const char *location_tag)
2212 int ret = MEDIA_CONTENT_ERROR_NONE;
2213 media_info_s *_media = (media_info_s*)media;
2215 if (_media != NULL) {
2216 SAFE_FREE(_media->location_tag);
2218 if (STRING_VALID(location_tag)) {
2219 _media->location_tag = strdup(location_tag);
2220 media_content_retvm_if(_media->location_tag == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
2222 _media->location_tag = NULL;
2225 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
2226 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
2232 int media_info_set_age_rating(media_info_h media, const char *age_rating)
2234 int ret = MEDIA_CONTENT_ERROR_NONE;
2235 media_info_s *_media = (media_info_s*)media;
2237 if (_media != NULL) {
2238 SAFE_FREE(_media->age_rating);
2240 if (STRING_VALID(age_rating)) {
2241 _media->age_rating = strdup(age_rating);
2242 media_content_retvm_if(_media->age_rating == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
2244 _media->age_rating = NULL;
2247 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
2248 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
2254 int media_info_set_keyword(media_info_h media, const char *keyword)
2256 int ret = MEDIA_CONTENT_ERROR_NONE;
2257 media_info_s *_media = (media_info_s*)media;
2259 if (_media != NULL) {
2260 SAFE_FREE(_media->keyword);
2262 if (STRING_VALID(keyword)) {
2263 _media->keyword = strdup(keyword);
2264 media_content_retvm_if(_media->keyword == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
2266 _media->keyword = NULL;
2269 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
2270 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
2276 int media_info_update_to_db(media_info_h media)
2278 int ret = MEDIA_CONTENT_ERROR_NONE;
2279 media_info_s *_media = (media_info_s*)media;
2280 char *set_sql = NULL;
2283 if (_media != NULL && STRING_VALID(_media->media_id)) {
2284 /* This sql is due to sqlite3_mprintf's wrong operation when using floating point in the text format */
2285 /* This code will be removed when sqlite3_mprintf works clearly */
2286 char *test_sql = sqlite3_mprintf("%f, %f, %f", _media->longitude, _media->latitude, _media->altitude);
2287 SQLITE3_SAFE_FREE(test_sql);
2289 /*Update Pinyin If Support Pinyin*/
2290 char *file_name_pinyin = NULL;
2291 char *description_pinyin = NULL;
2292 char *author_pinyin = NULL;
2293 char *provider_pinyin = NULL;
2294 char *content_name_pinyin = NULL;
2295 char *category_pinyin = NULL;
2296 char *location_tag_pinyin = NULL;
2297 char *age_rating_pinyin = NULL;
2298 char *keyword_pinyin = NULL;
2299 bool pinyin_support = FALSE;
2301 /*Update Pinyin If Support Pinyin*/
2302 media_svc_check_pinyin_support(&pinyin_support);
2303 if (pinyin_support) {
2304 if (STRING_VALID(_media->display_name))
2305 media_svc_get_pinyin(_media->display_name, &file_name_pinyin);
2306 if (STRING_VALID(_media->description))
2307 media_svc_get_pinyin(_media->description, &description_pinyin);
2308 if (STRING_VALID(_media->author))
2309 media_svc_get_pinyin(_media->author, &author_pinyin);
2310 if (STRING_VALID(_media->provider))
2311 media_svc_get_pinyin(_media->provider, &provider_pinyin);
2312 if (STRING_VALID(_media->content_name))
2313 media_svc_get_pinyin(_media->content_name, &content_name_pinyin);
2314 if (STRING_VALID(_media->category))
2315 media_svc_get_pinyin(_media->category, &category_pinyin);
2316 if (STRING_VALID(_media->location_tag))
2317 media_svc_get_pinyin(_media->location_tag, &location_tag_pinyin);
2318 if (STRING_VALID(_media->age_rating))
2319 media_svc_get_pinyin(_media->age_rating, &age_rating_pinyin);
2320 if (STRING_VALID(_media->keyword))
2321 media_svc_get_pinyin(_media->keyword, &keyword_pinyin);
2325 char *artist = NULL;
2327 char *recorded_date = NULL;
2329 if (_media->media_type == MEDIA_CONTENT_TYPE_VIDEO) {
2330 if (_media->video_meta->album != NULL)
2331 album = strdup(_media->video_meta->album);
2332 if (_media->video_meta->artist != NULL)
2333 artist = strdup(_media->video_meta->artist);
2334 if (_media->video_meta->genre != NULL)
2335 genre = strdup(_media->video_meta->genre);
2336 if (_media->video_meta->recorded_date != NULL)
2337 recorded_date = strdup(_media->video_meta->recorded_date);
2338 } else if ((_media->media_type == MEDIA_CONTENT_TYPE_MUSIC) || (_media->media_type == MEDIA_CONTENT_TYPE_SOUND)) {
2339 if (_media->audio_meta->album != NULL)
2340 album = strdup(_media->audio_meta->album);
2341 if (_media->audio_meta->artist != NULL)
2342 artist = strdup(_media->audio_meta->artist);
2343 if (_media->audio_meta->genre != NULL)
2344 genre = strdup(_media->audio_meta->genre);
2345 if (_media->audio_meta->recorded_date != NULL)
2346 recorded_date = strdup(_media->audio_meta->recorded_date);
2349 set_sql = sqlite3_mprintf("file_name=%Q, added_time=%d, description=%Q, longitude=%f, latitude=%f, altitude=%f, \
2350 played_count=%d, last_played_time=%d, last_played_position=%d, \
2351 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, \
2352 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, \
2353 album=%Q, artist=%Q, genre=%Q, recorded_date=%Q",
2354 _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,
2355 _media->author, _media->provider, _media->content_name, _media->category, _media->location_tag, _media->age_rating, _media->keyword, _media->weather, _media->sync_status,
2356 file_name_pinyin, description_pinyin, author_pinyin, provider_pinyin, content_name_pinyin, category_pinyin, location_tag_pinyin, age_rating_pinyin, keyword_pinyin, _media->title,
2357 album, artist, genre, recorded_date);
2359 sql = sqlite3_mprintf("UPDATE %Q SET %s WHERE media_uuid=%Q", _media->storage_uuid, set_sql, _media->media_id);
2361 ret = _content_query_sql(sql);
2362 SQLITE3_SAFE_FREE(set_sql);
2363 SQLITE3_SAFE_FREE(sql);
2365 SAFE_FREE(description_pinyin);
2366 SAFE_FREE(author_pinyin);
2367 SAFE_FREE(provider_pinyin);
2368 SAFE_FREE(content_name_pinyin);
2369 SAFE_FREE(category_pinyin);
2370 SAFE_FREE(location_tag_pinyin);
2371 SAFE_FREE(age_rating_pinyin);
2372 SAFE_FREE(keyword_pinyin);
2377 SAFE_FREE(recorded_date);
2379 if (_media->storage_type == MEDIA_CONTENT_STORAGE_CLOUD) {
2383 if (_media->media_type == MEDIA_CONTENT_TYPE_VIDEO) {
2384 set_sql = sqlite3_mprintf("title=%Q, album=%Q, artist=%Q, genre=%Q, duration=%d, width=%d, height=%d", \
2385 _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);
2386 } else if ((_media->media_type == MEDIA_CONTENT_TYPE_MUSIC) || (_media->media_type == MEDIA_CONTENT_TYPE_SOUND)) {
2387 set_sql = sqlite3_mprintf("title=%Q, album=%Q, artist=%Q, genre=%Q, duration=%d", \
2388 _media->title, _media->audio_meta->album, _media->audio_meta->artist, _media->audio_meta->genre, _media->audio_meta->duration);
2389 } else if (_media->media_type == MEDIA_CONTENT_TYPE_IMAGE) {
2390 set_sql = sqlite3_mprintf("title=%Q, width=%d, height=%d", _media->title, _media->image_meta->width, _media->image_meta->height);
2392 set_sql = sqlite3_mprintf("title=%Q", _media->title);
2395 sql = sqlite3_mprintf("UPDATE %Q SET %s WHERE media_uuid=%Q", _media->storage_uuid, set_sql, _media->media_id);
2397 ret = _content_query_sql(sql);
2399 SQLITE3_SAFE_FREE(set_sql);
2400 SQLITE3_SAFE_FREE(sql);
2403 if (ret == MEDIA_CONTENT_ERROR_NONE) {
2404 /* Send notification for this update */
2405 media_content_debug("Update is successfull. Send notification for this");
2406 if (_media->file_path && _media->mime_type)
2407 media_svc_publish_noti(MS_MEDIA_ITEM_FILE, MS_MEDIA_ITEM_UPDATE, _media->file_path, _media->media_type, _media->media_id, _media->mime_type);
2409 media_content_error("Can't Send Noti : path or mime type is NULL");
2412 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
2413 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
2419 int media_info_refresh_metadata_to_db(const char *media_id)
2421 int ret = MEDIA_CONTENT_ERROR_NONE;
2422 media_info_h media = NULL;
2423 char *file_path = NULL;
2424 media_content_storage_e storage_type = 0;
2425 char storage_id[MEDIA_CONTENT_UUID_SIZE+1] = {0, };
2427 if (!STRING_VALID(media_id)) {
2428 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
2429 return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
2432 ret = media_info_get_media_from_db(media_id, &media);
2433 if (ret != MEDIA_CONTENT_ERROR_NONE) {
2434 media_info_destroy(media);
2438 ret = media_info_get_storage_type(media, &storage_type);
2439 if (ret != MEDIA_CONTENT_ERROR_NONE) {
2440 media_info_destroy(media);
2444 if (storage_type == MEDIA_CONTENT_STORAGE_CLOUD) {
2445 media_info_destroy(media);
2446 media_content_error("Can't refresh cloud content!!");
2447 return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
2450 ret = media_info_get_file_path(media, &file_path);
2451 if (ret != MEDIA_CONTENT_ERROR_NONE) {
2452 media_info_destroy(media);
2456 ret = _media_util_check_file_exist(file_path);
2457 if (ret != MEDIA_CONTENT_ERROR_NONE) {
2458 SAFE_FREE(file_path);
2459 media_info_destroy(media);
2463 memset(storage_id, 0x00, sizeof(storage_id));
2464 ret = media_svc_get_storage_id(_content_get_db_handle(), file_path, storage_id);
2465 if (ret != MS_MEDIA_ERR_NONE) {
2466 media_content_error("media_svc_get_storage_id failed : %d", ret);
2467 SAFE_FREE(file_path);
2468 media_info_destroy(media);
2469 return _content_error_capi(MEDIA_CONTENT_TYPE, ret);
2472 ret = media_svc_refresh_item(_content_get_db_handle(), storage_id, storage_type, file_path, tzplatform_getuid(TZ_USER_NAME));
2473 if (ret != MS_MEDIA_ERR_NONE)
2474 ret = _content_error_capi(MEDIA_CONTENT_TYPE, ret);
2476 SAFE_FREE(file_path);
2477 media_info_destroy(media);
2482 int media_info_move_to_db(media_info_h media, const char* dst_path)
2484 int ret = MEDIA_CONTENT_ERROR_NONE;
2485 bool ignore_file = FALSE;
2486 bool ignore_dir = FALSE;
2487 char *folder_path = NULL;
2488 media_svc_storage_type_e src_storage_type = 0;
2489 media_svc_storage_type_e dst_storage_type = 0;
2490 char storage_id[MEDIA_CONTENT_UUID_SIZE+1] = {0, };
2492 media_content_retvm_if(media == NULL, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "invalid media");
2493 media_content_retvm_if(!STRING_VALID(dst_path), MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "invalid dst_path");
2495 media_info_s *_media = (media_info_s*)media;
2497 ret = _media_util_check_ignore_file(dst_path, &ignore_file);
2498 media_content_retvm_if(ignore_file == TRUE, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid path");
2500 ret = _media_util_check_file_exist(dst_path);
2501 media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
2503 folder_path = g_path_get_dirname(dst_path);
2504 ret = _media_util_check_ignore_dir(folder_path, &ignore_dir);
2505 SAFE_FREE(folder_path);
2507 media_content_retvm_if(ignore_dir == TRUE, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid folder path");
2509 ret = media_svc_get_storage_type(_media->file_path, &src_storage_type, tzplatform_getuid(TZ_USER_NAME));
2510 if (ret != MS_MEDIA_ERR_NONE) {
2511 media_content_sec_error("media_svc_get_storage_type failed : %d", ret);
2512 return _content_error_capi(MEDIA_CONTENT_TYPE, ret);
2515 ret = media_svc_get_storage_type(dst_path, &dst_storage_type, tzplatform_getuid(TZ_USER_NAME));
2516 if (ret != MS_MEDIA_ERR_NONE) {
2517 media_content_sec_error("media_svc_get_storage_type failed : %d", ret);
2518 return _content_error_capi(MEDIA_CONTENT_TYPE, ret);
2521 memset(storage_id, 0x00, sizeof(storage_id));
2522 ret = media_svc_get_storage_id(_content_get_db_handle(), _media->file_path, storage_id);
2523 if (ret != MS_MEDIA_ERR_NONE) {
2524 media_content_error("media_svc_get_storage_id failed : %d", ret);
2525 return _content_error_capi(MEDIA_CONTENT_TYPE, ret);
2528 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));
2529 return _content_error_capi(MEDIA_CONTENT_TYPE, ret);
2532 int media_info_create_thumbnail(media_info_h media, media_thumbnail_completed_cb callback, void *user_data)
2534 int ret = MEDIA_CONTENT_ERROR_NONE;
2535 static unsigned int req_id = 0;
2536 media_info_s *_media = (media_info_s*)media;
2538 if (_media != NULL && STRING_VALID(_media->media_id) && STRING_VALID(_media->file_path)) {
2539 media_thumbnail_cb_s *_thumb_cb = (media_thumbnail_cb_s*)calloc(1, sizeof(media_thumbnail_cb_s));
2540 media_content_retvm_if(_thumb_cb == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
2542 _media->request_id = req_id;
2544 _thumb_cb->handle = _media;
2545 _thumb_cb->user_data = user_data;
2546 _thumb_cb->thumbnail_completed_cb = callback;
2548 ret = thumbnail_request_from_db_async(_media->request_id, _media->file_path, (ThumbFunc)__media_info_thumbnail_completed_cb, (void *)_thumb_cb, tzplatform_getuid(TZ_USER_NAME));
2549 ret = _content_error_capi(MEDIA_THUMBNAIL_TYPE, ret);
2551 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
2552 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
2558 int media_info_cancel_thumbnail(media_info_h media)
2560 int ret = MEDIA_CONTENT_ERROR_NONE;
2561 media_info_s *_media = (media_info_s*)media;
2563 if (_media != NULL && STRING_VALID(_media->media_id) && STRING_VALID(_media->file_path) && _media->request_id > 0) {
2564 ret = thumbnail_request_cancel_media(_media->request_id, _media->file_path);
2565 ret = _content_error_capi(MEDIA_THUMBNAIL_TYPE, ret);
2567 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
2568 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
2574 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)
2576 media_content_retvm_if(media == NULL, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid handle");
2578 media_svc_content_info_s *svc_content_info = calloc(1, sizeof(media_svc_content_info_s));
2579 media_content_retvm_if(svc_content_info == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
2581 svc_content_info->path = g_strdup(media->file_path);
2582 svc_content_info->file_name = g_strdup(media->display_name);
2583 svc_content_info->media_type = media->media_type;
2584 svc_content_info->mime_type = g_strdup(media->mime_type);
2585 svc_content_info->size = media->size;
2586 svc_content_info->storage_type = storage_type;
2587 svc_content_info->storage_uuid = g_strdup(media->storage_uuid);
2589 svc_content_info->added_time = media->added_time;
2590 svc_content_info->modified_time = media->modified_time;
2591 svc_content_info->thumbnail_path = g_strdup(media->thumbnail_path);
2592 svc_content_info->is_drm = media->is_drm;
2593 svc_content_info->last_played_time = media->played_time;
2594 svc_content_info->played_count = media->played_count;
2595 svc_content_info->favourate = media->favourite;
2597 svc_content_info->media_meta.title = g_strdup(media->title);
2598 svc_content_info->media_meta.rating = media->rating;
2599 svc_content_info->media_meta.description = g_strdup(media->description);
2600 svc_content_info->media_meta.longitude = media->longitude;
2601 svc_content_info->media_meta.latitude = media->latitude;
2602 svc_content_info->media_meta.altitude = media->altitude;
2603 svc_content_info->media_meta.weather = g_strdup(media->weather);
2604 svc_content_info->media_meta.category = g_strdup(media->category);
2605 svc_content_info->media_meta.keyword = g_strdup(media->keyword);
2606 svc_content_info->media_meta.location_tag = g_strdup(media->location_tag);
2607 svc_content_info->media_meta.content_name = g_strdup(media->content_name);
2608 svc_content_info->media_meta.age_rating = g_strdup(media->age_rating);
2609 svc_content_info->media_meta.author = g_strdup(media->author);
2610 svc_content_info->media_meta.provider = g_strdup(media->provider);
2612 svc_content_info->media_meta.album = g_strdup(media->audio_meta->album);
2613 svc_content_info->media_meta.artist = g_strdup(media->audio_meta->artist);
2614 svc_content_info->media_meta.genre = g_strdup(media->audio_meta->genre);
2615 svc_content_info->media_meta.recorded_date = g_strdup(media->audio_meta->recorded_date);
2617 if (storage_type == MEDIA_CONTENT_STORAGE_CLOUD) {
2618 switch (media->media_type) {
2619 case MEDIA_CONTENT_TYPE_IMAGE:
2620 svc_content_info->media_meta.width = media->image_meta->width;
2621 svc_content_info->media_meta.height = media->image_meta->height;
2622 svc_content_info->media_meta.datetaken = g_strdup(media->image_meta->date_taken);
2623 svc_content_info->media_meta.orientation = media->image_meta->orientation;
2625 case MEDIA_CONTENT_TYPE_VIDEO:
2626 svc_content_info->media_meta.album_artist = g_strdup(media->audio_meta->album_artist);
2627 svc_content_info->media_meta.composer = g_strdup(media->audio_meta->composer);
2628 svc_content_info->media_meta.year = g_strdup(media->audio_meta->year);
2629 svc_content_info->media_meta.copyright = g_strdup(media->audio_meta->copyright);
2630 svc_content_info->media_meta.track_num = g_strdup(media->audio_meta->track_num);
2631 svc_content_info->media_meta.bitrate = media->audio_meta->bitrate;
2632 svc_content_info->media_meta.duration = media->audio_meta->duration;
2633 svc_content_info->media_meta.width = media->image_meta->width;
2634 svc_content_info->media_meta.height = media->image_meta->height;
2636 case MEDIA_CONTENT_TYPE_SOUND:
2637 case MEDIA_CONTENT_TYPE_MUSIC:
2638 svc_content_info->media_meta.album_artist = g_strdup(media->audio_meta->album_artist);
2639 svc_content_info->media_meta.composer = g_strdup(media->audio_meta->composer);
2640 svc_content_info->media_meta.year = g_strdup(media->audio_meta->year);
2641 svc_content_info->media_meta.copyright = g_strdup(media->audio_meta->copyright);
2642 svc_content_info->media_meta.track_num = g_strdup(media->audio_meta->track_num);
2643 svc_content_info->media_meta.bitrate = media->audio_meta->bitrate;
2644 svc_content_info->media_meta.duration = media->audio_meta->duration;
2645 svc_content_info->media_meta.channel = media->audio_meta->channel;
2646 svc_content_info->media_meta.samplerate = media->audio_meta->samplerate;
2648 case MEDIA_CONTENT_TYPE_OTHERS:
2654 *service_content = svc_content_info;
2656 return MEDIA_CONTENT_ERROR_NONE;
2659 static int __media_info_set_str_data(media_info_h media, media_info_item_e data_type, const char *str_data)
2661 media_info_s *_media = (media_info_s*)media;
2663 media_content_retvm_if(_media == NULL, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid media");
2665 switch (data_type) {
2666 case MEDIA_INFO_PATH:
2667 SAFE_FREE(_media->file_path);
2668 if (STRING_VALID(str_data)) {
2669 _media->file_path = strdup(str_data);
2670 media_content_retvm_if(_media->file_path == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
2672 _media->file_path = NULL;
2675 case MEDIA_INFO_MIME_TYPE:
2676 SAFE_FREE(_media->mime_type);
2677 if (STRING_VALID(str_data)) {
2678 _media->mime_type = strdup(str_data);
2679 media_content_retvm_if(_media->mime_type == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
2681 _media->mime_type = NULL;
2684 case MEDIA_INFO_THUMBNAIL_PATH:
2685 SAFE_FREE(_media->thumbnail_path);
2686 if (STRING_VALID(str_data)) {
2687 _media->thumbnail_path = strdup(str_data);
2688 media_content_retvm_if(_media->thumbnail_path == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
2690 _media->thumbnail_path = NULL;
2693 case MEDIA_INFO_TITLE:
2694 SAFE_FREE(_media->title);
2695 if (STRING_VALID(str_data)) {
2696 _media->title = strdup(str_data);
2697 media_content_retvm_if(_media->title == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
2699 _media->title = NULL;
2702 case MEDIA_INFO_STORAGE_UUID:
2703 SAFE_FREE(_media->storage_uuid);
2704 if (STRING_VALID(str_data)) {
2705 _media->storage_uuid = strdup(str_data);
2706 media_content_retvm_if(_media->storage_uuid == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
2708 _media->storage_uuid = NULL;
2711 case MEDIA_INFO_ALBUM:
2712 if (STRING_VALID(_media->media_id)) {
2713 if (_media->media_type == MEDIA_CONTENT_TYPE_VIDEO) {
2714 SAFE_FREE(_media->video_meta->album);
2715 if (str_data != NULL) {
2716 _media->video_meta->album = strdup(str_data);
2717 media_content_retvm_if(_media->video_meta->album == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
2719 } else if ((_media->media_type == MEDIA_CONTENT_TYPE_MUSIC) || (_media->media_type == MEDIA_CONTENT_TYPE_SOUND)) {
2720 SAFE_FREE(_media->audio_meta->album);
2721 if (str_data != NULL) {
2722 _media->audio_meta->album = strdup(str_data);
2723 media_content_retvm_if(_media->audio_meta->album == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
2727 SAFE_FREE(_media->video_meta->album);
2728 if (str_data != NULL) {
2729 _media->video_meta->album = strdup(str_data);
2730 media_content_retvm_if(_media->video_meta->album == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
2733 SAFE_FREE(_media->audio_meta->album);
2734 if (str_data != NULL) {
2735 _media->audio_meta->album = strdup(str_data);
2736 media_content_retvm_if(_media->audio_meta->album == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
2740 case MEDIA_INFO_ARTIST:
2741 if (STRING_VALID(_media->media_id)) {
2742 if (_media->media_type == MEDIA_CONTENT_TYPE_VIDEO) {
2743 SAFE_FREE(_media->video_meta->artist);
2744 if (str_data != NULL) {
2745 _media->video_meta->artist = strdup(str_data);
2746 media_content_retvm_if(_media->video_meta->artist == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
2748 } else if ((_media->media_type == MEDIA_CONTENT_TYPE_MUSIC) || (_media->media_type == MEDIA_CONTENT_TYPE_SOUND)) {
2749 SAFE_FREE(_media->audio_meta->artist);
2750 if (str_data != NULL) {
2751 _media->audio_meta->artist = strdup(str_data);
2752 media_content_retvm_if(_media->audio_meta->artist == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
2756 SAFE_FREE(_media->video_meta->artist);
2757 if (str_data != NULL) {
2758 _media->video_meta->artist = strdup(str_data);
2759 media_content_retvm_if(_media->video_meta->artist == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
2762 SAFE_FREE(_media->audio_meta->artist);
2763 if (str_data != NULL) {
2764 _media->audio_meta->artist = strdup(str_data);
2765 media_content_retvm_if(_media->audio_meta->artist == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
2769 case MEDIA_INFO_GENRE:
2770 if (STRING_VALID(_media->media_id)) {
2771 if (_media->media_type == MEDIA_CONTENT_TYPE_VIDEO) {
2772 SAFE_FREE(_media->video_meta->genre);
2773 if (str_data != NULL) {
2774 _media->video_meta->genre = strdup(str_data);
2775 media_content_retvm_if(_media->video_meta->genre == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
2777 } else if ((_media->media_type == MEDIA_CONTENT_TYPE_MUSIC) || (_media->media_type == MEDIA_CONTENT_TYPE_SOUND)) {
2778 SAFE_FREE(_media->audio_meta->genre);
2779 if (str_data != NULL) {
2780 _media->audio_meta->genre = strdup(str_data);
2781 media_content_retvm_if(_media->audio_meta->genre == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
2785 SAFE_FREE(_media->video_meta->genre);
2786 if (str_data != NULL) {
2787 _media->video_meta->genre = strdup(str_data);
2788 media_content_retvm_if(_media->video_meta->genre == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
2791 SAFE_FREE(_media->audio_meta->genre);
2792 if (str_data != NULL) {
2793 _media->audio_meta->genre = strdup(str_data);
2794 media_content_retvm_if(_media->audio_meta->genre == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
2798 case MEDIA_INFO_RECORDED_DATE:
2799 if (STRING_VALID(_media->media_id)) {
2800 if (_media->media_type == MEDIA_CONTENT_TYPE_VIDEO) {
2801 SAFE_FREE(_media->video_meta->recorded_date);
2802 if (str_data != NULL) {
2803 _media->video_meta->recorded_date = strdup(str_data);
2804 media_content_retvm_if(_media->video_meta->recorded_date == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
2806 } else if ((_media->media_type == MEDIA_CONTENT_TYPE_MUSIC) || (_media->media_type == MEDIA_CONTENT_TYPE_SOUND)) {
2807 SAFE_FREE(_media->audio_meta->recorded_date);
2808 if (str_data != NULL) {
2809 _media->audio_meta->recorded_date = strdup(str_data);
2810 media_content_retvm_if(_media->audio_meta->recorded_date == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
2814 SAFE_FREE(_media->video_meta->recorded_date);
2815 if (str_data != NULL) {
2816 _media->video_meta->recorded_date = strdup(str_data);
2817 media_content_retvm_if(_media->video_meta->recorded_date == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
2820 SAFE_FREE(_media->audio_meta->recorded_date);
2821 if (str_data != NULL) {
2822 _media->audio_meta->recorded_date = strdup(str_data);
2823 media_content_retvm_if(_media->audio_meta->recorded_date == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
2828 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
2829 return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
2832 return MEDIA_CONTENT_ERROR_NONE;
2835 static int __media_info_destroy(media_info_h media)
2837 int ret = MEDIA_CONTENT_ERROR_NONE;
2838 media_info_s *_media = (media_info_s*)media;
2841 SAFE_FREE(_media->media_id);
2842 SAFE_FREE(_media->file_path);
2843 SAFE_FREE(_media->display_name);
2844 SAFE_FREE(_media->mime_type);
2845 SAFE_FREE(_media->thumbnail_path);
2846 SAFE_FREE(_media->description);
2847 SAFE_FREE(_media->author);
2848 SAFE_FREE(_media->provider);
2849 SAFE_FREE(_media->content_name);
2850 SAFE_FREE(_media->category);
2851 SAFE_FREE(_media->location_tag);
2852 SAFE_FREE(_media->age_rating);
2853 SAFE_FREE(_media->keyword);
2854 SAFE_FREE(_media->title);
2855 SAFE_FREE(_media->weather);
2856 SAFE_FREE(_media->storage_uuid);
2858 if (_media->image_meta) {
2859 SAFE_FREE(_media->image_meta->media_id);
2860 SAFE_FREE(_media->image_meta->date_taken);
2861 SAFE_FREE(_media->image_meta->burst_id);
2862 SAFE_FREE(_media->image_meta->exposure_time);
2863 SAFE_FREE(_media->image_meta->model);
2864 SAFE_FREE(_media->image_meta->title);
2865 SAFE_FREE(_media->image_meta->weather);
2867 SAFE_FREE(_media->image_meta);
2870 if (_media->video_meta) {
2871 SAFE_FREE(_media->video_meta->media_id);
2872 SAFE_FREE(_media->video_meta->title);
2873 SAFE_FREE(_media->video_meta->album);
2874 SAFE_FREE(_media->video_meta->artist);
2875 SAFE_FREE(_media->video_meta->album_artist);
2876 SAFE_FREE(_media->video_meta->genre);
2877 SAFE_FREE(_media->video_meta->composer);
2878 SAFE_FREE(_media->video_meta->year);
2879 SAFE_FREE(_media->video_meta->recorded_date);
2880 SAFE_FREE(_media->video_meta->copyright);
2881 SAFE_FREE(_media->video_meta->track_num);
2883 SAFE_FREE(_media->video_meta);
2886 if (_media->audio_meta) {
2887 SAFE_FREE(_media->audio_meta->media_id);
2888 SAFE_FREE(_media->audio_meta->title);
2889 SAFE_FREE(_media->audio_meta->album);
2890 SAFE_FREE(_media->audio_meta->artist);
2891 SAFE_FREE(_media->audio_meta->album_artist);
2892 SAFE_FREE(_media->audio_meta->genre);
2893 SAFE_FREE(_media->audio_meta->composer);
2894 SAFE_FREE(_media->audio_meta->year);
2895 SAFE_FREE(_media->audio_meta->recorded_date);
2896 SAFE_FREE(_media->audio_meta->copyright);
2897 SAFE_FREE(_media->audio_meta->track_num);
2899 SAFE_FREE(_media->audio_meta);
2902 ret = MEDIA_CONTENT_ERROR_NONE;
2904 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
2905 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
2911 int media_info_insert_to_db_with_data(media_info_h media)
2913 int ret = MEDIA_CONTENT_ERROR_NONE;
2915 media_info_s *_media = (media_info_s*)media;
2917 media_content_retvm_if(_media == NULL, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid media");
2918 media_content_retvm_if(!STRING_VALID(_media->file_path), MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid file_path");
2919 media_content_retvm_if(!STRING_VALID(_media->storage_uuid), MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid storage_uuid");
2920 media_content_retvm_if(_media->storage_type < 0, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid storage_type [%d]", _media->storage_type);
2922 /* Cloud Item should be filled whole info*/
2923 if (_media->storage_type == MEDIA_CONTENT_STORAGE_CLOUD) {
2924 media_content_retvm_if(!STRING_VALID(_media->mime_type), MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid mime_type");
2925 media_content_retvm_if(!STRING_VALID(_media->title), MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid title");
2926 media_content_retvm_if(_media->size <= 0, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid size [%d]", _media->size);
2927 media_content_retvm_if(_media->modified_time <= 0, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid modified_time [%d]", _media->modified_time);
2929 if ((_media->media_type < MEDIA_CONTENT_TYPE_IMAGE) || (_media->media_type > MEDIA_CONTENT_TYPE_OTHERS)) {
2930 media_content_error("invalid media type [%d]", _media->media_type);
2931 return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
2935 media_content_sec_debug("storage[%d], path[%s], media_type[%d]", _media->storage_type, _media->file_path, _media->media_type);
2937 media_svc_content_info_s *svc_content_info = NULL;
2939 ret = __media_info_map_data_usr_to_svc(_media, &svc_content_info, _media->storage_type);
2940 media_content_retvm_if(ret != MEDIA_CONTENT_ERROR_NONE, ret, "__media_info_map_data_usr_to_svc fail");
2942 ret = media_svc_insert_item_immediately_with_data(_content_get_db_handle(), svc_content_info, tzplatform_getuid(TZ_USER_NAME));
2943 if (ret != MS_MEDIA_ERR_NONE) {
2944 media_content_sec_error("media_svc_insert_item_immediately_with_data failed : %d (%s)", ret, _media->file_path);
2945 media_svc_destroy_content_info(svc_content_info);
2946 SAFE_FREE(svc_content_info);
2947 return _content_error_capi(MEDIA_CONTENT_TYPE, ret);
2949 /*free the svc_content_info*/
2950 media_svc_destroy_content_info(svc_content_info);
2951 SAFE_FREE(svc_content_info);
2953 /*Fill out the handle*/
2954 char *media_file_path = g_strdup(_media->file_path);
2955 char *media_string_uuid = g_strdup(_media->storage_uuid);
2957 __media_info_destroy(media);
2958 ret = _media_info_get_media_info_from_db(media_file_path, media_string_uuid, media);
2959 if (ret != MEDIA_CONTENT_ERROR_NONE)
2960 media_content_error("_media_info_get_media_info_from_db fail", ret);
2962 SAFE_FREE(media_file_path);
2963 SAFE_FREE(media_string_uuid);
2968 int media_info_create(const char *path, media_info_h *media)
2970 int ret = MEDIA_CONTENT_ERROR_NONE;
2971 char storage_id[MEDIA_CONTENT_UUID_SIZE+1] = {0, };
2972 media_svc_storage_type_e storage_type = 0;
2973 bool ignore_file = FALSE;
2975 media_content_retvm_if(!STRING_VALID(path), MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid path");
2976 media_content_retvm_if(media == NULL, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid media");
2978 ret = _media_util_check_ignore_file(path, &ignore_file);
2979 media_content_retvm_if(ignore_file == TRUE, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid path");
2981 memset(storage_id, 0x00, sizeof(storage_id));
2983 if (STRING_VALID(MEDIA_ROOT_PATH_CLOUD) && (strstr(path, MEDIA_ROOT_PATH_CLOUD) == NULL)) {
2984 bool ignore_dir = FALSE;
2985 char *folder_path = NULL;
2987 ret = _media_util_check_file_exist(path);
2988 media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
2990 folder_path = g_path_get_dirname(path);
2991 ret = _media_util_check_ignore_dir(folder_path, &ignore_dir);
2992 SAFE_FREE(folder_path);
2993 media_content_retvm_if(ignore_dir == TRUE, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid folder path");
2995 ret = media_svc_get_storage_id(_content_get_db_handle(), path, storage_id);
2996 if (ret != MS_MEDIA_ERR_NONE) {
2997 media_content_error("media_svc_get_storage_id failed : %d", ret);
2998 return _content_error_capi(MEDIA_CONTENT_TYPE, ret);
3001 ret = media_svc_get_storage_type(path, &storage_type, tzplatform_getuid(TZ_USER_NAME));
3002 if (ret != MS_MEDIA_ERR_NONE) {
3003 media_content_sec_error("media_svc_get_storage_type failed : %d", ret);
3004 return _content_error_capi(MEDIA_CONTENT_TYPE, ret);
3008 media_info_s *_media = (media_info_s*)calloc(1, sizeof(media_info_s));
3009 media_content_retvm_if(_media == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
3011 _media->audio_meta = (audio_meta_s *)calloc(1, sizeof(audio_meta_s));
3012 if (_media->audio_meta == NULL) {
3014 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
3015 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
3018 _media->video_meta = (video_meta_s *)calloc(1, sizeof(video_meta_s));
3019 if (_media->video_meta == NULL) {
3020 SAFE_FREE(_media->audio_meta);
3022 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
3023 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
3026 _media->image_meta = (image_meta_s *)calloc(1, sizeof(image_meta_s));
3027 if (_media->image_meta == NULL) {
3028 SAFE_FREE(_media->audio_meta);
3029 SAFE_FREE(_media->video_meta);
3031 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
3032 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
3035 _media->file_path = g_strdup(path);
3036 _media->storage_type = -1;
3037 _media->media_type = 0;
3038 _media->modified_time = 0;
3040 _media->request_id = 0;
3041 _media->longitude = MEDIA_SVC_DEFAULT_GPS_VALUE;
3042 _media->latitude = MEDIA_SVC_DEFAULT_GPS_VALUE;
3043 _media->altitude = MEDIA_SVC_DEFAULT_GPS_VALUE;
3045 if (STRING_VALID(storage_id)) {
3046 _media->storage_uuid = g_strdup(storage_id);
3047 _media->storage_type = storage_type;
3050 *media = (media_info_h)_media;
3055 int media_info_set_mime_type(media_info_h media, const char *mime_type)
3057 return __media_info_set_str_data(media, MEDIA_INFO_MIME_TYPE, mime_type);
3060 int media_info_set_title(media_info_h media, const char *title)
3062 return __media_info_set_str_data(media, MEDIA_INFO_TITLE, title);
3065 int media_info_set_album(media_info_h media, const char *album)
3067 return __media_info_set_str_data(media, MEDIA_INFO_ALBUM, album);
3070 int media_info_set_artist(media_info_h media, const char *artist)
3072 return __media_info_set_str_data(media, MEDIA_INFO_ARTIST, artist);
3075 int media_info_set_genre(media_info_h media, const char *genre)
3077 return __media_info_set_str_data(media, MEDIA_INFO_GENRE, genre);
3080 int media_info_set_recorded_date(media_info_h media, const char *recorded_date)
3082 return __media_info_set_str_data(media, MEDIA_INFO_RECORDED_DATE, recorded_date);
3085 int media_info_set_thumbnail_path(media_info_h media, const char *thumbnail_path)
3087 return __media_info_set_str_data(media, MEDIA_INFO_THUMBNAIL_PATH, thumbnail_path);
3090 int media_info_set_storage_id(media_info_h media, const char *storage_id)
3092 return __media_info_set_str_data(media, MEDIA_INFO_STORAGE_UUID, storage_id);
3095 int media_info_set_size(media_info_h media, unsigned long long size)
3097 media_info_s *_media = (media_info_s*)media;
3099 media_content_retvm_if(_media == NULL, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid media");
3101 _media->size = size;
3103 return MEDIA_CONTENT_ERROR_NONE;
3106 int media_info_set_modified_time(media_info_h media, time_t modified_time)
3108 media_info_s *_media = (media_info_s*)media;
3110 media_content_retvm_if(_media == NULL, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid media");
3112 _media->modified_time = modified_time;
3114 return MEDIA_CONTENT_ERROR_NONE;
3117 int media_info_set_media_type(media_info_h media, media_content_type_e type)
3119 media_info_s *_media = (media_info_s*)media;
3121 media_content_retvm_if(_media == NULL, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid media");
3123 _media->media_type = type;
3125 return MEDIA_CONTENT_ERROR_NONE;
3128 int media_info_set_duration(media_info_h media, int duration)
3130 media_info_s *_media = (media_info_s*)media;
3132 media_content_retvm_if(_media == NULL, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid media");
3134 if (_media->media_type == MEDIA_CONTENT_TYPE_VIDEO)
3135 _media->video_meta->duration = duration;
3136 else if ((_media->media_type == MEDIA_CONTENT_TYPE_MUSIC) || (_media->media_type == MEDIA_CONTENT_TYPE_SOUND))
3137 _media->audio_meta->duration = duration;
3139 media_content_error("Invalid media type");
3140 return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
3143 return MEDIA_CONTENT_ERROR_NONE;
3146 int media_info_set_width(media_info_h media, int width)
3148 media_info_s *_media = (media_info_s*)media;
3150 media_content_retvm_if(_media == NULL, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid media");
3152 if (_media->media_type == MEDIA_CONTENT_TYPE_VIDEO)
3153 _media->video_meta->width = width;
3154 else if (_media->media_type == MEDIA_CONTENT_TYPE_IMAGE)
3155 _media->image_meta->width = width;
3157 media_content_error("Invalid media type");
3158 return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
3161 return MEDIA_CONTENT_ERROR_NONE;
3164 int media_info_set_height(media_info_h media, int height)
3166 media_info_s *_media = (media_info_s*)media;
3168 media_content_retvm_if(_media == NULL, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid media");
3170 if (_media->media_type == MEDIA_CONTENT_TYPE_VIDEO)
3171 _media->video_meta->height = height;
3172 else if (_media->media_type == MEDIA_CONTENT_TYPE_IMAGE)
3173 _media->image_meta->height = height;
3175 media_content_error("Invalid media type");
3176 return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
3179 return MEDIA_CONTENT_ERROR_NONE;
3182 int media_info_set_storage_type(media_info_h media, media_content_storage_e storage_type)
3184 media_info_s *_media = (media_info_s*)media;
3186 media_content_retvm_if(_media == NULL, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid media");
3188 _media->storage_type = storage_type;
3190 return MEDIA_CONTENT_ERROR_NONE;