#include <media_util_private.h>
#include <system_info.h>
-
static void __media_info_insert_completed_cb(media_request_result_s *result, void *user_data);
static void __media_info_thumbnail_completed_cb(int error, const char *path, void *user_data);
static void __media_info_face_completed_cb(int error, const int face_count, void *user_data);
-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);
-static int __media_info_set_str_data(media_info_h media, media_info_item_e data_type, const char *str_data);
+static int __media_info_insert_batch(const char **path_array, unsigned int array_length, media_insert_completed_cb completed_cb, void *user_data);
static int __media_info_check_file_validity(const char *path);
static int __media_info_get_media_path_by_id_from_db(const char *media_id, char **path)
sqlite3_stmt *stmt = NULL;
char *select_query = NULL;
- media_content_retvm_if(!STRING_VALID(media_id), MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "invalid media_id");
+ content_retip_if_fail(STRING_VALID(media_id));
select_query = sqlite3_mprintf(SELECT_MEDIA_PATH_BY_ID, media_id);
- ret = _content_query_prepare(&stmt, select_query, NULL, NULL);
+ ret = _content_get_result(select_query, &stmt);
SQLITE3_SAFE_FREE(select_query);
- media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
+ content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
if (sqlite3_step(stmt) == SQLITE_ROW) {
*path = g_strdup((const char *)sqlite3_column_text(stmt, 0));
} else {
- media_content_error("There's no media with this ID : %s", media_id);
+ content_error("There's no media with this ID : %s", media_id);
*path = NULL;
ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
}
if (_cb_data) {
if (result)
- ret = _content_error_capi(MEDIA_CONTENT_TYPE, result->result);
+ ret = _content_error_capi(result->result);
- if (_cb_data->insert_completed_cb)
+ if (_cb_data->insert_completed_cb) {
+ content_debug("User callback is being called now");
_cb_data->insert_completed_cb(ret, _cb_data->user_data);
+ }
if (STRING_VALID(_cb_data->insert_list_path)) {
if (unlink(_cb_data->insert_list_path) < 0)
- media_content_stderror("failed to delete");
- SAFE_FREE(_cb_data->insert_list_path);
+ content_stderror("failed to delete");
+ g_free(_cb_data->insert_list_path);
}
}
- SAFE_FREE(_cb_data);
+ g_free(_cb_data);
return;
}
media = _thumb_cb->handle;
if (media != NULL) {
- if (media->thumbnail_path != NULL)
- SAFE_FREE(media->thumbnail_path);
+ g_free(media->thumbnail_path);
if (STRING_VALID(path))
media->thumbnail_path = g_strdup(path);
else
- media->thumbnail_path = g_strdup(EMPTY_STR);
+ media->thumbnail_path = g_strdup(MEDIA_CONTENT_EMPTY_STRING);
}
- media_content_debug("error [%d], thumbnail_path [%s]", error, path);
- error_value = _content_error_capi(MEDIA_THUMBNAIL_TYPE, error);
+ content_debug("error [%d], thumbnail_path [%s]", error, path);
+ error_value = _content_error_capi(error);
if (_thumb_cb->thumbnail_completed_cb)
_thumb_cb->thumbnail_completed_cb(error_value, path, _thumb_cb->user_data);
}
- SAFE_FREE(_thumb_cb);
+ g_free(_thumb_cb);
return;
}
const int nRetVal = system_info_get_platform_bool("http://tizen.org/feature/vision.face_recognition", &isFaceRecognitionSupported);
if (nRetVal != SYSTEM_INFO_ERROR_NONE) {
- media_content_debug("SYSTEM_INFO_ERROR: vision.face_recognition [%d]", nRetVal);
+ content_debug("SYSTEM_INFO_ERROR: vision.face_recognition [%d]", nRetVal);
return false;
}
media_face_cb_s *_face_cb = (media_face_cb_s *)user_data;
if (_face_cb != NULL) {
- media_content_debug("error [%d], face_count [%d]", error, face_count);
- error_value = _content_error_capi(MEDIA_THUMBNAIL_TYPE, error);
+ content_debug("error [%d], face_count [%d]", error, face_count);
+ error_value = _content_error_capi(error);
if (_face_cb->face_completed_cb)
_face_cb->face_completed_cb(error_value, face_count, _face_cb->user_data);
}
- SAFE_FREE(_face_cb);
+ g_free(_face_cb);
return;
}
-static int __media_info_insert_batch(media_batch_insert_e insert_type, const char **path_array,
+static int __media_info_insert_batch(const char **path_array,
unsigned int array_length,
media_insert_completed_cb completed_cb,
void *user_data)
memset(list_path, 0x00, sizeof(list_path));
continue;
} else {
- media_content_debug("The request file list path : %s", list_path);
+ content_sec_debug("The request file list path : %s", list_path);
break;
}
}
if (idx == BATCH_REQUEST_MAX) {
- media_content_error("Too many batch request for one thread");
+ content_error("Too many batch request for one thread");
return MEDIA_CONTENT_ERROR_DB_BUSY;
}
fp = fopen(list_path, "w");
if (fp == NULL) {
- media_content_error("failed to open file : [%s]", list_path);
- media_content_stderror("failed to open file");
+ content_sec_error("failed to open file : [%s]", list_path);
+ content_stderror("failed to open file");
return MEDIA_CONTENT_ERROR_INVALID_OPERATION;
}
if (ret != MEDIA_CONTENT_ERROR_NONE) {
fclose(fp);
if (unlink(list_path) < 0)
- media_content_stderror("failed to delete");
+ content_stderror("failed to delete");
return ret;
}
+ if (!_media_util_check_support_media_type(path_array[idx])) {
+ fclose(fp);
+ if (unlink(list_path) < 0)
+ content_stderror("failed to delete");
+ return MEDIA_CONTENT_ERROR_NOT_SUPPORTED;
+ }
+
nwrites = fwrite(path_array[idx], 1, size, fp);
if (nwrites != size) {
- media_content_stderror("failed to write");
+ content_stderror("failed to write");
fclose(fp);
if (unlink(list_path) < 0)
- media_content_stderror("failed to delete");
+ content_stderror("failed to delete");
return MEDIA_CONTENT_ERROR_INVALID_OPERATION;
}
nwrites = fwrite("\n", 1, 1, fp);
if (nwrites != 1) {
- media_content_stderror("failed to write");
+ content_stderror("failed to write");
fclose(fp);
if (unlink(list_path) < 0)
- media_content_stderror("failed to delete");
+ content_stderror("failed to delete");
return MEDIA_CONTENT_ERROR_INVALID_OPERATION;
}
} else {
- media_content_error("path[%d] is invalid string", idx);
+ content_error("path[%d] is invalid string", idx);
}
}
fclose(fp);
- media_insert_cb_s *_cb_data = (media_insert_cb_s *)calloc(1, sizeof(media_insert_cb_s));
- media_content_retvm_if(_cb_data == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
+ media_insert_cb_s *_cb_data = g_new0(media_insert_cb_s, 1);
_cb_data->insert_completed_cb = completed_cb;
_cb_data->user_data = user_data;
_cb_data->insert_list_path = g_strdup(list_path);
- if (insert_type == MEDIA_BATCH_INSERT_NORMAL)
- ret = media_files_register(list_path, __media_info_insert_completed_cb, _cb_data, _content_get_uid());
- else if (insert_type == MEDIA_BATCH_INSERT_BURSTSHOT)
- ret = media_burstshot_register(list_path, __media_info_insert_completed_cb, _cb_data, _content_get_uid());
- else
- ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
-
+ ret = media_files_register(list_path, __media_info_insert_completed_cb, _cb_data, _content_get_uid());
if (ret != MEDIA_CONTENT_ERROR_NONE) {
- media_content_error("media_files_register failed : %d", ret);
+ content_error("media_files_register failed : %d", ret);
if (unlink(list_path) < 0)
- media_content_stderror("failed to delete");
- return _content_error_capi(MEDIA_CONTENT_TYPE, ret);
- }
-
- return ret;
-}
-
-int __media_info_get_storage_list_to_remove(const char *condition_query, GArray **storage_list)
-{
- int ret = MEDIA_CONTENT_ERROR_NONE;
- char *query_string = NULL;
- sqlite3_stmt *stmt = NULL;
-
- media_content_retv_if(storage_list == NULL, MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- media_content_retv_if(!STRING_VALID(condition_query), MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
-
- query_string = sqlite3_mprintf(SELECT_STORAGE_BY_FILTER, condition_query);
-
- ret = _content_query_prepare(&stmt, query_string, NULL, NULL);
- SQLITE3_SAFE_FREE(query_string);
-
- media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
-
- *storage_list = g_array_new(FALSE, FALSE, sizeof(media_storage_s *));
-
- while (sqlite3_step(stmt) == SQLITE_ROW) {
- media_storage_s *storage = (media_storage_s*)calloc(1, sizeof(media_storage_s));
- if (storage == NULL) {
- media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
- SQLITE3_FINALIZE(stmt);
- return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
- }
- storage->storage_id = g_strdup((const char *)sqlite3_column_text(stmt, 0));
- storage->storage_type = (int)sqlite3_column_int(stmt, 1);
-
- g_array_append_val(*storage_list, storage);
- }
-
- SQLITE3_FINALIZE(stmt);
-
- return ret;
-}
-
-int __media_info_get_thumbnail_to_remove(const char *condition_query, const char *storage_id, int storage_type, GArray **thumb_list)
-{
- int ret = MEDIA_CONTENT_ERROR_NONE;
- char *query_string = NULL;
- char *thumbnail_path = NULL;
- sqlite3_stmt *stmt = NULL;
-
- media_content_retv_if(thumb_list == NULL, MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- media_content_retv_if(storage_id == NULL, MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- media_content_retv_if(!STRING_VALID(condition_query), MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
-
- query_string = sqlite3_mprintf(SELECT_THUMBNAIL_BY_FILTER, storage_id, condition_query, storage_type);
-
- ret = _content_query_prepare(&stmt, query_string, NULL, NULL);
- SQLITE3_SAFE_FREE(query_string);
-
- media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
-
- *thumb_list = g_array_new(FALSE, FALSE, sizeof(char*));
-
- while (sqlite3_step(stmt) == SQLITE_ROW) {
- thumbnail_path = g_strdup((const char *)sqlite3_column_text(stmt, 0));
- if (STRING_VALID(thumbnail_path))
- g_array_append_val(*thumb_list, thumbnail_path);
- else
- SAFE_FREE(thumbnail_path);
+ content_stderror("failed to delete");
+ return _content_error_capi(ret);
}
- SQLITE3_FINALIZE(stmt);
-
return ret;
}
static int __media_info_check_file_validity(const char *path)
{
- bool ignore = FALSE;
char *folder_path = NULL;
int ret = MEDIA_CONTENT_ERROR_NONE;
- media_content_retvm_if(!STRING_VALID(path), MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "invalid path");
+ content_retip_if_fail(path);
- ret = _media_util_check_ignore_file(path, &ignore);
- media_content_retvm_if(ignore == TRUE, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid ignore path");
+ content_retvm_if(_media_util_is_ignorable_file(path), MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid ignore path");
ret = _media_util_check_file_exist(path);
- media_content_retvm_if(ret != MEDIA_CONTENT_ERROR_NONE, ret, "invalid path");
+ content_retvm_if(ret != MEDIA_CONTENT_ERROR_NONE, ret, "invalid path");
folder_path = g_path_get_dirname(path);
- ret = _media_util_check_ignore_dir(folder_path, &ignore);
- SAFE_FREE(folder_path);
- media_content_retvm_if(ignore == TRUE, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid folder path");
+ if (_media_util_is_ignorable_dir(folder_path))
+ ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
- return MEDIA_CONTENT_ERROR_NONE;
+ g_free(folder_path);
+
+ return ret;
}
void _media_info_item_get_detail(sqlite3_stmt* stmt, media_info_h media)
{
media_info_s *_media = (media_info_s*)media;
- char *tmp_path = NULL;
- char repl_path[MAX_PATH_LEN] = {0, };
+ if (!_media)
+ return;
_media->media_id = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_UUID));
-
- tmp_path = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_PATH));
- _media_content_rollback_path(tmp_path, repl_path);
- _media->file_path = g_strdup(repl_path);
- SAFE_FREE(tmp_path);
-
+ _media->file_path = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_PATH));
_media->display_name = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_FILE_NAME));
_media->media_type = (int)sqlite3_column_int(stmt, MEDIA_INFO_TYPE);
_media->mime_type = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_MIME_TYPE));
_media->description = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_DESCRIPTION));
_media->rating = (int)sqlite3_column_int(stmt, MEDIA_INFO_RATING);
_media->favourite = (int)sqlite3_column_int(stmt, MEDIA_INFO_FAVOURITE);
- _media->author = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_AUTHOR));
- _media->provider = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_PROVIDER));
- _media->content_name = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_CONTENT_NAME));
- _media->category = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_CATEGORY));
- _media->location_tag = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_LOCATION_TAG));
- _media->age_rating = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_AGE_RATING));
- _media->keyword = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_KEYWORD));
_media->is_drm = (int)sqlite3_column_int(stmt, MEDIA_INFO_IS_DRM);
_media->storage_type = (int)sqlite3_column_int(stmt, MEDIA_INFO_STORAGE_TYPE);
_media->longitude = (double)sqlite3_column_double(stmt, MEDIA_INFO_LONGITUDE);
_media->latitude = (double)sqlite3_column_double(stmt, MEDIA_INFO_LATITUDE);
_media->altitude = (double)sqlite3_column_double(stmt, MEDIA_INFO_ALTITUDE);
- _media->played_count = sqlite3_column_int(stmt, MEDIA_INFO_PLAYED_COUNT);
- _media->played_time = sqlite3_column_int(stmt, MEDIA_INFO_LAST_PLAYED_TIME);
- _media->played_position = sqlite3_column_int(stmt, MEDIA_INFO_LAST_PLAYED_POSITION);
_media->title = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_TITLE));
_media->timeline = (double)sqlite3_column_double(stmt, MEDIA_INFO_TIMELINE);
- _media->weather = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_WEATHER));
- _media->sync_status = (int)sqlite3_column_int(stmt, MEDIA_INFO_SYNC_STATUS);
_media->storage_uuid = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_STORAGE_UUID));
_media->is_360 = (int)sqlite3_column_int(stmt, MEDIA_INFO_IS_360);
#ifdef _USE_TVPD_MODE
+ _media->played_count = sqlite3_column_int(stmt, MEDIA_INFO_PLAYED_COUNT);
+ _media->played_time = sqlite3_column_int(stmt, MEDIA_INFO_LAST_PLAYED_TIME);
+ _media->played_position = sqlite3_column_int(stmt, MEDIA_INFO_LAST_PLAYED_POSITION);
_media->stitched_info = (int)sqlite3_column_int(stmt, MEDIA_INFO_STITCHED_INFO);
#endif
if (_media->media_type == MEDIA_CONTENT_TYPE_IMAGE) {
- _media->image_meta = (image_meta_s *)calloc(1, sizeof(image_meta_s));
- if (_media->image_meta) {
- _media->image_meta->media_id = g_strdup(_media->media_id);
- _media->image_meta->width = sqlite3_column_int(stmt, MEDIA_INFO_WIDTH);
- _media->image_meta->height = sqlite3_column_int(stmt, MEDIA_INFO_HEIGHT);
- _media->image_meta->fnumber = (double)sqlite3_column_double(stmt, MEDIA_INFO_FNUMBER);
- _media->image_meta->iso = sqlite3_column_int(stmt, MEDIA_INFO_ISO);
- _media->image_meta->date_taken = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_DATETAKEN));
- _media->image_meta->orientation = sqlite3_column_int(stmt, MEDIA_INFO_ORIENTATION);
- _media->image_meta->title = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_TITLE));
- _media->image_meta->burst_id = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_BURST_ID));
- _media->image_meta->weather = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_WEATHER));
- _media->image_meta->exposure_time = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_EXPOSURE_TIME));
- _media->image_meta->model = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_MODEL));
- }
+ _media->image_meta = g_new0(image_meta_s, 1);
+
+ _media->image_meta->media_id = g_strdup(_media->media_id);
+ _media->image_meta->width = sqlite3_column_int(stmt, MEDIA_INFO_WIDTH);
+ _media->image_meta->height = sqlite3_column_int(stmt, MEDIA_INFO_HEIGHT);
+ _media->image_meta->fnumber = (double)sqlite3_column_double(stmt, MEDIA_INFO_FNUMBER);
+ _media->image_meta->iso = sqlite3_column_int(stmt, MEDIA_INFO_ISO);
+ _media->image_meta->date_taken = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_DATETAKEN));
+ _media->image_meta->orientation = sqlite3_column_int(stmt, MEDIA_INFO_ORIENTATION);
+ _media->image_meta->exposure_time = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_EXPOSURE_TIME));
+ _media->image_meta->model = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_MODEL));
+
} else if (_media->media_type == MEDIA_CONTENT_TYPE_VIDEO) {
- _media->video_meta = (video_meta_s *)calloc(1, sizeof(video_meta_s));
- if (_media->video_meta) {
- _media->video_meta->media_id = g_strdup(_media->media_id);
- _media->video_meta->width = sqlite3_column_int(stmt, MEDIA_INFO_WIDTH);
- _media->video_meta->height = sqlite3_column_int(stmt, MEDIA_INFO_HEIGHT);
- _media->video_meta->title = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_TITLE));
- _media->video_meta->album = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_ALBUM));
- _media->video_meta->artist = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_ARTIST));
- _media->video_meta->album_artist = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_ALBUM_ARTIST));
- _media->video_meta->genre = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_GENRE));
- _media->video_meta->composer = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_COMPOSER));
- _media->video_meta->year = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_YEAR));
- _media->video_meta->recorded_date = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_RECORDED_DATE));
- _media->video_meta->copyright = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_COPYRIGHT));
- _media->video_meta->track_num = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_TRACK_NUM));
- _media->video_meta->bitrate = sqlite3_column_int(stmt, MEDIA_INFO_BITRATE);
- _media->video_meta->duration = sqlite3_column_int(stmt, MEDIA_INFO_DURATION);
- _media->video_meta->played_count = sqlite3_column_int(stmt, MEDIA_INFO_PLAYED_COUNT);
- _media->video_meta->played_time = sqlite3_column_int(stmt, MEDIA_INFO_LAST_PLAYED_TIME);
- _media->video_meta->played_position = sqlite3_column_int(stmt, MEDIA_INFO_LAST_PLAYED_POSITION);
- _media->video_meta->rotation = sqlite3_column_int(stmt, MEDIA_INFO_ORIENTATION);
- }
+ _media->video_meta = g_new0(video_meta_s, 1);
+
+ _media->video_meta->media_id = g_strdup(_media->media_id);
+ _media->video_meta->width = sqlite3_column_int(stmt, MEDIA_INFO_WIDTH);
+ _media->video_meta->height = sqlite3_column_int(stmt, MEDIA_INFO_HEIGHT);
+ _media->video_meta->album = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_ALBUM));
+ _media->video_meta->artist = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_ARTIST));
+ _media->video_meta->album_artist = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_ALBUM_ARTIST));
+ _media->video_meta->genre = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_GENRE));
+ _media->video_meta->composer = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_COMPOSER));
+ _media->video_meta->year = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_YEAR));
+ _media->video_meta->recorded_date = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_RECORDED_DATE));
+ _media->video_meta->copyright = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_COPYRIGHT));
+ _media->video_meta->track_num = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_TRACK_NUM));
+ _media->video_meta->bitrate = sqlite3_column_int(stmt, MEDIA_INFO_BITRATE);
+ _media->video_meta->duration = sqlite3_column_int(stmt, MEDIA_INFO_DURATION);
+ _media->video_meta->rotation = sqlite3_column_int(stmt, MEDIA_INFO_ORIENTATION);
} else if ((_media->media_type == MEDIA_CONTENT_TYPE_MUSIC) || (_media->media_type == MEDIA_CONTENT_TYPE_SOUND)) {
- _media->audio_meta = (audio_meta_s *)calloc(1, sizeof(audio_meta_s));
- if (_media->audio_meta) {
- _media->audio_meta->media_id = g_strdup(_media->media_id);
- _media->audio_meta->title = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_TITLE));
- _media->audio_meta->album = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_ALBUM));
- _media->audio_meta->artist = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_ARTIST));
- _media->audio_meta->album_artist = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_ALBUM_ARTIST));
- _media->audio_meta->genre = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_GENRE));
- _media->audio_meta->composer = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_COMPOSER));
- _media->audio_meta->year = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_YEAR));
- _media->audio_meta->recorded_date = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_RECORDED_DATE));
- _media->audio_meta->copyright = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_COPYRIGHT));
- _media->audio_meta->track_num = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_TRACK_NUM));
- _media->audio_meta->bitrate = sqlite3_column_int(stmt, MEDIA_INFO_BITRATE);
- _media->audio_meta->bitpersample = sqlite3_column_int(stmt, MEDIA_INFO_BITPERSAMPLE);
- _media->audio_meta->duration = sqlite3_column_int(stmt, MEDIA_INFO_DURATION);
- _media->audio_meta->played_count = sqlite3_column_int(stmt, MEDIA_INFO_PLAYED_COUNT);
- _media->audio_meta->played_time = sqlite3_column_int(stmt, MEDIA_INFO_LAST_PLAYED_TIME);
- _media->audio_meta->played_position = sqlite3_column_int(stmt, MEDIA_INFO_LAST_PLAYED_POSITION);
- _media->audio_meta->samplerate = sqlite3_column_int(stmt, MEDIA_INFO_SAMPLERATE);
- _media->audio_meta->channel = sqlite3_column_int(stmt, MEDIA_INFO_CHANNEL);
- }
+ _media->audio_meta = g_new0(audio_meta_s, 1);
+
+ _media->audio_meta->media_id = g_strdup(_media->media_id);
+ _media->audio_meta->album = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_ALBUM));
+ _media->audio_meta->artist = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_ARTIST));
+ _media->audio_meta->album_artist = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_ALBUM_ARTIST));
+ _media->audio_meta->genre = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_GENRE));
+ _media->audio_meta->composer = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_COMPOSER));
+ _media->audio_meta->year = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_YEAR));
+ _media->audio_meta->recorded_date = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_RECORDED_DATE));
+ _media->audio_meta->copyright = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_COPYRIGHT));
+ _media->audio_meta->track_num = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_TRACK_NUM));
+ _media->audio_meta->bitrate = sqlite3_column_int(stmt, MEDIA_INFO_BITRATE);
+ _media->audio_meta->bitpersample = sqlite3_column_int(stmt, MEDIA_INFO_BITPERSAMPLE);
+ _media->audio_meta->duration = sqlite3_column_int(stmt, MEDIA_INFO_DURATION);
+ _media->audio_meta->samplerate = sqlite3_column_int(stmt, MEDIA_INFO_SAMPLERATE);
+ _media->audio_meta->channel = sqlite3_column_int(stmt, MEDIA_INFO_CHANNEL);
+
}
}
-
+#ifdef _USE_TVPD_MODE
int _media_info_get_media_info_from_db(const char *path, const char *storage_id, media_info_h media)
{
int ret = MEDIA_CONTENT_ERROR_NONE;
char *select_query = NULL;
media_info_s *_media = (media_info_s*)media;
- media_content_retvm_if(_media == NULL, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "invalid media");
+ content_retip_if_fail(media);
select_query = sqlite3_mprintf(SELECT_MEDIA_BY_PATH, storage_id, path);
- ret = _content_query_prepare(&stmt, select_query, NULL, NULL);
+ ret = _content_get_result(select_query, &stmt);
SQLITE3_SAFE_FREE(select_query);
- media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
+ content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
if (sqlite3_step(stmt) == SQLITE_ROW) {
_media_info_item_get_detail(stmt, (media_info_h)_media);
} else {
- media_content_error("There's no media!!");
- media_content_error("%s", path);
- media_content_error("%s", storage_id);
+ content_sec_error("No media : path[%s] storage id[%s]", path, storage_id);
ret = MEDIA_CONTENT_ERROR_DB_FAILED;
}
return ret;
}
+#else
+int _media_info_get_media_info_from_db(const char *path, media_info_h media)
+{
+ int ret = MEDIA_CONTENT_ERROR_NONE;
+ sqlite3_stmt *stmt = NULL;
+ char *select_query = NULL;
+ media_info_s *_media = (media_info_s*)media;
+
+ content_retip_if_fail(path);
+ content_retip_if_fail(media);
+
+ select_query = sqlite3_mprintf(SELECT_MEDIA_BY_PATH, path);
+
+ ret = _content_get_result(select_query, &stmt);
+ SQLITE3_SAFE_FREE(select_query);
+ content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
+
+ if (sqlite3_step(stmt) == SQLITE_ROW) {
+ _media_info_item_get_detail(stmt, (media_info_h)_media);
+ } else {
+ content_sec_error("No media : path[%s]", path);
+ ret = MEDIA_CONTENT_ERROR_DB_FAILED;
+ }
+
+ SQLITE3_FINALIZE(stmt);
+
+ return ret;
+}
+#endif
int media_info_insert_to_db(const char *path, media_info_h *info)
{
char storage_id[MEDIA_CONTENT_UUID_SIZE+1] = {0, };
char repl_path[MAX_PATH_LEN] = {0, };
int ret = MEDIA_CONTENT_ERROR_NONE;
+ ms_user_storage_type_e storage_type = MS_USER_STORAGE_INTERNAL;
+ int modified_time = 0;
+
+ content_retip_if_fail(STRING_VALID(path));
+ content_retip_if_fail(info);
- media_content_retvm_if(!STRING_VALID(path), MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "invalid path");
- media_content_retvm_if(info == NULL, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "invalid info");
- memset(repl_path, 0, sizeof(repl_path));
ret = _media_content_replace_path(path, repl_path);
- media_content_retvm_if(!STRING_VALID(repl_path), MEDIA_CONTENT_ERROR_INVALID_OPERATION, "path replacement failed");
+ content_retvm_if(!STRING_VALID(repl_path), MEDIA_CONTENT_ERROR_INVALID_OPERATION, "path replacement failed");
ret = __media_info_check_file_validity(repl_path);
- media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
+ content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
- memset(storage_id, 0x00, sizeof(storage_id));
ret = media_svc_get_storage_id(_content_get_db_handle(), repl_path, storage_id, _content_get_uid());
if (ret != MS_MEDIA_ERR_NONE) {
- media_content_error("media_svc_get_storage_id failed : %d", ret);
- return _content_error_capi(MEDIA_CONTENT_TYPE, ret);
+ content_error("media_svc_get_storage_id failed : %d", ret);
+ return _content_error_capi(ret);
}
- ret = media_svc_check_item_exist_by_path(_content_get_db_handle(), storage_id, repl_path);
- if (ret == MS_MEDIA_ERR_DB_NO_RECORD) {
- media_content_sec_debug("media_svc_check_item_exist_by_path : no record : %s", repl_path);
-
- media_svc_storage_type_e storage_type = 0;
+ ret = ms_user_get_storage_type(_content_get_uid(), repl_path, &storage_type);
+ if (ret != MS_MEDIA_ERR_NONE) {
+ content_sec_error("ms_user_get_storage_type failed : %d", ret);
+ return _content_error_capi(ret);
+ }
- ret = media_svc_get_storage_type(repl_path, &storage_type, _content_get_uid());
- if (ret != MS_MEDIA_ERR_NONE) {
- media_content_sec_error("media_svc_get_storage_type failed : %d", ret);
- return _content_error_capi(MEDIA_CONTENT_TYPE, ret);
+ /* Get modified time for check exists */
+ ret = media_svc_get_modified_time(_content_get_db_handle(), storage_id, repl_path, &modified_time);
+ if (ret == MS_MEDIA_ERR_NONE) {
+ /* Refresh if need */
+ if (modified_time != _media_util_get_file_time(repl_path)) {
+ ret = media_svc_refresh_item(_content_get_db_handle(), false, storage_id, storage_type, repl_path, _content_get_uid());
+ if (ret != MS_MEDIA_ERR_NONE) {
+ content_error("media_svc_refresh_item failed : %d", ret);
+ return _content_error_capi(ret);
+ }
}
+ } else if (ret == MS_MEDIA_ERR_DB_NO_RECORD) {
+ content_sec_debug("media_svc_check_item_exist_by_path : no record : %s", repl_path);
+ content_retvm_if(!_media_util_check_support_media_type(repl_path), MEDIA_CONTENT_ERROR_NOT_SUPPORTED, "Unsupported media type");
ret = media_svc_insert_item_immediately(_content_get_db_handle(), storage_id, storage_type, repl_path, _content_get_uid());
-
if (ret != MS_MEDIA_ERR_NONE) {
if (ret == MS_MEDIA_ERR_DB_CONSTRAINT_FAIL) {
- media_content_sec_error("This item is already inserted. This may be normal operation because other process already did this (%s)", repl_path);
+ content_sec_error("This item is already inserted. This may be normal operation because other process already did this (%s)", repl_path);
ret = MEDIA_CONTENT_ERROR_NONE;
} else {
- media_content_sec_error("media_svc_insert_item_immediately failed : %d (%s)", ret, repl_path);
+ content_sec_error("media_svc_insert_item_immediately failed : %d (%s)", ret, repl_path);
}
- return _content_error_capi(MEDIA_CONTENT_TYPE, ret);
+ return _content_error_capi(ret);
}
- } else if (ret != MS_MEDIA_ERR_NONE) {
- media_content_sec_error("media_svc_check_item_exist_by_path failed : %d (%s)", ret, repl_path);
- return _content_error_capi(MEDIA_CONTENT_TYPE, ret);
+ } else {
+ content_sec_error("media_svc_get_modified_time failed : %d (%s)", ret, repl_path);
+ return _content_error_capi(ret);
}
- media_info_s *_media = (media_info_s*)calloc(1, sizeof(media_info_s));
- media_content_retvm_if(_media == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
+ media_info_s *_media = g_new0(media_info_s, 1);
+#ifdef _USE_TVPD_MODE
if (STRING_VALID(storage_id))
ret = _media_info_get_media_info_from_db(repl_path, storage_id, (media_info_h)_media);
else
- ret = _media_info_get_media_info_from_db(repl_path, DEFAULT_MEDIA_STORAGE_ID, (media_info_h)_media);
+ ret = _media_info_get_media_info_from_db(repl_path, DB_TABLE_MEDIA, (media_info_h)_media);
*info = (media_info_h)_media;
- return ret;
-}
-
-int media_info_insert_batch_to_db(const char **path_array, unsigned int array_length, media_insert_completed_cb completed_cb, void *user_data)
-{
- char **repl_path_array = NULL;
- int idx = 0;
- int ret = MS_MEDIA_ERR_NONE;
- char repl_path[MAX_PATH_LEN] = {0, };
-
- media_content_retvm_if(path_array == NULL, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid path_array");
- media_content_retvm_if(array_length <= 0, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid array_length");
-
- repl_path_array = calloc(1, sizeof(char *) * array_length);
- media_content_retvm_if(repl_path_array == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
-
- for (idx = 0; idx < array_length; idx++) {
- if (STRING_VALID(path_array[idx])) {
- memset(repl_path, 0, sizeof(repl_path));
- _media_content_replace_path(path_array[idx], repl_path);
- repl_path_array[idx] = strndup(repl_path, strlen(repl_path));
- } else {
- media_content_error("path[%d] is invalid string", idx);
- }
- }
-
- ret = __media_info_insert_batch(MEDIA_BATCH_INSERT_NORMAL, (const char **)repl_path_array, array_length, completed_cb, user_data);
- for (idx = 0; idx < array_length; idx++)
- SAFE_FREE(repl_path_array[idx]);
-
- SAFE_FREE(repl_path_array);
+#else
+ ret = _media_info_get_media_info_from_db(repl_path, (media_info_h)_media);
+ *info = (media_info_h)_media;
+#endif
return ret;
}
-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)
+int media_info_insert_batch_to_db(const char **path_array, unsigned int array_length, media_insert_completed_cb completed_cb, void *user_data)
{
char **repl_path_array = NULL;
int idx = 0;
int ret = MS_MEDIA_ERR_NONE;
char repl_path[MAX_PATH_LEN] = {0, };
- media_content_retvm_if(path_array == NULL, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid path_array");
- media_content_retvm_if(array_length <= 0, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid array_length");
+ content_retip_if_fail(path_array);
+ content_retip_if_fail(array_length > 0);
+ content_retip_if_fail(completed_cb);
- repl_path_array = calloc(1, sizeof(char *) * array_length);
- media_content_retvm_if(repl_path_array == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
+ repl_path_array = g_malloc0(sizeof(char *) * array_length);
for (idx = 0; idx < array_length; idx++) {
if (STRING_VALID(path_array[idx])) {
memset(repl_path, 0, sizeof(repl_path));
_media_content_replace_path(path_array[idx], repl_path);
- repl_path_array[idx] = strndup(repl_path, strlen(repl_path));
+ repl_path_array[idx] = g_strndup(repl_path, strlen(repl_path));
} else {
- media_content_error("path[%d] is invalid string", idx);
+ content_error("path[%d] is invalid string", idx);
}
}
- ret = __media_info_insert_batch(MEDIA_BATCH_INSERT_BURSTSHOT, (const char **)repl_path_array, array_length, callback, user_data);
+ ret = __media_info_insert_batch((const char **)repl_path_array, array_length, completed_cb, user_data);
for (idx = 0; idx < array_length; idx++)
- SAFE_FREE(repl_path_array[idx]);
+ g_free(repl_path_array[idx]);
- SAFE_FREE(repl_path_array);
+ g_free(repl_path_array);
return ret;
}
-
#ifdef _USE_TVPD_MODE
int media_info_get_media_info_by_path_from_db(const char* path, media_info_h* media)
{
- char storage_id[MEDIA_CONTENT_UUID_SIZE+1] = {0,};
int ret = MEDIA_CONTENT_ERROR_NONE;
- media_content_retvm_if(!STRING_VALID(path), MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "invalid path");
- media_content_retvm_if(media == NULL, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "invalid info");
+ char storage_id[MEDIA_CONTENT_UUID_SIZE+1] = {0, };
+
+ content_retip_if_fail(STRING_VALID(path));
+ content_retip_if_fail(media);
- memset(storage_id, 0x00, sizeof(storage_id));
ret = media_svc_get_storage_id(_content_get_db_handle(), path, storage_id, tzplatform_getuid(TZ_USER_NAME));
if (ret != MS_MEDIA_ERR_NONE) {
- media_content_error("media_svc_get_storage_id failed : %d", ret);
- return _content_error_capi(MEDIA_CONTENT_TYPE, ret);
+ content_error("media_svc_get_storage_id failed : %d", ret);
+ return _content_error_capi(ret);
}
- media_info_s *_media = (media_info_s*)calloc(1, sizeof(media_info_s));
- media_content_retvm_if(_media == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
+ media_info_s *_media = g_new0(media_info_s, 1);
ret = _media_info_get_media_info_from_db(path, storage_id, (media_info_h)_media);
*media = (media_info_h)_media;
}
#endif
-#ifdef _USE_SENIOR_MODE
-int media_info_set_contact(media_info_h media, const char *contact)
-{
- return __media_info_set_str_data(media, MEDIA_INFO_CONTACT, contact);
-}
-
-int media_info_set_app_data(media_info_h media, const char *app_data)
+int media_info_delete_from_db(const char *media_id)
{
- return __media_info_set_str_data(media, MEDIA_INFO_APP_DATA, app_data);
-}
+ int ret = MEDIA_CONTENT_ERROR_NONE;
+ char *path = NULL;
+ char *storage_id = NULL;
+ content_warn("DEPRECATION WARNING: media_info_delete_from_db() is deprecated and will be removed from next release. Use media_content_scan_file() instead.");
-int media_info_insert_to_db_with_contact_data(const char *path, const char* contact, const char* app_data, media_info_h *info)
-{
- int ret = media_info_insert_to_db(path, info);
- media_content_retvm_if(ret != MEDIA_CONTENT_ERROR_NONE, ret, "media_info_insert_to_db [%s] failed", path);
+ content_retip_if_fail(STRING_VALID(media_id));
- ret = media_info_set_contact(*info, contact);
+ ret = __media_info_get_media_path_by_id_from_db(media_id, &path);
if (ret != MEDIA_CONTENT_ERROR_NONE) {
- media_content_error("media_info_set_contact [%s] failed", contact);
-
- media_info_s* _media_info = (media_info_s*)*info;
- ret = media_info_delete_from_db(_media_info->media_id);
- media_content_retvm_if(ret != MEDIA_CONTENT_ERROR_NONE, ret, "media_info_delete_from_db [%s] failed", _media_info->media_id);
-
- media_info_destroy(*info);
+ content_error("__media_info_get_media_path_by_id_from_db failed : %d", ret);
+ g_free(path);
return ret;
}
- ret = media_info_set_app_data(*info, app_data);
+ ret = _media_db_get_storage_id_by_media_id(media_id, &storage_id);
if (ret != MEDIA_CONTENT_ERROR_NONE) {
- media_content_error("media_info_set_app_data [%s] failed", app_data);
-
- media_info_s* _media_info = (media_info_s*)*info;
- ret = media_info_delete_from_db(_media_info->media_id);
- media_content_retvm_if(ret != MEDIA_CONTENT_ERROR_NONE, ret, "media_info_delete_from_db [%s] failed", _media_info->media_id);
-
- media_info_destroy(*info);
+ content_error("_media_db_get_storage_id_by_media_id failed : %d", ret);
+ g_free(path);
return ret;
}
- ret = media_info_update_to_db(*info);
- if (ret != MEDIA_CONTENT_ERROR_NONE) {
- media_content_error("media_info_update_to_db [] failed");
-
- media_info_s* _media_info = (media_info_s*)*info;
- ret = media_info_delete_from_db(_media_info->media_id);
- media_content_retvm_if(ret != MEDIA_CONTENT_ERROR_NONE, ret, "media_info_delete_from_db [%s] failed", _media_info->media_id);
-
- media_info_destroy(*info);
- return ret;
- }
+ ret = media_svc_delete_item_by_path(_content_get_db_handle(), storage_id, path, _content_get_uid());
+ g_free(path);
+ g_free(storage_id);
- return ret;
+ return _content_error_capi(ret);
}
-int media_info_delete_contact_from_db(const char* contact, const char* storage_id)
+int media_info_destroy(media_info_h media)
{
- return -1;
-}
+ media_info_s *_media = (media_info_s*)media;
-int media_info_delete_item(const char *media_id)
-{
- int ret = MEDIA_CONTENT_ERROR_NONE;
- char *path = NULL;
- char storage_id[MEDIA_CONTENT_UUID_SIZE+1] = {0,};
+ content_retip_if_fail(media);
- if (!STRING_VALID(media_id)) {
- media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
- }
+ g_free(_media->media_id);
+ g_free(_media->file_path);
+ g_free(_media->display_name);
+ g_free(_media->mime_type);
+ g_free(_media->thumbnail_path);
+ g_free(_media->description);
+ g_free(_media->title);
+#ifdef _USE_TVPD_MODE
+ g_free(_media->modified_month);
+#endif
+ g_free(_media->storage_uuid);
- memset(storage_id, 0x00, sizeof(storage_id));
+ if (_media->image_meta) {
+ g_free(_media->image_meta->media_id);
+ g_free(_media->image_meta->date_taken);
+ g_free(_media->image_meta->exposure_time);
+ g_free(_media->image_meta->model);
- ret = __media_info_get_media_path_by_id_from_db(media_id, &path);
- if (ret != MEDIA_CONTENT_ERROR_NONE) {
- media_content_error("__media_info_get_media_path_by_id_from_db failed : %d", ret);
- SAFE_FREE(path);
- return ret;
+ g_free(_media->image_meta);
}
- ret = _media_db_get_storage_id_by_media_id(media_id, storage_id);
- if (ret != MEDIA_CONTENT_ERROR_NONE) {
- media_content_error("_media_db_get_storage_id_by_media_id failed : %d", ret);
- SAFE_FREE(path);
- return ret;
+ if (_media->video_meta) {
+ g_free(_media->video_meta->media_id);
+ g_free(_media->video_meta->album);
+ g_free(_media->video_meta->artist);
+ g_free(_media->video_meta->album_artist);
+ g_free(_media->video_meta->genre);
+ g_free(_media->video_meta->composer);
+ g_free(_media->video_meta->year);
+ g_free(_media->video_meta->recorded_date);
+ g_free(_media->video_meta->copyright);
+ g_free(_media->video_meta->track_num);
+
+ g_free(_media->video_meta);
}
- ret = media_svc_delete_item_by_path(_content_get_db_handle(), storage_id, path, tzplatform_getuid(TZ_USER_NAME));
- if (ret != MEDIA_CONTENT_ERROR_NONE) {
- media_content_error("remove from DB failed : %d", ret);
- SAFE_FREE(path);
- return ret;
+ if (_media->audio_meta) {
+ g_free(_media->audio_meta->media_id);
+ g_free(_media->audio_meta->album);
+ g_free(_media->audio_meta->artist);
+ g_free(_media->audio_meta->album_artist);
+ g_free(_media->audio_meta->genre);
+ g_free(_media->audio_meta->composer);
+ g_free(_media->audio_meta->year);
+ g_free(_media->audio_meta->recorded_date);
+ g_free(_media->audio_meta->copyright);
+ g_free(_media->audio_meta->track_num);
+
+ g_free(_media->audio_meta);
}
- ret = media_svc_remove_file(path);
- SAFE_FREE(path);
- return _content_error_capi(MEDIA_CONTENT_TYPE, ret);
-}
+ g_free(_media);
-#endif
+ return MEDIA_CONTENT_ERROR_NONE;
+}
-int media_info_delete_from_db(const char *media_id)
+int media_info_clone(media_info_h *dst, media_info_h src)
{
- int ret = MEDIA_CONTENT_ERROR_NONE;
- char *path = NULL;
- char storage_id[MEDIA_CONTENT_UUID_SIZE+1] = {0, };
-
- if (!STRING_VALID(media_id)) {
- media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
- }
+ media_info_s *_src = (media_info_s*)src;
- memset(storage_id, 0x00, sizeof(storage_id));
+ content_retip_if_fail(dst);
+ content_retip_if_fail(src);
- ret = __media_info_get_media_path_by_id_from_db(media_id, &path);
- if (ret != MEDIA_CONTENT_ERROR_NONE) {
- media_content_error("__media_info_get_media_path_by_id_from_db failed : %d", ret);
- SAFE_FREE(path);
- return ret;
- }
+ media_info_s *_dst = g_new0(media_info_s, 1);
- ret = _media_db_get_storage_id_by_media_id(media_id, storage_id);
- if (ret != MEDIA_CONTENT_ERROR_NONE) {
- media_content_error("_media_db_get_storage_id_by_media_id failed : %d", ret);
- SAFE_FREE(path);
- return ret;
- }
+ _dst->media_id = g_strdup(_src->media_id);
+ _dst->file_path = g_strdup(_src->file_path);
+ _dst->display_name = g_strdup(_src->display_name);
+ _dst->mime_type = g_strdup(_src->mime_type);
+ _dst->thumbnail_path = g_strdup(_src->thumbnail_path);
+ _dst->description = g_strdup(_src->description);
+ _dst->title = g_strdup(_src->title);
+ _dst->storage_uuid = g_strdup(_src->storage_uuid);
+#ifdef _USE_TVPD_MODE
+ _dst->modified_month = g_strdup(_src->modified_month);
+#endif
+ _dst->media_type = _src->media_type;
+ _dst->size = _src->size;
+ _dst->added_time = _src->added_time;
+ _dst->modified_time = _src->modified_time;
+ _dst->timeline = _src->timeline;
+ _dst->longitude = _src->longitude;
+ _dst->latitude = _src->latitude;
+ _dst->altitude = _src->altitude;
+ _dst->rating = _src->rating;
+ _dst->favourite = _src->favourite;
+ _dst->is_drm = _src->is_drm;
+ _dst->storage_type = _src->storage_type;
+ _dst->request_id = _src->request_id;
+ _dst->face_request_id = _src->face_request_id;
+ _dst->is_360 = _src->is_360;
+#ifdef _USE_TVPD_MODE
+ _dst->played_count = _src->played_count;
+ _dst->played_time = _src->played_time;
+ _dst->played_position = _src->played_position;
+ _dst->stitched_info = _src->stitched_info;
+ _dst->extract_flag = _src->extract_flag;
+#endif
- ret = media_svc_delete_item_by_path(_content_get_db_handle(), storage_id, path, _content_get_uid());
- SAFE_FREE(path);
+ if (_src->media_type == MEDIA_CONTENT_TYPE_IMAGE && _src->image_meta) {
+ _dst->image_meta = g_new0(image_meta_s, 1);
+
+ _dst->image_meta->media_id = g_strdup(_src->image_meta->media_id);
+ _dst->image_meta->date_taken = g_strdup(_src->image_meta->date_taken);
+ _dst->image_meta->exposure_time = g_strdup(_src->image_meta->exposure_time);
+ _dst->image_meta->model = g_strdup(_src->image_meta->model);
+ _dst->image_meta->fnumber = _src->image_meta->fnumber;
+ _dst->image_meta->iso = _src->image_meta->iso;
+ _dst->image_meta->width = _src->image_meta->width;
+ _dst->image_meta->height = _src->image_meta->height;
+ _dst->image_meta->orientation = _src->image_meta->orientation;
+
+ } else if (_src->media_type == MEDIA_CONTENT_TYPE_VIDEO && _src->video_meta) {
+ _dst->video_meta = g_new0(video_meta_s, 1);
+
+ _dst->video_meta->media_id = g_strdup(_src->video_meta->media_id);
+ _dst->video_meta->album = g_strdup(_src->video_meta->album);
+ _dst->video_meta->artist = g_strdup(_src->video_meta->artist);
+ _dst->video_meta->album_artist = g_strdup(_src->video_meta->album_artist);
+ _dst->video_meta->genre = g_strdup(_src->video_meta->genre);
+ _dst->video_meta->composer = g_strdup(_src->video_meta->composer);
+ _dst->video_meta->year = g_strdup(_src->video_meta->year);
+ _dst->video_meta->recorded_date = g_strdup(_src->video_meta->recorded_date);
+ _dst->video_meta->copyright = g_strdup(_src->video_meta->copyright);
+ _dst->video_meta->track_num = g_strdup(_src->video_meta->track_num);
+ _dst->video_meta->width = _src->video_meta->width;
+ _dst->video_meta->height = _src->video_meta->height;
+ _dst->video_meta->duration = _src->video_meta->duration;
+ _dst->video_meta->bitrate = _src->video_meta->bitrate;
+ _dst->video_meta->rotation = _src->video_meta->rotation;
+
+ } else if ((_src->media_type == MEDIA_CONTENT_TYPE_MUSIC || _src->media_type == MEDIA_CONTENT_TYPE_SOUND) && _src->audio_meta) {
+ _dst->audio_meta = g_new0(audio_meta_s, 1);
+
+ _dst->audio_meta->media_id = g_strdup(_src->audio_meta->media_id);
+ _dst->audio_meta->album = g_strdup(_src->audio_meta->album);
+ _dst->audio_meta->artist = g_strdup(_src->audio_meta->artist);
+ _dst->audio_meta->album_artist = g_strdup(_src->audio_meta->album_artist);
+ _dst->audio_meta->genre = g_strdup(_src->audio_meta->genre);
+ _dst->audio_meta->composer = g_strdup(_src->audio_meta->composer);
+ _dst->audio_meta->year = g_strdup(_src->audio_meta->year);
+ _dst->audio_meta->recorded_date = g_strdup(_src->audio_meta->recorded_date);
+ _dst->audio_meta->copyright = g_strdup(_src->audio_meta->copyright);
+ _dst->audio_meta->track_num = g_strdup(_src->audio_meta->track_num);
+ _dst->audio_meta->channel = _src->audio_meta->channel;
+ _dst->audio_meta->samplerate = _src->audio_meta->samplerate;
+ _dst->audio_meta->duration = _src->audio_meta->duration;
+ _dst->audio_meta->bitrate = _src->audio_meta->bitrate;
+ _dst->audio_meta->bitpersample = _src->audio_meta->bitpersample;
+ }
+
+ *dst = (media_info_h)_dst;
- return _content_error_capi(MEDIA_CONTENT_TYPE, ret);
+ return MEDIA_CONTENT_ERROR_NONE;
}
-static int __media_info_delete_thumb_from_list(GArray *thumb_list)
+int media_info_get_media_count_from_db(filter_h filter, int *media_count)
{
- int i = 0;
- int list_len = 0;
- char *thumb_path = NULL;
+ content_retip_if_fail(media_count);
- if (thumb_list != NULL) {
- list_len = thumb_list->len;
- for (i = 0; i < list_len; i++) {
- thumb_path = g_array_index(thumb_list, char*, i);
- media_content_debug("thumb path [%s]", thumb_path);
- if (unlink(thumb_path) < 0)
- media_content_stderror("failed to delete");
- }
- }
- return MEDIA_CONTENT_ERROR_NONE;
+ return _media_db_get_group_item_count(NULL, filter, MEDIA_GROUP_NONE, media_count);
}
-static int __media_info_release_thumb_list(GArray *thumb_list)
+int media_info_foreach_media_from_db(filter_h filter, media_info_cb callback, void *user_data)
{
- int i = 0;
- int list_len = 0;
- char *thumb_path = NULL;
-
- if (thumb_list != NULL) {
- list_len = thumb_list->len;
- for (i = 0; i < list_len; i++) {
- thumb_path = g_array_index(thumb_list, char*, 0);
- g_array_remove_index(thumb_list, 0);
- SAFE_FREE(thumb_path);
- }
+ content_retip_if_fail(callback);
- g_array_free(thumb_list, FALSE);
- }
-
- return MEDIA_CONTENT_ERROR_NONE;
+ return _media_db_get_group_item(NULL, filter, callback, user_data, MEDIA_GROUP_NONE);
}
-static int __media_info_release_storage_list(GArray *storage_list)
+int media_info_get_tag_count_from_db(const char *media_id, filter_h filter, int *tag_count)
{
- int i = 0;
- int list_len = 0;
- media_storage_s *storage = NULL;
+ content_retip_if_fail(STRING_VALID(media_id));
+ content_retip_if_fail(tag_count);
- if (storage_list != NULL) {
- list_len = storage_list->len;
- for (i = 0; i < list_len; i++) {
- storage = g_array_index(storage_list, media_storage_s *, 0);
- g_array_remove_index(storage_list, 0);
- SAFE_FREE(storage->storage_id);
- SAFE_FREE(storage);
- }
-
- g_array_free(storage_list, FALSE);
- }
-
- return MEDIA_CONTENT_ERROR_NONE;
+ return _media_db_get_group_item_count(media_id, filter, MEDIA_GROUP_TAG_BY_MEDIA_ID, tag_count);
}
-int media_info_delete_batch_from_db(filter_h filter)
+int media_info_foreach_tag_from_db(const char *media_id, filter_h filter, media_tag_cb callback, void *user_data)
{
- int ret = MEDIA_CONTENT_ERROR_NONE;
- char *query_string = NULL;
- filter_s *_filter = NULL;
- attribute_h attr;
- char *condition_query = NULL;
- GArray *storage_list = NULL;
- GArray *thumb_list = NULL;
- int idx = 0;
- media_storage_s *storage_item = NULL;
-
- media_content_retvm_if(filter == NULL, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid filter");
+ content_retip_if_fail(STRING_VALID(media_id));
+ content_retip_if_fail(callback);
- _filter = (filter_s*)filter;
+ return _media_db_get_tag(media_id, filter, callback, user_data);
+}
- media_content_retvm_if(_filter->condition == NULL, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid condition");
+int media_info_get_bookmark_count_from_db(const char *media_id, filter_h filter, int *bookmark_count)
+{
+ content_retip_if_fail(STRING_VALID(media_id));
+ content_retip_if_fail(bookmark_count);
- attr = _content_get_attirbute_handle();
+ return _media_db_get_group_item_count(media_id, filter, MEDIA_GROUP_BOOKMARK_BY_MEDIA_ID, bookmark_count);
+}
- ret = _media_filter_attribute_generate(attr, filter, &condition_query);
- media_content_retvm_if(ret != MEDIA_CONTENT_ERROR_NONE, ret, "Invalid condition");
+int media_info_foreach_bookmark_from_db(const char *media_id, filter_h filter, media_bookmark_cb callback, void *user_data)
+{
+ content_retip_if_fail(STRING_VALID(media_id));
+ content_retip_if_fail(callback);
- ret = __media_info_get_storage_list_to_remove(condition_query, &storage_list);
- if (ret != MEDIA_CONTENT_ERROR_NONE) {
- SAFE_FREE(condition_query);
- __media_info_release_storage_list(storage_list);
+ return _media_db_get_bookmark(media_id, filter, callback, user_data);
+}
- return ret;
- }
+int media_info_get_face_count_from_db(const char *media_id, filter_h filter, int *face_count)
+{
+ content_retip_if_fail(STRING_VALID(media_id));
+ content_retip_if_fail(face_count);
- for (idx = 0; idx < storage_list->len; idx++) {
- storage_item = g_array_index(storage_list, media_storage_s *, idx);
- /*media_content_debug("storage_id[%s] storage_type[%d]", storage_item->storage_id, storage_item->storage_type);*/
+ return _media_db_get_group_item_count(media_id, filter, MEDIA_GROUP_FACE_BY_MEDIA_ID, face_count);
+}
- ret = __media_info_get_thumbnail_to_remove(condition_query, storage_item->storage_id, storage_item->storage_type, &thumb_list);
- if (ret != MEDIA_CONTENT_ERROR_NONE) {
- SAFE_FREE(condition_query);
- __media_info_release_storage_list(storage_list);
- __media_info_release_thumb_list(thumb_list);
+int media_info_foreach_face_from_db(const char *media_id, filter_h filter, media_face_cb callback, void *user_data)
+{
+ content_retip_if_fail(STRING_VALID(media_id));
+ content_retip_if_fail(callback);
- return ret;
- }
+ return _media_db_get_face(media_id, filter, callback, user_data);
+}
- query_string = sqlite3_mprintf(DELETE_MEDIA_FROM_MEDIA_BATCH, storage_item->storage_id, condition_query, storage_item->storage_type);
+int media_info_get_image(media_info_h media, image_meta_h *image)
+{
+ int ret = MEDIA_CONTENT_ERROR_NONE;
- ret = _content_query_sql(query_string);
- SQLITE3_SAFE_FREE(query_string);
+ media_info_s *_media = (media_info_s*)media;
- if (ret == MEDIA_CONTENT_ERROR_NONE) {
- media_content_debug("Batch deletion succeeded. Send notification for this");
- if (storage_item->storage_type == MEDIA_CONTENT_STORAGE_INTERNAL) {
- media_svc_publish_noti(MS_MEDIA_ITEM_DIRECTORY, MS_MEDIA_ITEM_UPDATE, MEDIA_ROOT_PATH_INTERNAL, -1, NULL, NULL);
- } else {
- char *storage_path = NULL;
- media_svc_get_storage_path(_content_get_db_handle(), storage_item->storage_id, &storage_path);
- if (STRING_VALID(storage_path))
- media_svc_publish_noti(MS_MEDIA_ITEM_DIRECTORY, MS_MEDIA_ITEM_UPDATE, storage_path, -1, NULL, NULL);
+ content_retip_if_fail(media);
+ content_retip_if_fail(_media->media_type == MEDIA_CONTENT_TYPE_IMAGE);
+ content_retip_if_fail(_media->image_meta);
+ content_retip_if_fail(image);
- SAFE_FREE(storage_path);
- }
- __media_info_delete_thumb_from_list(thumb_list);
- }
- __media_info_release_thumb_list(thumb_list);
+ image_meta_s *_image = g_new0(image_meta_s, 1);
- }
+ _image->media_id = g_strdup(_media->media_id);
+ _image->width = _media->image_meta->width;
+ _image->height = _media->image_meta->height;
+ _image->orientation = _media->image_meta->orientation;
+ _image->fnumber = _media->image_meta->fnumber;
+ _image->iso = _media->image_meta->iso;
+ _image->date_taken = g_strdup(_media->image_meta->date_taken);
+ _image->exposure_time = g_strdup(_media->image_meta->exposure_time);
+ _image->model = g_strdup(_media->image_meta->model);
- SAFE_FREE(condition_query);
- __media_info_release_storage_list(storage_list);
+ *image = (image_meta_h)_image;
return ret;
}
-int media_info_destroy(media_info_h media)
+int media_info_get_video(media_info_h media, video_meta_h *video)
{
int ret = MEDIA_CONTENT_ERROR_NONE;
- media_info_s *_media = (media_info_s*)media;
- if (_media) {
- SAFE_FREE(_media->media_id);
- SAFE_FREE(_media->file_path);
- SAFE_FREE(_media->display_name);
- SAFE_FREE(_media->mime_type);
- SAFE_FREE(_media->thumbnail_path);
- SAFE_FREE(_media->description);
- SAFE_FREE(_media->author);
- SAFE_FREE(_media->provider);
- SAFE_FREE(_media->content_name);
- SAFE_FREE(_media->category);
- SAFE_FREE(_media->location_tag);
- SAFE_FREE(_media->age_rating);
- SAFE_FREE(_media->keyword);
- SAFE_FREE(_media->title);
-#ifdef _USE_TVPD_MODE
- SAFE_FREE(_media->modified_month);
-#endif
- SAFE_FREE(_media->weather);
- SAFE_FREE(_media->storage_uuid);
-#ifdef _USE_SENIOR_MODE
- SAFE_FREE(_media->contact);
- SAFE_FREE(_media->app_data);
-#endif
-
- if (_media->image_meta) {
- SAFE_FREE(_media->image_meta->media_id);
- SAFE_FREE(_media->image_meta->date_taken);
- SAFE_FREE(_media->image_meta->burst_id);
- SAFE_FREE(_media->image_meta->exposure_time);
- SAFE_FREE(_media->image_meta->model);
- SAFE_FREE(_media->image_meta->title);
- SAFE_FREE(_media->image_meta->weather);
+ media_info_s *_media = (media_info_s*)media;
- SAFE_FREE(_media->image_meta);
- }
+ content_retip_if_fail(media);
+ content_retip_if_fail(_media->media_type == MEDIA_CONTENT_TYPE_VIDEO);
+ content_retip_if_fail(_media->video_meta);
+ content_retip_if_fail(video);
- if (_media->video_meta) {
- SAFE_FREE(_media->video_meta->media_id);
- SAFE_FREE(_media->video_meta->title);
- SAFE_FREE(_media->video_meta->album);
- SAFE_FREE(_media->video_meta->artist);
- SAFE_FREE(_media->video_meta->album_artist);
- SAFE_FREE(_media->video_meta->genre);
- SAFE_FREE(_media->video_meta->composer);
- SAFE_FREE(_media->video_meta->year);
- SAFE_FREE(_media->video_meta->recorded_date);
- SAFE_FREE(_media->video_meta->copyright);
- SAFE_FREE(_media->video_meta->track_num);
-
- SAFE_FREE(_media->video_meta);
- }
-
- if (_media->audio_meta) {
- SAFE_FREE(_media->audio_meta->media_id);
- SAFE_FREE(_media->audio_meta->title);
- SAFE_FREE(_media->audio_meta->album);
- SAFE_FREE(_media->audio_meta->artist);
- SAFE_FREE(_media->audio_meta->album_artist);
- SAFE_FREE(_media->audio_meta->genre);
- SAFE_FREE(_media->audio_meta->composer);
- SAFE_FREE(_media->audio_meta->year);
- SAFE_FREE(_media->audio_meta->recorded_date);
- SAFE_FREE(_media->audio_meta->copyright);
- SAFE_FREE(_media->audio_meta->track_num);
-
- SAFE_FREE(_media->audio_meta);
- }
-
- SAFE_FREE(_media);
-
- ret = MEDIA_CONTENT_ERROR_NONE;
- } else {
- media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
- }
-
- return ret;
-}
-
-int media_info_clone(media_info_h *dst, media_info_h src)
-{
- int ret = MEDIA_CONTENT_ERROR_NONE;
- media_info_s *_src = (media_info_s*)src;
-
- if (_src != NULL) {
- media_info_s *_dst = (media_info_s*)calloc(1, sizeof(media_info_s));
- media_content_retvm_if(_dst == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
-
- if (_src->media_id) {
- _dst->media_id = g_strdup(_src->media_id);
- if (_dst->media_id == NULL) {
- media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
- media_info_destroy((media_info_h)_dst);
- return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
- }
- }
- if (_src->file_path) {
- _dst->file_path = g_strdup(_src->file_path);
- if (_dst->file_path == NULL) {
- media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
- media_info_destroy((media_info_h)_dst);
- return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
- }
- }
- if (_src->display_name != NULL) {
- _dst->display_name = g_strdup(_src->display_name);
- if (_dst->display_name == NULL) {
- media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
- media_info_destroy((media_info_h)_dst);
- return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
- }
- }
- if (_src->mime_type) {
- _dst->mime_type = g_strdup(_src->mime_type);
- if (_dst->mime_type == NULL) {
- media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
- media_info_destroy((media_info_h)_dst);
- return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
- }
- }
- if (_src->thumbnail_path != NULL) {
- _dst->thumbnail_path = g_strdup(_src->thumbnail_path);
- if (_dst->thumbnail_path == NULL) {
- media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
- media_info_destroy((media_info_h)_dst);
- return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
- }
- }
- if (_src->description != NULL) {
- _dst->description = g_strdup(_src->description);
- if (_dst->description == NULL) {
- media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
- media_info_destroy((media_info_h)_dst);
- return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
- }
- }
-
- if (_src->weather != NULL) {
- _dst->weather = g_strdup(_src->weather);
- if (_dst->weather == NULL) {
- media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
- media_info_destroy((media_info_h)_dst);
- return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
- }
- }
-
- if (_src->title != NULL) {
- _dst->title = g_strdup(_src->title);
- if (_dst->title == NULL) {
- media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
- media_info_destroy((media_info_h)_dst);
- return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
- }
- }
- if (_src->author != NULL) {
- _dst->author = g_strdup(_src->author);
- if (_dst->author == NULL) {
- media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
- media_info_destroy((media_info_h)_dst);
- return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
- }
- }
- if (_src->provider != NULL) {
- _dst->provider = g_strdup(_src->provider);
- if (_dst->provider == NULL) {
- media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
- media_info_destroy((media_info_h)_dst);
- return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
- }
- }
- if (_src->content_name != NULL) {
- _dst->content_name = g_strdup(_src->content_name);
- if (_dst->content_name == NULL) {
- media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
- media_info_destroy((media_info_h)_dst);
- return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
- }
- }
- if (_src->category != NULL) {
- _dst->category = g_strdup(_src->category);
- if (_dst->category == NULL) {
- media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
- media_info_destroy((media_info_h)_dst);
- return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
- }
- }
- if (_src->location_tag != NULL) {
- _dst->location_tag = g_strdup(_src->location_tag);
- if (_dst->location_tag == NULL) {
- media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
- media_info_destroy((media_info_h)_dst);
- return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
- }
- }
- if (_src->age_rating != NULL) {
- _dst->age_rating = g_strdup(_src->age_rating);
- if (_dst->age_rating == NULL) {
- media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
- media_info_destroy((media_info_h)_dst);
- return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
- }
- }
- if (_src->keyword != NULL) {
- _dst->keyword = g_strdup(_src->keyword);
- if (_dst->keyword == NULL) {
- media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
- media_info_destroy((media_info_h)_dst);
- return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
- }
- }
-
- if (_src->storage_uuid != NULL) {
- _dst->storage_uuid = g_strdup(_src->storage_uuid);
- if (_dst->storage_uuid == NULL) {
- media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
- media_info_destroy((media_info_h)_dst);
- return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
- }
- }
-#ifdef _USE_TVPD_MODE
- if (STRING_VALID(_src->modified_month)) {
- _dst->modified_month = strdup(_src->modified_month);
- if (_dst->modified_month == NULL) {
- media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
- media_info_destroy((media_info_h)_dst);
- return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
- }
- }
-#endif
-#ifdef _USE_SENIOR_MODE
- if (STRING_VALID(_src->contact)) {
- _dst->contact = strdup(_src->contact);
- if (_dst->contact == NULL) {
- media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
- media_info_destroy((media_info_h)_dst);
- return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
- }
- }
-
- if (STRING_VALID(_src->app_data)) {
- _dst->app_data = strdup(_src->app_data);
- if (_dst->app_data == NULL) {
- media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
- media_info_destroy((media_info_h)_dst);
- return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
- }
- }
-#endif
-
- _dst->media_type = _src->media_type;
- _dst->size = _src->size;
- _dst->added_time = _src->added_time;
- _dst->modified_time = _src->modified_time;
- _dst->timeline = _src->timeline;
- _dst->longitude = _src->longitude;
- _dst->latitude = _src->latitude;
- _dst->altitude = _src->altitude;
- _dst->rating = _src->rating;
- _dst->favourite = _src->favourite;
- _dst->is_drm = _src->is_drm;
- _dst->storage_type = _src->storage_type;
- _dst->played_count = _src->played_count;
- _dst->played_time = _src->played_time;
- _dst->played_position = _src->played_position;
- _dst->sync_status = _src->sync_status;
- _dst->request_id = _src->request_id;
- _dst->face_request_id = _src->face_request_id;
- _dst->is_360 = _src->is_360;
-#ifdef _USE_TVPD_MODE
- _dst->stitched_info = _src->stitched_info;
- _dst->extract_flag = _src->extract_flag;
-#endif
-
- if (_src->media_type == MEDIA_CONTENT_TYPE_IMAGE && _src->image_meta) {
- _dst->image_meta = (image_meta_s *)calloc(1, sizeof(image_meta_s));
- if (_dst->image_meta == NULL) {
- media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
- media_info_destroy((media_info_h)_dst);
- return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
- }
-
- if (_src->image_meta->media_id != NULL) {
- _dst->image_meta->media_id = g_strdup(_src->image_meta->media_id);
- if (_dst->image_meta->media_id == NULL) {
- media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
- media_info_destroy((media_info_h)_dst);
- return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
- }
- }
-
- if (_src->image_meta->date_taken != NULL) {
- _dst->image_meta->date_taken = g_strdup(_src->image_meta->date_taken);
- if (_dst->image_meta->date_taken == NULL) {
- media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
- media_info_destroy((media_info_h)_dst);
- return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
- }
- }
-
- if (_src->image_meta->burst_id != NULL) {
- _dst->image_meta->burst_id = g_strdup(_src->image_meta->burst_id);
- if (_dst->image_meta->burst_id == NULL) {
- media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
- media_info_destroy((media_info_h)_dst);
- return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
- }
- }
-
- if (_src->image_meta->weather != NULL) {
- _dst->image_meta->weather = g_strdup(_src->image_meta->weather);
- if (_dst->image_meta->weather == NULL) {
- media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
- media_info_destroy((media_info_h)_dst);
- return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
- }
- }
-
- if (_src->image_meta->exposure_time != NULL) {
- _dst->image_meta->exposure_time = g_strdup(_src->image_meta->exposure_time);
- if (_dst->image_meta->exposure_time == NULL) {
- media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
- media_info_destroy((media_info_h)_dst);
- return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
- }
- }
-
- if (_src->image_meta->model != NULL) {
- _dst->image_meta->model = g_strdup(_src->image_meta->model);
- if (_dst->image_meta->model == NULL) {
- media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
- media_info_destroy((media_info_h)_dst);
- return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
- }
- }
-
- _dst->image_meta->fnumber = _src->image_meta->fnumber;
- _dst->image_meta->iso = _src->image_meta->iso;
- _dst->image_meta->width = _src->image_meta->width;
- _dst->image_meta->height = _src->image_meta->height;
- _dst->image_meta->orientation = _src->image_meta->orientation;
-
- } else if (_src->media_type == MEDIA_CONTENT_TYPE_VIDEO && _src->video_meta) {
- _dst->video_meta = (video_meta_s *)calloc(1, sizeof(video_meta_s));
- if (_dst->video_meta == NULL) {
- media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
- media_info_destroy((media_info_h)_dst);
- return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
- }
-
- if (_src->video_meta->media_id != NULL) {
- _dst->video_meta->media_id = g_strdup(_src->video_meta->media_id);
- if (_dst->video_meta->media_id == NULL) {
- media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
- media_info_destroy((media_info_h)_dst);
- return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
- }
- }
- if (_src->video_meta->title != NULL) {
- _dst->video_meta->title = g_strdup(_src->video_meta->title);
- if (_dst->video_meta->title == NULL) {
- media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
- media_info_destroy((media_info_h)_dst);
- return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
- }
- }
- if (_src->video_meta->album != NULL) {
- _dst->video_meta->album = g_strdup(_src->video_meta->album);
- if (_dst->video_meta->album == NULL) {
- media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
- media_info_destroy((media_info_h)_dst);
- return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
- }
- }
- if (_src->video_meta->artist != NULL) {
- _dst->video_meta->artist = g_strdup(_src->video_meta->artist);
- if (_dst->video_meta->artist == NULL) {
- media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
- media_info_destroy((media_info_h)_dst);
- return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
- }
- }
- if (_src->video_meta->album_artist != NULL) {
- _dst->video_meta->album_artist = g_strdup(_src->video_meta->album_artist);
- if (_dst->video_meta->album_artist == NULL) {
- media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
- media_info_destroy((media_info_h)_dst);
- return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
- }
- }
- if (_src->video_meta->genre != NULL) {
- _dst->video_meta->genre = g_strdup(_src->video_meta->genre);
- if (_dst->video_meta->genre == NULL) {
- media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
- media_info_destroy((media_info_h)_dst);
- return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
- }
- }
- if (_src->video_meta->composer != NULL) {
- _dst->video_meta->composer = g_strdup(_src->video_meta->composer);
- if (_dst->video_meta->composer == NULL) {
- media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
- media_info_destroy((media_info_h)_dst);
- return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
- }
- }
- if (_src->video_meta->year != NULL) {
- _dst->video_meta->year = g_strdup(_src->video_meta->year);
- if (_dst->video_meta->year == NULL) {
- media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
- media_info_destroy((media_info_h)_dst);
- return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
- }
- }
- if (_src->video_meta->recorded_date != NULL) {
- _dst->video_meta->recorded_date = g_strdup(_src->video_meta->recorded_date);
- if (_dst->video_meta->recorded_date == NULL) {
- media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
- media_info_destroy((media_info_h)_dst);
- return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
- }
- }
- if (_src->video_meta->copyright != NULL) {
- _dst->video_meta->copyright = g_strdup(_src->video_meta->copyright);
- if (_dst->video_meta->copyright == NULL) {
- media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
- media_info_destroy((media_info_h)_dst);
- return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
- }
- }
- if (_src->video_meta->track_num != NULL) {
- _dst->video_meta->track_num = g_strdup(_src->video_meta->track_num);
- if (_dst->video_meta->track_num == NULL) {
- media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
- media_info_destroy((media_info_h)_dst);
- return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
- }
- }
-
- _dst->video_meta->width = _src->video_meta->width;
- _dst->video_meta->height = _src->video_meta->height;
- _dst->video_meta->duration = _src->video_meta->duration;
- _dst->video_meta->bitrate = _src->video_meta->bitrate;
- _dst->video_meta->played_count = _src->video_meta->played_count;
- _dst->video_meta->played_time = _src->video_meta->played_time;
- _dst->video_meta->played_position = _src->video_meta->played_position;
- _dst->video_meta->rotation = _src->video_meta->rotation;
-
- } else if ((_src->media_type == MEDIA_CONTENT_TYPE_MUSIC || _src->media_type == MEDIA_CONTENT_TYPE_SOUND) && _src->audio_meta) {
- _dst->audio_meta = (audio_meta_s *)calloc(1, sizeof(audio_meta_s));
- if (_dst->audio_meta == NULL) {
- media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
- media_info_destroy((media_info_h)_dst);
- return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
- }
-
- if (_src->audio_meta->media_id != NULL) {
- _dst->audio_meta->media_id = g_strdup(_src->audio_meta->media_id);
- if (_dst->audio_meta->media_id == NULL) {
- media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
- media_info_destroy((media_info_h)_dst);
- return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
- }
- }
- if (_src->audio_meta->title != NULL) {
- _dst->audio_meta->title = g_strdup(_src->audio_meta->title);
- if (_dst->audio_meta->title == NULL) {
- media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
- media_info_destroy((media_info_h)_dst);
- return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
- }
- }
- if (_src->audio_meta->album != NULL) {
- _dst->audio_meta->album = g_strdup(_src->audio_meta->album);
- if (_dst->audio_meta->album == NULL) {
- media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
- media_info_destroy((media_info_h)_dst);
- return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
- }
- }
- if (_src->audio_meta->artist != NULL) {
- _dst->audio_meta->artist = g_strdup(_src->audio_meta->artist);
- if (_dst->audio_meta->artist == NULL) {
- media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
- media_info_destroy((media_info_h)_dst);
- return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
- }
- }
- if (_src->audio_meta->album_artist != NULL) {
- _dst->audio_meta->album_artist = g_strdup(_src->audio_meta->album_artist);
- if (_dst->audio_meta->album_artist == NULL) {
- media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
- media_info_destroy((media_info_h)_dst);
- return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
- }
- }
- if (_src->audio_meta->genre != NULL) {
- _dst->audio_meta->genre = g_strdup(_src->audio_meta->genre);
- if (_dst->audio_meta->genre == NULL) {
- media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
- media_info_destroy((media_info_h)_dst);
- return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
- }
- }
- if (_src->audio_meta->composer != NULL) {
- _dst->audio_meta->composer = g_strdup(_src->audio_meta->composer);
- if (_dst->audio_meta->composer == NULL) {
- media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
- media_info_destroy((media_info_h)_dst);
- return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
- }
- }
- if (_src->audio_meta->year != NULL) {
- _dst->audio_meta->year = g_strdup(_src->audio_meta->year);
- if (_dst->audio_meta->year == NULL) {
- media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
- media_info_destroy((media_info_h)_dst);
- return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
- }
- }
- if (_src->audio_meta->recorded_date != NULL) {
- _dst->audio_meta->recorded_date = g_strdup(_src->audio_meta->recorded_date);
- if (_dst->audio_meta->recorded_date == NULL) {
- media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
- media_info_destroy((media_info_h)_dst);
- return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
- }
- }
- if (_src->audio_meta->copyright != NULL) {
- _dst->audio_meta->copyright = g_strdup(_src->audio_meta->copyright);
- if (_dst->audio_meta->copyright == NULL) {
- media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
- media_info_destroy((media_info_h)_dst);
- return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
- }
- }
- if (_src->audio_meta->track_num != NULL) {
- _dst->audio_meta->track_num = g_strdup(_src->audio_meta->track_num);
- if (_dst->audio_meta->track_num == NULL) {
- media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
- media_info_destroy((media_info_h)_dst);
- return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
- }
- }
-
- _dst->audio_meta->channel = _src->audio_meta->channel;
- _dst->audio_meta->samplerate = _src->audio_meta->samplerate;
- _dst->audio_meta->duration = _src->audio_meta->duration;
- _dst->audio_meta->bitrate = _src->audio_meta->bitrate;
- _dst->audio_meta->bitpersample = _src->audio_meta->bitpersample;
- _dst->audio_meta->played_count = _src->audio_meta->played_count;
- _dst->audio_meta->played_time = _src->audio_meta->played_time;
- _dst->audio_meta->played_position = _src->audio_meta->played_position;
- }
- *dst = (media_info_h)_dst;
-
- ret = MEDIA_CONTENT_ERROR_NONE;
- } else {
- media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
- }
-
- return ret;
-}
-
-int media_info_get_media_count_from_db(filter_h filter, int *media_count)
-{
- int ret = MEDIA_CONTENT_ERROR_NONE;
-
- if (media_count == NULL) {
- media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
-
- return ret;
- }
-
- ret = _media_db_get_group_item_count(NULL, filter, MEDIA_GROUP_NONE, media_count);
-
- return ret;
-}
-
-int media_info_foreach_media_from_db(filter_h filter, media_info_cb callback, void *user_data)
-{
- int ret = MEDIA_CONTENT_ERROR_NONE;
-
- media_content_retvm_if(callback == NULL, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid callback");
-
- ret = _media_db_get_group_item(NULL, filter, callback, user_data, MEDIA_GROUP_NONE);
-
- return ret;
-}
-
-int media_info_get_tag_count_from_db(const char *media_id, filter_h filter, int *tag_count)
-{
- int ret = MEDIA_CONTENT_ERROR_NONE;
-
- if (STRING_VALID(media_id) && tag_count) {
- ret = _media_db_get_group_item_count(media_id, filter, MEDIA_GROUP_TAG_BY_MEDIA_ID, tag_count);
- } else {
- media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
- }
-
- return ret;
-}
-
-int media_info_foreach_tag_from_db(const char *media_id, filter_h filter, media_tag_cb callback, void *user_data)
-{
- int ret = MEDIA_CONTENT_ERROR_NONE;
-
- if ((callback != NULL) && STRING_VALID(media_id)) {
- ret = _media_db_get_tag(media_id, filter, callback, user_data);
- } else {
- media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
- }
-
- return ret;
-}
-
-int media_info_get_bookmark_count_from_db(const char *media_id, filter_h filter, int *bookmark_count)
-{
- int ret = MEDIA_CONTENT_ERROR_NONE;
-
- if (STRING_VALID(media_id) && bookmark_count) {
- ret = _media_db_get_group_item_count(media_id, filter, MEDIA_GROUP_BOOKMARK_BY_MEDIA_ID, bookmark_count);
- } else {
- media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
- }
-
- return ret;
-}
-
-int media_info_foreach_bookmark_from_db(const char *media_id, filter_h filter, media_bookmark_cb callback, void *user_data)
-{
- int ret = MEDIA_CONTENT_ERROR_NONE;
-
- if ((callback != NULL) && STRING_VALID(media_id)) {
- ret = _media_db_get_bookmark(media_id, filter, callback, user_data);
- } else {
- media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
- }
-
- return ret;
-}
-
-int media_info_get_face_count_from_db(const char *media_id, filter_h filter, int *face_count)
-{
- int ret = MEDIA_CONTENT_ERROR_NONE;
-
- if (STRING_VALID(media_id) && face_count) {
- ret = _media_db_get_group_item_count(media_id, filter, MEDIA_GROUP_FACE_BY_MEDIA_ID, face_count);
- } else {
- media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
- }
-
- return ret;
-}
-
-int media_info_foreach_face_from_db(const char *media_id, filter_h filter, media_face_cb callback, void *user_data)
-{
- int ret = MEDIA_CONTENT_ERROR_NONE;
-
- if ((callback != NULL) && STRING_VALID(media_id)) {
- ret = _media_db_get_face(media_id, filter, callback, user_data);
- } else {
- media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
- }
-
- return ret;
-}
-
-int media_info_get_image(media_info_h media, image_meta_h *image)
-{
- int ret = MEDIA_CONTENT_ERROR_NONE;
-
- media_info_s *_media = (media_info_s*)media;
-
- media_content_retvm_if(_media == NULL, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid media");
- media_content_retvm_if(_media->media_type != MEDIA_CONTENT_TYPE_IMAGE, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid media_type");
- media_content_retvm_if(_media->image_meta == NULL, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid image_meta");
-
- image_meta_s *_image = (image_meta_s*)calloc(1, sizeof(image_meta_s));
- media_content_retvm_if(_image == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
-
- _image->media_id = g_strdup(_media->media_id);
- _image->width = _media->image_meta->width;
- _image->height = _media->image_meta->height;
- _image->orientation = _media->image_meta->orientation;
- _image->fnumber = _media->image_meta->fnumber;
- _image->iso = _media->image_meta->iso;
- _image->date_taken = g_strdup(_media->image_meta->date_taken);
- _image->title = g_strdup(_media->image_meta->title);
- _image->burst_id = g_strdup(_media->image_meta->burst_id);
- _image->weather = g_strdup(_media->image_meta->weather);
- _image->exposure_time = g_strdup(_media->image_meta->exposure_time);
- _image->model = g_strdup(_media->image_meta->model);
-
- *image = (image_meta_h)_image;
-
- return ret;
-}
-
-int media_info_get_video(media_info_h media, video_meta_h *video)
-{
- int ret = MEDIA_CONTENT_ERROR_NONE;
-
- media_info_s *_media = (media_info_s*)media;
-
- media_content_retvm_if(_media == NULL, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid media");
- media_content_retvm_if(_media->media_type != MEDIA_CONTENT_TYPE_VIDEO, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid media_type");
- media_content_retvm_if(_media->video_meta == NULL, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid video_meta");
-
- video_meta_s *_video = (video_meta_s*)calloc(1, sizeof(video_meta_s));
- media_content_retvm_if(_video == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
+ video_meta_s *_video = g_new0(video_meta_s, 1);
_video->media_id = g_strdup(_media->media_id);
- _video->title = g_strdup(_media->video_meta->title);
_video->album = g_strdup(_media->video_meta->album);
_video->artist = g_strdup(_media->video_meta->artist);
_video->album_artist = g_strdup(_media->video_meta->album_artist);
_video->height = _media->video_meta->height;
_video->duration = _media->video_meta->duration;
_video->bitrate = _media->video_meta->bitrate;
- _video->played_count = _media->video_meta->played_count;
- _video->played_time = _media->video_meta->played_time;
- _video->played_position = _media->video_meta->played_position;
_video->rotation = _media->video_meta->rotation;
*video = (video_meta_h)_video;
media_info_s *_media = (media_info_s*)media;
- media_content_retvm_if(_media == NULL, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid media");
- 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");
- media_content_retvm_if(_media->audio_meta == NULL, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid audio_meta");
+ content_retip_if_fail(media);
+ content_retip_if_fail(_media->media_type == MEDIA_CONTENT_TYPE_MUSIC);
+ content_retip_if_fail(_media->audio_meta);
+ content_retip_if_fail(audio);
- audio_meta_s *_audio = (audio_meta_s*)calloc(1, sizeof(audio_meta_s));
- media_content_retvm_if(_audio == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
+ audio_meta_s *_audio = g_new0(audio_meta_s, 1);
_audio->media_id = g_strdup(_media->media_id);
- _audio->title = g_strdup(_media->audio_meta->title);
_audio->album = g_strdup(_media->audio_meta->album);
_audio->artist = g_strdup(_media->audio_meta->artist);
_audio->album_artist = g_strdup(_media->audio_meta->album_artist);
_audio->bitpersample = _media->audio_meta->bitpersample;
_audio->samplerate = _media->audio_meta->samplerate;
_audio->channel = _media->audio_meta->channel;
- _audio->played_time = _media->audio_meta->played_time;
- _audio->played_count = _media->audio_meta->played_count;
- _audio->played_position = _media->audio_meta->played_position;
*audio = (audio_meta_h)_audio;
int media_info_get_media_id(media_info_h media, char **media_id)
{
- int ret = MEDIA_CONTENT_ERROR_NONE;
media_info_s *_media = (media_info_s*)media;
- if (_media && media_id) {
- if (STRING_VALID(_media->media_id)) {
- *media_id = strdup(_media->media_id);
- media_content_retvm_if(*media_id == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
- } else {
- *media_id = NULL;
- }
- ret = MEDIA_CONTENT_ERROR_NONE;
- } else {
- media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
- }
+ content_retip_if_fail(media);
+ content_retip_if_fail(media_id);
- return ret;
+ *media_id = g_strdup(_media->media_id);
+
+ return MEDIA_CONTENT_ERROR_NONE;
}
int media_info_get_file_path(media_info_h media, char **path)
{
- int ret = MEDIA_CONTENT_ERROR_NONE;
media_info_s *_media = (media_info_s*)media;
- if (_media && path) {
- if (STRING_VALID(_media->file_path)) {
- *path = strdup(_media->file_path);
- media_content_retvm_if(*path == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
- } else {
- *path = NULL;
- }
- ret = MEDIA_CONTENT_ERROR_NONE;
+ content_retip_if_fail(media);
+ content_retip_if_fail(path);
- } else {
- media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
- }
+ *path = g_strdup(_media->file_path);
- return ret;
+ return MEDIA_CONTENT_ERROR_NONE;
}
int media_info_get_display_name(media_info_h media, char **name)
{
- int ret = MEDIA_CONTENT_ERROR_NONE;
media_info_s *_media = (media_info_s*)media;
- if (_media && name) {
- if (_media->display_name != NULL) {
- *name = g_strdup(_media->display_name);
- media_content_retvm_if(*name == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
- } else {
- *name = NULL;
- }
- ret = MEDIA_CONTENT_ERROR_NONE;
- } else {
- media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
- }
-
- return ret;
-}
-
-int media_info_get_media_type(media_info_h media, media_content_type_e *type)
-{
- int ret = MEDIA_CONTENT_ERROR_NONE;
- media_info_s *_media = (media_info_s*)media;
- if (_media && type) {
- *type = _media->media_type;
- ret = MEDIA_CONTENT_ERROR_NONE;
- } else {
- media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
- }
-
- return ret;
-}
-
-int media_info_get_mime_type(media_info_h media, char **mime_type)
-{
- int ret = MEDIA_CONTENT_ERROR_NONE;
- media_info_s *_media = (media_info_s*)media;
-
- if (_media && mime_type) {
- if (STRING_VALID(_media->mime_type)) {
- *mime_type = strdup(_media->mime_type);
- media_content_retvm_if(*mime_type == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
- } else {
- *mime_type = NULL;
- }
- ret = MEDIA_CONTENT_ERROR_NONE;
- } else {
- media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
- }
-
- return ret;
-}
-
-int media_info_get_size(media_info_h media, unsigned long long *size)
-{
- int ret = MEDIA_CONTENT_ERROR_NONE;
- media_info_s *_media = (media_info_s*)media;
-
- if (_media && size) {
- *size = _media->size;
- ret = MEDIA_CONTENT_ERROR_NONE;
- } else {
- media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
- }
-
- return ret;
-}
-
-int media_info_get_added_time(media_info_h media, time_t *added_time)
-{
- int ret = MEDIA_CONTENT_ERROR_NONE;
- media_info_s *_media = (media_info_s*)media;
- if (_media && added_time) {
- *added_time = _media->added_time;
- ret = MEDIA_CONTENT_ERROR_NONE;
- } else {
- media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
- }
-
- return ret;
-}
-
-int media_info_get_modified_time(media_info_h media, time_t* time)
-{
- int ret = MEDIA_CONTENT_ERROR_NONE;
- media_info_s *_media = (media_info_s*)media;
- if (_media && time) {
- *time = _media->modified_time;
- ret = MEDIA_CONTENT_ERROR_NONE;
- } else {
- media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
- }
-
- return ret;
-}
-
-int media_info_get_timeline(media_info_h media, time_t* time)
-{
- int ret = MEDIA_CONTENT_ERROR_NONE;
- media_info_s *_media = (media_info_s*)media;
- if (_media && time) {
- *time = _media->timeline;
- ret = MEDIA_CONTENT_ERROR_NONE;
- } else {
- media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
- }
-
- return ret;
-}
-
-int media_info_get_thumbnail_path(media_info_h media, char **path)
-{
- int ret = MEDIA_CONTENT_ERROR_NONE;
- media_info_s *_media = (media_info_s*)media;
- if (_media && path) {
- if (_media->thumbnail_path != NULL) {
- *path = g_strdup(_media->thumbnail_path);
- media_content_retvm_if(*path == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
- } else {
- *path = NULL;
- }
- ret = MEDIA_CONTENT_ERROR_NONE;
-
- } else {
- media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
- }
-
- return ret;
-}
-
-int media_info_get_title(media_info_h media, char **title)
-{
- int ret = MEDIA_CONTENT_ERROR_NONE;
- media_info_s *_media = (media_info_s*)media;
-
- if (_media && title) { /*title can be empty string*/
- if (_media->title != NULL) {
- *title = g_strdup(_media->title);
- media_content_retvm_if(*title == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
- } else {
- *title = NULL;
- }
- ret = MEDIA_CONTENT_ERROR_NONE;
- } else {
- media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
- }
-
- return ret;
-}
-#ifdef _USE_TVPD_MODE
-int media_info_get_extract_flag(media_info_h media, int *extract_flag)
-{
- int ret = MEDIA_CONTENT_ERROR_NONE;
- media_info_s *_media = (media_info_s *)media;
-
- if (_media && extract_flag) {
- *extract_flag = _media->extract_flag;
- ret = MEDIA_CONTENT_ERROR_NONE;
- } else {
- media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
- }
-
- return ret;
-}
-#endif
-
-int media_info_get_description(media_info_h media, char **description)
-{
- int ret = MEDIA_CONTENT_ERROR_NONE;
- media_info_s *_media = (media_info_s*)media;
-
- if (_media && description) {
- if (_media->description != NULL) { /*description can be empty string*/
- *description = g_strdup(_media->description);
- media_content_retvm_if(*description == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
- } else {
- *description = NULL;
- }
- ret = MEDIA_CONTENT_ERROR_NONE;
- } else {
- media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
- }
-
- return ret;
-}
-
-int media_info_get_longitude(media_info_h media, double* longitude)
-{
- int ret = MEDIA_CONTENT_ERROR_NONE;
- media_info_s *_media = (media_info_s*)media;
-
- if (_media && longitude) {
- *longitude = _media->longitude;
- ret = MEDIA_CONTENT_ERROR_NONE;
- } else {
- media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
- }
+ content_retip_if_fail(media);
+ content_retip_if_fail(name);
- return ret;
-}
-int media_info_get_latitude(media_info_h media, double* latitude)
-{
- int ret = MEDIA_CONTENT_ERROR_NONE;
- media_info_s *_media = (media_info_s*)media;
+ *name = g_strdup(_media->display_name);
- if (_media && latitude) {
- *latitude = _media->latitude;
- ret = MEDIA_CONTENT_ERROR_NONE;
- } else {
- media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
- }
-
- return ret;
-}
-
-int media_info_get_altitude(media_info_h media, double *altitude)
-{
- int ret = MEDIA_CONTENT_ERROR_NONE;
- media_info_s *_media = (media_info_s*)media;
-
- if (_media && altitude) {
- *altitude = _media->altitude;
- ret = MEDIA_CONTENT_ERROR_NONE;
- } else {
- media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
- }
-
- return ret;
-}
-
-int media_info_get_weather(media_info_h media, char **weather)
-{
- int ret = MEDIA_CONTENT_ERROR_NONE;
- media_info_s *_media = (media_info_s*)media;
-
- if (_media && weather) {
- if (_media->weather != NULL) {
- *weather = strdup(_media->weather);
- media_content_retvm_if(*weather == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
- } else {
- *weather = NULL;
- }
- ret = MEDIA_CONTENT_ERROR_NONE;
- } else {
- media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
- }
-
- return ret;
-}
-
-int media_info_get_rating(media_info_h media, int *rating)
-{
- int ret = MEDIA_CONTENT_ERROR_NONE;
- media_info_s *_media = (media_info_s*)media;
-
- if (_media && rating) {
- *rating = _media->rating;
- ret = MEDIA_CONTENT_ERROR_NONE;
- } else {
- media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
- }
-
- return ret;
-}
-
-int media_info_get_favorite(media_info_h media, bool* favorite)
-{
- int ret = MEDIA_CONTENT_ERROR_NONE;
- media_info_s *_media = (media_info_s*)media;
-
- if (_media && favorite) {
- *favorite = _media->favourite;
- ret = MEDIA_CONTENT_ERROR_NONE;
- } else {
- media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
- }
-
- return ret;
-}
-
-int media_info_get_author(media_info_h media, char **author)
-{
- int ret = MEDIA_CONTENT_ERROR_NONE;
- media_content_warn("DEPRECATION WARNING: media_info_get_author() is deprecated and will be removed from next release.");
- media_info_s *_media = (media_info_s*)media;
-
- if (_media && author) {
- if (_media->author != NULL) {
- *author = strdup(_media->author);
- media_content_retvm_if(*author == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
- } else {
- *author = NULL;
- }
- ret = MEDIA_CONTENT_ERROR_NONE;
- } else {
- media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
- }
-
- return ret;
-}
-
-int media_info_get_provider(media_info_h media, char **provider)
-{
- int ret = MEDIA_CONTENT_ERROR_NONE;
- media_info_s *_media = (media_info_s*)media;
-
- if (_media && provider) {
- if (_media->provider != NULL) {
- *provider = strdup(_media->provider);
- media_content_retvm_if(*provider == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
- } else {
- *provider = NULL;
- }
- ret = MEDIA_CONTENT_ERROR_NONE;
- } else {
- media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
- }
-
- return ret;
-}
-
-int media_info_get_content_name(media_info_h media, char **content_name)
-{
- int ret = MEDIA_CONTENT_ERROR_NONE;
- media_content_warn("DEPRECATION WARNING: media_info_get_content_name() is deprecated and will be removed from next release.");
- media_info_s *_media = (media_info_s*)media;
-
- if (_media && content_name) {
- if (_media->content_name != NULL) {
- *content_name = strdup(_media->content_name);
- media_content_retvm_if(*content_name == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
- } else {
- *content_name = NULL;
- }
- ret = MEDIA_CONTENT_ERROR_NONE;
- } else {
- media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
- }
-
- return ret;
-}
-
-int media_info_get_category(media_info_h media, char **category)
-{
- int ret = MEDIA_CONTENT_ERROR_NONE;
- media_info_s *_media = (media_info_s*)media;
-
- if (_media && category) {
- if (_media->category != NULL) {
- *category = strdup(_media->category);
- media_content_retvm_if(*category == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
- } else {
- *category = NULL;
- }
- ret = MEDIA_CONTENT_ERROR_NONE;
- } else {
- media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
- }
-
- return ret;
-}
-
-int media_info_get_location_tag(media_info_h media, char **location_tag)
-{
- int ret = MEDIA_CONTENT_ERROR_NONE;
- media_info_s *_media = (media_info_s*)media;
-
- if (_media && location_tag) {
- if (_media->location_tag != NULL) {
- *location_tag = strdup(_media->location_tag);
- media_content_retvm_if(*location_tag == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
- } else {
- *location_tag = NULL;
- }
- ret = MEDIA_CONTENT_ERROR_NONE;
- } else {
- media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
- }
-
- return ret;
-}
-
-int media_info_get_age_rating(media_info_h media, char **age_rating)
-{
- int ret = MEDIA_CONTENT_ERROR_NONE;
- media_info_s *_media = (media_info_s*)media;
-
- if (_media && age_rating) {
- if (_media->age_rating != NULL) {
- *age_rating = strdup(_media->age_rating);
- media_content_retvm_if(*age_rating == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
- } else {
- *age_rating = NULL;
- }
- ret = MEDIA_CONTENT_ERROR_NONE;
- } else {
- media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
- }
-
- return ret;
+ return MEDIA_CONTENT_ERROR_NONE;
}
-int media_info_get_keyword(media_info_h media, char **keyword)
+int media_info_get_media_type(media_info_h media, media_content_type_e *type)
{
- int ret = MEDIA_CONTENT_ERROR_NONE;
- media_content_warn("DEPRECATION WARNING: media_info_get_keyword() is deprecated and will be removed from next release.");
media_info_s *_media = (media_info_s*)media;
- if (_media && keyword) {
- if (_media->keyword != NULL) {
- *keyword = strdup(_media->keyword);
- media_content_retvm_if(*keyword == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
- } else {
- *keyword = NULL;
- }
- ret = MEDIA_CONTENT_ERROR_NONE;
- } else {
- media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
- }
+ content_retip_if_fail(media);
+ content_retip_if_fail(type);
- return ret;
-}
+ *type = _media->media_type;
-int media_info_get_storage_id(media_info_h media, char **storage_id)
-{
- int ret = MEDIA_CONTENT_ERROR_NONE;
- media_info_s *_media = (media_info_s*)media;
-
- if (_media && storage_id) {
- if (STRING_VALID(_media->storage_uuid)) {
- *storage_id = strdup(_media->storage_uuid);
- media_content_retvm_if(*storage_id == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
- } else {
- *storage_id = NULL;
- ret = MEDIA_CONTENT_ERROR_DB_FAILED;
- }
- ret = MEDIA_CONTENT_ERROR_NONE;
- } else {
- media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
- }
-
- return ret;
+ return MEDIA_CONTENT_ERROR_NONE;
}
-int media_info_is_drm(media_info_h media, bool *is_drm)
+int media_info_get_mime_type(media_info_h media, char **mime_type)
{
- int ret = MEDIA_CONTENT_ERROR_NONE;
media_info_s *_media = (media_info_s*)media;
- if (_media) {
- *is_drm = _media->is_drm;
- ret = MEDIA_CONTENT_ERROR_NONE;
- } else {
- media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
- }
-
- return ret;
-}
+ content_retip_if_fail(media);
+ content_retip_if_fail(mime_type);
-int media_info_is_360_content(media_info_h media, bool *is_360)
-{
- int ret = MEDIA_CONTENT_ERROR_NONE;
- media_info_s *_media = (media_info_s*)media;
+ *mime_type = g_strdup(_media->mime_type);
- if (_media) {
- *is_360 = _media->is_360;
- ret = MEDIA_CONTENT_ERROR_NONE;
- } else {
- media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
- }
-
- return ret;
+ return MEDIA_CONTENT_ERROR_NONE;
}
-#ifdef _USE_TVPD_MODE
-int media_info_get_stitched_state(media_info_h media, int *stitched_info)
+int media_info_get_size(media_info_h media, unsigned long long *size)
{
- int ret = MEDIA_CONTENT_ERROR_NONE;
media_info_s *_media = (media_info_s*)media;
- if (_media) {
- *stitched_info = (_media->stitched_info & 0xFFFF0000) >> 16;
- ret = MEDIA_CONTENT_ERROR_NONE;
- } else {
- media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
- }
-
- return ret;
-}
+ content_retip_if_fail(media);
+ content_retip_if_fail(size);
-int media_info_get_stitched_engine(media_info_h media, int *stitched_info)
-{
- int ret = MEDIA_CONTENT_ERROR_NONE;
- media_info_s *_media = (media_info_s*)media;
+ *size = _media->size;
- if (_media) {
- *stitched_info = _media->stitched_info & 0x0000FFFF;
- ret = MEDIA_CONTENT_ERROR_NONE;
- } else {
- media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
- }
-
- return ret;
+ return MEDIA_CONTENT_ERROR_NONE;
}
-#endif
-int media_info_get_storage_type(media_info_h media, media_content_storage_e *storage_type)
+int media_info_get_added_time(media_info_h media, time_t *added_time)
{
- int ret = MEDIA_CONTENT_ERROR_NONE;
media_info_s *_media = (media_info_s*)media;
- if (_media && storage_type) {
- *storage_type = _media->storage_type;
- ret = MEDIA_CONTENT_ERROR_NONE;
- } else {
- media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
- }
-
- return ret;
-}
-
-#ifdef _USE_TVPD_MODE
-int media_info_get_played_position(media_info_h media, int *played_position)
-{
- int ret = MEDIA_CONTENT_ERROR_NONE;
- media_info_s *_media = (media_info_s*)media;
+ content_retip_if_fail(media);
+ content_retip_if_fail(added_time);
- if (_media) {
- *played_position = _media->played_position;
- ret = MEDIA_CONTENT_ERROR_NONE;
- } else {
- media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
- }
+ *added_time = _media->added_time;
- return ret;
+ return MEDIA_CONTENT_ERROR_NONE;
}
-#endif
-int media_info_get_played_count(media_info_h media, int *played_count)
+int media_info_get_modified_time(media_info_h media, time_t* time)
{
- int ret = MEDIA_CONTENT_ERROR_NONE;
- media_content_warn("DEPRECATION WARNING: media_info_get_played_count() is deprecated and will be removed from next release.");
media_info_s *_media = (media_info_s*)media;
- if (_media) {
- *played_count = _media->played_count;
- ret = MEDIA_CONTENT_ERROR_NONE;
- } else {
- media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
- }
+ content_retip_if_fail(media);
+ content_retip_if_fail(time);
- return ret;
+ *time = _media->modified_time;
+
+ return MEDIA_CONTENT_ERROR_NONE;
}
-int media_info_get_played_time(media_info_h media, time_t* played_time)
+int media_info_get_timeline(media_info_h media, time_t* time)
{
- int ret = MEDIA_CONTENT_ERROR_NONE;
- media_content_warn("DEPRECATION WARNING: media_info_get_played_time() is deprecated and will be removed from next release.");
media_info_s *_media = (media_info_s*)media;
- if (_media) {
- *played_time = _media->played_time;
- ret = MEDIA_CONTENT_ERROR_NONE;
- } else {
- media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
- }
+ content_retip_if_fail(media);
+ content_retip_if_fail(time);
- return ret;
+ *time = _media->timeline;
+
+ return MEDIA_CONTENT_ERROR_NONE;
}
-int media_info_increase_played_count(media_info_h media)
+int media_info_get_thumbnail_path(media_info_h media, char **path)
{
- int ret = MEDIA_CONTENT_ERROR_NONE;
- media_content_warn("DEPRECATION WARNING: media_info_increase_played_count() is deprecated and will be removed from next release.");
-
media_info_s *_media = (media_info_s*)media;
- if (_media) {
- _media->played_count += 1;
- } else {
- media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
- }
+ content_retip_if_fail(media);
+ content_retip_if_fail(path);
- return ret;
+ *path = g_strdup(_media->thumbnail_path);
+
+ return MEDIA_CONTENT_ERROR_NONE;
}
-#ifdef _USE_TVPD_MODE
-int media_info_get_modified_month(media_info_h media, char **modified_month)
+int media_info_get_title(media_info_h media, char **title)
{
- int ret = MEDIA_CONTENT_ERROR_NONE;
media_info_s *_media = (media_info_s*)media;
- if (_media && modified_month) {
- if (STRING_VALID(_media->modified_month)) {
- *modified_month = strdup(_media->modified_month);
- if (*modified_month == NULL) {
- media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
- return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
- }
- } else {
- *modified_month = NULL;
- }
- ret = MEDIA_CONTENT_ERROR_NONE;
- } else {
- media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
- }
+ content_retip_if_fail(media);
+ content_retip_if_fail(title);
- return ret;
+ *title = g_strdup(_media->title);
+
+ return MEDIA_CONTENT_ERROR_NONE;
}
-#endif
-#ifdef _USE_SENIOR_MODE
-int media_info_get_contact(media_info_h media, char **contact)
+
+int media_info_get_description(media_info_h media, char **description)
{
- int ret = MEDIA_CONTENT_ERROR_NONE;
media_info_s *_media = (media_info_s*)media;
- if (_media && contact) {
- if (STRING_VALID(_media->contact)) {
- *contact = strdup(_media->contact);
- if (*contact == NULL) {
- media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
- return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
- }
- } else {
- *contact = NULL;
- }
- ret = MEDIA_CONTENT_ERROR_NONE;
- } else {
- media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
- }
+ content_retip_if_fail(media);
+ content_retip_if_fail(description);
- return ret;
+ *description = g_strdup(_media->description);
+
+ return MEDIA_CONTENT_ERROR_NONE;
}
-int media_info_get_app_data(media_info_h media, char **app_data)
+int media_info_get_longitude(media_info_h media, double* longitude)
{
- int ret = MEDIA_CONTENT_ERROR_NONE;
media_info_s *_media = (media_info_s*)media;
- if (_media && app_data) {
- if (STRING_VALID(_media->app_data)) {
- *app_data = strdup(_media->app_data);
- if (*app_data == NULL) {
- media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
- return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
- }
- } else {
- *app_data = NULL;
- }
- ret = MEDIA_CONTENT_ERROR_NONE;
- } else {
- media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
- }
+ content_retip_if_fail(media);
+ content_retip_if_fail(longitude);
- return ret;
+ *longitude = _media->longitude;
+
+ return MEDIA_CONTENT_ERROR_NONE;
}
-#endif
-#ifdef _USE_TVPD_MODE
-int media_info_set_played_count(media_info_h media, int played_count)
+int media_info_get_latitude(media_info_h media, double* latitude)
{
- int ret = MEDIA_CONTENT_ERROR_NONE;
-
media_info_s *_media = (media_info_s*)media;
- if (_media) {
- _media->played_count = played_count;
- } else {
- media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
- }
+ content_retip_if_fail(media);
+ content_retip_if_fail(latitude);
- return ret;
+ *latitude = _media->latitude;
+
+ return MEDIA_CONTENT_ERROR_NONE;
}
-#endif
-int media_info_set_played_time(media_info_h media)
+int media_info_get_altitude(media_info_h media, double *altitude)
{
- int ret = MEDIA_CONTENT_ERROR_NONE;
- media_content_warn("DEPRECATION WARNING: media_info_set_played_time() is deprecated and will be removed from next release.");
- time_t current_time;
-
media_info_s *_media = (media_info_s*)media;
- if (_media != NULL) {
- time(¤t_time);
- _media->played_time = current_time;
- } else {
- media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
- }
+ content_retip_if_fail(media);
+ content_retip_if_fail(altitude);
- return ret;
+ *altitude = _media->altitude;
+
+ return MEDIA_CONTENT_ERROR_NONE;
}
-#ifdef _USE_TVPD_MODE
-int media_info_set_played_position(media_info_h media, int played_position)
+
+int media_info_get_rating(media_info_h media, int *rating)
{
- int ret = MEDIA_CONTENT_ERROR_NONE;
media_info_s *_media = (media_info_s*)media;
- if ((_media != NULL) && (played_position >= 0)) {
- _media->played_position = played_position;
- } else {
- media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
- }
+ content_retip_if_fail(media);
+ content_retip_if_fail(rating);
- return ret;
+ *rating = _media->rating;
+
+ return MEDIA_CONTENT_ERROR_NONE;
}
-#endif
-int media_info_get_media_from_db(const char *media_id, media_info_h *media)
+int media_info_get_favorite(media_info_h media, bool* favorite)
{
- int ret = MEDIA_CONTENT_ERROR_NONE;
- char select_query[DEFAULT_QUERY_SIZE] = {0, };
- char storage_id[MEDIA_CONTENT_UUID_SIZE+1] = {0, };
- sqlite3_stmt *stmt = NULL;
+ media_info_s *_media = (media_info_s*)media;
- if (!STRING_VALID(media_id) || (media == NULL)) {
- media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
- }
+ content_retip_if_fail(media);
+ content_retip_if_fail(favorite);
- memset(select_query, 0x00, sizeof(select_query));
- memset(storage_id, 0x00, sizeof(storage_id));
+ *favorite = _media->favourite;
- ret = _media_db_get_storage_id_by_media_id(media_id, storage_id);
- media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
+ return MEDIA_CONTENT_ERROR_NONE;
+}
- snprintf(select_query, sizeof(select_query), SELECT_MEDIA_FROM_MEDIA, storage_id, media_id);
+int media_info_get_storage_id(media_info_h media, char **storage_id)
+{
+ content_warn("DEPRECATION WARNING: media_info_get_storage_id() is deprecated and will be removed from next release.");
+ media_info_s *_media = (media_info_s*)media;
- ret = _content_query_prepare(&stmt, select_query, NULL, NULL);
- media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
+ content_retip_if_fail(media);
+ content_retip_if_fail(storage_id);
- media_info_s *_media = NULL;
+ *storage_id = g_strdup(_media->storage_uuid);
- while (sqlite3_step(stmt) == SQLITE_ROW) {
- if (_media)
- media_info_destroy((media_info_h)_media);
+ return MEDIA_CONTENT_ERROR_NONE;
+}
- _media = (media_info_s*)calloc(1, sizeof(media_info_s));
+int media_info_is_drm(media_info_h media, bool *is_drm)
+{
+ media_info_s *_media = (media_info_s*)media;
- if (_media == NULL) {
- media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
- SQLITE3_FINALIZE(stmt);
- return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
- }
+ content_retip_if_fail(media);
+ content_retip_if_fail(is_drm);
- _media_info_item_get_detail(stmt, (media_info_h)_media);
+ *is_drm = _media->is_drm;
- *media = (media_info_h)_media;
- }
+ return MEDIA_CONTENT_ERROR_NONE;
+}
- SQLITE3_FINALIZE(stmt);
+int media_info_is_360_content(media_info_h media, bool *is_360)
+{
+ media_info_s *_media = (media_info_s*)media;
- return ret;
+ content_retip_if_fail(media);
+ content_retip_if_fail(is_360);
+
+ *is_360 = _media->is_360;
+
+ return MEDIA_CONTENT_ERROR_NONE;
}
-int media_info_set_display_name(media_info_h media, const char *display_name)
+int media_info_get_storage_type(media_info_h media, media_content_storage_e *storage_type)
{
- int ret = MEDIA_CONTENT_ERROR_NONE;
- media_content_warn("DEPRECATION WARNING: media_info_set_display_name() is deprecated and will be removed from next release.");
+ content_warn("DEPRECATION WARNING: media_info_get_storage_type() is deprecated and will be removed from next release. Use storage_get_type_dev() instead.");
media_info_s *_media = (media_info_s*)media;
- if (_media != NULL && STRING_VALID(display_name)) {
- SAFE_FREE(_media->display_name);
+ content_retip_if_fail(media);
+ content_retip_if_fail(storage_type);
- _media->display_name = strdup(display_name);
- media_content_retvm_if(_media->display_name == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
- } else {
- media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
- }
+ *storage_type = _media->storage_type;
- return ret;
+ return MEDIA_CONTENT_ERROR_NONE;
}
-int media_info_set_description(media_info_h media, const char *description)
+#ifdef _USE_TVPD_MODE
+int media_info_get_played_count(media_info_h media, int *played_count)
{
- int ret = MEDIA_CONTENT_ERROR_NONE;
- media_content_warn("DEPRECATION WARNING: media_info_set_description() is deprecated and will be removed from next release.");
media_info_s *_media = (media_info_s*)media;
- if (_media != NULL) {
- SAFE_FREE(_media->description);
+ content_retip_if_fail(media);
+ content_retip_if_fail(played_count);
- if (STRING_VALID(description)) {
- _media->description = strdup(description);
- media_content_retvm_if(_media->description == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
- } else {
- _media->description = NULL;
- }
- } else {
- media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
- }
+ *played_count = _media->played_count;
- return ret;
+ return MEDIA_CONTENT_ERROR_NONE;
}
-int media_info_set_longitude(media_info_h media, double longitude)
+int media_info_set_played_count(media_info_h media, int played_count)
{
- int ret = MEDIA_CONTENT_ERROR_NONE;
- media_content_warn("DEPRECATION WARNING: media_info_set_longitude() is deprecated and will be removed from next release.");
media_info_s *_media = (media_info_s*)media;
- if (_media != NULL) {
- _media->longitude = longitude;
- } else {
- media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
- }
+ content_retip_if_fail(media);
- return ret;
+ _media->played_count = played_count;
+
+ return MEDIA_CONTENT_ERROR_NONE;
}
-int media_info_set_latitude(media_info_h media, double latitude)
+int media_info_set_played_position(media_info_h media, int played_position)
{
- int ret = MEDIA_CONTENT_ERROR_NONE;
- media_content_warn("DEPRECATION WARNING: media_info_set_latitude() is deprecated and will be removed from next release.");
media_info_s *_media = (media_info_s*)media;
- if (_media != NULL) {
- _media->latitude = latitude;
- } else {
- media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
- }
+ content_retip_if_fail(media);
+ content_retip_if_fail(played_position >= 0);
- return ret;
+ _media->played_position = played_position;
+
+ return MEDIA_CONTENT_ERROR_NONE;
}
-int media_info_set_altitude(media_info_h media, double altitude)
+int media_info_get_played_position(media_info_h media, int *played_position)
{
- int ret = MEDIA_CONTENT_ERROR_NONE;
- media_content_warn("DEPRECATION WARNING: media_info_set_altitude() is deprecated and will be removed from next release.");
media_info_s *_media = (media_info_s*)media;
- if (_media != NULL) {
- _media->altitude = altitude;
- } else {
- media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
- }
+ content_retip_if_fail(media);
+ content_retip_if_fail(played_position);
- return ret;
+ *played_position = _media->played_position;
+
+ return MEDIA_CONTENT_ERROR_NONE;
}
-int media_info_set_weather(media_info_h media, const char *weather)
+int media_info_set_played_time(media_info_h media)
{
- int ret = MEDIA_CONTENT_ERROR_NONE;
+ time_t current_time;
+
media_info_s *_media = (media_info_s*)media;
- if (_media != NULL) {
- SAFE_FREE(_media->weather);
+ content_retip_if_fail(media);
- if (STRING_VALID(weather)) {
- _media->weather = strdup(weather);
- media_content_retvm_if(_media->weather == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
- } else {
- _media->weather = NULL;
- }
- } else {
- media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
- }
+ time(¤t_time);
+ _media->played_time = current_time;
- return ret;
+ return MEDIA_CONTENT_ERROR_NONE;
}
-int media_info_set_rating(media_info_h media, int rating)
+int media_info_get_played_time(media_info_h media, time_t* played_time)
{
- int ret = MEDIA_CONTENT_ERROR_NONE;
- media_content_warn("DEPRECATION WARNING: media_info_set_rating() is deprecated and will be removed from next release.");
media_info_s *_media = (media_info_s*)media;
- if (_media != NULL) {
- _media->rating = rating;
- } else {
- media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
- }
+ content_retip_if_fail(media);
+ content_retip_if_fail(played_time);
- return ret;
+ *played_time = _media->played_time;
+
+ return MEDIA_CONTENT_ERROR_NONE;
}
-int media_info_set_added_time(media_info_h media, time_t added_time)
+int media_info_get_extract_flag(media_info_h media, int *extract_flag)
{
- int ret = MEDIA_CONTENT_ERROR_NONE;
- media_content_warn("DEPRECATION WARNING: media_info_set_added_time() is deprecated and will be removed from next release.");
+ media_info_s *_media = (media_info_s *)media;
- media_info_s *_media = (media_info_s*)media;
+ content_retip_if_fail(media);
+ content_retip_if_fail(extract_flag);
- if ((_media != NULL) && (added_time >= 0)) {
- _media->added_time = added_time;
- } else {
- media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
- }
+ *extract_flag = _media->extract_flag;
- return ret;
+ return MEDIA_CONTENT_ERROR_NONE;
}
-int media_info_set_favorite(media_info_h media, bool favorite)
+int media_info_get_stitched_state(media_info_h media, int *stitched_info)
{
- int ret = MEDIA_CONTENT_ERROR_NONE;
media_info_s *_media = (media_info_s*)media;
- if (_media != NULL) {
- if (favorite == TRUE)
- time(&_media->favourite);
- else
- _media->favourite = 0;
- } else {
- media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
- }
+ content_retip_if_fail(media);
+ content_retip_if_fail(stitched_info);
- return ret;
+ *stitched_info = (_media->stitched_info & 0xFFFF0000) >> 16;
+
+ return MEDIA_CONTENT_ERROR_NONE;
}
-int media_info_set_author(media_info_h media, const char *author)
+int media_info_get_stitched_engine(media_info_h media, int *stitched_info)
{
- int ret = MEDIA_CONTENT_ERROR_NONE;
- media_content_warn("DEPRECATION WARNING: media_info_set_author() is deprecated and will be removed from next release.");
media_info_s *_media = (media_info_s*)media;
- if (_media != NULL) {
- if (STRING_VALID(author)) {
- _media->author = strdup(author);
- media_content_retvm_if(_media->author == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
- } else {
- _media->author = NULL;
- }
- } else {
- media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
- }
+ content_retip_if_fail(media);
+ content_retip_if_fail(stitched_info);
- return ret;
+ *stitched_info = _media->stitched_info & 0x0000FFFF;
+
+ return MEDIA_CONTENT_ERROR_NONE;
}
-int media_info_set_provider(media_info_h media, const char *provider)
+int media_info_get_modified_month(media_info_h media, char **modified_month)
{
- int ret = MEDIA_CONTENT_ERROR_NONE;
media_info_s *_media = (media_info_s*)media;
- if (_media != NULL) {
- SAFE_FREE(_media->provider);
+ content_retip_if_fail(media);
+ content_retip_if_fail(modified_month);
- if (STRING_VALID(provider)) {
- _media->provider = strdup(provider);
- media_content_retvm_if(_media->provider == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
- } else {
- _media->provider = NULL;
- }
- } else {
- media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
- }
+ *modified_month = g_strdup(_media->modified_month);
- return ret;
+ return MEDIA_CONTENT_ERROR_NONE;
}
-int media_info_set_content_name(media_info_h media, const char *content_name)
+#endif
+
+int media_info_get_media_from_db(const char *media_id, media_info_h *media)
{
int ret = MEDIA_CONTENT_ERROR_NONE;
- media_content_warn("DEPRECATION WARNING: media_info_set_content_name() is deprecated and will be removed from next release.");
- media_info_s *_media = (media_info_s*)media;
+ char select_query[DEFAULT_QUERY_SIZE] = {0, };
+ sqlite3_stmt *stmt = NULL;
- if (_media != NULL) {
- SAFE_FREE(_media->content_name);
+ content_retip_if_fail(STRING_VALID(media_id));
+ content_retip_if_fail(media);
- if (STRING_VALID(content_name)) {
- _media->content_name = strdup(content_name);
- media_content_retvm_if(_media->content_name == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
- } else {
- _media->content_name = NULL;
- }
- } else {
- media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
- }
+#ifdef _USE_TVPD_MODE
+ char *storage_id = NULL;
- return ret;
-}
+ ret = _media_db_get_storage_id_by_media_id(media_id, &storage_id);
+ content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
+ snprintf(select_query, sizeof(select_query), SELECT_MEDIA_FROM_MEDIA, storage_id, media_id);
+ g_free(storage_id);
+#else
+ snprintf(select_query, sizeof(select_query), SELECT_MEDIA_FROM_MEDIA, media_id);
+#endif
+ ret = _content_get_result(select_query, &stmt);
+ content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
-int media_info_set_category(media_info_h media, const char *category)
-{
- int ret = MEDIA_CONTENT_ERROR_NONE;
- media_info_s *_media = (media_info_s*)media;
+ media_info_s *_media = NULL;
- if (_media != NULL) {
- SAFE_FREE(_media->category);
+ if (sqlite3_step(stmt) == SQLITE_ROW) {
+ _media = g_new0(media_info_s, 1);
- if (STRING_VALID(category)) {
- _media->category = strdup(category);
- media_content_retvm_if(_media->category == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
- } else {
- _media->category = NULL;
- }
+ _media_info_item_get_detail(stmt, (media_info_h)_media);
+
+ *media = (media_info_h)_media;
} else {
- media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
}
+ SQLITE3_FINALIZE(stmt);
+
return ret;
}
-int media_info_set_location_tag(media_info_h media, const char *location_tag)
+int media_info_get_media_from_db_by_path(const char *path, media_info_h *media)
{
int ret = MEDIA_CONTENT_ERROR_NONE;
- media_info_s *_media = (media_info_s*)media;
-
- if (_media != NULL) {
- SAFE_FREE(_media->location_tag);
+ media_info_s *_media = NULL;
- if (STRING_VALID(location_tag)) {
- _media->location_tag = strdup(location_tag);
- media_content_retvm_if(_media->location_tag == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
- } else {
- _media->location_tag = NULL;
- }
- } else {
- media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
- }
+ content_retip_if_fail(STRING_VALID(path));
+ content_retip_if_fail(media);
+ ret = _media_util_check_file_exist(path);
+ content_retvm_if(ret != MEDIA_CONTENT_ERROR_NONE, ret, "_media_util_check_file_exist failed : %d", ret);
- return ret;
-}
+#ifdef _USE_TVPD_MODE
+ char storage_id[MEDIA_CONTENT_UUID_SIZE + 1] = {0, };
-int media_info_set_age_rating(media_info_h media, const char *age_rating)
-{
- int ret = MEDIA_CONTENT_ERROR_NONE;
- media_info_s *_media = (media_info_s*)media;
+ ret = media_svc_get_storage_id(_content_get_db_handle(), path, storage_id, _content_get_uid());
+ if (ret != MS_MEDIA_ERR_NONE) {
+ content_error("media_svc_get_storage_id failed : %d", ret);
+ return _content_error_capi(ret);
+ }
+#endif
- if (_media != NULL) {
- SAFE_FREE(_media->age_rating);
+ _media = g_new0(media_info_s, 1);
- if (STRING_VALID(age_rating)) {
- _media->age_rating = strdup(age_rating);
- media_content_retvm_if(_media->age_rating == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
- } else {
- _media->age_rating = NULL;
- }
- } else {
- media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+#ifdef _USE_TVPD_MODE
+ ret = _media_info_get_media_info_from_db(path, STRING_VALID(storage_id) ? storage_id : DB_TABLE_MEDIA, (media_info_h)_media);
+#else
+ ret = _media_info_get_media_info_from_db(path, (media_info_h)_media);
+#endif
+ if (ret != MEDIA_CONTENT_ERROR_NONE) {
+ g_free(_media);
+ _media = NULL;
}
+ *media = (media_info_h)_media;
+
return ret;
}
-int media_info_set_keyword(media_info_h media, const char *keyword)
+int media_info_set_favorite(media_info_h media, bool favorite)
{
- int ret = MEDIA_CONTENT_ERROR_NONE;
- media_content_warn("DEPRECATION WARNING: media_info_set_keyword() is deprecated and will be removed from next release.");
media_info_s *_media = (media_info_s*)media;
- if (_media != NULL) {
- SAFE_FREE(_media->keyword);
+ content_retip_if_fail(media);
- if (STRING_VALID(keyword)) {
- _media->keyword = strdup(keyword);
- media_content_retvm_if(_media->keyword == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
- } else {
- _media->keyword = NULL;
- }
- } else {
- media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
- }
+ if (favorite == TRUE)
+ time(&_media->favourite);
+ else
+ _media->favourite = 0;
- return ret;
+ return MEDIA_CONTENT_ERROR_NONE;
}
int media_info_update_to_db(media_info_h media)
char *set_sql = NULL;
char *sql = NULL;
- if (_media != NULL && STRING_VALID(_media->media_id)) {
- /* This sql is due to sqlite3_mprintf's wrong operation when using floating point in the text format */
- /* This code will be removed when sqlite3_mprintf works clearly */
- char *test_sql = sqlite3_mprintf("%f, %f, %f", _media->longitude, _media->latitude, _media->altitude);
- SQLITE3_SAFE_FREE(test_sql);
-
- /*Update Pinyin If Support Pinyin*/
- char *file_name_pinyin = NULL;
- char *description_pinyin = NULL;
- char *author_pinyin = NULL;
- char *provider_pinyin = NULL;
- char *content_name_pinyin = NULL;
- char *category_pinyin = NULL;
- char *location_tag_pinyin = NULL;
- char *age_rating_pinyin = NULL;
- char *keyword_pinyin = NULL;
- bool pinyin_support = FALSE;
-
- /*Update Pinyin If Support Pinyin*/
- media_svc_check_pinyin_support(&pinyin_support);
- if (pinyin_support) {
- if (STRING_VALID(_media->display_name))
- media_svc_get_pinyin(_media->display_name, &file_name_pinyin);
- if (STRING_VALID(_media->description))
- media_svc_get_pinyin(_media->description, &description_pinyin);
- if (STRING_VALID(_media->author))
- media_svc_get_pinyin(_media->author, &author_pinyin);
- if (STRING_VALID(_media->provider))
- media_svc_get_pinyin(_media->provider, &provider_pinyin);
- if (STRING_VALID(_media->content_name))
- media_svc_get_pinyin(_media->content_name, &content_name_pinyin);
- if (STRING_VALID(_media->category))
- media_svc_get_pinyin(_media->category, &category_pinyin);
- if (STRING_VALID(_media->location_tag))
- media_svc_get_pinyin(_media->location_tag, &location_tag_pinyin);
- if (STRING_VALID(_media->age_rating))
- media_svc_get_pinyin(_media->age_rating, &age_rating_pinyin);
- if (STRING_VALID(_media->keyword))
- media_svc_get_pinyin(_media->keyword, &keyword_pinyin);
- }
+ content_retip_if_fail(media);
+ content_retip_if_fail(STRING_VALID(_media->media_id));
- char *album = NULL;
- char *artist = NULL;
- char *genre = NULL;
- char *recorded_date = NULL;
-
- if (_media->media_type == MEDIA_CONTENT_TYPE_VIDEO) {
- if (_media->video_meta->album != NULL)
- album = strdup(_media->video_meta->album);
- if (_media->video_meta->artist != NULL)
- artist = strdup(_media->video_meta->artist);
- if (_media->video_meta->genre != NULL)
- genre = strdup(_media->video_meta->genre);
- if (_media->video_meta->recorded_date != NULL)
- recorded_date = strdup(_media->video_meta->recorded_date);
- } else if ((_media->media_type == MEDIA_CONTENT_TYPE_MUSIC) || (_media->media_type == MEDIA_CONTENT_TYPE_SOUND)) {
- if (_media->audio_meta->album != NULL)
- album = strdup(_media->audio_meta->album);
- if (_media->audio_meta->artist != NULL)
- artist = strdup(_media->audio_meta->artist);
- if (_media->audio_meta->genre != NULL)
- genre = strdup(_media->audio_meta->genre);
- if (_media->audio_meta->recorded_date != NULL)
- recorded_date = strdup(_media->audio_meta->recorded_date);
- }
+ /* This sql is due to sqlite3_mprintf's wrong operation when using floating point in the text format */
+ /* This code will be removed when sqlite3_mprintf works clearly */
+ char *test_sql = sqlite3_mprintf("%f, %f, %f", _media->longitude, _media->latitude, _media->altitude);
+ SQLITE3_SAFE_FREE(test_sql);
-#ifdef _USE_SENIOR_MODE
- if (_media_content_is_support_senior_mode()) {
- set_sql = sqlite3_mprintf("file_name=%Q, added_time=%d, description=%Q, longitude=%f, latitude=%f, altitude=%f, \
- played_count=%d, last_played_time=%d, last_played_position=%d, \
- 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, \
- 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",
- _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,
- _media->author, _media->provider, _media->content_name, _media->category, _media->location_tag, _media->age_rating, _media->keyword, _media->weather, _media->sync_status,
- 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);
- } else
-#endif
- {
- set_sql = sqlite3_mprintf("file_name=%Q, added_time=%d, description=%Q, longitude=%f, latitude=%f, altitude=%f, \
- played_count=%d, last_played_time=%d, last_played_position=%d, \
- 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, \
- 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, \
- album=%Q, artist=%Q, genre=%Q, recorded_date=%Q",
- _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,
- _media->author, _media->provider, _media->content_name, _media->category, _media->location_tag, _media->age_rating, _media->keyword, _media->weather, _media->sync_status,
- file_name_pinyin, description_pinyin, author_pinyin, provider_pinyin, content_name_pinyin, category_pinyin, location_tag_pinyin, age_rating_pinyin, keyword_pinyin, _media->title,
- album, artist, genre, recorded_date);
- }
+ /*Update Pinyin If Support Pinyin*/
+ char *file_name_pinyin = NULL;
+ char *description_pinyin = NULL;
+ bool pinyin_support = FALSE;
- sql = sqlite3_mprintf("UPDATE %Q SET %s WHERE media_uuid=%Q", _media->storage_uuid, set_sql, _media->media_id);
-
- ret = _content_query_sql(sql);
- SQLITE3_SAFE_FREE(set_sql);
- SQLITE3_SAFE_FREE(sql);
-
- SAFE_FREE(file_name_pinyin);
- SAFE_FREE(description_pinyin);
- SAFE_FREE(author_pinyin);
- SAFE_FREE(provider_pinyin);
- SAFE_FREE(content_name_pinyin);
- SAFE_FREE(category_pinyin);
- SAFE_FREE(location_tag_pinyin);
- SAFE_FREE(age_rating_pinyin);
- SAFE_FREE(keyword_pinyin);
-
- SAFE_FREE(album);
- SAFE_FREE(artist);
- SAFE_FREE(genre);
- SAFE_FREE(recorded_date);
-
- if (ret == MEDIA_CONTENT_ERROR_NONE) {
- /* Send notification for this update */
- media_content_debug("Update is successfull. Send notification for this");
- if (_media->file_path && _media->mime_type)
- media_svc_publish_noti(MS_MEDIA_ITEM_FILE, MS_MEDIA_ITEM_UPDATE, _media->file_path, _media->media_type, _media->media_id, _media->mime_type);
- else
- media_content_error("Can't Send Noti : path or mime type is NULL");
- }
- } else {
- media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+ /*Update Pinyin If Support Pinyin*/
+ media_svc_check_pinyin_support(&pinyin_support);
+ if (pinyin_support) {
+ if (STRING_VALID(_media->display_name))
+ media_svc_get_pinyin(_media->display_name, &file_name_pinyin);
+ if (STRING_VALID(_media->description))
+ media_svc_get_pinyin(_media->description, &description_pinyin);
+ }
+#ifdef _USE_TVPD_MODE
+ set_sql = sqlite3_mprintf("media_display_name=%Q, media_description=%Q, media_longitude=%f, media_latitude=%f, media_file_name_pinyin=%Q, media_description_pinyin=%Q, played_count=%d, last_played_time=%d, last_played_position=%d, media_rating=%d, media_favourite=%d",
+ _media->display_name, _media->description, _media->longitude, _media->latitude, file_name_pinyin, description_pinyin, _media->played_count, _media->played_time, _media->played_position, _media->rating, _media->favourite);
+#else
+ set_sql = sqlite3_mprintf("media_display_name=%Q, media_description=%Q, media_longitude=%f, media_latitude=%f, media_file_name_pinyin=%Q, media_description_pinyin=%Q, media_rating=%d, media_favourite=%d", _media->display_name, _media->description, _media->longitude, _media->latitude, file_name_pinyin, description_pinyin, _media->rating, _media->favourite);
+#endif
+#ifdef _USE_TVPD_MODE
+ sql = sqlite3_mprintf("UPDATE %Q SET %s WHERE media_id=%Q", _media->storage_uuid, set_sql, _media->media_id);
+#else
+ sql = sqlite3_mprintf("UPDATE %q SET %s WHERE media_id=%Q", DB_TABLE_MEDIA, set_sql, _media->media_id);
+#endif
+ ret = _content_query_sql(sql);
+ SQLITE3_SAFE_FREE(set_sql);
+ SQLITE3_SAFE_FREE(sql);
+
+ SAFE_FREE(file_name_pinyin);
+ SAFE_FREE(description_pinyin);
+
+ if (ret == MEDIA_CONTENT_ERROR_NONE) {
+ /* Send notification for this update */
+ content_debug("Update is successfull. Send notification for this");
+ if (_media->file_path && _media->mime_type)
+ media_svc_publish_noti(MS_MEDIA_ITEM_UPDATE, _media->file_path, _media->media_type, _media->media_id, _media->mime_type);
+ else
+ content_error("Can't Send Noti : path or mime type is NULL");
}
return ret;
}
-int media_info_refresh_metadata_to_db(const char *media_id)
+int media_info_move_to_db(media_info_h media, const char* dst_path)
{
int ret = MEDIA_CONTENT_ERROR_NONE;
- media_content_warn("DEPRECATION WARNING: media_info_refresh_metadata_to_db() is deprecated and will be removed from next release.");
- media_info_h media = NULL;
- char *file_path = NULL;
- media_content_storage_e storage_type = 0;
- char storage_id[MEDIA_CONTENT_UUID_SIZE+1] = {0, };
char repl_path[MAX_PATH_LEN] = {0, };
+ media_info_s *_info = NULL;
+#ifdef _USE_TVPD_MODE
+ char storage_id[MEDIA_CONTENT_UUID_SIZE + 1] = {0, };
+#endif
- if (!STRING_VALID(media_id)) {
- media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
- }
+ content_retip_if_fail(media);
+ content_retip_if_fail(STRING_VALID(dst_path));
- ret = media_info_get_media_from_db(media_id, &media);
- if (ret != MEDIA_CONTENT_ERROR_NONE) {
- media_info_destroy(media);
- return ret;
- }
+ ret = _media_content_replace_path(dst_path, repl_path);
+ content_retvm_if(!STRING_VALID(repl_path), MEDIA_CONTENT_ERROR_INVALID_OPERATION, "path replacement failed");
- ret = media_info_get_storage_type(media, &storage_type);
- if (ret != MEDIA_CONTENT_ERROR_NONE) {
- media_info_destroy(media);
- return ret;
- }
+ media_info_s *_media = (media_info_s*)media;
- ret = media_info_get_file_path(media, &file_path);
- if (ret != MEDIA_CONTENT_ERROR_NONE) {
- media_info_destroy(media);
- return ret;
- }
- memset(repl_path, 0, sizeof(repl_path));
- ret = _media_content_replace_path(file_path, repl_path);
+ /* If dst_path is folder, append file_name */
+ if (g_file_test(repl_path, G_FILE_TEST_IS_DIR)) {
+ if (repl_path[strlen(repl_path) - 1] != '/')
+ SAFE_STRLCAT(repl_path, "/", sizeof(repl_path));
- ret = _media_util_check_file_exist(repl_path);
- if (ret != MEDIA_CONTENT_ERROR_NONE) {
- SAFE_FREE(file_path);
- media_info_destroy(media);
- return ret;
+ SAFE_STRLCAT(repl_path, _media->display_name, sizeof(repl_path));
}
- memset(storage_id, 0x00, sizeof(storage_id));
+ /* If the two paths are the same, do nothing */
+ content_retvm_if(g_strcmp0(repl_path, _media->file_path) == 0, MEDIA_CONTENT_ERROR_NONE, "Same path");
+
+ ret = __media_info_check_file_validity(repl_path);
+ content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
+
+ ret = media_svc_move_item(_content_get_db_handle(), _media->file_path, repl_path, _media->media_id, _media->media_type, _media->mime_type, _content_get_uid());
+ ret = _content_error_capi(ret);
+ content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
+
+ /* Update media_info handle */
+ _info = g_new0(media_info_s, 1);
+
+#ifdef _USE_TVPD_MODE
ret = media_svc_get_storage_id(_content_get_db_handle(), repl_path, storage_id, _content_get_uid());
- if (ret != MS_MEDIA_ERR_NONE) {
- media_content_error("media_svc_get_storage_id failed : %d", ret);
- SAFE_FREE(file_path);
- media_info_destroy(media);
- return _content_error_capi(MEDIA_CONTENT_TYPE, ret);
- }
+ content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
+
+ ret = _media_info_get_media_info_from_db(repl_path, storage_id, (media_info_h)_info);
+#else
+ ret = _media_info_get_media_info_from_db(repl_path, (media_info_h)_info);
+#endif
- ret = media_svc_refresh_item(_content_get_db_handle(), storage_id, storage_type, repl_path, _content_get_uid());
- if (ret != MS_MEDIA_ERR_NONE)
- ret = _content_error_capi(MEDIA_CONTENT_TYPE, ret);
+ SAFE_FREE(_media->display_name);
+ _media->display_name = g_strdup(_info->display_name);
+ SAFE_FREE(_media->file_path);
+ _media->file_path = g_strdup(_info->file_path);
+ _media->storage_type = _info->storage_type;
+ SAFE_FREE(_media->storage_uuid);
+ _media->storage_uuid = g_strdup(_info->storage_uuid);
+ SAFE_FREE(_media->thumbnail_path);
+ _media->thumbnail_path = NULL;
- SAFE_FREE(file_path);
- media_info_destroy(media);
+ media_info_destroy((media_info_h)_info);
return ret;
}
-int media_info_move_to_db(media_info_h media, const char* dst_path)
+int media_info_create_thumbnail(media_info_h media, media_thumbnail_completed_cb callback, void *user_data)
{
+ content_warn("DEPRECATION WARNING: media_info_create_thumbnail() is deprecated and will be removed from next release. Use media_info_generate_thumbnail() instead.");
int ret = MEDIA_CONTENT_ERROR_NONE;
- media_svc_storage_type_e src_storage_type = 0;
- media_svc_storage_type_e dst_storage_type = 0;
- char storage_id[MEDIA_CONTENT_UUID_SIZE+1] = {0, };
- char repl_path[MAX_PATH_LEN] = {0, };
- char org_repl_path[MAX_PATH_LEN] = {0, };
-
- media_content_retvm_if(media == NULL, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "invalid media");
- media_content_retvm_if(!STRING_VALID(dst_path), MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "invalid dst_path");
- memset(repl_path, 0, sizeof(repl_path));
- memset(org_repl_path, 0, sizeof(org_repl_path));
- ret = _media_content_replace_path(dst_path, repl_path);
- media_content_retvm_if(!STRING_VALID(repl_path), MEDIA_CONTENT_ERROR_INVALID_OPERATION, "path replacement failed");
-
+ static unsigned int req_id = 0;
media_info_s *_media = (media_info_s*)media;
- ret = _media_content_replace_path(_media->file_path, org_repl_path);
- media_content_retvm_if(!STRING_VALID(org_repl_path), MEDIA_CONTENT_ERROR_INVALID_OPERATION, "path replacement failed");
-
- ret = __media_info_check_file_validity(repl_path);
- media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
+ content_retip_if_fail(media);
+ content_retip_if_fail(callback);
+ content_retip_if_fail(STRING_VALID(_media->media_id));
+ content_retip_if_fail(_media->file_path);
- ret = media_svc_get_storage_type(org_repl_path, &src_storage_type, _content_get_uid());
- if (ret != MS_MEDIA_ERR_NONE) {
- media_content_sec_error("media_svc_get_storage_type failed : %d", ret);
- return _content_error_capi(MEDIA_CONTENT_TYPE, ret);
- }
+ media_thumbnail_cb_s *_thumb_cb = g_new0(media_thumbnail_cb_s, 1);
- ret = media_svc_get_storage_type(repl_path, &dst_storage_type, _content_get_uid());
- if (ret != MS_MEDIA_ERR_NONE) {
- media_content_sec_error("media_svc_get_storage_type failed : %d", ret);
- return _content_error_capi(MEDIA_CONTENT_TYPE, ret);
- }
+ req_id++;
+ _media->request_id = req_id;
- if (src_storage_type == MEDIA_SVC_STORAGE_EXTERNAL_USB || dst_storage_type == MEDIA_SVC_STORAGE_EXTERNAL_USB) {
- media_content_sec_error("Unsupported storage type src[%d] dst[%d]", src_storage_type, dst_storage_type);
- return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
- }
+ _thumb_cb->handle = _media;
+ _thumb_cb->user_data = user_data;
+ _thumb_cb->thumbnail_completed_cb = callback;
- memset(storage_id, 0x00, sizeof(storage_id));
- ret = media_svc_get_storage_id(_content_get_db_handle(), org_repl_path, storage_id, _content_get_uid());
- if (ret != MS_MEDIA_ERR_NONE) {
- media_content_error("media_svc_get_storage_id failed : %d", ret);
- return _content_error_capi(MEDIA_CONTENT_TYPE, ret);
- }
+ ret = thumbnail_request_from_db_async(_media->request_id, _media->file_path, (ThumbFunc)__media_info_thumbnail_completed_cb, (void *)_thumb_cb, _content_get_uid());
+ ret = _content_error_capi(ret);
- ret = media_svc_move_item(_content_get_db_handle(), storage_id, src_storage_type, org_repl_path, dst_storage_type, repl_path, _content_get_uid());
- return _content_error_capi(MEDIA_CONTENT_TYPE, ret);
+ return ret;
}
-int media_info_create_thumbnail(media_info_h media, media_thumbnail_completed_cb callback, void *user_data)
+int media_info_generate_thumbnail(media_info_h media)
{
int ret = MEDIA_CONTENT_ERROR_NONE;
- static unsigned int req_id = 0;
- char repl_path[MAX_PATH_LEN] = {0, };
+ char *thumb_path = NULL;
media_info_s *_media = (media_info_s*)media;
- if (_media != NULL && STRING_VALID(_media->media_id) && STRING_VALID(_media->file_path)) {
- memset(repl_path, 0, sizeof(repl_path));
- ret = _media_content_replace_path(_media->file_path, repl_path);
- media_content_retvm_if(!STRING_VALID(repl_path), MEDIA_CONTENT_ERROR_INVALID_OPERATION, "path replacement failed");
+ content_retip_if_fail(media);
+ content_retip_if_fail(STRING_VALID(_media->media_id));
+ content_retip_if_fail(STRING_VALID(_media->file_path));
- media_thumbnail_cb_s *_thumb_cb = (media_thumbnail_cb_s*)calloc(1, sizeof(media_thumbnail_cb_s));
- media_content_retvm_if(_thumb_cb == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
- req_id++;
- _media->request_id = req_id;
+ /* Already exists */
+ if (STRING_VALID(_media->thumbnail_path))
+ return MEDIA_CONTENT_ERROR_NONE;
- _thumb_cb->handle = _media;
- _thumb_cb->user_data = user_data;
- _thumb_cb->thumbnail_completed_cb = callback;
-
- ret = thumbnail_request_from_db_async(_media->request_id, repl_path, (ThumbFunc)__media_info_thumbnail_completed_cb, (void *)_thumb_cb, _content_get_uid());
- ret = _content_error_capi(MEDIA_THUMBNAIL_TYPE, ret);
- } else {
- media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+ ret = media_svc_create_thumbnail(_media->file_path, _media->media_type, _content_get_uid(), &thumb_path);
+ ret = _content_error_capi(ret);
+ if (ret == MEDIA_CONTENT_ERROR_UNSUPPORTED_CONTENT) {
+ g_free(thumb_path);
+ return ret;
}
+ /* thumb_path is not NULL except #MEDIA_CONTENT_ERROR_UNSUPPORTED_CONTENT */
+ _media->thumbnail_path = g_strdup(thumb_path);
+ g_free(thumb_path);
+
return ret;
}
int media_info_cancel_thumbnail(media_info_h media)
{
int ret = MEDIA_CONTENT_ERROR_NONE;
+ content_warn("DEPRECATION WARNING: media_info_cancel_thumbnail() is deprecated and will be removed from next release.");
media_info_s *_media = (media_info_s*)media;
- if (_media != NULL && STRING_VALID(_media->media_id) && _media->request_id > 0) {
- ret = thumbnail_request_cancel_media(_media->request_id);
- ret = _content_error_capi(MEDIA_THUMBNAIL_TYPE, ret);
- } else {
- media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
- }
+ content_retip_if_fail(media);
+ content_retip_if_fail(STRING_VALID(_media->media_id));
+ content_retip_if_fail(_media->request_id > 0);
- return ret;
+ ret = thumbnail_request_cancel_media(_media->request_id);
+ return _content_error_capi(ret);
}
int media_info_start_face_detection(media_info_h media, media_face_detection_completed_cb callback, void *user_data)
int ret = MEDIA_CONTENT_ERROR_NONE;
static unsigned int req_id = 0;
media_info_s *_media = (media_info_s*)media;
- char repl_path[MAX_PATH_LEN] = {0, };
if (!__media_info_isFaceRecognition_feature_supported()) {
- media_content_error("NOT_SUPPORTED(0x%08x)", MEDIA_CONTENT_ERROR_NOT_SUPPORTED);
+ content_error("NOT_SUPPORTED(0x%08x)", MEDIA_CONTENT_ERROR_NOT_SUPPORTED);
return MEDIA_CONTENT_ERROR_NOT_SUPPORTED;
}
- if (_media != NULL && STRING_VALID(_media->media_id) && STRING_VALID(_media->file_path)) {
- memset(repl_path, 0, sizeof(repl_path));
- ret = _media_content_replace_path(_media->file_path, repl_path);
- media_content_retvm_if(!STRING_VALID(repl_path), MEDIA_CONTENT_ERROR_INVALID_OPERATION, "path replacement failed");
- media_face_cb_s *_face_cb = (media_face_cb_s*)calloc(1, sizeof(media_face_cb_s));
- media_content_retvm_if(_face_cb == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
- req_id++;
- _media->face_request_id = req_id;
-
- _face_cb->handle = _media;
- _face_cb->user_data = user_data;
- _face_cb->face_completed_cb = callback;
-
- ret = dcm_request_extract_face_async(_media->face_request_id, repl_path, (FaceFunc)__media_info_face_completed_cb, (void *)_face_cb, _content_get_uid());
- ret = _content_error_capi(MEDIA_THUMBNAIL_TYPE, ret);
- } else {
- media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+ content_retip_if_fail(media);
+ content_retip_if_fail(STRING_VALID(_media->media_id));
+ content_retip_if_fail(STRING_VALID(_media->file_path));
+ content_retip_if_fail(callback);
+
+ if (g_strcmp0(_media->mime_type, "image/jpeg") != 0 && g_strcmp0(_media->mime_type, "image/png") != 0 && g_strcmp0(_media->mime_type, "image/bmp") != 0) {
+ content_error("Unsupported mime type");
+ return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
}
+ media_face_cb_s *_face_cb = g_new0(media_face_cb_s, 1);
+
+ req_id++;
+ _media->face_request_id = req_id;
+
+ _face_cb->user_data = user_data;
+ _face_cb->face_completed_cb = callback;
+
+ ret = dcm_request_extract_face_async(_media->face_request_id, _media->file_path, (FaceFunc)__media_info_face_completed_cb, (void *)_face_cb, _content_get_uid());
+ ret = _content_error_capi(ret);
+
return ret;
}
{
int ret = MEDIA_CONTENT_ERROR_NONE;
media_info_s *_media = (media_info_s*)media;
- char repl_path[MAX_PATH_LEN] = {0, };
if (!__media_info_isFaceRecognition_feature_supported()) {
- media_content_error("NOT_SUPPORTED(0x%08x)", MEDIA_CONTENT_ERROR_NOT_SUPPORTED);
+ content_error("NOT_SUPPORTED(0x%08x)", MEDIA_CONTENT_ERROR_NOT_SUPPORTED);
return MEDIA_CONTENT_ERROR_NOT_SUPPORTED;
}
- if (_media != NULL && STRING_VALID(_media->media_id) && STRING_VALID(_media->file_path) && _media->face_request_id > 0) {
- memset(repl_path, 0, sizeof(repl_path));
- ret = _media_content_replace_path(_media->file_path, repl_path);
- media_content_retvm_if(!STRING_VALID(repl_path), MEDIA_CONTENT_ERROR_INVALID_OPERATION, "path replacement failed");
- ret = dcm_request_cancel_face(_media->face_request_id, repl_path);
- ret = _content_error_capi(MEDIA_THUMBNAIL_TYPE, ret);
- } else {
- media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
- }
-
- return ret;
-}
-
-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)
-{
- media_content_retvm_if(media == NULL, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid handle");
- char repl_path[MAX_PATH_LEN] = {0, };
- char *tmp_path = NULL;
-
- media_svc_content_info_s *svc_content_info = calloc(1, sizeof(media_svc_content_info_s));
- media_content_retvm_if(svc_content_info == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
-
- memset(repl_path, 0, sizeof(repl_path));
- tmp_path = g_strdup(media->file_path);
- _media_content_replace_path(tmp_path, repl_path);
- svc_content_info->path = g_strdup(repl_path);
- SAFE_FREE(tmp_path);
-
- svc_content_info->file_name = g_strdup(media->display_name);
- svc_content_info->media_type = media->media_type;
- svc_content_info->mime_type = g_strdup(media->mime_type);
- svc_content_info->size = media->size;
- svc_content_info->storage_type = storage_type;
- svc_content_info->storage_uuid = g_strdup(media->storage_uuid);
-
- svc_content_info->added_time = media->added_time;
- svc_content_info->modified_time = media->modified_time;
- svc_content_info->thumbnail_path = g_strdup(media->thumbnail_path);
- svc_content_info->is_drm = media->is_drm;
- svc_content_info->last_played_time = media->played_time;
- svc_content_info->played_count = media->played_count;
- svc_content_info->favourate = media->favourite;
-
-#ifdef _USE_SENIOR_MODE
- if (_media_content_is_support_senior_mode()) {
- svc_content_info->contact = g_strdup(media->contact);
- svc_content_info->app_data = g_strdup(media->app_data);
- }
-#endif
-
- svc_content_info->media_meta.title = g_strdup(media->title);
- svc_content_info->media_meta.rating = media->rating;
- svc_content_info->media_meta.description = g_strdup(media->description);
- svc_content_info->media_meta.longitude = media->longitude;
- svc_content_info->media_meta.latitude = media->latitude;
- svc_content_info->media_meta.altitude = media->altitude;
- svc_content_info->media_meta.weather = g_strdup(media->weather);
- svc_content_info->media_meta.category = g_strdup(media->category);
- svc_content_info->media_meta.keyword = g_strdup(media->keyword);
- svc_content_info->media_meta.location_tag = g_strdup(media->location_tag);
- svc_content_info->media_meta.content_name = g_strdup(media->content_name);
- svc_content_info->media_meta.age_rating = g_strdup(media->age_rating);
- svc_content_info->media_meta.author = g_strdup(media->author);
- svc_content_info->media_meta.provider = g_strdup(media->provider);
-
- svc_content_info->media_meta.album = g_strdup(media->audio_meta->album);
- svc_content_info->media_meta.artist = g_strdup(media->audio_meta->artist);
- svc_content_info->media_meta.genre = g_strdup(media->audio_meta->genre);
- svc_content_info->media_meta.recorded_date = g_strdup(media->audio_meta->recorded_date);
-
- *service_content = svc_content_info;
+ content_retip_if_fail(media);
+ content_retip_if_fail(STRING_VALID(_media->media_id));
+ content_retip_if_fail(_media->face_request_id > 0);
- return MEDIA_CONTENT_ERROR_NONE;
+ ret = dcm_request_cancel_face(_media->face_request_id);
+ return _content_error_capi(ret);
}
-static int __media_info_set_str_data(media_info_h media, media_info_item_e data_type, const char *str_data)
+int media_info_set_description(media_info_h media, const char *description)
{
+ content_warn("DEPRECATION WARNING: media_info_set_description() is deprecated and will be removed from next release.");
media_info_s *_media = (media_info_s*)media;
- media_content_retvm_if(_media == NULL, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid media");
-
- switch (data_type) {
- case MEDIA_INFO_PATH:
- SAFE_FREE(_media->file_path);
- if (STRING_VALID(str_data)) {
- _media->file_path = strdup(str_data);
- media_content_retvm_if(_media->file_path == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
- } else {
- _media->file_path = NULL;
- }
- break;
- case MEDIA_INFO_MIME_TYPE:
- SAFE_FREE(_media->mime_type);
- if (STRING_VALID(str_data)) {
- _media->mime_type = strdup(str_data);
- media_content_retvm_if(_media->mime_type == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
- } else {
- _media->mime_type = NULL;
- }
- break;
- case MEDIA_INFO_THUMBNAIL_PATH:
- SAFE_FREE(_media->thumbnail_path);
- if (STRING_VALID(str_data)) {
- _media->thumbnail_path = strdup(str_data);
- media_content_retvm_if(_media->thumbnail_path == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
- } else {
- _media->thumbnail_path = NULL;
- }
- break;
- case MEDIA_INFO_TITLE:
- SAFE_FREE(_media->title);
- if (STRING_VALID(str_data)) {
- _media->title = strdup(str_data);
- media_content_retvm_if(_media->title == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
- } else {
- _media->title = NULL;
- }
- break;
- case MEDIA_INFO_STORAGE_UUID:
- SAFE_FREE(_media->storage_uuid);
- if (STRING_VALID(str_data)) {
- _media->storage_uuid = strdup(str_data);
- media_content_retvm_if(_media->storage_uuid == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
- } else {
- _media->storage_uuid = NULL;
- }
- break;
- case MEDIA_INFO_ALBUM:
- if (STRING_VALID(_media->media_id)) {
- if (_media->media_type == MEDIA_CONTENT_TYPE_VIDEO) {
- SAFE_FREE(_media->video_meta->album);
- if (str_data != NULL) {
- _media->video_meta->album = strdup(str_data);
- media_content_retvm_if(_media->video_meta->album == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
- }
- } else if ((_media->media_type == MEDIA_CONTENT_TYPE_MUSIC) || (_media->media_type == MEDIA_CONTENT_TYPE_SOUND)) {
- SAFE_FREE(_media->audio_meta->album);
- if (str_data != NULL) {
- _media->audio_meta->album = strdup(str_data);
- media_content_retvm_if(_media->audio_meta->album == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
- }
- }
- } else {
- SAFE_FREE(_media->video_meta->album);
- if (str_data != NULL) {
- _media->video_meta->album = strdup(str_data);
- media_content_retvm_if(_media->video_meta->album == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
- }
-
- SAFE_FREE(_media->audio_meta->album);
- if (str_data != NULL) {
- _media->audio_meta->album = strdup(str_data);
- media_content_retvm_if(_media->audio_meta->album == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
- }
- }
- break;
- case MEDIA_INFO_ARTIST:
- if (STRING_VALID(_media->media_id)) {
- if (_media->media_type == MEDIA_CONTENT_TYPE_VIDEO) {
- SAFE_FREE(_media->video_meta->artist);
- if (str_data != NULL) {
- _media->video_meta->artist = strdup(str_data);
- media_content_retvm_if(_media->video_meta->artist == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
- }
- } else if ((_media->media_type == MEDIA_CONTENT_TYPE_MUSIC) || (_media->media_type == MEDIA_CONTENT_TYPE_SOUND)) {
- SAFE_FREE(_media->audio_meta->artist);
- if (str_data != NULL) {
- _media->audio_meta->artist = strdup(str_data);
- media_content_retvm_if(_media->audio_meta->artist == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
- }
- }
- } else {
- SAFE_FREE(_media->video_meta->artist);
- if (str_data != NULL) {
- _media->video_meta->artist = strdup(str_data);
- media_content_retvm_if(_media->video_meta->artist == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
- }
-
- SAFE_FREE(_media->audio_meta->artist);
- if (str_data != NULL) {
- _media->audio_meta->artist = strdup(str_data);
- media_content_retvm_if(_media->audio_meta->artist == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
- }
- }
- break;
- case MEDIA_INFO_GENRE:
- if (STRING_VALID(_media->media_id)) {
- if (_media->media_type == MEDIA_CONTENT_TYPE_VIDEO) {
- SAFE_FREE(_media->video_meta->genre);
- if (str_data != NULL) {
- _media->video_meta->genre = strdup(str_data);
- media_content_retvm_if(_media->video_meta->genre == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
- }
- } else if ((_media->media_type == MEDIA_CONTENT_TYPE_MUSIC) || (_media->media_type == MEDIA_CONTENT_TYPE_SOUND)) {
- SAFE_FREE(_media->audio_meta->genre);
- if (str_data != NULL) {
- _media->audio_meta->genre = strdup(str_data);
- media_content_retvm_if(_media->audio_meta->genre == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
- }
- }
- } else {
- SAFE_FREE(_media->video_meta->genre);
- if (str_data != NULL) {
- _media->video_meta->genre = strdup(str_data);
- media_content_retvm_if(_media->video_meta->genre == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
- }
-
- SAFE_FREE(_media->audio_meta->genre);
- if (str_data != NULL) {
- _media->audio_meta->genre = strdup(str_data);
- media_content_retvm_if(_media->audio_meta->genre == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
- }
- }
- break;
- case MEDIA_INFO_RECORDED_DATE:
- if (STRING_VALID(_media->media_id)) {
- if (_media->media_type == MEDIA_CONTENT_TYPE_VIDEO) {
- SAFE_FREE(_media->video_meta->recorded_date);
- if (str_data != NULL) {
- _media->video_meta->recorded_date = strdup(str_data);
- media_content_retvm_if(_media->video_meta->recorded_date == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
- }
- } else if ((_media->media_type == MEDIA_CONTENT_TYPE_MUSIC) || (_media->media_type == MEDIA_CONTENT_TYPE_SOUND)) {
- SAFE_FREE(_media->audio_meta->recorded_date);
- if (str_data != NULL) {
- _media->audio_meta->recorded_date = strdup(str_data);
- media_content_retvm_if(_media->audio_meta->recorded_date == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
- }
- }
- } else {
- SAFE_FREE(_media->video_meta->recorded_date);
- if (str_data != NULL) {
- _media->video_meta->recorded_date = strdup(str_data);
- media_content_retvm_if(_media->video_meta->recorded_date == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
- }
+ content_retip_if_fail(media);
- SAFE_FREE(_media->audio_meta->recorded_date);
- if (str_data != NULL) {
- _media->audio_meta->recorded_date = strdup(str_data);
- media_content_retvm_if(_media->audio_meta->recorded_date == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
- }
- }
- break;
- default:
- media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
- }
+ g_free(_media->description);
+ _media->description = g_strdup(description);
return MEDIA_CONTENT_ERROR_NONE;
}
-static int __media_info_destroy(media_info_h media)
+int media_info_set_longitude(media_info_h media, double longitude)
{
- int ret = MEDIA_CONTENT_ERROR_NONE;
+ content_warn("DEPRECATION WARNING: media_info_set_longitude() is deprecated and will be removed from next release.");
media_info_s *_media = (media_info_s*)media;
- if (_media) {
- SAFE_FREE(_media->media_id);
- SAFE_FREE(_media->file_path);
- SAFE_FREE(_media->display_name);
- SAFE_FREE(_media->mime_type);
- SAFE_FREE(_media->thumbnail_path);
- SAFE_FREE(_media->description);
- SAFE_FREE(_media->author);
- SAFE_FREE(_media->provider);
- SAFE_FREE(_media->content_name);
- SAFE_FREE(_media->category);
- SAFE_FREE(_media->location_tag);
- SAFE_FREE(_media->age_rating);
- SAFE_FREE(_media->keyword);
- SAFE_FREE(_media->title);
- SAFE_FREE(_media->weather);
- SAFE_FREE(_media->storage_uuid);
-
- if (_media->image_meta) {
- SAFE_FREE(_media->image_meta->media_id);
- SAFE_FREE(_media->image_meta->date_taken);
- SAFE_FREE(_media->image_meta->burst_id);
- SAFE_FREE(_media->image_meta->exposure_time);
- SAFE_FREE(_media->image_meta->model);
- SAFE_FREE(_media->image_meta->title);
- SAFE_FREE(_media->image_meta->weather);
-
- SAFE_FREE(_media->image_meta);
- }
-
- if (_media->video_meta) {
- SAFE_FREE(_media->video_meta->media_id);
- SAFE_FREE(_media->video_meta->title);
- SAFE_FREE(_media->video_meta->album);
- SAFE_FREE(_media->video_meta->artist);
- SAFE_FREE(_media->video_meta->album_artist);
- SAFE_FREE(_media->video_meta->genre);
- SAFE_FREE(_media->video_meta->composer);
- SAFE_FREE(_media->video_meta->year);
- SAFE_FREE(_media->video_meta->recorded_date);
- SAFE_FREE(_media->video_meta->copyright);
- SAFE_FREE(_media->video_meta->track_num);
-
- SAFE_FREE(_media->video_meta);
- }
-
- if (_media->audio_meta) {
- SAFE_FREE(_media->audio_meta->media_id);
- SAFE_FREE(_media->audio_meta->title);
- SAFE_FREE(_media->audio_meta->album);
- SAFE_FREE(_media->audio_meta->artist);
- SAFE_FREE(_media->audio_meta->album_artist);
- SAFE_FREE(_media->audio_meta->genre);
- SAFE_FREE(_media->audio_meta->composer);
- SAFE_FREE(_media->audio_meta->year);
- SAFE_FREE(_media->audio_meta->recorded_date);
- SAFE_FREE(_media->audio_meta->copyright);
- SAFE_FREE(_media->audio_meta->track_num);
-
- SAFE_FREE(_media->audio_meta);
- }
+ content_retip_if_fail(media);
- ret = MEDIA_CONTENT_ERROR_NONE;
- } else {
- media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
- }
+ _media->longitude = longitude;
- return ret;
+ return MEDIA_CONTENT_ERROR_NONE;
}
-int media_info_insert_to_db_with_data(media_info_h media)
+int media_info_set_latitude(media_info_h media, double latitude)
{
- int ret = MEDIA_CONTENT_ERROR_NONE;
- int ret_cnt = 0;
- char repl_path[MAX_PATH_LEN] = {0, };
-
- 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.");
-
+ content_warn("DEPRECATION WARNING: media_info_set_latitude() is deprecated and will be removed from next release.");
media_info_s *_media = (media_info_s*)media;
- media_content_retvm_if(_media == NULL, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid media");
- media_content_retvm_if(!STRING_VALID(_media->file_path), MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid file_path");
- media_content_retvm_if(!STRING_VALID(_media->storage_uuid), MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid storage_uuid");
- media_content_retvm_if(_media->storage_type < 0, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid storage_type [%d]", _media->storage_type);
-
- media_content_sec_debug("storage[%d], path[%s], media_type[%d]", _media->storage_type, _media->file_path, _media->media_type);
-
- media_svc_content_info_s *svc_content_info = NULL;
-
- ret = __media_info_map_data_usr_to_svc(_media, &svc_content_info, _media->storage_type);
- media_content_retvm_if(ret != MEDIA_CONTENT_ERROR_NONE, ret, "__media_info_map_data_usr_to_svc fail");
-
- ret = media_svc_insert_item_immediately_with_data(_content_get_db_handle(), svc_content_info, _content_get_uid());
- if (ret != MS_MEDIA_ERR_NONE) {
- media_content_sec_error("media_svc_insert_item_immediately_with_data failed : %d (%s)", ret, _media->file_path);
- media_svc_destroy_content_info(svc_content_info);
- SAFE_FREE(svc_content_info);
- return _content_error_capi(MEDIA_CONTENT_TYPE, ret);
- }
- /*free the svc_content_info*/
- media_svc_destroy_content_info(svc_content_info);
- SAFE_FREE(svc_content_info);
-
- /*Fill out the handle*/
- memset(repl_path, 0, sizeof(repl_path));
- ret = _media_content_replace_path(_media->file_path, repl_path);
- char *media_file_path = g_strdup(repl_path);
-
- char *media_string_uuid = g_strdup(_media->storage_uuid);
-
- __media_info_destroy(media);
-RETRY:
- ret = _media_info_get_media_info_from_db(media_file_path, media_string_uuid, media);
- if (ret != MEDIA_CONTENT_ERROR_NONE) {
- media_content_error("_media_info_get_media_info_from_db fail [%d]", ret);
- if (ret == MEDIA_CONTENT_ERROR_DB_FAILED && ret_cnt < 5) {
- ret_cnt++;
- media_content_error("RETRY GETTING DATA");
- goto RETRY;
- }
- }
+ content_retip_if_fail(media);
- SAFE_FREE(media_file_path);
- SAFE_FREE(media_string_uuid);
+ _media->latitude = latitude;
- return ret;
+ return MEDIA_CONTENT_ERROR_NONE;
}
-int media_info_create(const char *path, media_info_h *media)
+int media_info_set_rating(media_info_h media, int rating)
{
- int ret = MEDIA_CONTENT_ERROR_NONE;
- char storage_id[MEDIA_CONTENT_UUID_SIZE+1] = {0, };
- media_svc_storage_type_e storage_type = 0;
- char repl_path[MAX_PATH_LEN] = {0, };
- media_content_warn("DEPRECATION WARNING: media_info_create() is deprecated and will be removed from next release. Use media_info_insert_to_db() instead.");
-
- media_content_retvm_if(!STRING_VALID(path), MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid path");
- media_content_retvm_if(media == NULL, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid media");
- memset(repl_path, 0, sizeof(repl_path));
- ret = _media_content_replace_path(path, repl_path);
- media_content_retvm_if(!STRING_VALID(repl_path), MEDIA_CONTENT_ERROR_INVALID_OPERATION, "path replacement failed");
-
- memset(storage_id, 0x00, sizeof(storage_id));
-
- ret = __media_info_check_file_validity(repl_path);
- media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
-
- ret = media_svc_get_storage_id(_content_get_db_handle(), repl_path, storage_id, _content_get_uid());
- if (ret != MS_MEDIA_ERR_NONE) {
- media_content_error("media_svc_get_storage_id failed : %d", ret);
- return _content_error_capi(MEDIA_CONTENT_TYPE, ret);
- }
-
- ret = media_svc_get_storage_type(repl_path, &storage_type, _content_get_uid());
- if (ret != MS_MEDIA_ERR_NONE) {
- media_content_sec_error("media_svc_get_storage_type failed : %d", ret);
- return _content_error_capi(MEDIA_CONTENT_TYPE, ret);
- }
-
- media_info_s *_media = (media_info_s*)calloc(1, sizeof(media_info_s));
- media_content_retvm_if(_media == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
-
- _media->audio_meta = (audio_meta_s *)calloc(1, sizeof(audio_meta_s));
- if (_media->audio_meta == NULL) {
- SAFE_FREE(_media);
- media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
- return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
- }
-
- _media->video_meta = (video_meta_s *)calloc(1, sizeof(video_meta_s));
- if (_media->video_meta == NULL) {
- SAFE_FREE(_media->audio_meta);
- SAFE_FREE(_media);
- media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
- return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
- }
-
- _media->image_meta = (image_meta_s *)calloc(1, sizeof(image_meta_s));
- if (_media->image_meta == NULL) {
- SAFE_FREE(_media->audio_meta);
- SAFE_FREE(_media->video_meta);
- SAFE_FREE(_media);
- media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
- return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
- }
+ content_warn("DEPRECATION WARNING: media_info_set_rating() is deprecated and will be removed from next release.");
+ media_info_s *_media = (media_info_s*)media;
- _media->file_path = g_strdup(path);
- _media->storage_type = -1;
- _media->media_type = 0;
- _media->modified_time = 0;
- _media->size = 0;
- _media->request_id = 0;
- _media->longitude = MEDIA_SVC_DEFAULT_GPS_VALUE;
- _media->latitude = MEDIA_SVC_DEFAULT_GPS_VALUE;
- _media->altitude = MEDIA_SVC_DEFAULT_GPS_VALUE;
-
- if (STRING_VALID(storage_id)) {
- _media->storage_uuid = g_strdup(storage_id);
- _media->storage_type = storage_type;
- }
+ content_retip_if_fail(media);
- *media = (media_info_h)_media;
+ _media->rating = rating;
- return ret;
+ return MEDIA_CONTENT_ERROR_NONE;
}
-int media_info_set_title(media_info_h media, const char *title)
+#ifdef TIZEN_FEATURE_COMPATIBILITY
+int media_info_set_added_time(media_info_h media, time_t added_time)
{
- media_content_warn("DEPRECATION WARNING: media_info_set_title() is deprecated and will be removed from next release.");
+ content_warn("DEPRECATION WARNING: media_info_set_added_time() is removed from 5.5.");
- return __media_info_set_str_data(media, MEDIA_INFO_TITLE, title);
+ return MEDIA_CONTENT_ERROR_NONE;
}
-int media_info_set_album(media_info_h media, const char *album)
+int media_info_delete_batch_from_db(filter_h filter)
{
- media_content_warn("DEPRECATION WARNING: media_info_set_album() is deprecated and will be removed from next release.");
+ content_warn("DEPRECATION WARNING: media_info_delete_batch_from_db() is removed from 5.5.");
- return __media_info_set_str_data(media, MEDIA_INFO_ALBUM, album);
+ return MEDIA_CONTENT_ERROR_NONE;
}
-int media_info_set_artist(media_info_h media, const char *artist)
+int media_info_create(const char *path, media_info_h *media)
{
- media_content_warn("DEPRECATION WARNING: media_info_set_artist() is deprecated and will be removed from next release.");
+ content_warn("DEPRECATION WARNING: media_info_create() is removed from 5.5.");
- return __media_info_set_str_data(media, MEDIA_INFO_ARTIST, artist);
+ return MEDIA_CONTENT_ERROR_NONE;
}
-int media_info_set_genre(media_info_h media, const char *genre)
+int media_info_refresh_metadata_to_db(const char *media_id)
{
- media_content_warn("DEPRECATION WARNING: media_info_set_genre() is deprecated and will be removed from next release.");
+ content_warn("DEPRECATION WARNING: media_info_refresh_metadata_to_db() is removed from 5.5.");
- return __media_info_set_str_data(media, MEDIA_INFO_GENRE, genre);
+ return MEDIA_CONTENT_ERROR_NONE;
}
-int media_info_set_recorded_date(media_info_h media, const char *recorded_date)
+int media_info_set_display_name(media_info_h media, const char *display_name)
{
- media_content_warn("DEPRECATION WARNING: media_info_set_recorded_date() is deprecated and will be removed from next release.");
+ content_warn("DEPRECATION WARNING: media_info_set_display_name() is removed from 5.5.");
- return __media_info_set_str_data(media, MEDIA_INFO_RECORDED_DATE, recorded_date);
+ return MEDIA_CONTENT_ERROR_NONE;
}
+#endif