Code refactoring for dcm-service 18/135918/3
authorJiyong Min <jiyong.min@samsung.com>
Tue, 27 Jun 2017 09:26:47 +0000 (18:26 +0900)
committerJiyong Min <jiyong.min@samsung.com>
Tue, 27 Jun 2017 10:11:47 +0000 (19:11 +0900)
 - Remove unused source code
 - Cleanup header file

Change-Id: Ia562e4ea5dcc9ce953b5d7925778c71929944885
Signed-off-by: Jiyong Min <jiyong.min@samsung.com>
21 files changed:
include/dcm_svc_db.h
include/dcm_svc_debug.h
include/dcm_svc_detect_face.h
include/dcm_svc_extract_color.h
include/dcm_svc_internal.h
include/dcm_svc_ipc.h
include/dcm_svc_main.h
include/dcm_svc_type.h [deleted file]
libdcm-face/dcm-face-debug.h
libdcm-face/include/dcm-face.h
libdcm-util/dcm_image_codec.c
libdcm-util/include/dcm_image_codec.h
libdcm-util/include/dcm_image_codec_debug.h [new file with mode: 0755]
libdcm-util/include/dcm_image_debug_utils.h [deleted file]
packaging/dcm-service.spec
src/dcm_svc_db.c
src/dcm_svc_detect_face.c
src/dcm_svc_extract_color.c
src/dcm_svc_internal.c
src/dcm_svc_ipc.c
svc/dcm_svc_main.c

index 91e01bd251b767466aabf1a6fd5ca7c1d3e87746..a63e728f95d71136a9d37f9e4831ee9c69f30c39 100755 (executable)
 #ifndef _DCM_DB_UTILS_H_
 #define _DCM_DB_UTILS_H_
 
-#include <stdbool.h>
 #include <sqlite3.h>
-#include <glib.h>
-#include <media-util.h>
-/*#include <media-util-noti-face.h> */
-#include <dcm-face.h>
-#include <dcm_svc_type.h>
+#include <dcm_svc_internal.h>
 
 #define DCM_STRING_VALID(str)          ((str != NULL && strlen(str) > 0) ? TRUE : FALSE)
 #define DCM_SQLITE3_FINALIZE(x)                { if (x != NULL) { sqlite3_finalize(x); x = NULL; } }
index 4fce682fea062eadfd717f15420e7d31719653c5..29d7f3c37e907227ec4481b3399049a66b97f7d7 100755 (executable)
@@ -19,6 +19,7 @@
 #define _DCM_DEBUG_UTILS_H_
 
 #include <dlog.h>
+#include <media-util.h>
 
 #ifdef LOG_TAG
 #undef LOG_TAG
index 841a138e30547a2123a97931e866bca0f43caf44..db605fc1cfca5dc6036f3b76ee7027eb912de126 100755 (executable)
 #ifndef _DCM_SVC_FACE_H_
 #define _DCM_SVC_FACE_H_
 
-#include <dcm_svc_type.h>
+#include <dcm_svc_internal.h>
 
-int face_detect_initialize();
-int face_detect_finalize();
-int face_detect_process(dcm_svc_item_s *scan_item, dcm_image_info_s *image_info);
+int dcm_face_detect_initialize();
+int dcm_face_detect_finalize();
+int dcm_face_detect_process(dcm_svc_item_s *scan_item, dcm_image_info_s *image_info);
 
 #endif /*_DCM_SVC_FACE_H_*/
 
index e06aede78731da28ee9f9b02027bf9ad8a13d34f..f33b674a3bf1a0871a2d7793d2f44355bee1d0c4 100755 (executable)
@@ -18,9 +18,9 @@
 #ifndef _DCM_SVC_COLOR_H_
 #define _DCM_SVC_COLOR_H_
 
-#include <dcm_svc_type.h>
+#include <dcm_svc_internal.h>
 
-int color_extract_process(dcm_svc_item_s *scan_item, dcm_image_info_s *image_info);
+int dcm_color_extract_process(dcm_svc_item_s *scan_item, dcm_image_info_s *image_info);
 
 #endif /*_DCM_SVC_COLOR_H_*/
 
index b9d89c524dbb85bc6ca1549ecd5782861be01986..2a73af2772b2c23737e26a86a9574de352b348c6 100755 (executable)
@@ -19,6 +19,7 @@
 #define _DCM_SCAN_SVC_H_
 
 #include <glib.h>
+#include <dcm_image_codec.h>
 
 typedef struct {
        GMainLoop *main_loop;
@@ -37,6 +38,36 @@ typedef struct {
        uid_t g_uid;
 } dcm_scan_s;
 
+typedef enum {
+       DCM_SCAN_ITEM_TYPE_NONE,
+       DCM_SCAN_ITEM_TYPE_SCAN_ALL,
+       DCM_SCAN_ITEM_TYPE_SCAN_SINGLE,
+       DCM_SCAN_ITEM_TYPE_MAX,
+} dcm_svc_type_e;
+
+typedef struct {
+       char *media_uuid;
+       char *file_path;
+       char *storage_uuid;
+       int image_width;
+       int image_height;
+       int image_orientation;
+       char *mime_type;
+       int face_count;
+       dcm_svc_type_e scan_item_type;
+} dcm_svc_item_s;
+
+typedef struct {
+       unsigned char *pixel;           /* decoding results, must be freed after use */
+       unsigned long long size;
+       int orientation;                        /* orientation information extracted from exif */
+       unsigned int original_width;                    /* original image width */
+       unsigned int original_height;           /* original image height */
+       unsigned int buffer_width;                      /* scaled image width used by decoder (width/height ratio should be the same as original) */
+       unsigned int buffer_height;                     /* scaled image height used by decoder (width/height ratio should be the same as original) */
+       dcm_image_format_e decode_type; /* decoding pre-condition */
+} dcm_image_info_s;
+
 gboolean dcm_scan_thread(void *data);
 int dcm_scan_single(const char *file_path, uid_t uid, int *face_count);
 
index e8606bd0b92f4a88dc39cc757406f26814d635f7..a748c3da4ef7edee7f4e0914dc20ee7364c8f2bc 100755 (executable)
 #ifndef _DCM_SVC_IPC_H_
 #define _DCM_SVC_IPC_H_
 
-#include <dcm_svc_type.h>
+#include <dcm_svc_internal.h>
 #include <media-server-ipc.h>
 
+#define DCM_IPC_MSG_MAX_SIZE 4096
 #define DCM_TIMEOUT_SEC_60                     60              /**< Response to media server time out */
 
+typedef enum {
+       DCM_IPC_PORT_SCAN_RECV = 0,
+       DCM_IPC_PORT_DCM_RECV,
+       DCM_IPC_PORT_MS_RECV,
+       DCM_IPC_PORT_MAX,
+} dcm_ipc_port_e;
+
 int dcm_ipc_create_socket(int *socket_fd, dcm_ipc_port_e port);
 int dcm_ipc_accept_socket(int serv_sock, int *client_sock);
 int dcm_ipc_receive_message(int client_sock, dcmMsg *recv_msg);
index 26aa670b0455bd47dbd5ff594db5db51c8b5c5d3..f63bc149d0b2042bf0f3d68c633aa617a0dc0907 100755 (executable)
@@ -19,8 +19,6 @@
 #define _DCM_MAIN_SVC_H_
 
 #include <glib.h>
-#include <dcm_svc_type.h>
-#include <dcm_svc_ipc.h>
 
 #ifndef EXPORT_API
 #define EXPORT_API __attribute__ ((visibility("default")))
diff --git a/include/dcm_svc_type.h b/include/dcm_svc_type.h
deleted file mode 100755 (executable)
index 4189971..0000000
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-#ifndef _DCM_TYPES_H_
-#define _DCM_TYPES_H_
-
-#include <glib.h>
-#include <unistd.h>
-
-/*
- * Definitions defined here can be used by all threads
- * If a definition can only be used in a specific thread, then this definition should be defined in that thread, not here.
- */
-
-#define DCM_MAX_PATH_SIZE 4096
-#define DCM_IPC_MSG_MAX_SIZE 4096
-#define DCM_DB_QUERY_MAX_SIZE 4096
-
-typedef enum {
-       DCM_IPC_PORT_SCAN_RECV = 0,
-       DCM_IPC_PORT_DCM_RECV,
-       DCM_IPC_PORT_MS_RECV,
-       DCM_IPC_PORT_MAX,
-} dcm_ipc_port_e;
-
-typedef enum {
-       DCM_SCAN_ITEM_TYPE_NONE,
-       DCM_SCAN_ITEM_TYPE_SCAN_ALL,
-       DCM_SCAN_ITEM_TYPE_SCAN_SINGLE,
-       DCM_SCAN_ITEM_TYPE_MAX,
-} dcm_svc_type_e;
-
-typedef enum {
-       DCM_SVC_I420,
-       DCM_SVC_RGB,
-       DCM_SVC_RGBA,
-} dcm_image_type_e;
-
-typedef struct {
-       char *media_uuid;
-       char *file_path;
-       char *storage_uuid;
-       int image_width;
-       int image_height;
-       int image_orientation;
-       char *mime_type;
-       int face_count;
-       dcm_svc_type_e scan_item_type;
-} dcm_svc_item_s;
-
-typedef struct {
-       unsigned char *pixel;           /* decoding results, must be freed after use */
-       unsigned long long size;
-       int orientation;                        /* orientation information extracted from exif */
-       unsigned int original_width;                    /* original image width */
-       unsigned int original_height;           /* original image height */
-       unsigned int buffer_width;                      /* scaled image width used by decoder (width/height ratio should be the same as original) */
-       unsigned int buffer_height;                     /* scaled image height used by decoder (width/height ratio should be the same as original) */
-       dcm_image_type_e decode_type;   /* decoding pre-condition */
-} dcm_image_info_s;
-
-#endif /* _DCM_TYPES_H_ */
-
index fe3c4c4e545711c4b78b0f0ff6748be7e7d757e6..7a214670a0fd42b071a489456b3b1f3d5862d6f4 100755 (executable)
@@ -17,6 +17,7 @@
 #define __FACE_DEBUG_H__
 
 #include <dlog.h>
+#include <media-util.h>
 
 #ifdef LOG_TAG
 #undef LOG_TAG
index 2a250e689c5ddf95a1634352dc14c6b493789505..b411ba546d6962cb174a29f5538bb2bcaab2d31c 100755 (executable)
@@ -18,7 +18,6 @@
 
 #include <tizen.h>
 #include "dcm-face_type.h"
-#include <media-util.h>
 
 #ifdef __cplusplus
 extern "C" {
index 804bf5c8f4133d9e0c9f035821fb33060d6dc8a1..4bbd0db40700a814fff1cad11a7f8754af4dea06 100755 (executable)
  *
  */
 
-#include <glib.h>
-#include <stdio.h>
+
 #include <stdlib.h>
 #include <image_util.h>
 #include <image_util_internal.h>
 #include <mm_util_imgp.h>
-#include <dcm_svc_debug.h>
+#include <dcm_image_codec_debug.h>
 #include <dcm_image_codec.h>
-#include <dcm_svc_type.h>
-#include <media-util.h>
-
-#define MIME_TYPE_JPEG "image/jpeg"
-#define MIME_TYPE_PNG "image/png"
-#define MIME_TYPE_BMP "image/bmp"
 
 #define OPT_IMAGE_WIDTH                1280
 #define OPT_IMAGE_HEIGHT       720
index 22d81294df462eb7fb6f1cf86e325b5e1d703f26..f26204610a253b50f97fb833d4e962b70f95e83a 100755 (executable)
 #ifndef _DCM_IMAGE_CODEC_H_
 #define _DCM_IMAGE_CODEC_H_
 
+#include <glib.h>
+
 #define DEGREE_0               0
 #define DEGREE_90              1
 #define DEGREE_180             2
 #define DEGREE_270             3
 
+#define MIME_TYPE_JPEG "image/jpeg"
+#define MIME_TYPE_PNG  "image/png"
+#define MIME_TYPE_BMP  "image/bmp"
+
 #ifdef __cplusplus
 extern "C" {
 #endif
@@ -33,17 +39,6 @@ typedef enum {
        DCM_IMAGE_FORMAT_RGBA,
 } dcm_image_format_e;
 
-typedef struct {
-       int size;
-       int width;
-       int height;
-       int origin_width;
-       int origin_height;
-       int alpha;
-       unsigned char *data;
-} dcm_image_info;
-
-
 int dcm_decode_image(const char *file_path, const dcm_image_format_e format,
        const char* mimne_type, const int orientation, const gboolean resize,
        unsigned char **image_buffer, unsigned long long *size,
diff --git a/libdcm-util/include/dcm_image_codec_debug.h b/libdcm-util/include/dcm_image_codec_debug.h
new file mode 100755 (executable)
index 0000000..4b295ed
--- /dev/null
@@ -0,0 +1,91 @@
+/*
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#ifndef _DCM_DEBUG_UTILS_H_
+#define _DCM_DEBUG_UTILS_H_
+
+#include <dlog.h>
+#include <media-util.h>
+
+#ifdef LOG_TAG
+#undef LOG_TAG
+#endif
+
+#define LOG_TAG "DCM_IMAGE_CODEC"
+
+#define FONT_COLOR_RESET               "\033[0m"
+#define FONT_COLOR_RED                 "\033[31m"
+#define FONT_COLOR_GREEN               "\033[32m"
+#define FONT_COLOR_YELLOW              "\033[33m"
+#define FONT_COLOR_BLUE                "\033[34m"
+#define FONT_COLOR_PURPLE              "\033[35m"
+#define FONT_COLOR_CYAN                "\033[36m"
+#define FONT_COLOR_GRAY                "\033[37m"
+
+#define dcm_debug(fmt, arg...) do { \
+               LOGD(FONT_COLOR_CYAN"" fmt "" FONT_COLOR_RESET, ##arg); \
+       } while (0)
+
+#define dcm_info(fmt, arg...) do { \
+               LOGI(FONT_COLOR_YELLOW"" fmt "" FONT_COLOR_RESET, ##arg); \
+       } while (0)
+
+#define dcm_warn(fmt, arg...) do { \
+               LOGW(FONT_COLOR_GREEN"" fmt "" FONT_COLOR_RESET, ##arg); \
+       } while (0)
+
+#define dcm_error(fmt, arg...) do { \
+               LOGE(FONT_COLOR_RED"" fmt "" FONT_COLOR_RESET, ##arg); \
+       } while (0)
+
+#define dcm_sec_debug(fmt, arg...) do { \
+               SECURE_LOGD(FONT_COLOR_CYAN"" fmt "" FONT_COLOR_RESET, ##arg); \
+       } while (0)
+
+#define dcm_sec_info(fmt, arg...) do { \
+               SECURE_LOGI(FONT_COLOR_YELLOW"" fmt "" FONT_COLOR_RESET, ##arg); \
+       } while (0)
+
+#define dcm_sec_warn(fmt, arg...) do { \
+               SECURE_LOGW(FONT_COLOR_GREEN"" fmt "" FONT_COLOR_RESET, ##arg); \
+       } while (0)
+
+#define dcm_sec_error(fmt, arg...) do { \
+               SECURE_LOGE(FONT_COLOR_RED"" fmt "" FONT_COLOR_RESET , ##arg); \
+       } while (0)
+
+#define dcm_debug_fenter() do { \
+               LOGD(FONT_COLOR_RESET"<Enter>"); \
+       } while (0)
+
+#define dcm_debug_fleave() do { \
+               LOGD(FONT_COLOR_RESET"<Leave>"); \
+       } while (0)
+
+#define dcm_retvm_if(expr, val, fmt, arg...) do { \
+               if (expr) { \
+                       dcm_error(fmt, ##arg); \
+               dcm_error("(%s) -> %s() return", #expr, __FUNCTION__); \
+                       return (val); \
+               } \
+       } while (0)
+
+#define DCM_CHECK_VAL(expr, val)               dcm_retvm_if(!(expr), val , "Invalid parameter, return ERROR code!")
+
+#define DCM_SAFE_FREE(ptr) { if (ptr) {free(ptr); ptr = NULL; } }
+
+#endif /* _DCM_DEBUG_UTILS_H_ */
diff --git a/libdcm-util/include/dcm_image_debug_utils.h b/libdcm-util/include/dcm_image_debug_utils.h
deleted file mode 100755 (executable)
index 6926c40..0000000
+++ /dev/null
@@ -1,108 +0,0 @@
-/*
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-#ifndef _DCM_DEBUG_UTILS_H_
-#define _DCM_DEBUG_UTILS_H_
-
-#include <string.h>
-#include <dlog.h>
-
-#ifdef LOG_TAG
-#undef LOG_TAG
-#endif
-
-#define LOG_TAG "DCM_IMAGE_CODEC"
-
-#define FONT_COLOR_RESET               "\033[0m"
-#define FONT_COLOR_RED                 "\033[31m"
-#define FONT_COLOR_GREEN               "\033[32m"
-#define FONT_COLOR_YELLOW              "\033[33m"
-#define FONT_COLOR_BLUE                "\033[34m"
-#define FONT_COLOR_PURPLE              "\033[35m"
-#define FONT_COLOR_CYAN                "\033[36m"
-#define FONT_COLOR_GRAY                "\033[37m"
-
-#define dcm_debug(fmt, arg...) do { \
-               LOGD(FONT_COLOR_CYAN"" fmt "" FONT_COLOR_RESET, ##arg); \
-       } while (0)
-
-#define dcm_info(fmt, arg...) do { \
-               LOGI(FONT_COLOR_YELLOW"" fmt "" FONT_COLOR_RESET, ##arg); \
-       } while (0)
-
-#define dcm_warn(fmt, arg...) do { \
-               LOGW(FONT_COLOR_GREEN"" fmt "" FONT_COLOR_RESET, ##arg); \
-       } while (0)
-
-#define dcm_error(fmt, arg...) do { \
-               LOGE(FONT_COLOR_RED"" fmt "" FONT_COLOR_RESET, ##arg); \
-       } while (0)
-
-#define dcm_sec_debug(fmt, arg...) do { \
-               SECURE_LOGD(FONT_COLOR_CYAN"" fmt "" FONT_COLOR_RESET, ##arg); \
-       } while (0)
-
-#define dcm_sec_info(fmt, arg...) do { \
-               SECURE_LOGI(FONT_COLOR_YELLOW"" fmt "" FONT_COLOR_RESET, ##arg); \
-       } while (0)
-
-#define dcm_sec_warn(fmt, arg...) do { \
-               SECURE_LOGW(FONT_COLOR_GREEN"" fmt "" FONT_COLOR_RESET, ##arg); \
-       } while (0)
-
-#define dcm_sec_error(fmt, arg...) do { \
-               SECURE_LOGE(FONT_COLOR_RED"" fmt "" FONT_COLOR_RESET , ##arg); \
-       } while (0)
-
-#define dcm_debug_fenter() do { \
-               LOGD(FONT_COLOR_RESET"<Enter>"); \
-       } while (0)
-
-#define dcm_debug_fleave() do { \
-               LOGD(FONT_COLOR_RESET"<Leave>"); \
-       } while (0)
-
-#define dcm_retm_if(expr, fmt, arg...) do { \
-               if (expr) { \
-                       dcm_error(fmt, ##arg); \
-               dcm_error("(%s) -> %s() return", #expr, __FUNCTION__); \
-                       return; \
-               } \
-       } while (0)
-
-#define dcm_retvm_if(expr, val, fmt, arg...) do { \
-               if (expr) { \
-                       dcm_error(fmt, ##arg); \
-               dcm_error("(%s) -> %s() return", #expr, __FUNCTION__); \
-                       return (val); \
-               } \
-       } while (0)
-
-#define ERR_BUF_LENGHT 256
-#define dcm_stderror(fmt) do { \
-               char dcm_stderror_buf[ERR_BUF_LENGHT] = {0, }; \
-               LOGE(fmt" : standard error= [%s]", strerror_r(errno, dcm_stderror_buf, ERR_BUF_LENGHT)); \
-       } while (0)
-
-#define DCM_CHECK_VAL(expr, val)               dcm_retvm_if(!(expr), val , "Invalid parameter, return ERROR code!")
-#define DCM_CHECK_NULL(expr)                   dcm_retvm_if(!(expr), NULL, "Invalid parameter, return NULL!")
-#define DCM_CHECK_FALSE(expr)                  dcm_retvm_if(!(expr), FALSE, "Invalid parameter, return FALSE!")
-#define DCM_CHECK(expr)                                        dcm_retm_if(!(expr), "Invalid parameter, return!")
-
-#define DCM_SAFE_FREE(ptr) { if (ptr) {free(ptr); ptr = NULL; } }
-
-#endif /* _DCM_DEBUG_UTILS_H_ */
index dfd3d68d04c96f700daade527280467cd8c82dc3..45d377bf098107610e8296ffb1408300a8e8df00 100755 (executable)
@@ -1,6 +1,6 @@
 Name:       dcm-service
 Summary:    A media DCM(Digital Contents Management) Service
-Version:    0.1.0
+Version:    0.1.1
 Release:    0
 Group:      Multimedia/Service
 License:    Apache-2.0
@@ -52,7 +52,6 @@ make %{?jobs:-j%jobs}
 #export CFLAGS+=" -Wwrite-strings -Wswitch-default"
 
 %install
-rm -rf %{buildroot}
 %make_install
 
 %post -p /sbin/ldconfig
index 5fcc4c3e3442de9ef69fd75a12a9e53d951a3fd1..4cc2f1f6bac96a0d15ea1eef6c524ebd9e989784 100755 (executable)
 
 #include <stdio.h>
 #include <stdlib.h>
-#include <glib.h>
 #include <string.h>
 #include <unistd.h>
-#include <media-util.h>
-#include <dcm_svc_db.h>
-#include <dcm_svc_type.h>
 #include <uuid/uuid.h>
 
-#include "dcm_svc_debug.h"
+#include <dcm_svc_db.h>
+#include <dcm_svc_debug.h>
 
 static GMutex gMutexLock;
 static MediaDBHandle *db_handle;
index 4496cb94ffa62d50f289189476499d2077afecb4..77ed35bad0e9c0f33ecac8aa38d364e5e1cb92f9 100755 (executable)
  *
  */
 
-#include <unistd.h>
-#include <dirent.h>
 #include <stdlib.h>
-#include <stdio.h>
-#include <stdbool.h>
 #include <string.h>
-#include <sys/stat.h>
-#include <glib.h>
-#include <image_util.h>
 #include <dcm-face.h>
-#include <dcm_image_codec.h>
 #include <dcm_svc_db.h>
-#include <dcm_svc_type.h>
 #include <dcm_svc_debug.h>
-#include "dcm_svc_detect_face.h"
+#include <dcm_svc_detect_face.h>
 
 static dcm_face_h dcm_face_handle = NULL;
 
@@ -83,7 +74,7 @@ void _destroy_face_item(void *data)
        return;
 }
 
-int face_detect_initialize()
+int dcm_face_detect_initialize()
 {
        int ret = MS_MEDIA_ERR_NONE;
 
@@ -96,7 +87,7 @@ int face_detect_initialize()
        return ret;
 }
 
-int face_detect_finalize()
+int dcm_face_detect_finalize()
 {
        int ret = MS_MEDIA_ERR_NONE;
 
@@ -113,7 +104,7 @@ int face_detect_finalize()
        return ret;
 }
 
-int face_detect_process(dcm_svc_item_s *scan_item, dcm_image_info_s *image_info)
+int dcm_face_detect_process(dcm_svc_item_s *scan_item, dcm_image_info_s *image_info)
 {
        dcm_face_item_s *face = NULL;
        int face_area = 0;
index 31c17c61de801633cf3f46901928cd2e519a82fc..eab32c796a9869ecdf23da89e53d88f3a454a260 100755 (executable)
  */
 
 #include <stdlib.h>
-#include <stdio.h>
-#include <stdbool.h>
 #include <string.h>
-#include <glib.h>
 #include <image_util.h>
-#include <dcm_image_codec.h>
 #include <dcm_svc_db.h>
-#include <dcm_svc_type.h>
-#include "dcm_svc_debug.h"
-#include "dcm_svc_extract_color.h"
+#include <dcm_svc_debug.h>
+#include <dcm_svc_extract_color.h>
 
-int color_extract_process(dcm_svc_item_s *scan_item, dcm_image_info_s *image_info)
+int dcm_color_extract_process(dcm_svc_item_s *scan_item, dcm_image_info_s *image_info)
 {
        DCM_CHECK_VAL(scan_item, MS_MEDIA_ERR_INVALID_PARAMETER);
        DCM_CHECK_VAL(image_info, MS_MEDIA_ERR_INVALID_PARAMETER);
index 46fe605d06789d554eda2688145a3fd2ba1a1a05..c2e2ce753f80387360ecf42edaa2cc820c3bc9f2 100755 (executable)
  *
  */
 
-#include <unistd.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
-#include <errno.h>
-#include <glib.h>
 #include <vconf.h>
 #include <img-codec-parser.h>
 
-#include "../libdcm-util/include/dcm_image_codec.h"
 #include <dcm_svc_ipc.h>
-#include <dcm_svc_type.h>
 #include <dcm_svc_internal.h>
 #include <dcm_svc_main.h>
 #include <dcm_svc_db.h>
 
-#include "dcm_svc_debug.h"
-#include "dcm_svc_extract_color.h"
-#include "dcm_svc_detect_face.h"
-
-#define MIME_TYPE_JPEG "image/jpeg"
-#define MIME_TYPE_PNG "image/png"
-#define MIME_TYPE_BMP "image/bmp"
+#include <dcm_svc_debug.h>
+#include <dcm_svc_extract_color.h>
+#include <dcm_svc_detect_face.h>
 
 #define DCM_SVC_SCAN_THREAD_TIMEOUT_SEC 1
 
@@ -274,7 +265,7 @@ int _dcm_scan_process(dcm_svc_item_s *scan_item)
 
        dcm_image_info_s image_info = {0, };
        memset(&image_info, 0, sizeof(dcm_image_info_s));
-       dcm_image_format_e image_format = DCM_IMAGE_FORMAT_I420;
+       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) {
@@ -319,16 +310,16 @@ int _dcm_scan_process(dcm_svc_item_s *scan_item)
                }
 
                if (strcmp(scan_item->mime_type, MIME_TYPE_JPEG) == 0) {
-                       image_format = DCM_IMAGE_FORMAT_RGB;
+                       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_format = DCM_IMAGE_FORMAT_RGBA;
+                       image_info.decode_type = DCM_IMAGE_FORMAT_RGBA;
                } else {
                        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_format, scan_item->mime_type,
+               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) {
@@ -336,19 +327,17 @@ int _dcm_scan_process(dcm_svc_item_s *scan_item)
                        return ret;
                }
 
-               image_info.decode_type = (dcm_image_type_e)image_format;
-
                dcm_debug("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);
 
                /* Process face scan */
-               ret = face_detect_process(scan_item, &image_info);
+               ret = dcm_face_detect_process(scan_item, &image_info);
                if (ret != MS_MEDIA_ERR_NONE)
                        dcm_error("Failed to process face detection! err: %d", ret);
 
 #if 0
                /* Process color extract */
-               ret = color_extract_process(scan_item, &image_info);
+               ret = dcm_color_extract_process(scan_item, &image_info);
                if (ret != MS_MEDIA_ERR_NONE)
                        dcm_error("Failed to process color extraction! err: %d", ret);
 #endif
@@ -494,7 +483,7 @@ int dcm_scan_init(gpointer data)
        _data->g_scan_cancel = FALSE;
        _data->kill_timer_source = NULL;
 
-       face_detect_initialize();
+       dcm_face_detect_initialize();
 
        return MS_MEDIA_ERR_NONE;
 }
@@ -506,7 +495,7 @@ int dcm_scan_finalize(gpointer data)
 
        _dcm_scan_clear_all_items(data);
        _dcm_scan_clear_single_item(data);
-       face_detect_finalize();
+       dcm_face_detect_finalize();
 
        if (_data != NULL)
                free(_data);
@@ -580,8 +569,7 @@ gboolean dcm_scan_read_request(GIOChannel *src, GIOCondition condition, gpointer
        }
 
 DCM_SVC_SCAN_READ_THREAD_RECV_SOCKET_FAILED:
-       if (close(client_sock) < 0)
-               dcm_stderror("close failed");
+       dcm_ipc_close_socket(client_sock);
 
        return TRUE;
 }
@@ -736,7 +724,7 @@ gboolean dcm_scan_thread(void *data)
        g_io_channel_unref(channel);
 
        /* Close the TCP socket */
-       close(socket_fd);
+       dcm_ipc_close_socket(socket_fd);
 
        /* Descrease the reference count of main loop of scan thread */
        g_main_loop_unref(dcm_scan_data->main_loop);
index 8bfd26f5ab17c156e4a87c76bb8dbd89d07eb33c..efd4151d7f39e1a7bb95caf543b6d937e985440b 100755 (executable)
@@ -18,7 +18,6 @@
 #include <unistd.h>
 #include <stdio.h>
 #include <stdlib.h>
-#include <stdbool.h>
 #include <string.h>
 #include <errno.h>
 #include <glib.h>
@@ -28,9 +27,7 @@
 #include <arpa/inet.h>
 
 #include <dcm_svc_ipc.h>
-#include <dcm_svc_type.h>
 #include <dcm_svc_debug.h>
-#include <media-util.h>
 
 static char DCM_IPC_PATH[][100] = {
                        {"/var/run/media-server/dcm_ipc_scanthread.socket"},
@@ -330,6 +327,10 @@ int dcm_ipc_send_complete(ms_dcm_msg_type_e msg_type, const unsigned int count,
 
 int dcm_ipc_close_socket(int socket_fd)
 {
+       if (socket_fd < 0) {
+               dcm_error("The socket has been closed already.");
+               return MS_MEDIA_ERR_NONE;
+       }
        close(socket_fd);
 
        return MS_MEDIA_ERR_NONE;
index b6e15f0f9d6676937143a0390d32dacb5ed00a07..9ad25b46bc5234735561e887aff731f4921e6c8d 100755 (executable)
  */
 
 #include <sys/types.h>
-#include <dirent.h>
-#include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
-#include <stdbool.h>
 #include <glib.h>
 #include <dcm_svc_main.h>
 #include <dcm_svc_ipc.h>
-#include <dcm_svc_type.h>
 #include <dcm_svc_internal.h>
 #include <dcm_svc_debug.h>
-#include <media-util.h>
-
 
 #define DCM_SVC_MAIN_THREAD_TIMEOUT_SEC 1
 
@@ -167,8 +161,7 @@ static void dcm_service_start(gpointer data)
 static void dcm_service_finish(gpointer data)
 {
        dcm_service_s *_data = (dcm_service_s *)data;
-       if (_data != NULL)
-               free(_data);
+       DCM_SAFE_FREE(_data);
 }
 
 gboolean dcm_service_recieve_request(GIOChannel *src, GIOCondition condition, gpointer data)
@@ -235,8 +228,7 @@ gboolean dcm_service_recieve_request(GIOChannel *src, GIOCondition condition, gp
                dcm_debug("createDcmSvcReadSocket, invalid message(%d).", recv_msg.msg_type);
        }
 
-       if (dcm_ipc_close_socket(client_sock) < 0)
-               dcm_stderror("close failed");
+       dcm_ipc_close_socket(client_sock);
 
        return TRUE;
 }
@@ -287,7 +279,7 @@ EXPORT_API int main(int argc, char *argv[])
 
        g_io_channel_shutdown(channel, FALSE, NULL);
        g_io_channel_unref(channel);
-       close(sockfd);
+       dcm_ipc_close_socket(sockfd);
        g_main_loop_unref(dcm_svc_data->main_loop);
 
        dcm_service_finish(dcm_svc_data);