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));
262 _media->is_360 = (int)sqlite3_column_int(stmt, MEDIA_INFO_IS_360);
264 if (_media->media_type == MEDIA_CONTENT_TYPE_IMAGE) {
265 _media->image_meta = (image_meta_s *)calloc(1, sizeof(image_meta_s));
266 if (_media->image_meta) {
267 _media->image_meta->media_id = g_strdup(_media->media_id);
268 _media->image_meta->width = sqlite3_column_int(stmt, MEDIA_INFO_WIDTH);
269 _media->image_meta->height = sqlite3_column_int(stmt, MEDIA_INFO_HEIGHT);
270 _media->image_meta->fnumber = (double)sqlite3_column_double(stmt, MEDIA_INFO_FNUMBER);
271 _media->image_meta->iso = sqlite3_column_int(stmt, MEDIA_INFO_ISO);
272 _media->image_meta->date_taken = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_DATETAKEN));
273 _media->image_meta->orientation = sqlite3_column_int(stmt, MEDIA_INFO_ORIENTATION);
274 _media->image_meta->title = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_TITLE));
275 _media->image_meta->burst_id = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_BURST_ID));
276 _media->image_meta->weather = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_WEATHER));
277 _media->image_meta->exposure_time = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_EXPOSURE_TIME));
278 _media->image_meta->model = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_MODEL));
280 } else if (_media->media_type == MEDIA_CONTENT_TYPE_VIDEO) {
281 _media->video_meta = (video_meta_s *)calloc(1, sizeof(video_meta_s));
282 if (_media->video_meta) {
283 _media->video_meta->media_id = g_strdup(_media->media_id);
284 _media->video_meta->width = sqlite3_column_int(stmt, MEDIA_INFO_WIDTH);
285 _media->video_meta->height = sqlite3_column_int(stmt, MEDIA_INFO_HEIGHT);
286 _media->video_meta->title = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_TITLE));
287 _media->video_meta->album = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_ALBUM));
288 _media->video_meta->artist = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_ARTIST));
289 _media->video_meta->album_artist = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_ALBUM_ARTIST));
290 _media->video_meta->genre = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_GENRE));
291 _media->video_meta->composer = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_COMPOSER));
292 _media->video_meta->year = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_YEAR));
293 _media->video_meta->recorded_date = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_RECORDED_DATE));
294 _media->video_meta->copyright = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_COPYRIGHT));
295 _media->video_meta->track_num = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_TRACK_NUM));
296 _media->video_meta->bitrate = sqlite3_column_int(stmt, MEDIA_INFO_BITRATE);
297 _media->video_meta->duration = sqlite3_column_int(stmt, MEDIA_INFO_DURATION);
298 _media->video_meta->played_count = sqlite3_column_int(stmt, MEDIA_INFO_PLAYED_COUNT);
299 _media->video_meta->played_time = sqlite3_column_int(stmt, MEDIA_INFO_LAST_PLAYED_TIME);
300 _media->video_meta->played_position = sqlite3_column_int(stmt, MEDIA_INFO_LAST_PLAYED_POSITION);
303 } else if ((_media->media_type == MEDIA_CONTENT_TYPE_MUSIC) || (_media->media_type == MEDIA_CONTENT_TYPE_SOUND)) {
304 _media->audio_meta = (audio_meta_s *)calloc(1, sizeof(audio_meta_s));
305 if (_media->audio_meta) {
306 _media->audio_meta->media_id = g_strdup(_media->media_id);
307 _media->audio_meta->title = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_TITLE));
308 _media->audio_meta->album = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_ALBUM));
309 _media->audio_meta->artist = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_ARTIST));
310 _media->audio_meta->album_artist = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_ALBUM_ARTIST));
311 _media->audio_meta->genre = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_GENRE));
312 _media->audio_meta->composer = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_COMPOSER));
313 _media->audio_meta->year = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_YEAR));
314 _media->audio_meta->recorded_date = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_RECORDED_DATE));
315 _media->audio_meta->copyright = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_COPYRIGHT));
316 _media->audio_meta->track_num = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_TRACK_NUM));
317 _media->audio_meta->bitrate = sqlite3_column_int(stmt, MEDIA_INFO_BITRATE);
318 _media->audio_meta->bitpersample = sqlite3_column_int(stmt, MEDIA_INFO_BITPERSAMPLE);
319 _media->audio_meta->duration = sqlite3_column_int(stmt, MEDIA_INFO_DURATION);
320 _media->audio_meta->played_count = sqlite3_column_int(stmt, MEDIA_INFO_PLAYED_COUNT);
321 _media->audio_meta->played_time = sqlite3_column_int(stmt, MEDIA_INFO_LAST_PLAYED_TIME);
322 _media->audio_meta->played_position = sqlite3_column_int(stmt, MEDIA_INFO_LAST_PLAYED_POSITION);
323 _media->audio_meta->samplerate = sqlite3_column_int(stmt, MEDIA_INFO_SAMPLERATE);
324 _media->audio_meta->channel = sqlite3_column_int(stmt, MEDIA_INFO_CHANNEL);
329 int _media_info_get_media_info_from_db(const char *path, const char *storage_id, media_info_h media)
331 int ret = MEDIA_CONTENT_ERROR_NONE;
332 sqlite3_stmt *stmt = NULL;
333 char *select_query = NULL;
334 media_info_s *_media = (media_info_s*)media;
336 media_content_retvm_if(_media == NULL, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "invalid media");
338 select_query = sqlite3_mprintf(SELECT_MEDIA_BY_PATH, storage_id, path);
340 ret = _content_query_prepare(&stmt, select_query, NULL, NULL);
341 SQLITE3_SAFE_FREE(select_query);
342 media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
344 if (sqlite3_step(stmt) == SQLITE_ROW) {
345 _media_info_item_get_detail(stmt, (media_info_h)_media);
347 media_content_error("There's no media!!");
348 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
351 SQLITE3_FINALIZE(stmt);
356 int media_info_insert_to_db(const char *path, media_info_h *info)
358 bool ignore_file = FALSE;
359 bool ignore_dir = FALSE;
360 char *folder_path = NULL;
361 char storage_id[MEDIA_CONTENT_UUID_SIZE+1] = {0, };
362 int ret = MEDIA_CONTENT_ERROR_NONE;
364 media_content_retvm_if(!STRING_VALID(path), MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "invalid path");
365 media_content_retvm_if(info == NULL, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "invalid info");
367 ret = _media_util_check_ignore_file(path, &ignore_file);
368 media_content_retvm_if(ignore_file == TRUE, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid path");
370 ret = _media_util_check_file_exist(path);
371 media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
373 folder_path = g_path_get_dirname(path);
374 ret = _media_util_check_ignore_dir(folder_path, &ignore_dir);
375 SAFE_FREE(folder_path);
377 media_content_retvm_if(ignore_dir == TRUE, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid folder path");
379 memset(storage_id, 0x00, sizeof(storage_id));
380 ret = media_svc_get_storage_id(_content_get_db_handle(), path, storage_id);
381 if (ret != MS_MEDIA_ERR_NONE) {
382 media_content_error("media_svc_get_storage_id failed : %d", ret);
383 return _content_error_capi(MEDIA_CONTENT_TYPE, ret);
386 ret = media_svc_check_item_exist_by_path(_content_get_db_handle(), storage_id, path);
387 if (ret == MS_MEDIA_ERR_DB_NO_RECORD) {
388 media_content_sec_debug("media_svc_check_item_exist_by_path : no record : %s", path);
390 media_svc_storage_type_e storage_type = 0;
392 ret = media_svc_get_storage_type(path, &storage_type, tzplatform_getuid(TZ_USER_NAME));
393 if (ret != MS_MEDIA_ERR_NONE) {
394 media_content_sec_error("media_svc_get_storage_type failed : %d", ret);
395 return _content_error_capi(MEDIA_CONTENT_TYPE, ret);
398 ret = media_svc_insert_item_immediately(_content_get_db_handle(), storage_id, storage_type, path, tzplatform_getuid(TZ_USER_NAME));
400 if (ret != MS_MEDIA_ERR_NONE) {
401 if (ret == MS_MEDIA_ERR_DB_CONSTRAINT_FAIL) {
402 media_content_sec_error("This item is already inserted. This may be normal operation because other process already did this (%s)", path);
403 ret = MEDIA_CONTENT_ERROR_NONE;
405 media_content_sec_error("media_svc_insert_item_immediately failed : %d (%s)", ret, path);
408 return _content_error_capi(MEDIA_CONTENT_TYPE, ret);
410 } else if (ret != MS_MEDIA_ERR_NONE) {
411 media_content_sec_error("media_svc_check_item_exist_by_path failed : %d (%s)", ret, path);
412 return _content_error_capi(MEDIA_CONTENT_TYPE, ret);
415 media_info_s *_media = (media_info_s*)calloc(1, sizeof(media_info_s));
416 media_content_retvm_if(_media == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
418 ret = _media_info_get_media_info_from_db(path, DEFAULT_MEDIA_STORAGE_ID, (media_info_h)_media);
420 *info = (media_info_h)_media;
424 int media_info_insert_batch_to_db(
425 const char **path_array,
426 unsigned int array_length,
427 media_insert_completed_cb completed_cb,
430 media_content_retvm_if(path_array == NULL, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid path_array");
431 media_content_retvm_if(array_length <= 0, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid array_length");
433 return __media_info_insert_batch(MEDIA_BATCH_INSERT_NORMAL, path_array, array_length, completed_cb, user_data);
436 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)
438 media_content_retvm_if(path_array == NULL, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid path_array");
439 media_content_retvm_if(array_length <= 0, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid array_length");
441 return __media_info_insert_batch(MEDIA_BATCH_INSERT_BURSTSHOT, path_array, array_length, callback, user_data);
444 int media_info_delete_from_db(const char *media_id)
446 int ret = MEDIA_CONTENT_ERROR_NONE;
448 char storage_id[MEDIA_CONTENT_UUID_SIZE+1] = {0, };
450 if (!STRING_VALID(media_id)) {
451 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
452 return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
455 memset(storage_id, 0x00, sizeof(storage_id));
457 ret = __media_info_get_media_path_by_id_from_db(media_id, &path);
458 if (ret != MEDIA_CONTENT_ERROR_NONE) {
459 media_content_error("__media_info_get_media_path_by_id_from_db failed : %d", ret);
464 ret = _media_db_get_storage_id_by_media_id(media_id, storage_id);
465 if (ret != MEDIA_CONTENT_ERROR_NONE) {
466 media_content_error("_media_db_get_storage_id_by_media_id failed : %d", ret);
471 ret = media_svc_delete_item_by_path(_content_get_db_handle(), storage_id, path, tzplatform_getuid(TZ_USER_NAME));
474 return _content_error_capi(MEDIA_CONTENT_TYPE, ret);
477 static int __media_info_delete_thumb_from_list(GArray *thumb_list)
481 char *thumb_path = NULL;
483 if (thumb_list != NULL) {
484 list_len = thumb_list->len;
485 for (i = 0; i < list_len; i++) {
486 thumb_path = g_array_index(thumb_list, char*, i);
487 media_content_debug("thumb path [%s]", thumb_path);
488 if (unlink(thumb_path) < 0)
489 media_content_stderror("failed to delete");
492 return MEDIA_CONTENT_ERROR_NONE;
495 static int __media_info_release_thumb_list(GArray *thumb_list)
499 char *thumb_path = NULL;
501 if (thumb_list != NULL) {
502 list_len = thumb_list->len;
503 for (i = 0; i < list_len; i++) {
504 thumb_path = g_array_index(thumb_list, char*, 0);
505 g_array_remove_index(thumb_list, 0);
506 SAFE_FREE(thumb_path);
509 g_array_free(thumb_list, FALSE);
512 return MEDIA_CONTENT_ERROR_NONE;
515 int media_info_delete_batch_from_db(filter_h filter)
517 int ret = MEDIA_CONTENT_ERROR_NONE;
519 char *query_string = NULL;
520 filter_s *_filter = NULL;
522 char *condition_query = NULL;
523 GArray *thumb_list = NULL;
525 media_content_retvm_if(filter == NULL, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid filter");
527 thumb_list = g_array_new(FALSE, FALSE, sizeof(char*));
529 /* Delete thumbnail of each item */
530 ret = _media_db_get_group_item(NULL, filter, __media_info_delete_batch_cb, thumb_list, MEDIA_GROUP_NONE);
532 _filter = (filter_s*)filter;
533 attr = _content_get_attirbute_handle();
535 if (_filter->condition) {
536 ret = _media_filter_attribute_generate(attr, _filter->condition, _filter->condition_collate_type, &condition_query);
537 if (ret != MEDIA_CONTENT_ERROR_NONE) {
538 __media_info_release_thumb_list(thumb_list);
543 if (STRING_VALID(condition_query)) {
544 if (_filter->storage_id == NULL) {
546 query_string = sqlite3_mprintf(DELETE_MEDIA_FROM_MEDIA_BATCH, "media", condition_query);
548 query_string = sqlite3_mprintf(DELETE_MEDIA_FROM_MEDIA_BATCH, _filter->storage_id, condition_query);
551 SAFE_FREE(condition_query);
552 __media_info_release_thumb_list(thumb_list);
554 return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
557 ret = _content_query_sql(query_string);
558 if (ret == MEDIA_CONTENT_ERROR_NONE) {
559 /* Send notification for this
560 In this case, send noti for internal storage and external storage
562 media_content_debug("Batch deletion is successfull. Send notification for this");
563 if (_filter->storage_id != NULL) {
564 char *storage_path = NULL;
565 media_svc_get_storage_path(_content_get_db_handle(), _filter->storage_id, &storage_path);
566 if (STRING_VALID(storage_path))
567 media_svc_publish_noti(MS_MEDIA_ITEM_DIRECTORY, MS_MEDIA_ITEM_UPDATE, storage_path, -1, NULL, NULL);
569 SAFE_FREE(storage_path);
572 media_svc_publish_noti(MS_MEDIA_ITEM_DIRECTORY, MS_MEDIA_ITEM_UPDATE, MEDIA_ROOT_PATH_INTERNAL, -1, NULL, NULL);
573 media_svc_publish_noti(MS_MEDIA_ITEM_DIRECTORY, MS_MEDIA_ITEM_UPDATE, MEDIA_ROOT_PATH_SDCARD, -1, NULL, NULL);
576 __media_info_delete_thumb_from_list(thumb_list);
577 __media_info_release_thumb_list(thumb_list);
580 SAFE_FREE(condition_query);
581 SQLITE3_SAFE_FREE(query_string);
586 int media_info_destroy(media_info_h media)
588 int ret = MEDIA_CONTENT_ERROR_NONE;
589 media_info_s *_media = (media_info_s*)media;
592 SAFE_FREE(_media->media_id);
593 SAFE_FREE(_media->file_path);
594 SAFE_FREE(_media->display_name);
595 SAFE_FREE(_media->mime_type);
596 SAFE_FREE(_media->thumbnail_path);
597 SAFE_FREE(_media->description);
598 SAFE_FREE(_media->author);
599 SAFE_FREE(_media->provider);
600 SAFE_FREE(_media->content_name);
601 SAFE_FREE(_media->category);
602 SAFE_FREE(_media->location_tag);
603 SAFE_FREE(_media->age_rating);
604 SAFE_FREE(_media->keyword);
605 SAFE_FREE(_media->title);
606 SAFE_FREE(_media->weather);
607 SAFE_FREE(_media->storage_uuid);
609 if (_media->image_meta) {
610 SAFE_FREE(_media->image_meta->media_id);
611 SAFE_FREE(_media->image_meta->date_taken);
612 SAFE_FREE(_media->image_meta->burst_id);
613 SAFE_FREE(_media->image_meta->exposure_time);
614 SAFE_FREE(_media->image_meta->model);
615 SAFE_FREE(_media->image_meta->title);
616 SAFE_FREE(_media->image_meta->weather);
618 SAFE_FREE(_media->image_meta);
621 if (_media->video_meta) {
622 SAFE_FREE(_media->video_meta->media_id);
623 SAFE_FREE(_media->video_meta->title);
624 SAFE_FREE(_media->video_meta->album);
625 SAFE_FREE(_media->video_meta->artist);
626 SAFE_FREE(_media->video_meta->album_artist);
627 SAFE_FREE(_media->video_meta->genre);
628 SAFE_FREE(_media->video_meta->composer);
629 SAFE_FREE(_media->video_meta->year);
630 SAFE_FREE(_media->video_meta->recorded_date);
631 SAFE_FREE(_media->video_meta->copyright);
632 SAFE_FREE(_media->video_meta->track_num);
634 SAFE_FREE(_media->video_meta);
637 if (_media->audio_meta) {
638 SAFE_FREE(_media->audio_meta->media_id);
639 SAFE_FREE(_media->audio_meta->title);
640 SAFE_FREE(_media->audio_meta->album);
641 SAFE_FREE(_media->audio_meta->artist);
642 SAFE_FREE(_media->audio_meta->album_artist);
643 SAFE_FREE(_media->audio_meta->genre);
644 SAFE_FREE(_media->audio_meta->composer);
645 SAFE_FREE(_media->audio_meta->year);
646 SAFE_FREE(_media->audio_meta->recorded_date);
647 SAFE_FREE(_media->audio_meta->copyright);
648 SAFE_FREE(_media->audio_meta->track_num);
650 SAFE_FREE(_media->audio_meta);
655 ret = MEDIA_CONTENT_ERROR_NONE;
657 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
658 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
664 int media_info_clone(media_info_h *dst, media_info_h src)
666 int ret = MEDIA_CONTENT_ERROR_NONE;
667 media_info_s *_src = (media_info_s*)src;
670 media_info_s *_dst = (media_info_s*)calloc(1, sizeof(media_info_s));
671 media_content_retvm_if(_dst == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
673 if (_src->media_id) {
674 _dst->media_id = g_strdup(_src->media_id);
675 if (_dst->media_id == NULL) {
676 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
677 media_info_destroy((media_info_h)_dst);
678 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
681 if (_src->file_path) {
682 _dst->file_path = g_strdup(_src->file_path);
683 if (_dst->file_path == NULL) {
684 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
685 media_info_destroy((media_info_h)_dst);
686 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
689 if (_src->display_name != NULL) {
690 _dst->display_name = g_strdup(_src->display_name);
691 if (_dst->display_name == NULL) {
692 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
693 media_info_destroy((media_info_h)_dst);
694 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
697 if (_src->mime_type) {
698 _dst->mime_type = g_strdup(_src->mime_type);
699 if (_dst->mime_type == NULL) {
700 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
701 media_info_destroy((media_info_h)_dst);
702 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
705 if (_src->thumbnail_path != NULL) {
706 _dst->thumbnail_path = g_strdup(_src->thumbnail_path);
707 if (_dst->thumbnail_path == NULL) {
708 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
709 media_info_destroy((media_info_h)_dst);
710 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
713 if (_src->description != NULL) {
714 _dst->description = g_strdup(_src->description);
715 if (_dst->description == NULL) {
716 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
717 media_info_destroy((media_info_h)_dst);
718 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
722 if (_src->weather != NULL) {
723 _dst->weather = g_strdup(_src->weather);
724 if (_dst->weather == NULL) {
725 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
726 media_info_destroy((media_info_h)_dst);
727 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
731 if (_src->title != NULL) {
732 _dst->title = g_strdup(_src->title);
733 if (_dst->title == NULL) {
734 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
735 media_info_destroy((media_info_h)_dst);
736 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
739 if (_src->author != NULL) {
740 _dst->author = g_strdup(_src->author);
741 if (_dst->author == NULL) {
742 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
743 media_info_destroy((media_info_h)_dst);
744 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
747 if (_src->provider != NULL) {
748 _dst->provider = g_strdup(_src->provider);
749 if (_dst->provider == NULL) {
750 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
751 media_info_destroy((media_info_h)_dst);
752 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
755 if (_src->content_name != NULL) {
756 _dst->content_name = g_strdup(_src->content_name);
757 if (_dst->content_name == NULL) {
758 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
759 media_info_destroy((media_info_h)_dst);
760 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
763 if (_src->category != NULL) {
764 _dst->category = g_strdup(_src->category);
765 if (_dst->category == NULL) {
766 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
767 media_info_destroy((media_info_h)_dst);
768 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
771 if (_src->location_tag != NULL) {
772 _dst->location_tag = g_strdup(_src->location_tag);
773 if (_dst->location_tag == NULL) {
774 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
775 media_info_destroy((media_info_h)_dst);
776 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
779 if (_src->age_rating != NULL) {
780 _dst->age_rating = g_strdup(_src->age_rating);
781 if (_dst->age_rating == NULL) {
782 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
783 media_info_destroy((media_info_h)_dst);
784 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
787 if (_src->keyword != NULL) {
788 _dst->keyword = g_strdup(_src->keyword);
789 if (_dst->keyword == NULL) {
790 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
791 media_info_destroy((media_info_h)_dst);
792 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
796 if (_src->storage_uuid != NULL) {
797 _dst->storage_uuid = g_strdup(_src->storage_uuid);
798 if (_dst->storage_uuid == NULL) {
799 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
800 media_info_destroy((media_info_h)_dst);
801 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
805 _dst->media_type = _src->media_type;
806 _dst->size = _src->size;
807 _dst->added_time = _src->added_time;
808 _dst->modified_time = _src->modified_time;
809 _dst->timeline = _src->timeline;
810 _dst->longitude = _src->longitude;
811 _dst->latitude = _src->latitude;
812 _dst->altitude = _src->altitude;
813 _dst->rating = _src->rating;
814 _dst->favourite = _src->favourite;
815 _dst->is_drm = _src->is_drm;
816 _dst->storage_type = _src->storage_type;
817 _dst->played_count = _src->played_count;
818 _dst->played_time = _src->played_time;
819 _dst->played_position = _src->played_position;
820 _dst->sync_status = _src->sync_status;
821 _dst->request_id = _src->request_id;
822 _dst->is_360 = _src->is_360;
824 if (_src->media_type == MEDIA_CONTENT_TYPE_IMAGE && _src->image_meta) {
825 _dst->image_meta = (image_meta_s *)calloc(1, sizeof(image_meta_s));
826 if (_dst->image_meta == NULL) {
827 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
828 media_info_destroy((media_info_h)_dst);
829 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
832 if (_src->image_meta->media_id != NULL) {
833 _dst->image_meta->media_id = g_strdup(_src->image_meta->media_id);
834 if (_dst->image_meta->media_id == NULL) {
835 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
836 media_info_destroy((media_info_h)_dst);
837 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
841 if (_src->image_meta->date_taken != NULL) {
842 _dst->image_meta->date_taken = g_strdup(_src->image_meta->date_taken);
843 if (_dst->image_meta->date_taken == NULL) {
844 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
845 media_info_destroy((media_info_h)_dst);
846 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
850 if (_src->image_meta->burst_id != NULL) {
851 _dst->image_meta->burst_id = g_strdup(_src->image_meta->burst_id);
852 if (_dst->image_meta->burst_id == NULL) {
853 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
854 media_info_destroy((media_info_h)_dst);
855 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
859 if (_src->image_meta->weather != NULL) {
860 _dst->image_meta->weather = g_strdup(_src->image_meta->weather);
861 if (_dst->image_meta->weather == NULL) {
862 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
863 media_info_destroy((media_info_h)_dst);
864 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
868 if (_src->image_meta->exposure_time != NULL) {
869 _dst->image_meta->exposure_time = g_strdup(_src->image_meta->exposure_time);
870 if (_dst->image_meta->exposure_time == NULL) {
871 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
872 media_info_destroy((media_info_h)_dst);
873 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
877 if (_src->image_meta->model != NULL) {
878 _dst->image_meta->model = g_strdup(_src->image_meta->model);
879 if (_dst->image_meta->model == NULL) {
880 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
881 media_info_destroy((media_info_h)_dst);
882 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
886 _dst->image_meta->fnumber = _src->image_meta->fnumber;
887 _dst->image_meta->iso = _src->image_meta->iso;
888 _dst->image_meta->width = _src->image_meta->width;
889 _dst->image_meta->height = _src->image_meta->height;
890 _dst->image_meta->orientation = _src->image_meta->orientation;
892 } else if (_src->media_type == MEDIA_CONTENT_TYPE_VIDEO && _src->video_meta) {
893 _dst->video_meta = (video_meta_s *)calloc(1, sizeof(video_meta_s));
894 if (_dst->video_meta == NULL) {
895 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
896 media_info_destroy((media_info_h)_dst);
897 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
900 if (_src->video_meta->media_id != NULL) {
901 _dst->video_meta->media_id = g_strdup(_src->video_meta->media_id);
902 if (_dst->video_meta->media_id == NULL) {
903 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
904 media_info_destroy((media_info_h)_dst);
905 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
908 if (_src->video_meta->title != NULL) {
909 _dst->video_meta->title = g_strdup(_src->video_meta->title);
910 if (_dst->video_meta->title == NULL) {
911 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
912 media_info_destroy((media_info_h)_dst);
913 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
916 if (_src->video_meta->album != NULL) {
917 _dst->video_meta->album = g_strdup(_src->video_meta->album);
918 if (_dst->video_meta->album == NULL) {
919 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
920 media_info_destroy((media_info_h)_dst);
921 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
924 if (_src->video_meta->artist != NULL) {
925 _dst->video_meta->artist = g_strdup(_src->video_meta->artist);
926 if (_dst->video_meta->artist == NULL) {
927 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
928 media_info_destroy((media_info_h)_dst);
929 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
932 if (_src->video_meta->album_artist != NULL) {
933 _dst->video_meta->album_artist = g_strdup(_src->video_meta->album_artist);
934 if (_dst->video_meta->album_artist == NULL) {
935 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
936 media_info_destroy((media_info_h)_dst);
937 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
940 if (_src->video_meta->genre != NULL) {
941 _dst->video_meta->genre = g_strdup(_src->video_meta->genre);
942 if (_dst->video_meta->genre == NULL) {
943 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
944 media_info_destroy((media_info_h)_dst);
945 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
948 if (_src->video_meta->composer != NULL) {
949 _dst->video_meta->composer = g_strdup(_src->video_meta->composer);
950 if (_dst->video_meta->composer == NULL) {
951 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
952 media_info_destroy((media_info_h)_dst);
953 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
956 if (_src->video_meta->year != NULL) {
957 _dst->video_meta->year = g_strdup(_src->video_meta->year);
958 if (_dst->video_meta->year == NULL) {
959 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
960 media_info_destroy((media_info_h)_dst);
961 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
964 if (_src->video_meta->recorded_date != NULL) {
965 _dst->video_meta->recorded_date = g_strdup(_src->video_meta->recorded_date);
966 if (_dst->video_meta->recorded_date == NULL) {
967 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
968 media_info_destroy((media_info_h)_dst);
969 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
972 if (_src->video_meta->copyright != NULL) {
973 _dst->video_meta->copyright = g_strdup(_src->video_meta->copyright);
974 if (_dst->video_meta->copyright == NULL) {
975 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
976 media_info_destroy((media_info_h)_dst);
977 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
980 if (_src->video_meta->track_num != NULL) {
981 _dst->video_meta->track_num = g_strdup(_src->video_meta->track_num);
982 if (_dst->video_meta->track_num == NULL) {
983 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
984 media_info_destroy((media_info_h)_dst);
985 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
989 _dst->video_meta->width = _src->video_meta->width;
990 _dst->video_meta->height = _src->video_meta->height;
991 _dst->video_meta->duration = _src->video_meta->duration;
992 _dst->video_meta->bitrate = _src->video_meta->bitrate;
993 _dst->video_meta->played_count = _src->video_meta->played_count;
994 _dst->video_meta->played_time = _src->video_meta->played_time;
995 _dst->video_meta->played_position = _src->video_meta->played_position;
997 } else if ((_src->media_type == MEDIA_CONTENT_TYPE_MUSIC || _src->media_type == MEDIA_CONTENT_TYPE_SOUND) && _src->audio_meta) {
998 _dst->audio_meta = (audio_meta_s *)calloc(1, sizeof(audio_meta_s));
999 if (_dst->audio_meta == NULL) {
1000 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
1001 media_info_destroy((media_info_h)_dst);
1002 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
1005 if (_src->audio_meta->media_id != NULL) {
1006 _dst->audio_meta->media_id = g_strdup(_src->audio_meta->media_id);
1007 if (_dst->audio_meta->media_id == NULL) {
1008 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
1009 media_info_destroy((media_info_h)_dst);
1010 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
1013 if (_src->audio_meta->title != NULL) {
1014 _dst->audio_meta->title = g_strdup(_src->audio_meta->title);
1015 if (_dst->audio_meta->title == NULL) {
1016 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
1017 media_info_destroy((media_info_h)_dst);
1018 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
1021 if (_src->audio_meta->album != NULL) {
1022 _dst->audio_meta->album = g_strdup(_src->audio_meta->album);
1023 if (_dst->audio_meta->album == NULL) {
1024 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
1025 media_info_destroy((media_info_h)_dst);
1026 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
1029 if (_src->audio_meta->artist != NULL) {
1030 _dst->audio_meta->artist = g_strdup(_src->audio_meta->artist);
1031 if (_dst->audio_meta->artist == NULL) {
1032 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
1033 media_info_destroy((media_info_h)_dst);
1034 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
1037 if (_src->audio_meta->album_artist != NULL) {
1038 _dst->audio_meta->album_artist = g_strdup(_src->audio_meta->album_artist);
1039 if (_dst->audio_meta->album_artist == NULL) {
1040 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
1041 media_info_destroy((media_info_h)_dst);
1042 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
1045 if (_src->audio_meta->genre != NULL) {
1046 _dst->audio_meta->genre = g_strdup(_src->audio_meta->genre);
1047 if (_dst->audio_meta->genre == NULL) {
1048 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
1049 media_info_destroy((media_info_h)_dst);
1050 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
1053 if (_src->audio_meta->composer != NULL) {
1054 _dst->audio_meta->composer = g_strdup(_src->audio_meta->composer);
1055 if (_dst->audio_meta->composer == NULL) {
1056 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
1057 media_info_destroy((media_info_h)_dst);
1058 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
1061 if (_src->audio_meta->year != NULL) {
1062 _dst->audio_meta->year = g_strdup(_src->audio_meta->year);
1063 if (_dst->audio_meta->year == NULL) {
1064 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
1065 media_info_destroy((media_info_h)_dst);
1066 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
1069 if (_src->audio_meta->recorded_date != NULL) {
1070 _dst->audio_meta->recorded_date = g_strdup(_src->audio_meta->recorded_date);
1071 if (_dst->audio_meta->recorded_date == NULL) {
1072 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
1073 media_info_destroy((media_info_h)_dst);
1074 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
1077 if (_src->audio_meta->copyright != NULL) {
1078 _dst->audio_meta->copyright = g_strdup(_src->audio_meta->copyright);
1079 if (_dst->audio_meta->copyright == NULL) {
1080 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
1081 media_info_destroy((media_info_h)_dst);
1082 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
1085 if (_src->audio_meta->track_num != NULL) {
1086 _dst->audio_meta->track_num = g_strdup(_src->audio_meta->track_num);
1087 if (_dst->audio_meta->track_num == NULL) {
1088 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
1089 media_info_destroy((media_info_h)_dst);
1090 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
1094 _dst->audio_meta->channel = _src->audio_meta->channel;
1095 _dst->audio_meta->samplerate = _src->audio_meta->samplerate;
1096 _dst->audio_meta->duration = _src->audio_meta->duration;
1097 _dst->audio_meta->bitrate = _src->audio_meta->bitrate;
1098 _dst->audio_meta->bitpersample = _src->audio_meta->bitpersample;
1099 _dst->audio_meta->played_count = _src->audio_meta->played_count;
1100 _dst->audio_meta->played_time = _src->audio_meta->played_time;
1101 _dst->audio_meta->played_position = _src->audio_meta->played_position;
1103 *dst = (media_info_h)_dst;
1105 ret = MEDIA_CONTENT_ERROR_NONE;
1107 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1108 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1114 int media_info_get_media_count_from_db(filter_h filter, int *media_count)
1116 int ret = MEDIA_CONTENT_ERROR_NONE;
1118 if (media_count == NULL) {
1119 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1120 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1125 ret = _media_db_get_group_item_count(NULL, filter, MEDIA_GROUP_NONE, media_count);
1130 int media_info_foreach_media_from_db(filter_h filter, media_info_cb callback, void *user_data)
1132 int ret = MEDIA_CONTENT_ERROR_NONE;
1134 media_content_retvm_if(callback == NULL, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid callback");
1136 ret = _media_db_get_group_item(NULL, filter, callback, user_data, MEDIA_GROUP_NONE);
1141 int media_info_get_tag_count_from_db(const char *media_id, filter_h filter, int *tag_count)
1143 int ret = MEDIA_CONTENT_ERROR_NONE;
1145 if (STRING_VALID(media_id) && tag_count) {
1146 ret = _media_db_get_group_item_count(media_id, filter, MEDIA_GROUP_TAG_BY_MEDIA_ID, tag_count);
1148 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1149 return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1155 int media_info_foreach_tag_from_db(const char *media_id, filter_h filter, media_tag_cb callback, void *user_data)
1157 int ret = MEDIA_CONTENT_ERROR_NONE;
1159 if ((callback != NULL) && STRING_VALID(media_id)) {
1160 ret = _media_db_get_tag(media_id, filter, callback, user_data);
1162 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1163 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1169 int media_info_get_bookmark_count_from_db(const char *media_id, filter_h filter, int *bookmark_count)
1171 int ret = MEDIA_CONTENT_ERROR_NONE;
1173 if (STRING_VALID(media_id) && bookmark_count) {
1174 ret = _media_db_get_group_item_count(media_id, filter, MEDIA_GROUP_BOOKMARK_BY_MEDIA_ID, bookmark_count);
1176 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1177 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1183 int media_info_foreach_bookmark_from_db(const char *media_id, filter_h filter, media_bookmark_cb callback, void *user_data)
1185 int ret = MEDIA_CONTENT_ERROR_NONE;
1187 if ((callback != NULL) && STRING_VALID(media_id)) {
1188 ret = _media_db_get_bookmark(media_id, filter, callback, user_data);
1190 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1191 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1197 int media_info_get_face_count_from_db(const char *media_id, filter_h filter, int *face_count)
1199 int ret = MEDIA_CONTENT_ERROR_NONE;
1201 if (STRING_VALID(media_id) && face_count) {
1202 ret = _media_db_get_group_item_count(media_id, filter, MEDIA_GROUP_FACE_BY_MEDIA_ID, face_count);
1204 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1205 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1211 int media_info_foreach_face_from_db(const char *media_id, filter_h filter, media_face_cb callback, void *user_data)
1213 int ret = MEDIA_CONTENT_ERROR_NONE;
1215 if ((callback != NULL) && STRING_VALID(media_id)) {
1216 ret = _media_db_get_face(media_id, filter, callback, user_data);
1218 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1219 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1225 int media_info_get_image(media_info_h media, image_meta_h *image)
1227 int ret = MEDIA_CONTENT_ERROR_NONE;
1229 media_info_s *_media = (media_info_s*)media;
1231 media_content_retvm_if(_media == NULL, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid media");
1232 media_content_retvm_if(_media->media_type != MEDIA_CONTENT_TYPE_IMAGE, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid media_type");
1233 media_content_retvm_if(_media->image_meta == NULL, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid image_meta");
1235 image_meta_s *_image = (image_meta_s*)calloc(1, sizeof(image_meta_s));
1236 media_content_retvm_if(_image == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
1238 _image->media_id = g_strdup(_media->media_id);
1239 _image->width = _media->image_meta->width;
1240 _image->height = _media->image_meta->height;
1241 _image->orientation = _media->image_meta->orientation;
1242 _image->fnumber = _media->image_meta->fnumber;
1243 _image->iso = _media->image_meta->iso;
1244 _image->date_taken = g_strdup(_media->image_meta->date_taken);
1245 _image->title = g_strdup(_media->image_meta->title);
1246 _image->burst_id = g_strdup(_media->image_meta->burst_id);
1247 _image->weather = g_strdup(_media->image_meta->weather);
1248 _image->exposure_time = g_strdup(_media->image_meta->exposure_time);
1249 _image->model = g_strdup(_media->image_meta->model);
1251 *image = (image_meta_h)_image;
1256 int media_info_get_video(media_info_h media, video_meta_h *video)
1258 int ret = MEDIA_CONTENT_ERROR_NONE;
1260 media_info_s *_media = (media_info_s*)media;
1262 media_content_retvm_if(_media == NULL, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid media");
1263 media_content_retvm_if(_media->media_type != MEDIA_CONTENT_TYPE_VIDEO, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid media_type");
1264 media_content_retvm_if(_media->video_meta == NULL, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid video_meta");
1266 video_meta_s *_video = (video_meta_s*)calloc(1, sizeof(video_meta_s));
1267 media_content_retvm_if(_video == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
1269 _video->media_id = g_strdup(_media->media_id);
1270 _video->title = g_strdup(_media->video_meta->title);
1271 _video->album = g_strdup(_media->video_meta->album);
1272 _video->artist = g_strdup(_media->video_meta->artist);
1273 _video->album_artist = g_strdup(_media->video_meta->album_artist);
1274 _video->genre = g_strdup(_media->video_meta->genre);
1275 _video->composer = g_strdup(_media->video_meta->composer);
1276 _video->year = g_strdup(_media->video_meta->year);
1277 _video->recorded_date = g_strdup(_media->video_meta->recorded_date);
1278 _video->copyright = g_strdup(_media->video_meta->copyright);
1279 _video->track_num = g_strdup(_media->video_meta->track_num);
1281 _video->width = _media->video_meta->width;
1282 _video->height = _media->video_meta->height;
1283 _video->duration = _media->video_meta->duration;
1284 _video->bitrate = _media->video_meta->bitrate;
1285 _video->played_count = _media->video_meta->played_count;
1286 _video->played_time = _media->video_meta->played_time;
1287 _video->played_position = _media->video_meta->played_position;
1289 *video = (video_meta_h)_video;
1294 int media_info_get_audio(media_info_h media, audio_meta_h *audio)
1296 int ret = MEDIA_CONTENT_ERROR_NONE;
1298 media_info_s *_media = (media_info_s*)media;
1300 media_content_retvm_if(_media == NULL, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid media");
1301 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");
1302 media_content_retvm_if(_media->audio_meta == NULL, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid audio_meta");
1304 audio_meta_s *_audio = (audio_meta_s*)calloc(1, sizeof(audio_meta_s));
1305 media_content_retvm_if(_audio == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
1307 _audio->media_id = g_strdup(_media->media_id);
1308 _audio->title = g_strdup(_media->audio_meta->title);
1309 _audio->album = g_strdup(_media->audio_meta->album);
1310 _audio->artist = g_strdup(_media->audio_meta->artist);
1311 _audio->album_artist = g_strdup(_media->audio_meta->album_artist);
1312 _audio->genre = g_strdup(_media->audio_meta->genre);
1313 _audio->composer = g_strdup(_media->audio_meta->composer);
1314 _audio->year = g_strdup(_media->audio_meta->year);
1315 _audio->recorded_date = g_strdup(_media->audio_meta->recorded_date);
1316 _audio->copyright = g_strdup(_media->audio_meta->copyright);
1317 _audio->track_num = g_strdup(_media->audio_meta->track_num);
1319 _audio->duration = _media->audio_meta->duration;
1320 _audio->bitrate = _media->audio_meta->bitrate;
1321 _audio->bitpersample = _media->audio_meta->bitpersample;
1322 _audio->samplerate = _media->audio_meta->samplerate;
1323 _audio->channel = _media->audio_meta->channel;
1324 _audio->played_time = _media->audio_meta->played_time;
1325 _audio->played_count = _media->audio_meta->played_count;
1326 _audio->played_position = _media->audio_meta->played_position;
1328 *audio = (audio_meta_h)_audio;
1333 int media_info_get_media_id(media_info_h media, char **media_id)
1335 int ret = MEDIA_CONTENT_ERROR_NONE;
1336 media_info_s *_media = (media_info_s*)media;
1338 if (_media && media_id) {
1339 if (STRING_VALID(_media->media_id)) {
1340 *media_id = strdup(_media->media_id);
1341 media_content_retvm_if(*media_id == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
1345 ret = MEDIA_CONTENT_ERROR_NONE;
1347 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1348 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1354 int media_info_get_file_path(media_info_h media, char **path)
1356 int ret = MEDIA_CONTENT_ERROR_NONE;
1357 media_info_s *_media = (media_info_s*)media;
1359 if (_media && path) {
1360 if (STRING_VALID(_media->file_path)) {
1361 *path = strdup(_media->file_path);
1362 media_content_retvm_if(*path == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
1366 ret = MEDIA_CONTENT_ERROR_NONE;
1369 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1370 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1376 int media_info_get_display_name(media_info_h media, char **name)
1378 int ret = MEDIA_CONTENT_ERROR_NONE;
1379 media_info_s *_media = (media_info_s*)media;
1380 if (_media && name) {
1381 if (_media->display_name != NULL) {
1382 *name = g_strdup(_media->display_name);
1383 media_content_retvm_if(*name == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
1387 ret = MEDIA_CONTENT_ERROR_NONE;
1390 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1391 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1397 int media_info_get_media_type(media_info_h media, media_content_type_e *type)
1399 int ret = MEDIA_CONTENT_ERROR_NONE;
1400 media_info_s *_media = (media_info_s*)media;
1401 if (_media && type) {
1402 *type = _media->media_type;
1403 ret = MEDIA_CONTENT_ERROR_NONE;
1405 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1406 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1412 int media_info_get_mime_type(media_info_h media, char **mime_type)
1414 int ret = MEDIA_CONTENT_ERROR_NONE;
1415 media_info_s *_media = (media_info_s*)media;
1417 if (_media && mime_type) {
1418 if (STRING_VALID(_media->mime_type)) {
1419 *mime_type = strdup(_media->mime_type);
1420 media_content_retvm_if(*mime_type == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
1424 ret = MEDIA_CONTENT_ERROR_NONE;
1426 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1427 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1433 int media_info_get_size(media_info_h media, unsigned long long *size)
1435 int ret = MEDIA_CONTENT_ERROR_NONE;
1436 media_info_s *_media = (media_info_s*)media;
1438 if (_media && size) {
1439 *size = _media->size;
1440 ret = MEDIA_CONTENT_ERROR_NONE;
1442 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1443 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1449 int media_info_get_added_time(media_info_h media, time_t *added_time)
1451 int ret = MEDIA_CONTENT_ERROR_NONE;
1452 media_info_s *_media = (media_info_s*)media;
1453 if (_media && added_time) {
1454 *added_time = _media->added_time;
1455 ret = MEDIA_CONTENT_ERROR_NONE;
1457 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1458 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1464 int media_info_get_modified_time(media_info_h media, time_t* time)
1466 int ret = MEDIA_CONTENT_ERROR_NONE;
1467 media_info_s *_media = (media_info_s*)media;
1468 if (_media && time) {
1469 *time = _media->modified_time;
1470 ret = MEDIA_CONTENT_ERROR_NONE;
1472 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1473 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1479 int media_info_get_timeline(media_info_h media, time_t* time)
1481 int ret = MEDIA_CONTENT_ERROR_NONE;
1482 media_info_s *_media = (media_info_s*)media;
1483 if (_media && time) {
1484 *time = _media->timeline;
1485 ret = MEDIA_CONTENT_ERROR_NONE;
1487 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1488 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1494 int media_info_get_thumbnail_path(media_info_h media, char **path)
1496 int ret = MEDIA_CONTENT_ERROR_NONE;
1497 media_info_s *_media = (media_info_s*)media;
1498 if (_media && path) {
1499 if (_media->thumbnail_path != NULL) {
1500 *path = g_strdup(_media->thumbnail_path);
1501 media_content_retvm_if(*path == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
1505 ret = MEDIA_CONTENT_ERROR_NONE;
1508 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1509 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1515 int media_info_get_title(media_info_h media, char **title)
1517 int ret = MEDIA_CONTENT_ERROR_NONE;
1518 media_info_s *_media = (media_info_s*)media;
1520 if (_media && title) { /*title can be empty string*/
1521 if (_media->title != NULL) {
1522 *title = g_strdup(_media->title);
1523 media_content_retvm_if(*title == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
1527 ret = MEDIA_CONTENT_ERROR_NONE;
1529 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1530 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1536 int media_info_get_description(media_info_h media, char **description)
1538 int ret = MEDIA_CONTENT_ERROR_NONE;
1539 media_info_s *_media = (media_info_s*)media;
1541 if (_media && description) {
1542 if (_media->description != NULL) { /*description can be empty string*/
1543 *description = g_strdup(_media->description);
1544 media_content_retvm_if(*description == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
1546 *description = NULL;
1548 ret = MEDIA_CONTENT_ERROR_NONE;
1550 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1551 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1557 int media_info_get_longitude(media_info_h media, double* longitude)
1559 int ret = MEDIA_CONTENT_ERROR_NONE;
1560 media_info_s *_media = (media_info_s*)media;
1562 if (_media && longitude) {
1563 *longitude = _media->longitude;
1564 ret = MEDIA_CONTENT_ERROR_NONE;
1566 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1567 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1572 int media_info_get_latitude(media_info_h media, double* latitude)
1574 int ret = MEDIA_CONTENT_ERROR_NONE;
1575 media_info_s *_media = (media_info_s*)media;
1577 if (_media && latitude) {
1578 *latitude = _media->latitude;
1579 ret = MEDIA_CONTENT_ERROR_NONE;
1581 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1582 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1588 int media_info_get_altitude(media_info_h media, double *altitude)
1590 int ret = MEDIA_CONTENT_ERROR_NONE;
1591 media_info_s *_media = (media_info_s*)media;
1593 if (_media && altitude) {
1594 *altitude = _media->altitude;
1595 ret = MEDIA_CONTENT_ERROR_NONE;
1597 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1598 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1604 int media_info_get_weather(media_info_h media, char **weather)
1606 int ret = MEDIA_CONTENT_ERROR_NONE;
1607 media_info_s *_media = (media_info_s*)media;
1609 if (_media && weather) {
1610 if (_media->weather != NULL) {
1611 *weather = strdup(_media->weather);
1612 media_content_retvm_if(*weather == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
1616 ret = MEDIA_CONTENT_ERROR_NONE;
1618 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1619 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1625 int media_info_get_rating(media_info_h media, int *rating)
1627 int ret = MEDIA_CONTENT_ERROR_NONE;
1628 media_info_s *_media = (media_info_s*)media;
1630 if (_media && rating) {
1631 *rating = _media->rating;
1632 ret = MEDIA_CONTENT_ERROR_NONE;
1634 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1635 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1641 int media_info_get_favorite(media_info_h media, bool* favorite)
1643 int ret = MEDIA_CONTENT_ERROR_NONE;
1644 media_info_s *_media = (media_info_s*)media;
1646 if (_media && favorite) {
1647 *favorite = _media->favourite;
1648 ret = MEDIA_CONTENT_ERROR_NONE;
1650 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1651 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1657 int media_info_get_author(media_info_h media, char **author)
1659 int ret = MEDIA_CONTENT_ERROR_NONE;
1660 media_info_s *_media = (media_info_s*)media;
1662 if (_media && author) {
1663 if (_media->author != NULL) {
1664 *author = strdup(_media->author);
1665 media_content_retvm_if(*author == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
1669 ret = MEDIA_CONTENT_ERROR_NONE;
1671 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1672 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1678 int media_info_get_provider(media_info_h media, char **provider)
1680 int ret = MEDIA_CONTENT_ERROR_NONE;
1681 media_info_s *_media = (media_info_s*)media;
1683 if (_media && provider) {
1684 if (_media->provider != NULL) {
1685 *provider = strdup(_media->provider);
1686 media_content_retvm_if(*provider == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
1690 ret = MEDIA_CONTENT_ERROR_NONE;
1692 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1693 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1699 int media_info_get_content_name(media_info_h media, char **content_name)
1701 int ret = MEDIA_CONTENT_ERROR_NONE;
1702 media_info_s *_media = (media_info_s*)media;
1704 if (_media && content_name) {
1705 if (_media->content_name != NULL) {
1706 *content_name = strdup(_media->content_name);
1707 media_content_retvm_if(*content_name == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
1709 *content_name = NULL;
1711 ret = MEDIA_CONTENT_ERROR_NONE;
1713 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1714 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1720 int media_info_get_category(media_info_h media, char **category)
1722 int ret = MEDIA_CONTENT_ERROR_NONE;
1723 media_info_s *_media = (media_info_s*)media;
1725 if (_media && category) {
1726 if (_media->category != NULL) {
1727 *category = strdup(_media->category);
1728 media_content_retvm_if(*category == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
1732 ret = MEDIA_CONTENT_ERROR_NONE;
1734 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1735 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1741 int media_info_get_location_tag(media_info_h media, char **location_tag)
1743 int ret = MEDIA_CONTENT_ERROR_NONE;
1744 media_info_s *_media = (media_info_s*)media;
1746 if (_media && location_tag) {
1747 if (_media->location_tag != NULL) {
1748 *location_tag = strdup(_media->location_tag);
1749 media_content_retvm_if(*location_tag == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
1751 *location_tag = NULL;
1753 ret = MEDIA_CONTENT_ERROR_NONE;
1755 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1756 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1762 int media_info_get_age_rating(media_info_h media, char **age_rating)
1764 int ret = MEDIA_CONTENT_ERROR_NONE;
1765 media_info_s *_media = (media_info_s*)media;
1767 if (_media && age_rating) {
1768 if (_media->age_rating != NULL) {
1769 *age_rating = strdup(_media->age_rating);
1770 media_content_retvm_if(*age_rating == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
1774 ret = MEDIA_CONTENT_ERROR_NONE;
1776 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1777 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1783 int media_info_get_keyword(media_info_h media, char **keyword)
1785 int ret = MEDIA_CONTENT_ERROR_NONE;
1786 media_info_s *_media = (media_info_s*)media;
1788 if (_media && keyword) {
1789 if (_media->keyword != NULL) {
1790 *keyword = strdup(_media->keyword);
1791 media_content_retvm_if(*keyword == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
1795 ret = MEDIA_CONTENT_ERROR_NONE;
1797 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1798 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1804 int media_info_get_storage_id(media_info_h media, char **storage_id)
1806 int ret = MEDIA_CONTENT_ERROR_NONE;
1807 media_info_s *_media = (media_info_s*)media;
1809 if (_media && storage_id) {
1810 if (STRING_VALID(_media->storage_uuid)) {
1811 *storage_id = strdup(_media->storage_uuid);
1812 media_content_retvm_if(*storage_id == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
1815 ret = MEDIA_CONTENT_ERROR_DB_FAILED;
1817 ret = MEDIA_CONTENT_ERROR_NONE;
1819 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1820 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1826 int media_info_is_drm(media_info_h media, bool *is_drm)
1828 int ret = MEDIA_CONTENT_ERROR_NONE;
1829 media_info_s *_media = (media_info_s*)media;
1832 *is_drm = _media->is_drm;
1833 ret = MEDIA_CONTENT_ERROR_NONE;
1835 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1836 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1842 int media_info_is_360_content(media_info_h media, bool *is_360)
1844 int ret = MEDIA_CONTENT_ERROR_NONE;
1845 media_info_s *_media = (media_info_s*)media;
1848 *is_360 = _media->is_360;
1849 ret = MEDIA_CONTENT_ERROR_NONE;
1851 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1852 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1858 int media_info_get_storage_type(media_info_h media, media_content_storage_e *storage_type)
1860 int ret = MEDIA_CONTENT_ERROR_NONE;
1861 media_info_s *_media = (media_info_s*)media;
1863 if (_media && storage_type) {
1864 *storage_type = _media->storage_type;
1865 ret = MEDIA_CONTENT_ERROR_NONE;
1867 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1868 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1874 int media_info_get_played_count(media_info_h media, int *played_count)
1876 int ret = MEDIA_CONTENT_ERROR_NONE;
1877 media_info_s *_media = (media_info_s*)media;
1880 *played_count = _media->played_count;
1881 ret = MEDIA_CONTENT_ERROR_NONE;
1883 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1884 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1890 int media_info_get_played_time(media_info_h media, time_t* played_time)
1892 int ret = MEDIA_CONTENT_ERROR_NONE;
1893 media_info_s *_media = (media_info_s*)media;
1896 *played_time = _media->played_time;
1897 ret = MEDIA_CONTENT_ERROR_NONE;
1899 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1900 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1906 int media_info_increase_played_count(media_info_h media)
1908 int ret = MEDIA_CONTENT_ERROR_NONE;
1910 media_info_s *_media = (media_info_s*)media;
1913 _media->played_count += 1;
1915 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1916 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1922 int media_info_set_played_time(media_info_h media)
1924 int ret = MEDIA_CONTENT_ERROR_NONE;
1925 time_t current_time;
1927 media_info_s *_media = (media_info_s*)media;
1929 if (_media != NULL) {
1930 time(¤t_time);
1931 _media->played_time = current_time;
1933 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1934 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1940 int media_info_get_media_from_db(const char *media_id, media_info_h *media)
1942 int ret = MEDIA_CONTENT_ERROR_NONE;
1943 char select_query[DEFAULT_QUERY_SIZE];
1944 char storage_id[MEDIA_CONTENT_UUID_SIZE+1] = {0, };
1945 sqlite3_stmt *stmt = NULL;
1947 if (!STRING_VALID(media_id) || (media == NULL)) {
1948 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1949 return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1952 memset(select_query, 0x00, sizeof(select_query));
1953 memset(storage_id, 0x00, sizeof(storage_id));
1955 ret = _media_db_get_storage_id_by_media_id(media_id, storage_id);
1956 media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
1958 snprintf(select_query, sizeof(select_query), SELECT_MEDIA_FROM_MEDIA, storage_id, media_id);
1960 ret = _content_query_prepare(&stmt, select_query, NULL, NULL);
1961 media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
1963 media_info_s *_media = NULL;
1965 while (sqlite3_step(stmt) == SQLITE_ROW) {
1967 media_info_destroy((media_info_h)_media);
1969 _media = (media_info_s*)calloc(1, sizeof(media_info_s));
1971 if (_media == NULL) {
1972 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
1973 SQLITE3_FINALIZE(stmt);
1974 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
1977 _media_info_item_get_detail(stmt, (media_info_h)_media);
1979 *media = (media_info_h)_media;
1982 SQLITE3_FINALIZE(stmt);
1987 int media_info_set_display_name(media_info_h media, const char *display_name)
1989 int ret = MEDIA_CONTENT_ERROR_NONE;
1990 media_info_s *_media = (media_info_s*)media;
1992 if (_media != NULL && STRING_VALID(display_name)) {
1993 SAFE_FREE(_media->display_name);
1995 _media->display_name = strdup(display_name);
1996 media_content_retvm_if(_media->display_name == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
1998 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1999 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
2005 int media_info_set_description(media_info_h media, const char *description)
2007 int ret = MEDIA_CONTENT_ERROR_NONE;
2008 media_info_s *_media = (media_info_s*)media;
2010 if (_media != NULL) {
2011 SAFE_FREE(_media->description);
2013 if (STRING_VALID(description)) {
2014 _media->description = strdup(description);
2015 media_content_retvm_if(_media->description == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
2017 _media->description = NULL;
2020 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
2021 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
2027 int media_info_set_longitude(media_info_h media, double longitude)
2029 int ret = MEDIA_CONTENT_ERROR_NONE;
2030 media_info_s *_media = (media_info_s*)media;
2032 if (_media != NULL) {
2033 _media->longitude = longitude;
2035 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
2036 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
2042 int media_info_set_latitude(media_info_h media, double latitude)
2044 int ret = MEDIA_CONTENT_ERROR_NONE;
2045 media_info_s *_media = (media_info_s*)media;
2047 if (_media != NULL) {
2048 _media->latitude = latitude;
2050 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
2051 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
2057 int media_info_set_altitude(media_info_h media, double altitude)
2059 int ret = MEDIA_CONTENT_ERROR_NONE;
2060 media_info_s *_media = (media_info_s*)media;
2062 if (_media != NULL) {
2063 _media->altitude = altitude;
2065 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
2066 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
2072 int media_info_set_weather(media_info_h media, const char *weather)
2074 int ret = MEDIA_CONTENT_ERROR_NONE;
2075 media_info_s *_media = (media_info_s*)media;
2077 if (_media != NULL) {
2078 SAFE_FREE(_media->weather);
2080 if (STRING_VALID(weather)) {
2081 _media->weather = strdup(weather);
2082 media_content_retvm_if(_media->weather == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
2084 _media->weather = NULL;
2087 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
2088 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
2094 int media_info_set_rating(media_info_h media, int rating)
2096 int ret = MEDIA_CONTENT_ERROR_NONE;
2097 media_info_s *_media = (media_info_s*)media;
2099 if (_media != NULL) {
2100 _media->rating = rating;
2102 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
2103 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
2109 int media_info_set_added_time(media_info_h media, time_t added_time)
2111 int ret = MEDIA_CONTENT_ERROR_NONE;
2113 media_info_s *_media = (media_info_s*)media;
2115 if ((_media != NULL) && (added_time >= 0)) {
2116 _media->added_time = added_time;
2118 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
2119 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
2125 int media_info_set_favorite(media_info_h media, bool favorite)
2127 int ret = MEDIA_CONTENT_ERROR_NONE;
2128 media_info_s *_media = (media_info_s*)media;
2130 if (_media != NULL) {
2131 if (favorite == TRUE)
2132 time(&_media->favourite);
2134 _media->favourite = 0;
2136 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
2137 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
2143 int media_info_set_author(media_info_h media, const char *author)
2145 int ret = MEDIA_CONTENT_ERROR_NONE;
2146 media_info_s *_media = (media_info_s*)media;
2148 if (_media != NULL) {
2149 if (STRING_VALID(author)) {
2150 _media->author = strdup(author);
2151 media_content_retvm_if(_media->author == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
2153 _media->author = NULL;
2156 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
2157 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
2163 int media_info_set_provider(media_info_h media, const char *provider)
2165 int ret = MEDIA_CONTENT_ERROR_NONE;
2166 media_info_s *_media = (media_info_s*)media;
2168 if (_media != NULL) {
2169 SAFE_FREE(_media->provider);
2171 if (STRING_VALID(provider)) {
2172 _media->provider = strdup(provider);
2173 media_content_retvm_if(_media->provider == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
2175 _media->provider = NULL;
2178 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
2179 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
2185 int media_info_set_content_name(media_info_h media, const char *content_name)
2187 int ret = MEDIA_CONTENT_ERROR_NONE;
2188 media_info_s *_media = (media_info_s*)media;
2190 if (_media != NULL) {
2191 SAFE_FREE(_media->content_name);
2193 if (STRING_VALID(content_name)) {
2194 _media->content_name = strdup(content_name);
2195 media_content_retvm_if(_media->content_name == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
2197 _media->content_name = NULL;
2200 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
2201 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
2207 int media_info_set_category(media_info_h media, const char *category)
2209 int ret = MEDIA_CONTENT_ERROR_NONE;
2210 media_info_s *_media = (media_info_s*)media;
2212 if (_media != NULL) {
2213 SAFE_FREE(_media->category);
2215 if (STRING_VALID(category)) {
2216 _media->category = strdup(category);
2217 media_content_retvm_if(_media->category == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
2219 _media->category = NULL;
2222 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
2223 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
2229 int media_info_set_location_tag(media_info_h media, const char *location_tag)
2231 int ret = MEDIA_CONTENT_ERROR_NONE;
2232 media_info_s *_media = (media_info_s*)media;
2234 if (_media != NULL) {
2235 SAFE_FREE(_media->location_tag);
2237 if (STRING_VALID(location_tag)) {
2238 _media->location_tag = strdup(location_tag);
2239 media_content_retvm_if(_media->location_tag == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
2241 _media->location_tag = NULL;
2244 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
2245 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
2251 int media_info_set_age_rating(media_info_h media, const char *age_rating)
2253 int ret = MEDIA_CONTENT_ERROR_NONE;
2254 media_info_s *_media = (media_info_s*)media;
2256 if (_media != NULL) {
2257 SAFE_FREE(_media->age_rating);
2259 if (STRING_VALID(age_rating)) {
2260 _media->age_rating = strdup(age_rating);
2261 media_content_retvm_if(_media->age_rating == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
2263 _media->age_rating = NULL;
2266 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
2267 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
2273 int media_info_set_keyword(media_info_h media, const char *keyword)
2275 int ret = MEDIA_CONTENT_ERROR_NONE;
2276 media_info_s *_media = (media_info_s*)media;
2278 if (_media != NULL) {
2279 SAFE_FREE(_media->keyword);
2281 if (STRING_VALID(keyword)) {
2282 _media->keyword = strdup(keyword);
2283 media_content_retvm_if(_media->keyword == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
2285 _media->keyword = NULL;
2288 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
2289 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
2295 int media_info_update_to_db(media_info_h media)
2297 int ret = MEDIA_CONTENT_ERROR_NONE;
2298 media_info_s *_media = (media_info_s*)media;
2299 char *set_sql = NULL;
2302 if (_media != NULL && STRING_VALID(_media->media_id)) {
2303 /* This sql is due to sqlite3_mprintf's wrong operation when using floating point in the text format */
2304 /* This code will be removed when sqlite3_mprintf works clearly */
2305 char *test_sql = sqlite3_mprintf("%f, %f, %f", _media->longitude, _media->latitude, _media->altitude);
2306 SQLITE3_SAFE_FREE(test_sql);
2308 /*Update Pinyin If Support Pinyin*/
2309 char *file_name_pinyin = NULL;
2310 char *description_pinyin = NULL;
2311 char *author_pinyin = NULL;
2312 char *provider_pinyin = NULL;
2313 char *content_name_pinyin = NULL;
2314 char *category_pinyin = NULL;
2315 char *location_tag_pinyin = NULL;
2316 char *age_rating_pinyin = NULL;
2317 char *keyword_pinyin = NULL;
2318 bool pinyin_support = FALSE;
2320 /*Update Pinyin If Support Pinyin*/
2321 media_svc_check_pinyin_support(&pinyin_support);
2322 if (pinyin_support) {
2323 if (STRING_VALID(_media->display_name))
2324 media_svc_get_pinyin(_media->display_name, &file_name_pinyin);
2325 if (STRING_VALID(_media->description))
2326 media_svc_get_pinyin(_media->description, &description_pinyin);
2327 if (STRING_VALID(_media->author))
2328 media_svc_get_pinyin(_media->author, &author_pinyin);
2329 if (STRING_VALID(_media->provider))
2330 media_svc_get_pinyin(_media->provider, &provider_pinyin);
2331 if (STRING_VALID(_media->content_name))
2332 media_svc_get_pinyin(_media->content_name, &content_name_pinyin);
2333 if (STRING_VALID(_media->category))
2334 media_svc_get_pinyin(_media->category, &category_pinyin);
2335 if (STRING_VALID(_media->location_tag))
2336 media_svc_get_pinyin(_media->location_tag, &location_tag_pinyin);
2337 if (STRING_VALID(_media->age_rating))
2338 media_svc_get_pinyin(_media->age_rating, &age_rating_pinyin);
2339 if (STRING_VALID(_media->keyword))
2340 media_svc_get_pinyin(_media->keyword, &keyword_pinyin);
2344 char *artist = NULL;
2346 char *recorded_date = NULL;
2348 if (_media->media_type == MEDIA_CONTENT_TYPE_VIDEO) {
2349 if (_media->video_meta->album != NULL)
2350 album = strdup(_media->video_meta->album);
2351 if (_media->video_meta->artist != NULL)
2352 artist = strdup(_media->video_meta->artist);
2353 if (_media->video_meta->genre != NULL)
2354 genre = strdup(_media->video_meta->genre);
2355 if (_media->video_meta->recorded_date != NULL)
2356 recorded_date = strdup(_media->video_meta->recorded_date);
2357 } else if ((_media->media_type == MEDIA_CONTENT_TYPE_MUSIC) || (_media->media_type == MEDIA_CONTENT_TYPE_SOUND)) {
2358 if (_media->audio_meta->album != NULL)
2359 album = strdup(_media->audio_meta->album);
2360 if (_media->audio_meta->artist != NULL)
2361 artist = strdup(_media->audio_meta->artist);
2362 if (_media->audio_meta->genre != NULL)
2363 genre = strdup(_media->audio_meta->genre);
2364 if (_media->audio_meta->recorded_date != NULL)
2365 recorded_date = strdup(_media->audio_meta->recorded_date);
2368 set_sql = sqlite3_mprintf("file_name=%Q, added_time=%d, description=%Q, longitude=%f, latitude=%f, altitude=%f, \
2369 played_count=%d, last_played_time=%d, last_played_position=%d, \
2370 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, \
2371 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, \
2372 album=%Q, artist=%Q, genre=%Q, recorded_date=%Q",
2373 _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,
2374 _media->author, _media->provider, _media->content_name, _media->category, _media->location_tag, _media->age_rating, _media->keyword, _media->weather, _media->sync_status,
2375 file_name_pinyin, description_pinyin, author_pinyin, provider_pinyin, content_name_pinyin, category_pinyin, location_tag_pinyin, age_rating_pinyin, keyword_pinyin, _media->title,
2376 album, artist, genre, recorded_date);
2378 sql = sqlite3_mprintf("UPDATE %Q SET %s WHERE media_uuid=%Q", _media->storage_uuid, set_sql, _media->media_id);
2380 ret = _content_query_sql(sql);
2381 SQLITE3_SAFE_FREE(set_sql);
2382 SQLITE3_SAFE_FREE(sql);
2384 SAFE_FREE(description_pinyin);
2385 SAFE_FREE(author_pinyin);
2386 SAFE_FREE(provider_pinyin);
2387 SAFE_FREE(content_name_pinyin);
2388 SAFE_FREE(category_pinyin);
2389 SAFE_FREE(location_tag_pinyin);
2390 SAFE_FREE(age_rating_pinyin);
2391 SAFE_FREE(keyword_pinyin);
2396 SAFE_FREE(recorded_date);
2398 if (_media->storage_type == MEDIA_CONTENT_STORAGE_CLOUD) {
2402 if (_media->media_type == MEDIA_CONTENT_TYPE_VIDEO) {
2403 set_sql = sqlite3_mprintf("title=%Q, album=%Q, artist=%Q, genre=%Q, duration=%d, width=%d, height=%d", \
2404 _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);
2405 } else if ((_media->media_type == MEDIA_CONTENT_TYPE_MUSIC) || (_media->media_type == MEDIA_CONTENT_TYPE_SOUND)) {
2406 set_sql = sqlite3_mprintf("title=%Q, album=%Q, artist=%Q, genre=%Q, duration=%d", \
2407 _media->title, _media->audio_meta->album, _media->audio_meta->artist, _media->audio_meta->genre, _media->audio_meta->duration);
2408 } else if (_media->media_type == MEDIA_CONTENT_TYPE_IMAGE) {
2409 set_sql = sqlite3_mprintf("title=%Q, width=%d, height=%d", _media->title, _media->image_meta->width, _media->image_meta->height);
2411 set_sql = sqlite3_mprintf("title=%Q", _media->title);
2414 sql = sqlite3_mprintf("UPDATE %Q SET %s WHERE media_uuid=%Q", _media->storage_uuid, set_sql, _media->media_id);
2416 ret = _content_query_sql(sql);
2418 SQLITE3_SAFE_FREE(set_sql);
2419 SQLITE3_SAFE_FREE(sql);
2422 if (ret == MEDIA_CONTENT_ERROR_NONE) {
2423 /* Send notification for this update */
2424 media_content_debug("Update is successfull. Send notification for this");
2425 if (_media->file_path && _media->mime_type)
2426 media_svc_publish_noti(MS_MEDIA_ITEM_FILE, MS_MEDIA_ITEM_UPDATE, _media->file_path, _media->media_type, _media->media_id, _media->mime_type);
2428 media_content_error("Can't Send Noti : path or mime type is NULL");
2431 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
2432 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
2438 int media_info_refresh_metadata_to_db(const char *media_id)
2440 int ret = MEDIA_CONTENT_ERROR_NONE;
2441 media_info_h media = NULL;
2442 char *file_path = NULL;
2443 media_content_storage_e storage_type = 0;
2444 char storage_id[MEDIA_CONTENT_UUID_SIZE+1] = {0, };
2446 if (!STRING_VALID(media_id)) {
2447 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
2448 return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
2451 ret = media_info_get_media_from_db(media_id, &media);
2452 if (ret != MEDIA_CONTENT_ERROR_NONE) {
2453 media_info_destroy(media);
2457 ret = media_info_get_storage_type(media, &storage_type);
2458 if (ret != MEDIA_CONTENT_ERROR_NONE) {
2459 media_info_destroy(media);
2463 if (storage_type == MEDIA_CONTENT_STORAGE_CLOUD) {
2464 media_info_destroy(media);
2465 media_content_error("Can't refresh cloud content!!");
2466 return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
2469 ret = media_info_get_file_path(media, &file_path);
2470 if (ret != MEDIA_CONTENT_ERROR_NONE) {
2471 media_info_destroy(media);
2475 ret = _media_util_check_file_exist(file_path);
2476 if (ret != MEDIA_CONTENT_ERROR_NONE) {
2477 SAFE_FREE(file_path);
2478 media_info_destroy(media);
2482 memset(storage_id, 0x00, sizeof(storage_id));
2483 ret = media_svc_get_storage_id(_content_get_db_handle(), file_path, storage_id);
2484 if (ret != MS_MEDIA_ERR_NONE) {
2485 media_content_error("media_svc_get_storage_id failed : %d", ret);
2486 SAFE_FREE(file_path);
2487 media_info_destroy(media);
2488 return _content_error_capi(MEDIA_CONTENT_TYPE, ret);
2491 ret = media_svc_refresh_item(_content_get_db_handle(), storage_id, storage_type, file_path, tzplatform_getuid(TZ_USER_NAME));
2492 if (ret != MS_MEDIA_ERR_NONE)
2493 ret = _content_error_capi(MEDIA_CONTENT_TYPE, ret);
2495 SAFE_FREE(file_path);
2496 media_info_destroy(media);
2501 int media_info_move_to_db(media_info_h media, const char* dst_path)
2503 int ret = MEDIA_CONTENT_ERROR_NONE;
2504 bool ignore_file = FALSE;
2505 bool ignore_dir = FALSE;
2506 char *folder_path = NULL;
2507 media_svc_storage_type_e src_storage_type = 0;
2508 media_svc_storage_type_e dst_storage_type = 0;
2509 char storage_id[MEDIA_CONTENT_UUID_SIZE+1] = {0, };
2511 media_content_retvm_if(media == NULL, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "invalid media");
2512 media_content_retvm_if(!STRING_VALID(dst_path), MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "invalid dst_path");
2514 media_info_s *_media = (media_info_s*)media;
2516 ret = _media_util_check_ignore_file(dst_path, &ignore_file);
2517 media_content_retvm_if(ignore_file == TRUE, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid path");
2519 ret = _media_util_check_file_exist(dst_path);
2520 media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
2522 folder_path = g_path_get_dirname(dst_path);
2523 ret = _media_util_check_ignore_dir(folder_path, &ignore_dir);
2524 SAFE_FREE(folder_path);
2526 media_content_retvm_if(ignore_dir == TRUE, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid folder path");
2528 ret = media_svc_get_storage_type(_media->file_path, &src_storage_type, tzplatform_getuid(TZ_USER_NAME));
2529 if (ret != MS_MEDIA_ERR_NONE) {
2530 media_content_sec_error("media_svc_get_storage_type failed : %d", ret);
2531 return _content_error_capi(MEDIA_CONTENT_TYPE, ret);
2534 ret = media_svc_get_storage_type(dst_path, &dst_storage_type, tzplatform_getuid(TZ_USER_NAME));
2535 if (ret != MS_MEDIA_ERR_NONE) {
2536 media_content_sec_error("media_svc_get_storage_type failed : %d", ret);
2537 return _content_error_capi(MEDIA_CONTENT_TYPE, ret);
2540 memset(storage_id, 0x00, sizeof(storage_id));
2541 ret = media_svc_get_storage_id(_content_get_db_handle(), _media->file_path, storage_id);
2542 if (ret != MS_MEDIA_ERR_NONE) {
2543 media_content_error("media_svc_get_storage_id failed : %d", ret);
2544 return _content_error_capi(MEDIA_CONTENT_TYPE, ret);
2547 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));
2548 return _content_error_capi(MEDIA_CONTENT_TYPE, ret);
2551 int media_info_create_thumbnail(media_info_h media, media_thumbnail_completed_cb callback, void *user_data)
2553 int ret = MEDIA_CONTENT_ERROR_NONE;
2554 static unsigned int req_id = 0;
2555 media_info_s *_media = (media_info_s*)media;
2557 if (_media != NULL && STRING_VALID(_media->media_id) && STRING_VALID(_media->file_path)) {
2558 media_thumbnail_cb_s *_thumb_cb = (media_thumbnail_cb_s*)calloc(1, sizeof(media_thumbnail_cb_s));
2559 media_content_retvm_if(_thumb_cb == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
2561 _media->request_id = req_id;
2563 _thumb_cb->handle = _media;
2564 _thumb_cb->user_data = user_data;
2565 _thumb_cb->thumbnail_completed_cb = callback;
2567 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));
2568 ret = _content_error_capi(MEDIA_THUMBNAIL_TYPE, ret);
2570 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
2571 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
2577 int media_info_cancel_thumbnail(media_info_h media)
2579 int ret = MEDIA_CONTENT_ERROR_NONE;
2580 media_info_s *_media = (media_info_s*)media;
2582 if (_media != NULL && STRING_VALID(_media->media_id) && STRING_VALID(_media->file_path) && _media->request_id > 0) {
2583 ret = thumbnail_request_cancel_media(_media->request_id, _media->file_path);
2584 ret = _content_error_capi(MEDIA_THUMBNAIL_TYPE, ret);
2586 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
2587 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
2593 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)
2595 media_content_retvm_if(media == NULL, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid handle");
2597 media_svc_content_info_s *svc_content_info = calloc(1, sizeof(media_svc_content_info_s));
2598 media_content_retvm_if(svc_content_info == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
2600 svc_content_info->path = g_strdup(media->file_path);
2601 svc_content_info->file_name = g_strdup(media->display_name);
2602 svc_content_info->media_type = media->media_type;
2603 svc_content_info->mime_type = g_strdup(media->mime_type);
2604 svc_content_info->size = media->size;
2605 svc_content_info->storage_type = storage_type;
2606 svc_content_info->storage_uuid = g_strdup(media->storage_uuid);
2608 svc_content_info->added_time = media->added_time;
2609 svc_content_info->modified_time = media->modified_time;
2610 svc_content_info->thumbnail_path = g_strdup(media->thumbnail_path);
2611 svc_content_info->is_drm = media->is_drm;
2612 svc_content_info->last_played_time = media->played_time;
2613 svc_content_info->played_count = media->played_count;
2614 svc_content_info->favourate = media->favourite;
2616 svc_content_info->media_meta.title = g_strdup(media->title);
2617 svc_content_info->media_meta.rating = media->rating;
2618 svc_content_info->media_meta.description = g_strdup(media->description);
2619 svc_content_info->media_meta.longitude = media->longitude;
2620 svc_content_info->media_meta.latitude = media->latitude;
2621 svc_content_info->media_meta.altitude = media->altitude;
2622 svc_content_info->media_meta.weather = g_strdup(media->weather);
2623 svc_content_info->media_meta.category = g_strdup(media->category);
2624 svc_content_info->media_meta.keyword = g_strdup(media->keyword);
2625 svc_content_info->media_meta.location_tag = g_strdup(media->location_tag);
2626 svc_content_info->media_meta.content_name = g_strdup(media->content_name);
2627 svc_content_info->media_meta.age_rating = g_strdup(media->age_rating);
2628 svc_content_info->media_meta.author = g_strdup(media->author);
2629 svc_content_info->media_meta.provider = g_strdup(media->provider);
2631 svc_content_info->media_meta.album = g_strdup(media->audio_meta->album);
2632 svc_content_info->media_meta.artist = g_strdup(media->audio_meta->artist);
2633 svc_content_info->media_meta.genre = g_strdup(media->audio_meta->genre);
2634 svc_content_info->media_meta.recorded_date = g_strdup(media->audio_meta->recorded_date);
2636 if (storage_type == MEDIA_CONTENT_STORAGE_CLOUD) {
2637 switch (media->media_type) {
2638 case MEDIA_CONTENT_TYPE_IMAGE:
2639 svc_content_info->media_meta.width = media->image_meta->width;
2640 svc_content_info->media_meta.height = media->image_meta->height;
2641 svc_content_info->media_meta.datetaken = g_strdup(media->image_meta->date_taken);
2642 svc_content_info->media_meta.orientation = media->image_meta->orientation;
2644 case MEDIA_CONTENT_TYPE_VIDEO:
2645 svc_content_info->media_meta.album_artist = g_strdup(media->audio_meta->album_artist);
2646 svc_content_info->media_meta.composer = g_strdup(media->audio_meta->composer);
2647 svc_content_info->media_meta.year = g_strdup(media->audio_meta->year);
2648 svc_content_info->media_meta.copyright = g_strdup(media->audio_meta->copyright);
2649 svc_content_info->media_meta.track_num = g_strdup(media->audio_meta->track_num);
2650 svc_content_info->media_meta.bitrate = media->audio_meta->bitrate;
2651 svc_content_info->media_meta.duration = media->audio_meta->duration;
2652 svc_content_info->media_meta.width = media->image_meta->width;
2653 svc_content_info->media_meta.height = media->image_meta->height;
2655 case MEDIA_CONTENT_TYPE_SOUND:
2656 case MEDIA_CONTENT_TYPE_MUSIC:
2657 svc_content_info->media_meta.album_artist = g_strdup(media->audio_meta->album_artist);
2658 svc_content_info->media_meta.composer = g_strdup(media->audio_meta->composer);
2659 svc_content_info->media_meta.year = g_strdup(media->audio_meta->year);
2660 svc_content_info->media_meta.copyright = g_strdup(media->audio_meta->copyright);
2661 svc_content_info->media_meta.track_num = g_strdup(media->audio_meta->track_num);
2662 svc_content_info->media_meta.bitrate = media->audio_meta->bitrate;
2663 svc_content_info->media_meta.duration = media->audio_meta->duration;
2664 svc_content_info->media_meta.channel = media->audio_meta->channel;
2665 svc_content_info->media_meta.samplerate = media->audio_meta->samplerate;
2667 case MEDIA_CONTENT_TYPE_OTHERS:
2673 *service_content = svc_content_info;
2675 return MEDIA_CONTENT_ERROR_NONE;
2678 static int __media_info_set_str_data(media_info_h media, media_info_item_e data_type, const char *str_data)
2680 media_info_s *_media = (media_info_s*)media;
2682 media_content_retvm_if(_media == NULL, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid media");
2684 switch (data_type) {
2685 case MEDIA_INFO_PATH:
2686 SAFE_FREE(_media->file_path);
2687 if (STRING_VALID(str_data)) {
2688 _media->file_path = strdup(str_data);
2689 media_content_retvm_if(_media->file_path == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
2691 _media->file_path = NULL;
2694 case MEDIA_INFO_MIME_TYPE:
2695 SAFE_FREE(_media->mime_type);
2696 if (STRING_VALID(str_data)) {
2697 _media->mime_type = strdup(str_data);
2698 media_content_retvm_if(_media->mime_type == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
2700 _media->mime_type = NULL;
2703 case MEDIA_INFO_THUMBNAIL_PATH:
2704 SAFE_FREE(_media->thumbnail_path);
2705 if (STRING_VALID(str_data)) {
2706 _media->thumbnail_path = strdup(str_data);
2707 media_content_retvm_if(_media->thumbnail_path == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
2709 _media->thumbnail_path = NULL;
2712 case MEDIA_INFO_TITLE:
2713 SAFE_FREE(_media->title);
2714 if (STRING_VALID(str_data)) {
2715 _media->title = strdup(str_data);
2716 media_content_retvm_if(_media->title == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
2718 _media->title = NULL;
2721 case MEDIA_INFO_STORAGE_UUID:
2722 SAFE_FREE(_media->storage_uuid);
2723 if (STRING_VALID(str_data)) {
2724 _media->storage_uuid = strdup(str_data);
2725 media_content_retvm_if(_media->storage_uuid == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
2727 _media->storage_uuid = NULL;
2730 case MEDIA_INFO_ALBUM:
2731 if (STRING_VALID(_media->media_id)) {
2732 if (_media->media_type == MEDIA_CONTENT_TYPE_VIDEO) {
2733 SAFE_FREE(_media->video_meta->album);
2734 if (str_data != NULL) {
2735 _media->video_meta->album = strdup(str_data);
2736 media_content_retvm_if(_media->video_meta->album == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
2738 } else if ((_media->media_type == MEDIA_CONTENT_TYPE_MUSIC) || (_media->media_type == MEDIA_CONTENT_TYPE_SOUND)) {
2739 SAFE_FREE(_media->audio_meta->album);
2740 if (str_data != NULL) {
2741 _media->audio_meta->album = strdup(str_data);
2742 media_content_retvm_if(_media->audio_meta->album == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
2746 SAFE_FREE(_media->video_meta->album);
2747 if (str_data != NULL) {
2748 _media->video_meta->album = strdup(str_data);
2749 media_content_retvm_if(_media->video_meta->album == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
2752 SAFE_FREE(_media->audio_meta->album);
2753 if (str_data != NULL) {
2754 _media->audio_meta->album = strdup(str_data);
2755 media_content_retvm_if(_media->audio_meta->album == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
2759 case MEDIA_INFO_ARTIST:
2760 if (STRING_VALID(_media->media_id)) {
2761 if (_media->media_type == MEDIA_CONTENT_TYPE_VIDEO) {
2762 SAFE_FREE(_media->video_meta->artist);
2763 if (str_data != NULL) {
2764 _media->video_meta->artist = strdup(str_data);
2765 media_content_retvm_if(_media->video_meta->artist == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
2767 } else if ((_media->media_type == MEDIA_CONTENT_TYPE_MUSIC) || (_media->media_type == MEDIA_CONTENT_TYPE_SOUND)) {
2768 SAFE_FREE(_media->audio_meta->artist);
2769 if (str_data != NULL) {
2770 _media->audio_meta->artist = strdup(str_data);
2771 media_content_retvm_if(_media->audio_meta->artist == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
2775 SAFE_FREE(_media->video_meta->artist);
2776 if (str_data != NULL) {
2777 _media->video_meta->artist = strdup(str_data);
2778 media_content_retvm_if(_media->video_meta->artist == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
2781 SAFE_FREE(_media->audio_meta->artist);
2782 if (str_data != NULL) {
2783 _media->audio_meta->artist = strdup(str_data);
2784 media_content_retvm_if(_media->audio_meta->artist == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
2788 case MEDIA_INFO_GENRE:
2789 if (STRING_VALID(_media->media_id)) {
2790 if (_media->media_type == MEDIA_CONTENT_TYPE_VIDEO) {
2791 SAFE_FREE(_media->video_meta->genre);
2792 if (str_data != NULL) {
2793 _media->video_meta->genre = strdup(str_data);
2794 media_content_retvm_if(_media->video_meta->genre == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
2796 } else if ((_media->media_type == MEDIA_CONTENT_TYPE_MUSIC) || (_media->media_type == MEDIA_CONTENT_TYPE_SOUND)) {
2797 SAFE_FREE(_media->audio_meta->genre);
2798 if (str_data != NULL) {
2799 _media->audio_meta->genre = strdup(str_data);
2800 media_content_retvm_if(_media->audio_meta->genre == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
2804 SAFE_FREE(_media->video_meta->genre);
2805 if (str_data != NULL) {
2806 _media->video_meta->genre = strdup(str_data);
2807 media_content_retvm_if(_media->video_meta->genre == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
2810 SAFE_FREE(_media->audio_meta->genre);
2811 if (str_data != NULL) {
2812 _media->audio_meta->genre = strdup(str_data);
2813 media_content_retvm_if(_media->audio_meta->genre == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
2817 case MEDIA_INFO_RECORDED_DATE:
2818 if (STRING_VALID(_media->media_id)) {
2819 if (_media->media_type == MEDIA_CONTENT_TYPE_VIDEO) {
2820 SAFE_FREE(_media->video_meta->recorded_date);
2821 if (str_data != NULL) {
2822 _media->video_meta->recorded_date = strdup(str_data);
2823 media_content_retvm_if(_media->video_meta->recorded_date == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
2825 } else if ((_media->media_type == MEDIA_CONTENT_TYPE_MUSIC) || (_media->media_type == MEDIA_CONTENT_TYPE_SOUND)) {
2826 SAFE_FREE(_media->audio_meta->recorded_date);
2827 if (str_data != NULL) {
2828 _media->audio_meta->recorded_date = strdup(str_data);
2829 media_content_retvm_if(_media->audio_meta->recorded_date == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
2833 SAFE_FREE(_media->video_meta->recorded_date);
2834 if (str_data != NULL) {
2835 _media->video_meta->recorded_date = strdup(str_data);
2836 media_content_retvm_if(_media->video_meta->recorded_date == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
2839 SAFE_FREE(_media->audio_meta->recorded_date);
2840 if (str_data != NULL) {
2841 _media->audio_meta->recorded_date = strdup(str_data);
2842 media_content_retvm_if(_media->audio_meta->recorded_date == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
2847 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
2848 return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
2851 return MEDIA_CONTENT_ERROR_NONE;
2854 static int __media_info_destroy(media_info_h media)
2856 int ret = MEDIA_CONTENT_ERROR_NONE;
2857 media_info_s *_media = (media_info_s*)media;
2860 SAFE_FREE(_media->media_id);
2861 SAFE_FREE(_media->file_path);
2862 SAFE_FREE(_media->display_name);
2863 SAFE_FREE(_media->mime_type);
2864 SAFE_FREE(_media->thumbnail_path);
2865 SAFE_FREE(_media->description);
2866 SAFE_FREE(_media->author);
2867 SAFE_FREE(_media->provider);
2868 SAFE_FREE(_media->content_name);
2869 SAFE_FREE(_media->category);
2870 SAFE_FREE(_media->location_tag);
2871 SAFE_FREE(_media->age_rating);
2872 SAFE_FREE(_media->keyword);
2873 SAFE_FREE(_media->title);
2874 SAFE_FREE(_media->weather);
2875 SAFE_FREE(_media->storage_uuid);
2877 if (_media->image_meta) {
2878 SAFE_FREE(_media->image_meta->media_id);
2879 SAFE_FREE(_media->image_meta->date_taken);
2880 SAFE_FREE(_media->image_meta->burst_id);
2881 SAFE_FREE(_media->image_meta->exposure_time);
2882 SAFE_FREE(_media->image_meta->model);
2883 SAFE_FREE(_media->image_meta->title);
2884 SAFE_FREE(_media->image_meta->weather);
2886 SAFE_FREE(_media->image_meta);
2889 if (_media->video_meta) {
2890 SAFE_FREE(_media->video_meta->media_id);
2891 SAFE_FREE(_media->video_meta->title);
2892 SAFE_FREE(_media->video_meta->album);
2893 SAFE_FREE(_media->video_meta->artist);
2894 SAFE_FREE(_media->video_meta->album_artist);
2895 SAFE_FREE(_media->video_meta->genre);
2896 SAFE_FREE(_media->video_meta->composer);
2897 SAFE_FREE(_media->video_meta->year);
2898 SAFE_FREE(_media->video_meta->recorded_date);
2899 SAFE_FREE(_media->video_meta->copyright);
2900 SAFE_FREE(_media->video_meta->track_num);
2902 SAFE_FREE(_media->video_meta);
2905 if (_media->audio_meta) {
2906 SAFE_FREE(_media->audio_meta->media_id);
2907 SAFE_FREE(_media->audio_meta->title);
2908 SAFE_FREE(_media->audio_meta->album);
2909 SAFE_FREE(_media->audio_meta->artist);
2910 SAFE_FREE(_media->audio_meta->album_artist);
2911 SAFE_FREE(_media->audio_meta->genre);
2912 SAFE_FREE(_media->audio_meta->composer);
2913 SAFE_FREE(_media->audio_meta->year);
2914 SAFE_FREE(_media->audio_meta->recorded_date);
2915 SAFE_FREE(_media->audio_meta->copyright);
2916 SAFE_FREE(_media->audio_meta->track_num);
2918 SAFE_FREE(_media->audio_meta);
2921 ret = MEDIA_CONTENT_ERROR_NONE;
2923 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
2924 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
2930 int media_info_insert_to_db_with_data(media_info_h media)
2932 int ret = MEDIA_CONTENT_ERROR_NONE;
2934 media_info_s *_media = (media_info_s*)media;
2936 media_content_retvm_if(_media == NULL, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid media");
2937 media_content_retvm_if(!STRING_VALID(_media->file_path), MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid file_path");
2938 media_content_retvm_if(!STRING_VALID(_media->storage_uuid), MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid storage_uuid");
2939 media_content_retvm_if(_media->storage_type < 0, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid storage_type [%d]", _media->storage_type);
2941 /* Cloud Item should be filled whole info*/
2942 if (_media->storage_type == MEDIA_CONTENT_STORAGE_CLOUD) {
2943 media_content_retvm_if(!STRING_VALID(_media->mime_type), MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid mime_type");
2944 media_content_retvm_if(!STRING_VALID(_media->title), MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid title");
2945 media_content_retvm_if(_media->size <= 0, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid size [%d]", _media->size);
2946 media_content_retvm_if(_media->modified_time <= 0, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid modified_time [%d]", _media->modified_time);
2948 if ((_media->media_type < MEDIA_CONTENT_TYPE_IMAGE) || (_media->media_type > MEDIA_CONTENT_TYPE_OTHERS)) {
2949 media_content_error("invalid media type [%d]", _media->media_type);
2950 return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
2954 media_content_sec_debug("storage[%d], path[%s], media_type[%d]", _media->storage_type, _media->file_path, _media->media_type);
2956 media_svc_content_info_s *svc_content_info = NULL;
2958 ret = __media_info_map_data_usr_to_svc(_media, &svc_content_info, _media->storage_type);
2959 media_content_retvm_if(ret != MEDIA_CONTENT_ERROR_NONE, ret, "__media_info_map_data_usr_to_svc fail");
2961 ret = media_svc_insert_item_immediately_with_data(_content_get_db_handle(), svc_content_info, tzplatform_getuid(TZ_USER_NAME));
2962 if (ret != MS_MEDIA_ERR_NONE) {
2963 media_content_sec_error("media_svc_insert_item_immediately_with_data failed : %d (%s)", ret, _media->file_path);
2964 media_svc_destroy_content_info(svc_content_info);
2965 SAFE_FREE(svc_content_info);
2966 return _content_error_capi(MEDIA_CONTENT_TYPE, ret);
2968 /*free the svc_content_info*/
2969 media_svc_destroy_content_info(svc_content_info);
2970 SAFE_FREE(svc_content_info);
2972 /*Fill out the handle*/
2973 char *media_file_path = g_strdup(_media->file_path);
2974 char *media_string_uuid = g_strdup(_media->storage_uuid);
2976 __media_info_destroy(media);
2977 ret = _media_info_get_media_info_from_db(media_file_path, media_string_uuid, media);
2978 if (ret != MEDIA_CONTENT_ERROR_NONE)
2979 media_content_error("_media_info_get_media_info_from_db fail", ret);
2981 SAFE_FREE(media_file_path);
2982 SAFE_FREE(media_string_uuid);
2987 int media_info_create(const char *path, media_info_h *media)
2989 int ret = MEDIA_CONTENT_ERROR_NONE;
2990 char storage_id[MEDIA_CONTENT_UUID_SIZE+1] = {0, };
2991 media_svc_storage_type_e storage_type = 0;
2992 bool ignore_file = FALSE;
2994 media_content_retvm_if(!STRING_VALID(path), MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid path");
2995 media_content_retvm_if(media == NULL, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid media");
2997 ret = _media_util_check_ignore_file(path, &ignore_file);
2998 media_content_retvm_if(ignore_file == TRUE, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid path");
3000 memset(storage_id, 0x00, sizeof(storage_id));
3002 if (STRING_VALID(MEDIA_ROOT_PATH_CLOUD) && (strstr(path, MEDIA_ROOT_PATH_CLOUD) == NULL)) {
3003 bool ignore_dir = FALSE;
3004 char *folder_path = NULL;
3006 ret = _media_util_check_file_exist(path);
3007 media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
3009 folder_path = g_path_get_dirname(path);
3010 ret = _media_util_check_ignore_dir(folder_path, &ignore_dir);
3011 SAFE_FREE(folder_path);
3012 media_content_retvm_if(ignore_dir == TRUE, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid folder path");
3014 ret = media_svc_get_storage_id(_content_get_db_handle(), path, storage_id);
3015 if (ret != MS_MEDIA_ERR_NONE) {
3016 media_content_error("media_svc_get_storage_id failed : %d", ret);
3017 return _content_error_capi(MEDIA_CONTENT_TYPE, ret);
3020 ret = media_svc_get_storage_type(path, &storage_type, tzplatform_getuid(TZ_USER_NAME));
3021 if (ret != MS_MEDIA_ERR_NONE) {
3022 media_content_sec_error("media_svc_get_storage_type failed : %d", ret);
3023 return _content_error_capi(MEDIA_CONTENT_TYPE, ret);
3027 media_info_s *_media = (media_info_s*)calloc(1, sizeof(media_info_s));
3028 media_content_retvm_if(_media == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
3030 _media->audio_meta = (audio_meta_s *)calloc(1, sizeof(audio_meta_s));
3031 if (_media->audio_meta == NULL) {
3033 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
3034 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
3037 _media->video_meta = (video_meta_s *)calloc(1, sizeof(video_meta_s));
3038 if (_media->video_meta == NULL) {
3039 SAFE_FREE(_media->audio_meta);
3041 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
3042 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
3045 _media->image_meta = (image_meta_s *)calloc(1, sizeof(image_meta_s));
3046 if (_media->image_meta == NULL) {
3047 SAFE_FREE(_media->audio_meta);
3048 SAFE_FREE(_media->video_meta);
3050 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
3051 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
3054 _media->file_path = g_strdup(path);
3055 _media->storage_type = -1;
3056 _media->media_type = 0;
3057 _media->modified_time = 0;
3059 _media->request_id = 0;
3060 _media->longitude = MEDIA_SVC_DEFAULT_GPS_VALUE;
3061 _media->latitude = MEDIA_SVC_DEFAULT_GPS_VALUE;
3062 _media->altitude = MEDIA_SVC_DEFAULT_GPS_VALUE;
3064 if (STRING_VALID(storage_id)) {
3065 _media->storage_uuid = g_strdup(storage_id);
3066 _media->storage_type = storage_type;
3069 *media = (media_info_h)_media;
3074 int media_info_set_mime_type(media_info_h media, const char *mime_type)
3076 return __media_info_set_str_data(media, MEDIA_INFO_MIME_TYPE, mime_type);
3079 int media_info_set_title(media_info_h media, const char *title)
3081 return __media_info_set_str_data(media, MEDIA_INFO_TITLE, title);
3084 int media_info_set_album(media_info_h media, const char *album)
3086 return __media_info_set_str_data(media, MEDIA_INFO_ALBUM, album);
3089 int media_info_set_artist(media_info_h media, const char *artist)
3091 return __media_info_set_str_data(media, MEDIA_INFO_ARTIST, artist);
3094 int media_info_set_genre(media_info_h media, const char *genre)
3096 return __media_info_set_str_data(media, MEDIA_INFO_GENRE, genre);
3099 int media_info_set_recorded_date(media_info_h media, const char *recorded_date)
3101 return __media_info_set_str_data(media, MEDIA_INFO_RECORDED_DATE, recorded_date);
3104 int media_info_set_thumbnail_path(media_info_h media, const char *thumbnail_path)
3106 return __media_info_set_str_data(media, MEDIA_INFO_THUMBNAIL_PATH, thumbnail_path);
3109 int media_info_set_storage_id(media_info_h media, const char *storage_id)
3111 return __media_info_set_str_data(media, MEDIA_INFO_STORAGE_UUID, storage_id);
3114 int media_info_set_size(media_info_h media, unsigned long long size)
3116 media_info_s *_media = (media_info_s*)media;
3118 media_content_retvm_if(_media == NULL, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid media");
3120 _media->size = size;
3122 return MEDIA_CONTENT_ERROR_NONE;
3125 int media_info_set_modified_time(media_info_h media, time_t modified_time)
3127 media_info_s *_media = (media_info_s*)media;
3129 media_content_retvm_if(_media == NULL, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid media");
3131 _media->modified_time = modified_time;
3133 return MEDIA_CONTENT_ERROR_NONE;
3136 int media_info_set_media_type(media_info_h media, media_content_type_e type)
3138 media_info_s *_media = (media_info_s*)media;
3140 media_content_retvm_if(_media == NULL, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid media");
3142 _media->media_type = type;
3144 return MEDIA_CONTENT_ERROR_NONE;
3147 int media_info_set_duration(media_info_h media, int duration)
3149 media_info_s *_media = (media_info_s*)media;
3151 media_content_retvm_if(_media == NULL, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid media");
3153 if (_media->media_type == MEDIA_CONTENT_TYPE_VIDEO)
3154 _media->video_meta->duration = duration;
3155 else if ((_media->media_type == MEDIA_CONTENT_TYPE_MUSIC) || (_media->media_type == MEDIA_CONTENT_TYPE_SOUND))
3156 _media->audio_meta->duration = duration;
3158 media_content_error("Invalid media type");
3159 return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
3162 return MEDIA_CONTENT_ERROR_NONE;
3165 int media_info_set_width(media_info_h media, int width)
3167 media_info_s *_media = (media_info_s*)media;
3169 media_content_retvm_if(_media == NULL, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid media");
3171 if (_media->media_type == MEDIA_CONTENT_TYPE_VIDEO)
3172 _media->video_meta->width = width;
3173 else if (_media->media_type == MEDIA_CONTENT_TYPE_IMAGE)
3174 _media->image_meta->width = width;
3176 media_content_error("Invalid media type");
3177 return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
3180 return MEDIA_CONTENT_ERROR_NONE;
3183 int media_info_set_height(media_info_h media, int height)
3185 media_info_s *_media = (media_info_s*)media;
3187 media_content_retvm_if(_media == NULL, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid media");
3189 if (_media->media_type == MEDIA_CONTENT_TYPE_VIDEO)
3190 _media->video_meta->height = height;
3191 else if (_media->media_type == MEDIA_CONTENT_TYPE_IMAGE)
3192 _media->image_meta->height = height;
3194 media_content_error("Invalid media type");
3195 return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
3198 return MEDIA_CONTENT_ERROR_NONE;
3201 int media_info_set_storage_type(media_info_h media, media_content_storage_e storage_type)
3203 media_info_s *_media = (media_info_s*)media;
3205 media_content_retvm_if(_media == NULL, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid media");
3207 _media->storage_type = storage_type;
3209 return MEDIA_CONTENT_ERROR_NONE;