* limitations under the License.
*/
-#include <unistd.h>
-#include <media_content.h>
+#include <media_info.h>
#include <media-thumbnail.h>
+#include <media-util-dcm.h>
#include <media_info_private.h>
#include <media_util_private.h>
-#include <media-svc.h>
-#include <media-util.h>
+#include <system_info.h>
+#ifdef _USE_TV_PROFILE
+#include <media_content_internal.h>
+#endif
-static int __media_info_get_media_info_from_db(char *path, media_info_h media);
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 bool __media_info_delete_batch_cb(media_info_h media, 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_get_media_info_from_db(char *path, media_info_h media)
-{
- int ret = MEDIA_CONTENT_ERROR_NONE;
- int ret_view = MEDIA_CONTENT_ERROR_NONE;
- sqlite3_stmt *stmt = NULL;
- char *select_query = NULL;
- media_info_s *_media = (media_info_s*)media;
-
- if(_media == NULL)
- {
- media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
- }
-
- select_query = sqlite3_mprintf(SELECT_MEDIA_BY_PATH, path);
-
- ret = _content_query_prepare(&stmt, select_query, NULL, NULL);
- sqlite3_free(select_query);
- media_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);
- media_content_debug("New Media ID: %s", _media->media_id);
- } else {
- media_content_debug("There's no media!!");
- }
-/*
- while(sqlite3_step(stmt) == SQLITE_ROW)
- {
- _media_info_item_get_detail(stmt, (media_info_h)_media);
- media_content_debug("New Media ID: %s", _media->media_id);
- }
-*/
- SQLITE3_FINALIZE(stmt);
-
- return ret;
-}
-
static int __media_info_get_media_path_by_id_from_db(const char *media_id, char **path)
{
int ret = MEDIA_CONTENT_ERROR_NONE;
- int ret_view = MEDIA_CONTENT_ERROR_NONE;
sqlite3_stmt *stmt = NULL;
char *select_query = NULL;
- if(!STRING_VALID(media_id))
- {
- media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
- }
+ media_content_retvm_if(!STRING_VALID(media_id), MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "invalid media_id");
select_query = sqlite3_mprintf(SELECT_MEDIA_PATH_BY_ID, media_id);
ret = _content_query_prepare(&stmt, select_query, NULL, NULL);
- sqlite3_free(select_query);
+ SQLITE3_SAFE_FREE(select_query);
media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
- if(sqlite3_step(stmt) == SQLITE_ROW)
- {
- if(STRING_VALID((const char *)sqlite3_column_text(stmt, 0)))
- *path = strdup((const char *)sqlite3_column_text(stmt, 0));
+ if (sqlite3_step(stmt) == SQLITE_ROW) {
+ *path = g_strdup((const char *)sqlite3_column_text(stmt, 0));
} else {
- media_content_debug("There's no media with this ID : %s", media_id);
+ media_content_error("There's no media with this ID : %s", media_id);
*path = NULL;
- ret = MEDIA_CONTENT_ERROR_DB_FAILED;
+ ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
}
SQLITE3_FINALIZE(stmt);
+
return ret;
}
media_insert_cb_s *_cb_data = (media_insert_cb_s *)user_data;
if (_cb_data) {
- if (result) {
+ if (result)
ret = _content_error_capi(MEDIA_CONTENT_TYPE, result->result);
- }
if (_cb_data->insert_completed_cb)
_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_error("failed to delete : %s", strerror(errno));
- }
+ if (unlink(_cb_data->insert_list_path) < 0)
+ media_content_stderror("failed to delete");
SAFE_FREE(_cb_data->insert_list_path);
}
}
media_thumbnail_cb_s *_thumb_cb = (media_thumbnail_cb_s *)user_data;
media_info_s *media = NULL;
- if(_thumb_cb != NULL)
- {
+ if (_thumb_cb != NULL) {
media = _thumb_cb->handle;
- if((media != NULL) && STRING_VALID(path))
- {
- SAFE_FREE(media->thumbnail_path);
- media->thumbnail_path = strdup(path);
+ if ((media != NULL) && STRING_VALID(path)) {
+ media->thumbnail_path = NULL;
+ media->thumbnail_path = g_strdup(path);
}
media_content_debug("error [%d], thumbnail_path [%s]", error, path);
return;
}
-static bool __media_info_delete_batch_cb(media_info_h media, void *user_data)
+static bool __media_info_isFaceRecognition_feature_supported()
{
- char *thumb_path = NULL;
- media_content_type_e media_type = 0;
+ bool isFaceRecognitionSupported = false;
- if(media == NULL)
- {
- media_content_debug("NO Item \n");
- return true;
+ 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);
+ return false;
}
- media_info_get_media_type(media, &media_type);
- media_content_debug("media_type : [%d] \n", media_type);
+ return isFaceRecognitionSupported;
+}
- media_info_get_thumbnail_path(media, &thumb_path);
- if (STRING_VALID(thumb_path)) {
- if (strncmp(MEDIA_CONTENT_THUMB_DEFAULT_PATH, thumb_path, strlen(MEDIA_CONTENT_THUMB_DEFAULT_PATH)) != 0) {
- media_content_debug("Deleting thumbnail : [%s] \n", thumb_path);
- if (unlink(thumb_path) < 0) {
- media_content_error("failed to delete : %s", strerror(errno));
- }
- }
+static void __media_info_face_completed_cb(int error, const int face_count, void *user_data)
+{
+ int error_value = MEDIA_CONTENT_ERROR_NONE;
+
+ media_face_cb_s *_face_cb = (media_face_cb_s *)user_data;
- SAFE_FREE(thumb_path);
+ if (_face_cb != NULL) {
+ media_content_debug("error [%d], face_count [%d]", error, face_count);
+ error_value = _content_error_capi(MEDIA_THUMBNAIL_TYPE, error);
+ if (_face_cb->face_completed_cb)
+ _face_cb->face_completed_cb(error_value, face_count, _face_cb->user_data);
}
- return true;
-}
+ SAFE_FREE(_face_cb);
+ return;
+}
-typedef enum {
- MEDIA_INFO_UUID = 0,
- MEDIA_INFO_PATH,
- MEDIA_INFO_FILE_NAME,
- MEDIA_INFO_TYPE,
- MEDIA_INFO_MIME_TYPE,
- MEDIA_INFO_SIZE,
- MEDIA_INFO_ADDED_TIME,
- MEDIA_INFO_MODIFIED_TIME,
- MEDIA_INFO_THUMBNAIL_PATH,
- MEDIA_INFO_DESCRIPTION,
- MEDIA_INFO_RATING, //10
- MEDIA_INFO_FAVOURITE,
- MEDIA_INFO_AUTHOR,
- MEDIA_INFO_PROVIDER,
- MEDIA_INFO_CONTENT_NAME,
- MEDIA_INFO_CATEGORY,
- MEDIA_INFO_LOCATION_TAG,
- MEDIA_INFO_AGE_RATING,
- MEDIA_INFO_KEYWORD,
- MEDIA_INFO_IS_DRM,
- MEDIA_INFO_STORAGE_TYPE, //20
- MEDIA_INFO_LONGITUDE,
- MEDIA_INFO_LATITUDE,
- MEDIA_INFO_ALTITUDE,
- MEDIA_INFO_WIDTH,
- MEDIA_INFO_HEIGHT,
- MEDIA_INFO_DATETAKEN,
- MEDIA_INFO_ORIENTATION,
- MEDIA_INFO_TITLE,
- MEDIA_INFO_ALBUM,
- MEDIA_INFO_ARTIST, //30
- MEDIA_INFO_ALBUM_ARTIST,
- MEDIA_INFO_GENRE,
- MEDIA_INFO_COMPOSER,
- MEDIA_INFO_YEAR,
- MEDIA_INFO_RECORDED_DATE,
- MEDIA_INFO_COPYRIGHT,
- MEDIA_INFO_TRACK_NUM,
- MEDIA_INFO_BITRATE,
- MEDIA_INFO_BITPERSAMPLE,
- MEDIA_INFO_DURATION,
- MEDIA_INFO_PLAYED_COUNT, //40
- MEDIA_INFO_LAST_PLAYED_TIME,
- MEDIA_INFO_LAST_PLAYED_POSITION,
- MEDIA_INFO_SAMPLERATE,
- MEDIA_INFO_CHANNEL,
- MEDIA_INFO_BURST_ID,
- MEDIA_INFO_TIMELINE,
- MEDIA_INFO_WEATHER,
- MEDIA_INFO_SYNC_STATUS,
- MEDIA_INFO_ITEM_MAX,
-} media_info_item_e;
-void _media_info_item_get_detail(sqlite3_stmt* stmt, media_info_h media)
+static bool __media_info_delete_batch_cb(media_info_h media, void *user_data)
{
-//#define MEDIA_INFO_ITEM "media_uuid, path, file_name, media_type, mime_type, size, added_time, modified_time, thumbnail_path, description,
-// rating, favourite, author, provider, content_name, category, location_tag, age_rating, keyword, is_drm, storage_type, longitude, latitude, altitude, width, height, datetaken, orientation, title, album, artist, genre, composer, year, recorded_date, copyright, track_num, bitrate, duration, played_count, last_played_time, last_played_position, samplerate, channel"
+ int err = MEDIA_CONTENT_ERROR_NONE;
+ char *thumb_path = NULL;
+ media_content_type_e media_type = 0;
+ GArray *thumb_list = (GArray *)user_data;
- media_info_s *_media = (media_info_s*)media;
+ if (media == NULL) {
+ media_content_debug("NO Item");
+ return true;
+ }
- if(STRING_VALID((const char *)sqlite3_column_text(stmt, MEDIA_INFO_UUID)))
- _media->media_id = strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_UUID));
+ err = media_info_get_media_type(media, &media_type);
+ if (err == MEDIA_CONTENT_ERROR_NONE) {
+ media_content_debug("media_type : [%d]", media_type);
- if(STRING_VALID((const char *)sqlite3_column_text(stmt, MEDIA_INFO_PATH)))
- _media->file_path = strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_PATH));
+ media_info_get_thumbnail_path(media, &thumb_path);
+ if (STRING_VALID(thumb_path) && STRING_VALID(MEDIA_CONTENT_THUMB_DEFAULT_PATH)) {
+ if (strncmp(MEDIA_CONTENT_THUMB_DEFAULT_PATH, thumb_path, strlen(MEDIA_CONTENT_THUMB_DEFAULT_PATH)) != 0)
+ g_array_append_val(thumb_list, thumb_path);
+ }
+ } else {
+ media_content_error("media_info_get_media_type failed");
+ }
- if(STRING_VALID((const char *)sqlite3_column_text(stmt, MEDIA_INFO_FILE_NAME)))
- _media->display_name = strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_FILE_NAME));
+ return true;
+}
- _media->media_type = (int)sqlite3_column_int(stmt, MEDIA_INFO_TYPE);
+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)
+{
+ int ret = MEDIA_CONTENT_ERROR_NONE;
+ FILE *fp = NULL;
+ char list_path[255] = {0, };
+ unsigned int idx = 0;
+ int nwrites = 0;
- if(STRING_VALID((const char *)sqlite3_column_text(stmt, MEDIA_INFO_MIME_TYPE)))
- _media->mime_type = strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_MIME_TYPE));
+ for (idx = 0; idx < BATCH_REQUEST_MAX; idx++) {
+ snprintf(list_path, sizeof(list_path), "%s/request-%ld-%d", MEDIA_CONTENT_INSERT_FILES_PATH, media_content_gettid(), idx);
- _media->size = (unsigned long long)sqlite3_column_int64(stmt, MEDIA_INFO_SIZE);
+ if (g_file_test(list_path, G_FILE_TEST_EXISTS | G_FILE_TEST_IS_REGULAR)) {
+ memset(list_path, 0x00, sizeof(list_path));
+ continue;
+ } else {
+ media_content_debug("The request file list path : %s", list_path);
+ break;
+ }
+ }
- _media->added_time = (int)sqlite3_column_int(stmt, MEDIA_INFO_ADDED_TIME);
+ if (idx == BATCH_REQUEST_MAX) {
+ media_content_error("Too many batch request for one thread");
+ return MEDIA_CONTENT_ERROR_DB_BUSY;
+ }
- _media->modified_time = (int)sqlite3_column_int(stmt, MEDIA_INFO_MODIFIED_TIME);
+ 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");
+ return MEDIA_CONTENT_ERROR_INVALID_OPERATION;
+ }
- if(STRING_VALID((const char *)sqlite3_column_text(stmt, MEDIA_INFO_THUMBNAIL_PATH)))
- _media->thumbnail_path= strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_THUMBNAIL_PATH));
+ for (idx = 0; idx < array_length; idx++) {
+ if (STRING_VALID(path_array[idx])) {
+ int size = strlen(path_array[idx]);
- if(STRING_VALID((const char *)sqlite3_column_text(stmt, MEDIA_INFO_DESCRIPTION)))
- _media->description = strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_DESCRIPTION));
+ ret = _media_util_check_file_exist(path_array[idx]);
+ if (ret != MEDIA_CONTENT_ERROR_NONE) {
+ fclose(fp);
+ if (unlink(list_path) < 0)
+ media_content_stderror("failed to delete");
+ return ret;
+ }
- _media->rating = (int)sqlite3_column_int(stmt, MEDIA_INFO_RATING);
+ nwrites = fwrite(path_array[idx], 1, size, fp);
+ if (nwrites != size) {
+ media_content_stderror("failed to write");
+ fclose(fp);
+ if (unlink(list_path) < 0)
+ media_content_stderror("failed to delete");
+ return MEDIA_CONTENT_ERROR_INVALID_OPERATION;
+ }
- _media->favourite = (int)sqlite3_column_int(stmt, MEDIA_INFO_FAVOURITE);
+ nwrites = fwrite("\n", 1, 1, fp);
+ if (nwrites != 1) {
+ media_content_stderror("failed to write");
+ fclose(fp);
+ if (unlink(list_path) < 0)
+ media_content_stderror("failed to delete");
+ return MEDIA_CONTENT_ERROR_INVALID_OPERATION;
+ }
+ } else {
+ media_content_error("path[%d] is invalid string", idx);
+ }
+ }
- if(STRING_VALID((const char *)sqlite3_column_text(stmt, MEDIA_INFO_AUTHOR)))
- _media->author = strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_AUTHOR));
+ fclose(fp);
- if(STRING_VALID((const char *)sqlite3_column_text(stmt, MEDIA_INFO_PROVIDER)))
- _media->provider = strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_PROVIDER));
+ 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");
- if(STRING_VALID((const char *)sqlite3_column_text(stmt, MEDIA_INFO_CONTENT_NAME)))
- _media->content_name = strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_CONTENT_NAME));
+ _cb_data->insert_completed_cb = completed_cb;
+ _cb_data->user_data = user_data;
+ _cb_data->insert_list_path = g_strdup(list_path);
- if(STRING_VALID((const char *)sqlite3_column_text(stmt, MEDIA_INFO_CATEGORY)))
- _media->category = strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_CATEGORY));
+ if (insert_type == MEDIA_BATCH_INSERT_NORMAL)
+ ret = media_files_register(list_path, __media_info_insert_completed_cb, _cb_data, tzplatform_getuid(TZ_USER_NAME));
+ else if (insert_type == MEDIA_BATCH_INSERT_BURSTSHOT)
+ ret = media_burstshot_register(list_path, __media_info_insert_completed_cb, _cb_data, tzplatform_getuid(TZ_USER_NAME));
+ else
+ ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
- if(STRING_VALID((const char *)sqlite3_column_text(stmt, MEDIA_INFO_LOCATION_TAG)))
- _media->location_tag = strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_LOCATION_TAG));
+ if (ret != MEDIA_CONTENT_ERROR_NONE) {
+ media_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);
+ }
- if(STRING_VALID((const char *)sqlite3_column_text(stmt, MEDIA_INFO_AGE_RATING)))
- _media->age_rating = strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_AGE_RATING));
+ return ret;
+}
- if(STRING_VALID((const char *)sqlite3_column_text(stmt, MEDIA_INFO_KEYWORD)))
- _media->keyword = strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_KEYWORD));
+void _media_info_item_get_detail(sqlite3_stmt* stmt, media_info_h media)
+{
+ media_info_s *_media = (media_info_s*)media;
+#ifndef _USE_TV_PROFILE
+ char *tmp_path = NULL;
+ char repl_path[MAX_QUERY_SIZE] = {0, };
+#endif
+ _media->media_id = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_UUID));
+#ifdef _USE_TV_PROFILE
+ _media->file_path = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_PATH));
+#else
+ 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);
+#endif
+ _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->size = (unsigned long long)sqlite3_column_int64(stmt, MEDIA_INFO_SIZE);
+ _media->added_time = (int)sqlite3_column_int(stmt, MEDIA_INFO_ADDED_TIME);
+ _media->modified_time = (int)sqlite3_column_int(stmt, MEDIA_INFO_MODIFIED_TIME);
+ _media->thumbnail_path = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_THUMBNAIL_PATH));
+ _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);
-
- if(STRING_VALID((const char *)sqlite3_column_text(stmt, MEDIA_INFO_TITLE)))
- _media->title = strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_TITLE));
-
+ _media->title = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_TITLE));
_media->timeline = (double)sqlite3_column_double(stmt, MEDIA_INFO_TIMELINE);
-
- if(STRING_VALID((const char *)sqlite3_column_text(stmt, MEDIA_INFO_WEATHER)))
- _media->weather = strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_WEATHER));
-
+ _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);
-
- if(_media->media_type == MEDIA_CONTENT_TYPE_IMAGE) {
+ if (_media->media_type == MEDIA_CONTENT_TYPE_IMAGE) {
_media->image_meta = (image_meta_s *)calloc(1, sizeof(image_meta_s));
- if(_media->image_meta) {
- if(STRING_VALID(_media->media_id))
- _media->image_meta->media_id = strdup(_media->media_id);
-
+ 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);
-
- if(STRING_VALID((const char *)sqlite3_column_text(stmt, MEDIA_INFO_DATETAKEN)))
- _media->image_meta->date_taken = strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_DATETAKEN));
-
+ _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);
-
- if(STRING_VALID((const char *)sqlite3_column_text(stmt, MEDIA_INFO_TITLE)))
- _media->image_meta->title = strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_TITLE));
-
- if(STRING_VALID((const char *)sqlite3_column_text(stmt, MEDIA_INFO_BURST_ID)))
- _media->image_meta->burst_id = strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_BURST_ID));
-
- if(STRING_VALID((const char *)sqlite3_column_text(stmt, MEDIA_INFO_WEATHER)))
- _media->image_meta->weather = strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_WEATHER));
+ _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));
}
-
- } else if(_media->media_type == MEDIA_CONTENT_TYPE_VIDEO) {
+ } 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) {
- if(STRING_VALID(_media->media_id))
- _media->video_meta->media_id = strdup(_media->media_id);
-
+ 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);
-
- if(STRING_VALID((const char *)sqlite3_column_text(stmt, MEDIA_INFO_TITLE)))
- _media->video_meta->title = strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_TITLE));
-
- if(STRING_VALID((const char *)sqlite3_column_text(stmt, MEDIA_INFO_ALBUM)))
- _media->video_meta->album = strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_ALBUM));
-
- if(STRING_VALID((const char *)sqlite3_column_text(stmt, MEDIA_INFO_ARTIST)))
- _media->video_meta->artist = strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_ARTIST));
-
- if(STRING_VALID((const char *)sqlite3_column_text(stmt, MEDIA_INFO_ALBUM_ARTIST)))
- _media->video_meta->album_artist = strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_ALBUM_ARTIST));
-
- if(STRING_VALID((const char *)sqlite3_column_text(stmt, MEDIA_INFO_GENRE)))
- _media->video_meta->genre = strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_GENRE));
-
- if(STRING_VALID((const char *)sqlite3_column_text(stmt, MEDIA_INFO_COMPOSER)))
- _media->video_meta->composer = strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_COMPOSER));
-
- if(STRING_VALID((const char *)sqlite3_column_text(stmt, MEDIA_INFO_YEAR)))
- _media->video_meta->year = strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_YEAR));
-
- if(STRING_VALID((const char *)sqlite3_column_text(stmt, MEDIA_INFO_RECORDED_DATE)))
- _media->video_meta->recorded_date = strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_RECORDED_DATE));
-
- if(STRING_VALID((const char *)sqlite3_column_text(stmt, MEDIA_INFO_COPYRIGHT)))
- _media->video_meta->copyright = strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_COPYRIGHT));
-
- if(STRING_VALID((const char *)sqlite3_column_text(stmt, MEDIA_INFO_TRACK_NUM)))
- _media->video_meta->track_num = strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_TRACK_NUM));
-
+ _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_position = sqlite3_column_int(stmt, MEDIA_INFO_LAST_PLAYED_POSITION);
}
- }
- else if((_media->media_type == MEDIA_CONTENT_TYPE_MUSIC) || (_media->media_type == MEDIA_CONTENT_TYPE_SOUND)) {
+ } 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) {
- if(STRING_VALID(_media->media_id))
- _media->audio_meta->media_id = strdup(_media->media_id);
-
- if(STRING_VALID((const char *)sqlite3_column_text(stmt, MEDIA_INFO_TITLE)))
- _media->audio_meta->title = strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_TITLE));
-
- if(STRING_VALID((const char *)sqlite3_column_text(stmt, MEDIA_INFO_ALBUM)))
- _media->audio_meta->album = strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_ALBUM));
-
- if(STRING_VALID((const char *)sqlite3_column_text(stmt, MEDIA_INFO_ARTIST)))
- _media->audio_meta->artist = strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_ARTIST));
-
- if(STRING_VALID((const char *)sqlite3_column_text(stmt, MEDIA_INFO_ALBUM_ARTIST)))
- _media->audio_meta->album_artist = strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_ALBUM_ARTIST));
-
- if(STRING_VALID((const char *)sqlite3_column_text(stmt, MEDIA_INFO_GENRE)))
- _media->audio_meta->genre = strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_GENRE));
-
- if(STRING_VALID((const char *)sqlite3_column_text(stmt, MEDIA_INFO_COMPOSER)))
- _media->audio_meta->composer = strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_COMPOSER));
-
- if(STRING_VALID((const char *)sqlite3_column_text(stmt, MEDIA_INFO_YEAR)))
- _media->audio_meta->year = strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_YEAR));
-
- if(STRING_VALID((const char *)sqlite3_column_text(stmt, MEDIA_INFO_RECORDED_DATE)))
- _media->audio_meta->recorded_date = strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_RECORDED_DATE));
-
- if(STRING_VALID((const char *)sqlite3_column_text(stmt, MEDIA_INFO_COPYRIGHT)))
- _media->audio_meta->copyright = strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_COPYRIGHT));
-
- if(STRING_VALID((const char *)sqlite3_column_text(stmt, MEDIA_INFO_TRACK_NUM)))
- _media->audio_meta->track_num = strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_TRACK_NUM));
-
+ 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->samplerate = sqlite3_column_int(stmt, MEDIA_INFO_SAMPLERATE);
_media->audio_meta->channel = sqlite3_column_int(stmt, MEDIA_INFO_CHANNEL);
}
-
}
}
-int media_info_insert_to_db (const char *path, media_info_h *info)
+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;
+ sqlite3_stmt *stmt = NULL;
+ char *select_query = NULL;
+ media_info_s *_media = (media_info_s*)media;
- if(!STRING_VALID(path))
- {
- media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
- }
+ media_content_retvm_if(_media == NULL, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "invalid media");
- if(info == NULL)
- {
- media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
- }
+ select_query = sqlite3_mprintf(SELECT_MEDIA_BY_PATH, storage_id, path);
+
+ ret = _content_query_prepare(&stmt, select_query, NULL, NULL);
+ SQLITE3_SAFE_FREE(select_query);
+ media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
-#if 0
- media_content_debug("Register: %s", path);
- ret = media_file_register(path);
- if(ret != MS_MEDIA_ERR_NONE)
- {
- media_content_error("media_file_register failed");
- return _content_error_capi(MEDIA_REGISTER_TYPE, 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!!");
+ ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
}
-#else
- char *_path = strdup(path);
- if (_path == NULL) {
- media_content_error("strdup failed : %s", path);
- return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
+ SQLITE3_FINALIZE(stmt);
+
+ return ret;
+}
+
+int media_info_insert_to_db(const char *path, media_info_h *info)
+{
+ bool ignore_file = FALSE;
+ bool ignore_dir = FALSE;
+ char *folder_path = NULL;
+ char storage_id[MEDIA_CONTENT_UUID_SIZE+1] = {0, };
+ char repl_path[MAX_QUERY_SIZE] = {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(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");
+
+ ret = _media_util_check_ignore_file(repl_path, &ignore_file);
+ media_content_retvm_if(ignore_file == TRUE, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid path");
+
+ ret = _media_util_check_file_exist(repl_path);
+ media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
+
+ folder_path = g_path_get_dirname(repl_path);
+ ret = _media_util_check_ignore_dir(folder_path, &ignore_dir);
+ SAFE_FREE(folder_path);
+
+ media_content_retvm_if(ignore_dir == TRUE, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid folder path");
+
+ memset(storage_id, 0x00, sizeof(storage_id));
+ ret = media_svc_get_storage_id(_content_get_db_handle(), repl_path, storage_id);
+ 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_check_item_exist_by_path(_content_get_db_handle(), _path);
+ 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_debug("media_svc_check_item_exist_by_path : no record : %s", _path);
+ media_content_sec_debug("media_svc_check_item_exist_by_path : no record : %s", repl_path);
- media_svc_storage_type_e storage_type;
+ media_svc_storage_type_e storage_type = 0;
- ret = media_svc_get_storage_type(_path, &storage_type);
- if (ret < 0) {
- media_content_error("media_svc_get_storage_type failed : %d (%s)", ret, _path);
- SAFE_FREE(_path);
+ ret = media_svc_get_storage_type(repl_path, &storage_type, tzplatform_getuid(TZ_USER_NAME));
+ 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_content_debug("media_svc_insert_item_immediately: %s", _path);
- ret = media_svc_insert_item_immediately(_content_get_db_handle(), storage_type, _path, tzplatform_getuid(TZ_USER_NAME));
+ ret = media_svc_insert_item_immediately(_content_get_db_handle(), storage_id, storage_type, repl_path, tzplatform_getuid(TZ_USER_NAME));
+
+ 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);
+ ret = MEDIA_CONTENT_ERROR_NONE;
+ } else {
+ media_content_sec_error("media_svc_insert_item_immediately failed : %d (%s)", ret, repl_path);
+ }
- if (ret < 0) {
- media_content_error("media_svc_insert_item_immediately failed : %d (%s)", ret, _path);
- SAFE_FREE(_path);
return _content_error_capi(MEDIA_CONTENT_TYPE, ret);
}
} else if (ret != MS_MEDIA_ERR_NONE) {
- media_content_error("media_svc_check_item_exist_by_path failed : %d (%s)", ret, _path);
- SAFE_FREE(_path);
+ 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);
}
-#endif
media_info_s *_media = (media_info_s*)calloc(1, sizeof(media_info_s));
- if(_media == NULL)
- {
- media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
- SAFE_FREE(_path);
- return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
- }
-
- _media->file_path = _path;
- if(_media->file_path == NULL)
- {
- media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
- SAFE_FREE(_media);
- return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
- }
+ media_content_retvm_if(_media == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
- ret = __media_info_get_media_info_from_db(_media->file_path, (media_info_h)_media);
+ 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);
*info = (media_info_h)_media;
return ret;
}
-static int __media_info_insert_batch(media_batch_insert_e insert_type, const char **path_array,
+int media_info_insert_batch_to_db(
+ const char **path_array,
unsigned int array_length,
media_insert_completed_cb completed_cb,
void *user_data)
{
- int ret = MEDIA_CONTENT_ERROR_NONE;
- FILE *fp = NULL;
- char list_path[255] = {0,};
+ char **repl_path_array = NULL;
int idx = 0;
- int nwrites = 0;
+ int ret = MS_MEDIA_ERR_NONE;
+ char repl_path[MAX_QUERY_SIZE] = {0, };
- for (idx = 0; idx < BATCH_REQUEST_MAX; idx++) {
- snprintf(list_path, sizeof(list_path), "%s/request-%ld-%d", MEDIA_CONTENT_INSERT_FILES_PATH, media_content_gettid(), idx);
+ 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");
- if (g_file_test(list_path, G_FILE_TEST_EXISTS | G_FILE_TEST_IS_REGULAR)) {
- memset(list_path, 0x00, sizeof(list_path));
- continue;
+ repl_path_array = calloc(1, 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));
} else {
- media_content_debug("The request file list path : %s", list_path);
- break;
+ media_content_error("path[%d] is invalid string", idx);
}
}
- if (idx == BATCH_REQUEST_MAX) {
- media_content_error("Too many batch request for one thread");
- return MEDIA_CONTENT_ERROR_DB_BUSY;
- }
+ 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]);
- fp = fopen(list_path, "w");
- if (fp == NULL) {
- media_content_error("failed to open file : %s [%s]", list_path, strerror(errno));
- return MEDIA_CONTENT_ERROR_INVALID_OPERATION;
- }
+ SAFE_FREE(repl_path_array);
- for (idx = 0; idx < array_length; idx++) {
- if (STRING_VALID(path_array[idx])) {
- int size = strlen(path_array[idx]);
+ return ret;
+}
- nwrites = fwrite(path_array[idx], 1, size, fp);
- if (nwrites != size) {
- media_content_error("failed to write thumbnail : %s", strerror(errno));
- fclose(fp);
- if (unlink(list_path) < 0) {
- media_content_error("failed to delete : %s", strerror(errno));
- }
- return MEDIA_CONTENT_ERROR_INVALID_OPERATION;
- }
+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)
+{
+ char **repl_path_array = NULL;
+ int idx = 0;
+ int ret = MS_MEDIA_ERR_NONE;
+ char repl_path[MAX_QUERY_SIZE] = {0, };
- nwrites = fwrite("\n", 1, 1, fp);
- if (nwrites != 1) {
- media_content_error("failed to write thumbnail : %s", strerror(errno));
- fclose(fp);
- if (unlink(list_path) < 0) {
- media_content_error("failed to delete : %s", strerror(errno));
- }
- return MEDIA_CONTENT_ERROR_INVALID_OPERATION;
- }
+ 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);
+
+ 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);
}
}
- fclose(fp);
+ ret = __media_info_insert_batch(MEDIA_BATCH_INSERT_BURSTSHOT, (const char **)repl_path_array, array_length, callback, user_data);
+ for (idx = 0; idx < array_length; idx++)
+ SAFE_FREE(repl_path_array[idx]);
- media_insert_cb_s *_cb_data = (media_insert_cb_s *)calloc(1, sizeof(media_insert_cb_s));
- _cb_data->insert_completed_cb = completed_cb;
- _cb_data->user_data = user_data;
- _cb_data->insert_list_path = strdup(list_path);
+ SAFE_FREE(repl_path_array);
- if(insert_type == MEDIA_BATCH_INSERT_NORMAL)
- ret = media_files_register(list_path, __media_info_insert_completed_cb, _cb_data, tzplatform_getuid(TZ_USER_NAME));
- else if(insert_type == MEDIA_BATCH_INSERT_BURSTSHOT)
- ret = media_burstshot_register(list_path, __media_info_insert_completed_cb, _cb_data, tzplatform_getuid(TZ_USER_NAME));
- else
- ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+ return ret;
+}
+#ifdef _USE_SENIOR_MODE
+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);
+
+ ret = media_info_set_contact(*info, contact);
if (ret != MEDIA_CONTENT_ERROR_NONE) {
- media_content_error("media_files_register failed : %d", ret);
- if (unlink(list_path) < 0) {
- media_content_error("failed to delete : %s", strerror(errno));
- }
- return _content_error_capi(MEDIA_CONTENT_TYPE, ret);
+ 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);
+ return ret;
+ }
+
+ ret = media_info_set_app_data(*info, app_data);
+ 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);
+ 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;
}
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)
+int media_info_delete_contact_from_db(const char* contact, const char* storage_id)
{
- if (path_array == NULL)
- {
- media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
- }
+ return -1;
+}
- if (array_length <= 0)
- {
- media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+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");
+
+ memset(storage_id, 0x00, sizeof(storage_id));
+ ret = media_svc_get_storage_id(_content_get_db_handle(), path, storage_id);
+ 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);
}
- return __media_info_insert_batch(MEDIA_BATCH_INSERT_NORMAL, path_array, array_length, completed_cb, user_data);
+ 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");
+
+ ret = _media_info_get_media_info_from_db(path, storage_id, (media_info_h)_media);
+ *media = (media_info_h)_media;
+
+ 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_delete_item(const char *media_id)
{
- if (path_array == NULL)
- {
+ 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;
}
- if (array_length <= 0)
- {
- media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+ memset(storage_id, 0x00, sizeof(storage_id));
+
+ 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;
+ }
+
+ 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;
+ }
+
+ 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;
}
- return __media_info_insert_batch(MEDIA_BATCH_INSERT_BURSTSHOT, path_array, array_length, callback, user_data);
+ ret = media_svc_remove_file(path);
+ SAFE_FREE(path);
+ return _content_error_capi(MEDIA_CONTENT_TYPE, ret);
}
+#endif
+
int media_info_delete_from_db(const char *media_id)
{
int ret = MEDIA_CONTENT_ERROR_NONE;
+ char *path = NULL;
+ char storage_id[MEDIA_CONTENT_UUID_SIZE+1] = {0, };
- if(!STRING_VALID(media_id))
- {
+ if (!STRING_VALID(media_id)) {
media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
}
-#if 0
- char *query_string = NULL;
- query_string = sqlite3_mprintf(DELETE_MEDIA_FROM_MEDIA, media_id);
-
- ret = _content_query_sql(query_string);
-
- sqlite3_free(query_string);
-
- return ret;
-#else
- char *path = NULL;
+ memset(storage_id, 0x00, sizeof(storage_id));
ret = __media_info_get_media_path_by_id_from_db(media_id, &path);
- if (ret < MEDIA_CONTENT_ERROR_NONE) {
+ 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;
}
- ret = media_svc_delete_item_by_path(_content_get_db_handle(), path, tzplatform_getuid(TZ_USER_NAME));
+ 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;
+ }
+
+ ret = media_svc_delete_item_by_path(_content_get_db_handle(), storage_id, path, tzplatform_getuid(TZ_USER_NAME));
SAFE_FREE(path);
- return _content_error_capi(ret,MEDIA_CONTENT_TYPE);
-#endif
+ return _content_error_capi(MEDIA_CONTENT_TYPE, ret);
+}
+
+static int __media_info_delete_thumb_from_list(GArray *thumb_list)
+{
+ 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*, 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;
+}
+
+static int __media_info_release_thumb_list(GArray *thumb_list)
+{
+ 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);
+ }
+
+ g_array_free(thumb_list, FALSE);
+ }
+
+ return MEDIA_CONTENT_ERROR_NONE;
}
int media_info_delete_batch_from_db(filter_h filter)
filter_s *_filter = NULL;
attribute_h attr;
char *condition_query = NULL;
+ GArray *thumb_list = NULL;
- if(filter == NULL)
- {
- media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
- }
+ media_content_retvm_if(filter == NULL, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid filter");
+
+ thumb_list = g_array_new(FALSE, FALSE, sizeof(char*));
/* Delete thumbnail of each item */
- ret = _media_db_get_group_item(NULL, filter, __media_info_delete_batch_cb, NULL, MEDIA_GROUP_NONE);
+ ret = _media_db_get_group_item(NULL, filter, __media_info_delete_batch_cb, thumb_list, MEDIA_GROUP_NONE);
_filter = (filter_s*)filter;
attr = _content_get_attirbute_handle();
- if(_filter->condition)
- {
+ if (_filter->condition) {
ret = _media_filter_attribute_generate(attr, _filter->condition, _filter->condition_collate_type, &condition_query);
- media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
+ if (ret != MEDIA_CONTENT_ERROR_NONE) {
+ __media_info_release_thumb_list(thumb_list);
+ return ret;
+ }
}
- if(STRING_VALID(condition_query))
- {
- query_string = sqlite3_mprintf(DELETE_MEDIA_FROM_MEDIA_BATCH, condition_query);
- }
- else
- {
+ if (STRING_VALID(condition_query)) {
+ if (_filter->storage_id == NULL) {
+ /*FIX ME*/
+ query_string = sqlite3_mprintf(DELETE_MEDIA_FROM_MEDIA_BATCH, "media", condition_query);
+ } else {
+ query_string = sqlite3_mprintf(DELETE_MEDIA_FROM_MEDIA_BATCH, _filter->storage_id, condition_query);
+ }
+ } else {
SAFE_FREE(condition_query);
+ __media_info_release_thumb_list(thumb_list);
+
return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
}
ret = _content_query_sql(query_string);
if (ret == MEDIA_CONTENT_ERROR_NONE) {
- /* Send notification for this
+ /* Send notification for this
In this case, send noti for internal storage and external storage
*/
media_content_debug("Batch deletion is successfull. Send notification for this");
- media_db_update_send(getpid(), MS_MEDIA_ITEM_DIRECTORY, MS_MEDIA_ITEM_UPDATE, MEDIA_CONTENT_PATH_PHONE, NULL, -1, NULL);
- media_db_update_send(getpid(), MS_MEDIA_ITEM_DIRECTORY, MS_MEDIA_ITEM_UPDATE, MEDIA_CONTENT_PATH_MMC, NULL, -1, NULL);
+ if (_filter->storage_id != NULL) {
+ char *storage_path = NULL;
+ media_svc_get_storage_path(_content_get_db_handle(), _filter->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);
+
+ SAFE_FREE(storage_path);
+ } else {
+ /*FIX ME*/
+ media_svc_publish_noti(MS_MEDIA_ITEM_DIRECTORY, MS_MEDIA_ITEM_UPDATE, MEDIA_ROOT_PATH_INTERNAL, -1, NULL, NULL);
+ media_svc_publish_noti(MS_MEDIA_ITEM_DIRECTORY, MS_MEDIA_ITEM_UPDATE, MEDIA_ROOT_PATH_SDCARD, -1, NULL, NULL);
+ }
+
+ __media_info_delete_thumb_from_list(thumb_list);
+ __media_info_release_thumb_list(thumb_list);
}
SAFE_FREE(condition_query);
- sqlite3_free(query_string);
+ SQLITE3_SAFE_FREE(query_string);
return ret;
}
int ret = MEDIA_CONTENT_ERROR_NONE;
media_info_s *_media = (media_info_s*)media;
- if(_media)
- {
+ if (_media) {
SAFE_FREE(_media->media_id);
SAFE_FREE(_media->file_path);
SAFE_FREE(_media->display_name);
SAFE_FREE(_media->age_rating);
SAFE_FREE(_media->keyword);
SAFE_FREE(_media->title);
+#ifdef _USE_TV_PROFILE
+ 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) {
+ 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);
- } else if(_media->video_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->track_num);
SAFE_FREE(_media->video_meta);
- } else if(_media->audio_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);
ret = MEDIA_CONTENT_ERROR_NONE;
- }
- else
- {
+ } else {
media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
}
int ret = MEDIA_CONTENT_ERROR_NONE;
media_info_s *_src = (media_info_s*)src;
-
- if(_src != NULL)
- {
+ 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(_dst == NULL)
- {
- media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
- return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
- }
-
- if(STRING_VALID(_src->media_id))
- {
- _dst->media_id = strdup(_src->media_id);
- if(_dst->media_id == NULL)
- {
+ 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(STRING_VALID(_src->file_path))
- {
- _dst->file_path = strdup(_src->file_path);
- if(_dst->file_path == NULL)
- {
+ 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(STRING_VALID(_src->display_name))
- {
- _dst->display_name = strdup(_src->display_name);
- if(_dst->display_name == NULL)
- {
+ 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(STRING_VALID(_src->mime_type))
- {
- _dst->mime_type = strdup(_src->mime_type);
- if(_dst->mime_type == NULL)
- {
+ 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(STRING_VALID(_src->thumbnail_path))
- {
- _dst->thumbnail_path = strdup(_src->thumbnail_path);
- if(_dst->thumbnail_path == NULL)
- {
+ 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(STRING_VALID(_src->description))
- {
- _dst->description = strdup(_src->description);
- if(_dst->description == NULL)
- {
+ 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(STRING_VALID(_src->weather))
- {
- _dst->weather = strdup(_src->weather);
- if(_dst->weather == NULL)
- {
+ 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(STRING_VALID(_src->title))
- {
- _dst->title = strdup(_src->title);
- if(_dst->title == NULL)
- {
+ 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(STRING_VALID(_src->author))
- {
- _dst->author = strdup(_src->author);
- if(_dst->author == NULL)
- {
+ 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(STRING_VALID(_src->provider))
- {
- _dst->provider = strdup(_src->provider);
- if(_dst->provider == NULL)
- {
+ 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(STRING_VALID(_src->content_name))
- {
- _dst->content_name = strdup(_src->content_name);
- if(_dst->content_name == NULL)
- {
+ 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(STRING_VALID(_src->category))
- {
- _dst->category = strdup(_src->category);
- if(_dst->category == NULL)
- {
+ 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(STRING_VALID(_src->location_tag))
- {
- _dst->location_tag = strdup(_src->location_tag);
- if(_dst->location_tag == NULL)
- {
+ 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(STRING_VALID(_src->age_rating))
- {
- _dst->age_rating = strdup(_src->age_rating);
- if(_dst->age_rating == NULL)
- {
+ 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(STRING_VALID(_src->keyword))
- {
- _dst->keyword = strdup(_src->keyword);
- if(_dst->keyword == NULL)
- {
+ 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_TV_PROFILE
+ 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->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_TV_PROFILE
+ _dst->extract_flag = _src->extract_flag;
+#endif
- if(_src->media_type == MEDIA_CONTENT_TYPE_IMAGE && _src->image_meta) {
+ 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)
- {
+ 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(STRING_VALID(_src->image_meta->media_id))
- {
- _dst->image_meta->media_id = strdup(_src->image_meta->media_id);
- if(_dst->image_meta->media_id == NULL)
- {
+ 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(STRING_VALID(_src->image_meta->date_taken))
- {
- _dst->image_meta->date_taken = strdup(_src->image_meta->date_taken);
- if(_dst->image_meta->date_taken == NULL)
- {
+ 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(STRING_VALID(_src->image_meta->burst_id))
- {
- _dst->image_meta->burst_id = strdup(_src->image_meta->burst_id);
- if(_dst->image_meta->burst_id == NULL)
- {
+ 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(STRING_VALID(_src->image_meta->weather))
- {
- _dst->image_meta->weather = strdup(_src->image_meta->weather);
- if(_dst->image_meta->weather == NULL)
- {
+ 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) {
+ } 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)
- {
+ 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(STRING_VALID(_src->video_meta->media_id))
- {
- _dst->video_meta->media_id = strdup(_src->video_meta->media_id);
- if(_dst->video_meta->media_id == NULL)
- {
+ 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(STRING_VALID(_src->video_meta->title))
- {
- _dst->video_meta->title = strdup(_src->video_meta->title);
- if(_dst->video_meta->title == NULL)
- {
+ 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(STRING_VALID(_src->video_meta->album))
- {
- _dst->video_meta->album = strdup(_src->video_meta->album);
- if(_dst->video_meta->album == NULL)
- {
+ 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(STRING_VALID(_src->video_meta->artist))
- {
- _dst->video_meta->artist = strdup(_src->video_meta->artist);
- if(_dst->video_meta->artist == NULL)
- {
+ 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(STRING_VALID(_src->video_meta->genre))
- {
- _dst->video_meta->genre = strdup(_src->video_meta->genre);
- if(_dst->video_meta->genre == NULL)
- {
+ 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(STRING_VALID(_src->video_meta->composer))
- {
- _dst->video_meta->composer = strdup(_src->video_meta->composer);
- if(_dst->video_meta->composer == NULL)
- {
+ 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(STRING_VALID(_src->video_meta->year))
- {
- _dst->video_meta->year = strdup(_src->video_meta->year);
- if(_dst->video_meta->year == NULL)
- {
+ 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(STRING_VALID(_src->video_meta->recorded_date))
- {
- _dst->video_meta->recorded_date = strdup(_src->video_meta->recorded_date);
- if(_dst->video_meta->recorded_date == NULL)
- {
+ 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(STRING_VALID(_src->video_meta->copyright))
- {
- _dst->video_meta->copyright = strdup(_src->video_meta->copyright);
- if(_dst->video_meta->copyright == NULL)
- {
+ 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(STRING_VALID(_src->video_meta->track_num))
- {
- _dst->video_meta->track_num = strdup(_src->video_meta->track_num);
- if(_dst->video_meta->track_num == NULL)
- {
+ 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->played_time = _src->video_meta->played_time;
_dst->video_meta->played_position = _src->video_meta->played_position;
- } else if((_src->media_type == MEDIA_CONTENT_TYPE_MUSIC || _src->media_type == MEDIA_CONTENT_TYPE_SOUND) && _src->audio_meta) {
+ } 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)
- {
+ 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(STRING_VALID(_src->audio_meta->media_id))
- {
- _dst->audio_meta->media_id = strdup(_src->audio_meta->media_id);
- if(_dst->audio_meta->media_id == NULL)
- {
+ 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(STRING_VALID(_src->audio_meta->title))
- {
- _dst->audio_meta->title = strdup(_src->audio_meta->title);
- if(_dst->audio_meta->title == NULL)
- {
+ 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(STRING_VALID(_src->audio_meta->album))
- {
- _dst->audio_meta->album = strdup(_src->audio_meta->album);
- if(_dst->audio_meta->album == NULL)
- {
+ 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(STRING_VALID(_src->audio_meta->artist))
- {
- _dst->audio_meta->artist = strdup(_src->audio_meta->artist);
- if(_dst->audio_meta->artist == NULL)
- {
+ 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(STRING_VALID(_src->audio_meta->genre))
- {
- _dst->audio_meta->genre = strdup(_src->audio_meta->genre);
- if(_dst->audio_meta->genre == NULL)
- {
+ 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(STRING_VALID(_src->audio_meta->composer))
- {
- _dst->audio_meta->composer = strdup(_src->audio_meta->composer);
- if(_dst->audio_meta->composer == NULL)
- {
+ 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(STRING_VALID(_src->audio_meta->year))
- {
- _dst->audio_meta->year = strdup(_src->audio_meta->year);
- if(_dst->audio_meta->year == NULL)
- {
+ 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(STRING_VALID(_src->audio_meta->recorded_date))
- {
- _dst->audio_meta->recorded_date = strdup(_src->audio_meta->recorded_date);
- if(_dst->audio_meta->recorded_date == NULL)
- {
+ 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(STRING_VALID(_src->audio_meta->copyright))
- {
- _dst->audio_meta->copyright = strdup(_src->audio_meta->copyright);
- if(_dst->audio_meta->copyright == NULL)
- {
+ 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(STRING_VALID(_src->audio_meta->track_num))
- {
- _dst->audio_meta->track_num = strdup(_src->audio_meta->track_num);
- if(_dst->audio_meta->track_num == NULL)
- {
+ 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->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
- {
+ } else {
media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
}
{
int ret = MEDIA_CONTENT_ERROR_NONE;
- media_content_debug_func();
-
- if(media_count == NULL)
- {
+ if (media_count == NULL) {
media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
{
int ret = MEDIA_CONTENT_ERROR_NONE;
- media_content_debug_func();
-
- if(callback == NULL)
- {
- media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
- }
+ 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);
{
int ret = MEDIA_CONTENT_ERROR_NONE;
- media_content_debug_func();
-
- if(STRING_VALID(media_id) && tag_count)
- {
+ 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
- {
+ } else {
media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
}
{
int ret = MEDIA_CONTENT_ERROR_NONE;
- media_content_debug_func();
-
- if((callback != NULL) && STRING_VALID(media_id))
- {
+ if ((callback != NULL) && STRING_VALID(media_id)) {
ret = _media_db_get_tag(media_id, filter, callback, user_data);
- }
- else
- {
+ } else {
media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
}
{
int ret = MEDIA_CONTENT_ERROR_NONE;
- media_content_debug_func();
-
- if(STRING_VALID(media_id) && bookmark_count)
- {
+ 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
- {
+ } 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 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;
- media_content_debug_func();
-
- if((callback != NULL) && STRING_VALID(media_id))
- {
+ if ((callback != NULL) && STRING_VALID(media_id)) {
ret = _media_db_get_bookmark(media_id, filter, callback, user_data);
- }
- else
- {
+ } 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 media_info_get_face_count_from_db(const char *media_id, filter_h filter, int *face_count)
{
int ret = MEDIA_CONTENT_ERROR_NONE;
- media_info_s *_media = (media_info_s*)media;
-
- if(_media == NULL)
- {
+ 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);
- return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+ ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
}
- if(_media->media_type != MEDIA_CONTENT_TYPE_IMAGE)
- {
- media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
- }
+ return ret;
+}
- if(_media->image_meta == NULL)
- {
- media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
- }
-
- image_meta_s *_image = (image_meta_s*)calloc(1, sizeof(image_meta_s));
+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(_image == NULL)
- {
- media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
- return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
+ 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;
}
- if(STRING_VALID(_media->media_id)) {
- _image->media_id = strdup(_media->media_id);
- }
+ return ret;
+}
- _image->width = _media->image_meta->width;
- _image->height = _media->image_meta->height;
- _image->orientation = _media->image_meta->orientation;
+int media_info_get_image(media_info_h media, image_meta_h *image)
+{
+ int ret = MEDIA_CONTENT_ERROR_NONE;
- if(STRING_VALID(_media->image_meta->date_taken)) {
- _image->date_taken = strdup(_media->image_meta->date_taken);
- }
+ media_info_s *_media = (media_info_s*)media;
- if(STRING_VALID(_media->image_meta->title)) {
- _image->title = strdup(_media->image_meta->title);
- }
+ 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");
- if(STRING_VALID(_media->image_meta->burst_id)) {
- _image->burst_id = strdup(_media->image_meta->burst_id);
- }
+ 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");
- if(STRING_VALID(_media->image_meta->weather)) {
- _image->weather = strdup(_media->image_meta->weather);
- }
+ _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;
media_info_s *_media = (media_info_s*)media;
- if(_media == NULL)
- {
- media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
- }
-
- if(_media->media_type != MEDIA_CONTENT_TYPE_VIDEO)
- {
- media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
- }
-
- if(_media->video_meta == NULL)
- {
- media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
- }
+ 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));
-
- if(_video == NULL)
- {
- media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
- return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
- }
-
- if(STRING_VALID(_media->media_id)) {
- _video->media_id = strdup(_media->media_id);
- }
-
- if(STRING_VALID(_media->video_meta->title)) {
- _video->title = strdup(_media->video_meta->title);
- }
- if(STRING_VALID(_media->video_meta->album)) {
- _video->album = strdup(_media->video_meta->album);
- }
- if(STRING_VALID(_media->video_meta->artist)) {
- _video->artist = strdup(_media->video_meta->artist);
- }
- if(STRING_VALID(_media->video_meta->genre)) {
- _video->genre = strdup(_media->video_meta->genre);
- }
- if(STRING_VALID(_media->video_meta->composer)) {
- _video->composer = strdup(_media->video_meta->composer);
- }
- if(STRING_VALID(_media->video_meta->year)) {
- _video->year = strdup(_media->video_meta->year);
- }
- if(STRING_VALID(_media->video_meta->recorded_date)) {
- _video->recorded_date = strdup(_media->video_meta->recorded_date);
- }
- if(STRING_VALID(_media->video_meta->copyright)) {
- _video->copyright = strdup(_media->video_meta->copyright);
- }
- if(STRING_VALID(_media->video_meta->track_num)) {
- _video->track_num = strdup(_media->video_meta->track_num);
- }
+ media_content_retvm_if(_video == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
+
+ _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->genre = g_strdup(_media->video_meta->genre);
+ _video->composer = g_strdup(_media->video_meta->composer);
+ _video->year = g_strdup(_media->video_meta->year);
+ _video->recorded_date = g_strdup(_media->video_meta->recorded_date);
+ _video->copyright = g_strdup(_media->video_meta->copyright);
+ _video->track_num = g_strdup(_media->video_meta->track_num);
_video->width = _media->video_meta->width;
_video->height = _media->video_meta->height;
media_info_s *_media = (media_info_s*)media;
- if(_media == NULL)
- {
- media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
- }
-
- if(_media->media_type != MEDIA_CONTENT_TYPE_MUSIC && _media->media_type != MEDIA_CONTENT_TYPE_SOUND)
- {
- media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
- }
-
- if(_media->audio_meta == NULL)
- {
- media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
- }
+ 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");
audio_meta_s *_audio = (audio_meta_s*)calloc(1, sizeof(audio_meta_s));
-
- if(_audio == NULL)
- {
- media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
- return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
- }
-
- if(STRING_VALID(_media->media_id)) {
- _audio->media_id = strdup(_media->media_id);
- }
-
- if(STRING_VALID(_media->audio_meta->title)) {
- _audio->title = strdup(_media->audio_meta->title);
- }
- if(STRING_VALID(_media->audio_meta->album)) {
- _audio->album = strdup(_media->audio_meta->album);
- }
- if(STRING_VALID(_media->audio_meta->artist)) {
- _audio->artist = strdup(_media->audio_meta->artist);
- }
- if(STRING_VALID(_media->audio_meta->genre)) {
- _audio->genre = strdup(_media->audio_meta->genre);
- }
- if(STRING_VALID(_media->audio_meta->composer)) {
- _audio->composer = strdup(_media->audio_meta->composer);
- }
- if(STRING_VALID(_media->audio_meta->year)) {
- _audio->year = strdup(_media->audio_meta->year);
- }
- if(STRING_VALID(_media->audio_meta->recorded_date)) {
- _audio->recorded_date = strdup(_media->audio_meta->recorded_date);
- }
- if(STRING_VALID(_media->audio_meta->copyright)) {
- _audio->copyright = strdup(_media->audio_meta->copyright);
- }
- if(STRING_VALID(_media->audio_meta->track_num)) {
- _audio->track_num = strdup(_media->audio_meta->track_num);
- }
+ media_content_retvm_if(_audio == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
+
+ _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->genre = g_strdup(_media->audio_meta->genre);
+ _audio->composer = g_strdup(_media->audio_meta->composer);
+ _audio->year = g_strdup(_media->audio_meta->year);
+ _audio->recorded_date = g_strdup(_media->audio_meta->recorded_date);
+ _audio->copyright = g_strdup(_media->audio_meta->copyright);
+ _audio->track_num = g_strdup(_media->audio_meta->track_num);
_audio->duration = _media->audio_meta->duration;
_audio->bitrate = _media->audio_meta->bitrate;
int ret = MEDIA_CONTENT_ERROR_NONE;
media_info_s *_media = (media_info_s*)media;
- if(_media && media_id)
- {
- if(STRING_VALID(_media->media_id))
- {
+ if (_media && media_id) {
+ if (STRING_VALID(_media->media_id)) {
*media_id = strdup(_media->media_id);
- if(*media_id == NULL)
- {
- media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
- return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
- }
- }
- else
- {
+ 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
- {
+ } else {
media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
}
int ret = MEDIA_CONTENT_ERROR_NONE;
media_info_s *_media = (media_info_s*)media;
- if(_media && path)
- {
- if(STRING_VALID(_media->file_path))
- {
+ if (_media && path) {
+ if (STRING_VALID(_media->file_path)) {
*path = strdup(_media->file_path);
- if(*path == NULL)
- {
- media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
- return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
- }
- }
- else
- {
+ media_content_retvm_if(*path == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
+ } else {
*path = NULL;
}
ret = MEDIA_CONTENT_ERROR_NONE;
- }
- else
- {
+ } else {
media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
}
{
int ret = MEDIA_CONTENT_ERROR_NONE;
media_info_s *_media = (media_info_s*)media;
- if(_media && name)
- {
- if(STRING_VALID(_media->display_name))
- {
- *name = strdup(_media->display_name);
- if(*name == NULL)
- {
- media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
- return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
- }
- }
- else
- {
+ 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
- {
+ } else {
media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
}
{
int ret = MEDIA_CONTENT_ERROR_NONE;
media_info_s *_media = (media_info_s*)media;
- if(_media && type)
- {
+ if (_media && type) {
*type = _media->media_type;
ret = MEDIA_CONTENT_ERROR_NONE;
- }
- else
- {
+ } else {
media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
}
int ret = MEDIA_CONTENT_ERROR_NONE;
media_info_s *_media = (media_info_s*)media;
- if(_media && mime_type)
- {
- if(STRING_VALID(_media->mime_type))
- {
+ if (_media && mime_type) {
+ if (STRING_VALID(_media->mime_type)) {
*mime_type = strdup(_media->mime_type);
- if(*mime_type == NULL)
- {
- media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
- return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
- }
- }
- else
- {
+ 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
- {
+ } else {
media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
}
int ret = MEDIA_CONTENT_ERROR_NONE;
media_info_s *_media = (media_info_s*)media;
- if(_media && size)
- {
+ if (_media && size) {
*size = _media->size;
ret = MEDIA_CONTENT_ERROR_NONE;
- }
- else
- {
+ } else {
media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
}
{
int ret = MEDIA_CONTENT_ERROR_NONE;
media_info_s *_media = (media_info_s*)media;
- if(_media && added_time)
- {
+ if (_media && added_time) {
*added_time = _media->added_time;
ret = MEDIA_CONTENT_ERROR_NONE;
- }
- else
- {
+ } else {
media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
}
{
int ret = MEDIA_CONTENT_ERROR_NONE;
media_info_s *_media = (media_info_s*)media;
- if(_media && time)
- {
+ if (_media && time) {
*time = _media->modified_time;
ret = MEDIA_CONTENT_ERROR_NONE;
- }
- else
- {
+ } else {
media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
}
{
int ret = MEDIA_CONTENT_ERROR_NONE;
media_info_s *_media = (media_info_s*)media;
- if(_media && time)
- {
+ if (_media && time) {
*time = _media->timeline;
ret = MEDIA_CONTENT_ERROR_NONE;
- }
- else
- {
+ } else {
media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
}
{
int ret = MEDIA_CONTENT_ERROR_NONE;
media_info_s *_media = (media_info_s*)media;
- if(_media && path)
- {
- if(STRING_VALID(_media->thumbnail_path))
- {
- *path = strdup(_media->thumbnail_path);
- if(*path == NULL)
- {
- media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
- return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
- }
- }
- else
- {
+ 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
- {
+ } else {
media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
}
int ret = MEDIA_CONTENT_ERROR_NONE;
media_info_s *_media = (media_info_s*)media;
- if(_media && title)
- {
- if(STRING_VALID(_media->title))
- {
- *title = strdup(_media->title);
- if(*title == NULL)
- {
- media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
- return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
- }
- }
- else
- {
+ 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;
}
- else
- {
+
+ return ret;
+}
+#ifdef _USE_TV_PROFILE
+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(STRING_VALID(_media->description))
- {
- *description = strdup(_media->description);
- if(*description == NULL)
- {
- media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
- return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
- }
- }
- else
- {
+ 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
- {
+ } else {
media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
}
int ret = MEDIA_CONTENT_ERROR_NONE;
media_info_s *_media = (media_info_s*)media;
- if(_media && longitude)
- {
+ if (_media && longitude) {
*longitude = _media->longitude;
ret = MEDIA_CONTENT_ERROR_NONE;
- }
- else
- {
+ } else {
media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
}
int ret = MEDIA_CONTENT_ERROR_NONE;
media_info_s *_media = (media_info_s*)media;
- if(_media && latitude)
- {
+ if (_media && latitude) {
*latitude = _media->latitude;
ret = MEDIA_CONTENT_ERROR_NONE;
- }
- else
- {
+ } else {
media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
}
int ret = MEDIA_CONTENT_ERROR_NONE;
media_info_s *_media = (media_info_s*)media;
- if(_media && altitude)
- {
+ if (_media && altitude) {
*altitude = _media->altitude;
ret = MEDIA_CONTENT_ERROR_NONE;
- }
- else
- {
+ } else {
media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
}
int ret = MEDIA_CONTENT_ERROR_NONE;
media_info_s *_media = (media_info_s*)media;
- if(_media && weather)
- {
- if(STRING_VALID(_media->weather))
- {
+ if (_media && weather) {
+ if (_media->weather != NULL) {
*weather = strdup(_media->weather);
- if(*weather == NULL)
- {
- media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
- return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
- }
- }
- else
- {
+ media_content_retvm_if(*weather == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
+ } else {
*weather = NULL;
}
ret = MEDIA_CONTENT_ERROR_NONE;
- }
- else
- {
+ } else {
media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
}
int ret = MEDIA_CONTENT_ERROR_NONE;
media_info_s *_media = (media_info_s*)media;
- if(_media && rating)
- {
+ if (_media && rating) {
*rating = _media->rating;
ret = MEDIA_CONTENT_ERROR_NONE;
- }
- else
- {
+ } else {
media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
}
int ret = MEDIA_CONTENT_ERROR_NONE;
media_info_s *_media = (media_info_s*)media;
- if(_media && favorite)
- {
-
+ if (_media && favorite) {
*favorite = _media->favourite;
ret = MEDIA_CONTENT_ERROR_NONE;
- }
- else
- {
+ } else {
media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
}
int ret = MEDIA_CONTENT_ERROR_NONE;
media_info_s *_media = (media_info_s*)media;
- if(_media && author)
- {
- if(STRING_VALID(_media->author))
- {
+ if (_media && author) {
+ if (_media->author != NULL) {
*author = strdup(_media->author);
- if(*author == NULL)
- {
- media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
- return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
- }
- }
- else
- {
+ media_content_retvm_if(*author == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
+ } else {
*author = NULL;
}
ret = MEDIA_CONTENT_ERROR_NONE;
- }
- else
- {
+ } else {
media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
}
int ret = MEDIA_CONTENT_ERROR_NONE;
media_info_s *_media = (media_info_s*)media;
- if(_media && provider)
- {
- if(STRING_VALID(_media->provider))
- {
+ if (_media && provider) {
+ if (_media->provider != NULL) {
*provider = strdup(_media->provider);
- if(*provider == NULL)
- {
- media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
- return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
- }
- }
- else
- {
+ media_content_retvm_if(*provider == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
+ } else {
*provider = NULL;
}
ret = MEDIA_CONTENT_ERROR_NONE;
- }
- else
- {
+ } else {
media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
}
int ret = MEDIA_CONTENT_ERROR_NONE;
media_info_s *_media = (media_info_s*)media;
- if(_media && content_name)
- {
- if(STRING_VALID(_media->content_name))
- {
+ if (_media && content_name) {
+ if (_media->content_name != NULL) {
*content_name = strdup(_media->content_name);
- if(*content_name == NULL)
- {
- media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
- return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
- }
- }
- else
- {
+ 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
- {
+ } else {
media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
}
int ret = MEDIA_CONTENT_ERROR_NONE;
media_info_s *_media = (media_info_s*)media;
- if(_media && category)
- {
- if(STRING_VALID(_media->category))
- {
+ if (_media && category) {
+ if (_media->category != NULL) {
*category = strdup(_media->category);
- if(*category == NULL)
- {
- media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
- return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
- }
- }
- else
- {
+ media_content_retvm_if(*category == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
+ } else {
*category = NULL;
}
ret = MEDIA_CONTENT_ERROR_NONE;
- }
- else
- {
+ } else {
media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
}
int ret = MEDIA_CONTENT_ERROR_NONE;
media_info_s *_media = (media_info_s*)media;
- if(_media && location_tag)
- {
- if(STRING_VALID(_media->location_tag))
- {
+ if (_media && location_tag) {
+ if (_media->location_tag != NULL) {
*location_tag = strdup(_media->location_tag);
- if(*location_tag == NULL)
- {
- media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
- return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
- }
- }
- else
- {
+ 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
- {
+ } else {
media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
}
int ret = MEDIA_CONTENT_ERROR_NONE;
media_info_s *_media = (media_info_s*)media;
- if(_media && age_rating)
- {
- if(STRING_VALID(_media->age_rating))
- {
+ if (_media && age_rating) {
+ if (_media->age_rating != NULL) {
*age_rating = strdup(_media->age_rating);
- if(*age_rating == NULL)
- {
- media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
- return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
- }
- }
- else
- {
+ 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
- {
+ } else {
media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
}
int ret = MEDIA_CONTENT_ERROR_NONE;
media_info_s *_media = (media_info_s*)media;
- if(_media && keyword)
- {
- if(STRING_VALID(_media->keyword))
- {
+ if (_media && keyword) {
+ if (_media->keyword != NULL) {
*keyword = strdup(_media->keyword);
- if(*keyword == NULL)
- {
- media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
- return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
- }
- }
- else
- {
+ 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;
}
- else
- {
+
+ return ret;
+}
+
+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;
}
int ret = MEDIA_CONTENT_ERROR_NONE;
media_info_s *_media = (media_info_s*)media;
- if(_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;
}
- else
- {
+
+ return ret;
+}
+
+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;
+
+ 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;
}
int ret = MEDIA_CONTENT_ERROR_NONE;
media_info_s *_media = (media_info_s*)media;
- if(_media && storage_type)
- {
+ 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;
}
- else
- {
+
+ return ret;
+}
+
+#ifdef _USE_TV_PROFILE
+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;
+
+ 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;
}
return ret;
}
+#endif
int media_info_get_played_count(media_info_h media, int *played_count)
{
int ret = MEDIA_CONTENT_ERROR_NONE;
media_info_s *_media = (media_info_s*)media;
- if(_media)
- {
+ if (_media) {
*played_count = _media->played_count;
ret = MEDIA_CONTENT_ERROR_NONE;
- }
- else
- {
+ } else {
media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
}
int ret = MEDIA_CONTENT_ERROR_NONE;
media_info_s *_media = (media_info_s*)media;
- if(_media)
- {
+ if (_media) {
*played_time = _media->played_time;
ret = MEDIA_CONTENT_ERROR_NONE;
- }
- else
- {
+ } else {
media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
}
media_info_s *_media = (media_info_s*)media;
- if(_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;
}
- else
- {
+
+ return ret;
+}
+
+#ifdef _USE_TV_PROFILE
+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 && 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;
+ }
+
+ return ret;
+}
+#endif
+#ifdef _USE_SENIOR_MODE
+int media_info_get_contact(media_info_h media, char **contact)
+{
+ 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;
+ }
+
+ return ret;
+}
+
+int media_info_get_app_data(media_info_h media, char **app_data)
+{
+ 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;
+ }
+
+ return ret;
+}
+#endif
+#ifdef _USE_TV_PROFILE
+int media_info_set_played_count(media_info_h media, int played_count)
+{
+ 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;
}
return ret;
}
+#endif
int media_info_set_played_time(media_info_h media)
{
media_info_s *_media = (media_info_s*)media;
- if(_media != NULL)
- {
+ 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;
}
- else
- {
+
+ return ret;
+}
+#ifdef _USE_TV_PROFILE
+int media_info_set_played_position(media_info_h media, int played_position)
+{
+ 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;
}
return ret;
}
+#endif
int media_info_get_media_from_db(const char *media_id, media_info_h *media)
{
int ret = MEDIA_CONTENT_ERROR_NONE;
- int ret_view = MEDIA_CONTENT_ERROR_NONE;
char select_query[DEFAULT_QUERY_SIZE];
+ char storage_id[MEDIA_CONTENT_UUID_SIZE+1] = {0, };
sqlite3_stmt *stmt = NULL;
- if(!STRING_VALID(media_id) || (media == NULL))
- {
+ 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;
}
memset(select_query, 0x00, sizeof(select_query));
+ memset(storage_id, 0x00, sizeof(storage_id));
+
+ ret = _media_db_get_storage_id_by_media_id(media_id, storage_id);
+ media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
+
+ snprintf(select_query, sizeof(select_query), SELECT_MEDIA_FROM_MEDIA, storage_id, media_id);
- snprintf(select_query, sizeof(select_query), SELECT_MEDIA_FROM_MEDIA, media_id);
ret = _content_query_prepare(&stmt, select_query, NULL, NULL);
media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
- while(sqlite3_step(stmt) == SQLITE_ROW)
- {
- media_info_s *_media = (media_info_s*)calloc(1, sizeof(media_info_s));
+ media_info_s *_media = NULL;
- if(_media == NULL)
- {
+ while (sqlite3_step(stmt) == SQLITE_ROW) {
+ if (_media)
+ media_info_destroy((media_info_h)_media);
+
+ _media = (media_info_s*)calloc(1, sizeof(media_info_s));
+
+ 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;
}
SQLITE3_FINALIZE(stmt);
+
return ret;
}
int ret = MEDIA_CONTENT_ERROR_NONE;
media_info_s *_media = (media_info_s*)media;
- if(_media != NULL && STRING_VALID(display_name))
- {
+ if (_media != NULL && STRING_VALID(display_name)) {
SAFE_FREE(_media->display_name);
_media->display_name = strdup(display_name);
- if(_media->display_name == NULL)
- {
- media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
- return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
- }
- }
- else
- {
+ 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;
}
int ret = MEDIA_CONTENT_ERROR_NONE;
media_info_s *_media = (media_info_s*)media;
- if(_media != NULL)
- {
+ if (_media != NULL) {
SAFE_FREE(_media->description);
- if(STRING_VALID(description))
- {
+ if (STRING_VALID(description)) {
_media->description = strdup(description);
-
- if(_media->description == NULL)
- {
- media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
- return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
- }
- }
- else
- {
+ media_content_retvm_if(_media->description == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
+ } else {
_media->description = NULL;
}
- }
- else
- {
+ } else {
media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
}
int ret = MEDIA_CONTENT_ERROR_NONE;
media_info_s *_media = (media_info_s*)media;
- if(_media != NULL)
- {
+ if (_media != NULL) {
_media->longitude = longitude;
- }
- else
- {
+ } else {
media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
}
int ret = MEDIA_CONTENT_ERROR_NONE;
media_info_s *_media = (media_info_s*)media;
- if(_media != NULL)
- {
+ if (_media != NULL) {
_media->latitude = latitude;
- }
- else
- {
+ } else {
media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
}
int ret = MEDIA_CONTENT_ERROR_NONE;
media_info_s *_media = (media_info_s*)media;
- if(_media != NULL)
- {
+ if (_media != NULL) {
_media->altitude = altitude;
- }
- else
- {
+ } else {
media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
}
int ret = MEDIA_CONTENT_ERROR_NONE;
media_info_s *_media = (media_info_s*)media;
- if(_media != NULL)
- {
+ if (_media != NULL) {
SAFE_FREE(_media->weather);
- if(STRING_VALID(weather))
- {
+ if (STRING_VALID(weather)) {
_media->weather = strdup(weather);
-
- if(_media->weather == NULL)
- {
- media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
- return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
- }
- }
- else
- {
+ media_content_retvm_if(_media->weather == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
+ } else {
_media->weather = NULL;
}
- }
- else
- {
+ } else {
media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
}
int ret = MEDIA_CONTENT_ERROR_NONE;
media_info_s *_media = (media_info_s*)media;
- if(_media != NULL)
- {
+ if (_media != NULL) {
_media->rating = rating;
- }
- else
- {
+ } else {
media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
}
media_info_s *_media = (media_info_s*)media;
- if((_media != NULL) && (added_time >= 0))
- {
+ if ((_media != NULL) && (added_time >= 0)) {
_media->added_time = added_time;
- }
- else
- {
+ } else {
media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
}
int ret = MEDIA_CONTENT_ERROR_NONE;
media_info_s *_media = (media_info_s*)media;
- if(_media != NULL)
- {
- if(favorite == TRUE)
- {
+ if (_media != NULL) {
+ if (favorite == TRUE)
time(&_media->favourite);
- }
else
- {
_media->favourite = 0;
- }
- }
- else
- {
+ } else {
media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
}
int ret = MEDIA_CONTENT_ERROR_NONE;
media_info_s *_media = (media_info_s*)media;
- if(_media != NULL)
- {
- if(STRING_VALID(author))
- {
+ if (_media != NULL) {
+ if (STRING_VALID(author)) {
_media->author = strdup(author);
- if(_media->author == NULL)
- {
- media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
- return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
- }
- }
- else
- {
+ media_content_retvm_if(_media->author == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
+ } else {
_media->author = NULL;
}
- }
- else
- {
+ } else {
media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
}
int ret = MEDIA_CONTENT_ERROR_NONE;
media_info_s *_media = (media_info_s*)media;
- if(_media != NULL)
- {
+ if (_media != NULL) {
SAFE_FREE(_media->provider);
- if(STRING_VALID(provider))
- {
+ if (STRING_VALID(provider)) {
_media->provider = strdup(provider);
- if(_media->provider == NULL)
- {
- media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
- return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
- }
- }
- else
- {
+ media_content_retvm_if(_media->provider == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
+ } else {
_media->provider = NULL;
}
- }
- else
- {
+ } else {
media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
}
int ret = MEDIA_CONTENT_ERROR_NONE;
media_info_s *_media = (media_info_s*)media;
- if(_media != NULL)
- {
+ if (_media != NULL) {
SAFE_FREE(_media->content_name);
- if(STRING_VALID(content_name))
- {
+ if (STRING_VALID(content_name)) {
_media->content_name = strdup(content_name);
- if(_media->content_name == NULL)
- {
- media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
- return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
- }
- }
- else
- {
+ media_content_retvm_if(_media->content_name == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
+ } else {
_media->content_name = NULL;
}
- }
- else
- {
+ } else {
media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
}
int ret = MEDIA_CONTENT_ERROR_NONE;
media_info_s *_media = (media_info_s*)media;
- if(_media != NULL)
- {
+ if (_media != NULL) {
SAFE_FREE(_media->category);
- if(STRING_VALID(category))
- {
+ if (STRING_VALID(category)) {
_media->category = strdup(category);
- if(_media->category == NULL)
- {
- media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
- return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
- }
- }
- else
- {
+ media_content_retvm_if(_media->category == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
+ } else {
_media->category = NULL;
}
- }
- else
- {
+ } else {
media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
}
int ret = MEDIA_CONTENT_ERROR_NONE;
media_info_s *_media = (media_info_s*)media;
- if(_media != NULL)
- {
+ if (_media != NULL) {
SAFE_FREE(_media->location_tag);
- if(STRING_VALID(location_tag))
- {
+ if (STRING_VALID(location_tag)) {
_media->location_tag = strdup(location_tag);
- if(_media->location_tag == NULL)
- {
- media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
- return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
- }
- }
- else
- {
+ media_content_retvm_if(_media->location_tag == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
+ } else {
_media->location_tag = NULL;
}
- }
- else
- {
+ } else {
media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
}
int ret = MEDIA_CONTENT_ERROR_NONE;
media_info_s *_media = (media_info_s*)media;
- if(_media != NULL)
- {
+ if (_media != NULL) {
SAFE_FREE(_media->age_rating);
- if(STRING_VALID(age_rating))
- {
+ if (STRING_VALID(age_rating)) {
_media->age_rating = strdup(age_rating);
- if(_media->age_rating == NULL)
- {
- media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
- return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
- }
- }
- else
- {
+ media_content_retvm_if(_media->age_rating == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
+ } else {
_media->age_rating = NULL;
}
- }
- else
- {
+ } else {
media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
}
int ret = MEDIA_CONTENT_ERROR_NONE;
media_info_s *_media = (media_info_s*)media;
- if(_media != NULL)
- {
+ if (_media != NULL) {
SAFE_FREE(_media->keyword);
- if(STRING_VALID(keyword))
- {
+ if (STRING_VALID(keyword)) {
_media->keyword = strdup(keyword);
- if(_media->keyword == NULL)
- {
- media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
- return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
- }
- }
- else
- {
+ media_content_retvm_if(_media->keyword == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
+ } else {
_media->keyword = NULL;
}
- }
- else
- {
+ } else {
media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
}
int media_info_update_to_db(media_info_h media)
{
int ret = MEDIA_CONTENT_ERROR_NONE;
- int len = 0;
media_info_s *_media = (media_info_s*)media;
char *set_sql = NULL;
- char sql[MAX_QUERY_SIZE];
- memset(sql, '\0', sizeof(sql));
+ char *sql = NULL;
- if(_media != NULL && STRING_VALID(_media->media_id))
- {
+ 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_free(test_sql);
+ SQLITE3_SAFE_FREE(test_sql);
/*Update Pinyin If Support Pinyin*/
char *file_name_pinyin = NULL;
/*Update Pinyin If Support Pinyin*/
media_svc_check_pinyin_support(&pinyin_support);
- if(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);
+ }
+
+ 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);
+ }
+
+#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
{
- if(STRING_VALID(_media->display_name))
- media_svc_get_pinyin(_content_get_db_handle(), _media->display_name, &file_name_pinyin);
- if(STRING_VALID(_media->description))
- media_svc_get_pinyin(_content_get_db_handle(), _media->description, &description_pinyin);
- if(STRING_VALID(_media->author))
- media_svc_get_pinyin(_content_get_db_handle(), _media->author, &author_pinyin);
- if(STRING_VALID(_media->provider))
- media_svc_get_pinyin(_content_get_db_handle(), _media->provider, &provider_pinyin);
- if(STRING_VALID(_media->content_name))
- media_svc_get_pinyin(_content_get_db_handle(), _media->content_name, &content_name_pinyin);
- if(STRING_VALID(_media->category))
- media_svc_get_pinyin(_content_get_db_handle(), _media->category, &category_pinyin);
- if(STRING_VALID(_media->location_tag))
- media_svc_get_pinyin(_content_get_db_handle(), _media->location_tag, &location_tag_pinyin);
- if(STRING_VALID(_media->age_rating))
- media_svc_get_pinyin(_content_get_db_handle(), _media->age_rating, &age_rating_pinyin);
- if(STRING_VALID(_media->keyword))
- media_svc_get_pinyin(_content_get_db_handle(), _media->keyword, &keyword_pinyin);
- }
-
- 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",
- _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);
-
- len = snprintf(sql, sizeof(sql), "UPDATE %s SET %s WHERE media_uuid='%s'", DB_TABLE_MEDIA, set_sql, _media->media_id);
- sqlite3_free(set_sql);
+ 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);
+ }
+
+ 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(description_pinyin);
SAFE_FREE(author_pinyin);
SAFE_FREE(age_rating_pinyin);
SAFE_FREE(keyword_pinyin);
- if (len > 0) {
- sql[len] = '\0';
- } else {
- media_content_error("snprintf failed");
- return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
- }
+ SAFE_FREE(album);
+ SAFE_FREE(artist);
+ SAFE_FREE(genre);
+ SAFE_FREE(recorded_date);
+
+ if (_media->storage_type == MEDIA_CONTENT_STORAGE_CLOUD) {
+ set_sql = NULL;
+ sql = NULL;
+
+ if (_media->media_type == MEDIA_CONTENT_TYPE_VIDEO) {
+ set_sql = sqlite3_mprintf("title=%Q, album=%Q, artist=%Q, genre=%Q, duration=%d, width=%d, height=%d", \
+ _media->title, _media->video_meta->album, _media->video_meta->artist, _media->video_meta->genre, _media->video_meta->duration, _media->video_meta->width, _media->video_meta->height);
+ } else if ((_media->media_type == MEDIA_CONTENT_TYPE_MUSIC) || (_media->media_type == MEDIA_CONTENT_TYPE_SOUND)) {
+ set_sql = sqlite3_mprintf("title=%Q, album=%Q, artist=%Q, genre=%Q, duration=%d", \
+ _media->title, _media->audio_meta->album, _media->audio_meta->artist, _media->audio_meta->genre, _media->audio_meta->duration);
+ } else if (_media->media_type == MEDIA_CONTENT_TYPE_IMAGE) {
+ set_sql = sqlite3_mprintf("title=%Q, width=%d, height=%d", _media->title, _media->image_meta->width, _media->image_meta->height);
+ } else {
+ set_sql = sqlite3_mprintf("title=%Q", _media->title);
+ }
+ 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);
+ }
- ret = _content_query_sql(sql);
if (ret == MEDIA_CONTENT_ERROR_NONE) {
- /* Send notification for this update */
+ /* Send notification for this update */
media_content_debug("Update is successfull. Send notification for this");
- if (_media->file_path && _media->mime_type) {
- media_db_update_send(getpid(), MS_MEDIA_ITEM_FILE, MS_MEDIA_ITEM_UPDATE, _media->file_path, _media->media_id, _media->media_type, _media->mime_type);
- } else {
- media_content_error("Can't media_db_update_send : path or mime type is NULL");
- }
+ 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
- {
+ } else {
media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
}
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_QUERY_SIZE] = {0, };
- if(!STRING_VALID(media_id))
- {
+ if (!STRING_VALID(media_id)) {
media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
}
ret = media_info_get_media_from_db(media_id, &media);
- if(ret != MEDIA_CONTENT_ERROR_NONE)
- {
+ if (ret != MEDIA_CONTENT_ERROR_NONE) {
media_info_destroy(media);
return ret;
}
ret = media_info_get_storage_type(media, &storage_type);
- if(ret != MEDIA_CONTENT_ERROR_NONE)
- {
+ if (ret != MEDIA_CONTENT_ERROR_NONE) {
media_info_destroy(media);
return ret;
}
+ if (storage_type == MEDIA_CONTENT_STORAGE_CLOUD) {
+ media_info_destroy(media);
+ media_content_error("Can't refresh cloud content!!");
+ return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+ }
+
ret = media_info_get_file_path(media, &file_path);
- if(ret != MEDIA_CONTENT_ERROR_NONE)
- {
+ 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);
- ret = media_svc_refresh_item(_content_get_db_handle(), storage_type, file_path, tzplatform_getuid(TZ_USER_NAME));
+ ret = _media_util_check_file_exist(repl_path);
+ if (ret != MEDIA_CONTENT_ERROR_NONE) {
+ SAFE_FREE(file_path);
+ media_info_destroy(media);
+ return ret;
+ }
+
+ memset(storage_id, 0x00, sizeof(storage_id));
+ ret = media_svc_get_storage_id(_content_get_db_handle(), repl_path, storage_id);
+ 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);
+ }
+
+ ret = media_svc_refresh_item(_content_get_db_handle(), storage_id, storage_type, repl_path, tzplatform_getuid(TZ_USER_NAME));
+ if (ret != MS_MEDIA_ERR_NONE)
+ ret = _content_error_capi(MEDIA_CONTENT_TYPE, ret);
SAFE_FREE(file_path);
media_info_destroy(media);
int media_info_move_to_db(media_info_h media, const char* dst_path)
{
int ret = MEDIA_CONTENT_ERROR_NONE;
+ bool ignore_file = FALSE;
+ bool ignore_dir = FALSE;
+ char *folder_path = NULL;
+ 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_QUERY_SIZE] = {0, };
+ char org_repl_path[MAX_QUERY_SIZE] = {0, };
- int src_storage_type = 0;
- int dst_storage_type = 0;
-
- if(media == NULL || !STRING_VALID(dst_path))
- {
- media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
- }
+ 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");
media_info_s *_media = (media_info_s*)media;
- ret = _media_util_get_store_type_by_path(_media->file_path, &src_storage_type);
- media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
- ret = _media_util_get_store_type_by_path(dst_path, &dst_storage_type);
+ ret = _media_util_check_ignore_file(repl_path, &ignore_file);
+ media_content_retvm_if(ignore_file == TRUE, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid path");
+ 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_util_check_file_exist(repl_path);
media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
- ret = media_svc_move_item(_content_get_db_handle(), src_storage_type, _media->file_path, dst_storage_type, dst_path, tzplatform_getuid(TZ_USER_NAME));
+ folder_path = g_path_get_dirname(repl_path);
+ ret = _media_util_check_ignore_dir(folder_path, &ignore_dir);
+ SAFE_FREE(folder_path);
+
+ media_content_retvm_if(ignore_dir == TRUE, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid folder path");
+
+ ret = media_svc_get_storage_type(org_repl_path, &src_storage_type, tzplatform_getuid(TZ_USER_NAME));
+ 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);
+ }
+
+ ret = media_svc_get_storage_type(repl_path, &dst_storage_type, tzplatform_getuid(TZ_USER_NAME));
+ 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);
+ }
+
+ memset(storage_id, 0x00, sizeof(storage_id));
+ ret = media_svc_get_storage_id(_content_get_db_handle(), org_repl_path, storage_id);
+ 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_move_item(_content_get_db_handle(), storage_id, src_storage_type, org_repl_path, dst_storage_type, repl_path, tzplatform_getuid(TZ_USER_NAME));
return _content_error_capi(MEDIA_CONTENT_TYPE, ret);
}
int media_info_create_thumbnail(media_info_h media, media_thumbnail_completed_cb callback, void *user_data)
{
int ret = MEDIA_CONTENT_ERROR_NONE;
+ static unsigned int req_id = 0;
+ char repl_path[MAX_QUERY_SIZE] = {0, };
media_info_s *_media = (media_info_s*)media;
- if(_media != NULL && STRING_VALID(_media->media_id) && STRING_VALID(_media->file_path))
- {
+ 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_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;
+
_thumb_cb->handle = _media;
_thumb_cb->user_data = user_data;
_thumb_cb->thumbnail_completed_cb = callback;
- ret = thumbnail_request_from_db_async(_media->file_path, (ThumbFunc)__media_info_thumbnail_completed_cb, (void *)_thumb_cb, tzplatform_getuid(TZ_USER_NAME));
+ ret = thumbnail_request_from_db_async(_media->request_id, repl_path, (ThumbFunc)__media_info_thumbnail_completed_cb, (void *)_thumb_cb, tzplatform_getuid(TZ_USER_NAME));
ret = _content_error_capi(MEDIA_THUMBNAIL_TYPE, ret);
- }
- else
- {
+ } else {
media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
}
{
int ret = MEDIA_CONTENT_ERROR_NONE;
media_info_s *_media = (media_info_s*)media;
+ char repl_path[MAX_QUERY_SIZE] = {0, };
+
+ if (_media != NULL && STRING_VALID(_media->media_id) && STRING_VALID(_media->file_path) && _media->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");
- if(_media != NULL && STRING_VALID(_media->media_id) && STRING_VALID(_media->file_path))
- {
- ret = thumbnail_request_cancel_media(_media->file_path, tzplatform_getuid(TZ_USER_NAME));
+ ret = thumbnail_request_cancel_media(_media->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;
}
- else
- {
+
+ return 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_QUERY_SIZE] = {0, };
+
+ if (!__media_info_isFaceRecognition_feature_supported()) {
+ media_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, tzplatform_getuid(TZ_USER_NAME));
+ 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;
+}
+
+int media_info_cancel_face_detection(media_info_h media)
+{
+ int ret = MEDIA_CONTENT_ERROR_NONE;
+ media_info_s *_media = (media_info_s*)media;
+ char repl_path[MAX_QUERY_SIZE] = {0, };
+
+ if (!__media_info_isFaceRecognition_feature_supported()) {
+ media_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");
+#ifndef _USE_TV_PROFILE
+ char repl_path[MAX_QUERY_SIZE] = {0, };
+ char *tmp_path = NULL;
+#endif
+
+ 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");
+
+#ifdef _USE_TV_PROFILE
+ svc_content_info->path = g_strdup(media->file_path);
+#else
+ 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);
+#endif
+ 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);
+
+ if (storage_type == MEDIA_CONTENT_STORAGE_CLOUD) {
+ switch (media->media_type) {
+ case MEDIA_CONTENT_TYPE_IMAGE:
+ svc_content_info->media_meta.width = media->image_meta->width;
+ svc_content_info->media_meta.height = media->image_meta->height;
+ svc_content_info->media_meta.datetaken = g_strdup(media->image_meta->date_taken);
+ svc_content_info->media_meta.orientation = media->image_meta->orientation;
+ break;
+ case MEDIA_CONTENT_TYPE_VIDEO:
+ svc_content_info->media_meta.album_artist = g_strdup(media->audio_meta->album_artist);
+ svc_content_info->media_meta.composer = g_strdup(media->audio_meta->composer);
+ svc_content_info->media_meta.year = g_strdup(media->audio_meta->year);
+ svc_content_info->media_meta.copyright = g_strdup(media->audio_meta->copyright);
+ svc_content_info->media_meta.track_num = g_strdup(media->audio_meta->track_num);
+ svc_content_info->media_meta.bitrate = media->audio_meta->bitrate;
+ svc_content_info->media_meta.duration = media->audio_meta->duration;
+ svc_content_info->media_meta.width = media->image_meta->width;
+ svc_content_info->media_meta.height = media->image_meta->height;
+ break;
+ case MEDIA_CONTENT_TYPE_SOUND:
+ case MEDIA_CONTENT_TYPE_MUSIC:
+ svc_content_info->media_meta.album_artist = g_strdup(media->audio_meta->album_artist);
+ svc_content_info->media_meta.composer = g_strdup(media->audio_meta->composer);
+ svc_content_info->media_meta.year = g_strdup(media->audio_meta->year);
+ svc_content_info->media_meta.copyright = g_strdup(media->audio_meta->copyright);
+ svc_content_info->media_meta.track_num = g_strdup(media->audio_meta->track_num);
+ svc_content_info->media_meta.bitrate = media->audio_meta->bitrate;
+ svc_content_info->media_meta.duration = media->audio_meta->duration;
+ svc_content_info->media_meta.channel = media->audio_meta->channel;
+ svc_content_info->media_meta.samplerate = media->audio_meta->samplerate;
+ break;
+ case MEDIA_CONTENT_TYPE_OTHERS:
+ default:
+ break;
+ }
+ }
+
+ *service_content = svc_content_info;
+
+ return MEDIA_CONTENT_ERROR_NONE;
+}
+
+static int __media_info_set_str_data(media_info_h media, media_info_item_e data_type, const char *str_data)
+{
+ 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");
+ }
+
+ 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;
+ }
+
+ return MEDIA_CONTENT_ERROR_NONE;
+}
+
+static int __media_info_destroy(media_info_h media)
+{
+ 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);
+ 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);
+ }
+
+ 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_insert_to_db_with_data(media_info_h media)
+{
+ int ret = MEDIA_CONTENT_ERROR_NONE;
+ char repl_path[MAX_QUERY_SIZE] = {0, };
+
+ 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);
+
+ /* Cloud Item should be filled whole info*/
+ if (_media->storage_type == MEDIA_CONTENT_STORAGE_CLOUD) {
+ media_content_retvm_if(!STRING_VALID(_media->mime_type), MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid mime_type");
+ media_content_retvm_if(!STRING_VALID(_media->title), MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid title");
+ media_content_retvm_if(_media->size <= 0, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid size [%d]", _media->size);
+ media_content_retvm_if(_media->modified_time <= 0, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid modified_time [%d]", _media->modified_time);
+
+ if ((_media->media_type < MEDIA_CONTENT_TYPE_IMAGE) || (_media->media_type > MEDIA_CONTENT_TYPE_OTHERS)) {
+ media_content_error("invalid media type [%d]", _media->media_type);
+ return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+ }
+ }
+
+ 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, tzplatform_getuid(TZ_USER_NAME));
+ 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);
+ 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", ret);
+
+ SAFE_FREE(media_file_path);
+ SAFE_FREE(media_string_uuid);
+
+ return ret;
+}
+
+int media_info_create(const char *path, media_info_h *media)
+{
+ int ret = MEDIA_CONTENT_ERROR_NONE;
+ char storage_id[MEDIA_CONTENT_UUID_SIZE+1] = {0, };
+ media_svc_storage_type_e storage_type = 0;
+ bool ignore_file = FALSE;
+ char repl_path[MAX_QUERY_SIZE] = {0, };
+
+ 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");
+
+ ret = _media_util_check_ignore_file(repl_path, &ignore_file);
+ media_content_retvm_if(ignore_file == TRUE, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid path");
+
+ memset(storage_id, 0x00, sizeof(storage_id));
+
+ if (STRING_VALID(MEDIA_ROOT_PATH_CLOUD) && (strstr(repl_path, MEDIA_ROOT_PATH_CLOUD) == NULL)) {
+ bool ignore_dir = FALSE;
+ char *folder_path = NULL;
+
+ ret = _media_util_check_file_exist(repl_path);
+ media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
+
+ folder_path = g_path_get_dirname(repl_path);
+ ret = _media_util_check_ignore_dir(folder_path, &ignore_dir);
+ SAFE_FREE(folder_path);
+ media_content_retvm_if(ignore_dir == TRUE, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid folder path");
+
+ ret = media_svc_get_storage_id(_content_get_db_handle(), repl_path, storage_id);
+ 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, tzplatform_getuid(TZ_USER_NAME));
+ 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;
+ }
+
+ _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;
+ }
+
+ *media = (media_info_h)_media;
+
+ return ret;
+}
+
+int media_info_set_mime_type(media_info_h media, const char *mime_type)
+{
+ return __media_info_set_str_data(media, MEDIA_INFO_MIME_TYPE, mime_type);
+}
+
+int media_info_set_title(media_info_h media, const char *title)
+{
+ return __media_info_set_str_data(media, MEDIA_INFO_TITLE, title);
+}
+
+int media_info_set_album(media_info_h media, const char *album)
+{
+ return __media_info_set_str_data(media, MEDIA_INFO_ALBUM, album);
+}
+
+int media_info_set_artist(media_info_h media, const char *artist)
+{
+ return __media_info_set_str_data(media, MEDIA_INFO_ARTIST, artist);
+}
+
+int media_info_set_genre(media_info_h media, const char *genre)
+{
+ return __media_info_set_str_data(media, MEDIA_INFO_GENRE, genre);
+}
+
+int media_info_set_recorded_date(media_info_h media, const char *recorded_date)
+{
+ return __media_info_set_str_data(media, MEDIA_INFO_RECORDED_DATE, recorded_date);
+}
+
+int media_info_set_thumbnail_path(media_info_h media, const char *thumbnail_path)
+{
+ return __media_info_set_str_data(media, MEDIA_INFO_THUMBNAIL_PATH, thumbnail_path);
+}
+
+int media_info_set_storage_id(media_info_h media, const char *storage_id)
+{
+ return __media_info_set_str_data(media, MEDIA_INFO_STORAGE_UUID, storage_id);
+}
+
+int media_info_set_size(media_info_h media, unsigned long long size)
+{
+ media_info_s *_media = (media_info_s*)media;
+
+ media_content_retvm_if(_media == NULL, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid media");
+
+ _media->size = size;
+
+ return MEDIA_CONTENT_ERROR_NONE;
+}
+
+int media_info_set_modified_time(media_info_h media, time_t modified_time)
+{
+ media_info_s *_media = (media_info_s*)media;
+
+ media_content_retvm_if(_media == NULL, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid media");
+
+ _media->modified_time = modified_time;
+
+ return MEDIA_CONTENT_ERROR_NONE;
+}
+
+int media_info_set_media_type(media_info_h media, media_content_type_e type)
+{
+ media_info_s *_media = (media_info_s*)media;
+
+ media_content_retvm_if(_media == NULL, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid media");
+
+ _media->media_type = type;
+
+ return MEDIA_CONTENT_ERROR_NONE;
+}
+
+int media_info_set_duration(media_info_h media, int duration)
+{
+ media_info_s *_media = (media_info_s*)media;
+
+ media_content_retvm_if(_media == NULL, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid media");
+
+ if (_media->media_type == MEDIA_CONTENT_TYPE_VIDEO)
+ _media->video_meta->duration = duration;
+ else if ((_media->media_type == MEDIA_CONTENT_TYPE_MUSIC) || (_media->media_type == MEDIA_CONTENT_TYPE_SOUND))
+ _media->audio_meta->duration = duration;
+ else {
+ media_content_error("Invalid media type");
+ return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+ }
+
+ return MEDIA_CONTENT_ERROR_NONE;
+}
+
+int media_info_set_width(media_info_h media, int width)
+{
+ media_info_s *_media = (media_info_s*)media;
+
+ media_content_retvm_if(_media == NULL, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid media");
+
+ if (_media->media_type == MEDIA_CONTENT_TYPE_VIDEO)
+ _media->video_meta->width = width;
+ else if (_media->media_type == MEDIA_CONTENT_TYPE_IMAGE)
+ _media->image_meta->width = width;
+ else {
+ media_content_error("Invalid media type");
+ return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+ }
+
+ return MEDIA_CONTENT_ERROR_NONE;
+}
+
+int media_info_set_height(media_info_h media, int height)
+{
+ media_info_s *_media = (media_info_s*)media;
+
+ media_content_retvm_if(_media == NULL, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid media");
+
+ if (_media->media_type == MEDIA_CONTENT_TYPE_VIDEO)
+ _media->video_meta->height = height;
+ else if (_media->media_type == MEDIA_CONTENT_TYPE_IMAGE)
+ _media->image_meta->height = height;
+ else {
+ media_content_error("Invalid media type");
+ return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+ }
+
+ return MEDIA_CONTENT_ERROR_NONE;
+}
+
+int media_info_set_storage_type(media_info_h media, media_content_storage_e storage_type)
+{
+ media_info_s *_media = (media_info_s*)media;
+
+ media_content_retvm_if(_media == NULL, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid media");
+
+ _media->storage_type = storage_type;
+
+ return MEDIA_CONTENT_ERROR_NONE;
+}
+
+#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)
+{
+ return __media_info_set_str_data(media, MEDIA_INFO_APP_DATA, app_data);
+}
+#endif
+