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-util-dcm.h>
20 #include <media_info_private.h>
21 #include <media_util_private.h>
22 #include <system_info.h>
23 #ifdef _USE_TV_PROFILE
24 #include <media_content_internal.h>
27 static void __media_info_insert_completed_cb(media_request_result_s *result, void *user_data);
28 static void __media_info_thumbnail_completed_cb(int error, const char *path, void *user_data);
29 static void __media_info_face_completed_cb(int error, const int face_count, void *user_data);
30 static bool __media_info_delete_batch_cb(media_info_h media, void *user_data);
31 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);
33 static int __media_info_get_media_path_by_id_from_db(const char *media_id, char **path)
35 int ret = MEDIA_CONTENT_ERROR_NONE;
36 sqlite3_stmt *stmt = NULL;
37 char *select_query = NULL;
39 media_content_retvm_if(!STRING_VALID(media_id), MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "invalid media_id");
41 select_query = sqlite3_mprintf(SELECT_MEDIA_PATH_BY_ID, media_id);
43 ret = _content_query_prepare(&stmt, select_query, NULL, NULL);
44 SQLITE3_SAFE_FREE(select_query);
45 media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
47 if (sqlite3_step(stmt) == SQLITE_ROW) {
48 *path = g_strdup((const char *)sqlite3_column_text(stmt, 0));
50 media_content_error("There's no media with this ID : %s", media_id);
52 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
55 SQLITE3_FINALIZE(stmt);
60 static void __media_info_insert_completed_cb(media_request_result_s *result, void *user_data)
62 int ret = MEDIA_CONTENT_ERROR_NONE;
63 media_insert_cb_s *_cb_data = (media_insert_cb_s *)user_data;
67 ret = _content_error_capi(MEDIA_CONTENT_TYPE, result->result);
69 if (_cb_data->insert_completed_cb)
70 _cb_data->insert_completed_cb(ret, _cb_data->user_data);
72 if (STRING_VALID(_cb_data->insert_list_path)) {
73 if (unlink(_cb_data->insert_list_path) < 0)
74 media_content_stderror("failed to delete");
75 SAFE_FREE(_cb_data->insert_list_path);
84 static void __media_info_thumbnail_completed_cb(int error, const char *path, void *user_data)
86 int error_value = MEDIA_CONTENT_ERROR_NONE;
88 media_thumbnail_cb_s *_thumb_cb = (media_thumbnail_cb_s *)user_data;
89 media_info_s *media = NULL;
91 if (_thumb_cb != NULL) {
92 media = _thumb_cb->handle;
95 if (media->thumbnail_path != NULL)
96 SAFE_FREE(media->thumbnail_path);
98 if (STRING_VALID(path))
99 media->thumbnail_path = g_strdup(path);
101 media->thumbnail_path = (char *)calloc(1, sizeof(char) * strlen(EMPTY_STR) + 1);
102 strncpy(media->thumbnail_path, EMPTY_STR, strlen(EMPTY_STR));
106 media_content_debug("error [%d], thumbnail_path [%s]", error, path);
107 error_value = _content_error_capi(MEDIA_THUMBNAIL_TYPE, error);
108 if (_thumb_cb->thumbnail_completed_cb)
109 _thumb_cb->thumbnail_completed_cb(error_value, path, _thumb_cb->user_data);
112 SAFE_FREE(_thumb_cb);
117 static bool __media_info_isFaceRecognition_feature_supported()
119 bool isFaceRecognitionSupported = false;
121 const int nRetVal = system_info_get_platform_bool("http://tizen.org/feature/vision.face_recognition", &isFaceRecognitionSupported);
123 if (nRetVal != SYSTEM_INFO_ERROR_NONE) {
124 media_content_debug("SYSTEM_INFO_ERROR: vision.face_recognition [%d]", nRetVal);
128 return isFaceRecognitionSupported;
131 static void __media_info_face_completed_cb(int error, const int face_count, void *user_data)
133 int error_value = MEDIA_CONTENT_ERROR_NONE;
135 media_face_cb_s *_face_cb = (media_face_cb_s *)user_data;
137 if (_face_cb != NULL) {
138 media_content_debug("error [%d], face_count [%d]", error, face_count);
139 error_value = _content_error_capi(MEDIA_THUMBNAIL_TYPE, error);
140 if (_face_cb->face_completed_cb)
141 _face_cb->face_completed_cb(error_value, face_count, _face_cb->user_data);
149 static bool __media_info_delete_batch_cb(media_info_h media, void *user_data)
151 int err = MEDIA_CONTENT_ERROR_NONE;
152 char *thumb_path = NULL;
153 media_content_type_e media_type = 0;
154 GArray *thumb_list = (GArray *)user_data;
157 media_content_debug("NO Item");
161 err = media_info_get_media_type(media, &media_type);
162 if (err == MEDIA_CONTENT_ERROR_NONE) {
163 media_content_debug("media_type : [%d]", media_type);
165 media_info_get_thumbnail_path(media, &thumb_path);
166 if (STRING_VALID(thumb_path) && STRING_VALID(MEDIA_CONTENT_THUMB_DEFAULT_PATH)) {
167 if (strncmp(MEDIA_CONTENT_THUMB_DEFAULT_PATH, thumb_path, strlen(MEDIA_CONTENT_THUMB_DEFAULT_PATH)) != 0)
168 g_array_append_val(thumb_list, thumb_path);
171 media_content_error("media_info_get_media_type failed");
177 static int __media_info_insert_batch(media_batch_insert_e insert_type, const char **path_array,
178 unsigned int array_length,
179 media_insert_completed_cb completed_cb,
182 int ret = MEDIA_CONTENT_ERROR_NONE;
184 char list_path[255] = {0, };
185 unsigned int idx = 0;
188 for (idx = 0; idx < BATCH_REQUEST_MAX; idx++) {
189 snprintf(list_path, sizeof(list_path), "%s/request-%ld-%d", MEDIA_CONTENT_INSERT_FILES_PATH, media_content_gettid(), idx);
191 if (g_file_test(list_path, G_FILE_TEST_EXISTS | G_FILE_TEST_IS_REGULAR)) {
192 memset(list_path, 0x00, sizeof(list_path));
195 media_content_debug("The request file list path : %s", list_path);
200 if (idx == BATCH_REQUEST_MAX) {
201 media_content_error("Too many batch request for one thread");
202 return MEDIA_CONTENT_ERROR_DB_BUSY;
205 fp = fopen(list_path, "w");
207 media_content_error("failed to open file : [%s]", list_path);
208 media_content_stderror("failed to open file");
209 return MEDIA_CONTENT_ERROR_INVALID_OPERATION;
212 for (idx = 0; idx < array_length; idx++) {
213 if (STRING_VALID(path_array[idx])) {
214 int size = strlen(path_array[idx]);
216 ret = _media_util_check_file_exist(path_array[idx]);
217 if (ret != MEDIA_CONTENT_ERROR_NONE) {
219 if (unlink(list_path) < 0)
220 media_content_stderror("failed to delete");
224 nwrites = fwrite(path_array[idx], 1, size, fp);
225 if (nwrites != size) {
226 media_content_stderror("failed to write");
228 if (unlink(list_path) < 0)
229 media_content_stderror("failed to delete");
230 return MEDIA_CONTENT_ERROR_INVALID_OPERATION;
233 nwrites = fwrite("\n", 1, 1, fp);
235 media_content_stderror("failed to write");
237 if (unlink(list_path) < 0)
238 media_content_stderror("failed to delete");
239 return MEDIA_CONTENT_ERROR_INVALID_OPERATION;
242 media_content_error("path[%d] is invalid string", idx);
248 media_insert_cb_s *_cb_data = (media_insert_cb_s *)calloc(1, sizeof(media_insert_cb_s));
249 media_content_retvm_if(_cb_data == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
251 _cb_data->insert_completed_cb = completed_cb;
252 _cb_data->user_data = user_data;
253 _cb_data->insert_list_path = g_strdup(list_path);
255 if (insert_type == MEDIA_BATCH_INSERT_NORMAL)
256 ret = media_files_register(list_path, __media_info_insert_completed_cb, _cb_data, tzplatform_getuid(TZ_USER_NAME));
257 else if (insert_type == MEDIA_BATCH_INSERT_BURSTSHOT)
258 ret = media_burstshot_register(list_path, __media_info_insert_completed_cb, _cb_data, tzplatform_getuid(TZ_USER_NAME));
260 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
262 if (ret != MEDIA_CONTENT_ERROR_NONE) {
263 media_content_error("media_files_register failed : %d", ret);
264 if (unlink(list_path) < 0)
265 media_content_stderror("failed to delete");
266 return _content_error_capi(MEDIA_CONTENT_TYPE, ret);
272 void _media_info_item_get_detail(sqlite3_stmt* stmt, media_info_h media)
274 media_info_s *_media = (media_info_s*)media;
276 char *tmp_path = NULL;
277 char repl_path[MAX_PATH_LEN] = {0, };
279 _media->media_id = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_UUID));
281 tmp_path = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_PATH));
282 _media_content_rollback_path(tmp_path, repl_path);
283 _media->file_path = g_strdup(repl_path);
286 _media->display_name = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_FILE_NAME));
287 _media->media_type = (int)sqlite3_column_int(stmt, MEDIA_INFO_TYPE);
288 _media->mime_type = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_MIME_TYPE));
289 _media->size = (unsigned long long)sqlite3_column_int64(stmt, MEDIA_INFO_SIZE);
290 _media->added_time = (int)sqlite3_column_int(stmt, MEDIA_INFO_ADDED_TIME);
291 _media->modified_time = (int)sqlite3_column_int(stmt, MEDIA_INFO_MODIFIED_TIME);
292 _media->thumbnail_path = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_THUMBNAIL_PATH));
293 _media->description = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_DESCRIPTION));
294 _media->rating = (int)sqlite3_column_int(stmt, MEDIA_INFO_RATING);
295 _media->favourite = (int)sqlite3_column_int(stmt, MEDIA_INFO_FAVOURITE);
296 _media->author = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_AUTHOR));
297 _media->provider = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_PROVIDER));
298 _media->content_name = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_CONTENT_NAME));
299 _media->category = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_CATEGORY));
300 _media->location_tag = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_LOCATION_TAG));
301 _media->age_rating = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_AGE_RATING));
302 _media->keyword = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_KEYWORD));
303 _media->is_drm = (int)sqlite3_column_int(stmt, MEDIA_INFO_IS_DRM);
304 _media->storage_type = (int)sqlite3_column_int(stmt, MEDIA_INFO_STORAGE_TYPE);
305 _media->longitude = (double)sqlite3_column_double(stmt, MEDIA_INFO_LONGITUDE);
306 _media->latitude = (double)sqlite3_column_double(stmt, MEDIA_INFO_LATITUDE);
307 _media->altitude = (double)sqlite3_column_double(stmt, MEDIA_INFO_ALTITUDE);
308 _media->played_count = sqlite3_column_int(stmt, MEDIA_INFO_PLAYED_COUNT);
309 _media->played_time = sqlite3_column_int(stmt, MEDIA_INFO_LAST_PLAYED_TIME);
310 _media->played_position = sqlite3_column_int(stmt, MEDIA_INFO_LAST_PLAYED_POSITION);
311 _media->title = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_TITLE));
312 _media->timeline = (double)sqlite3_column_double(stmt, MEDIA_INFO_TIMELINE);
313 _media->weather = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_WEATHER));
314 _media->sync_status = (int)sqlite3_column_int(stmt, MEDIA_INFO_SYNC_STATUS);
315 _media->storage_uuid = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_STORAGE_UUID));
316 _media->is_360 = (int)sqlite3_column_int(stmt, MEDIA_INFO_IS_360);
317 #ifdef _USE_TV_PROFILE
318 _media->stitched_info = (int)sqlite3_column_int(stmt, MEDIA_INFO_STITCHED_INFO);
321 if (_media->media_type == MEDIA_CONTENT_TYPE_IMAGE) {
322 _media->image_meta = (image_meta_s *)calloc(1, sizeof(image_meta_s));
323 if (_media->image_meta) {
324 _media->image_meta->media_id = g_strdup(_media->media_id);
325 _media->image_meta->width = sqlite3_column_int(stmt, MEDIA_INFO_WIDTH);
326 _media->image_meta->height = sqlite3_column_int(stmt, MEDIA_INFO_HEIGHT);
327 _media->image_meta->fnumber = (double)sqlite3_column_double(stmt, MEDIA_INFO_FNUMBER);
328 _media->image_meta->iso = sqlite3_column_int(stmt, MEDIA_INFO_ISO);
329 _media->image_meta->date_taken = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_DATETAKEN));
330 _media->image_meta->orientation = sqlite3_column_int(stmt, MEDIA_INFO_ORIENTATION);
331 _media->image_meta->title = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_TITLE));
332 _media->image_meta->burst_id = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_BURST_ID));
333 _media->image_meta->weather = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_WEATHER));
334 _media->image_meta->exposure_time = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_EXPOSURE_TIME));
335 _media->image_meta->model = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_MODEL));
337 } else if (_media->media_type == MEDIA_CONTENT_TYPE_VIDEO) {
338 _media->video_meta = (video_meta_s *)calloc(1, sizeof(video_meta_s));
339 if (_media->video_meta) {
340 _media->video_meta->media_id = g_strdup(_media->media_id);
341 _media->video_meta->width = sqlite3_column_int(stmt, MEDIA_INFO_WIDTH);
342 _media->video_meta->height = sqlite3_column_int(stmt, MEDIA_INFO_HEIGHT);
343 _media->video_meta->title = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_TITLE));
344 _media->video_meta->album = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_ALBUM));
345 _media->video_meta->artist = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_ARTIST));
346 _media->video_meta->album_artist = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_ALBUM_ARTIST));
347 _media->video_meta->genre = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_GENRE));
348 _media->video_meta->composer = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_COMPOSER));
349 _media->video_meta->year = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_YEAR));
350 _media->video_meta->recorded_date = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_RECORDED_DATE));
351 _media->video_meta->copyright = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_COPYRIGHT));
352 _media->video_meta->track_num = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_TRACK_NUM));
353 _media->video_meta->bitrate = sqlite3_column_int(stmt, MEDIA_INFO_BITRATE);
354 _media->video_meta->duration = sqlite3_column_int(stmt, MEDIA_INFO_DURATION);
355 _media->video_meta->played_count = sqlite3_column_int(stmt, MEDIA_INFO_PLAYED_COUNT);
356 _media->video_meta->played_time = sqlite3_column_int(stmt, MEDIA_INFO_LAST_PLAYED_TIME);
357 _media->video_meta->played_position = sqlite3_column_int(stmt, MEDIA_INFO_LAST_PLAYED_POSITION);
358 _media->video_meta->rotation = sqlite3_column_int(stmt, MEDIA_INFO_ORIENTATION);
361 } else if ((_media->media_type == MEDIA_CONTENT_TYPE_MUSIC) || (_media->media_type == MEDIA_CONTENT_TYPE_SOUND)) {
362 _media->audio_meta = (audio_meta_s *)calloc(1, sizeof(audio_meta_s));
363 if (_media->audio_meta) {
364 _media->audio_meta->media_id = g_strdup(_media->media_id);
365 _media->audio_meta->title = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_TITLE));
366 _media->audio_meta->album = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_ALBUM));
367 _media->audio_meta->artist = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_ARTIST));
368 _media->audio_meta->album_artist = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_ALBUM_ARTIST));
369 _media->audio_meta->genre = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_GENRE));
370 _media->audio_meta->composer = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_COMPOSER));
371 _media->audio_meta->year = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_YEAR));
372 _media->audio_meta->recorded_date = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_RECORDED_DATE));
373 _media->audio_meta->copyright = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_COPYRIGHT));
374 _media->audio_meta->track_num = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_TRACK_NUM));
375 _media->audio_meta->bitrate = sqlite3_column_int(stmt, MEDIA_INFO_BITRATE);
376 _media->audio_meta->bitpersample = sqlite3_column_int(stmt, MEDIA_INFO_BITPERSAMPLE);
377 _media->audio_meta->duration = sqlite3_column_int(stmt, MEDIA_INFO_DURATION);
378 _media->audio_meta->played_count = sqlite3_column_int(stmt, MEDIA_INFO_PLAYED_COUNT);
379 _media->audio_meta->played_time = sqlite3_column_int(stmt, MEDIA_INFO_LAST_PLAYED_TIME);
380 _media->audio_meta->played_position = sqlite3_column_int(stmt, MEDIA_INFO_LAST_PLAYED_POSITION);
381 _media->audio_meta->samplerate = sqlite3_column_int(stmt, MEDIA_INFO_SAMPLERATE);
382 _media->audio_meta->channel = sqlite3_column_int(stmt, MEDIA_INFO_CHANNEL);
387 int _media_info_get_media_info_from_db(const char *path, const char *storage_id, media_info_h media)
389 int ret = MEDIA_CONTENT_ERROR_NONE;
390 sqlite3_stmt *stmt = NULL;
391 char *select_query = NULL;
392 media_info_s *_media = (media_info_s*)media;
394 media_content_retvm_if(_media == NULL, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "invalid media");
396 select_query = sqlite3_mprintf(SELECT_MEDIA_BY_PATH, storage_id, path);
398 ret = _content_query_prepare(&stmt, select_query, NULL, NULL);
399 SQLITE3_SAFE_FREE(select_query);
400 media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
402 if (sqlite3_step(stmt) == SQLITE_ROW) {
403 _media_info_item_get_detail(stmt, (media_info_h)_media);
405 media_content_error("There's no media!!");
406 media_content_error("%s", path);
407 media_content_error("%s", storage_id);
408 ret = MEDIA_CONTENT_ERROR_DB_FAILED;
411 SQLITE3_FINALIZE(stmt);
416 int media_info_insert_to_db(const char *path, media_info_h *info)
418 bool ignore_file = FALSE;
419 bool ignore_dir = FALSE;
420 char *folder_path = NULL;
421 char storage_id[MEDIA_CONTENT_UUID_SIZE+1] = {0, };
422 char repl_path[MAX_PATH_LEN] = {0, };
423 int ret = MEDIA_CONTENT_ERROR_NONE;
425 media_content_retvm_if(!STRING_VALID(path), MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "invalid path");
426 media_content_retvm_if(info == NULL, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "invalid info");
427 memset(repl_path, 0, sizeof(repl_path));
428 ret = _media_content_replace_path(path, repl_path);
429 media_content_retvm_if(!STRING_VALID(repl_path), MEDIA_CONTENT_ERROR_INVALID_OPERATION, "path replacement failed");
431 ret = _media_util_check_ignore_file(repl_path, &ignore_file);
432 media_content_retvm_if(ignore_file == TRUE, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid path");
434 ret = _media_util_check_file_exist(repl_path);
435 media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
437 folder_path = g_path_get_dirname(repl_path);
438 ret = _media_util_check_ignore_dir(folder_path, &ignore_dir);
439 SAFE_FREE(folder_path);
441 media_content_retvm_if(ignore_dir == TRUE, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid folder path");
443 memset(storage_id, 0x00, sizeof(storage_id));
444 ret = media_svc_get_storage_id(_content_get_db_handle(), repl_path, storage_id, tzplatform_getuid(TZ_USER_NAME));
445 if (ret != MS_MEDIA_ERR_NONE) {
446 media_content_error("media_svc_get_storage_id failed : %d", ret);
447 return _content_error_capi(MEDIA_CONTENT_TYPE, ret);
450 ret = media_svc_check_item_exist_by_path(_content_get_db_handle(), storage_id, repl_path);
451 if (ret == MS_MEDIA_ERR_DB_NO_RECORD) {
452 media_content_sec_debug("media_svc_check_item_exist_by_path : no record : %s", repl_path);
454 media_svc_storage_type_e storage_type = 0;
456 ret = media_svc_get_storage_type(repl_path, &storage_type, tzplatform_getuid(TZ_USER_NAME));
457 if (ret != MS_MEDIA_ERR_NONE) {
458 media_content_sec_error("media_svc_get_storage_type failed : %d", ret);
459 return _content_error_capi(MEDIA_CONTENT_TYPE, ret);
462 ret = media_svc_insert_item_immediately(_content_get_db_handle(), storage_id, storage_type, repl_path, tzplatform_getuid(TZ_USER_NAME));
464 if (ret != MS_MEDIA_ERR_NONE) {
465 if (ret == MS_MEDIA_ERR_DB_CONSTRAINT_FAIL) {
466 media_content_sec_error("This item is already inserted. This may be normal operation because other process already did this (%s)", repl_path);
467 ret = MEDIA_CONTENT_ERROR_NONE;
469 media_content_sec_error("media_svc_insert_item_immediately failed : %d (%s)", ret, repl_path);
472 return _content_error_capi(MEDIA_CONTENT_TYPE, ret);
474 } else if (ret != MS_MEDIA_ERR_NONE) {
475 media_content_sec_error("media_svc_check_item_exist_by_path failed : %d (%s)", ret, repl_path);
476 return _content_error_capi(MEDIA_CONTENT_TYPE, ret);
479 media_info_s *_media = (media_info_s*)calloc(1, sizeof(media_info_s));
480 media_content_retvm_if(_media == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
482 if (STRING_VALID(storage_id))
483 ret = _media_info_get_media_info_from_db(repl_path, storage_id, (media_info_h)_media);
485 ret = _media_info_get_media_info_from_db(repl_path, DEFAULT_MEDIA_STORAGE_ID, (media_info_h)_media);
487 *info = (media_info_h)_media;
491 int media_info_insert_batch_to_db(
492 const char **path_array,
493 unsigned int array_length,
494 media_insert_completed_cb completed_cb,
497 char **repl_path_array = NULL;
499 int ret = MS_MEDIA_ERR_NONE;
500 char repl_path[MAX_PATH_LEN] = {0, };
502 media_content_retvm_if(path_array == NULL, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid path_array");
503 media_content_retvm_if(array_length <= 0, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid array_length");
505 repl_path_array = calloc(1, sizeof(char *) * array_length);
507 for (idx = 0; idx < array_length; idx++) {
508 if (STRING_VALID(path_array[idx])) {
509 memset(repl_path, 0, sizeof(repl_path));
510 _media_content_replace_path(path_array[idx], repl_path);
511 repl_path_array[idx] = strndup(repl_path, strlen(repl_path));
513 media_content_error("path[%d] is invalid string", idx);
517 ret = __media_info_insert_batch(MEDIA_BATCH_INSERT_NORMAL, (const char **)repl_path_array, array_length, completed_cb, user_data);
518 for (idx = 0; idx < array_length; idx++)
519 SAFE_FREE(repl_path_array[idx]);
521 SAFE_FREE(repl_path_array);
526 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)
528 char **repl_path_array = NULL;
530 int ret = MS_MEDIA_ERR_NONE;
531 char repl_path[MAX_PATH_LEN] = {0, };
533 media_content_retvm_if(path_array == NULL, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid path_array");
534 media_content_retvm_if(array_length <= 0, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid array_length");
536 repl_path_array = calloc(1, sizeof(char *) * array_length);
538 for (idx = 0; idx < array_length; idx++) {
539 if (STRING_VALID(path_array[idx])) {
540 memset(repl_path, 0, sizeof(repl_path));
541 _media_content_replace_path(path_array[idx], repl_path);
542 repl_path_array[idx] = strndup(repl_path, strlen(repl_path));
544 media_content_error("path[%d] is invalid string", idx);
548 ret = __media_info_insert_batch(MEDIA_BATCH_INSERT_BURSTSHOT, (const char **)repl_path_array, array_length, callback, user_data);
549 for (idx = 0; idx < array_length; idx++)
550 SAFE_FREE(repl_path_array[idx]);
552 SAFE_FREE(repl_path_array);
557 int media_info_get_media_info_by_path_from_db(const char* path, media_info_h* media)
559 char storage_id[MEDIA_CONTENT_UUID_SIZE+1] = {0,};
560 int ret = MEDIA_CONTENT_ERROR_NONE;
561 media_content_retvm_if(!STRING_VALID(path), MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "invalid path");
562 media_content_retvm_if(media == NULL, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "invalid info");
564 memset(storage_id, 0x00, sizeof(storage_id));
565 ret = media_svc_get_storage_id(_content_get_db_handle(), path, storage_id, tzplatform_getuid(TZ_USER_NAME));
566 if (ret != MS_MEDIA_ERR_NONE) {
567 media_content_error("media_svc_get_storage_id failed : %d", ret);
568 return _content_error_capi(MEDIA_CONTENT_TYPE, ret);
571 media_info_s *_media = (media_info_s*)calloc(1, sizeof(media_info_s));
572 media_content_retvm_if(_media == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
574 ret = _media_info_get_media_info_from_db(path, storage_id, (media_info_h)_media);
575 *media = (media_info_h)_media;
580 #ifdef _USE_SENIOR_MODE
581 int media_info_insert_to_db_with_contact_data(const char *path, const char* contact, const char* app_data, media_info_h *info)
583 int ret = media_info_insert_to_db(path, info);
584 media_content_retvm_if(ret != MEDIA_CONTENT_ERROR_NONE, ret, "media_info_insert_to_db [%s] failed", path);
586 ret = media_info_set_contact(*info, contact);
587 if (ret != MEDIA_CONTENT_ERROR_NONE) {
588 media_content_error("media_info_set_contact [%s] failed", contact);
590 media_info_s* _media_info = (media_info_s*)*info;
591 ret = media_info_delete_from_db(_media_info->media_id);
592 media_content_retvm_if(ret != MEDIA_CONTENT_ERROR_NONE, ret, "media_info_delete_from_db [%s] failed", _media_info->media_id);
594 media_info_destroy(*info);
598 ret = media_info_set_app_data(*info, app_data);
599 if (ret != MEDIA_CONTENT_ERROR_NONE) {
600 media_content_error("media_info_set_app_data [%s] failed", app_data);
602 media_info_s* _media_info = (media_info_s*)*info;
603 ret = media_info_delete_from_db(_media_info->media_id);
604 media_content_retvm_if(ret != MEDIA_CONTENT_ERROR_NONE, ret, "media_info_delete_from_db [%s] failed", _media_info->media_id);
606 media_info_destroy(*info);
610 ret = media_info_update_to_db(*info);
611 if (ret != MEDIA_CONTENT_ERROR_NONE) {
612 media_content_error("media_info_update_to_db [] failed");
614 media_info_s* _media_info = (media_info_s*)*info;
615 ret = media_info_delete_from_db(_media_info->media_id);
616 media_content_retvm_if(ret != MEDIA_CONTENT_ERROR_NONE, ret, "media_info_delete_from_db [%s] failed", _media_info->media_id);
618 media_info_destroy(*info);
625 int media_info_delete_contact_from_db(const char* contact, const char* storage_id)
630 int media_info_delete_item(const char *media_id)
632 int ret = MEDIA_CONTENT_ERROR_NONE;
634 char storage_id[MEDIA_CONTENT_UUID_SIZE+1] = {0,};
636 if (!STRING_VALID(media_id)) {
637 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
638 return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
641 memset(storage_id, 0x00, sizeof(storage_id));
643 ret = __media_info_get_media_path_by_id_from_db(media_id, &path);
644 if (ret != MEDIA_CONTENT_ERROR_NONE) {
645 media_content_error("__media_info_get_media_path_by_id_from_db failed : %d", ret);
650 ret = _media_db_get_storage_id_by_media_id(media_id, storage_id);
651 if (ret != MEDIA_CONTENT_ERROR_NONE) {
652 media_content_error("_media_db_get_storage_id_by_media_id failed : %d", ret);
657 ret = media_svc_delete_item_by_path(_content_get_db_handle(), storage_id, path, tzplatform_getuid(TZ_USER_NAME));
658 if (ret != MEDIA_CONTENT_ERROR_NONE) {
659 media_content_error("remove from DB failed : %d", ret);
664 ret = media_svc_remove_file(path);
666 return _content_error_capi(MEDIA_CONTENT_TYPE, ret);
671 int media_info_delete_from_db(const char *media_id)
673 int ret = MEDIA_CONTENT_ERROR_NONE;
675 char storage_id[MEDIA_CONTENT_UUID_SIZE+1] = {0, };
677 if (!STRING_VALID(media_id)) {
678 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
679 return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
682 memset(storage_id, 0x00, sizeof(storage_id));
684 ret = __media_info_get_media_path_by_id_from_db(media_id, &path);
685 if (ret != MEDIA_CONTENT_ERROR_NONE) {
686 media_content_error("__media_info_get_media_path_by_id_from_db failed : %d", ret);
691 ret = _media_db_get_storage_id_by_media_id(media_id, storage_id);
692 if (ret != MEDIA_CONTENT_ERROR_NONE) {
693 media_content_error("_media_db_get_storage_id_by_media_id failed : %d", ret);
698 ret = media_svc_delete_item_by_path(_content_get_db_handle(), storage_id, path, tzplatform_getuid(TZ_USER_NAME));
701 return _content_error_capi(MEDIA_CONTENT_TYPE, ret);
704 static int __media_info_delete_thumb_from_list(GArray *thumb_list)
708 char *thumb_path = NULL;
710 if (thumb_list != NULL) {
711 list_len = thumb_list->len;
712 for (i = 0; i < list_len; i++) {
713 thumb_path = g_array_index(thumb_list, char*, i);
714 media_content_debug("thumb path [%s]", thumb_path);
715 if (unlink(thumb_path) < 0)
716 media_content_stderror("failed to delete");
719 return MEDIA_CONTENT_ERROR_NONE;
722 static int __media_info_release_thumb_list(GArray *thumb_list)
726 char *thumb_path = NULL;
728 if (thumb_list != NULL) {
729 list_len = thumb_list->len;
730 for (i = 0; i < list_len; i++) {
731 thumb_path = g_array_index(thumb_list, char*, 0);
732 g_array_remove_index(thumb_list, 0);
733 SAFE_FREE(thumb_path);
736 g_array_free(thumb_list, FALSE);
739 return MEDIA_CONTENT_ERROR_NONE;
742 int media_info_delete_batch_from_db(filter_h filter)
744 int ret = MEDIA_CONTENT_ERROR_NONE;
746 char *query_string = NULL;
747 filter_s *_filter = NULL;
749 char *condition_query = NULL;
750 GArray *thumb_list = NULL;
752 media_content_retvm_if(filter == NULL, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid filter");
754 thumb_list = g_array_new(FALSE, FALSE, sizeof(char*));
756 /* Delete thumbnail of each item */
757 ret = _media_db_get_group_item(NULL, filter, __media_info_delete_batch_cb, thumb_list, MEDIA_GROUP_NONE);
759 _filter = (filter_s*)filter;
760 attr = _content_get_attirbute_handle();
762 if (_filter->condition) {
763 ret = _media_filter_attribute_generate(attr, _filter->condition, _filter->condition_collate_type, &condition_query);
764 if (ret != MEDIA_CONTENT_ERROR_NONE) {
765 __media_info_release_thumb_list(thumb_list);
770 if (STRING_VALID(condition_query)) {
771 if (_filter->storage_id == NULL) {
773 query_string = sqlite3_mprintf(DELETE_MEDIA_FROM_MEDIA_BATCH, "media", condition_query);
775 query_string = sqlite3_mprintf(DELETE_MEDIA_FROM_MEDIA_BATCH, _filter->storage_id, condition_query);
778 SAFE_FREE(condition_query);
779 __media_info_release_thumb_list(thumb_list);
781 return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
784 ret = _content_query_sql(query_string);
785 if (ret == MEDIA_CONTENT_ERROR_NONE) {
786 /* Send notification for this
787 In this case, send noti for internal storage and external storage
789 media_content_debug("Batch deletion is successfull. Send notification for this");
790 if (_filter->storage_id != NULL) {
791 char *storage_path = NULL;
792 media_svc_get_storage_path(_content_get_db_handle(), _filter->storage_id, &storage_path);
793 if (STRING_VALID(storage_path))
794 media_svc_publish_noti(MS_MEDIA_ITEM_DIRECTORY, MS_MEDIA_ITEM_UPDATE, storage_path, -1, NULL, NULL);
796 SAFE_FREE(storage_path);
799 media_svc_publish_noti(MS_MEDIA_ITEM_DIRECTORY, MS_MEDIA_ITEM_UPDATE, MEDIA_ROOT_PATH_INTERNAL, -1, NULL, NULL);
800 media_svc_publish_noti(MS_MEDIA_ITEM_DIRECTORY, MS_MEDIA_ITEM_UPDATE, MEDIA_ROOT_PATH_SDCARD, -1, NULL, NULL);
803 __media_info_delete_thumb_from_list(thumb_list);
804 __media_info_release_thumb_list(thumb_list);
807 SAFE_FREE(condition_query);
808 SQLITE3_SAFE_FREE(query_string);
813 int media_info_destroy(media_info_h media)
815 int ret = MEDIA_CONTENT_ERROR_NONE;
816 media_info_s *_media = (media_info_s*)media;
819 SAFE_FREE(_media->media_id);
820 SAFE_FREE(_media->file_path);
821 SAFE_FREE(_media->display_name);
822 SAFE_FREE(_media->mime_type);
823 SAFE_FREE(_media->thumbnail_path);
824 SAFE_FREE(_media->description);
825 SAFE_FREE(_media->author);
826 SAFE_FREE(_media->provider);
827 SAFE_FREE(_media->content_name);
828 SAFE_FREE(_media->category);
829 SAFE_FREE(_media->location_tag);
830 SAFE_FREE(_media->age_rating);
831 SAFE_FREE(_media->keyword);
832 SAFE_FREE(_media->title);
833 #ifdef _USE_TV_PROFILE
834 SAFE_FREE(_media->modified_month);
836 SAFE_FREE(_media->weather);
837 SAFE_FREE(_media->storage_uuid);
838 #ifdef _USE_SENIOR_MODE
839 SAFE_FREE(_media->contact);
840 SAFE_FREE(_media->app_data);
843 if (_media->image_meta) {
844 SAFE_FREE(_media->image_meta->media_id);
845 SAFE_FREE(_media->image_meta->date_taken);
846 SAFE_FREE(_media->image_meta->burst_id);
847 SAFE_FREE(_media->image_meta->exposure_time);
848 SAFE_FREE(_media->image_meta->model);
849 SAFE_FREE(_media->image_meta->title);
850 SAFE_FREE(_media->image_meta->weather);
852 SAFE_FREE(_media->image_meta);
855 if (_media->video_meta) {
856 SAFE_FREE(_media->video_meta->media_id);
857 SAFE_FREE(_media->video_meta->title);
858 SAFE_FREE(_media->video_meta->album);
859 SAFE_FREE(_media->video_meta->artist);
860 SAFE_FREE(_media->video_meta->album_artist);
861 SAFE_FREE(_media->video_meta->genre);
862 SAFE_FREE(_media->video_meta->composer);
863 SAFE_FREE(_media->video_meta->year);
864 SAFE_FREE(_media->video_meta->recorded_date);
865 SAFE_FREE(_media->video_meta->copyright);
866 SAFE_FREE(_media->video_meta->track_num);
868 SAFE_FREE(_media->video_meta);
871 if (_media->audio_meta) {
872 SAFE_FREE(_media->audio_meta->media_id);
873 SAFE_FREE(_media->audio_meta->title);
874 SAFE_FREE(_media->audio_meta->album);
875 SAFE_FREE(_media->audio_meta->artist);
876 SAFE_FREE(_media->audio_meta->album_artist);
877 SAFE_FREE(_media->audio_meta->genre);
878 SAFE_FREE(_media->audio_meta->composer);
879 SAFE_FREE(_media->audio_meta->year);
880 SAFE_FREE(_media->audio_meta->recorded_date);
881 SAFE_FREE(_media->audio_meta->copyright);
882 SAFE_FREE(_media->audio_meta->track_num);
884 SAFE_FREE(_media->audio_meta);
889 ret = MEDIA_CONTENT_ERROR_NONE;
891 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
892 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
898 int media_info_clone(media_info_h *dst, media_info_h src)
900 int ret = MEDIA_CONTENT_ERROR_NONE;
901 media_info_s *_src = (media_info_s*)src;
904 media_info_s *_dst = (media_info_s*)calloc(1, sizeof(media_info_s));
905 media_content_retvm_if(_dst == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
907 if (_src->media_id) {
908 _dst->media_id = g_strdup(_src->media_id);
909 if (_dst->media_id == NULL) {
910 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
911 media_info_destroy((media_info_h)_dst);
912 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
915 if (_src->file_path) {
916 _dst->file_path = g_strdup(_src->file_path);
917 if (_dst->file_path == NULL) {
918 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
919 media_info_destroy((media_info_h)_dst);
920 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
923 if (_src->display_name != NULL) {
924 _dst->display_name = g_strdup(_src->display_name);
925 if (_dst->display_name == NULL) {
926 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
927 media_info_destroy((media_info_h)_dst);
928 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
931 if (_src->mime_type) {
932 _dst->mime_type = g_strdup(_src->mime_type);
933 if (_dst->mime_type == NULL) {
934 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
935 media_info_destroy((media_info_h)_dst);
936 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
939 if (_src->thumbnail_path != NULL) {
940 _dst->thumbnail_path = g_strdup(_src->thumbnail_path);
941 if (_dst->thumbnail_path == NULL) {
942 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
943 media_info_destroy((media_info_h)_dst);
944 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
947 if (_src->description != NULL) {
948 _dst->description = g_strdup(_src->description);
949 if (_dst->description == NULL) {
950 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
951 media_info_destroy((media_info_h)_dst);
952 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
956 if (_src->weather != NULL) {
957 _dst->weather = g_strdup(_src->weather);
958 if (_dst->weather == 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;
965 if (_src->title != NULL) {
966 _dst->title = g_strdup(_src->title);
967 if (_dst->title == NULL) {
968 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
969 media_info_destroy((media_info_h)_dst);
970 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
973 if (_src->author != NULL) {
974 _dst->author = g_strdup(_src->author);
975 if (_dst->author == NULL) {
976 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
977 media_info_destroy((media_info_h)_dst);
978 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
981 if (_src->provider != NULL) {
982 _dst->provider = g_strdup(_src->provider);
983 if (_dst->provider == NULL) {
984 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
985 media_info_destroy((media_info_h)_dst);
986 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
989 if (_src->content_name != NULL) {
990 _dst->content_name = g_strdup(_src->content_name);
991 if (_dst->content_name == NULL) {
992 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
993 media_info_destroy((media_info_h)_dst);
994 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
997 if (_src->category != NULL) {
998 _dst->category = g_strdup(_src->category);
999 if (_dst->category == 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->location_tag != NULL) {
1006 _dst->location_tag = g_strdup(_src->location_tag);
1007 if (_dst->location_tag == 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->age_rating != NULL) {
1014 _dst->age_rating = g_strdup(_src->age_rating);
1015 if (_dst->age_rating == 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->keyword != NULL) {
1022 _dst->keyword = g_strdup(_src->keyword);
1023 if (_dst->keyword == 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;
1030 if (_src->storage_uuid != NULL) {
1031 _dst->storage_uuid = g_strdup(_src->storage_uuid);
1032 if (_dst->storage_uuid == NULL) {
1033 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
1034 media_info_destroy((media_info_h)_dst);
1035 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
1038 #ifdef _USE_TV_PROFILE
1039 if (STRING_VALID(_src->modified_month)) {
1040 _dst->modified_month = strdup(_src->modified_month);
1041 if (_dst->modified_month == NULL) {
1042 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
1043 media_info_destroy((media_info_h)_dst);
1044 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
1048 #ifdef _USE_SENIOR_MODE
1049 if (STRING_VALID(_src->contact)) {
1050 _dst->contact = strdup(_src->contact);
1051 if (_dst->contact == NULL) {
1052 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
1053 media_info_destroy((media_info_h)_dst);
1054 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
1058 if (STRING_VALID(_src->app_data)) {
1059 _dst->app_data = strdup(_src->app_data);
1060 if (_dst->app_data == NULL) {
1061 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
1062 media_info_destroy((media_info_h)_dst);
1063 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
1068 _dst->media_type = _src->media_type;
1069 _dst->size = _src->size;
1070 _dst->added_time = _src->added_time;
1071 _dst->modified_time = _src->modified_time;
1072 _dst->timeline = _src->timeline;
1073 _dst->longitude = _src->longitude;
1074 _dst->latitude = _src->latitude;
1075 _dst->altitude = _src->altitude;
1076 _dst->rating = _src->rating;
1077 _dst->favourite = _src->favourite;
1078 _dst->is_drm = _src->is_drm;
1079 _dst->storage_type = _src->storage_type;
1080 _dst->played_count = _src->played_count;
1081 _dst->played_time = _src->played_time;
1082 _dst->played_position = _src->played_position;
1083 _dst->sync_status = _src->sync_status;
1084 _dst->request_id = _src->request_id;
1085 _dst->face_request_id = _src->face_request_id;
1086 _dst->is_360 = _src->is_360;
1087 #ifdef _USE_TV_PROFILE
1088 _dst->stitched_info = _src->stitched_info;
1089 _dst->extract_flag = _src->extract_flag;
1092 if (_src->media_type == MEDIA_CONTENT_TYPE_IMAGE && _src->image_meta) {
1093 _dst->image_meta = (image_meta_s *)calloc(1, sizeof(image_meta_s));
1094 if (_dst->image_meta == NULL) {
1095 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
1096 media_info_destroy((media_info_h)_dst);
1097 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
1100 if (_src->image_meta->media_id != NULL) {
1101 _dst->image_meta->media_id = g_strdup(_src->image_meta->media_id);
1102 if (_dst->image_meta->media_id == NULL) {
1103 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
1104 media_info_destroy((media_info_h)_dst);
1105 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
1109 if (_src->image_meta->date_taken != NULL) {
1110 _dst->image_meta->date_taken = g_strdup(_src->image_meta->date_taken);
1111 if (_dst->image_meta->date_taken == NULL) {
1112 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
1113 media_info_destroy((media_info_h)_dst);
1114 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
1118 if (_src->image_meta->burst_id != NULL) {
1119 _dst->image_meta->burst_id = g_strdup(_src->image_meta->burst_id);
1120 if (_dst->image_meta->burst_id == NULL) {
1121 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
1122 media_info_destroy((media_info_h)_dst);
1123 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
1127 if (_src->image_meta->weather != NULL) {
1128 _dst->image_meta->weather = g_strdup(_src->image_meta->weather);
1129 if (_dst->image_meta->weather == NULL) {
1130 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
1131 media_info_destroy((media_info_h)_dst);
1132 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
1136 if (_src->image_meta->exposure_time != NULL) {
1137 _dst->image_meta->exposure_time = g_strdup(_src->image_meta->exposure_time);
1138 if (_dst->image_meta->exposure_time == NULL) {
1139 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
1140 media_info_destroy((media_info_h)_dst);
1141 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
1145 if (_src->image_meta->model != NULL) {
1146 _dst->image_meta->model = g_strdup(_src->image_meta->model);
1147 if (_dst->image_meta->model == NULL) {
1148 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
1149 media_info_destroy((media_info_h)_dst);
1150 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
1154 _dst->image_meta->fnumber = _src->image_meta->fnumber;
1155 _dst->image_meta->iso = _src->image_meta->iso;
1156 _dst->image_meta->width = _src->image_meta->width;
1157 _dst->image_meta->height = _src->image_meta->height;
1158 _dst->image_meta->orientation = _src->image_meta->orientation;
1160 } else if (_src->media_type == MEDIA_CONTENT_TYPE_VIDEO && _src->video_meta) {
1161 _dst->video_meta = (video_meta_s *)calloc(1, sizeof(video_meta_s));
1162 if (_dst->video_meta == NULL) {
1163 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
1164 media_info_destroy((media_info_h)_dst);
1165 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
1168 if (_src->video_meta->media_id != NULL) {
1169 _dst->video_meta->media_id = g_strdup(_src->video_meta->media_id);
1170 if (_dst->video_meta->media_id == NULL) {
1171 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
1172 media_info_destroy((media_info_h)_dst);
1173 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
1176 if (_src->video_meta->title != NULL) {
1177 _dst->video_meta->title = g_strdup(_src->video_meta->title);
1178 if (_dst->video_meta->title == NULL) {
1179 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
1180 media_info_destroy((media_info_h)_dst);
1181 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
1184 if (_src->video_meta->album != NULL) {
1185 _dst->video_meta->album = g_strdup(_src->video_meta->album);
1186 if (_dst->video_meta->album == NULL) {
1187 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
1188 media_info_destroy((media_info_h)_dst);
1189 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
1192 if (_src->video_meta->artist != NULL) {
1193 _dst->video_meta->artist = g_strdup(_src->video_meta->artist);
1194 if (_dst->video_meta->artist == NULL) {
1195 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
1196 media_info_destroy((media_info_h)_dst);
1197 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
1200 if (_src->video_meta->album_artist != NULL) {
1201 _dst->video_meta->album_artist = g_strdup(_src->video_meta->album_artist);
1202 if (_dst->video_meta->album_artist == NULL) {
1203 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
1204 media_info_destroy((media_info_h)_dst);
1205 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
1208 if (_src->video_meta->genre != NULL) {
1209 _dst->video_meta->genre = g_strdup(_src->video_meta->genre);
1210 if (_dst->video_meta->genre == NULL) {
1211 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
1212 media_info_destroy((media_info_h)_dst);
1213 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
1216 if (_src->video_meta->composer != NULL) {
1217 _dst->video_meta->composer = g_strdup(_src->video_meta->composer);
1218 if (_dst->video_meta->composer == NULL) {
1219 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
1220 media_info_destroy((media_info_h)_dst);
1221 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
1224 if (_src->video_meta->year != NULL) {
1225 _dst->video_meta->year = g_strdup(_src->video_meta->year);
1226 if (_dst->video_meta->year == NULL) {
1227 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
1228 media_info_destroy((media_info_h)_dst);
1229 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
1232 if (_src->video_meta->recorded_date != NULL) {
1233 _dst->video_meta->recorded_date = g_strdup(_src->video_meta->recorded_date);
1234 if (_dst->video_meta->recorded_date == NULL) {
1235 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
1236 media_info_destroy((media_info_h)_dst);
1237 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
1240 if (_src->video_meta->copyright != NULL) {
1241 _dst->video_meta->copyright = g_strdup(_src->video_meta->copyright);
1242 if (_dst->video_meta->copyright == NULL) {
1243 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
1244 media_info_destroy((media_info_h)_dst);
1245 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
1248 if (_src->video_meta->track_num != NULL) {
1249 _dst->video_meta->track_num = g_strdup(_src->video_meta->track_num);
1250 if (_dst->video_meta->track_num == NULL) {
1251 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
1252 media_info_destroy((media_info_h)_dst);
1253 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
1257 _dst->video_meta->width = _src->video_meta->width;
1258 _dst->video_meta->height = _src->video_meta->height;
1259 _dst->video_meta->duration = _src->video_meta->duration;
1260 _dst->video_meta->bitrate = _src->video_meta->bitrate;
1261 _dst->video_meta->played_count = _src->video_meta->played_count;
1262 _dst->video_meta->played_time = _src->video_meta->played_time;
1263 _dst->video_meta->played_position = _src->video_meta->played_position;
1264 _dst->video_meta->rotation = _src->video_meta->rotation;
1266 } else if ((_src->media_type == MEDIA_CONTENT_TYPE_MUSIC || _src->media_type == MEDIA_CONTENT_TYPE_SOUND) && _src->audio_meta) {
1267 _dst->audio_meta = (audio_meta_s *)calloc(1, sizeof(audio_meta_s));
1268 if (_dst->audio_meta == NULL) {
1269 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
1270 media_info_destroy((media_info_h)_dst);
1271 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
1274 if (_src->audio_meta->media_id != NULL) {
1275 _dst->audio_meta->media_id = g_strdup(_src->audio_meta->media_id);
1276 if (_dst->audio_meta->media_id == NULL) {
1277 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
1278 media_info_destroy((media_info_h)_dst);
1279 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
1282 if (_src->audio_meta->title != NULL) {
1283 _dst->audio_meta->title = g_strdup(_src->audio_meta->title);
1284 if (_dst->audio_meta->title == NULL) {
1285 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
1286 media_info_destroy((media_info_h)_dst);
1287 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
1290 if (_src->audio_meta->album != NULL) {
1291 _dst->audio_meta->album = g_strdup(_src->audio_meta->album);
1292 if (_dst->audio_meta->album == NULL) {
1293 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
1294 media_info_destroy((media_info_h)_dst);
1295 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
1298 if (_src->audio_meta->artist != NULL) {
1299 _dst->audio_meta->artist = g_strdup(_src->audio_meta->artist);
1300 if (_dst->audio_meta->artist == NULL) {
1301 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
1302 media_info_destroy((media_info_h)_dst);
1303 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
1306 if (_src->audio_meta->album_artist != NULL) {
1307 _dst->audio_meta->album_artist = g_strdup(_src->audio_meta->album_artist);
1308 if (_dst->audio_meta->album_artist == NULL) {
1309 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
1310 media_info_destroy((media_info_h)_dst);
1311 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
1314 if (_src->audio_meta->genre != NULL) {
1315 _dst->audio_meta->genre = g_strdup(_src->audio_meta->genre);
1316 if (_dst->audio_meta->genre == NULL) {
1317 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
1318 media_info_destroy((media_info_h)_dst);
1319 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
1322 if (_src->audio_meta->composer != NULL) {
1323 _dst->audio_meta->composer = g_strdup(_src->audio_meta->composer);
1324 if (_dst->audio_meta->composer == NULL) {
1325 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
1326 media_info_destroy((media_info_h)_dst);
1327 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
1330 if (_src->audio_meta->year != NULL) {
1331 _dst->audio_meta->year = g_strdup(_src->audio_meta->year);
1332 if (_dst->audio_meta->year == NULL) {
1333 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
1334 media_info_destroy((media_info_h)_dst);
1335 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
1338 if (_src->audio_meta->recorded_date != NULL) {
1339 _dst->audio_meta->recorded_date = g_strdup(_src->audio_meta->recorded_date);
1340 if (_dst->audio_meta->recorded_date == NULL) {
1341 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
1342 media_info_destroy((media_info_h)_dst);
1343 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
1346 if (_src->audio_meta->copyright != NULL) {
1347 _dst->audio_meta->copyright = g_strdup(_src->audio_meta->copyright);
1348 if (_dst->audio_meta->copyright == NULL) {
1349 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
1350 media_info_destroy((media_info_h)_dst);
1351 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
1354 if (_src->audio_meta->track_num != NULL) {
1355 _dst->audio_meta->track_num = g_strdup(_src->audio_meta->track_num);
1356 if (_dst->audio_meta->track_num == NULL) {
1357 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
1358 media_info_destroy((media_info_h)_dst);
1359 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
1363 _dst->audio_meta->channel = _src->audio_meta->channel;
1364 _dst->audio_meta->samplerate = _src->audio_meta->samplerate;
1365 _dst->audio_meta->duration = _src->audio_meta->duration;
1366 _dst->audio_meta->bitrate = _src->audio_meta->bitrate;
1367 _dst->audio_meta->bitpersample = _src->audio_meta->bitpersample;
1368 _dst->audio_meta->played_count = _src->audio_meta->played_count;
1369 _dst->audio_meta->played_time = _src->audio_meta->played_time;
1370 _dst->audio_meta->played_position = _src->audio_meta->played_position;
1372 *dst = (media_info_h)_dst;
1374 ret = MEDIA_CONTENT_ERROR_NONE;
1376 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1377 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1383 int media_info_get_media_count_from_db(filter_h filter, int *media_count)
1385 int ret = MEDIA_CONTENT_ERROR_NONE;
1387 if (media_count == NULL) {
1388 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1389 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1394 ret = _media_db_get_group_item_count(NULL, filter, MEDIA_GROUP_NONE, media_count);
1399 int media_info_foreach_media_from_db(filter_h filter, media_info_cb callback, void *user_data)
1401 int ret = MEDIA_CONTENT_ERROR_NONE;
1403 media_content_retvm_if(callback == NULL, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid callback");
1405 ret = _media_db_get_group_item(NULL, filter, callback, user_data, MEDIA_GROUP_NONE);
1410 int media_info_get_tag_count_from_db(const char *media_id, filter_h filter, int *tag_count)
1412 int ret = MEDIA_CONTENT_ERROR_NONE;
1414 if (STRING_VALID(media_id) && tag_count) {
1415 ret = _media_db_get_group_item_count(media_id, filter, MEDIA_GROUP_TAG_BY_MEDIA_ID, tag_count);
1417 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1418 return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1424 int media_info_foreach_tag_from_db(const char *media_id, filter_h filter, media_tag_cb callback, void *user_data)
1426 int ret = MEDIA_CONTENT_ERROR_NONE;
1428 if ((callback != NULL) && STRING_VALID(media_id)) {
1429 ret = _media_db_get_tag(media_id, filter, callback, user_data);
1431 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1432 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1438 int media_info_get_bookmark_count_from_db(const char *media_id, filter_h filter, int *bookmark_count)
1440 int ret = MEDIA_CONTENT_ERROR_NONE;
1442 if (STRING_VALID(media_id) && bookmark_count) {
1443 ret = _media_db_get_group_item_count(media_id, filter, MEDIA_GROUP_BOOKMARK_BY_MEDIA_ID, bookmark_count);
1445 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1446 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1452 int media_info_foreach_bookmark_from_db(const char *media_id, filter_h filter, media_bookmark_cb callback, void *user_data)
1454 int ret = MEDIA_CONTENT_ERROR_NONE;
1456 if ((callback != NULL) && STRING_VALID(media_id)) {
1457 ret = _media_db_get_bookmark(media_id, filter, callback, user_data);
1459 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1460 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1466 int media_info_get_face_count_from_db(const char *media_id, filter_h filter, int *face_count)
1468 int ret = MEDIA_CONTENT_ERROR_NONE;
1470 if (STRING_VALID(media_id) && face_count) {
1471 ret = _media_db_get_group_item_count(media_id, filter, MEDIA_GROUP_FACE_BY_MEDIA_ID, face_count);
1473 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1474 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1480 int media_info_foreach_face_from_db(const char *media_id, filter_h filter, media_face_cb callback, void *user_data)
1482 int ret = MEDIA_CONTENT_ERROR_NONE;
1484 if ((callback != NULL) && STRING_VALID(media_id)) {
1485 ret = _media_db_get_face(media_id, filter, callback, user_data);
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_image(media_info_h media, image_meta_h *image)
1496 int ret = MEDIA_CONTENT_ERROR_NONE;
1498 media_info_s *_media = (media_info_s*)media;
1500 media_content_retvm_if(_media == NULL, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid media");
1501 media_content_retvm_if(_media->media_type != MEDIA_CONTENT_TYPE_IMAGE, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid media_type");
1502 media_content_retvm_if(_media->image_meta == NULL, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid image_meta");
1504 image_meta_s *_image = (image_meta_s*)calloc(1, sizeof(image_meta_s));
1505 media_content_retvm_if(_image == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
1507 _image->media_id = g_strdup(_media->media_id);
1508 _image->width = _media->image_meta->width;
1509 _image->height = _media->image_meta->height;
1510 _image->orientation = _media->image_meta->orientation;
1511 _image->fnumber = _media->image_meta->fnumber;
1512 _image->iso = _media->image_meta->iso;
1513 _image->date_taken = g_strdup(_media->image_meta->date_taken);
1514 _image->title = g_strdup(_media->image_meta->title);
1515 _image->burst_id = g_strdup(_media->image_meta->burst_id);
1516 _image->weather = g_strdup(_media->image_meta->weather);
1517 _image->exposure_time = g_strdup(_media->image_meta->exposure_time);
1518 _image->model = g_strdup(_media->image_meta->model);
1520 *image = (image_meta_h)_image;
1525 int media_info_get_video(media_info_h media, video_meta_h *video)
1527 int ret = MEDIA_CONTENT_ERROR_NONE;
1529 media_info_s *_media = (media_info_s*)media;
1531 media_content_retvm_if(_media == NULL, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid media");
1532 media_content_retvm_if(_media->media_type != MEDIA_CONTENT_TYPE_VIDEO, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid media_type");
1533 media_content_retvm_if(_media->video_meta == NULL, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid video_meta");
1535 video_meta_s *_video = (video_meta_s*)calloc(1, sizeof(video_meta_s));
1536 media_content_retvm_if(_video == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
1538 _video->media_id = g_strdup(_media->media_id);
1539 _video->title = g_strdup(_media->video_meta->title);
1540 _video->album = g_strdup(_media->video_meta->album);
1541 _video->artist = g_strdup(_media->video_meta->artist);
1542 _video->album_artist = g_strdup(_media->video_meta->album_artist);
1543 _video->genre = g_strdup(_media->video_meta->genre);
1544 _video->composer = g_strdup(_media->video_meta->composer);
1545 _video->year = g_strdup(_media->video_meta->year);
1546 _video->recorded_date = g_strdup(_media->video_meta->recorded_date);
1547 _video->copyright = g_strdup(_media->video_meta->copyright);
1548 _video->track_num = g_strdup(_media->video_meta->track_num);
1550 _video->width = _media->video_meta->width;
1551 _video->height = _media->video_meta->height;
1552 _video->duration = _media->video_meta->duration;
1553 _video->bitrate = _media->video_meta->bitrate;
1554 _video->played_count = _media->video_meta->played_count;
1555 _video->played_time = _media->video_meta->played_time;
1556 _video->played_position = _media->video_meta->played_position;
1557 _video->rotation = _media->video_meta->rotation;
1559 *video = (video_meta_h)_video;
1564 int media_info_get_audio(media_info_h media, audio_meta_h *audio)
1566 int ret = MEDIA_CONTENT_ERROR_NONE;
1568 media_info_s *_media = (media_info_s*)media;
1570 media_content_retvm_if(_media == NULL, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid media");
1571 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");
1572 media_content_retvm_if(_media->audio_meta == NULL, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid audio_meta");
1574 audio_meta_s *_audio = (audio_meta_s*)calloc(1, sizeof(audio_meta_s));
1575 media_content_retvm_if(_audio == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
1577 _audio->media_id = g_strdup(_media->media_id);
1578 _audio->title = g_strdup(_media->audio_meta->title);
1579 _audio->album = g_strdup(_media->audio_meta->album);
1580 _audio->artist = g_strdup(_media->audio_meta->artist);
1581 _audio->album_artist = g_strdup(_media->audio_meta->album_artist);
1582 _audio->genre = g_strdup(_media->audio_meta->genre);
1583 _audio->composer = g_strdup(_media->audio_meta->composer);
1584 _audio->year = g_strdup(_media->audio_meta->year);
1585 _audio->recorded_date = g_strdup(_media->audio_meta->recorded_date);
1586 _audio->copyright = g_strdup(_media->audio_meta->copyright);
1587 _audio->track_num = g_strdup(_media->audio_meta->track_num);
1589 _audio->duration = _media->audio_meta->duration;
1590 _audio->bitrate = _media->audio_meta->bitrate;
1591 _audio->bitpersample = _media->audio_meta->bitpersample;
1592 _audio->samplerate = _media->audio_meta->samplerate;
1593 _audio->channel = _media->audio_meta->channel;
1594 _audio->played_time = _media->audio_meta->played_time;
1595 _audio->played_count = _media->audio_meta->played_count;
1596 _audio->played_position = _media->audio_meta->played_position;
1598 *audio = (audio_meta_h)_audio;
1603 int media_info_get_media_id(media_info_h media, char **media_id)
1605 int ret = MEDIA_CONTENT_ERROR_NONE;
1606 media_info_s *_media = (media_info_s*)media;
1608 if (_media && media_id) {
1609 if (STRING_VALID(_media->media_id)) {
1610 *media_id = strdup(_media->media_id);
1611 media_content_retvm_if(*media_id == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
1615 ret = MEDIA_CONTENT_ERROR_NONE;
1617 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1618 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1624 int media_info_get_file_path(media_info_h media, char **path)
1626 int ret = MEDIA_CONTENT_ERROR_NONE;
1627 media_info_s *_media = (media_info_s*)media;
1629 if (_media && path) {
1630 if (STRING_VALID(_media->file_path)) {
1631 *path = strdup(_media->file_path);
1632 media_content_retvm_if(*path == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
1636 ret = MEDIA_CONTENT_ERROR_NONE;
1639 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1640 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1646 int media_info_get_display_name(media_info_h media, char **name)
1648 int ret = MEDIA_CONTENT_ERROR_NONE;
1649 media_info_s *_media = (media_info_s*)media;
1650 if (_media && name) {
1651 if (_media->display_name != NULL) {
1652 *name = g_strdup(_media->display_name);
1653 media_content_retvm_if(*name == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
1657 ret = MEDIA_CONTENT_ERROR_NONE;
1660 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1661 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1667 int media_info_get_media_type(media_info_h media, media_content_type_e *type)
1669 int ret = MEDIA_CONTENT_ERROR_NONE;
1670 media_info_s *_media = (media_info_s*)media;
1671 if (_media && type) {
1672 *type = _media->media_type;
1673 ret = MEDIA_CONTENT_ERROR_NONE;
1675 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1676 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1682 int media_info_get_mime_type(media_info_h media, char **mime_type)
1684 int ret = MEDIA_CONTENT_ERROR_NONE;
1685 media_info_s *_media = (media_info_s*)media;
1687 if (_media && mime_type) {
1688 if (STRING_VALID(_media->mime_type)) {
1689 *mime_type = strdup(_media->mime_type);
1690 media_content_retvm_if(*mime_type == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
1694 ret = MEDIA_CONTENT_ERROR_NONE;
1696 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1697 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1703 int media_info_get_size(media_info_h media, unsigned long long *size)
1705 int ret = MEDIA_CONTENT_ERROR_NONE;
1706 media_info_s *_media = (media_info_s*)media;
1708 if (_media && size) {
1709 *size = _media->size;
1710 ret = MEDIA_CONTENT_ERROR_NONE;
1712 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1713 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1719 int media_info_get_added_time(media_info_h media, time_t *added_time)
1721 int ret = MEDIA_CONTENT_ERROR_NONE;
1722 media_info_s *_media = (media_info_s*)media;
1723 if (_media && added_time) {
1724 *added_time = _media->added_time;
1725 ret = MEDIA_CONTENT_ERROR_NONE;
1727 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1728 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1734 int media_info_get_modified_time(media_info_h media, time_t* time)
1736 int ret = MEDIA_CONTENT_ERROR_NONE;
1737 media_info_s *_media = (media_info_s*)media;
1738 if (_media && time) {
1739 *time = _media->modified_time;
1740 ret = MEDIA_CONTENT_ERROR_NONE;
1742 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1743 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1749 int media_info_get_timeline(media_info_h media, time_t* time)
1751 int ret = MEDIA_CONTENT_ERROR_NONE;
1752 media_info_s *_media = (media_info_s*)media;
1753 if (_media && time) {
1754 *time = _media->timeline;
1755 ret = MEDIA_CONTENT_ERROR_NONE;
1757 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1758 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1764 int media_info_get_thumbnail_path(media_info_h media, char **path)
1766 int ret = MEDIA_CONTENT_ERROR_NONE;
1767 media_info_s *_media = (media_info_s*)media;
1768 if (_media && path) {
1769 if (_media->thumbnail_path != NULL) {
1770 *path = g_strdup(_media->thumbnail_path);
1771 media_content_retvm_if(*path == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
1775 ret = MEDIA_CONTENT_ERROR_NONE;
1778 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1779 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1785 int media_info_get_title(media_info_h media, char **title)
1787 int ret = MEDIA_CONTENT_ERROR_NONE;
1788 media_info_s *_media = (media_info_s*)media;
1790 if (_media && title) { /*title can be empty string*/
1791 if (_media->title != NULL) {
1792 *title = g_strdup(_media->title);
1793 media_content_retvm_if(*title == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
1797 ret = MEDIA_CONTENT_ERROR_NONE;
1799 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1800 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1805 #ifdef _USE_TV_PROFILE
1806 int media_info_get_extract_flag(media_info_h media, int *extract_flag)
1808 int ret = MEDIA_CONTENT_ERROR_NONE;
1809 media_info_s *_media = (media_info_s *)media;
1811 if (_media && extract_flag) {
1812 *extract_flag = _media->extract_flag;
1813 ret = MEDIA_CONTENT_ERROR_NONE;
1815 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1816 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1823 int media_info_get_description(media_info_h media, char **description)
1825 int ret = MEDIA_CONTENT_ERROR_NONE;
1826 media_info_s *_media = (media_info_s*)media;
1828 if (_media && description) {
1829 if (_media->description != NULL) { /*description can be empty string*/
1830 *description = g_strdup(_media->description);
1831 media_content_retvm_if(*description == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
1833 *description = NULL;
1835 ret = MEDIA_CONTENT_ERROR_NONE;
1837 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1838 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1844 int media_info_get_longitude(media_info_h media, double* longitude)
1846 int ret = MEDIA_CONTENT_ERROR_NONE;
1847 media_info_s *_media = (media_info_s*)media;
1849 if (_media && longitude) {
1850 *longitude = _media->longitude;
1851 ret = MEDIA_CONTENT_ERROR_NONE;
1853 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1854 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1859 int media_info_get_latitude(media_info_h media, double* latitude)
1861 int ret = MEDIA_CONTENT_ERROR_NONE;
1862 media_info_s *_media = (media_info_s*)media;
1864 if (_media && latitude) {
1865 *latitude = _media->latitude;
1866 ret = MEDIA_CONTENT_ERROR_NONE;
1868 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1869 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1875 int media_info_get_altitude(media_info_h media, double *altitude)
1877 int ret = MEDIA_CONTENT_ERROR_NONE;
1878 media_info_s *_media = (media_info_s*)media;
1880 if (_media && altitude) {
1881 *altitude = _media->altitude;
1882 ret = MEDIA_CONTENT_ERROR_NONE;
1884 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1885 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1891 int media_info_get_weather(media_info_h media, char **weather)
1893 int ret = MEDIA_CONTENT_ERROR_NONE;
1894 media_info_s *_media = (media_info_s*)media;
1896 if (_media && weather) {
1897 if (_media->weather != NULL) {
1898 *weather = strdup(_media->weather);
1899 media_content_retvm_if(*weather == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
1903 ret = MEDIA_CONTENT_ERROR_NONE;
1905 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1906 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1912 int media_info_get_rating(media_info_h media, int *rating)
1914 int ret = MEDIA_CONTENT_ERROR_NONE;
1915 media_info_s *_media = (media_info_s*)media;
1917 if (_media && rating) {
1918 *rating = _media->rating;
1919 ret = MEDIA_CONTENT_ERROR_NONE;
1921 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1922 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1928 int media_info_get_favorite(media_info_h media, bool* favorite)
1930 int ret = MEDIA_CONTENT_ERROR_NONE;
1931 media_info_s *_media = (media_info_s*)media;
1933 if (_media && favorite) {
1934 *favorite = _media->favourite;
1935 ret = MEDIA_CONTENT_ERROR_NONE;
1937 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1938 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1944 int media_info_get_author(media_info_h media, char **author)
1946 int ret = MEDIA_CONTENT_ERROR_NONE;
1947 media_info_s *_media = (media_info_s*)media;
1949 if (_media && author) {
1950 if (_media->author != NULL) {
1951 *author = strdup(_media->author);
1952 media_content_retvm_if(*author == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
1956 ret = MEDIA_CONTENT_ERROR_NONE;
1958 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1959 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1965 int media_info_get_provider(media_info_h media, char **provider)
1967 int ret = MEDIA_CONTENT_ERROR_NONE;
1968 media_info_s *_media = (media_info_s*)media;
1970 if (_media && provider) {
1971 if (_media->provider != NULL) {
1972 *provider = strdup(_media->provider);
1973 media_content_retvm_if(*provider == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
1977 ret = MEDIA_CONTENT_ERROR_NONE;
1979 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
1980 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
1986 int media_info_get_content_name(media_info_h media, char **content_name)
1988 int ret = MEDIA_CONTENT_ERROR_NONE;
1989 media_info_s *_media = (media_info_s*)media;
1991 if (_media && content_name) {
1992 if (_media->content_name != NULL) {
1993 *content_name = strdup(_media->content_name);
1994 media_content_retvm_if(*content_name == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
1996 *content_name = NULL;
1998 ret = MEDIA_CONTENT_ERROR_NONE;
2000 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
2001 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
2007 int media_info_get_category(media_info_h media, char **category)
2009 int ret = MEDIA_CONTENT_ERROR_NONE;
2010 media_info_s *_media = (media_info_s*)media;
2012 if (_media && category) {
2013 if (_media->category != NULL) {
2014 *category = strdup(_media->category);
2015 media_content_retvm_if(*category == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
2019 ret = MEDIA_CONTENT_ERROR_NONE;
2021 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
2022 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
2028 int media_info_get_location_tag(media_info_h media, char **location_tag)
2030 int ret = MEDIA_CONTENT_ERROR_NONE;
2031 media_info_s *_media = (media_info_s*)media;
2033 if (_media && location_tag) {
2034 if (_media->location_tag != NULL) {
2035 *location_tag = strdup(_media->location_tag);
2036 media_content_retvm_if(*location_tag == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
2038 *location_tag = NULL;
2040 ret = MEDIA_CONTENT_ERROR_NONE;
2042 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
2043 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
2049 int media_info_get_age_rating(media_info_h media, char **age_rating)
2051 int ret = MEDIA_CONTENT_ERROR_NONE;
2052 media_info_s *_media = (media_info_s*)media;
2054 if (_media && age_rating) {
2055 if (_media->age_rating != NULL) {
2056 *age_rating = strdup(_media->age_rating);
2057 media_content_retvm_if(*age_rating == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
2061 ret = MEDIA_CONTENT_ERROR_NONE;
2063 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
2064 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
2070 int media_info_get_keyword(media_info_h media, char **keyword)
2072 int ret = MEDIA_CONTENT_ERROR_NONE;
2073 media_info_s *_media = (media_info_s*)media;
2075 if (_media && keyword) {
2076 if (_media->keyword != NULL) {
2077 *keyword = strdup(_media->keyword);
2078 media_content_retvm_if(*keyword == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
2082 ret = MEDIA_CONTENT_ERROR_NONE;
2084 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
2085 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
2091 int media_info_get_storage_id(media_info_h media, char **storage_id)
2093 int ret = MEDIA_CONTENT_ERROR_NONE;
2094 media_info_s *_media = (media_info_s*)media;
2096 if (_media && storage_id) {
2097 if (STRING_VALID(_media->storage_uuid)) {
2098 *storage_id = strdup(_media->storage_uuid);
2099 media_content_retvm_if(*storage_id == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
2102 ret = MEDIA_CONTENT_ERROR_DB_FAILED;
2104 ret = MEDIA_CONTENT_ERROR_NONE;
2106 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
2107 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
2113 int media_info_is_drm(media_info_h media, bool *is_drm)
2115 int ret = MEDIA_CONTENT_ERROR_NONE;
2116 media_info_s *_media = (media_info_s*)media;
2119 *is_drm = _media->is_drm;
2120 ret = MEDIA_CONTENT_ERROR_NONE;
2122 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
2123 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
2129 int media_info_is_360_content(media_info_h media, bool *is_360)
2131 int ret = MEDIA_CONTENT_ERROR_NONE;
2132 media_info_s *_media = (media_info_s*)media;
2135 *is_360 = _media->is_360;
2136 ret = MEDIA_CONTENT_ERROR_NONE;
2138 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
2139 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
2145 #ifdef _USE_TV_PROFILE
2146 int media_info_get_stitched_state(media_info_h media, int *stitched_info)
2148 int ret = MEDIA_CONTENT_ERROR_NONE;
2149 media_info_s *_media = (media_info_s*)media;
2152 *stitched_info = (_media->stitched_info & 0xFFFF0000) >> 16;
2153 ret = MEDIA_CONTENT_ERROR_NONE;
2155 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
2156 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
2162 int media_info_get_stitched_engine(media_info_h media, int *stitched_info)
2164 int ret = MEDIA_CONTENT_ERROR_NONE;
2165 media_info_s *_media = (media_info_s*)media;
2168 *stitched_info = _media->stitched_info & 0x0000FFFF;
2169 ret = MEDIA_CONTENT_ERROR_NONE;
2171 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
2172 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
2179 int media_info_get_storage_type(media_info_h media, media_content_storage_e *storage_type)
2181 int ret = MEDIA_CONTENT_ERROR_NONE;
2182 media_info_s *_media = (media_info_s*)media;
2184 if (_media && storage_type) {
2185 *storage_type = _media->storage_type;
2186 ret = MEDIA_CONTENT_ERROR_NONE;
2188 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
2189 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
2195 #ifdef _USE_TV_PROFILE
2196 int media_info_get_played_position(media_info_h media, int *played_position)
2198 int ret = MEDIA_CONTENT_ERROR_NONE;
2199 media_info_s *_media = (media_info_s*)media;
2202 *played_position = _media->played_position;
2203 ret = MEDIA_CONTENT_ERROR_NONE;
2205 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
2206 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
2213 int media_info_get_played_count(media_info_h media, int *played_count)
2215 int ret = MEDIA_CONTENT_ERROR_NONE;
2216 media_info_s *_media = (media_info_s*)media;
2219 *played_count = _media->played_count;
2220 ret = MEDIA_CONTENT_ERROR_NONE;
2222 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
2223 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
2229 int media_info_get_played_time(media_info_h media, time_t* played_time)
2231 int ret = MEDIA_CONTENT_ERROR_NONE;
2232 media_info_s *_media = (media_info_s*)media;
2235 *played_time = _media->played_time;
2236 ret = MEDIA_CONTENT_ERROR_NONE;
2238 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
2239 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
2245 int media_info_increase_played_count(media_info_h media)
2247 int ret = MEDIA_CONTENT_ERROR_NONE;
2249 media_info_s *_media = (media_info_s*)media;
2252 _media->played_count += 1;
2254 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
2255 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
2261 #ifdef _USE_TV_PROFILE
2262 int media_info_get_modified_month(media_info_h media, char **modified_month)
2264 int ret = MEDIA_CONTENT_ERROR_NONE;
2265 media_info_s *_media = (media_info_s*)media;
2267 if (_media && modified_month) {
2268 if (STRING_VALID(_media->modified_month)) {
2269 *modified_month = strdup(_media->modified_month);
2270 if (*modified_month == NULL) {
2271 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
2272 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
2275 *modified_month = NULL;
2277 ret = MEDIA_CONTENT_ERROR_NONE;
2279 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
2280 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
2286 #ifdef _USE_SENIOR_MODE
2287 int media_info_get_contact(media_info_h media, char **contact)
2289 int ret = MEDIA_CONTENT_ERROR_NONE;
2290 media_info_s *_media = (media_info_s*)media;
2292 if (_media && contact) {
2293 if (STRING_VALID(_media->contact)) {
2294 *contact = strdup(_media->contact);
2295 if (*contact == NULL) {
2296 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
2297 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
2302 ret = MEDIA_CONTENT_ERROR_NONE;
2304 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
2305 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
2311 int media_info_get_app_data(media_info_h media, char **app_data)
2313 int ret = MEDIA_CONTENT_ERROR_NONE;
2314 media_info_s *_media = (media_info_s*)media;
2316 if (_media && app_data) {
2317 if (STRING_VALID(_media->app_data)) {
2318 *app_data = strdup(_media->app_data);
2319 if (*app_data == NULL) {
2320 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
2321 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
2326 ret = MEDIA_CONTENT_ERROR_NONE;
2328 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
2329 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
2335 #ifdef _USE_TV_PROFILE
2336 int media_info_set_played_count(media_info_h media, int played_count)
2338 int ret = MEDIA_CONTENT_ERROR_NONE;
2340 media_info_s *_media = (media_info_s*)media;
2343 _media->played_count = played_count;
2345 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
2346 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
2353 int media_info_set_played_time(media_info_h media)
2355 int ret = MEDIA_CONTENT_ERROR_NONE;
2356 time_t current_time;
2358 media_info_s *_media = (media_info_s*)media;
2360 if (_media != NULL) {
2361 time(¤t_time);
2362 _media->played_time = current_time;
2364 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
2365 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
2370 #ifdef _USE_TV_PROFILE
2371 int media_info_set_played_position(media_info_h media, int played_position)
2373 int ret = MEDIA_CONTENT_ERROR_NONE;
2374 media_info_s *_media = (media_info_s*)media;
2376 if ((_media != NULL) && (played_position >= 0)) {
2377 _media->played_position = played_position;
2379 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
2380 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
2387 int media_info_get_media_from_db(const char *media_id, media_info_h *media)
2389 int ret = MEDIA_CONTENT_ERROR_NONE;
2390 char select_query[DEFAULT_QUERY_SIZE];
2391 char storage_id[MEDIA_CONTENT_UUID_SIZE+1] = {0, };
2392 sqlite3_stmt *stmt = NULL;
2394 if (!STRING_VALID(media_id) || (media == NULL)) {
2395 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
2396 return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
2399 memset(select_query, 0x00, sizeof(select_query));
2400 memset(storage_id, 0x00, sizeof(storage_id));
2402 ret = _media_db_get_storage_id_by_media_id(media_id, storage_id);
2403 media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
2405 snprintf(select_query, sizeof(select_query), SELECT_MEDIA_FROM_MEDIA, storage_id, media_id);
2407 ret = _content_query_prepare(&stmt, select_query, NULL, NULL);
2408 media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
2410 media_info_s *_media = NULL;
2412 while (sqlite3_step(stmt) == SQLITE_ROW) {
2414 media_info_destroy((media_info_h)_media);
2416 _media = (media_info_s*)calloc(1, sizeof(media_info_s));
2418 if (_media == NULL) {
2419 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
2420 SQLITE3_FINALIZE(stmt);
2421 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
2424 _media_info_item_get_detail(stmt, (media_info_h)_media);
2426 *media = (media_info_h)_media;
2429 SQLITE3_FINALIZE(stmt);
2434 int media_info_set_display_name(media_info_h media, const char *display_name)
2436 int ret = MEDIA_CONTENT_ERROR_NONE;
2437 media_info_s *_media = (media_info_s*)media;
2439 if (_media != NULL && STRING_VALID(display_name)) {
2440 SAFE_FREE(_media->display_name);
2442 _media->display_name = strdup(display_name);
2443 media_content_retvm_if(_media->display_name == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
2445 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
2446 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
2452 int media_info_set_description(media_info_h media, const char *description)
2454 int ret = MEDIA_CONTENT_ERROR_NONE;
2455 media_info_s *_media = (media_info_s*)media;
2457 if (_media != NULL) {
2458 SAFE_FREE(_media->description);
2460 if (STRING_VALID(description)) {
2461 _media->description = strdup(description);
2462 media_content_retvm_if(_media->description == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
2464 _media->description = NULL;
2467 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
2468 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
2474 int media_info_set_longitude(media_info_h media, double longitude)
2476 int ret = MEDIA_CONTENT_ERROR_NONE;
2477 media_info_s *_media = (media_info_s*)media;
2479 if (_media != NULL) {
2480 _media->longitude = longitude;
2482 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
2483 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
2489 int media_info_set_latitude(media_info_h media, double latitude)
2491 int ret = MEDIA_CONTENT_ERROR_NONE;
2492 media_info_s *_media = (media_info_s*)media;
2494 if (_media != NULL) {
2495 _media->latitude = latitude;
2497 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
2498 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
2504 int media_info_set_altitude(media_info_h media, double altitude)
2506 int ret = MEDIA_CONTENT_ERROR_NONE;
2507 media_info_s *_media = (media_info_s*)media;
2509 if (_media != NULL) {
2510 _media->altitude = altitude;
2512 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
2513 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
2519 int media_info_set_weather(media_info_h media, const char *weather)
2521 int ret = MEDIA_CONTENT_ERROR_NONE;
2522 media_info_s *_media = (media_info_s*)media;
2524 if (_media != NULL) {
2525 SAFE_FREE(_media->weather);
2527 if (STRING_VALID(weather)) {
2528 _media->weather = strdup(weather);
2529 media_content_retvm_if(_media->weather == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
2531 _media->weather = NULL;
2534 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
2535 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
2541 int media_info_set_rating(media_info_h media, int rating)
2543 int ret = MEDIA_CONTENT_ERROR_NONE;
2544 media_info_s *_media = (media_info_s*)media;
2546 if (_media != NULL) {
2547 _media->rating = rating;
2549 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
2550 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
2556 int media_info_set_added_time(media_info_h media, time_t added_time)
2558 int ret = MEDIA_CONTENT_ERROR_NONE;
2560 media_info_s *_media = (media_info_s*)media;
2562 if ((_media != NULL) && (added_time >= 0)) {
2563 _media->added_time = added_time;
2565 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
2566 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
2572 int media_info_set_favorite(media_info_h media, bool favorite)
2574 int ret = MEDIA_CONTENT_ERROR_NONE;
2575 media_info_s *_media = (media_info_s*)media;
2577 if (_media != NULL) {
2578 if (favorite == TRUE)
2579 time(&_media->favourite);
2581 _media->favourite = 0;
2583 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
2584 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
2590 int media_info_set_author(media_info_h media, const char *author)
2592 int ret = MEDIA_CONTENT_ERROR_NONE;
2593 media_info_s *_media = (media_info_s*)media;
2595 if (_media != NULL) {
2596 if (STRING_VALID(author)) {
2597 _media->author = strdup(author);
2598 media_content_retvm_if(_media->author == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
2600 _media->author = NULL;
2603 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
2604 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
2610 int media_info_set_provider(media_info_h media, const char *provider)
2612 int ret = MEDIA_CONTENT_ERROR_NONE;
2613 media_info_s *_media = (media_info_s*)media;
2615 if (_media != NULL) {
2616 SAFE_FREE(_media->provider);
2618 if (STRING_VALID(provider)) {
2619 _media->provider = strdup(provider);
2620 media_content_retvm_if(_media->provider == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
2622 _media->provider = NULL;
2625 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
2626 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
2632 int media_info_set_content_name(media_info_h media, const char *content_name)
2634 int ret = MEDIA_CONTENT_ERROR_NONE;
2635 media_info_s *_media = (media_info_s*)media;
2637 if (_media != NULL) {
2638 SAFE_FREE(_media->content_name);
2640 if (STRING_VALID(content_name)) {
2641 _media->content_name = strdup(content_name);
2642 media_content_retvm_if(_media->content_name == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
2644 _media->content_name = NULL;
2647 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
2648 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
2654 int media_info_set_category(media_info_h media, const char *category)
2656 int ret = MEDIA_CONTENT_ERROR_NONE;
2657 media_info_s *_media = (media_info_s*)media;
2659 if (_media != NULL) {
2660 SAFE_FREE(_media->category);
2662 if (STRING_VALID(category)) {
2663 _media->category = strdup(category);
2664 media_content_retvm_if(_media->category == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
2666 _media->category = NULL;
2669 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
2670 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
2676 int media_info_set_location_tag(media_info_h media, const char *location_tag)
2678 int ret = MEDIA_CONTENT_ERROR_NONE;
2679 media_info_s *_media = (media_info_s*)media;
2681 if (_media != NULL) {
2682 SAFE_FREE(_media->location_tag);
2684 if (STRING_VALID(location_tag)) {
2685 _media->location_tag = strdup(location_tag);
2686 media_content_retvm_if(_media->location_tag == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
2688 _media->location_tag = NULL;
2691 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
2692 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
2698 int media_info_set_age_rating(media_info_h media, const char *age_rating)
2700 int ret = MEDIA_CONTENT_ERROR_NONE;
2701 media_info_s *_media = (media_info_s*)media;
2703 if (_media != NULL) {
2704 SAFE_FREE(_media->age_rating);
2706 if (STRING_VALID(age_rating)) {
2707 _media->age_rating = strdup(age_rating);
2708 media_content_retvm_if(_media->age_rating == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
2710 _media->age_rating = NULL;
2713 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
2714 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
2720 int media_info_set_keyword(media_info_h media, const char *keyword)
2722 int ret = MEDIA_CONTENT_ERROR_NONE;
2723 media_info_s *_media = (media_info_s*)media;
2725 if (_media != NULL) {
2726 SAFE_FREE(_media->keyword);
2728 if (STRING_VALID(keyword)) {
2729 _media->keyword = strdup(keyword);
2730 media_content_retvm_if(_media->keyword == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
2732 _media->keyword = NULL;
2735 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
2736 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
2742 int media_info_update_to_db(media_info_h media)
2744 int ret = MEDIA_CONTENT_ERROR_NONE;
2745 media_info_s *_media = (media_info_s*)media;
2746 char *set_sql = NULL;
2749 if (_media != NULL && STRING_VALID(_media->media_id)) {
2750 /* This sql is due to sqlite3_mprintf's wrong operation when using floating point in the text format */
2751 /* This code will be removed when sqlite3_mprintf works clearly */
2752 char *test_sql = sqlite3_mprintf("%f, %f, %f", _media->longitude, _media->latitude, _media->altitude);
2753 SQLITE3_SAFE_FREE(test_sql);
2755 /*Update Pinyin If Support Pinyin*/
2756 char *file_name_pinyin = NULL;
2757 char *description_pinyin = NULL;
2758 char *author_pinyin = NULL;
2759 char *provider_pinyin = NULL;
2760 char *content_name_pinyin = NULL;
2761 char *category_pinyin = NULL;
2762 char *location_tag_pinyin = NULL;
2763 char *age_rating_pinyin = NULL;
2764 char *keyword_pinyin = NULL;
2765 bool pinyin_support = FALSE;
2767 /*Update Pinyin If Support Pinyin*/
2768 media_svc_check_pinyin_support(&pinyin_support);
2769 if (pinyin_support) {
2770 if (STRING_VALID(_media->display_name))
2771 media_svc_get_pinyin(_media->display_name, &file_name_pinyin);
2772 if (STRING_VALID(_media->description))
2773 media_svc_get_pinyin(_media->description, &description_pinyin);
2774 if (STRING_VALID(_media->author))
2775 media_svc_get_pinyin(_media->author, &author_pinyin);
2776 if (STRING_VALID(_media->provider))
2777 media_svc_get_pinyin(_media->provider, &provider_pinyin);
2778 if (STRING_VALID(_media->content_name))
2779 media_svc_get_pinyin(_media->content_name, &content_name_pinyin);
2780 if (STRING_VALID(_media->category))
2781 media_svc_get_pinyin(_media->category, &category_pinyin);
2782 if (STRING_VALID(_media->location_tag))
2783 media_svc_get_pinyin(_media->location_tag, &location_tag_pinyin);
2784 if (STRING_VALID(_media->age_rating))
2785 media_svc_get_pinyin(_media->age_rating, &age_rating_pinyin);
2786 if (STRING_VALID(_media->keyword))
2787 media_svc_get_pinyin(_media->keyword, &keyword_pinyin);
2791 char *artist = NULL;
2793 char *recorded_date = NULL;
2795 if (_media->media_type == MEDIA_CONTENT_TYPE_VIDEO) {
2796 if (_media->video_meta->album != NULL)
2797 album = strdup(_media->video_meta->album);
2798 if (_media->video_meta->artist != NULL)
2799 artist = strdup(_media->video_meta->artist);
2800 if (_media->video_meta->genre != NULL)
2801 genre = strdup(_media->video_meta->genre);
2802 if (_media->video_meta->recorded_date != NULL)
2803 recorded_date = strdup(_media->video_meta->recorded_date);
2804 } else if ((_media->media_type == MEDIA_CONTENT_TYPE_MUSIC) || (_media->media_type == MEDIA_CONTENT_TYPE_SOUND)) {
2805 if (_media->audio_meta->album != NULL)
2806 album = strdup(_media->audio_meta->album);
2807 if (_media->audio_meta->artist != NULL)
2808 artist = strdup(_media->audio_meta->artist);
2809 if (_media->audio_meta->genre != NULL)
2810 genre = strdup(_media->audio_meta->genre);
2811 if (_media->audio_meta->recorded_date != NULL)
2812 recorded_date = strdup(_media->audio_meta->recorded_date);
2815 #ifdef _USE_SENIOR_MODE
2816 if (_media_content_is_support_senior_mode()) {
2817 set_sql = sqlite3_mprintf("file_name=%Q, added_time=%d, description=%Q, longitude=%f, latitude=%f, altitude=%f, \
2818 played_count=%d, last_played_time=%d, last_played_position=%d, \
2819 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, \
2820 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, contact=%Q, app_data=%Q",
2821 _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,
2822 _media->author, _media->provider, _media->content_name, _media->category, _media->location_tag, _media->age_rating, _media->keyword, _media->weather, _media->sync_status,
2823 file_name_pinyin, description_pinyin, author_pinyin, provider_pinyin, content_name_pinyin, category_pinyin, location_tag_pinyin, age_rating_pinyin, keyword_pinyin, _media->title, _media->contact, _media->app_data);
2827 set_sql = sqlite3_mprintf("file_name=%Q, added_time=%d, description=%Q, longitude=%f, latitude=%f, altitude=%f, \
2828 played_count=%d, last_played_time=%d, last_played_position=%d, \
2829 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, \
2830 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, \
2831 album=%Q, artist=%Q, genre=%Q, recorded_date=%Q",
2832 _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,
2833 _media->author, _media->provider, _media->content_name, _media->category, _media->location_tag, _media->age_rating, _media->keyword, _media->weather, _media->sync_status,
2834 file_name_pinyin, description_pinyin, author_pinyin, provider_pinyin, content_name_pinyin, category_pinyin, location_tag_pinyin, age_rating_pinyin, keyword_pinyin, _media->title,
2835 album, artist, genre, recorded_date);
2838 sql = sqlite3_mprintf("UPDATE %Q SET %s WHERE media_uuid=%Q", _media->storage_uuid, set_sql, _media->media_id);
2840 ret = _content_query_sql(sql);
2841 SQLITE3_SAFE_FREE(set_sql);
2842 SQLITE3_SAFE_FREE(sql);
2844 SAFE_FREE(file_name_pinyin);
2845 SAFE_FREE(description_pinyin);
2846 SAFE_FREE(author_pinyin);
2847 SAFE_FREE(provider_pinyin);
2848 SAFE_FREE(content_name_pinyin);
2849 SAFE_FREE(category_pinyin);
2850 SAFE_FREE(location_tag_pinyin);
2851 SAFE_FREE(age_rating_pinyin);
2852 SAFE_FREE(keyword_pinyin);
2857 SAFE_FREE(recorded_date);
2859 if (ret == MEDIA_CONTENT_ERROR_NONE) {
2860 /* Send notification for this update */
2861 media_content_debug("Update is successfull. Send notification for this");
2862 if (_media->file_path && _media->mime_type)
2863 media_svc_publish_noti(MS_MEDIA_ITEM_FILE, MS_MEDIA_ITEM_UPDATE, _media->file_path, _media->media_type, _media->media_id, _media->mime_type);
2865 media_content_error("Can't Send Noti : path or mime type is NULL");
2868 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
2869 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
2875 int media_info_refresh_metadata_to_db(const char *media_id)
2877 int ret = MEDIA_CONTENT_ERROR_NONE;
2878 media_info_h media = NULL;
2879 char *file_path = NULL;
2880 media_content_storage_e storage_type = 0;
2881 char storage_id[MEDIA_CONTENT_UUID_SIZE+1] = {0, };
2882 char repl_path[MAX_PATH_LEN] = {0, };
2884 if (!STRING_VALID(media_id)) {
2885 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
2886 return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
2889 ret = media_info_get_media_from_db(media_id, &media);
2890 if (ret != MEDIA_CONTENT_ERROR_NONE) {
2891 media_info_destroy(media);
2895 ret = media_info_get_storage_type(media, &storage_type);
2896 if (ret != MEDIA_CONTENT_ERROR_NONE) {
2897 media_info_destroy(media);
2901 ret = media_info_get_file_path(media, &file_path);
2902 if (ret != MEDIA_CONTENT_ERROR_NONE) {
2903 media_info_destroy(media);
2906 memset(repl_path, 0, sizeof(repl_path));
2907 ret = _media_content_replace_path(file_path, repl_path);
2909 ret = _media_util_check_file_exist(repl_path);
2910 if (ret != MEDIA_CONTENT_ERROR_NONE) {
2911 SAFE_FREE(file_path);
2912 media_info_destroy(media);
2916 memset(storage_id, 0x00, sizeof(storage_id));
2917 ret = media_svc_get_storage_id(_content_get_db_handle(), repl_path, storage_id, tzplatform_getuid(TZ_USER_NAME));
2918 if (ret != MS_MEDIA_ERR_NONE) {
2919 media_content_error("media_svc_get_storage_id failed : %d", ret);
2920 SAFE_FREE(file_path);
2921 media_info_destroy(media);
2922 return _content_error_capi(MEDIA_CONTENT_TYPE, ret);
2925 ret = media_svc_refresh_item(_content_get_db_handle(), storage_id, storage_type, repl_path, tzplatform_getuid(TZ_USER_NAME));
2926 if (ret != MS_MEDIA_ERR_NONE)
2927 ret = _content_error_capi(MEDIA_CONTENT_TYPE, ret);
2929 SAFE_FREE(file_path);
2930 media_info_destroy(media);
2935 int media_info_move_to_db(media_info_h media, const char* dst_path)
2937 int ret = MEDIA_CONTENT_ERROR_NONE;
2938 bool ignore_file = FALSE;
2939 bool ignore_dir = FALSE;
2940 char *folder_path = NULL;
2941 media_svc_storage_type_e src_storage_type = 0;
2942 media_svc_storage_type_e dst_storage_type = 0;
2943 char storage_id[MEDIA_CONTENT_UUID_SIZE+1] = {0, };
2944 char repl_path[MAX_PATH_LEN] = {0, };
2945 char org_repl_path[MAX_PATH_LEN] = {0, };
2947 media_content_retvm_if(media == NULL, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "invalid media");
2948 media_content_retvm_if(!STRING_VALID(dst_path), MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "invalid dst_path");
2949 memset(repl_path, 0, sizeof(repl_path));
2950 memset(org_repl_path, 0, sizeof(org_repl_path));
2951 ret = _media_content_replace_path(dst_path, repl_path);
2952 media_content_retvm_if(!STRING_VALID(repl_path), MEDIA_CONTENT_ERROR_INVALID_OPERATION, "path replacement failed");
2954 media_info_s *_media = (media_info_s*)media;
2956 ret = _media_util_check_ignore_file(repl_path, &ignore_file);
2957 media_content_retvm_if(ignore_file == TRUE, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid path");
2958 ret = _media_content_replace_path(_media->file_path, org_repl_path);
2959 media_content_retvm_if(!STRING_VALID(org_repl_path), MEDIA_CONTENT_ERROR_INVALID_OPERATION, "path replacement failed");
2961 ret = _media_util_check_file_exist(repl_path);
2962 media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
2964 folder_path = g_path_get_dirname(repl_path);
2965 ret = _media_util_check_ignore_dir(folder_path, &ignore_dir);
2966 SAFE_FREE(folder_path);
2968 media_content_retvm_if(ignore_dir == TRUE, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid folder path");
2970 ret = media_svc_get_storage_type(org_repl_path, &src_storage_type, tzplatform_getuid(TZ_USER_NAME));
2971 if (ret != MS_MEDIA_ERR_NONE) {
2972 media_content_sec_error("media_svc_get_storage_type failed : %d", ret);
2973 return _content_error_capi(MEDIA_CONTENT_TYPE, ret);
2976 ret = media_svc_get_storage_type(repl_path, &dst_storage_type, tzplatform_getuid(TZ_USER_NAME));
2977 if (ret != MS_MEDIA_ERR_NONE) {
2978 media_content_sec_error("media_svc_get_storage_type failed : %d", ret);
2979 return _content_error_capi(MEDIA_CONTENT_TYPE, ret);
2982 memset(storage_id, 0x00, sizeof(storage_id));
2983 ret = media_svc_get_storage_id(_content_get_db_handle(), org_repl_path, storage_id, tzplatform_getuid(TZ_USER_NAME));
2984 if (ret != MS_MEDIA_ERR_NONE) {
2985 media_content_error("media_svc_get_storage_id failed : %d", ret);
2986 return _content_error_capi(MEDIA_CONTENT_TYPE, ret);
2989 ret = media_svc_move_item(_content_get_db_handle(), storage_id, src_storage_type, org_repl_path, dst_storage_type, repl_path, tzplatform_getuid(TZ_USER_NAME));
2990 return _content_error_capi(MEDIA_CONTENT_TYPE, ret);
2993 int media_info_create_thumbnail(media_info_h media, media_thumbnail_completed_cb callback, void *user_data)
2995 int ret = MEDIA_CONTENT_ERROR_NONE;
2996 static unsigned int req_id = 0;
2997 char repl_path[MAX_PATH_LEN] = {0, };
2998 media_info_s *_media = (media_info_s*)media;
3000 if (_media != NULL && STRING_VALID(_media->media_id) && STRING_VALID(_media->file_path)) {
3001 memset(repl_path, 0, sizeof(repl_path));
3002 ret = _media_content_replace_path(_media->file_path, repl_path);
3003 media_content_retvm_if(!STRING_VALID(repl_path), MEDIA_CONTENT_ERROR_INVALID_OPERATION, "path replacement failed");
3005 media_thumbnail_cb_s *_thumb_cb = (media_thumbnail_cb_s*)calloc(1, sizeof(media_thumbnail_cb_s));
3006 media_content_retvm_if(_thumb_cb == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
3008 _media->request_id = req_id;
3010 _thumb_cb->handle = _media;
3011 _thumb_cb->user_data = user_data;
3012 _thumb_cb->thumbnail_completed_cb = callback;
3014 ret = thumbnail_request_from_db_async(_media->request_id, repl_path, (ThumbFunc)__media_info_thumbnail_completed_cb, (void *)_thumb_cb, tzplatform_getuid(TZ_USER_NAME));
3015 ret = _content_error_capi(MEDIA_THUMBNAIL_TYPE, ret);
3017 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
3018 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
3024 int media_info_cancel_thumbnail(media_info_h media)
3026 int ret = MEDIA_CONTENT_ERROR_NONE;
3027 media_info_s *_media = (media_info_s*)media;
3028 char repl_path[MAX_PATH_LEN] = {0, };
3030 if (_media != NULL && STRING_VALID(_media->media_id) && STRING_VALID(_media->file_path) && _media->request_id > 0) {
3031 memset(repl_path, 0, sizeof(repl_path));
3032 ret = _media_content_replace_path(_media->file_path, repl_path);
3033 media_content_retvm_if(!STRING_VALID(repl_path), MEDIA_CONTENT_ERROR_INVALID_OPERATION, "path replacement failed");
3035 ret = thumbnail_request_cancel_media(_media->request_id, repl_path);
3036 ret = _content_error_capi(MEDIA_THUMBNAIL_TYPE, ret);
3038 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
3039 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
3045 int media_info_start_face_detection(media_info_h media, media_face_detection_completed_cb callback, void *user_data)
3047 int ret = MEDIA_CONTENT_ERROR_NONE;
3048 static unsigned int req_id = 0;
3049 media_info_s *_media = (media_info_s*)media;
3050 char repl_path[MAX_PATH_LEN] = {0, };
3052 if (!__media_info_isFaceRecognition_feature_supported()) {
3053 media_content_error("NOT_SUPPORTED(0x%08x)", MEDIA_CONTENT_ERROR_NOT_SUPPORTED);
3054 return MEDIA_CONTENT_ERROR_NOT_SUPPORTED;
3057 if (_media != NULL && STRING_VALID(_media->media_id) && STRING_VALID(_media->file_path)) {
3058 memset(repl_path, 0, sizeof(repl_path));
3059 ret = _media_content_replace_path(_media->file_path, repl_path);
3060 media_content_retvm_if(!STRING_VALID(repl_path), MEDIA_CONTENT_ERROR_INVALID_OPERATION, "path replacement failed");
3061 media_face_cb_s *_face_cb = (media_face_cb_s*)calloc(1, sizeof(media_face_cb_s));
3062 media_content_retvm_if(_face_cb == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
3064 _media->face_request_id = req_id;
3066 _face_cb->handle = _media;
3067 _face_cb->user_data = user_data;
3068 _face_cb->face_completed_cb = callback;
3070 ret = dcm_request_extract_face_async(_media->face_request_id, repl_path, (FaceFunc)__media_info_face_completed_cb, (void *)_face_cb, tzplatform_getuid(TZ_USER_NAME));
3071 ret = _content_error_capi(MEDIA_THUMBNAIL_TYPE, ret);
3073 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
3074 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
3080 int media_info_cancel_face_detection(media_info_h media)
3082 int ret = MEDIA_CONTENT_ERROR_NONE;
3083 media_info_s *_media = (media_info_s*)media;
3084 char repl_path[MAX_PATH_LEN] = {0, };
3086 if (!__media_info_isFaceRecognition_feature_supported()) {
3087 media_content_error("NOT_SUPPORTED(0x%08x)", MEDIA_CONTENT_ERROR_NOT_SUPPORTED);
3088 return MEDIA_CONTENT_ERROR_NOT_SUPPORTED;
3091 if (_media != NULL && STRING_VALID(_media->media_id) && STRING_VALID(_media->file_path) && _media->face_request_id > 0) {
3092 memset(repl_path, 0, sizeof(repl_path));
3093 ret = _media_content_replace_path(_media->file_path, repl_path);
3094 media_content_retvm_if(!STRING_VALID(repl_path), MEDIA_CONTENT_ERROR_INVALID_OPERATION, "path replacement failed");
3095 ret = dcm_request_cancel_face(_media->face_request_id, repl_path);
3096 ret = _content_error_capi(MEDIA_THUMBNAIL_TYPE, ret);
3098 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
3099 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
3105 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)
3107 media_content_retvm_if(media == NULL, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid handle");
3108 char repl_path[MAX_PATH_LEN] = {0, };
3109 char *tmp_path = NULL;
3111 media_svc_content_info_s *svc_content_info = calloc(1, sizeof(media_svc_content_info_s));
3112 media_content_retvm_if(svc_content_info == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
3114 memset(repl_path, 0, sizeof(repl_path));
3115 tmp_path = g_strdup(media->file_path);
3116 _media_content_replace_path(tmp_path, repl_path);
3117 svc_content_info->path = g_strdup(repl_path);
3118 SAFE_FREE(tmp_path);
3120 svc_content_info->file_name = g_strdup(media->display_name);
3121 svc_content_info->media_type = media->media_type;
3122 svc_content_info->mime_type = g_strdup(media->mime_type);
3123 svc_content_info->size = media->size;
3124 svc_content_info->storage_type = storage_type;
3125 svc_content_info->storage_uuid = g_strdup(media->storage_uuid);
3127 svc_content_info->added_time = media->added_time;
3128 svc_content_info->modified_time = media->modified_time;
3129 svc_content_info->thumbnail_path = g_strdup(media->thumbnail_path);
3130 svc_content_info->is_drm = media->is_drm;
3131 svc_content_info->last_played_time = media->played_time;
3132 svc_content_info->played_count = media->played_count;
3133 svc_content_info->favourate = media->favourite;
3135 #ifdef _USE_SENIOR_MODE
3136 if (_media_content_is_support_senior_mode()) {
3137 svc_content_info->contact = g_strdup(media->contact);
3138 svc_content_info->app_data = g_strdup(media->app_data);
3142 svc_content_info->media_meta.title = g_strdup(media->title);
3143 svc_content_info->media_meta.rating = media->rating;
3144 svc_content_info->media_meta.description = g_strdup(media->description);
3145 svc_content_info->media_meta.longitude = media->longitude;
3146 svc_content_info->media_meta.latitude = media->latitude;
3147 svc_content_info->media_meta.altitude = media->altitude;
3148 svc_content_info->media_meta.weather = g_strdup(media->weather);
3149 svc_content_info->media_meta.category = g_strdup(media->category);
3150 svc_content_info->media_meta.keyword = g_strdup(media->keyword);
3151 svc_content_info->media_meta.location_tag = g_strdup(media->location_tag);
3152 svc_content_info->media_meta.content_name = g_strdup(media->content_name);
3153 svc_content_info->media_meta.age_rating = g_strdup(media->age_rating);
3154 svc_content_info->media_meta.author = g_strdup(media->author);
3155 svc_content_info->media_meta.provider = g_strdup(media->provider);
3157 svc_content_info->media_meta.album = g_strdup(media->audio_meta->album);
3158 svc_content_info->media_meta.artist = g_strdup(media->audio_meta->artist);
3159 svc_content_info->media_meta.genre = g_strdup(media->audio_meta->genre);
3160 svc_content_info->media_meta.recorded_date = g_strdup(media->audio_meta->recorded_date);
3162 *service_content = svc_content_info;
3164 return MEDIA_CONTENT_ERROR_NONE;
3167 static int __media_info_set_str_data(media_info_h media, media_info_item_e data_type, const char *str_data)
3169 media_info_s *_media = (media_info_s*)media;
3171 media_content_retvm_if(_media == NULL, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid media");
3173 switch (data_type) {
3174 case MEDIA_INFO_PATH:
3175 SAFE_FREE(_media->file_path);
3176 if (STRING_VALID(str_data)) {
3177 _media->file_path = strdup(str_data);
3178 media_content_retvm_if(_media->file_path == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
3180 _media->file_path = NULL;
3183 case MEDIA_INFO_MIME_TYPE:
3184 SAFE_FREE(_media->mime_type);
3185 if (STRING_VALID(str_data)) {
3186 _media->mime_type = strdup(str_data);
3187 media_content_retvm_if(_media->mime_type == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
3189 _media->mime_type = NULL;
3192 case MEDIA_INFO_THUMBNAIL_PATH:
3193 SAFE_FREE(_media->thumbnail_path);
3194 if (STRING_VALID(str_data)) {
3195 _media->thumbnail_path = strdup(str_data);
3196 media_content_retvm_if(_media->thumbnail_path == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
3198 _media->thumbnail_path = NULL;
3201 case MEDIA_INFO_TITLE:
3202 SAFE_FREE(_media->title);
3203 if (STRING_VALID(str_data)) {
3204 _media->title = strdup(str_data);
3205 media_content_retvm_if(_media->title == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
3207 _media->title = NULL;
3210 case MEDIA_INFO_STORAGE_UUID:
3211 SAFE_FREE(_media->storage_uuid);
3212 if (STRING_VALID(str_data)) {
3213 _media->storage_uuid = strdup(str_data);
3214 media_content_retvm_if(_media->storage_uuid == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
3216 _media->storage_uuid = NULL;
3219 case MEDIA_INFO_ALBUM:
3220 if (STRING_VALID(_media->media_id)) {
3221 if (_media->media_type == MEDIA_CONTENT_TYPE_VIDEO) {
3222 SAFE_FREE(_media->video_meta->album);
3223 if (str_data != NULL) {
3224 _media->video_meta->album = strdup(str_data);
3225 media_content_retvm_if(_media->video_meta->album == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
3227 } else if ((_media->media_type == MEDIA_CONTENT_TYPE_MUSIC) || (_media->media_type == MEDIA_CONTENT_TYPE_SOUND)) {
3228 SAFE_FREE(_media->audio_meta->album);
3229 if (str_data != NULL) {
3230 _media->audio_meta->album = strdup(str_data);
3231 media_content_retvm_if(_media->audio_meta->album == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
3235 SAFE_FREE(_media->video_meta->album);
3236 if (str_data != NULL) {
3237 _media->video_meta->album = strdup(str_data);
3238 media_content_retvm_if(_media->video_meta->album == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
3241 SAFE_FREE(_media->audio_meta->album);
3242 if (str_data != NULL) {
3243 _media->audio_meta->album = strdup(str_data);
3244 media_content_retvm_if(_media->audio_meta->album == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
3248 case MEDIA_INFO_ARTIST:
3249 if (STRING_VALID(_media->media_id)) {
3250 if (_media->media_type == MEDIA_CONTENT_TYPE_VIDEO) {
3251 SAFE_FREE(_media->video_meta->artist);
3252 if (str_data != NULL) {
3253 _media->video_meta->artist = strdup(str_data);
3254 media_content_retvm_if(_media->video_meta->artist == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
3256 } else if ((_media->media_type == MEDIA_CONTENT_TYPE_MUSIC) || (_media->media_type == MEDIA_CONTENT_TYPE_SOUND)) {
3257 SAFE_FREE(_media->audio_meta->artist);
3258 if (str_data != NULL) {
3259 _media->audio_meta->artist = strdup(str_data);
3260 media_content_retvm_if(_media->audio_meta->artist == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
3264 SAFE_FREE(_media->video_meta->artist);
3265 if (str_data != NULL) {
3266 _media->video_meta->artist = strdup(str_data);
3267 media_content_retvm_if(_media->video_meta->artist == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
3270 SAFE_FREE(_media->audio_meta->artist);
3271 if (str_data != NULL) {
3272 _media->audio_meta->artist = strdup(str_data);
3273 media_content_retvm_if(_media->audio_meta->artist == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
3277 case MEDIA_INFO_GENRE:
3278 if (STRING_VALID(_media->media_id)) {
3279 if (_media->media_type == MEDIA_CONTENT_TYPE_VIDEO) {
3280 SAFE_FREE(_media->video_meta->genre);
3281 if (str_data != NULL) {
3282 _media->video_meta->genre = strdup(str_data);
3283 media_content_retvm_if(_media->video_meta->genre == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
3285 } else if ((_media->media_type == MEDIA_CONTENT_TYPE_MUSIC) || (_media->media_type == MEDIA_CONTENT_TYPE_SOUND)) {
3286 SAFE_FREE(_media->audio_meta->genre);
3287 if (str_data != NULL) {
3288 _media->audio_meta->genre = strdup(str_data);
3289 media_content_retvm_if(_media->audio_meta->genre == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
3293 SAFE_FREE(_media->video_meta->genre);
3294 if (str_data != NULL) {
3295 _media->video_meta->genre = strdup(str_data);
3296 media_content_retvm_if(_media->video_meta->genre == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
3299 SAFE_FREE(_media->audio_meta->genre);
3300 if (str_data != NULL) {
3301 _media->audio_meta->genre = strdup(str_data);
3302 media_content_retvm_if(_media->audio_meta->genre == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
3306 case MEDIA_INFO_RECORDED_DATE:
3307 if (STRING_VALID(_media->media_id)) {
3308 if (_media->media_type == MEDIA_CONTENT_TYPE_VIDEO) {
3309 SAFE_FREE(_media->video_meta->recorded_date);
3310 if (str_data != NULL) {
3311 _media->video_meta->recorded_date = strdup(str_data);
3312 media_content_retvm_if(_media->video_meta->recorded_date == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
3314 } else if ((_media->media_type == MEDIA_CONTENT_TYPE_MUSIC) || (_media->media_type == MEDIA_CONTENT_TYPE_SOUND)) {
3315 SAFE_FREE(_media->audio_meta->recorded_date);
3316 if (str_data != NULL) {
3317 _media->audio_meta->recorded_date = strdup(str_data);
3318 media_content_retvm_if(_media->audio_meta->recorded_date == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
3322 SAFE_FREE(_media->video_meta->recorded_date);
3323 if (str_data != NULL) {
3324 _media->video_meta->recorded_date = strdup(str_data);
3325 media_content_retvm_if(_media->video_meta->recorded_date == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
3328 SAFE_FREE(_media->audio_meta->recorded_date);
3329 if (str_data != NULL) {
3330 _media->audio_meta->recorded_date = strdup(str_data);
3331 media_content_retvm_if(_media->audio_meta->recorded_date == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
3336 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
3337 return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
3340 return MEDIA_CONTENT_ERROR_NONE;
3343 static int __media_info_destroy(media_info_h media)
3345 int ret = MEDIA_CONTENT_ERROR_NONE;
3346 media_info_s *_media = (media_info_s*)media;
3349 SAFE_FREE(_media->media_id);
3350 SAFE_FREE(_media->file_path);
3351 SAFE_FREE(_media->display_name);
3352 SAFE_FREE(_media->mime_type);
3353 SAFE_FREE(_media->thumbnail_path);
3354 SAFE_FREE(_media->description);
3355 SAFE_FREE(_media->author);
3356 SAFE_FREE(_media->provider);
3357 SAFE_FREE(_media->content_name);
3358 SAFE_FREE(_media->category);
3359 SAFE_FREE(_media->location_tag);
3360 SAFE_FREE(_media->age_rating);
3361 SAFE_FREE(_media->keyword);
3362 SAFE_FREE(_media->title);
3363 SAFE_FREE(_media->weather);
3364 SAFE_FREE(_media->storage_uuid);
3366 if (_media->image_meta) {
3367 SAFE_FREE(_media->image_meta->media_id);
3368 SAFE_FREE(_media->image_meta->date_taken);
3369 SAFE_FREE(_media->image_meta->burst_id);
3370 SAFE_FREE(_media->image_meta->exposure_time);
3371 SAFE_FREE(_media->image_meta->model);
3372 SAFE_FREE(_media->image_meta->title);
3373 SAFE_FREE(_media->image_meta->weather);
3375 SAFE_FREE(_media->image_meta);
3378 if (_media->video_meta) {
3379 SAFE_FREE(_media->video_meta->media_id);
3380 SAFE_FREE(_media->video_meta->title);
3381 SAFE_FREE(_media->video_meta->album);
3382 SAFE_FREE(_media->video_meta->artist);
3383 SAFE_FREE(_media->video_meta->album_artist);
3384 SAFE_FREE(_media->video_meta->genre);
3385 SAFE_FREE(_media->video_meta->composer);
3386 SAFE_FREE(_media->video_meta->year);
3387 SAFE_FREE(_media->video_meta->recorded_date);
3388 SAFE_FREE(_media->video_meta->copyright);
3389 SAFE_FREE(_media->video_meta->track_num);
3391 SAFE_FREE(_media->video_meta);
3394 if (_media->audio_meta) {
3395 SAFE_FREE(_media->audio_meta->media_id);
3396 SAFE_FREE(_media->audio_meta->title);
3397 SAFE_FREE(_media->audio_meta->album);
3398 SAFE_FREE(_media->audio_meta->artist);
3399 SAFE_FREE(_media->audio_meta->album_artist);
3400 SAFE_FREE(_media->audio_meta->genre);
3401 SAFE_FREE(_media->audio_meta->composer);
3402 SAFE_FREE(_media->audio_meta->year);
3403 SAFE_FREE(_media->audio_meta->recorded_date);
3404 SAFE_FREE(_media->audio_meta->copyright);
3405 SAFE_FREE(_media->audio_meta->track_num);
3407 SAFE_FREE(_media->audio_meta);
3410 ret = MEDIA_CONTENT_ERROR_NONE;
3412 media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
3413 ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
3419 int media_info_insert_to_db_with_data(media_info_h media)
3421 int ret = MEDIA_CONTENT_ERROR_NONE;
3423 char repl_path[MAX_PATH_LEN] = {0, };
3425 media_content_warn("DEPRECATION WARNING: media_info_insert_to_db_with_data() is deprecated and will be removed from next release. Use media_info_insert_to_db() instead.");
3427 media_info_s *_media = (media_info_s*)media;
3429 media_content_retvm_if(_media == NULL, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid media");
3430 media_content_retvm_if(!STRING_VALID(_media->file_path), MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid file_path");
3431 media_content_retvm_if(!STRING_VALID(_media->storage_uuid), MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid storage_uuid");
3432 media_content_retvm_if(_media->storage_type < 0, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid storage_type [%d]", _media->storage_type);
3434 media_content_sec_debug("storage[%d], path[%s], media_type[%d]", _media->storage_type, _media->file_path, _media->media_type);
3436 media_svc_content_info_s *svc_content_info = NULL;
3438 ret = __media_info_map_data_usr_to_svc(_media, &svc_content_info, _media->storage_type);
3439 media_content_retvm_if(ret != MEDIA_CONTENT_ERROR_NONE, ret, "__media_info_map_data_usr_to_svc fail");
3441 ret = media_svc_insert_item_immediately_with_data(_content_get_db_handle(), svc_content_info, tzplatform_getuid(TZ_USER_NAME));
3442 if (ret != MS_MEDIA_ERR_NONE) {
3443 media_content_sec_error("media_svc_insert_item_immediately_with_data failed : %d (%s)", ret, _media->file_path);
3444 media_svc_destroy_content_info(svc_content_info);
3445 SAFE_FREE(svc_content_info);
3446 return _content_error_capi(MEDIA_CONTENT_TYPE, ret);
3448 /*free the svc_content_info*/
3449 media_svc_destroy_content_info(svc_content_info);
3450 SAFE_FREE(svc_content_info);
3452 /*Fill out the handle*/
3453 memset(repl_path, 0, sizeof(repl_path));
3454 ret = _media_content_replace_path(_media->file_path, repl_path);
3455 char *media_file_path = g_strdup(repl_path);
3457 char *media_string_uuid = g_strdup(_media->storage_uuid);
3459 __media_info_destroy(media);
3461 ret = _media_info_get_media_info_from_db(media_file_path, media_string_uuid, media);
3462 if (ret != MEDIA_CONTENT_ERROR_NONE) {
3463 media_content_error("_media_info_get_media_info_from_db fail", ret);
3464 if (ret == MEDIA_CONTENT_ERROR_DB_FAILED && ret_cnt < 5) {
3466 media_content_error("RETRY GETTING DATA");
3471 SAFE_FREE(media_file_path);
3472 SAFE_FREE(media_string_uuid);
3477 int media_info_create(const char *path, media_info_h *media)
3479 int ret = MEDIA_CONTENT_ERROR_NONE;
3480 char storage_id[MEDIA_CONTENT_UUID_SIZE+1] = {0, };
3481 media_svc_storage_type_e storage_type = 0;
3482 bool ignore_file = FALSE;
3483 char repl_path[MAX_PATH_LEN] = {0, };
3484 media_content_warn("DEPRECATION WARNING: media_info_create() is deprecated and will be removed from next release. Use media_info_insert_to_db() instead.");
3486 media_content_retvm_if(!STRING_VALID(path), MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid path");
3487 media_content_retvm_if(media == NULL, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid media");
3488 memset(repl_path, 0, sizeof(repl_path));
3489 ret = _media_content_replace_path(path, repl_path);
3490 media_content_retvm_if(!STRING_VALID(repl_path), MEDIA_CONTENT_ERROR_INVALID_OPERATION, "path replacement failed");
3492 ret = _media_util_check_ignore_file(repl_path, &ignore_file);
3493 media_content_retvm_if(ignore_file == TRUE, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid path");
3495 memset(storage_id, 0x00, sizeof(storage_id));
3497 bool ignore_dir = FALSE;
3498 char *folder_path = NULL;
3500 ret = _media_util_check_file_exist(repl_path);
3501 media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
3503 folder_path = g_path_get_dirname(repl_path);
3504 ret = _media_util_check_ignore_dir(folder_path, &ignore_dir);
3505 SAFE_FREE(folder_path);
3506 media_content_retvm_if(ignore_dir == TRUE, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid folder path");
3508 ret = media_svc_get_storage_id(_content_get_db_handle(), repl_path, storage_id, tzplatform_getuid(TZ_USER_NAME));
3509 if (ret != MS_MEDIA_ERR_NONE) {
3510 media_content_error("media_svc_get_storage_id failed : %d", ret);
3511 return _content_error_capi(MEDIA_CONTENT_TYPE, ret);
3514 ret = media_svc_get_storage_type(repl_path, &storage_type, tzplatform_getuid(TZ_USER_NAME));
3515 if (ret != MS_MEDIA_ERR_NONE) {
3516 media_content_sec_error("media_svc_get_storage_type failed : %d", ret);
3517 return _content_error_capi(MEDIA_CONTENT_TYPE, ret);
3520 media_info_s *_media = (media_info_s*)calloc(1, sizeof(media_info_s));
3521 media_content_retvm_if(_media == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
3523 _media->audio_meta = (audio_meta_s *)calloc(1, sizeof(audio_meta_s));
3524 if (_media->audio_meta == NULL) {
3526 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
3527 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
3530 _media->video_meta = (video_meta_s *)calloc(1, sizeof(video_meta_s));
3531 if (_media->video_meta == NULL) {
3532 SAFE_FREE(_media->audio_meta);
3534 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
3535 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
3538 _media->image_meta = (image_meta_s *)calloc(1, sizeof(image_meta_s));
3539 if (_media->image_meta == NULL) {
3540 SAFE_FREE(_media->audio_meta);
3541 SAFE_FREE(_media->video_meta);
3543 media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
3544 return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
3547 _media->file_path = g_strdup(path);
3548 _media->storage_type = -1;
3549 _media->media_type = 0;
3550 _media->modified_time = 0;
3552 _media->request_id = 0;
3553 _media->longitude = MEDIA_SVC_DEFAULT_GPS_VALUE;
3554 _media->latitude = MEDIA_SVC_DEFAULT_GPS_VALUE;
3555 _media->altitude = MEDIA_SVC_DEFAULT_GPS_VALUE;
3557 if (STRING_VALID(storage_id)) {
3558 _media->storage_uuid = g_strdup(storage_id);
3559 _media->storage_type = storage_type;
3562 *media = (media_info_h)_media;
3567 int media_info_set_title(media_info_h media, const char *title)
3569 media_content_warn("DEPRECATION WARNING: media_info_set_title() is deprecated and will be removed from next release.");
3571 return __media_info_set_str_data(media, MEDIA_INFO_TITLE, title);
3574 int media_info_set_album(media_info_h media, const char *album)
3576 media_content_warn("DEPRECATION WARNING: media_info_set_album() is deprecated and will be removed from next release.");
3578 return __media_info_set_str_data(media, MEDIA_INFO_ALBUM, album);
3581 int media_info_set_artist(media_info_h media, const char *artist)
3583 media_content_warn("DEPRECATION WARNING: media_info_set_artist() is deprecated and will be removed from next release.");
3585 return __media_info_set_str_data(media, MEDIA_INFO_ARTIST, artist);
3588 int media_info_set_genre(media_info_h media, const char *genre)
3590 media_content_warn("DEPRECATION WARNING: media_info_set_genre() is deprecated and will be removed from next release.");
3592 return __media_info_set_str_data(media, MEDIA_INFO_GENRE, genre);
3595 int media_info_set_recorded_date(media_info_h media, const char *recorded_date)
3597 media_content_warn("DEPRECATION WARNING: media_info_set_recorded_date() is deprecated and will be removed from next release.");
3599 return __media_info_set_str_data(media, MEDIA_INFO_RECORDED_DATE, recorded_date);
3602 #ifdef _USE_SENIOR_MODE
3603 int media_info_set_contact(media_info_h media, const char *contact)
3605 return __media_info_set_str_data(media, MEDIA_INFO_CONTACT, contact);
3608 int media_info_set_app_data(media_info_h media, const char *app_data)
3610 return __media_info_set_str_data(media, MEDIA_INFO_APP_DATA, app_data);