* @param[in] path The file path
* @return 0 on success, otherwise a negative error value.
* @retval #MEDIA_CONTENT_ERROR_NONE Successful
+ * @pre This function requires opened connection to content service by media_content_connect().
*
*/
int media_content_scan_file(const char *path);
* The sub folders are also scanned, if there are sub folder in that folder. \n
* If you want that the any folders are not scanned, you have to create a blank file ".scan_ignore" in that folder.
* @param[in] path The folder path
+ * @param[in] is_recursive /@a true if scan recursively subdirectories,
+ * /@a false if scan only current directory,
* @param[in] callback The callback to invoke when the scanning is finished
* @param[in] user_data The user data to be passed to the callback function
* @return 0 on success, otherwise a negative error value.
* @see media_scan_completed_cb()
*
*/
-int media_content_scan_folder(const char *path, media_scan_completed_cb callback, void *user_data);
+int media_content_scan_folder(const char *path, bool is_recursive, media_scan_completed_cb callback, void *user_data);
+/**
+ * @brief Subscribe notifications of media db change.
+ * @details This function subscribes notifications of media db change, which are published by media server or other apps.
+ * #media_content_db_update_cb() function will be called when notification of media db change is subscribed.
+ * @param[in] callback The callback to invoke when the scanning is finished
+ * @param[in] user_data The user data to be passed to the callback function
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #MEDIA_CONTENT_ERROR_NONE Successful
+ * @see media_content_db_update_cb()
+ * @see media_content_unset_db_updated_cb()
+ *
+ */
+int media_content_set_db_updated_cb(media_content_db_update_cb callback, void *user_data);
+
+/**
+
+ * @brief Unsubscribe notifications of media db change.
+ * @details This function unsubscribes notifications of media db change, which are published by media server or other apps.
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #MEDIA_CONTENT_ERROR_NONE Successful
+ * @pre media_content_set_db_updated_cb()
+ * @see media_content_set_db_updated_cb()
+ *
+ */
+int media_content_unset_db_updated_cb(void);
/**
* @}
MEDIA_CONTENT_STORAGE_EXTERNAL = 1, /**< The device's external storage */
} media_content_storage_e;
+/**
+ * @ingroup CAPI_MEDIA_CONTENT_MODULE
+ * @brief The enumerations of media content db update item
+ */
+typedef enum {
+ MEDIA_ITEM_FILE = 0, /**< File type ,an item updated to db */
+ MEDIA_ITEM_DIRECTORY = 1, /**< Directory type, an item updated to db */
+} media_content_db_update_item_type_e;
+
+/**
+ * @ingroup CAPI_MEDIA_CONTENT_MODULE
+ * @brief The enumerations of media content db update type
+ */
+typedef enum {
+ MEDIA_CONTENT_INSERT = 0, /**< Insert, the type of DB update */
+ MEDIA_CONTENT_DELETE = 1, /**< Delete, The type of DB update */
+ MEDIA_CONTENT_UPDATE = 2, /**< Update, The type of DB update */
+} media_content_db_update_type_e;
+
/**
* @ingroup CAPI_CONTENT_MEDIA_INFO_MODULE
* @brief The type of orientation.
MEDIA_CONTENT_GROUP_LONGITUDE,
MEDIA_CONTENT_GROUP_LATITUDE,
MEDIA_CONTENT_GROUP_ALTITUDE,
+ MEDIA_CONTENT_GROUP_BURST_IMAGE,
MEDIA_CONTENT_GROUP_RATING,
MEDIA_CONTENT_GROUP_AUTHOR,
MEDIA_CONTENT_GROUP_PROVIDER,
*/
typedef void (*media_scan_completed_cb)(media_content_error_e error, void * user_data);
+/**
+ * @ingroup CAPI_MEDIA_CONTENT_MODULE
+ * @brief Called when notification of media db change is subscribed.
+ *
+ * @param[in] error The error code
+ * @param[in] pid pid which publish notification
+ * @param[in] update_item Update item of notification
+ * @param[in] update_type Update type of notification
+ * @param[in] media_type The type of media content(#media_content_type_e)
+ * @param[in] uuid UUID of media or directory, which is updated
+ * @param[in] path The path of media or directory
+ * @param[in] mime_type The mime type of media info
+ * @param[in] user_data The user data passed from the foreach function
+ * @pre media_content_db_update_subscribe()
+ * @see media_content_db_update_subscribe()
+ *
+ */
+typedef void (*media_content_db_update_cb)(
+ media_content_error_e error,
+ int pid,
+ media_content_db_update_item_type_e update_item,
+ media_content_db_update_type_e update_type,
+ media_content_type_e media_type,
+ char *uuid,
+ char *path,
+ char *mime_type,
+ void *user_data);
+
/**
* @ingroup CAPI_CONTENT_MEDIA_INFO_MODULE
typedef void (*media_insert_completed_cb)(media_content_error_e error, void * user_data);
+/**
+ * @ingroup CAPI_CONTENT_MEDIA_INFO_MODULE
+ * @brief Called when burst shot is inserted completely.
+ *
+ * @param[in] media The handle to media info
+ * @param[in] user_data The user data passed from the foreach function
+ * @pre media_info_insert_burst_shot_to_db()
+ * @see media_info_insert_burst_shot_to_db()
+ *
+ */
+typedef void (*media_insert_burst_shot_completed_cb)(media_content_error_e error, void * user_data);
+
/**
* @ingroup CAPI_CONTENT_MEDIA_INFO_MODULE
#define MEDIA_HEIGHT "MEDIA_HEIGHT" /**< media height*/
#define MEDIA_DATETAKEN "MEDIA_DATETAKEN" /**< media datetaken*/
#define MEDIA_ORIENTATION "MEDIA_ORIENTATION" /**< media orientation*/
+#define MEDIA_BURST_ID "BURST_ID" /**< media burst id*/
#define MEDIA_PLAYED_COUNT "MEDIA_PLAYED_COUNT" /**< media playedcount*/
#define MEDIA_LAST_PLAYED_TIME "MEDIA_LAST_PLAYED_TIME" /**< media last played time*/
#define MEDIA_LAST_PLAYED_POSITION "MEDIA_LAST_PLAYED_POSITION" /**< media last played position of file*/
#define MEDIA_KEYWORD "MEDIA_KEYWORD" /**< media keyword*/
#define MEDIA_IS_DRM "MEDIA_IS_DRM" /**< is drm. 0-not drm, 1-drm*/
#define MEDIA_STORAGE_TYPE "MEDIA_STORAGE_TYPE" /**< media storage. 0-internal storage, 1-external storage*/
+
/**
* @}
*/
*/
int image_meta_get_date_taken(image_meta_h image, char **date_taken);
+/**
+ * @brief Gets the burst shot id.
+ *
+ * @remarks @a burst id must be released with free() by you.
+ *
+ * @param[in] media The handle toimage metadata
+ * @param[out] burst_id The id of burst shot. if burst_id is NULL, this is not burst shot.
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #MEDIA_CONTENT_ERROR_NONE Successful
+ * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
+ *
+ */
+int image_meta_get_burst_id(image_meta_h image, char **burst_id);
+
+/**
+ * @brief Checks whether the media is burst shot image.
+ *
+ * @param[in] media The handle to image metadata
+ * @param[out] is_burst_shot /@a true if the burst shot image,
+ * /@a false if not burst shot image.
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #MEDIA_CONTENT_ERROR_NONE Successful
+ * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
+ *
+ */
+int image_meta_is_burst_shot(image_meta_h image, bool *is_burst_shot);
+
/**
* @brief Sets the image orientation.
*
*/
int media_info_insert_batch_to_db(const char **path_array,unsigned int array_length, media_insert_completed_cb callback, void *user_data);
+/**
+ * @brief Insert the burst shot images into the media database, asynchronously.
+ * @details This function insert the busrt images into the content storage.
+ * #media_insert_burst_shot_completed_cb will be called when insertion to media database is finished.
+ *
+ * @param[in] path_array The path array to the burst shot images
+ * @param[in] array_length The length of array
+ * @param[in] callback The callback to invoke when the images inserted completely
+ * @param[in] user_data The user data to be passed to the callback function
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #MEDIA_CONTENT_ERROR_NONE Successful
+ * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #MEDIA_CONTENT_ERROR_DB_FAILED DB operation failed
+ * @pre This function requires opened connection to content service by media_content_connect().
+ * @see media_content_connect()
+ * @see media_insert_burst_shot_completed_cb()
+ */
+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);
/**
* @brief Deletes media file from the media database.
* @brief Gets added time.
*
* @param[in] media The handle to media info
- * @param[out] added_time The added time
+ * @param[out] added_time The added time to DB
* @return 0 on success, otherwise a negative error value.
* @retval #MEDIA_CONTENT_ERROR_NONE Successful
* @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
* @brief Gets media info's date of modification.
*
* @param[in] media The handle to media info
- * @param[out] time The date of modification
+ * @param[out] time The date of modification of File. Get from File
* @return 0 on success, otherwise a negative error value.
* @retval #MEDIA_CONTENT_ERROR_NONE Successful
* @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
* @param[in] user_data The user data to be passed to the callback function
* @return 0 on success, otherwise a negative error value.
* @retval #MEDIA_CONTENT_ERROR_NONE Successful
- * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter ( Especially, if the request is duplicated, this error returns. )
* @retval #MEDIA_CONTENT_ERROR_DB_FAILED DB operation failed
* @pre This function requires opened connection to content service by media_content_connect().
* @see media_content_connect()
MEDIA_PLAYLIST_ADD,
MEDIA_PLAYLIST_REMOVE,
MEDIA_PLAYLIST_UPDATE_PLAYLIST_NAME,
+ MEDIA_PLAYLIST_UPDATE_THUMBNAIL_PATH,
MEDIA_PLAYLIST_UPDATE_PLAY_ORDER,
} playlist_function_e;
MEDIA_GROUP_BOOKMARK_BY_MEDIA_ID,
} group_list_e;
+typedef enum {
+ MEDIA_BATCH_INSERT_NORMAL,
+ MEDIA_BATCH_INSERT_BURSTSHOT,
+} media_batch_insert_e;
+
typedef struct _filter_s
{
char *condition;
{
int playlist_id; //playlist id
char *name; // playlist name
+ char *thumbnail_path; //playlist thumbnail path
}media_playlist_s;
typedef struct
int width;
int height;
char *date_taken;
+ char *burst_id;
media_content_orientation_e orientation;
}image_meta_s;
char *media_id; // media_uuid
int function; // Add, remove, modify
char *playlist_name; // playlist_name
+ char *thumbnail_path; //playlist thumbnail path
int playlist_member_id; // playlist unique id of media. Same content which has same media_id can be added to Playlist
int play_order; //play_order
}media_playlist_item_s;
void *user_data;
} media_insert_cb_s;
+typedef struct
+{
+ media_content_db_update_cb update_noti_cb;
+ void *user_data;
+} media_noti_cb_s;
+
typedef struct attribute_s *attribute_h;
#define DB_FIELD_MEDIA_HEIGHT "height"
#define DB_FIELD_MEDIA_DATETAKEN "datetaken"
#define DB_FIELD_MEDIA_ORIENTATION "orientation"
+#define DB_FIELD_MEDIA_BURST_ID "burst_id"
#define DB_FIELD_MEDIA_PLAYED_COUNT "played_count"
#define DB_FIELD_MEDIA_LAST_PLAYED_TIME "last_played_time"
#define DB_FIELD_MEDIA_LAST_PLAYED_POSITION "last_played_position"
//#define SELECT_TAG_LIST SELECT_EMPTY_TAG" UNION "SELECT_TAG_FROM_TAG_TAGMAP_MEDIA_JOIN
//#define SELECT_PLAYLIST_LIST SELECT_EMPTY_PLAYLIST" UNION "SELECT_PLAYLIST_FROM_PLAYLIST_PLAYLISTMAP_MEDIA_JOIN
#define SELECT_TAG_LIST "SELECT DISTINCT tag_id, name FROM "DB_VIEW_TAG" WHERE 1 "
-#define SELECT_PLAYLIST_LIST "SELECT DISTINCT playlist_id, name FROM "DB_VIEW_PLAYLIST" WHERE 1 "
+#define SELECT_PLAYLIST_LIST "SELECT DISTINCT playlist_id, name, thumbnail_path FROM "DB_VIEW_PLAYLIST" WHERE 1 "
#define SELECT_BOOKMARK_LIST "SELECT DISTINCT b.bookmark_id, b.media_uuid, b.marked_time, b.thumbnail_path FROM "BOOKMARK_MEDIA_JOIN
/* Get Group Count */
/* Get Media Count of Group */
#define SELECT_MEDIA_COUNT_FROM_MEDIA "SELECT COUNT(*) FROM ("SELECT_MEDIA_ITEM //to apply limit condition. "SELECT COUNT(*) FROM "DB_TABLE_MEDIA" WHERE validity=1"
+#define SELECT_MEDIA_COUNT_FROM_MEDIA_SIMPLE "SELECT COUNT(*) FROM "DB_TABLE_MEDIA" WHERE validity=1 "
#define SELECT_MEDIA_COUNT_FROM_ALBUM "SELECT COUNT(*) FROM "DB_TABLE_MEDIA" WHERE validity=1 AND album_id='%d'"
#define SELECT_MEDIA_COUNT_FROM_ARTIST "SELECT COUNT(*) FROM "DB_TABLE_MEDIA" WHERE validity=1 AND artist='%q'"
#define SELECT_MEDIA_COUNT_FROM_GENRE "SELECT COUNT(*) FROM "DB_TABLE_MEDIA" WHERE validity=1 AND genre='%q'"
/* Playlist Info */
#define INSERT_PLAYLIST_TO_PLAYLIST "INSERT INTO "DB_TABLE_PLAYLIST" (name) VALUES (%Q)"
#define UPDATE_PLAYLIST_NAME_FROM_PLAYLIST "UPDATE "DB_TABLE_PLAYLIST" SET name='%q' WHERE playlist_id=%d"
+#define UPDATE_PLAYLIST_THUMBNAIL_FROM_PLAYLIST "UPDATE "DB_TABLE_PLAYLIST" SET thumbnail_path='%q' WHERE playlist_id=%d"
#define SELECT_PLAYLIST_ID_FROM_PLAYLIST "SELECT playlist_id FROM "DB_TABLE_PLAYLIST" WHERE name='%q'"
//#define SELECT_PLAYLIST_ITEM_ID_FROM_PLAYLIST_MAP "SELECT pm._id, pm.media_uuid FROM "PLAYLISTMAP_MEDIA_JOIN" AND pm.playlist_id=%d"
#define SELECT_PLAYLIST_ITEM_ID_FROM_PLAYLIST_VIEW "SELECT pm_id, media_uuid FROM "DB_VIEW_PLAYLIST" WHERE playlist_id=%d "
//#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, is_drm, storage_type"
#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"
+ 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, burst_id"
#define SELECT_MEDIA_ITEM "SELECT "MEDIA_INFO_ITEM" FROM "DB_TABLE_MEDIA" WHERE validity=1"
#define SELECT_MEDIA_FROM_MEDIA "SELECT "MEDIA_INFO_ITEM" FROM "DB_TABLE_MEDIA" WHERE validity=1 AND media_uuid='%s'"
#define SELECT_MEDIA_FROM_FOLDER "SELECT "MEDIA_INFO_ITEM" FROM "DB_TABLE_MEDIA" WHERE validity=1 AND folder_uuid='%q'"
#define SELECT_MEDIA_FROM_TAG "SELECT "MEDIA_INFO_ITEM" FROM "DB_TABLE_MEDIA" WHERE media_uuid IN (SELECT media_uuid FROM "DB_TABLE_TAG_MAP" WHERE tag_id=%d) AND validity=1"
#define SELECT_MEDIA_FROM_PLAYLIST "SELECT "MEDIA_INFO_ITEM" FROM "DB_TABLE_MEDIA" WHERE media_uuid IN (SELECT media_uuid FROM "DB_TABLE_PLAYLIST_MAP" WHERE playlist_id=%d) AND validity=1"
+#define SELECT_MEDIA_PATH_BY_ID "SELECT path FROM "DB_TABLE_MEDIA" WHERE media_uuid='%q'"
/* Delete */
#define DELETE_MEDIA_FROM_MEDIA "DELETE FROM "DB_TABLE_MEDIA" WHERE media_uuid='%q'"
* @retval #MEDIA_CONTENT_ERROR_NONE Successful
* @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
* @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #MEDIA_CONTENT_ERROR_INVALID_OPERATION Invalid Operation
+ * @retval #MEDIA_CONTENT_ERROR_DB_FAILED DB Operation failed
+ * @retval #MEDIA_CONTENT_ERROR_DB_BUSY DB Operation BUSY
+ * @retval #MEDIA_CONTENT_ERROR_NETWORK Network Fail
* @pre This function requires opened connection to content service by media_content_connect().
* @see media_content_connect()
* @see media_playlist_delete_from_db()
* @remarks @a playlist must be released with media_playlist_destroy() by you.
*
* @param[in] playlist_id The ID of media playlist
- * @param [in] filter The handle to audio filter
* @param[out] playlist The media playlist handle associated with the playlist ID
* @return 0 on success, otherwise a negative error value.
* @retval #MEDIA_CONTENT_ERROR_NONE Successful
* @see media_playlist_destroy()
*
*/
-int media_playlist_get_playlist_from_db(int playlist_id, filter_h filter, media_playlist_h *playlist);
+int media_playlist_get_playlist_from_db(int playlist_id, media_playlist_h *playlist);
/**
* @brief Destroys a playlist handle.
*/
int media_playlist_set_name(media_playlist_h playlist, const char *playlist_name);
+/**
+ * @brief Gets a thumbnail path of the playlist.
+ *
+ * @remarks @a path must be released with free() by you.
+ *
+ * @param [in] playlist The handle to media playlist
+ * @param [out] path The path of thumbnail
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #MEDIA_CONTENT_ERROR_NONE Successful
+ * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory
+ *
+ */
+int media_playlist_get_thumbnail_path(media_playlist_h playlist, char **path);
+
+/**
+ * @brief Sets the thumbnail path of the playlist.
+ *
+ * @param[in] playlist The handle to media playlist
+ * @param[in] path The path of thumbnail
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #MEDIA_CONTENT_ERROR_NONE Successful
+ * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory
+ * @post media_playlist_update_to_db()
+ *
+ */
+int media_playlist_set_thumbnail_path(media_playlist_h playlist, const char *path);
+
+
/**
* @brief Sets the played order in the playlist.
*
Name: capi-content-media-content
Summary: A Media content library in SLP C API
-Version: 0.2.36
+Version: 0.2.52
Release: 0
Group: System/Libraries
License: Apache License, Version 2.0
static MediaSvcHandle *db_handle = NULL;
static int ref_count = 0;
+static __thread media_noti_cb_s *g_noti_info = NULL;
static int __media_content_create_attr_handle(void);
static int __media_content_create_alias_attr_handle(void);
ret = _media_filter_attribute_add(g_attr_handle, MEDIA_ORIENTATION, DB_FIELD_MEDIA_ORIENTATION);
media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
+ ret = _media_filter_attribute_add(g_attr_handle, MEDIA_BURST_ID, DB_FIELD_MEDIA_BURST_ID);
+ media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
+
ret = _media_filter_attribute_add(g_attr_handle, MEDIA_PLAYED_COUNT, DB_FIELD_MEDIA_PLAYED_COUNT);
media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
ret = _media_filter_attribute_add(g_alias_attr_handle, MEDIA_ORIENTATION, DB_TABLE_ALIAS_MEDIA"."DB_FIELD_MEDIA_ORIENTATION);
media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
+ ret = _media_filter_attribute_add(g_alias_attr_handle, MEDIA_BURST_ID, DB_TABLE_ALIAS_MEDIA"."DB_FIELD_MEDIA_BURST_ID);
+ media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
+
ret = _media_filter_attribute_add(g_alias_attr_handle, MEDIA_PLAYED_COUNT, DB_TABLE_ALIAS_MEDIA"."DB_FIELD_MEDIA_PLAYED_COUNT);
media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
} else if(type == MEDIA_THUMBNAIL_TYPE) {
if(content_error == MEDIA_THUMB_ERROR_NONE)
return MEDIA_CONTENT_ERROR_NONE;
- else if(content_error == MEDIA_THUMB_ERROR_INVALID_PARAMETER)
+ else if(content_error == MEDIA_THUMB_ERROR_INVALID_PARAMETER || content_error == MEDIA_THUMB_ERROR_DUPLICATED_REQUEST)
return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
else if(content_error == MEDIA_THUMB_ERROR_DB)
return MEDIA_CONTENT_ERROR_DB_FAILED;
return MEDIA_CONTENT_ERROR_DB_FAILED;
else if(content_error == MS_MEDIA_ERR_SCANNING_BUSY)
return MEDIA_CONTENT_ERROR_DB_BUSY;
+ else if(content_error == MS_MEDIA_ERR_ALLOCATE_MEMORY_FAIL)
+ return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
+ else if(content_error == MS_MEDIA_ERR_DBUS_GET || content_error == MS_MEDIA_ERR_DBUS_ADD_FILTER)
+ return MEDIA_CONTENT_ERROR_INVALID_OPERATION;
else if(content_error == MS_MEDIA_ERR_VCONF_GET_FAIL)
return MEDIA_CONTENT_ERROR_INVALID_OPERATION;
}
media_content_debug("Path : %s", path);
- if (g_file_test(path, G_FILE_TEST_EXISTS | G_FILE_TEST_IS_REGULAR)) {
- /* This means this path has to be inserted or refreshed */
- media_content_debug("This path exists in file system.");
-
- media_svc_media_type_e media_type;
- media_svc_storage_type_e storage_type;
- char mime_type[255];
-
- 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);
- return _content_error_capi(MEDIA_CONTENT_TYPE, ret);
- }
+ if (g_file_test(path, G_FILE_TEST_EXISTS)) {
+ if (g_file_test(path, G_FILE_TEST_IS_REGULAR)) {
+ /* This means this path has to be inserted or refreshed */
+ media_content_debug("This path exists in file system.");
- ret = media_svc_get_mime_type(path, mime_type);
- if (ret < 0) {
- media_content_error("media_svc_get_mime_type failed : %d (%s)", ret, path);
- return _content_error_capi(MEDIA_CONTENT_TYPE, ret);
- }
+ media_svc_media_type_e media_type;
+ media_svc_storage_type_e storage_type;
+ char mime_type[255];
- ret = media_svc_get_media_type(path, mime_type, &media_type);
- if (ret < 0) {
- media_content_error("media_svc_get_media_type failed : %d (%s)", ret, path);
- return _content_error_capi(MEDIA_CONTENT_TYPE, ret);
- }
+ 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);
+ return _content_error_capi(MEDIA_CONTENT_TYPE, ret);
+ }
- ret = media_svc_check_item_exist_by_path(_content_get_db_handle(), path);
- if (ret == MEDIA_INFO_ERROR_NONE) {
- /* Refresh */
- ret = media_svc_refresh_item(_content_get_db_handle(), storage_type, path, media_type);
+ ret = media_svc_get_mime_type(path, mime_type);
if (ret < 0) {
- media_content_error("media_svc_refresh_item failed : %d", ret);
+ media_content_error("media_svc_get_mime_type failed : %d (%s)", ret, path);
return _content_error_capi(MEDIA_CONTENT_TYPE, ret);
}
- } else if (ret == MEDIA_INFO_ERROR_DATABASE_NO_RECORD) {
- /* Insert */
- ret = media_svc_insert_item_immediately(_content_get_db_handle(), storage_type, path, mime_type, media_type);
+ ret = media_svc_get_media_type(path, mime_type, &media_type);
if (ret < 0) {
- media_content_error("media_svc_insert_item_immediately failed : %d", ret);
+ media_content_error("media_svc_get_media_type failed : %d (%s)", ret, path);
return _content_error_capi(MEDIA_CONTENT_TYPE, ret);
}
- } else {
- media_content_error("media_svc_check_item_exist_by_path failed : %d", ret);
- return _content_error_capi(MEDIA_CONTENT_TYPE, ret);
+ ret = media_svc_check_item_exist_by_path(_content_get_db_handle(), path);
+ if (ret == MEDIA_INFO_ERROR_NONE) {
+ /* Refresh */
+ ret = media_svc_refresh_item(_content_get_db_handle(), storage_type, path, media_type);
+ if (ret < 0) {
+ media_content_error("media_svc_refresh_item failed : %d", ret);
+ return _content_error_capi(MEDIA_CONTENT_TYPE, ret);
+ }
+
+ } else if (ret == MEDIA_INFO_ERROR_DATABASE_NO_RECORD) {
+ /* Insert */
+ ret = media_svc_insert_item_immediately(_content_get_db_handle(), storage_type, path, mime_type, media_type);
+ if (ret < 0) {
+ media_content_error("media_svc_insert_item_immediately failed : %d", ret);
+ return _content_error_capi(MEDIA_CONTENT_TYPE, ret);
+ }
+ } else {
+ media_content_error("media_svc_check_item_exist_by_path failed : %d", ret);
+ return _content_error_capi(MEDIA_CONTENT_TYPE, ret);
+ }
+ } else if (g_file_test(path, G_FILE_TEST_IS_DIR)) {
+ /* Dierectory is not accpted in this function */
+ media_content_error("This path is directory");
+ return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
}
- } else if(g_file_test(path, G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR)) {
- /* Dierectory is not accpted in this function */
- media_content_error("This path is directory");
- return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
} else {
/* This means this path has to be deleted */
media_content_debug("This path doesn't exists in file system... So now start to delete it from DB");
return;
}
-int media_content_scan_folder(const char *path, media_scan_completed_cb callback, void *user_data)
+int media_content_scan_folder(const char *path, bool is_recursive, media_scan_completed_cb callback, void *user_data)
{
int ret = MEDIA_CONTENT_ERROR_NONE;
cb_data->callback = callback;
cb_data->user_data = user_data;
- ret = media_directory_scanning_async(path, TRUE, _media_content_scan_cb, cb_data);
+ ret = media_directory_scanning_async(path, is_recursive, _media_content_scan_cb, cb_data);
if (ret < 0) {
media_content_error("media_directory_scanning_async failed : %d", ret);
}
return _content_error_capi(MEDIA_REGISTER_TYPE, ret);
}
+
+void _media_content_db_update_noti_cb(
+ int pid,
+ media_item_type_e item,
+ media_item_update_type_e update_type,
+ char* path,
+ char* uuid,
+ media_type_e content_type,
+ char *mime_type,
+ void *user_data)
+{
+ int error_value = MEDIA_CONTENT_ERROR_NONE;
+
+ media_noti_cb_s *_noti_info = (media_noti_cb_s *)user_data;
+
+ if(_noti_info != NULL)
+ {
+ if (_noti_info->update_noti_cb)
+ _noti_info->update_noti_cb(error_value, pid, item, update_type, content_type, uuid, path, mime_type, _noti_info->user_data);
+ }
+
+ return;
+}
+
+int media_content_set_db_updated_cb(media_content_db_update_cb callback, void *user_data)
+{
+ int ret = MEDIA_CONTENT_ERROR_NONE;
+
+ g_noti_info = (media_noti_cb_s*)calloc(1, sizeof(media_noti_cb_s));
+ if (g_noti_info == NULL) {
+ media_content_error("Failed to create noti info");
+ return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
+ }
+
+ g_noti_info->update_noti_cb = callback;
+ g_noti_info->user_data = user_data;
+
+ ret = media_db_update_subscribe(_media_content_db_update_noti_cb, (void *)g_noti_info);
+
+ return _content_error_capi(MEDIA_REGISTER_TYPE, ret);
+}
+
+int media_content_unset_db_updated_cb()
+{
+ int ret = MEDIA_CONTENT_ERROR_NONE;
+
+ SAFE_FREE(g_noti_info);
+ ret = media_db_update_unsubscribe();
+
+ return _content_error_capi(MEDIA_REGISTER_TYPE, ret);
+}
+
return DB_FIELD_MEDIA_LATITUDE;
case MEDIA_CONTENT_GROUP_ALTITUDE:
return DB_FIELD_MEDIA_ALTITUDE;
+ case MEDIA_CONTENT_GROUP_BURST_IMAGE:
+ return DB_FIELD_MEDIA_BURST_ID;
case MEDIA_CONTENT_GROUP_RATING:
return DB_FIELD_MEDIA_RATING;
case MEDIA_CONTENT_GROUP_AUTHOR:
if(STRING_VALID((const char *)sqlite3_column_text(stmt, 1)))
_playlist->name = strdup((const char *)sqlite3_column_text(stmt, 1));
+ if(STRING_VALID((const char *)sqlite3_column_text(stmt, 2)))
+ _playlist->thumbnail_path = strdup((const char *)sqlite3_column_text(stmt, 2));
+
if(callback((media_playlist_h)_playlist, user_data) == false)
{
media_playlist_destroy((media_playlist_h)_playlist);
char *select_query = NULL;
char *condition_query = NULL;
char *option_query = NULL;
+ bool is_simple = FALSE;
media_content_debug_func();
if(group_type == MEDIA_GROUP_NONE)
{
- select_query = sqlite3_mprintf(SELECT_MEDIA_COUNT_FROM_MEDIA);
+ /* There are 2 ways to get count for media table for performance
+ If user wants to set offset and count, use SQL SELECT_MEDIA_COUNT_FROM_MEDIA.
+ If user wants to get count without setting count, SELECT_MEDIA_COUNT_FROM_MEDIA_SIMPLE */
+ _filter = (filter_s *)filter;
+ if (_filter) {
+ if ((_filter->offset < 0) && (_filter->count < 0)) {
+ select_query = sqlite3_mprintf(SELECT_MEDIA_COUNT_FROM_MEDIA_SIMPLE);
+ is_simple = TRUE;
+ } else {
+ select_query = sqlite3_mprintf(SELECT_MEDIA_COUNT_FROM_MEDIA);
+ }
+ } else {
+ select_query = sqlite3_mprintf(SELECT_MEDIA_COUNT_FROM_MEDIA);
+ }
}
else if(group_type == MEDIA_GROUP_FOLDER)
{
if(STRING_VALID(option_query))
SAFE_STRLCAT(complete_select_query, option_query, sizeof(complete_select_query));
- SAFE_STRLCAT(complete_select_query, QUERY_KEYWORD_BRACKET, sizeof(complete_select_query));
+ if (!is_simple)
+ SAFE_STRLCAT(complete_select_query, QUERY_KEYWORD_BRACKET, sizeof(complete_select_query));
SAFE_FREE(condition_query);
SAFE_FREE(option_query);
static char *__media_filter_replace_attr(attribute_h attr, char *name)
{
- char *key_temp;
- char *generated_value;
+ char *key_temp = NULL;
+ char *generated_value = NULL;
attribute_s *_attr = (attribute_s *)attr;
if(!g_hash_table_lookup_extended(_attr->attr_map,
{
if(tmp[j] == media_token[1][0] && tmp[j+1] == media_token[1][0])
{
- j += 2;
+ j += 1;
continue;
}
if(tmp[j] == media_token[1][0])
{
if(tmp[j] == media_token[2][0] && tmp[j+1] == media_token[2][0])
{
- j += 2;
+ j += 1;
continue;
}
if(tmp[j] == media_token[2][0])
{
SAFE_FREE(_image->media_id);
SAFE_FREE(_image->date_taken);
+ SAFE_FREE(_image->burst_id);
SAFE_FREE(_image);
ret = MEDIA_CONTENT_ERROR_NONE;
image_meta_destroy((image_meta_h)_dst);
return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
}
- _dst->media_id = strdup(_src->media_id);
}
if(STRING_VALID(_src->date_taken))
image_meta_destroy((image_meta_h)_dst);
return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
}
- _dst->date_taken = strdup(_src->date_taken);
+ }
+
+ if(STRING_VALID(_src->burst_id))
+ {
+ _dst->burst_id = strdup(_src->burst_id);
+ if(_dst->burst_id == NULL)
+ {
+ media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
+ image_meta_destroy((image_meta_h)_dst);
+ return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
+ }
}
_dst->width = _src->width;
int ret = MEDIA_CONTENT_ERROR_NONE;
image_meta_s *_image = (image_meta_s*)image;
- if(_image)
+ if(_image && media_id)
{
if(STRING_VALID(_image->media_id))
{
{
int ret = MEDIA_CONTENT_ERROR_NONE;
image_meta_s *_image = (image_meta_s*)image;
- if(_image)
+
+ if(_image && orientation)
{
*orientation = _image->orientation;
ret = MEDIA_CONTENT_ERROR_NONE;
int ret = MEDIA_CONTENT_ERROR_NONE;
image_meta_s *_image = (image_meta_s*)image;
- if(_image)
+ if(_image && date_taken)
{
if(STRING_VALID(_image->date_taken))
{
return ret;
}
+int image_meta_get_burst_id(image_meta_h image, char **burst_id)
+{
+ int ret = MEDIA_CONTENT_ERROR_NONE;
+ image_meta_s *_image = (image_meta_s*)image;
+
+ if(_image && burst_id)
+ {
+ if(STRING_VALID(_image->burst_id))
+ {
+ *burst_id = strdup(_image->burst_id);
+ if(*burst_id == NULL)
+ {
+ media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
+ return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
+ }
+ }
+ else
+ {
+ *burst_id = NULL;
+ }
+ ret = MEDIA_CONTENT_ERROR_NONE;
+ }
+ else
+ {
+ media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+ ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+ }
+
+ return ret;
+}
+
+int image_meta_is_burst_shot(image_meta_h image, bool *is_burst_shot)
+{
+ int ret = MEDIA_CONTENT_ERROR_NONE;
+ image_meta_s *_image = (image_meta_s*)image;
+
+ if(_image && is_burst_shot)
+ {
+ if(STRING_VALID(_image->burst_id))
+ *is_burst_shot = true;
+ else
+ *is_burst_shot = false;
+
+ 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 image_meta_set_orientation(image_meta_h image, media_content_orientation_e orientation)
{
int ret = MEDIA_CONTENT_ERROR_NONE;
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 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)
{
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;
+ 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;
+ }
+
+ select_query = sqlite3_mprintf(SELECT_MEDIA_PATH_BY_ID, media_id);
+
+ 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)
+ {
+ if(STRING_VALID((const char *)sqlite3_column_text(stmt, 0)))
+ *path = strdup((const char *)sqlite3_column_text(stmt, 0));
+ } else {
+ media_content_debug("There's no media with this ID : %s", media_id);
+ *path = NULL;
+ ret = MEDIA_CONTENT_ERROR_DB_FAILED;
+ }
+
+ SQLITE3_FINALIZE(stmt);
+
+ return ret;
+}
+
static void __media_info_insert_completed_cb(media_request_result_s *result, void *user_data)
{
int ret = MEDIA_CONTENT_ERROR_NONE;
_media->image_meta->date_taken = strdup((const char *)sqlite3_column_text(stmt, 26));
_media->image_meta->orientation = sqlite3_column_int(stmt, 27);
+
+ if(STRING_VALID((const char *)sqlite3_column_text(stmt, 44)))
+ _media->image_meta->burst_id = strdup((const char *)sqlite3_column_text(stmt, 44));
}
} else if(_media->media_type == MEDIA_CONTENT_TYPE_VIDEO) {
return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
}
+#if 0
media_content_debug("Register: %s", path);
ret = media_file_register(path);
if(ret != MS_MEDIA_ERR_NONE)
return _content_error_capi(MEDIA_REGISTER_TYPE, ret);
}
+#else
+ ret = media_svc_check_item_exist_by_path(_content_get_db_handle(), path);
+ if (ret == MEDIA_INFO_ERROR_DATABASE_NO_RECORD) {
+ media_content_debug("media_svc_check_item_exist_by_path : no record : %s", path);
+
+ media_svc_media_type_e media_type;
+ media_svc_storage_type_e storage_type;
+ char mime_type[255] = {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);
+ return _content_error_capi(MEDIA_CONTENT_TYPE, ret);
+ }
+
+ ret = media_svc_get_mime_type(path, mime_type);
+ if (ret < 0) {
+ media_content_error("media_svc_get_mime_type failed : %d (%s)", ret, path);
+ return _content_error_capi(MEDIA_CONTENT_TYPE, ret);
+ }
+
+ ret = media_svc_get_media_type(path, mime_type, &media_type);
+ if (ret < 0) {
+ media_content_error("media_svc_get_media_type failed : %d (%s)", ret, path);
+ 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, mime_type, media_type);
+
+ if (ret < 0) {
+ media_content_error("media_svc_insert_item_immediately failed : %d (%s)", ret, path);
+ return _content_error_capi(MEDIA_CONTENT_TYPE, ret);
+ }
+ } else if (ret != MEDIA_INFO_ERROR_NONE) {
+ media_content_error("media_svc_check_item_exist_by_path failed : %d (%s)", ret, 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)
{
ret = __media_info_get_media_info_from_db(_media->file_path, (media_info_h)_media);
*info = (media_info_h)_media;
-
return ret;
}
-int media_info_insert_batch_to_db(
- const char **path_array,
+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;
-
- if (path_array == NULL)
- {
- 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;
- }
-
FILE *fp = NULL;
char list_path[255] = {0,};
- int i;
+ int idx = 0;
int nwrites = 0;
- for (i = 0; i < BATCH_REQUEST_MAX; i++) {
- snprintf(list_path, sizeof(list_path), "%s/request-%ld-%d", MEDIA_CONTENT_INSERT_FILES_PATH, media_content_gettid(), i);
+ 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);
if (g_file_test(list_path, G_FILE_TEST_EXISTS | G_FILE_TEST_IS_REGULAR)) {
memset(list_path, 0x00, sizeof(list_path));
}
}
- if (i == BATCH_REQUEST_MAX) {
+ if (idx == BATCH_REQUEST_MAX) {
media_content_error("Too many batch request for one thread");
return MEDIA_CONTENT_ERROR_DB_BUSY;
}
return MEDIA_CONTENT_ERROR_INVALID_OPERATION;
}
- for (i = 0; i < array_length; i++) {
- if (STRING_VALID(path_array[i])) {
- int size = strlen(path_array[i]);
+ for (idx = 0; idx < array_length; idx++) {
+ if (STRING_VALID(path_array[idx])) {
+ int size = strlen(path_array[idx]);
- nwrites = fwrite(path_array[i], 1, size, fp);
+ nwrites = fwrite(path_array[idx], 1, size, fp);
if (nwrites != size) {
media_content_error("failed to write thumbnail : %s", strerror(errno));
fclose(fp);
return MEDIA_CONTENT_ERROR_INVALID_OPERATION;
}
} else {
- media_content_error("path[%d] is invalid string", i);
+ media_content_error("path[%d] is invalid string", idx);
}
}
_cb_data->user_data = user_data;
_cb_data->insert_list_path = strdup(list_path);
- ret = media_files_register(list_path, __media_info_insert_completed_cb, _cb_data);
+ if(insert_type == MEDIA_BATCH_INSERT_NORMAL)
+ ret = media_files_register(list_path, __media_info_insert_completed_cb, _cb_data);
+ else if(insert_type == MEDIA_BATCH_INSERT_BURSTSHOT)
+ ret = media_burstshot_register(list_path, __media_info_insert_completed_cb, _cb_data);
+ else
+ ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
- if (ret < 0) {
+ 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);
}
-#if 0
- ret = media_svc_insert_item_begin(_content_get_db_handle(), array_length);
- if (ret < 0)
+ 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)
+{
+ if (path_array == NULL)
{
- media_content_error("media_svc_insert_item_begin failed : %d", ret);
- return _content_error_capi(MEDIA_CONTENT_TYPE, ret);
+ media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+ return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
}
- char *path = NULL;
- media_svc_media_type_e media_type;
- media_svc_storage_type_e storage_type;
- char mime_type[255];
-
- for (i = 0; i < array_length; i++) {
- memset(mime_type, 0x00, sizeof(mime_type));
- path = (char*)path_array[i];
-
- 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);
- continue;
- }
-
- ret = media_svc_get_mime_type(path, mime_type);
- if (ret < 0) {
- media_content_error("media_svc_get_mime_type failed : %d (%s)", ret, path);
- continue;
- }
+ if (array_length <= 0)
+ {
+ media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+ return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+ }
- ret = media_svc_get_media_type(path, mime_type, &media_type);
- if (ret < 0) {
- media_content_error("media_svc_get_media_type failed : %d (%s)", ret, path);
- continue;
- }
+ return __media_info_insert_batch(MEDIA_BATCH_INSERT_NORMAL, path_array, array_length, completed_cb, user_data);
+}
- ret = media_svc_insert_item_bulk(_content_get_db_handle(), storage_type, path, mime_type, media_type);
- if (ret < 0) {
- media_content_error("media_svc_insert_item_bulk failed : %d (%s)", ret, path);
- continue;
- }
+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)
+{
+ if (path_array == NULL)
+ {
+ media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+ return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
}
- ret = media_svc_insert_item_end(_content_get_db_handle());
- if (ret < 0)
+ if (array_length <= 0)
{
- media_content_error("media_svc_insert_item_end failed : %d", ret);
- return _content_error_capi(MEDIA_CONTENT_TYPE, ret);
+ media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+ return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
}
- if (completed_cb) {
- completed_cb(MEDIA_CONTENT_ERROR_NONE, user_data);
- }
-#endif
- return ret;
+ return __media_info_insert_batch(MEDIA_BATCH_INSERT_BURSTSHOT, path_array, array_length, callback, user_data);
}
int media_info_delete_from_db(const char *media_id)
{
int ret = MEDIA_CONTENT_ERROR_NONE;
- char *query_string = NULL;
-
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;
+
+ 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_svc_delete_item_by_path(_content_get_db_handle(), path);
+ SAFE_FREE(path);
+
+ return _content_error_capi(ret,MEDIA_CONTENT_TYPE);
+#endif
}
int media_info_delete_batch_from_db(filter_h filter)
}
ret = _content_query_sql(query_string);
+ if (ret == MEDIA_CONTENT_ERROR_NONE) {
+ /* 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);
+ }
SAFE_FREE(condition_query);
sqlite3_free(query_string);
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);
} else if(_media->video_meta) {
_dst->rating = _src->rating;
_dst->favourite = _src->favourite;
_dst->is_drm = _src->is_drm;
+ _dst->storage_type = _src->storage_type;
if(_src->media_type == MEDIA_CONTENT_TYPE_IMAGE && _src->image_meta) {
_dst->image_meta = (image_meta_s *)calloc(1, sizeof(image_meta_s));
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(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)
+ {
+ 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->width = _src->image_meta->width;
_dst->image_meta->height = _src->image_meta->height;
_dst->image_meta->orientation = _src->image_meta->orientation;
_image->date_taken = strdup(_media->image_meta->date_taken);
}
+ if(STRING_VALID(_media->image_meta->burst_id)) {
+ _image->burst_id = strdup(_media->image_meta->burst_id);
+ }
+
*image = (image_meta_h)_image;
return ret;
}
ret = _content_query_sql(sql);
+ if (ret == MEDIA_CONTENT_ERROR_NONE) {
+ /* Send notification for this update */
+ media_content_debug("Update is successfull. Send notification for this");
+ if (_media->file_path && _media->mime_type) {
+ media_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");
+ }
+ }
}
else
{
static int __media_playlist_insert_item_to_playlist(int playlist_id, const char *media_id);
static int __media_playlist_remove_item_from_playlist(int playlist_id, int playlist_member_id);
static int __media_playlist_update_playlist_name(int playlist_id, const char *playlist_name);
+static int __media_playlist_update_thumbnail_path(int playlist_id, const char *path);
static int __media_playlist_update_play_order(int playlist_id, int playlist_member_id, int play_order);
static void __media_playlist_item_add(media_playlist_item_s *item_s)
{
SAFE_FREE(item->media_id);
SAFE_FREE(item->playlist_name);
+ SAFE_FREE(item->thumbnail_path);
SAFE_FREE(item);
}
}
return ret;
}
+static int __media_playlist_update_thumbnail_path(int playlist_id, const char *path)
+{
+ int ret = MEDIA_CONTENT_ERROR_NONE;
+ char *query_str = NULL;
+
+ query_str = sqlite3_mprintf(UPDATE_PLAYLIST_THUMBNAIL_FROM_PLAYLIST, path, playlist_id);
+
+ ret = _content_query_sql(query_str);
+ sqlite3_free(query_str);
+
+ return ret;
+}
+
static int __media_playlist_update_play_order(int playlist_id, int playlist_member_id, int play_order)
{
int ret = MEDIA_CONTENT_ERROR_NONE;
return ret;
}
-int media_playlist_get_playlist_from_db(int playlist_id, filter_h filter, media_playlist_h *playlist)
+int media_playlist_get_playlist_from_db(int playlist_id, media_playlist_h *playlist)
{
int ret = MEDIA_CONTENT_ERROR_NONE;
sqlite3_stmt *stmt = NULL;
_playlist->playlist_id = (int)sqlite3_column_int(stmt, 0);
if(STRING_VALID((const char *)sqlite3_column_text(stmt, 1)))
_playlist->name = strdup((const char *)sqlite3_column_text(stmt, 1));
+ if(STRING_VALID((const char *)sqlite3_column_text(stmt, 2)))
+ _playlist->thumbnail_path = strdup((const char *)sqlite3_column_text(stmt, 2));
*playlist = (media_playlist_h)_playlist;
}
return ret;
}
+int media_playlist_get_thumbnail_path(media_playlist_h playlist, char **path)
+{
+ int ret = MEDIA_CONTENT_ERROR_NONE;
+ media_playlist_s *_playlist = (media_playlist_s*)playlist;
+ if(_playlist)
+ {
+ if(STRING_VALID(_playlist->thumbnail_path))
+ {
+ *path = strdup(_playlist->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
+ {
+ *path = NULL;
+ }
+
+ ret = MEDIA_CONTENT_ERROR_NONE;
+ }
+ else
+ {
+ media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+ ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+ }
+
+ return ret;
+}
+
int media_playlist_get_play_order(media_playlist_h playlist, int playlist_member_id, int *play_order)
{
int ret = MEDIA_CONTENT_ERROR_NONE;
return ret;
}
+int media_playlist_set_thumbnail_path(media_playlist_h playlist, const char *path)
+{
+ int ret = MEDIA_CONTENT_ERROR_NONE;
+ media_playlist_s *_playlist = (media_playlist_s*)playlist;
+
+ if(_playlist != NULL && STRING_VALID(path))
+ {
+ SAFE_FREE(_playlist->thumbnail_path);
+
+ media_playlist_item_s *item = (media_playlist_item_s*)calloc(1, sizeof(media_playlist_item_s));
+
+ item->thumbnail_path = strdup(path);
+ item->function = MEDIA_PLAYLIST_UPDATE_THUMBNAIL_PATH;
+ if(item->thumbnail_path == NULL)
+ {
+ SAFE_FREE(item);
+ media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
+ return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
+ }
+
+ _playlist->thumbnail_path = strdup(path);
+ if(_playlist->thumbnail_path == NULL)
+ {
+ SAFE_FREE(item->thumbnail_path);
+ SAFE_FREE(item);
+ media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
+ return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
+ }
+
+ __media_playlist_item_add(item);
+ }
+ else
+ {
+ media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+ ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+ }
+
+ return ret;
+}
+
int media_playlist_set_play_order(media_playlist_h playlist, int playlist_member_id, int play_order)
{
int ret = MEDIA_CONTENT_ERROR_NONE;
}
break;
+ case MEDIA_PLAYLIST_UPDATE_THUMBNAIL_PATH:
+ {
+ ret = __media_playlist_update_thumbnail_path(_playlist->playlist_id, _playlist_item->thumbnail_path);
+ }
+ break;
+
case MEDIA_PLAYLIST_UPDATE_PLAY_ORDER:
{
ret = __media_playlist_update_play_order(_playlist->playlist_id, _playlist_item->playlist_member_id, _playlist_item->play_order);
{
image_meta_h image;
media_content_orientation_e orientation = 0;
+ bool is_burst_shot = false;
+ char *burst_id = NULL;
if(media_info_get_image(media, &image) == MEDIA_CONTENT_ERROR_NONE)
{
else
media_content_debug("[image] orientation : %d", orientation);
+ ret = image_meta_is_burst_shot(image, &is_burst_shot);
+ if(ret != MEDIA_CONTENT_ERROR_NONE)
+ media_content_error("error image_meta_is_burst_shot : [%d]", ret);
+ if(is_burst_shot)
+ {
+ ret = image_meta_get_burst_id(image, &burst_id);
+ if(ret != MEDIA_CONTENT_ERROR_NONE)
+ media_content_error("error image_meta_get_burst_id : [%d]", ret);
+ else
+ media_content_debug("[image] burst_id : [%s]", burst_id);
+
+ SAFE_FREE(burst_id);
+ }
+
ret = image_meta_destroy(image);
if(ret != MEDIA_CONTENT_ERROR_NONE)
media_content_error("error image_meta_destroy : [%d]", ret);
int playlist_id = 0;
char *playlist_name = NULL;
media_playlist_h playlist_h;
+ char *playlist_thumbnail_path = NULL;
media_content_debug("playlist_list_cb ======");
media_content_debug("playlist_name : %s", playlist_name);
SAFE_FREE(playlist_name);
- media_playlist_get_playlist_from_db(playlist_id, NULL, &playlist_h);
+ media_playlist_get_thumbnail_path(playlist, &playlist_thumbnail_path);
+ media_content_debug("playlist_thumbnail_path : %s", playlist_thumbnail_path);
+ SAFE_FREE(playlist_thumbnail_path);
+
+ media_playlist_get_playlist_from_db(playlist_id, &playlist_h);
media_playlist_destroy(playlist_h);
int width = 0, height = 0;
media_content_orientation_e orientation = 0;
char *datetaken = NULL;
+ char *burst_id = NULL;
ret = media_info_get_image(media_handle, &image_handle);
if(ret != MEDIA_CONTENT_ERROR_NONE) {
ret = image_meta_get_date_taken(image_handle, &datetaken);
if(ret != MEDIA_CONTENT_ERROR_NONE)
media_content_error("error image_meta_get_date_taken : [%d]", ret);
+ ret = image_meta_get_burst_id(image_handle, &burst_id);
+ if(ret != MEDIA_CONTENT_ERROR_NONE)
+ media_content_error("error image_meta_get_burst_id : [%d]", ret);
media_content_debug("This is Image");
media_content_debug("Width : %d, Height : %d, Orientation : %d, Date taken : %s", width, height, orientation, datetaken);
}
SAFE_FREE(datetaken);
+ SAFE_FREE(burst_id);
ret = image_meta_destroy(image_handle);
if(ret != MEDIA_CONTENT_ERROR_NONE)
media_content_error("error image_meta_destroy : [%d]", ret);
media_playlist_add_media(playlist_1, test_audio_id);
media_playlist_add_media(playlist_1, test_audio_id);
media_playlist_add_media(playlist_1, test_video_id);
+
+ #if 0
+ char *playlist_thumb_path = "/opt/usr/media/Images/Default.jpg";
+ media_playlist_set_thumbnail_path(playlist_1, playlist_thumb_path);
+ #endif
+
media_playlist_update_to_db(playlist_1);
}
printf("Voice Memo size = [%d]\n", g_total_voice_memo_size);
ret = media_filter_destroy(filter);
- return 0;
+ return ret;
}
void insert_batch_cb(media_content_error_e error, void * user_data)
return ret;
}
+void insert_burst_shot_cb(media_content_error_e error, void * user_data)
+{
+ printf("media_info_insert_burst_shot_to_db completed![%d]\n", error);
+ g_main_loop_quit(g_loop);
+}
+
+gboolean test_insert_burst_shot_to_db_start(gpointer data)
+{
+ int ret = MEDIA_CONTENT_ERROR_NONE;
+ int i = 0;
+ char *file_list[10];
+
+ for (i = 0; i < 10; i++) {
+ char filepath[255] = {0,};
+ snprintf(filepath, sizeof(filepath), "%s%d.jpg", "/opt/usr/media/test/image", i+1);
+ media_content_debug("File : %s\n", filepath);
+ file_list[i] = strdup(filepath);
+ }
+
+ ret = media_info_insert_burst_shot_to_db((const char **)file_list, 10, insert_burst_shot_cb, NULL);
+ if(ret != MEDIA_CONTENT_ERROR_NONE) {
+ media_content_error("media_info_insert_burst_shot_to_db failed : %d\n", ret);
+ }
+
+ return ret;
+}
+
+int test_insert_burst_shot_to_db(void)
+{
+ GSource *source = NULL;
+ GMainContext *context = NULL;
+
+ g_loop = g_main_loop_new(NULL, FALSE);
+ context = g_main_loop_get_context(g_loop);
+ source = g_idle_source_new();
+ g_source_set_callback (source, test_insert_burst_shot_to_db_start, NULL, NULL);
+ g_source_attach (source, context);
+
+ g_main_loop_run(g_loop);
+ g_main_loop_unref(g_loop);
+
+ return 0;
+}
+
void _scan_cb(media_content_error_e err, void *user_data)
{
printf("scan callback is called : %d\n", err);
const char *dir_path = "/opt/usr/media";
- ret = media_content_scan_folder(dir_path, _scan_cb, NULL);
+ ret = media_content_scan_folder(dir_path, TRUE, _scan_cb, NULL);
if(ret != MEDIA_CONTENT_ERROR_NONE) {
media_content_error("Fail to media_content_scan_file : %d", ret);
return 0;
}
+void _noti_cb(media_content_error_e error,
+ int pid,
+ media_content_db_update_item_type_e update_item,
+ media_content_db_update_type_e update_type,
+ media_content_type_e media_type,
+ char *uuid,
+ char *path,
+ char *mime_type,
+ void *user_data)
+{
+ if (error == 0) {
+ printf("noti success! : %d\n", error);
+ } else {
+ printf("error occured! : %d\n", error);
+ }
+
+ printf("Noti from PID(%d)\n", pid);
+
+ if (update_item == MEDIA_ITEM_FILE) {
+ printf("Noti item : MEDIA_ITEM_FILE\n");
+ } else if (update_item == MEDIA_ITEM_DIRECTORY) {
+ printf("Noti item : MEDIA_ITEM_DIRECTORY\n");
+ }
+
+ if (update_type == MEDIA_CONTENT_INSERT) {
+ printf("Noti type : MEDIA_CONTENT_INSERT\n");
+ } else if (update_type == MEDIA_CONTENT_DELETE) {
+ printf("Noti type : MEDIA_CONTENT_DELETE\n");
+ } else if (update_type == MEDIA_CONTENT_UPDATE) {
+ printf("Noti type : MEDIA_CONTENT_UPDATE\n");
+ }
+
+ printf("content type : %d\n", media_type);
+
+ if (path)
+ printf("path : %s\n", path);
+ else
+ printf("path not\n");
+
+ if (uuid)
+ printf("uuid : %s\n", uuid);
+ else
+ printf("uuid not\n");
+
+ if (mime_type)
+ printf("mime_type : %s\n", mime_type);
+ else
+ printf("mime not\n");
+
+ if (user_data) printf("String : %s\n", (char *)user_data);
+
+ //g_main_loop_quit(g_loop);
+ return;
+}
+
+gboolean _send_noti_operations(gpointer data)
+{
+ int ret = MEDIA_CONTENT_ERROR_NONE;
+
+ /* First of all, noti subscription */
+ char *user_str = strdup("hi");
+ media_content_set_db_updated_cb(_noti_cb, (void*)user_str);
+
+ /* media_info_insert_to_db */
+ media_info_h media_item = NULL;
+ char *path = "/opt/usr/media/test/image1.jpg";
+
+ ret = media_info_insert_to_db(path, &media_item);
+ if (ret < MEDIA_CONTENT_ERROR_NONE) {
+ media_content_error("media_info_insert_to_db failed : %d", ret);
+ return FALSE;
+ }
+
+ media_content_debug("media_info_insert_to_db success");
+
+ /* media_info_delete_batch_from_db */
+ filter_h filter;
+ char *condition = "MEDIA_PATH LIKE \'/opt/usr/media/test/image%%jpg\'";
+
+ ret = media_filter_create(&filter);
+ if(ret != MEDIA_CONTENT_ERROR_NONE) {
+ media_content_error("Fail to create filter");
+ return ret;
+ }
+
+ ret = media_filter_set_condition(filter, condition, MEDIA_CONTENT_COLLATE_DEFAULT);
+ if(ret != MEDIA_CONTENT_ERROR_NONE) {
+ media_filter_destroy(filter);
+ media_content_error("Fail to set condition");
+ return ret;
+ }
+ ret = media_info_delete_batch_from_db(filter);
+ if(ret != MEDIA_CONTENT_ERROR_NONE) {
+ media_filter_destroy(filter);
+ media_content_error("media_info_delete_batch_from_db failed : %d\n", ret);
+ return ret;
+ }
+
+ media_filter_destroy(filter);
+
+ /* media_info_update_to_db */
+ ret = media_info_update_to_db(media_item);
+ if(ret != MEDIA_CONTENT_ERROR_NONE) {
+ media_content_error("media_info_update_to_db failed : %d\n", ret);
+ return ret;
+ }
+
+ return FALSE;
+}
+
+int test_noti()
+{
+ int ret = MEDIA_CONTENT_ERROR_NONE;
+ GSource *source = NULL;
+ GMainContext *context = NULL;
+
+ g_loop = g_main_loop_new(NULL, FALSE);
+ context = g_main_loop_get_context(g_loop);
+ source = g_idle_source_new();
+ g_source_set_callback (source, _send_noti_operations, NULL, NULL);
+ g_source_attach (source, context);
+
+ g_main_loop_run(g_loop);
+ g_main_loop_unref(g_loop);
+
+ test_filter_destroy();
+ media_content_unset_db_updated_cb();
+
+ return ret;
+}
+
int main(int argc, char *argv[])
{
int ret = MEDIA_CONTENT_ERROR_NONE;
if(ret != MEDIA_CONTENT_ERROR_NONE)
return MEDIA_CONTENT_ERROR_NONE;
+ ret = test_insert_burst_shot_to_db();
+ if(ret != MEDIA_CONTENT_ERROR_NONE)
+ return MEDIA_CONTENT_ERROR_NONE;
+
ret = test_scan_file();
if(ret != MEDIA_CONTENT_ERROR_NONE)
return MEDIA_CONTENT_ERROR_NONE;
ret = test_scan_dir();
if(ret != MEDIA_CONTENT_ERROR_NONE)
return MEDIA_CONTENT_ERROR_NONE;
+
+ ret = test_noti();
+ if(ret != MEDIA_CONTENT_ERROR_NONE)
+ return MEDIA_CONTENT_ERROR_NONE;
#endif
ret = test_disconnect_database();