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");
1816 ret = MEDIA_CONTENT_ERROR_NONE;
1818 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1819 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1825 int media_info_is_drm(media_info_h media, bool *is_drm)
1827 int ret = MEDIA_CONTENT_ERROR_NONE;
1828 media_info_s *_media = (media_info_s*)media;
1831 *is_drm = _media->is_drm;
1832 ret = MEDIA_CONTENT_ERROR_NONE;
1834 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1835 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1841 int media_info_is_360_content(media_info_h media, bool *is_360)
1843 int ret = MEDIA_CONTENT_ERROR_NONE;
1844 media_info_s *_media = (media_info_s*)media;
1847 *is_360 = _media->is_360;
1848 ret = MEDIA_CONTENT_ERROR_NONE;
1850 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1851 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1857 int media_info_get_storage_type(media_info_h media, media_content_storage_e *storage_type)
1859 int ret = MEDIA_CONTENT_ERROR_NONE;
1860 media_info_s *_media = (media_info_s*)media;
1862 if (_media && storage_type) {
1863 *storage_type = _media->storage_type;
1864 ret = MEDIA_CONTENT_ERROR_NONE;
1866 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1867 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1873 int media_info_get_played_count(media_info_h media, int *played_count)
1875 int ret = MEDIA_CONTENT_ERROR_NONE;
1876 media_info_s *_media = (media_info_s*)media;
1879 *played_count = _media->played_count;
1880 ret = MEDIA_CONTENT_ERROR_NONE;
1882 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1883 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1889 int media_info_get_played_time(media_info_h media, time_t* played_time)
1891 int ret = MEDIA_CONTENT_ERROR_NONE;
1892 media_info_s *_media = (media_info_s*)media;
1895 *played_time = _media->played_time;
1896 ret = MEDIA_CONTENT_ERROR_NONE;
1898 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1899 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1905 int media_info_increase_played_count(media_info_h media)
1907 int ret = MEDIA_CONTENT_ERROR_NONE;
1909 media_info_s *_media = (media_info_s*)media;
1912 _media->played_count += 1;
1914 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1915 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1921 int media_info_set_played_time(media_info_h media)
1923 int ret = MEDIA_CONTENT_ERROR_NONE;
1924 time_t current_time;
1926 media_info_s *_media = (media_info_s*)media;
1928 if (_media != NULL) {
1929 time(¤t_time);
1930 _media->played_time = current_time;
1932 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1933 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1939 int media_info_get_media_from_db(const char *media_id, media_info_h *media)
1941 int ret = MEDIA_CONTENT_ERROR_NONE;
1942 char select_query[DEFAULT_QUERY_SIZE];
1943 char storage_id[MEDIA_CONTENT_UUID_SIZE+1] = {0, };
1944 sqlite3_stmt *stmt = NULL;
1946 if (!STRING_VALID(media_id) || (media == NULL)) {
1947 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1948 return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1951 memset(select_query, 0x00, sizeof(select_query));
1952 memset(storage_id, 0x00, sizeof(storage_id));
1954 ret = _media_db_get_storage_id_by_media_id(media_id, storage_id);
1955 media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
1957 snprintf(select_query, sizeof(select_query), SELECT_MEDIA_FROM_MEDIA, storage_id, media_id);
1959 ret = _content_query_prepare(&stmt, select_query, NULL, NULL);
1960 media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
1962 media_info_s *_media = NULL;
1964 while (sqlite3_step(stmt) == SQLITE_ROW) {
1966 media_info_destroy((media_info_h)_media);
1968 _media = (media_info_s*)calloc(1, sizeof(media_info_s));
1970 if (_media == NULL) {
1971 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
1972 SQLITE3_FINALIZE(stmt);
1973 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
1976 _media_info_item_get_detail(stmt, (media_info_h)_media);
1978 *media = (media_info_h)_media;
1981 SQLITE3_FINALIZE(stmt);
1986 int media_info_set_display_name(media_info_h media, const char *display_name)
1988 int ret = MEDIA_CONTENT_ERROR_NONE;
1989 media_info_s *_media = (media_info_s*)media;
1991 if (_media != NULL && STRING_VALID(display_name)) {
1992 SAFE_FREE(_media->display_name);
1994 _media->display_name = strdup(display_name);
1995 media_content_retvm_if(_media->display_name == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
1997 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1998 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
2004 int media_info_set_description(media_info_h media, const char *description)
2006 int ret = MEDIA_CONTENT_ERROR_NONE;
2007 media_info_s *_media = (media_info_s*)media;
2009 if (_media != NULL) {
2010 SAFE_FREE(_media->description);
2012 if (STRING_VALID(description)) {
2013 _media->description = strdup(description);
2014 media_content_retvm_if(_media->description == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
2016 _media->description = NULL;
2019 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
2020 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
2026 int media_info_set_longitude(media_info_h media, double longitude)
2028 int ret = MEDIA_CONTENT_ERROR_NONE;
2029 media_info_s *_media = (media_info_s*)media;
2031 if (_media != NULL) {
2032 _media->longitude = longitude;
2034 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
2035 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
2041 int media_info_set_latitude(media_info_h media, double latitude)
2043 int ret = MEDIA_CONTENT_ERROR_NONE;
2044 media_info_s *_media = (media_info_s*)media;
2046 if (_media != NULL) {
2047 _media->latitude = latitude;
2049 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
2050 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
2056 int media_info_set_altitude(media_info_h media, double altitude)
2058 int ret = MEDIA_CONTENT_ERROR_NONE;
2059 media_info_s *_media = (media_info_s*)media;
2061 if (_media != NULL) {
2062 _media->altitude = altitude;
2064 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
2065 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
2071 int media_info_set_weather(media_info_h media, const char *weather)
2073 int ret = MEDIA_CONTENT_ERROR_NONE;
2074 media_info_s *_media = (media_info_s*)media;
2076 if (_media != NULL) {
2077 SAFE_FREE(_media->weather);
2079 if (STRING_VALID(weather)) {
2080 _media->weather = strdup(weather);
2081 media_content_retvm_if(_media->weather == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
2083 _media->weather = NULL;
2086 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
2087 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
2093 int media_info_set_rating(media_info_h media, int rating)
2095 int ret = MEDIA_CONTENT_ERROR_NONE;
2096 media_info_s *_media = (media_info_s*)media;
2098 if (_media != NULL) {
2099 _media->rating = rating;
2101 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
2102 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
2108 int media_info_set_added_time(media_info_h media, time_t added_time)
2110 int ret = MEDIA_CONTENT_ERROR_NONE;
2112 media_info_s *_media = (media_info_s*)media;
2114 if ((_media != NULL) && (added_time >= 0)) {
2115 _media->added_time = added_time;
2117 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
2118 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
2124 int media_info_set_favorite(media_info_h media, bool favorite)
2126 int ret = MEDIA_CONTENT_ERROR_NONE;
2127 media_info_s *_media = (media_info_s*)media;
2129 if (_media != NULL) {
2130 if (favorite == TRUE)
2131 time(&_media->favourite);
2133 _media->favourite = 0;
2135 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
2136 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
2142 int media_info_set_author(media_info_h media, const char *author)
2144 int ret = MEDIA_CONTENT_ERROR_NONE;
2145 media_info_s *_media = (media_info_s*)media;
2147 if (_media != NULL) {
2148 if (STRING_VALID(author)) {
2149 _media->author = strdup(author);
2150 media_content_retvm_if(_media->author == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
2152 _media->author = NULL;
2155 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
2156 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
2162 int media_info_set_provider(media_info_h media, const char *provider)
2164 int ret = MEDIA_CONTENT_ERROR_NONE;
2165 media_info_s *_media = (media_info_s*)media;
2167 if (_media != NULL) {
2168 SAFE_FREE(_media->provider);
2170 if (STRING_VALID(provider)) {
2171 _media->provider = strdup(provider);
2172 media_content_retvm_if(_media->provider == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
2174 _media->provider = NULL;
2177 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
2178 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
2184 int media_info_set_content_name(media_info_h media, const char *content_name)
2186 int ret = MEDIA_CONTENT_ERROR_NONE;
2187 media_info_s *_media = (media_info_s*)media;
2189 if (_media != NULL) {
2190 SAFE_FREE(_media->content_name);
2192 if (STRING_VALID(content_name)) {
2193 _media->content_name = strdup(content_name);
2194 media_content_retvm_if(_media->content_name == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
2196 _media->content_name = NULL;
2199 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
2200 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
2206 int media_info_set_category(media_info_h media, const char *category)
2208 int ret = MEDIA_CONTENT_ERROR_NONE;
2209 media_info_s *_media = (media_info_s*)media;
2211 if (_media != NULL) {
2212 SAFE_FREE(_media->category);
2214 if (STRING_VALID(category)) {
2215 _media->category = strdup(category);
2216 media_content_retvm_if(_media->category == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
2218 _media->category = NULL;
2221 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
2222 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
2228 int media_info_set_location_tag(media_info_h media, const char *location_tag)
2230 int ret = MEDIA_CONTENT_ERROR_NONE;
2231 media_info_s *_media = (media_info_s*)media;
2233 if (_media != NULL) {
2234 SAFE_FREE(_media->location_tag);
2236 if (STRING_VALID(location_tag)) {
2237 _media->location_tag = strdup(location_tag);
2238 media_content_retvm_if(_media->location_tag == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
2240 _media->location_tag = NULL;
2243 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
2244 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
2250 int media_info_set_age_rating(media_info_h media, const char *age_rating)
2252 int ret = MEDIA_CONTENT_ERROR_NONE;
2253 media_info_s *_media = (media_info_s*)media;
2255 if (_media != NULL) {
2256 SAFE_FREE(_media->age_rating);
2258 if (STRING_VALID(age_rating)) {
2259 _media->age_rating = strdup(age_rating);
2260 media_content_retvm_if(_media->age_rating == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
2262 _media->age_rating = NULL;
2265 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
2266 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
2272 int media_info_set_keyword(media_info_h media, const char *keyword)
2274 int ret = MEDIA_CONTENT_ERROR_NONE;
2275 media_info_s *_media = (media_info_s*)media;
2277 if (_media != NULL) {
2278 SAFE_FREE(_media->keyword);
2280 if (STRING_VALID(keyword)) {
2281 _media->keyword = strdup(keyword);
2282 media_content_retvm_if(_media->keyword == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
2284 _media->keyword = NULL;
2287 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
2288 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
2294 int media_info_update_to_db(media_info_h media)
2296 int ret = MEDIA_CONTENT_ERROR_NONE;
2297 media_info_s *_media = (media_info_s*)media;
2298 char *set_sql = NULL;
2301 if (_media != NULL && STRING_VALID(_media->media_id)) {
2302 /* This sql is due to sqlite3_mprintf's wrong operation when using floating point in the text format */
2303 /* This code will be removed when sqlite3_mprintf works clearly */
2304 char *test_sql = sqlite3_mprintf("%f, %f, %f", _media->longitude, _media->latitude, _media->altitude);
2305 SQLITE3_SAFE_FREE(test_sql);
2307 /*Update Pinyin If Support Pinyin*/
2308 char *file_name_pinyin = NULL;
2309 char *description_pinyin = NULL;
2310 char *author_pinyin = NULL;
2311 char *provider_pinyin = NULL;
2312 char *content_name_pinyin = NULL;
2313 char *category_pinyin = NULL;
2314 char *location_tag_pinyin = NULL;
2315 char *age_rating_pinyin = NULL;
2316 char *keyword_pinyin = NULL;
2317 bool pinyin_support = FALSE;
2319 /*Update Pinyin If Support Pinyin*/
2320 media_svc_check_pinyin_support(&pinyin_support);
2321 if (pinyin_support) {
2322 if (STRING_VALID(_media->display_name))
2323 media_svc_get_pinyin(_media->display_name, &file_name_pinyin);
2324 if (STRING_VALID(_media->description))
2325 media_svc_get_pinyin(_media->description, &description_pinyin);
2326 if (STRING_VALID(_media->author))
2327 media_svc_get_pinyin(_media->author, &author_pinyin);
2328 if (STRING_VALID(_media->provider))
2329 media_svc_get_pinyin(_media->provider, &provider_pinyin);
2330 if (STRING_VALID(_media->content_name))
2331 media_svc_get_pinyin(_media->content_name, &content_name_pinyin);
2332 if (STRING_VALID(_media->category))
2333 media_svc_get_pinyin(_media->category, &category_pinyin);
2334 if (STRING_VALID(_media->location_tag))
2335 media_svc_get_pinyin(_media->location_tag, &location_tag_pinyin);
2336 if (STRING_VALID(_media->age_rating))
2337 media_svc_get_pinyin(_media->age_rating, &age_rating_pinyin);
2338 if (STRING_VALID(_media->keyword))
2339 media_svc_get_pinyin(_media->keyword, &keyword_pinyin);
2343 char *artist = NULL;
2345 char *recorded_date = NULL;
2347 if (_media->media_type == MEDIA_CONTENT_TYPE_VIDEO) {
2348 if (_media->video_meta->album != NULL)
2349 album = strdup(_media->video_meta->album);
2350 if (_media->video_meta->artist != NULL)
2351 artist = strdup(_media->video_meta->artist);
2352 if (_media->video_meta->genre != NULL)
2353 genre = strdup(_media->video_meta->genre);
2354 if (_media->video_meta->recorded_date != NULL)
2355 recorded_date = strdup(_media->video_meta->recorded_date);
2356 } else if ((_media->media_type == MEDIA_CONTENT_TYPE_MUSIC) || (_media->media_type == MEDIA_CONTENT_TYPE_SOUND)) {
2357 if (_media->audio_meta->album != NULL)
2358 album = strdup(_media->audio_meta->album);
2359 if (_media->audio_meta->artist != NULL)
2360 artist = strdup(_media->audio_meta->artist);
2361 if (_media->audio_meta->genre != NULL)
2362 genre = strdup(_media->audio_meta->genre);
2363 if (_media->audio_meta->recorded_date != NULL)
2364 recorded_date = strdup(_media->audio_meta->recorded_date);
2367 set_sql = sqlite3_mprintf("file_name=%Q, added_time=%d, description=%Q, longitude=%f, latitude=%f, altitude=%f, \
2368 played_count=%d, last_played_time=%d, last_played_position=%d, \
2369 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, \
2370 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, \
2371 album=%Q, artist=%Q, genre=%Q, recorded_date=%Q",
2372 _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,
2373 _media->author, _media->provider, _media->content_name, _media->category, _media->location_tag, _media->age_rating, _media->keyword, _media->weather, _media->sync_status,
2374 file_name_pinyin, description_pinyin, author_pinyin, provider_pinyin, content_name_pinyin, category_pinyin, location_tag_pinyin, age_rating_pinyin, keyword_pinyin, _media->title,
2375 album, artist, genre, recorded_date);
2377 sql = sqlite3_mprintf("UPDATE %Q SET %s WHERE media_uuid=%Q", _media->storage_uuid, set_sql, _media->media_id);
2379 ret = _content_query_sql(sql);
2380 SQLITE3_SAFE_FREE(set_sql);
2381 SQLITE3_SAFE_FREE(sql);
2383 SAFE_FREE(description_pinyin);
2384 SAFE_FREE(author_pinyin);
2385 SAFE_FREE(provider_pinyin);
2386 SAFE_FREE(content_name_pinyin);
2387 SAFE_FREE(category_pinyin);
2388 SAFE_FREE(location_tag_pinyin);
2389 SAFE_FREE(age_rating_pinyin);
2390 SAFE_FREE(keyword_pinyin);
2395 SAFE_FREE(recorded_date);
2397 if (_media->storage_type == MEDIA_CONTENT_STORAGE_CLOUD) {
2401 if (_media->media_type == MEDIA_CONTENT_TYPE_VIDEO) {
2402 set_sql = sqlite3_mprintf("title=%Q, album=%Q, artist=%Q, genre=%Q, duration=%d, width=%d, height=%d", \
2403 _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);
2404 } else if ((_media->media_type == MEDIA_CONTENT_TYPE_MUSIC) || (_media->media_type == MEDIA_CONTENT_TYPE_SOUND)) {
2405 set_sql = sqlite3_mprintf("title=%Q, album=%Q, artist=%Q, genre=%Q, duration=%d", \
2406 _media->title, _media->audio_meta->album, _media->audio_meta->artist, _media->audio_meta->genre, _media->audio_meta->duration);
2407 } else if (_media->media_type == MEDIA_CONTENT_TYPE_IMAGE) {
2408 set_sql = sqlite3_mprintf("title=%Q, width=%d, height=%d", _media->title, _media->image_meta->width, _media->image_meta->height);
2410 set_sql = sqlite3_mprintf("title=%Q", _media->title);
2413 sql = sqlite3_mprintf("UPDATE %Q SET %s WHERE media_uuid=%Q", _media->storage_uuid, set_sql, _media->media_id);
2415 ret = _content_query_sql(sql);
2417 SQLITE3_SAFE_FREE(set_sql);
2418 SQLITE3_SAFE_FREE(sql);
2421 if (ret == MEDIA_CONTENT_ERROR_NONE) {
2422 /* Send notification for this update */
2423 media_content_debug("Update is successfull. Send notification for this");
2424 if (_media->file_path && _media->mime_type)
2425 media_svc_publish_noti(MS_MEDIA_ITEM_FILE, MS_MEDIA_ITEM_UPDATE, _media->file_path, _media->media_type, _media->media_id, _media->mime_type);
2427 media_content_error("Can't Send Noti : path or mime type is NULL");
2430 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
2431 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
2437 int media_info_refresh_metadata_to_db(const char *media_id)
2439 int ret = MEDIA_CONTENT_ERROR_NONE;
2440 media_info_h media = NULL;
2441 char *file_path = NULL;
2442 media_content_storage_e storage_type = 0;
2443 char storage_id[MEDIA_CONTENT_UUID_SIZE+1] = {0, };
2445 if (!STRING_VALID(media_id)) {
2446 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
2447 return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
2450 ret = media_info_get_media_from_db(media_id, &media);
2451 if (ret != MEDIA_CONTENT_ERROR_NONE) {
2452 media_info_destroy(media);
2456 ret = media_info_get_storage_type(media, &storage_type);
2457 if (ret != MEDIA_CONTENT_ERROR_NONE) {
2458 media_info_destroy(media);
2462 if (storage_type == MEDIA_CONTENT_STORAGE_CLOUD) {
2463 media_info_destroy(media);
2464 media_content_error("Can't refresh cloud content!!");
2465 return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
2468 ret = media_info_get_file_path(media, &file_path);
2469 if (ret != MEDIA_CONTENT_ERROR_NONE) {
2470 media_info_destroy(media);
2474 ret = _media_util_check_file_exist(file_path);
2475 if (ret != MEDIA_CONTENT_ERROR_NONE) {
2476 SAFE_FREE(file_path);
2477 media_info_destroy(media);
2481 memset(storage_id, 0x00, sizeof(storage_id));
2482 ret = media_svc_get_storage_id(_content_get_db_handle(), file_path, storage_id);
2483 if (ret != MS_MEDIA_ERR_NONE) {
2484 media_content_error("media_svc_get_storage_id failed : %d", ret);
2485 SAFE_FREE(file_path);
2486 media_info_destroy(media);
2487 return _content_error_capi(MEDIA_CONTENT_TYPE, ret);
2490 ret = media_svc_refresh_item(_content_get_db_handle(), storage_id, storage_type, file_path, tzplatform_getuid(TZ_USER_NAME));
2491 if (ret != MS_MEDIA_ERR_NONE)
2492 ret = _content_error_capi(MEDIA_CONTENT_TYPE, ret);
2494 SAFE_FREE(file_path);
2495 media_info_destroy(media);
2500 int media_info_move_to_db(media_info_h media, const char* dst_path)
2502 int ret = MEDIA_CONTENT_ERROR_NONE;
2503 bool ignore_file = FALSE;
2504 bool ignore_dir = FALSE;
2505 char *folder_path = NULL;
2506 media_svc_storage_type_e src_storage_type = 0;
2507 media_svc_storage_type_e dst_storage_type = 0;
2508 char storage_id[MEDIA_CONTENT_UUID_SIZE+1] = {0, };
2510 media_content_retvm_if(media == NULL, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "invalid media");
2511 media_content_retvm_if(!STRING_VALID(dst_path), MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "invalid dst_path");
2513 media_info_s *_media = (media_info_s*)media;
2515 ret = _media_util_check_ignore_file(dst_path, &ignore_file);
2516 media_content_retvm_if(ignore_file == TRUE, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid path");
2518 ret = _media_util_check_file_exist(dst_path);
2519 media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
2521 folder_path = g_path_get_dirname(dst_path);
2522 ret = _media_util_check_ignore_dir(folder_path, &ignore_dir);
2523 SAFE_FREE(folder_path);
2525 media_content_retvm_if(ignore_dir == TRUE, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid folder path");
2527 ret = media_svc_get_storage_type(_media->file_path, &src_storage_type, tzplatform_getuid(TZ_USER_NAME));
2528 if (ret != MS_MEDIA_ERR_NONE) {
2529 media_content_sec_error("media_svc_get_storage_type failed : %d", ret);
2530 return _content_error_capi(MEDIA_CONTENT_TYPE, ret);
2533 ret = media_svc_get_storage_type(dst_path, &dst_storage_type, tzplatform_getuid(TZ_USER_NAME));
2534 if (ret != MS_MEDIA_ERR_NONE) {
2535 media_content_sec_error("media_svc_get_storage_type failed : %d", ret);
2536 return _content_error_capi(MEDIA_CONTENT_TYPE, ret);
2539 memset(storage_id, 0x00, sizeof(storage_id));
2540 ret = media_svc_get_storage_id(_content_get_db_handle(), _media->file_path, storage_id);
2541 if (ret != MS_MEDIA_ERR_NONE) {
2542 media_content_error("media_svc_get_storage_id failed : %d", ret);
2543 return _content_error_capi(MEDIA_CONTENT_TYPE, ret);
2546 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));
2547 return _content_error_capi(MEDIA_CONTENT_TYPE, ret);
2550 int media_info_create_thumbnail(media_info_h media, media_thumbnail_completed_cb callback, void *user_data)
2552 int ret = MEDIA_CONTENT_ERROR_NONE;
2553 static unsigned int req_id = 0;
2554 media_info_s *_media = (media_info_s*)media;
2556 if (_media != NULL && STRING_VALID(_media->media_id) && STRING_VALID(_media->file_path)) {
2557 media_thumbnail_cb_s *_thumb_cb = (media_thumbnail_cb_s*)calloc(1, sizeof(media_thumbnail_cb_s));
2558 media_content_retvm_if(_thumb_cb == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
2560 _media->request_id = req_id;
2562 _thumb_cb->handle = _media;
2563 _thumb_cb->user_data = user_data;
2564 _thumb_cb->thumbnail_completed_cb = callback;
2566 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));
2567 ret = _content_error_capi(MEDIA_THUMBNAIL_TYPE, ret);
2569 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
2570 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
2576 int media_info_cancel_thumbnail(media_info_h media)
2578 int ret = MEDIA_CONTENT_ERROR_NONE;
2579 media_info_s *_media = (media_info_s*)media;
2581 if (_media != NULL && STRING_VALID(_media->media_id) && STRING_VALID(_media->file_path) && _media->request_id > 0) {
2582 ret = thumbnail_request_cancel_media(_media->request_id, _media->file_path);
2583 ret = _content_error_capi(MEDIA_THUMBNAIL_TYPE, ret);
2585 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
2586 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
2592 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)
2594 media_content_retvm_if(media == NULL, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid handle");
2596 media_svc_content_info_s *svc_content_info = calloc(1, sizeof(media_svc_content_info_s));
2597 media_content_retvm_if(svc_content_info == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
2599 svc_content_info->path = g_strdup(media->file_path);
2600 svc_content_info->file_name = g_strdup(media->display_name);
2601 svc_content_info->media_type = media->media_type;
2602 svc_content_info->mime_type = g_strdup(media->mime_type);
2603 svc_content_info->size = media->size;
2604 svc_content_info->storage_type = storage_type;
2605 svc_content_info->storage_uuid = g_strdup(media->storage_uuid);
2607 svc_content_info->added_time = media->added_time;
2608 svc_content_info->modified_time = media->modified_time;
2609 svc_content_info->thumbnail_path = g_strdup(media->thumbnail_path);
2610 svc_content_info->is_drm = media->is_drm;
2611 svc_content_info->last_played_time = media->played_time;
2612 svc_content_info->played_count = media->played_count;
2613 svc_content_info->favourate = media->favourite;
2615 svc_content_info->media_meta.title = g_strdup(media->title);
2616 svc_content_info->media_meta.rating = media->rating;
2617 svc_content_info->media_meta.description = g_strdup(media->description);
2618 svc_content_info->media_meta.longitude = media->longitude;
2619 svc_content_info->media_meta.latitude = media->latitude;
2620 svc_content_info->media_meta.altitude = media->altitude;
2621 svc_content_info->media_meta.weather = g_strdup(media->weather);
2622 svc_content_info->media_meta.category = g_strdup(media->category);
2623 svc_content_info->media_meta.keyword = g_strdup(media->keyword);
2624 svc_content_info->media_meta.location_tag = g_strdup(media->location_tag);
2625 svc_content_info->media_meta.content_name = g_strdup(media->content_name);
2626 svc_content_info->media_meta.age_rating = g_strdup(media->age_rating);
2627 svc_content_info->media_meta.author = g_strdup(media->author);
2628 svc_content_info->media_meta.provider = g_strdup(media->provider);
2630 svc_content_info->media_meta.album = g_strdup(media->audio_meta->album);
2631 svc_content_info->media_meta.artist = g_strdup(media->audio_meta->artist);
2632 svc_content_info->media_meta.genre = g_strdup(media->audio_meta->genre);
2633 svc_content_info->media_meta.recorded_date = g_strdup(media->audio_meta->recorded_date);
2635 if (storage_type == MEDIA_CONTENT_STORAGE_CLOUD) {
2636 switch (media->media_type) {
2637 case MEDIA_CONTENT_TYPE_IMAGE:
2638 svc_content_info->media_meta.width = media->image_meta->width;
2639 svc_content_info->media_meta.height = media->image_meta->height;
2640 svc_content_info->media_meta.datetaken = g_strdup(media->image_meta->date_taken);
2641 svc_content_info->media_meta.orientation = media->image_meta->orientation;
2643 case MEDIA_CONTENT_TYPE_VIDEO:
2644 svc_content_info->media_meta.album_artist = g_strdup(media->audio_meta->album_artist);
2645 svc_content_info->media_meta.composer = g_strdup(media->audio_meta->composer);
2646 svc_content_info->media_meta.year = g_strdup(media->audio_meta->year);
2647 svc_content_info->media_meta.copyright = g_strdup(media->audio_meta->copyright);
2648 svc_content_info->media_meta.track_num = g_strdup(media->audio_meta->track_num);
2649 svc_content_info->media_meta.bitrate = media->audio_meta->bitrate;
2650 svc_content_info->media_meta.duration = media->audio_meta->duration;
2651 svc_content_info->media_meta.width = media->image_meta->width;
2652 svc_content_info->media_meta.height = media->image_meta->height;
2654 case MEDIA_CONTENT_TYPE_SOUND:
2655 case MEDIA_CONTENT_TYPE_MUSIC:
2656 svc_content_info->media_meta.album_artist = g_strdup(media->audio_meta->album_artist);
2657 svc_content_info->media_meta.composer = g_strdup(media->audio_meta->composer);
2658 svc_content_info->media_meta.year = g_strdup(media->audio_meta->year);
2659 svc_content_info->media_meta.copyright = g_strdup(media->audio_meta->copyright);
2660 svc_content_info->media_meta.track_num = g_strdup(media->audio_meta->track_num);
2661 svc_content_info->media_meta.bitrate = media->audio_meta->bitrate;
2662 svc_content_info->media_meta.duration = media->audio_meta->duration;
2663 svc_content_info->media_meta.channel = media->audio_meta->channel;
2664 svc_content_info->media_meta.samplerate = media->audio_meta->samplerate;
2666 case MEDIA_CONTENT_TYPE_OTHERS:
2672 *service_content = svc_content_info;
2674 return MEDIA_CONTENT_ERROR_NONE;
2677 static int __media_info_set_str_data(media_info_h media, media_info_item_e data_type, const char *str_data)
2679 media_info_s *_media = (media_info_s*)media;
2681 media_content_retvm_if(_media == NULL, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid media");
2683 switch (data_type) {
2684 case MEDIA_INFO_PATH:
2685 SAFE_FREE(_media->file_path);
2686 if (STRING_VALID(str_data)) {
2687 _media->file_path = strdup(str_data);
2688 media_content_retvm_if(_media->file_path == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
2690 _media->file_path = NULL;
2693 case MEDIA_INFO_MIME_TYPE:
2694 SAFE_FREE(_media->mime_type);
2695 if (STRING_VALID(str_data)) {
2696 _media->mime_type = strdup(str_data);
2697 media_content_retvm_if(_media->mime_type == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
2699 _media->mime_type = NULL;
2702 case MEDIA_INFO_THUMBNAIL_PATH:
2703 SAFE_FREE(_media->thumbnail_path);
2704 if (STRING_VALID(str_data)) {
2705 _media->thumbnail_path = strdup(str_data);
2706 media_content_retvm_if(_media->thumbnail_path == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
2708 _media->thumbnail_path = NULL;
2711 case MEDIA_INFO_TITLE:
2712 SAFE_FREE(_media->title);
2713 if (STRING_VALID(str_data)) {
2714 _media->title = strdup(str_data);
2715 media_content_retvm_if(_media->title == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
2717 _media->title = NULL;
2720 case MEDIA_INFO_STORAGE_UUID:
2721 SAFE_FREE(_media->storage_uuid);
2722 if (STRING_VALID(str_data)) {
2723 _media->storage_uuid = strdup(str_data);
2724 media_content_retvm_if(_media->storage_uuid == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
2726 _media->storage_uuid = NULL;
2729 case MEDIA_INFO_ALBUM:
2730 if (STRING_VALID(_media->media_id)) {
2731 if (_media->media_type == MEDIA_CONTENT_TYPE_VIDEO) {
2732 SAFE_FREE(_media->video_meta->album);
2733 if (str_data != NULL) {
2734 _media->video_meta->album = strdup(str_data);
2735 media_content_retvm_if(_media->video_meta->album == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
2737 } else if ((_media->media_type == MEDIA_CONTENT_TYPE_MUSIC) || (_media->media_type == MEDIA_CONTENT_TYPE_SOUND)) {
2738 SAFE_FREE(_media->audio_meta->album);
2739 if (str_data != NULL) {
2740 _media->audio_meta->album = strdup(str_data);
2741 media_content_retvm_if(_media->audio_meta->album == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
2745 SAFE_FREE(_media->video_meta->album);
2746 if (str_data != NULL) {
2747 _media->video_meta->album = strdup(str_data);
2748 media_content_retvm_if(_media->video_meta->album == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
2751 SAFE_FREE(_media->audio_meta->album);
2752 if (str_data != NULL) {
2753 _media->audio_meta->album = strdup(str_data);
2754 media_content_retvm_if(_media->audio_meta->album == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
2758 case MEDIA_INFO_ARTIST:
2759 if (STRING_VALID(_media->media_id)) {
2760 if (_media->media_type == MEDIA_CONTENT_TYPE_VIDEO) {
2761 SAFE_FREE(_media->video_meta->artist);
2762 if (str_data != NULL) {
2763 _media->video_meta->artist = strdup(str_data);
2764 media_content_retvm_if(_media->video_meta->artist == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
2766 } else if ((_media->media_type == MEDIA_CONTENT_TYPE_MUSIC) || (_media->media_type == MEDIA_CONTENT_TYPE_SOUND)) {
2767 SAFE_FREE(_media->audio_meta->artist);
2768 if (str_data != NULL) {
2769 _media->audio_meta->artist = strdup(str_data);
2770 media_content_retvm_if(_media->audio_meta->artist == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
2774 SAFE_FREE(_media->video_meta->artist);
2775 if (str_data != NULL) {
2776 _media->video_meta->artist = strdup(str_data);
2777 media_content_retvm_if(_media->video_meta->artist == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
2780 SAFE_FREE(_media->audio_meta->artist);
2781 if (str_data != NULL) {
2782 _media->audio_meta->artist = strdup(str_data);
2783 media_content_retvm_if(_media->audio_meta->artist == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
2787 case MEDIA_INFO_GENRE:
2788 if (STRING_VALID(_media->media_id)) {
2789 if (_media->media_type == MEDIA_CONTENT_TYPE_VIDEO) {
2790 SAFE_FREE(_media->video_meta->genre);
2791 if (str_data != NULL) {
2792 _media->video_meta->genre = strdup(str_data);
2793 media_content_retvm_if(_media->video_meta->genre == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
2795 } else if ((_media->media_type == MEDIA_CONTENT_TYPE_MUSIC) || (_media->media_type == MEDIA_CONTENT_TYPE_SOUND)) {
2796 SAFE_FREE(_media->audio_meta->genre);
2797 if (str_data != NULL) {
2798 _media->audio_meta->genre = strdup(str_data);
2799 media_content_retvm_if(_media->audio_meta->genre == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
2803 SAFE_FREE(_media->video_meta->genre);
2804 if (str_data != NULL) {
2805 _media->video_meta->genre = strdup(str_data);
2806 media_content_retvm_if(_media->video_meta->genre == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
2809 SAFE_FREE(_media->audio_meta->genre);
2810 if (str_data != NULL) {
2811 _media->audio_meta->genre = strdup(str_data);
2812 media_content_retvm_if(_media->audio_meta->genre == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
2816 case MEDIA_INFO_RECORDED_DATE:
2817 if (STRING_VALID(_media->media_id)) {
2818 if (_media->media_type == MEDIA_CONTENT_TYPE_VIDEO) {
2819 SAFE_FREE(_media->video_meta->recorded_date);
2820 if (str_data != NULL) {
2821 _media->video_meta->recorded_date = strdup(str_data);
2822 media_content_retvm_if(_media->video_meta->recorded_date == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
2824 } else if ((_media->media_type == MEDIA_CONTENT_TYPE_MUSIC) || (_media->media_type == MEDIA_CONTENT_TYPE_SOUND)) {
2825 SAFE_FREE(_media->audio_meta->recorded_date);
2826 if (str_data != NULL) {
2827 _media->audio_meta->recorded_date = strdup(str_data);
2828 media_content_retvm_if(_media->audio_meta->recorded_date == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
2832 SAFE_FREE(_media->video_meta->recorded_date);
2833 if (str_data != NULL) {
2834 _media->video_meta->recorded_date = strdup(str_data);
2835 media_content_retvm_if(_media->video_meta->recorded_date == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
2838 SAFE_FREE(_media->audio_meta->recorded_date);
2839 if (str_data != NULL) {
2840 _media->audio_meta->recorded_date = strdup(str_data);
2841 media_content_retvm_if(_media->audio_meta->recorded_date == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
2846 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
2847 return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
2850 return MEDIA_CONTENT_ERROR_NONE;
2853 static int __media_info_destroy(media_info_h media)
2855 int ret = MEDIA_CONTENT_ERROR_NONE;
2856 media_info_s *_media = (media_info_s*)media;
2859 SAFE_FREE(_media->media_id);
2860 SAFE_FREE(_media->file_path);
2861 SAFE_FREE(_media->display_name);
2862 SAFE_FREE(_media->mime_type);
2863 SAFE_FREE(_media->thumbnail_path);
2864 SAFE_FREE(_media->description);
2865 SAFE_FREE(_media->author);
2866 SAFE_FREE(_media->provider);
2867 SAFE_FREE(_media->content_name);
2868 SAFE_FREE(_media->category);
2869 SAFE_FREE(_media->location_tag);
2870 SAFE_FREE(_media->age_rating);
2871 SAFE_FREE(_media->keyword);
2872 SAFE_FREE(_media->title);
2873 SAFE_FREE(_media->weather);
2874 SAFE_FREE(_media->storage_uuid);
2876 if (_media->image_meta) {
2877 SAFE_FREE(_media->image_meta->media_id);
2878 SAFE_FREE(_media->image_meta->date_taken);
2879 SAFE_FREE(_media->image_meta->burst_id);
2880 SAFE_FREE(_media->image_meta->exposure_time);
2881 SAFE_FREE(_media->image_meta->model);
2882 SAFE_FREE(_media->image_meta->title);
2883 SAFE_FREE(_media->image_meta->weather);
2885 SAFE_FREE(_media->image_meta);
2888 if (_media->video_meta) {
2889 SAFE_FREE(_media->video_meta->media_id);
2890 SAFE_FREE(_media->video_meta->title);
2891 SAFE_FREE(_media->video_meta->album);
2892 SAFE_FREE(_media->video_meta->artist);
2893 SAFE_FREE(_media->video_meta->album_artist);
2894 SAFE_FREE(_media->video_meta->genre);
2895 SAFE_FREE(_media->video_meta->composer);
2896 SAFE_FREE(_media->video_meta->year);
2897 SAFE_FREE(_media->video_meta->recorded_date);
2898 SAFE_FREE(_media->video_meta->copyright);
2899 SAFE_FREE(_media->video_meta->track_num);
2901 SAFE_FREE(_media->video_meta);
2904 if (_media->audio_meta) {
2905 SAFE_FREE(_media->audio_meta->media_id);
2906 SAFE_FREE(_media->audio_meta->title);
2907 SAFE_FREE(_media->audio_meta->album);
2908 SAFE_FREE(_media->audio_meta->artist);
2909 SAFE_FREE(_media->audio_meta->album_artist);
2910 SAFE_FREE(_media->audio_meta->genre);
2911 SAFE_FREE(_media->audio_meta->composer);
2912 SAFE_FREE(_media->audio_meta->year);
2913 SAFE_FREE(_media->audio_meta->recorded_date);
2914 SAFE_FREE(_media->audio_meta->copyright);
2915 SAFE_FREE(_media->audio_meta->track_num);
2917 SAFE_FREE(_media->audio_meta);
2920 ret = MEDIA_CONTENT_ERROR_NONE;
2922 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
2923 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
2929 int media_info_insert_to_db_with_data(media_info_h media)
2931 int ret = MEDIA_CONTENT_ERROR_NONE;
2933 media_info_s *_media = (media_info_s*)media;
2935 media_content_retvm_if(_media == NULL, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid media");
2936 media_content_retvm_if(!STRING_VALID(_media->file_path), MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid file_path");
2937 media_content_retvm_if(!STRING_VALID(_media->storage_uuid), MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid storage_uuid");
2938 media_content_retvm_if(_media->storage_type < 0, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid storage_type [%d]", _media->storage_type);
2940 /* Cloud Item should be filled whole info*/
2941 if (_media->storage_type == MEDIA_CONTENT_STORAGE_CLOUD) {
2942 media_content_retvm_if(!STRING_VALID(_media->mime_type), MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid mime_type");
2943 media_content_retvm_if(!STRING_VALID(_media->title), MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid title");
2944 media_content_retvm_if(_media->size <= 0, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid size [%d]", _media->size);
2945 media_content_retvm_if(_media->modified_time <= 0, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid modified_time [%d]", _media->modified_time);
2947 if ((_media->media_type < MEDIA_CONTENT_TYPE_IMAGE) || (_media->media_type > MEDIA_CONTENT_TYPE_OTHERS)) {
2948 media_content_error("invalid media type [%d]", _media->media_type);
2949 return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
2953 media_content_sec_debug("storage[%d], path[%s], media_type[%d]", _media->storage_type, _media->file_path, _media->media_type);
2955 media_svc_content_info_s *svc_content_info = NULL;
2957 ret = __media_info_map_data_usr_to_svc(_media, &svc_content_info, _media->storage_type);
2958 media_content_retvm_if(ret != MEDIA_CONTENT_ERROR_NONE, ret, "__media_info_map_data_usr_to_svc fail");
2960 ret = media_svc_insert_item_immediately_with_data(_content_get_db_handle(), svc_content_info, tzplatform_getuid(TZ_USER_NAME));
2961 if (ret != MS_MEDIA_ERR_NONE) {
2962 media_content_sec_error("media_svc_insert_item_immediately_with_data failed : %d (%s)", ret, _media->file_path);
2963 media_svc_destroy_content_info(svc_content_info);
2964 SAFE_FREE(svc_content_info);
2965 return _content_error_capi(MEDIA_CONTENT_TYPE, ret);
2967 /*free the svc_content_info*/
2968 media_svc_destroy_content_info(svc_content_info);
2969 SAFE_FREE(svc_content_info);
2971 /*Fill out the handle*/
2972 char *media_file_path = g_strdup(_media->file_path);
2973 char *media_string_uuid = g_strdup(_media->storage_uuid);
2975 __media_info_destroy(media);
2976 ret = _media_info_get_media_info_from_db(media_file_path, media_string_uuid, media);
2977 if (ret != MEDIA_CONTENT_ERROR_NONE)
2978 media_content_error("_media_info_get_media_info_from_db fail", ret);
2980 SAFE_FREE(media_file_path);
2981 SAFE_FREE(media_string_uuid);
2986 int media_info_create(const char *path, media_info_h *media)
2988 int ret = MEDIA_CONTENT_ERROR_NONE;
2989 char storage_id[MEDIA_CONTENT_UUID_SIZE+1] = {0, };
2990 media_svc_storage_type_e storage_type = 0;
2991 bool ignore_file = FALSE;
2993 media_content_retvm_if(!STRING_VALID(path), MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid path");
2994 media_content_retvm_if(media == NULL, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid media");
2996 ret = _media_util_check_ignore_file(path, &ignore_file);
2997 media_content_retvm_if(ignore_file == TRUE, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid path");
2999 memset(storage_id, 0x00, sizeof(storage_id));
3001 if (STRING_VALID(MEDIA_ROOT_PATH_CLOUD) && (strstr(path, MEDIA_ROOT_PATH_CLOUD) == NULL)) {
3002 bool ignore_dir = FALSE;
3003 char *folder_path = NULL;
3005 ret = _media_util_check_file_exist(path);
3006 media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
3008 folder_path = g_path_get_dirname(path);
3009 ret = _media_util_check_ignore_dir(folder_path, &ignore_dir);
3010 SAFE_FREE(folder_path);
3011 media_content_retvm_if(ignore_dir == TRUE, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid folder path");
3013 ret = media_svc_get_storage_id(_content_get_db_handle(), path, storage_id);
3014 if (ret != MS_MEDIA_ERR_NONE) {
3015 media_content_error("media_svc_get_storage_id failed : %d", ret);
3016 return _content_error_capi(MEDIA_CONTENT_TYPE, ret);
3019 ret = media_svc_get_storage_type(path, &storage_type, tzplatform_getuid(TZ_USER_NAME));
3020 if (ret != MS_MEDIA_ERR_NONE) {
3021 media_content_sec_error("media_svc_get_storage_type failed : %d", ret);
3022 return _content_error_capi(MEDIA_CONTENT_TYPE, ret);
3026 media_info_s *_media = (media_info_s*)calloc(1, sizeof(media_info_s));
3027 media_content_retvm_if(_media == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
3029 _media->audio_meta = (audio_meta_s *)calloc(1, sizeof(audio_meta_s));
3030 if (_media->audio_meta == NULL) {
3032 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
3033 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
3036 _media->video_meta = (video_meta_s *)calloc(1, sizeof(video_meta_s));
3037 if (_media->video_meta == NULL) {
3038 SAFE_FREE(_media->audio_meta);
3040 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
3041 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
3044 _media->image_meta = (image_meta_s *)calloc(1, sizeof(image_meta_s));
3045 if (_media->image_meta == NULL) {
3046 SAFE_FREE(_media->audio_meta);
3047 SAFE_FREE(_media->video_meta);
3049 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
3050 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
3053 _media->file_path = g_strdup(path);
3054 _media->storage_type = -1;
3055 _media->media_type = 0;
3056 _media->modified_time = 0;
3058 _media->request_id = 0;
3059 _media->longitude = MEDIA_SVC_DEFAULT_GPS_VALUE;
3060 _media->latitude = MEDIA_SVC_DEFAULT_GPS_VALUE;
3061 _media->altitude = MEDIA_SVC_DEFAULT_GPS_VALUE;
3063 if (STRING_VALID(storage_id)) {
3064 _media->storage_uuid = g_strdup(storage_id);
3065 _media->storage_type = storage_type;
3068 *media = (media_info_h)_media;
3073 int media_info_set_mime_type(media_info_h media, const char *mime_type)
3075 return __media_info_set_str_data(media, MEDIA_INFO_MIME_TYPE, mime_type);
3078 int media_info_set_title(media_info_h media, const char *title)
3080 return __media_info_set_str_data(media, MEDIA_INFO_TITLE, title);
3083 int media_info_set_album(media_info_h media, const char *album)
3085 return __media_info_set_str_data(media, MEDIA_INFO_ALBUM, album);
3088 int media_info_set_artist(media_info_h media, const char *artist)
3090 return __media_info_set_str_data(media, MEDIA_INFO_ARTIST, artist);
3093 int media_info_set_genre(media_info_h media, const char *genre)
3095 return __media_info_set_str_data(media, MEDIA_INFO_GENRE, genre);
3098 int media_info_set_recorded_date(media_info_h media, const char *recorded_date)
3100 return __media_info_set_str_data(media, MEDIA_INFO_RECORDED_DATE, recorded_date);
3103 int media_info_set_thumbnail_path(media_info_h media, const char *thumbnail_path)
3105 return __media_info_set_str_data(media, MEDIA_INFO_THUMBNAIL_PATH, thumbnail_path);
3108 int media_info_set_storage_id(media_info_h media, const char *storage_id)
3110 return __media_info_set_str_data(media, MEDIA_INFO_STORAGE_UUID, storage_id);
3113 int media_info_set_size(media_info_h media, unsigned long long size)
3115 media_info_s *_media = (media_info_s*)media;
3117 media_content_retvm_if(_media == NULL, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid media");
3119 _media->size = size;
3121 return MEDIA_CONTENT_ERROR_NONE;
3124 int media_info_set_modified_time(media_info_h media, time_t modified_time)
3126 media_info_s *_media = (media_info_s*)media;
3128 media_content_retvm_if(_media == NULL, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid media");
3130 _media->modified_time = modified_time;
3132 return MEDIA_CONTENT_ERROR_NONE;
3135 int media_info_set_media_type(media_info_h media, media_content_type_e type)
3137 media_info_s *_media = (media_info_s*)media;
3139 media_content_retvm_if(_media == NULL, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid media");
3141 _media->media_type = type;
3143 return MEDIA_CONTENT_ERROR_NONE;
3146 int media_info_set_duration(media_info_h media, int duration)
3148 media_info_s *_media = (media_info_s*)media;
3150 media_content_retvm_if(_media == NULL, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid media");
3152 if (_media->media_type == MEDIA_CONTENT_TYPE_VIDEO)
3153 _media->video_meta->duration = duration;
3154 else if ((_media->media_type == MEDIA_CONTENT_TYPE_MUSIC) || (_media->media_type == MEDIA_CONTENT_TYPE_SOUND))
3155 _media->audio_meta->duration = duration;
3157 media_content_error("Invalid media type");
3158 return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
3161 return MEDIA_CONTENT_ERROR_NONE;
3164 int media_info_set_width(media_info_h media, int width)
3166 media_info_s *_media = (media_info_s*)media;
3168 media_content_retvm_if(_media == NULL, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid media");
3170 if (_media->media_type == MEDIA_CONTENT_TYPE_VIDEO)
3171 _media->video_meta->width = width;
3172 else if (_media->media_type == MEDIA_CONTENT_TYPE_IMAGE)
3173 _media->image_meta->width = width;
3175 media_content_error("Invalid media type");
3176 return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
3179 return MEDIA_CONTENT_ERROR_NONE;
3182 int media_info_set_height(media_info_h media, int height)
3184 media_info_s *_media = (media_info_s*)media;
3186 media_content_retvm_if(_media == NULL, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid media");
3188 if (_media->media_type == MEDIA_CONTENT_TYPE_VIDEO)
3189 _media->video_meta->height = height;
3190 else if (_media->media_type == MEDIA_CONTENT_TYPE_IMAGE)
3191 _media->image_meta->height = height;
3193 media_content_error("Invalid media type");
3194 return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
3197 return MEDIA_CONTENT_ERROR_NONE;
3200 int media_info_set_storage_type(media_info_h media, media_content_storage_e storage_type)
3202 media_info_s *_media = (media_info_s*)media;
3204 media_content_retvm_if(_media == NULL, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid media");
3206 _media->storage_type = storage_type;
3208 return MEDIA_CONTENT_ERROR_NONE;