INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/dcm-service.pc DESTINATION ${LIB_INSTALL_DIR}/pkgconfig)
ADD_SUBDIRECTORY(svc)
-ADD_SUBDIRECTORY(test)
+#ADD_SUBDIRECTORY(test)
LINK_DIRECTORIES(${LIB_INSTALL_DIR})
int acceptSocket(int serv_sock, int *client_sock);
int receiveSocketMsg(int client_sock, DcmIpcMsg *recv_msg);
int sendSocketMsg(DcmIpcMsgType msg_type, uid_t uid, const char *msg, DcmIpcPortType port);
- int sendClientSocketMsg(int socket_fd, DcmIpcMsgType msg_type, uid_t uid, const char *msg, DcmIpcPortType port);
+ int sendCompleteMsg(DcmIpcMsgType msg_type, const unsigned int count, const char *msg, DcmIpcPortType port);
+ int sendClientSocketMsg(int socket_fd, DcmIpcMsgType msg_type, unsigned int result, const char *msg, DcmIpcPortType port);
int closeSocket(int socket_fd);
}
uid_t uid;
size_t msg_size; /*this is size of message below and this does not include the terminationg null byte ('\0'). */
char msg[DCM_IPC_MSG_MAX_SIZE];
+ int result;
} DcmIpcMsg;
typedef enum {
int image_height;
int image_orientation;
char *mime_type;
+ int face_count;
DcmScanItemType scan_item_type;
} DcmScanItem;
Name: dcm-service
Summary: A media DCM(Digital Contents Management) Service
-Version: 0.0.9
+Version: 0.0.10
Release: 0
Group: Multimedia/Service
License: Apache-2.0
dcm_warn("detected face count: %d", face_info->count);
if (face_info->count <= 0) {
+ scan_item->face_count = 0;
goto DCM_SVC_FACE_RECOGNIZE_BUFFER_FAILED;
}
+ scan_item->face_count = face_info->count;
/* Compute scale factor between decode size and original size */
scale_factor = DcmFaceApi::caculateScaleFactor(image_info);
return DCM_SUCCESS;
}
-int DcmIpcUtils::sendClientSocketMsg(int socket_fd, DcmIpcMsgType msg_type, uid_t uid, const char *msg, DcmIpcPortType port)
+int DcmIpcUtils::sendClientSocketMsg(int socket_fd, DcmIpcMsgType msg_type, unsigned int result, const char *msg, DcmIpcPortType port)
{
if (port < 0 || port >= DCM_IPC_PORT_MAX) {
dcm_error("Invalid port! Stop sending message...");
/* Prepare send message */
memset((void *)&send_msg, 0, sizeof(DcmIpcMsg));
send_msg.msg_type = msg_type;
- send_msg.uid = uid;
+ send_msg.result = result;
if (msg != NULL) {
send_msg.msg_size = strlen(msg);
strncpy(send_msg.msg, msg, send_msg.msg_size);
return DCM_SUCCESS;
}
+int DcmIpcUtils::sendCompleteMsg(DcmIpcMsgType msg_type, const unsigned int count, const char *msg, DcmIpcPortType port)
+{
+ if (port < 0 || port >= DCM_IPC_PORT_MAX) {
+ dcm_error("Invalid port! Stop sending message...");
+ return DCM_ERROR_INVALID_PARAMETER;
+ }
+ dcm_debug("Send message type: %d", msg_type);
+
+ int socket_fd = -1;
+ struct sockaddr_un serv_addr;
+ //struct timeval tv_timeout = { 10, 0 }; /* timeout: 10 seconds */
+ DcmIpcMsg send_msg;
+
+ /* Prepare send message */
+ memset((void *)&send_msg, 0, sizeof(DcmIpcMsg));
+ send_msg.msg_type = msg_type;
+ send_msg.result = count;
+ if (msg != NULL) {
+ send_msg.msg_size = strlen(msg);
+ strncpy(send_msg.msg, msg, send_msg.msg_size);
+ }
+
+ /* If message size is larget than max_size, then message is invalid */
+ if (send_msg.msg_size >= DCM_IPC_MSG_MAX_SIZE) {
+ dcm_error("Message size is invalid!");
+ return DCM_ERROR_NETWORK;
+ }
+
+ /* Create a new TCP socket */
+ if ((socket_fd = socket(PF_FILE, SOCK_STREAM, 0)) < 0) {
+ dcm_stderror("socket failed");
+ return DCM_ERROR_NETWORK;
+ }
+
+ /* Set dcm thread socket address */
+ memset(&serv_addr, 0, sizeof(serv_addr));
+ serv_addr.sun_family = AF_UNIX;
+ strncpy(serv_addr.sun_path, DCM_IPC_PATH[port], sizeof(serv_addr.sun_path) - 1);
+
+ /* Connect to the socket */
+ if (connect(socket_fd, (struct sockaddr*)&serv_addr, sizeof(serv_addr)) < 0) {
+ dcm_stderror("connect error");
+ close(socket_fd);
+ return DCM_ERROR_NETWORK;
+ }
+
+ /* Send msg to the socket */
+ if (send(socket_fd, &send_msg, sizeof(send_msg), 0) != sizeof(send_msg)) {
+ dcm_stderror("send failed");
+ close(socket_fd);
+ return DCM_ERROR_NETWORK;
+ }
+
+ close(socket_fd);
+ return DCM_SUCCESS;
+}
+
+
int DcmIpcUtils::closeSocket(int socket_fd)
{
close(socket_fd);
int clearSingleItemList();
int initialize();
int finalize();
- int sendCompletedMsg(const char *msg, DcmIpcPortType port);
+ int sendCompletedMsg(const char *msg, const unsigned int count, DcmIpcPortType port);
int sendTerminatedMsg();
int getScanStatus(DcmScanItem *scan_item, bool *media_scanned);
int runScanProcess(DcmScanItem *scan_item);
return DCM_SUCCESS;
}
-int DcmScanSvc::sendCompletedMsg(const char *msg, DcmIpcPortType port)
+int DcmScanSvc::sendCompletedMsg(const char *msg, const unsigned int count, DcmIpcPortType port)
{
if ((scan_all_item_list == NULL) && (scan_single_item_list == NULL)) {
dcm_debug("Send completed message");
- DcmIpcUtils::sendSocketMsg(DCM_IPC_MSG_SCAN_COMPLETED, 0, msg, port);
+ DcmIpcUtils::sendCompleteMsg(DCM_IPC_MSG_SCAN_COMPLETED, count, msg, port);
} else {
if (scan_all_item_list)
dcm_warn("scan_all_item_list");
dcm_debug("No items to Scan. Scan operation completed!!!");
clearAllItemList();
/* Send scan complete message to main thread (if all scan operations are finished) */
- sendCompletedMsg( NULL, DCM_IPC_PORT_DCM_RECV);
+ sendCompletedMsg( NULL, 0, DCM_IPC_PORT_DCM_RECV);
ret = dcmDBUtils->_dcm_svc_db_disconnect();
if (ret != DCM_SUCCESS) {
dcm_error("Failed to disconnect db! err: %d", ret);
dcm_debug("No items to Scan. Scan operation completed!!!");
clearSingleItemList();
/* Send scan complete message to main thread (if all scan operations are finished) */
- sendCompletedMsg( file_path/*ret*/, DCM_IPC_PORT_DCM_RECV);
+ sendCompletedMsg( file_path/*ret*/, 0, DCM_IPC_PORT_DCM_RECV);
return DCM_SUCCESS;
}
(scan_single_curr_index)++;
}
+ sendCompletedMsg( file_path/*ret*/, scan_item->face_count, DCM_IPC_PORT_DCM_RECV);
+
clearSingleItemList();
dcm_debug_fleave();
}
scanSvc->clearAllItemList();
/* Send scan complete message to main thread (if all scan operations are finished) */
- scanSvc->sendCompletedMsg( NULL, DCM_IPC_PORT_DCM_RECV);
+ scanSvc->sendCompletedMsg( NULL, 0, DCM_IPC_PORT_DCM_RECV);
dcm_debug_fleave();
return FALSE;
}
void DcmMainSvc::dcmServiceStartjobs(void)
{
+ if (createScanThread() != DCM_SUCCESS) {
+ dcm_error("Failed to create scan thread! Exit main thread...");
+ return TRUE;
+ }
+
/* Send ready response to dcm launcher */
if (DcmIpcUtils::sendClientSocketMsg(-1, DCM_IPC_MSG_SERVICE_READY, 0, NULL, DCM_IPC_PORT_MS_RECV) != DCM_SUCCESS) {
dcm_error("Failed to send ready message");
dcmSvc->createQuitTimerMainLoop();
} else if (recv_msg.msg_type == DCM_IPC_MSG_SCAN_COMPLETED) {
dcm_debug("Scan completed!");
- ret = DcmIpcUtils::sendClientSocketMsg(-1, DCM_IPC_MSG_SERVICE_COMPLETED, recv_msg.uid, recv_msg.msg, DCM_IPC_PORT_MS_RECV);
+ ret = DcmIpcUtils::sendClientSocketMsg(-1, DCM_IPC_MSG_SERVICE_COMPLETED, recv_msg.result, recv_msg.msg, DCM_IPC_PORT_MS_RECV);
} else if (recv_msg.msg_type == DCM_IPC_MSG_KILL_SERVICE) {
dcm_warn("Quit dcm-svc main loop!");
ret = DcmIpcUtils::sendSocketMsg(DCM_IPC_MSG_KILL_SERVICE, recv_msg.uid, recv_msg.msg, DCM_IPC_PORT_SCAN_RECV);
}
} else if (recv_msg.msg_type == DCM_IPC_MSG_SCAN_SINGLE) {
ret = DcmIpcUtils::sendSocketMsg(DCM_IPC_MSG_SCAN_SINGLE, recv_msg.uid, recv_msg.msg, DCM_IPC_PORT_SCAN_RECV);
- if (ret == DCM_SUCCESS) {
+/* if (ret == DCM_SUCCESS) {
ret = DcmIpcUtils::sendClientSocketMsg(client_sock, DCM_IPC_MSG_SCAN_SINGLE, recv_msg.uid, recv_msg.msg, DCM_IPC_PORT_DCM_RECV);
- }
+ }*/
} else {
- dcm_debug("createDcmSvcReadSocket, invalid message.");
+ dcm_debug("createDcmSvcReadSocket, invalid message(%d).", recv_msg.msg_type);
}
if (DcmIpcUtils::closeSocket(client_sock) < 0) {