remove all dcm related code 90/303990/7 accepted/tizen/unified/20240119.154749
authorhjkim <backto.kim@samsung.com>
Tue, 9 Jan 2024 02:24:46 +0000 (11:24 +0900)
committerhjkim <backto.kim@samsung.com>
Thu, 18 Jan 2024 06:28:20 +0000 (15:28 +0900)
face detection(dcm) related APIs are deprecated in Tizen 8.0.
However, to reduce memory usage on the media server, all dcm related code is removed from the media server in advance.

Change-Id: I96f56e97cda78a98512cb7807f3a363a0f38bf9c

12 files changed:
Makefile.am
lib/include/media-server-ipc.h
lib/include/media-util-dcm.h [deleted file]
lib/include/media-util.h
lib/media-util-dcm.c [deleted file]
lib/media-util-ipc.c
media_content_config.ini
media_content_config_product.ini
packaging/media-server.spec
src/server/include/media-server-dcm.h [deleted file]
src/server/media-server-dcm.c [deleted file]
src/server/media-server-main.c

index 5c32d57..509dc7b 100644 (file)
@@ -60,8 +60,7 @@ libmedia_utils_la_SOURCES = lib/media-util-noti.c \
                             lib/media-util-db.c \
                             lib/media-util-register.c \
                             lib/media-util-cynara.c \
-                            lib/media-util-user.c \
-                            lib/media-util-dcm.c
+                            lib/media-util-user.c
 
 libmedia_utils_la_CFLAGS = -I${srcdir}/lib/include \
                            -D_FILE_OFFSET_BITS=64 \
@@ -109,7 +108,6 @@ media_server_SOURCES = src/common/media-common-utils.c \
                        src/server/media-server-socket.c \
                        src/server/media-server-scanner.c \
                       src/server/media-server-device-block.c \
-                       src/server/media-server-dcm.c \
                        src/server/media-server-main.c
 
 if USE_PRODUCT_TV
@@ -229,5 +227,4 @@ includeheaders_HEADERS = lib/include/media-util-noti.h \
                          lib/include/media-util-cynara.h \
                          lib/include/media-util.h \
                          lib/include/media-server-ipc.h \
-                         lib/include/media-util-user.h \
-                         lib/include/media-util-dcm.h
+                         lib/include/media-util-user.h
index 4454824..d97b10a 100644 (file)
 
 #define MS_TIMEOUT_SEC_10                                      10              /**< Response from Server time out */
 #define MS_TIMEOUT_SEC_20                      20              /**< Response from Media server time out */
-#define MS_TIMEOUT_SEC_60                      60              /**< Response from DCM daemon time out */
-
 
 typedef enum {
        MS_SCAN_DAEMON_PORT = 0,                /**< Port of communication between scanner and server */
        MS_SCANNER_PORT,                                /**< Directory Scanner */
        MS_DB_UPDATE_PORT,                      /**< Media DB Update */
-       MS_DCM_CREATOR_PORT,                    /**< Port of DCM service thread. Receive DCM extract msg from client */
-       MS_DCM_COMM_PORT,                       /**< Port of communication between DCM service thread and DCM daemon */
-       MS_DCM_DAEMON_PORT,                     /**< Port of DCM daemon. Receive DCM extract msg from DCM service thread */
        MS_PORT_MAX,
 } ms_msg_port_type_e;
 
@@ -76,20 +71,4 @@ typedef struct {
        int noti_type;
 } ms_comm_msg_s;
 
-typedef struct {
-       int msg_type;
-       int pid;
-       uid_t uid;
-       char msg[MAX_FILEPATH_LEN];
-       int result;
-} dcmMsg;
-
-typedef enum {
-       DCM_MSG_REQUEST_MEDIA,                  /**< request single media extracting. msg from media server to dcm server*/
-       DCM_MSG_REQUEST_CANCEL_FACE,    /**< request cancel single media extracting. msg from media server to dcm server*/
-       DCM_MSG_REQUEST_KILL_SERVER,            /**< request dcm server terminating. msg from media server to dcm server*/
-       DCM_MSG_SERVER_READY,                   /**< dcm server is ready. msg from dcm server to media server*/
-       DCM_MSG_MAX,
-} ms_dcm_msg_type_e;
-
 #endif /*_MEDIA_SERVER_IPC_H_*/
diff --git a/lib/include/media-util-dcm.h b/lib/include/media-util-dcm.h
deleted file mode 100644 (file)
index ca1b4a9..0000000
+++ /dev/null
@@ -1,36 +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 _MEDIA_UTIL_DCM_H_
-#define _MEDIA_UTIL_DCM_H_
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#include <sys/types.h>
-
-typedef int (*FaceFunc) (int error_code, int count, void* data);
-
-int dcm_request_extract_face_async(const unsigned int request_id, const char *path, FaceFunc func, void *user_data, uid_t uid);
-int dcm_request_cancel_face(const unsigned int request_id);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* _MEDIA_UTIL_DCM_H_ */
index afe33ce..4d41eec 100644 (file)
@@ -27,7 +27,6 @@
 #include <media-util-noti.h>
 #include <media-util-ipc.h>
 #include <media-util-cynara.h>
-#include <media-util-dcm.h>
 #include <media-util-user.h>
 
 #include <tzplatform_config.h>
diff --git a/lib/media-util-dcm.c b/lib/media-util-dcm.c
deleted file mode 100644 (file)
index 65eca72..0000000
+++ /dev/null
@@ -1,309 +0,0 @@
-/*
- * Media Utility for DCM
- *
- * 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.
- *
- */
-
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <glib.h>
-#include <unistd.h>
-#include <media-server-ipc.h>
-#include <media-util.h>
-#include <media-util-internal.h>
-#include <media-util-dbg.h>
-#include <tzplatform_config.h>
-
-static GQueue *g_manage_queue = NULL;
-
-typedef struct {
-       FaceFunc func;
-       void *user_data;
-} faceUserData;
-
-typedef struct {
-       GIOChannel *channel;
-       int msg_type;
-       gboolean isCanceled;
-       gboolean isRequested;
-       int request_id;
-       int source_id;
-       uid_t uid;
-       char *path;
-       faceUserData *userData;
-} dcmReq;
-
-extern char MEDIA_IPC_PATH[][70];
-
-static int __media_dcm_send_request(void);
-
-static gboolean __media_dcm_is_canceled(void)
-{
-       dcmReq *req = (dcmReq *)g_queue_peek_head(g_manage_queue);
-
-       if (!req)
-               return TRUE;
-
-       return req->isCanceled;
-}
-
-static void __media_dcm_pop_data(void)
-{
-       int len = 0;
-
-       if (!g_manage_queue)
-               return;
-
-       dcmReq *req = (dcmReq *)g_queue_pop_head(g_manage_queue);
-       if (req) {
-               GSource *source_id = g_main_context_find_source_by_id(g_main_context_get_thread_default(), req->source_id);
-
-               g_io_channel_shutdown(req->channel, TRUE, NULL);
-               g_io_channel_unref(req->channel);
-
-               if (source_id)
-                       g_source_destroy(source_id);
-
-               g_free(req->path);
-               g_free(req->userData);
-               g_free(req);
-       }
-
-       len = g_queue_get_length(g_manage_queue);
-
-       if (len > 0)
-               __media_dcm_send_request();
-}
-
-static int __media_dcm_cancel_data(int request_id)
-{
-       int len = 0, i = 0;
-
-       MSAPI_RETV_IF(!g_manage_queue, MS_MEDIA_ERR_INTERNAL);
-
-       len = g_queue_get_length(g_manage_queue);
-       for (i = 0; i < len; i++) {
-               dcmReq *req = (dcmReq *)g_queue_peek_nth(g_manage_queue, i);
-               if (!req)
-                       continue;
-
-               if (req->request_id == request_id) {
-                       if (req->isRequested) {
-                               req->isCanceled = true;
-                       } else {
-                               g_queue_pop_nth(g_manage_queue, i);
-                               g_free(req->path);
-                               g_free(req->userData);
-                               g_free(req);
-                       }
-                       return MS_MEDIA_ERR_NONE;
-               }
-       }
-
-       MSAPI_DBG_STRERROR("item not found");
-
-       return MS_MEDIA_ERR_INTERNAL;
-}
-
-static gboolean __media_dcm_write_socket(GIOChannel *src, GIOCondition condition, gpointer data)
-{
-       dcmMsg recv_msg;
-       faceUserData *user_data = NULL;
-       int sock = 0;
-
-       memset((void *)&recv_msg, 0, sizeof(dcmMsg));
-       sock = g_io_channel_unix_get_fd(src);
-
-       MSAPI_DBG("Receive msg from dcm server : [%d]", sock);
-
-       if ((recv(sock, &recv_msg, sizeof(dcmMsg), 0)) < 0) {
-               MSAPI_DBG_STRERROR("recv failed ");
-               if (strlen(recv_msg.msg) > 0 && strlen(recv_msg.msg) < MAX_FILEPATH_LEN)
-                       __media_dcm_pop_data();
-               else
-                       MSAPI_DBG_ERR("origin path size is wrong.");
-
-               return G_SOURCE_REMOVE;
-       }
-
-       if (strlen(recv_msg.msg) == 0 || strlen(recv_msg.msg) >= MAX_FILEPATH_LEN) {
-               MSAPI_DBG_ERR("msg size is invalid");
-               return G_SOURCE_REMOVE;
-       }
-
-       MSAPI_DBG("Completed. msg_type[%d], msg[%.*s], result[%d]", recv_msg.msg_type, MAX_FILEPATH_LEN, recv_msg.msg, recv_msg.result);
-
-       if (__media_dcm_is_canceled() || !data)
-               goto NEXT;
-
-       MSAPI_DBG_INFO("Call the user callback");
-       user_data = (faceUserData*)data;
-       if (user_data->func) {
-               /*return value, face count, user_data*/
-               if (recv_msg.result < 0)
-                       user_data->func(recv_msg.result, 0, user_data->user_data);
-               else
-                       user_data->func(MS_MEDIA_ERR_NONE, recv_msg.result, user_data->user_data);
-       }
-
-NEXT:
-       __media_dcm_pop_data();
-       MSAPI_DBG("Done");
-
-       return G_SOURCE_REMOVE;
-}
-
-static int __media_dcm_send_request(void)
-{
-       int ret = MS_MEDIA_ERR_NONE;
-       int sock = -1;
-       struct sockaddr_un serv_addr;
-       dcmReq *req_manager = NULL;
-
-       ret = ms_ipc_create_client_socket(MS_TIMEOUT_SEC_10, &sock);
-       MSAPI_RETVM_IF(ret != MS_MEDIA_ERR_NONE, ret, "ms_ipc_create_client_socket failed");
-
-       memset(&serv_addr, 0, sizeof(serv_addr));
-       serv_addr.sun_family = AF_UNIX;
-       SAFE_STRLCPY(serv_addr.sun_path, tzplatform_mkpath(TZ_SYS_RUN, MEDIA_IPC_PATH[MS_DCM_CREATOR_PORT]), sizeof(serv_addr.sun_path));
-
-       GIOChannel *channel = NULL;
-       channel = g_io_channel_unix_new(sock);
-       int source_id = -1;
-
-       /* Connecting to the dcm service */
-       if (connect(sock, (struct sockaddr*)&serv_addr, sizeof(serv_addr)) < 0) {
-               MSAPI_DBG_STRERROR("connect");
-               g_io_channel_shutdown(channel, TRUE, NULL);
-               g_io_channel_unref(channel);
-               close(sock);
-               return MS_MEDIA_ERR_IPC;
-       }
-
-       req_manager = (dcmReq *)g_queue_peek_head(g_manage_queue);
-
-       if (req_manager == NULL) {
-               MSAPI_DBG_ERR("queue peek fail");
-               g_io_channel_shutdown(channel, TRUE, NULL);
-               g_io_channel_unref(channel);
-               close(sock);
-               return MS_MEDIA_ERR_INVALID_PARAMETER;
-       }
-
-       GSource *source = NULL;
-       source = g_io_create_watch(channel, G_IO_IN);
-       g_source_set_callback(source, (GSourceFunc)__media_dcm_write_socket, req_manager->userData, NULL);
-       source_id = g_source_attach(source, g_main_context_get_thread_default());
-
-       dcmMsg req_msg;
-
-       memset((void *)&req_msg, 0, sizeof(dcmMsg));
-
-       req_msg.pid = getpid();
-       req_msg.msg_type = req_manager->msg_type;
-       req_msg.uid = req_manager->uid;
-       SAFE_STRLCPY(req_msg.msg, req_manager->path, sizeof(req_msg.msg));
-
-       if (send(sock, &req_msg, sizeof(req_msg), 0) != sizeof(req_msg)) {
-               MSAPI_DBG_STRERROR("send failed");
-
-               g_source_destroy(g_main_context_find_source_by_id(g_main_context_get_thread_default(), source_id));
-               g_io_channel_shutdown(channel, TRUE, NULL);
-               g_io_channel_unref(channel);
-               close(sock);
-               return MS_MEDIA_ERR_IPC;
-       }
-
-       MSAPI_DBG("Sending msg to dcm service (in media-server) is successful");
-
-       if (req_manager->msg_type == DCM_MSG_REQUEST_MEDIA) {
-               req_manager->channel = channel;
-               req_manager->source_id = source_id;
-               req_manager->isRequested = true;
-       }
-
-       return ret;
-}
-
-static int __media_dcm_request_async(int msg_type, const unsigned int request_id, const char *path, faceUserData *userData, uid_t uid)
-{
-       dcmReq *dcm_req = NULL;
-
-       if (msg_type == DCM_MSG_REQUEST_CANCEL_FACE)
-               return __media_dcm_cancel_data(request_id);
-
-       if (!g_manage_queue)
-               g_manage_queue = g_queue_new();
-
-       dcm_req = g_new0(dcmReq, 1);
-
-       dcm_req->msg_type = msg_type;
-       dcm_req->path = g_strdup(path);
-       dcm_req->userData = userData;
-       dcm_req->isCanceled = FALSE;
-       dcm_req->request_id = request_id;
-       dcm_req->uid = uid;
-
-       MSAPI_DBG("Enqueue");
-       g_queue_push_tail(g_manage_queue, (gpointer)dcm_req);
-
-       /* directly request at first time */
-       if (g_queue_get_length(g_manage_queue) == 1)
-               return __media_dcm_send_request();
-
-       return MS_MEDIA_ERR_NONE;
-}
-
-int dcm_request_extract_face_async(const unsigned int request_id, const char *path, FaceFunc func, void *user_data, uid_t uid)
-{
-       int exist = -1;
-       ms_user_storage_type_e storage_type = -1;
-       faceUserData *userData = NULL;
-
-       MSAPI_RETVM_IF(!MS_STRING_VALID(path), MS_MEDIA_ERR_INVALID_PARAMETER, "Invalid path");
-
-       MSAPI_DBG_SLOG("Path : %s", path);
-
-       exist = open(path, O_RDONLY);
-       if (exist < 0) {
-               MSAPI_DBG_ERR("The path(%s) doesn't exist.", path);
-               if (errno == EACCES || errno == EPERM)
-                       return  MS_MEDIA_ERR_PERMISSION_DENIED;
-               else
-                       return MS_MEDIA_ERR_INVALID_PARAMETER;
-       }
-       close(exist);
-
-       ms_user_get_storage_type(uid, path, &storage_type);
-
-       if ((storage_type != MS_USER_STORAGE_INTERNAL) && (storage_type != MS_USER_STORAGE_EXTERNAL)) {
-               MSAPI_DBG_ERR("The path(%s) is invalid", path);
-               return MS_MEDIA_ERR_INVALID_PARAMETER;
-       }
-
-       userData = g_new0(faceUserData, 1);
-
-       userData->func = (FaceFunc)func;
-       userData->user_data = user_data;
-
-       /* Request for image file to the daemon "Dcm generator" */
-       return __media_dcm_request_async(DCM_MSG_REQUEST_MEDIA, request_id, path, userData, uid);
-}
-
-int dcm_request_cancel_face(const unsigned int request_id)
-{
-       return __media_dcm_request_async(DCM_MSG_REQUEST_CANCEL_FACE, request_id, NULL, NULL, 0);
-}
index 5d36f0f..5c874c0 100644 (file)
@@ -30,9 +30,6 @@ char MEDIA_IPC_PATH[][70] = {
        {"media-server/media_ipc_scandaemon.socket"},
        {"media-server/media_ipc_scanner.socket"},
        {"media-server/media_ipc_dbupdate.socket"},
-       {"media-server/media_ipc_dcmcreator.socket"},
-       {"media-server/media_ipc_dcmcomm.socket"},
-       {"media-server/media_ipc_dcmdaemon.socket"},
 };
 
 int ms_ipc_create_client_socket(int timeout_sec, int *sock_fd)
index da466d4..c0ca2df 100644 (file)
@@ -1,10 +1,4 @@
-;dcm_activation level
-; 0 = Deny all requests related dcm (never activate dcm service)
-; 1 = Allow all requests related dcm
-
 [media-content-config]
-dcm_activation=1
-
 ;scanner_type
 ; 0 = extract all data at once
 ; 1 = 2 step scanning
index 1e34e02..95614b5 100644 (file)
@@ -1,10 +1,4 @@
-;dcm_activation level
-; 0 = Deny all requests related dcm (never activate dcm service)
-; 1 = Allow all requests related dcm
-
 [media-content-config]
-dcm_activation=1
-
 ;scanner_type
 ; 0 = extract all data at once
 ; 1 = 2 step scanning
index add2546..674fb6f 100644 (file)
@@ -1,6 +1,6 @@
 Name:       media-server
 Summary:    A server for media content management
-Version:    0.4.31
+Version:    0.5.0
 Release:    0
 Group:      Multimedia/Service
 License:    Apache-2.0
diff --git a/src/server/include/media-server-dcm.h b/src/server/include/media-server-dcm.h
deleted file mode 100644 (file)
index e7ed30b..0000000
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * media-server-dcm
- *
- * 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.
- *
- */
-
-#include <glib.h>
-
-#ifndef _MEDIA_SERVER_DCM_H_
-#define _MEDIA_SERVER_DCM_H_
-
-void ms_dcm_finalize(void);
-int ms_dcm_get_server_pid(void);
-void ms_dcm_reset_server_status(void);
-gpointer ms_dcm_agent_start_thread(gpointer data);
-
-#endif /*_MEDIA_SERVER_DCM_H_*/
diff --git a/src/server/media-server-dcm.c b/src/server/media-server-dcm.c
deleted file mode 100644 (file)
index 99424b8..0000000
+++ /dev/null
@@ -1,481 +0,0 @@
-/*
- * media-server-dcm
- *
- * 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.
- *
- */
-
-#include "media-util.h"
-#include "media-common-types.h"
-#include "media-common-system.h"
-#include "media-server-dbg.h"
-
-#ifdef LOG_TAG
-#undef LOG_TAG
-#endif
-
-#define LOG_TAG "MEDIA_SERVER_DCM"
-
-#define DCM_SERVER_PATH tzplatform_mkpath(TZ_SYS_BIN, "dcm-svc")
-#define MAX_DCM_REQUEST 100
-
-static GMainLoop *g_dcm_agent_loop = NULL;
-static gboolean g_folk_dcm_server = FALSE;
-static gboolean g_shutdowning_dcm_server = FALSE;
-static int g_dcm_comm_sock = -1;
-static int g_dcm_timer_id = 0;
-static int g_dcm_service_pid = 0;
-static guint g_dcm_source_id;
-
-static GQueue *g_dcm_request_queue = NULL;
-static gboolean g_dcm_queue_work = FALSE;
-
-typedef struct {
-       int client_sock;
-       dcmMsg *recv_msg;
-} dcmRequest;
-
-extern char MEDIA_IPC_PATH[][70];
-
-void ms_dcm_finalize(void)
-{
-       if (g_dcm_comm_sock != -1) {
-               close(g_dcm_comm_sock);
-               g_dcm_comm_sock = -1;
-       }
-
-       if (g_main_loop_is_running(g_dcm_agent_loop)) {
-               g_source_destroy(g_main_context_find_source_by_id(g_main_context_get_thread_default(), g_dcm_source_id));
-               g_main_loop_quit(g_dcm_agent_loop);
-       }
-}
-
-int ms_dcm_get_server_pid(void)
-{
-       return g_dcm_service_pid;
-}
-
-void ms_dcm_reset_server_status(void)
-{
-       g_folk_dcm_server = FALSE;
-       g_shutdowning_dcm_server = FALSE;
-
-       if (g_dcm_timer_id > 0) {
-               g_source_destroy(g_main_context_find_source_by_id(g_main_context_get_thread_default(), g_dcm_timer_id));
-               g_dcm_timer_id = 0;
-       }
-
-       g_dcm_service_pid = 0;
-}
-
-static gboolean __ms_dcm_agent_prepare_tcp_socket(int *sock_fd, unsigned short serv_port)
-{
-       if (ms_ipc_create_server_socket(serv_port, sock_fd) < 0) {
-               MS_DBG_ERR("_ms_dcm_create_socket failed");
-               return FALSE;
-       }
-
-       return TRUE;
-}
-
-static int __ms_dcm_recv_msg(int sock, dcmMsg *msg)
-{
-       int recv_msg_len = 0;
-       unsigned char *buf = g_malloc0(sizeof(dcmMsg));
-
-       if ((recv_msg_len = recv(sock, buf, sizeof(dcmMsg), 0)) < 0) {
-               MS_DBG_STRERROR("recv failed");
-               g_free(buf);
-               return MS_MEDIA_ERR_IPC;
-       }
-       memcpy(msg, buf, sizeof(dcmMsg));
-
-       if (strlen(msg->msg) >= MAX_FILEPATH_LEN) {
-               MS_DBG_ERR("msg size is invalid[%zu]", strlen(msg->msg));
-               g_free(buf);
-               return MS_MEDIA_ERR_IPC;
-       }
-
-       g_free(buf);
-
-       MS_DBG("msg_type [%d]", msg->msg_type);
-
-       return MS_MEDIA_ERR_NONE;
-}
-
-static gboolean __ms_dcm_agent_recv_msg_from_server(void)
-{
-       struct sockaddr_un serv_addr;
-       socklen_t serv_addr_len;
-       int sockfd = -1;
-       int retry = 10;
-
-       if (g_dcm_comm_sock <= 0)
-               __ms_dcm_agent_prepare_tcp_socket(&g_dcm_comm_sock, MS_DCM_COMM_PORT);
-
-       serv_addr_len = (socklen_t)sizeof(serv_addr);
-
-       if ((sockfd = accept(g_dcm_comm_sock, (struct sockaddr*)&serv_addr, &serv_addr_len)) < 0) {
-               MS_DBG_STRERROR("accept failed");
-               return FALSE;
-       }
-
-       dcmMsg recv_msg;
-       int recv_result = 0;
-
-RETRY:
-       recv_result = __ms_dcm_recv_msg(sockfd, &recv_msg);
-       if (recv_result != MS_MEDIA_ERR_NONE) {
-               MS_DBG_STRERROR("__ms_dcm_recv_msg failed");
-               close(sockfd);
-               return FALSE;
-       }
-
-       if (recv_msg.msg_type == DCM_MSG_SERVER_READY) {
-               MS_DBG_INFO("DCM service is ready");
-       } else {
-               MS_DBG("DCM service is not ready retry=%d", retry);
-               if (retry > 0) {
-                       retry--;
-                       usleep(200000);
-                       goto RETRY;
-               }
-       }
-
-       MS_DBG("msg_type [%d]", recv_msg.msg_type);
-
-       close(sockfd);
-
-       return TRUE;
-}
-
-static gboolean __ms_dcm_agent_execute_server(void)
-{
-       int pid;
-       pid = fork();
-
-       if (pid < 0) {
-               return FALSE;
-       } else if (pid == 0) {
-               execl(DCM_SERVER_PATH, "dcm-svc", NULL);
-       } else {
-               MS_DBG("Child process for dcm is %d", pid);
-               g_folk_dcm_server = TRUE;
-       }
-
-       g_dcm_service_pid = pid;
-
-       if (!__ms_dcm_agent_recv_msg_from_server()) {
-               MS_DBG_ERR("_ms_dcm_agent_recv_msg_from_server is failed");
-               return FALSE;
-       }
-
-       return TRUE;
-}
-
-static gboolean __ms_dcm_agent_send_msg_to_dcm_server(dcmMsg *recv_msg, dcmMsg *res_msg)
-{
-       int sock;
-       struct sockaddr_un serv_addr;
-       int send_str_len = strlen(recv_msg->msg);
-
-       MS_DBG_RETVM_IF(send_str_len >= MAX_FILEPATH_LEN, FALSE, "Invalid msg");
-
-       if (ms_ipc_create_client_socket(MS_TIMEOUT_SEC_60, &sock) < 0) {
-               MS_DBG_ERR("ms_ipc_create_client_socket failed");
-               return FALSE;
-       }
-
-       if (recv_msg->uid == 0)
-               ms_sys_get_uid(&(recv_msg->uid));
-       memset(&serv_addr, 0, sizeof(serv_addr));
-       serv_addr.sun_family = AF_UNIX;
-       SAFE_STRLCPY(serv_addr.sun_path, tzplatform_mkpath(TZ_SYS_RUN, MEDIA_IPC_PATH[MS_DCM_DAEMON_PORT]), sizeof(serv_addr.sun_path));
-
-       /* Connecting to the DCM service */
-       if (connect(sock, (struct sockaddr*)&serv_addr, sizeof(serv_addr)) < 0) {
-               MS_DBG_STRERROR("connect failed");
-               goto ERROR;
-       }
-
-       if (send(sock, recv_msg, sizeof(dcmMsg), 0) != sizeof(dcmMsg)) {
-               MS_DBG_STRERROR("send failed");
-               goto ERROR;
-       }
-
-       MS_DBG_SLOG("Sending msg to DCM daemon is successful. msg_type [%d]", recv_msg->msg_type);
-
-       if (__ms_dcm_recv_msg(sock, res_msg) < 0)
-               goto ERROR;
-
-       MS_DBG_SLOG("recv %.*s(%d, %d) from DCM daemon is successful", MAX_FILEPATH_LEN, res_msg->msg, res_msg->msg_type, res_msg->result);
-       close(sock);
-
-       return TRUE;
-
-ERROR:
-       close(sock);
-
-       return G_SOURCE_REMOVE;
-}
-
-static gboolean __ms_dcm_agent_timer(gpointer data)
-{
-       g_dcm_timer_id = 0;
-       MS_DBG("Timer is called.. Now killing dcm-service[%d]", g_dcm_service_pid);
-
-       if (g_dcm_service_pid > 0) {
-               /* Kill DCM service */
-               dcmMsg msg;
-               dcmMsg recv_msg;
-               memset((void *)&msg, 0, sizeof(msg));
-               memset((void *)&recv_msg, 0, sizeof(recv_msg));
-
-               msg.msg_type = DCM_MSG_REQUEST_KILL_SERVER;
-               msg.msg[0] = '\0';
-
-               /* Command Kill to DCM service */
-               g_shutdowning_dcm_server = TRUE;
-               if (!__ms_dcm_agent_send_msg_to_dcm_server(&msg, &recv_msg)) {
-                       MS_DBG_ERR("__ms_dcm_agent_send_msg_to_dcm_server is failed");
-                       g_shutdowning_dcm_server = FALSE;
-               }
-               usleep(200000);
-       } else {
-               MS_DBG_ERR("g_dcm_service_pid is %d. Maybe there's problem in dcm-service", g_dcm_service_pid);
-       }
-
-       return FALSE;
-}
-
-static void __ms_dcm_create_timer(void)
-{
-       if (g_dcm_timer_id > 0)
-               g_source_destroy(g_main_context_find_source_by_id(g_main_context_get_thread_default(), g_dcm_timer_id));
-
-       GSource *timer_src = g_timeout_source_new_seconds(MS_TIMEOUT_SEC_20);
-       g_source_set_callback(timer_src, __ms_dcm_agent_timer, NULL, NULL);
-       g_dcm_timer_id = g_source_attach(timer_src, g_main_context_get_thread_default());
-       g_source_unref(timer_src);
-}
-
-static gboolean __ms_dcm_request_to_server(gpointer data)
-{
-       guint req_len = 0;
-
-       req_len = g_queue_get_length(g_dcm_request_queue);
-
-       MS_DBG("Queue length : %d", req_len);
-
-       if (req_len == 0) {
-               MS_DBG("There is no request job in the queue");
-               g_dcm_queue_work = FALSE;
-               return G_SOURCE_REMOVE;
-       }
-
-       if (g_shutdowning_dcm_server) {
-               MS_DBG_ERR("DCM service is shutting down... wait for complete");
-               usleep(10000);
-               return G_SOURCE_CONTINUE;
-       }
-
-       if (!g_folk_dcm_server) {
-               if (g_dcm_service_pid <= 0) { /* This logic is temporary */
-                       MS_DBG_WARN("DCM service is not running.. so start it");
-                       if (!__ms_dcm_agent_execute_server()) {
-                               MS_DBG_ERR("_ms_dcm_agent_execute_server is failed");
-                               g_dcm_queue_work = FALSE;
-                               return G_SOURCE_REMOVE;
-                       }
-
-                       __ms_dcm_create_timer();
-               }
-       } else {
-               /* Timer is re-created*/
-               __ms_dcm_create_timer();
-       }
-
-       dcmRequest *req = NULL;
-       req = (dcmRequest *)g_queue_pop_head(g_dcm_request_queue);
-       MS_DBG_RETVM_IF(!req, TRUE, "Failed to get a request job from queue");
-
-       int client_sock = -1;
-       dcmMsg *recv_msg = NULL;
-       dcmMsg res_msg;
-       memset((void *)&res_msg, 0, sizeof(res_msg));
-
-       client_sock = req->client_sock;
-       recv_msg = req->recv_msg;
-
-       if (client_sock <= 0 || !recv_msg) {
-               MS_DBG_ERR("client sock is below 0 or recv msg is NULL");
-               g_free(req->recv_msg);
-               g_free(req);
-               return G_SOURCE_CONTINUE;
-       }
-
-       if (!__ms_dcm_agent_send_msg_to_dcm_server(recv_msg, &res_msg)) {
-               MS_DBG_ERR("__ms_dcm_agent_send_msg_to_dcm_server is failed");
-
-               dcmMsg res_msg;
-               memset((void *)&res_msg, 0, sizeof(res_msg));
-
-               res_msg.msg_type = recv_msg->msg_type;
-               if (strlen(recv_msg->msg) > 0)
-                       SAFE_STRLCPY(res_msg.msg, recv_msg->msg, sizeof(res_msg.msg));
-               res_msg.result = recv_msg->result;
-
-               if (send(client_sock, &res_msg, sizeof(res_msg), 0) != sizeof(res_msg))
-                       MS_DBG_STRERROR("sendto failed");
-               else
-                       MS_DBG("Sent Refuse msg from %.*s", MAX_FILEPATH_LEN, recv_msg->msg);
-
-               close(client_sock);
-
-               g_free(req->recv_msg);
-               g_free(req);
-
-               return G_SOURCE_CONTINUE;
-       }
-
-       SAFE_STRLCPY(res_msg.msg, recv_msg->msg, sizeof(res_msg.msg));
-
-       if (send(client_sock, &res_msg, sizeof(res_msg), 0) != sizeof(res_msg))
-               MS_DBG_STRERROR("sendto failed");
-
-       close(client_sock);
-       g_free(req->recv_msg);
-       g_free(req);
-
-       return G_SOURCE_CONTINUE;
-}
-
-static gboolean __ms_dcm_agent_read_socket(GIOChannel *src, GIOCondition condition, gpointer data)
-{
-       struct sockaddr_un client_addr;
-       socklen_t client_addr_len;
-       dcmMsg *recv_msg = NULL;
-       dcmRequest *dcm_req = NULL;
-       int sock = -1;
-       int client_sock = -1;
-
-       sock = g_io_channel_unix_get_fd(src);
-       MS_DBG_RETVM_IF(sock < 0, G_SOURCE_CONTINUE, "sock fd is invalid!");
-
-       client_addr_len = (socklen_t)sizeof(client_addr);
-
-       if ((client_sock = accept(sock, (struct sockaddr*)&client_addr, &client_addr_len)) < 0) {
-               MS_DBG_STRERROR("accept failed");
-               return G_SOURCE_CONTINUE;
-       }
-
-       MS_DBG("Client[%d] is accepted", client_sock);
-
-       recv_msg = g_new0(dcmMsg, 1);
-
-       if (__ms_dcm_recv_msg(client_sock, recv_msg) < 0) {
-               MS_DBG_ERR("__ms_dcm_recv_msg failed ");
-               goto ERROR;
-       }
-
-       dcm_req = g_new0(dcmRequest, 1);
-
-       dcm_req->client_sock = client_sock;
-       dcm_req->recv_msg = recv_msg;
-
-       if (!g_dcm_request_queue) {
-               MS_DBG_WARN("Creating queue");
-               g_dcm_request_queue = g_queue_new();
-       }
-
-       if (g_queue_get_length(g_dcm_request_queue) >= MAX_DCM_REQUEST) {
-               MS_DBG_WARN("Request Queue is full");
-               dcmMsg res_msg;
-               memset((void *)&res_msg, 0, sizeof(res_msg));
-
-               res_msg.msg_type = recv_msg->msg_type;
-               if (strlen(recv_msg->msg) != 0)
-                       SAFE_STRLCPY(res_msg.msg, recv_msg->msg, sizeof(res_msg.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", MAX_FILEPATH_LEN, recv_msg->msg);
-
-               close(client_sock);
-               g_free(dcm_req->recv_msg);
-               g_free(dcm_req);
-
-               return G_SOURCE_CONTINUE;
-       }
-
-       MS_DBG_SLOG("[%.*s] is queued", MAX_FILEPATH_LEN, recv_msg->msg);
-       g_queue_push_tail(g_dcm_request_queue, (gpointer)dcm_req);
-
-       if (!g_dcm_queue_work) {
-               GSource *src_request = NULL;
-               src_request = g_idle_source_new();
-               g_source_set_callback(src_request, __ms_dcm_request_to_server, NULL, NULL);
-               g_source_attach(src_request, g_main_context_get_thread_default());
-               g_dcm_queue_work = TRUE;
-       }
-
-       return G_SOURCE_CONTINUE;
-
-ERROR:
-       close(client_sock);
-       g_free(recv_msg);
-       return G_SOURCE_CONTINUE;
-}
-
-
-gpointer ms_dcm_agent_start_thread(gpointer data)
-{
-       int sockfd = -1;
-       GSource *source = NULL;
-       GIOChannel *channel = NULL;
-       GMainContext *context = NULL;
-
-       /* Create and bind new TCP socket */
-       if (!__ms_dcm_agent_prepare_tcp_socket(&sockfd, MS_DCM_CREATOR_PORT)) {
-               MS_DBG_ERR("Failed to create socket");
-               return NULL;
-       }
-
-       context = g_main_context_new();
-
-       g_dcm_agent_loop = g_main_loop_new(context, FALSE);
-       g_main_context_push_thread_default(context);
-
-       /* Create new channel to watch udp socket */
-       channel = g_io_channel_unix_new(sockfd);
-       source = g_io_create_watch(channel, G_IO_IN);
-       g_io_channel_unref(channel);
-
-       /* Set callback to be called when socket is readable */
-       g_source_set_callback(source, (GSourceFunc)__ms_dcm_agent_read_socket, NULL, NULL);
-       g_dcm_source_id = g_source_attach(source, context);
-       g_source_unref(source);
-
-       MS_DBG_INFO("DCM Agent thread is running");
-       g_main_loop_run(g_dcm_agent_loop);
-       MS_DBG_INFO("DCM Agent thread is shutting down");
-
-       /*close an IO channel & remove resources */
-       close(sockfd);
-       g_main_loop_unref(g_dcm_agent_loop);
-
-       return NULL;
-}
index 8b30a6f..feb7750 100644 (file)
@@ -20,7 +20,6 @@
 #include <sys/wait.h>
 #include <sys/types.h>
 #include <malloc.h>
-#include <iniparser.h>
 #include <cpu-boosting.h>
 
 #include "media-util.h"
@@ -34,7 +33,6 @@
 #include "media-server-db.h"
 #include "media-server-scanner.h"
 #include "media-server-device-block.h"
-#include "media-server-dcm.h"
 #include "media-server-db-manage.h"
 
 #ifdef _USE_TVPD_MODE
@@ -58,7 +56,6 @@ static void __ms_update_storage_status(void);
 static void __ms_add_signal_handler(void);
 static void __ms_add_event_receiver(void);
 
-static bool __ms_is_dcm_supported(void);
 static bool __ms_is_external_supported(void);
 
 #ifdef _USE_TVPD_MODE
@@ -137,9 +134,6 @@ static void __power_off_cb(void *data)
        /*Quit DB Thread*/
        ms_db_finalize();
 
-       /*Quit DCM Thread*/
-       ms_dcm_finalize();
-
        g_source_remove(main_source_id);
 
        ms_sys_unset_device_block_event_cb();
@@ -149,20 +143,16 @@ static void __power_off_cb(void *data)
 
 static void __ms_signal_handler(int n)
 {
-       int stat, pid, dcm_pid;
+       int stat, pid;
        int scanner_pid;
 
        scanner_pid = ms_get_scanner_pid();
-       dcm_pid = ms_dcm_get_server_pid();
 
        while ((pid = waitpid(-1, &stat, WNOHANG)) > 0) {
                if (pid == scanner_pid) {
                        MS_DBG_WARN("[%d] Scanner is stopped by media-server", pid);
                        ms_reset_scanner_status();
                        ms_cleanup_scanner();
-               } else if (pid == dcm_pid) {
-                       MS_DBG_WARN("[%d] DCM is stopped by media-server", pid);
-                       ms_dcm_reset_server_status();
                } else {
                        MS_DBG_WARN("[%d] is stopped", pid);
                }
@@ -185,9 +175,7 @@ static void __ms_free_global_variable(void)
 int main(int argc, char **argv)
 {
        GThread *db_thread = NULL;
-       GThread *dcm_thread = NULL;
        GIOChannel *channel = NULL;
-       bool is_dcm_supported = __ms_is_dcm_supported();
        power_off = false;
 #ifdef _USE_TVPD_MODE
        int ret = 0;
@@ -271,8 +259,6 @@ int main(int argc, char **argv)
 
        /*create each threads*/
        db_thread = g_thread_new("db_thread", ms_db_thread, NULL);
-       if (is_dcm_supported)
-               dcm_thread = g_thread_new("dcm_agent_thread", 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()) {
@@ -299,8 +285,6 @@ int main(int argc, char **argv)
        g_main_loop_run(mainloop);
 
        g_thread_join(db_thread);
-       if (is_dcm_supported)
-               g_thread_join(dcm_thread);
 
        ms_cynara_finish();
 #ifdef _USE_TVPD_MODE
@@ -437,34 +421,6 @@ static void __ms_check_mediadb(void)
        }
 }
 
-static bool __ms_is_dcm_supported(void)
-{
-       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 false;
-       }
-
-       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;
-}
-
 static bool __ms_is_external_supported(void)
 {
        bool support = false;