#include <media_info_private.h>
#define MAX_SIZE 16
-
+// LCOV_EXCL_START
static int __media_face_check_media_id(const char *media_id)
{
int ret = MEDIA_CONTENT_ERROR_NONE;
sqlite3_stmt *stmt = NULL;
int item_count = 0;
- media_content_retvm_if(!STRING_VALID(media_id), MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "invalid media_id");
+ content_retip_if_fail(STRING_VALID(media_id));
- query_str = sqlite3_mprintf(SELECT_MEDIA_COUNT_FROM_MEDIA_BY_ID, media_id);
- ret = _content_query_prepare(&stmt, query_str, NULL, NULL);
+ /* Get image count */
+ query_str = sqlite3_mprintf(SELECT_IMAGE_COUNT_FROM_MEDIA_BY_ID, media_id);
+ ret = _content_get_result(query_str, &stmt);
SQLITE3_SAFE_FREE(query_str);
- media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
+ content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
if (sqlite3_step(stmt) == SQLITE_ROW)
item_count = (int)sqlite3_column_int(stmt, 0);
SQLITE3_FINALIZE(stmt);
- media_content_retvm_if(item_count == 0, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid media_id");
+ content_retvm_if(item_count == 0, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid media_id");
return MEDIA_CONTENT_ERROR_NONE;
}
int media_face_destroy(media_face_h face)
{
+ content_warn("DEPRECATION WARNING: media_face_destroy() is deprecated and will be removed from next release.");
media_face_s *_face = (media_face_s*)face;
- media_content_retvm_if(face == NULL, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid handle");
+ content_retip_if_fail(face);
- SAFE_FREE(_face->media_id);
- SAFE_FREE(_face->face_tag);
- SAFE_FREE(_face);
+ g_free(_face->media_id);
+ g_free(_face->face_tag);
+ g_free(_face);
return MEDIA_CONTENT_ERROR_NONE;
}
int media_face_clone(media_face_h *dst, media_face_h src)
{
+ content_warn("DEPRECATION WARNING: media_face_clone() is deprecated and will be removed from next release.");
media_face_s *_src = (media_face_s*)src;
- media_content_retvm_if(src == NULL, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid src handle");
-
- media_face_s *_dst = (media_face_s *)calloc(1, sizeof(media_face_s));
- media_content_retvm_if(_dst == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
+ content_retip_if_fail(dst);
+ content_retip_if_fail(src);
- if (STRING_VALID(_src->media_id)) {
- _dst->media_id = strdup(_src->media_id);
- if (_dst->media_id == NULL) {
- media_face_destroy((media_face_h)_dst);
- media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
- return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
- }
- }
+ media_face_s *_dst = g_new0(media_face_s, 1);
+ _dst->media_id = g_strdup(_src->media_id);
_dst->face_id = _src->face_id;
_dst->face_rect_x = _src->face_rect_x;
_dst->face_rect_y = _src->face_rect_y;
_dst->face_rect_w = _src->face_rect_w;
_dst->face_rect_h = _src->face_rect_h;
_dst->orientation = _src->orientation;
-
- if (STRING_VALID(_src->face_tag)) {
- _dst->face_tag = strdup(_src->face_tag);
- if (_dst->face_tag == NULL) {
- media_face_destroy((media_face_h)_dst);
- media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
- return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
- }
- }
+ _dst->face_tag = g_strdup(_src->face_tag);
*dst = (media_face_h)_dst;
char buf[MAX_SIZE] = {0, };
snprintf(buf, MAX_SIZE, "%d", face_id);
- *face_strid = strndup(buf, strlen(buf));
+ *face_strid = g_strndup(buf, strlen(buf));
}
int media_face_get_face_id(media_face_h face, char **face_id)
{
+ content_warn("DEPRECATION WARNING: media_face_get_face_id() is deprecated and will be removed from next release.");
media_face_s* _face = (media_face_s*)face;
- media_content_retvm_if(face == NULL, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid handle");
+ content_retip_if_fail(face);
+ content_retip_if_fail(face_id);
- if (_face->face_id > 0) {
+ if (_face->face_id > 0)
__media_face_convert_itoa(_face->face_id, face_id);
- media_content_retvm_if(*face_id == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "Out of memory");
- } else {
- *face_id = NULL;
- }
return MEDIA_CONTENT_ERROR_NONE;
}
int media_face_get_media_id(media_face_h face, char **media_id)
{
+ content_warn("DEPRECATION WARNING: media_face_get_media_id() is deprecated and will be removed from next release.");
media_face_s* _face = (media_face_s*)face;
- media_content_retvm_if(face == NULL, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid handle");
+ content_retip_if_fail(face);
+ content_retip_if_fail(media_id);
- if (STRING_VALID(_face->media_id)) {
- *media_id = strdup(_face->media_id);
- media_content_retvm_if(*media_id == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "Out of memory");
- } else {
- *media_id = NULL;
- }
+ *media_id = g_strdup(_face->media_id);
return MEDIA_CONTENT_ERROR_NONE;
}
int media_face_get_face_rect(media_face_h face, unsigned int *rect_x, unsigned int *rect_y, unsigned int *rect_w, unsigned int *rect_h)
{
+ content_warn("DEPRECATION WARNING: media_face_get_face_rect() is deprecated and will be removed from next release.");
media_face_s* _face = (media_face_s*)face;
- media_content_retvm_if(face == NULL, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid handle");
- media_content_retvm_if(!(rect_x && rect_y && rect_w && rect_h), MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid rect");
+ content_retip_if_fail(face);
+ content_retip_if_fail(rect_x);
+ content_retip_if_fail(rect_y);
+ content_retip_if_fail(rect_w);
+ content_retip_if_fail(rect_h);
*rect_x = _face->face_rect_x;
*rect_y = _face->face_rect_y;
int media_face_get_orientation(media_face_h face, media_content_orientation_e *orientation)
{
+ content_warn("DEPRECATION WARNING: media_face_get_orientation() is deprecated and will be removed from next release.");
media_face_s* _face = (media_face_s*)face;
- media_content_retvm_if(face == NULL, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid handle");
- media_content_retvm_if(orientation == NULL, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid orientation");
+ content_retip_if_fail(face);
+ content_retip_if_fail(orientation);
*orientation = _face->orientation;
int media_face_get_tag(media_face_h face, char **tag)
{
+ content_warn("DEPRECATION WARNING: media_face_get_tag() is deprecated and will be removed from next release.");
media_face_s* _face = (media_face_s*)face;
- media_content_retvm_if(face == NULL, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid handle");
+ content_retip_if_fail(face);
+ content_retip_if_fail(tag);
- if (STRING_VALID(_face->face_tag)) {
- *tag = strdup(_face->face_tag);
- media_content_retvm_if(*tag == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "Out of memory");
- } else {
- *tag = NULL;
- }
+ *tag = g_strdup(_face->face_tag);
return MEDIA_CONTENT_ERROR_NONE;
}
int media_face_create(const char *media_id, media_face_h *face)
{
+ content_warn("DEPRECATION WARNING: media_face_create() is deprecated and will be removed from next release.");
int ret = MEDIA_CONTENT_ERROR_NONE;
- media_content_retvm_if(!STRING_VALID(media_id), MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "invalid media_id");
- media_content_retvm_if(face == NULL, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid handle");
+ content_retip_if_fail(face);
ret = __media_face_check_media_id(media_id);
- media_content_retvm_if(ret != MEDIA_CONTENT_ERROR_NONE, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Not exist media_id");
+ content_retvm_if(ret != MEDIA_CONTENT_ERROR_NONE, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "media_id does not exist or is not an image");
- media_face_s* _face = calloc(1, sizeof(media_face_s));
- media_content_retvm_if(_face == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "Out of memory");
+ media_face_s* _face = g_new0(media_face_s, 1);
- _face->media_id = strdup(media_id);
+ _face->media_id = g_strdup(media_id);
*face = (media_face_h)_face;
int media_face_set_face_rect(media_face_h face, unsigned int rect_x, unsigned int rect_y, unsigned int rect_w, unsigned int rect_h)
{
+ content_warn("DEPRECATION WARNING: media_face_set_face_rect() is deprecated and will be removed from next release.");
media_face_s* _face = (media_face_s*)face;
- media_content_retvm_if(face == NULL, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid handle");
- media_content_retvm_if(rect_w == 0, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid rect_w");
- media_content_retvm_if(rect_h == 0, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid rect_h");
+ content_retip_if_fail(face);
+ content_retip_if_fail(rect_w > 0);
+ content_retip_if_fail(rect_h > 0);
_face->face_rect_x = rect_x;
_face->face_rect_y = rect_y;
int media_face_set_orientation(media_face_h face, media_content_orientation_e orientation)
{
+ content_warn("DEPRECATION WARNING: media_face_set_orientation() is deprecated and will be removed from next release.");
media_face_s* _face = (media_face_s*)face;
- media_content_retvm_if(face == NULL, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid handle");
+ content_retip_if_fail(face);
_face->orientation = orientation;
int media_face_set_tag(media_face_h face, const char *tag)
{
+ content_warn("DEPRECATION WARNING: media_face_set_tag() is deprecated and will be removed from next release.");
media_face_s* _face = (media_face_s*)face;
- media_content_retvm_if(face == NULL, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid handle");
+ content_retip_if_fail(face);
- if (STRING_VALID(tag))
- _face->face_tag = strdup(tag);
- else
- _face->face_tag = NULL;
+ g_free(_face->face_tag);
+ _face->face_tag = g_strdup(tag);
return MEDIA_CONTENT_ERROR_NONE;
}
int media_face_insert_to_db(media_face_h face)
{
+ content_warn("DEPRECATION WARNING: media_face_insert_to_db() is deprecated and will be removed from next release.");
int ret = MEDIA_CONTENT_ERROR_NONE;
char *query_str = NULL;
sqlite3_stmt *stmt = NULL;
media_face_s* _face = (media_face_s*)face;
- media_content_retvm_if(face == NULL, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid handle");
- media_content_retvm_if(_face->media_id == NULL, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid media_id");
- media_content_retvm_if(_face->face_rect_w == 0, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid rect_w");
- media_content_retvm_if(_face->face_rect_h == 0, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid rect_h");
+ content_retip_if_fail(face);
+ content_retip_if_fail(_face->media_id);
+ content_retip_if_fail(_face->face_rect_w > 0);
+ content_retip_if_fail(_face->face_rect_h > 0);
query_str = sqlite3_mprintf(INSERT_FACE_TO_FACE, _face->media_id, _face->face_rect_x, _face->face_rect_y, _face->face_rect_w, _face->face_rect_h, _face->orientation, _face->face_tag);
SQLITE3_SAFE_FREE(query_str);
query_str = sqlite3_mprintf(SELECT_FACE_ID, _face->media_id, _face->face_rect_x, _face->face_rect_y, _face->face_rect_w, _face->face_rect_h, _face->orientation);
- ret = _content_query_prepare(&stmt, query_str, NULL, NULL);
+ ret = _content_get_result(query_str, &stmt);
SQLITE3_SAFE_FREE(query_str);
- media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
+ content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
if (sqlite3_step(stmt) == SQLITE_ROW)
_face->face_id = (int)sqlite3_column_int(stmt, 0);
int media_face_update_to_db(media_face_h face)
{
+ content_warn("DEPRECATION WARNING: media_face_update_to_db() is deprecated and will be removed from next release.");
int ret = MEDIA_CONTENT_ERROR_NONE;
char *query_str = NULL;
media_face_s* _face = (media_face_s*)face;
- media_content_retvm_if(face == NULL, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid handle");
- media_content_retvm_if(_face->face_id == 0, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid face_id");
- media_content_retvm_if(_face->media_id == NULL, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid media_id");
- media_content_retvm_if(_face->face_rect_w == 0, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid rect_w");
- media_content_retvm_if(_face->face_rect_h == 0, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid rect_h");
+ content_retip_if_fail(face);
+ content_retip_if_fail(_face->media_id);
+ content_retip_if_fail(_face->face_id > 0);
+ content_retip_if_fail(_face->face_rect_w > 0);
+ content_retip_if_fail(_face->face_rect_h > 0);
query_str = sqlite3_mprintf(UPDATE_FACE_TO_FACE, _face->face_rect_x, _face->face_rect_y, _face->face_rect_w, _face->face_rect_h, _face->orientation, _face->face_tag, _face->face_id);
{
char *end = NULL;
errno = 0;
- media_content_retvm_if(buffer == NULL || si == NULL, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "invalid parameter");
+
+ content_retip_if_fail(buffer);
+ content_retip_if_fail(si);
const long sl = strtol(buffer, &end, 10);
- media_content_retvm_if(end == buffer, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "not a decimal number");
- media_content_retvm_if('\0' != *end, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "extra characters at end of input: %s", end);
- media_content_retvm_if((LONG_MIN == sl || LONG_MAX == sl) && (ERANGE == errno), MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "out of range of type long");
- media_content_retvm_if(sl > INT_MAX, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "greater than INT_MAX");
- media_content_retvm_if(sl < INT_MIN, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "less than INT_MIN");
+ content_retvm_if(end == buffer, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "not a decimal number");
+ content_retvm_if('\0' != *end, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "extra characters at end of input: %s", end);
+ content_retvm_if((LONG_MIN == sl || LONG_MAX == sl) && (ERANGE == errno), MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "out of range of type long");
+ content_retvm_if(sl > INT_MAX, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "greater than INT_MAX");
+ content_retvm_if(sl < INT_MIN, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "less than INT_MIN");
*si = (int)sl;
int media_face_delete_from_db(const char *face_id)
{
+ content_warn("DEPRECATION WARNING: media_face_delete_from_db() is deprecated and will be removed from next release.");
int ret = MEDIA_CONTENT_ERROR_NONE;
char *query_str = NULL;
int query_face_id = 0;
- media_content_retvm_if(!STRING_VALID(face_id), MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "invalid face_id");
ret = __media_face_safe_atoi(face_id, &query_face_id);
- media_content_retvm_if(ret != MEDIA_CONTENT_ERROR_NONE, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "invalid face_id");
+ content_retvm_if(ret != MEDIA_CONTENT_ERROR_NONE, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "invalid face_id");
/*Update modified_time to 0.. It will restore the deleted face when media_info_start_face_detection() is called */
query_str = sqlite3_mprintf(UPDATE_MEDIA_INFO_IN_FACE_SCAN_LIST, query_face_id);
ret = _content_query_sql(query_str);
SQLITE3_SAFE_FREE(query_str);
- media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
+ content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
query_str = sqlite3_mprintf(DELETE_FACE_FROM_FACE, query_face_id);
ret = _content_query_sql(query_str);
int media_face_get_face_count_from_db(filter_h filter, int *face_count)
{
- int ret = MEDIA_CONTENT_ERROR_NONE;
-
- if (face_count == NULL) {
- media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
- }
+ content_warn("DEPRECATION WARNING: media_face_get_face_count_from_db() is deprecated and will be removed from next release.");
+ content_retip_if_fail(face_count);
- ret = _media_db_get_group_count(filter, MEDIA_GROUP_FACE, face_count);
-
- return ret;
+ return _media_db_get_group_count(filter, MEDIA_GROUP_FACE, face_count);
}
int media_face_foreach_face_from_db(filter_h filter, media_face_cb callback, void *user_data)
{
- int ret = MEDIA_CONTENT_ERROR_NONE;
+ content_warn("DEPRECATION WARNING: media_face_foreach_face_from_db() is deprecated and will be removed from next release.");
+ content_retip_if_fail(callback);
- media_content_retvm_if(callback == NULL, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "invalid paramter");
-
- ret = _media_db_get_face(NULL, filter, callback, user_data);
-
- return ret;
+ return _media_db_get_face(NULL, filter, callback, user_data);
}
+// LCOV_EXCL_STOP
\ No newline at end of file