From 4552a22a08fec591faa54954d66600d860974392 Mon Sep 17 00:00:00 2001 From: Jiyong Min Date: Thu, 26 May 2016 10:31:31 +0900 Subject: [PATCH] Add to check face_recognition feature for DCM The face_recognition feature is not enabled, DCM does not support face detection. So it is added to check feature before using DCM thread. Change-Id: I9fb441cc68a08a5c0ed851a4d04bedfae081cb8b Signed-off-by: Jiyong Min --- Makefile.am | 6 ++++-- configure.ac | 5 +++++ packaging/media-server.spec | 1 + src/server/include/media-server-dcm.h | 2 -- src/server/media-server-dcm.c | 35 ------------------------------- src/server/media-server-main.c | 39 ++++++++++++++++++++++++++++++++--- 6 files changed, 46 insertions(+), 42 deletions(-) mode change 100755 => 100644 Makefile.am mode change 100755 => 100644 configure.ac diff --git a/Makefile.am b/Makefile.am old mode 100755 new mode 100644 index 463a742..5b25b6f --- a/Makefile.am +++ b/Makefile.am @@ -107,14 +107,16 @@ media_server_SOURCES = src/common/media-common-utils.c \ media_server_CFLAGS = -I${srcdir}/src/server/include \ $(COMMON_CFLAGS) \ - $(PHONESTATUS_CFLAGS) + $(PHONESTATUS_CFLAGS) \ + $(SYSTEM_INFO_CFLAGS) media_server_CFLAGS += -fPIE media_server_LDFLAGS = -pie media_server_LDADD = $(COMMON_LDADD) \ - $(PHONESTATUS_LIBS) + $(PHONESTATUS_LIBS) \ + $(SYSTEM_INFO_LIBS) ###################################################### #media scanner v1 diff --git a/configure.ac b/configure.ac old mode 100755 new mode 100644 index 076ed3d..373eaca --- a/configure.ac +++ b/configure.ac @@ -123,6 +123,11 @@ PKG_CHECK_MODULES(CYNARA_SESSION, cynara-session) AC_SUBST(CYNARA_SESSION_CFLAGS) AC_SUBST(CYNARA_SESSION_LIBS) +#capi-system-info +PKG_CHECK_MODULES(SYSTEM_INFO, capi-system-info) +AC_SUBST(SYSTEM_INFO_CFLAGS) +AC_SUBST(SYSTEM_INFO_LIBS) + dnl use notification -------------------------------------------------------------------------- AC_ARG_ENABLE(notification, AC_HELP_STRING([--enable-notification], [using notification]), [ diff --git a/packaging/media-server.spec b/packaging/media-server.spec index c01cabb..ebb94cc 100755 --- a/packaging/media-server.spec +++ b/packaging/media-server.spec @@ -25,6 +25,7 @@ BuildRequires: pkgconfig(libsmack) BuildRequires: pkgconfig(libtzplatform-config) BuildRequires: pkgconfig(cynara-client) BuildRequires: pkgconfig(cynara-session) +BuildRequires: pkgconfig(capi-system-info) BuildRequires: gettext-tools %description diff --git a/src/server/include/media-server-dcm.h b/src/server/include/media-server-dcm.h index 1c93a8f..6f8e50c 100755 --- a/src/server/include/media-server-dcm.h +++ b/src/server/include/media-server-dcm.h @@ -22,7 +22,6 @@ #include #include #include -#include #include "media-common-types.h" #include "media-server-ipc.h" @@ -34,7 +33,6 @@ int ms_dcm_get_server_pid(); void ms_dcm_reset_server_status(); gpointer ms_dcm_agent_start_thread(gpointer data); -int ms_dcm_get_config(); #endif /*_MEDIA_SERVER_DCM_H_*/ diff --git a/src/server/media-server-dcm.c b/src/server/media-server-dcm.c index 2af85cf..738ab12 100644 --- a/src/server/media-server-dcm.c +++ b/src/server/media-server-dcm.c @@ -36,12 +36,6 @@ #define LOG_TAG "MEDIA_SERVER_DCM" -#define MS_SOCK_BLOCK_SIZE 512 -#define MS_INI_GET_INT(dict, key, value, default) \ - do { \ - value = iniparser_getint(dict, key, default); \ - MS_DBG("get %s = %d", key, value); \ - } while (0) #define DCM_SERVER_PATH tzplatform_mkpath(TZ_SYS_BIN, "dcm-svc") static GMainLoop *g_dcm_agent_loop = NULL; @@ -558,18 +552,6 @@ gboolean _ms_dcm_agent_read_socket(GIOChannel *src, MS_DBG_ERR("credential information error"); } - if (g_dcm_service_active != 1) { - MS_DBG_ERR("dcm is not activated!"); - dcmMsg res_msg; - memset((void *)&res_msg, 0, sizeof(res_msg)); - if (send(client_sock, &res_msg, sizeof(dcmMsg), 0) != sizeof(dcmMsg)) - MS_DBG_STRERROR("sendto failed"); - else - MS_DBG("Sent Refuse msg from %s", recv_msg->msg); - close(client_sock); - return FALSE; - } - if (getuid() != cr.uid) recv_msg->uid = cr.uid; @@ -642,23 +624,6 @@ gboolean _ms_dcm_agent_prepare_tcp_socket(int *sock_fd, unsigned short serv_port return TRUE; } -int ms_dcm_get_config() -{ - dictionary *dict = NULL; - - dict = iniparser_load(MS_INI_DEFAULT_PATH); - if (!dict) { - MS_DBG_ERR("%s load failed", MS_INI_DEFAULT_PATH); - return -1; - } - - MS_INI_GET_INT(dict, "media-content-config:dcm_activation", g_dcm_service_active, 0); - MS_DBG("Thumb-server activation level = %d", g_dcm_service_active); - - iniparser_freedict(dict); - return 0; -} - gpointer ms_dcm_agent_start_thread(gpointer data) { int sockfd = -1; diff --git a/src/server/media-server-main.c b/src/server/media-server-main.c index ed3d5bf..a313ef8 100644 --- a/src/server/media-server-main.c +++ b/src/server/media-server-main.c @@ -28,6 +28,8 @@ #include #include #include +#include +#include #include "media-util.h" #include "media-common-utils.h" @@ -56,6 +58,7 @@ static void __ms_remove_request_receiver(GIOChannel *channel); static void __ms_add_request_receiver(GMainLoop *mainloop, GIOChannel **channel); static int __ms_check_mmc_status(void); static int __ms_check_usb_status(void); +static bool __ms_is_dcm_supported(void); static char *priv_lang = NULL; @@ -246,6 +249,7 @@ int main(int argc, char **argv) GThread *thumb_thread = NULL; GThread *dcm_thread = NULL; GIOChannel *channel = NULL; + bool is_dcm_supported = __ms_is_dcm_supported(); power_off = FALSE; @@ -269,7 +273,8 @@ int main(int argc, char **argv) /*create each threads*/ db_thread = g_thread_new("db_thread", (GThreadFunc)ms_db_thread, NULL); thumb_thread = g_thread_new("thumb_agent_thread", (GThreadFunc)ms_thumb_agent_start_thread, NULL); - dcm_thread = g_thread_new("dcm_agent_thread", (GThreadFunc)ms_dcm_agent_start_thread, NULL); + if (is_dcm_supported) + dcm_thread = g_thread_new("dcm_agent_thread", (GThreadFunc)ms_dcm_agent_start_thread, NULL); /*clear previous data of sdcard on media database and check db status for updating*/ while (!ms_db_get_thread_status()) { @@ -285,7 +290,6 @@ int main(int argc, char **argv) /*Read ini file */ ms_thumb_get_config(); - ms_dcm_get_config(); MS_DBG_ERR("*** Media Server is running ***"); @@ -293,7 +297,8 @@ int main(int argc, char **argv) g_thread_join(db_thread); g_thread_join(thumb_thread); - g_thread_join(dcm_thread); + if (is_dcm_supported) + g_thread_join(dcm_thread); ms_cynara_finish(); @@ -479,3 +484,31 @@ static int __ms_check_usb_status(void) return MS_MEDIA_ERR_NONE; } +static bool __ms_is_dcm_supported() +{ + bool isFaceRecognitionSupported = FALSE; /* face_recognition feature supported */ + int dcm_service_mode = -1; /* media-content-config:dcm_activation */ + + const int nRetVal = system_info_get_platform_bool("http://tizen.org/feature/vision.face_recognition", &isFaceRecognitionSupported); + + if (nRetVal != SYSTEM_INFO_ERROR_NONE) { + MS_DBG_ERR("SYSTEM_INFO_ERROR: vision.face_recognition [%d]", nRetVal); + return FALSE; + } + + dictionary *dict = NULL; + + dict = iniparser_load(MS_INI_DEFAULT_PATH); + if (!dict) { + MS_DBG_ERR("%s load failed", MS_INI_DEFAULT_PATH); + return -1; + } + + dcm_service_mode = iniparser_getint(dict, "media-content-config:dcm_activation", 0); + MS_DBG("Dcm-service activation level = %d", dcm_service_mode); + + iniparser_freedict(dict); + + return (isFaceRecognitionSupported && (dcm_service_mode == 1)) ? TRUE : FALSE; +} + -- 2.7.4