Change face uuid to id 06/159806/3
authorMinje Ahn <minje.ahn@samsung.com>
Mon, 13 Nov 2017 05:39:20 +0000 (14:39 +0900)
committerMinje Ahn <minje.ahn@samsung.com>
Tue, 14 Nov 2017 02:15:05 +0000 (11:15 +0900)
Change-Id: Iddbb8590b72824e6c0766747c2995fed1c726fc3
Signed-off-by: Minje Ahn <minje.ahn@samsung.com>
CMakeLists.txt
include/dcm_svc_db.h
packaging/dcm-service.spec
src/dcm_svc_db.c
src/dcm_svc_detect_face.c
src/dcm_svc_internal.c
svc/dcm_svc_main.c

index f94157af10ee957c80076f16650dc789217e0dc1..bf0dbe9e9a8c2f486e022a1136ae607979784e2e 100755 (executable)
@@ -42,7 +42,7 @@ INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include ${CMAKE_SOURCE_DIR}/libdcm-util/
 
 INCLUDE(FindPkgConfig)
 pkg_check_modules(pkgs REQUIRED glib-2.0 gthread-2.0 dlog sqlite3 capi-media-image-util capi-media-vision
- libmedia-utils uuid libtzplatform-config)
+ libmedia-utils libtzplatform-config)
 
 FOREACH(flag ${pkgs_CFLAGS})
        SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
index 0c6160c53c9727459570ee4a5f85ecb4a769042f..66f78797e29dfc32813319e315535f5e0ad8b464 100755 (executable)
 #define DB_TABLE_FACE "face"
 #define DB_TABLE_FACE_SCAN_LIST "face_scan_list"
 #define DB_TABLE_MEDIA "media"
-#define FACE_ITEM "face_uuid, media_uuid, face_rect_x , face_rect_y, face_rect_w , face_rect_h, orientation"
+#define FACE_ITEM "media_uuid, face_rect_x , face_rect_y, face_rect_w , face_rect_h, orientation"
 
 #define SELECT_MEDIA_INFO_BY_FILE_PATH_FROM_DB "SELECT media_uuid, width, height, orientation, mime_type, modified_time FROM media WHERE path = '%q';"
 #define SELECT_SCAN_INFO_BY_MEDIA_ID "SELECT modified_time FROM "DB_TABLE_FACE_SCAN_LIST" WHERE media_uuid = '%q';"
 
-#define INSERT_FACE_ITEM_TO_DB "INSERT OR IGNORE INTO " DB_TABLE_FACE" (" FACE_ITEM") VALUES ('%q', '%q', %d, %d, %d, %d, %d);"
+#define INSERT_FACE_ITEM_TO_DB "INSERT OR IGNORE INTO " DB_TABLE_FACE" (" FACE_ITEM") VALUES ('%q', %d, %d, %d, %d, %d);"
 
 typedef struct {
-       char *face_uuid;
        char *media_uuid;
        unsigned int face_rect_x;
        unsigned int face_rect_y;
@@ -62,7 +61,6 @@ typedef enum {
 int dcm_svc_db_connect(uid_t uid);
 int dcm_svc_db_disconnect();
 int dcm_svc_db_get_scan_image_info_by_path(const char *file_path, dcm_svc_item_s **scan_item);
-int dcm_svc_db_generate_uuid(dcm_face_item_s **face);
 int dcm_svc_db_insert_face_to_db(dcm_face_item_s *face);
 int dcm_svc_db_update_color_to_db(const dcm_color_item_s color);
 int dcm_svc_db_insert_face_to_face_scan_list(dcm_svc_item_s *scan_item);
index 180931be74bc702de30960284a6236a20f2bbebf..7052d65cd2db58af6299ec9e658b3ee10863a506 100755 (executable)
@@ -1,6 +1,6 @@
 Name:       dcm-service
 Summary:    A media DCM(Digital Contents Management) Service
-Version:    0.1.10
+Version:    0.1.11
 Release:    0
 Group:      Multimedia/Service
 License:    Apache-2.0
@@ -19,7 +19,6 @@ BuildRequires:  pkgconfig(capi-media-image-util)
 BuildRequires:  pkgconfig(capi-media-vision)
 BuildRequires:  pkgconfig(libmedia-utils)
 BuildRequires:  pkgconfig(libtzplatform-config)
-BuildRequires:  pkgconfig(uuid)
 
 %description
 This package provides a media DCM(Digital Contents Management) service
index 6d92f6b0e0fa5ed6cf95f47613f21f5b1f93db65..fcbc5737bb5783f1995a3bec32dca21c75fd8580 100755 (executable)
@@ -19,7 +19,6 @@
 #include <stdlib.h>
 #include <string.h>
 #include <unistd.h>
-#include <uuid/uuid.h>
 
 #include <dcm_svc_db.h>
 #include <dcm_svc_debug.h>
@@ -150,30 +149,6 @@ int dcm_svc_db_get_scan_image_info_by_path(const char *file_path, dcm_svc_item_s
        return ret;
 }
 
-int dcm_svc_db_generate_uuid(dcm_face_item_s **face)
-{
-       int ret = MS_MEDIA_ERR_NONE;
-       uuid_t uuid_value;
-       static char uuid_unparsed[50] = {0, };
-
-       dcm_debug_fenter();
-       dcm_retvm_if(face == NULL, MS_MEDIA_ERR_INVALID_PARAMETER, "Invalid face");
-
-       uuid_generate(uuid_value);
-       uuid_unparse(uuid_value, uuid_unparsed);
-
-       (*face)->face_uuid = g_strdup(uuid_unparsed);
-
-       if ((*face)->face_uuid == NULL)
-               ret = MS_MEDIA_ERR_INTERNAL;
-       else
-               dcm_debug("set face_uuid :%s", (*face)->face_uuid);
-
-       dcm_debug_fleave();
-
-       return ret;
-}
-
 int dcm_svc_db_insert_face_to_db(dcm_face_item_s *face)
 {
        int ret = MS_MEDIA_ERR_NONE;
@@ -183,9 +158,8 @@ int dcm_svc_db_insert_face_to_db(dcm_face_item_s *face)
 
        dcm_retvm_if(db_handle == NULL, MS_MEDIA_ERR_INVALID_PARAMETER, "Invalid db_handle");
        dcm_retvm_if(face == NULL, MS_MEDIA_ERR_INVALID_PARAMETER, "Invalid face");
-       dcm_retvm_if(face->face_uuid == NULL, MS_MEDIA_ERR_INVALID_PARAMETER, "Invalid face_uuid");
 
-       query_string = sqlite3_mprintf(INSERT_FACE_ITEM_TO_DB, face->face_uuid, face->media_uuid, face->face_rect_x, face->face_rect_y, face->face_rect_w, face->face_rect_h, face->orientation);
+       query_string = sqlite3_mprintf(INSERT_FACE_ITEM_TO_DB, face->media_uuid, face->face_rect_x, face->face_rect_y, face->face_rect_w, face->face_rect_h, face->orientation);
        dcm_debug("query[%s]", query_string);
 
        g_mutex_trylock(&gMutexLock);
@@ -242,7 +216,6 @@ int dcm_svc_db_update_face_to_face_scan_list(dcm_svc_item_s *scan_item)
        dcm_retvm_if(scan_item->media_uuid == NULL, MS_MEDIA_ERR_INVALID_PARAMETER, "Invalid media_uuid");
 
        query_string = sqlite3_mprintf("UPDATE %s SET modified_time = %d WHERE media_uuid='%q'", DB_TABLE_FACE_SCAN_LIST, scan_item->modified_time, scan_item->media_uuid);
-
        dcm_debug("query[%s]", query_string);
 
        g_mutex_trylock(&gMutexLock);
@@ -270,7 +243,6 @@ int dcm_svc_db_delete_face_from_db(const char *media_uuid)
        dcm_retvm_if(media_uuid == NULL, MS_MEDIA_ERR_INVALID_PARAMETER, "Invalid media_uuid");
 
        query_string = sqlite3_mprintf("DELETE FROM %s WHERE media_uuid='%q' AND user_marked = 0", DB_TABLE_FACE, media_uuid);
-
        dcm_sec_debug("query[%s]", query_string);
 
        g_mutex_trylock(&gMutexLock);
index 412b7c0d767dff85f6b998daeaa57082a1b6ca1c..79659ef8e03a1b6584288895e8b1ffba1f556da0 100755 (executable)
@@ -67,7 +67,6 @@ static void __destroy_face_item(void *data)
        dcm_face_item_s *_face = (dcm_face_item_s *)data;
        DCM_CHECK(_face);
 
-       DCM_SAFE_FREE(_face->face_uuid);
        DCM_SAFE_FREE(_face->media_uuid);
        DCM_SAFE_FREE(_face);
 
@@ -183,11 +182,6 @@ int dcm_face_detect_process(dcm_svc_item_s *scan_item, dcm_face_scan_status_e sc
                face->media_uuid = g_strdup(scan_item->media_uuid);
 
                /* Insert face rectangle into database */
-               ret = dcm_svc_db_generate_uuid(&face);
-               if (ret != MS_MEDIA_ERR_NONE) {
-                       dcm_error("Failed to set uuid! ret: %d", ret);
-                       goto DCM_SVC_FACE_RECOGNIZE_BUFFER_FAILED;
-               }
                ret = dcm_svc_db_insert_face_to_db(face);
                if (ret != MS_MEDIA_ERR_NONE) {
                        dcm_error("Failed to insert face item into db! ret: %d", ret);
index 4a89e7a578d5f79d0a65d7e69087076afa93e620..330612ae904a526c92f7b7a94a41d46107cd9b99 100755 (executable)
@@ -41,19 +41,10 @@ static int __dcm_scan_process(dcm_svc_item_s *scan_item)
        memset(&image_info, 0, sizeof(dcm_image_info_s));
        image_info.decode_type = DCM_IMAGE_FORMAT_I420;
 
-       /* Process scan operation if the file exists */
-       if (g_file_test(scan_item->file_path, (GFileTest)(G_FILE_TEST_EXISTS | G_FILE_TEST_IS_REGULAR)) == TRUE) {
-               /* Get necessary information from db again.
-               * Media information will be inserted after face is detected.
-               * If media uuid does not exist, retry is needed */
+       if (g_file_test(scan_item->file_path, G_FILE_TEST_IS_REGULAR)) {
                ret = dcm_svc_db_check_scanned_by_media_uuid(scan_item->media_uuid, scan_item->modified_time, &scan_status);
-               if (ret != MS_MEDIA_ERR_NONE) {
-                       dcm_error("Failed to get scan item info from db! err: %d", ret);
-                       return ret;
-               }
+               dcm_retvm_if(ret != MS_MEDIA_ERR_NONE, ret, "Failed to get scan item info from db(%d)", ret);
 
-               /* It is possible that when single and async scan for the same image is in the list.
-               * If the media uuid is already scanned, skip this scan. */
                if (scan_status == FACE_SCAN_NO_NEEDED) {
                        dcm_warn("This media is scanned already! Skip...");
                        DCM_SAFE_FREE(image_info.pixel);
@@ -62,35 +53,28 @@ static int __dcm_scan_process(dcm_svc_item_s *scan_item)
                        dcm_debug("Need to Scan");
                }
 
-               dcm_sec_debug("scan file path : [%s]", scan_item->file_path);
-               dcm_sec_debug("scan media uuid : [%s]", scan_item->media_uuid);
+               dcm_sec_debug("File path[%s] media id[%s]", scan_item->file_path, scan_item->media_uuid);
 
                image_info.original_width = scan_item->image_width;
                image_info.original_height = scan_item->image_height;
                image_info.orientation = scan_item->image_orientation;
 
-               dcm_info("scan media w : [%d], h : [%d], orientation : [%d]", image_info.original_width, image_info.original_height, scan_item->image_orientation);
-
                if (strcmp(scan_item->mime_type, MIME_TYPE_JPEG) == 0) {
                        image_info.decode_type = DCM_IMAGE_FORMAT_RGB;
                } else if ((strcmp(scan_item->mime_type, MIME_TYPE_PNG) == 0) ||
                                (strcmp(scan_item->mime_type, MIME_TYPE_BMP) == 0)) {
                        image_info.decode_type = DCM_IMAGE_FORMAT_RGBA;
                } else {
-                       dcm_error("Failed not supported type(%s)", scan_item->mime_type);
+                       dcm_error("Failed not supported type(%s)", scan_item->mime_type);
                        return MS_MEDIA_ERR_INVALID_PARAMETER;
                }
 
                ret = dcm_decode_image((const char *) (scan_item->file_path), image_info.decode_type, scan_item->mime_type,
-                       image_info.orientation, FALSE, &(image_info.pixel), &(image_info.size),
-                       &(image_info.buffer_width), &(image_info.buffer_height));
-               if (ret != MS_MEDIA_ERR_NONE) {
-                       dcm_error("Failed dcm_decode_image! err: %d", ret);
-                       return ret;
-               }
+                       image_info.orientation, FALSE, &(image_info.pixel), &(image_info.size), &(image_info.buffer_width), &(image_info.buffer_height));
+               dcm_retvm_if(ret != MS_MEDIA_ERR_NONE, ret, "Failed dcm_decode_image(%d)", ret);
 
-               dcm_info("Image info width: %d, height: %d, buf_width: %d, buf_height: %d",
-                       image_info.original_width, image_info.original_height, image_info.buffer_width, image_info.buffer_height);
+               dcm_info("Image info W[%d] H[%d] Orient[%d] buf_w[%d] buf_h[%d]",
+                       image_info.original_width, image_info.original_height, scan_item->image_orientation, image_info.buffer_width, image_info.buffer_height);
 
                if (scan_status == FACE_SCAN_REFRESH_NEEDED) {
                        ret = dcm_svc_db_delete_face_from_db(scan_item->media_uuid);
@@ -113,7 +97,7 @@ static int __dcm_scan_process(dcm_svc_item_s *scan_item)
                /* Free image buffer */
                DCM_SAFE_FREE(image_info.pixel);
        } else {
-               dcm_warn("The file does not exist");
+               dcm_warn("The file does not exist");
                ret = MS_MEDIA_ERR_INVALID_PATH;
        }
 
index e2cb4510e844536850f8e3fa908acf1d83b5cd59..e1f478d3f517ef1dbc82166b2c70cbbb260e0601 100755 (executable)
@@ -45,7 +45,7 @@ gboolean dcm_service_recieve_request(GIOChannel *src, GIOCondition condition, gp
        int sock = -1;
        int client_sock = -1;
        int ret = 0;
-       int face_count = 0;;
+       int face_count = 0;
 
        memset((void *)&recv_msg, 0, sizeof(recv_msg));
 
@@ -68,30 +68,25 @@ gboolean dcm_service_recieve_request(GIOChannel *src, GIOCondition condition, gp
                return TRUE;
        }
 
-       dcm_info("Received msg_type : [%d]", recv_msg.msg_type);
-       dcm_sec_info("Received uid : [%d]", recv_msg.uid);
-       dcm_sec_info("Received msg : [%s]", recv_msg.msg);
+       dcm_sec_info("msg_type[%d] uid[%d] msg[%s]", recv_msg.msg_type, recv_msg.uid, recv_msg.msg);
 
        if (recv_msg.msg_type == DCM_MSG_REQUEST_KILL_SERVER) {
                dcm_warn("Receive DCM_MSG_REQUEST_KILL_SERVER");
                __dcm_svc_kill_service();
 
        } else if (recv_msg.msg_type == DCM_MSG_REQUEST_MEDIA) {
-               dcm_debug("Scan single");
                ret = dcm_scan_single(recv_msg.msg, recv_msg.uid, &face_count);
-               dcm_debug("Scan single result: ret : [%d] face_count : [%d])", ret, face_count);
-               if (ret == MS_MEDIA_ERR_NONE) {
+               dcm_debug("Scan single result: ret[%d] face_count[%d]", ret, face_count);
+               if (ret == MS_MEDIA_ERR_NONE)
                        ret = dcm_ipc_send_client_message(client_sock, DCM_MSG_REQUEST_MEDIA, face_count, recv_msg.msg, DCM_IPC_PORT_MS_RECV);
-                       if (ret != MS_MEDIA_ERR_NONE)
-                               dcm_error("Failed to dcm_ipc_send_client_message! err: %d", ret);
-               } else {
+               else
                        ret = dcm_ipc_send_client_message(client_sock, DCM_MSG_REQUEST_MEDIA, ret, recv_msg.msg, DCM_IPC_PORT_MS_RECV);
-                       if (ret != MS_MEDIA_ERR_NONE)
-                               dcm_error("Failed to dcm_ipc_send_client_message! err: %d", ret);
-               }
+
+               if (ret != MS_MEDIA_ERR_NONE)
+                       dcm_error("Failed to dcm_ipc_send_client_message(%d)", ret);
 
        } else {
-               dcm_debug("createDcmSvcReadSocket, invalid message(%d).", recv_msg.msg_type);
+               dcm_debug("Invalid message(%d)", recv_msg.msg_type);
        }
 
        dcm_ipc_close_socket(client_sock);
@@ -105,7 +100,6 @@ EXPORT_API int main(int argc, char *argv[])
        GSource *source = NULL;
        GIOChannel *channel = NULL;
        GMainContext *context = NULL;
-       /* threads related */
 
        /* Create and bind new socket to main_loop */
        if (dcm_ipc_create_socket(&sockfd, DCM_IPC_PORT_DCM_RECV) != MS_MEDIA_ERR_NONE) {