#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; } }
#define _DCM_DEBUG_UTILS_H_
#include <dlog.h>
+#include <media-util.h>
#ifdef LOG_TAG
#undef LOG_TAG
#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_*/
#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_*/
#define _DCM_SCAN_SVC_H_
#include <glib.h>
+#include <dcm_image_codec.h>
typedef struct {
GMainLoop *main_loop;
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);
#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);
#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")))
+++ /dev/null
-/*
- * 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_ */
-
#define __FACE_DEBUG_H__
#include <dlog.h>
+#include <media-util.h>
#ifdef LOG_TAG
#undef LOG_TAG
#include <tizen.h>
#include "dcm-face_type.h"
-#include <media-util.h>
#ifdef __cplusplus
extern "C" {
*
*/
-#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
#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
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,
--- /dev/null
+/*
+ * 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_ */
+++ /dev/null
-/*
- * 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_ */
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
#export CFLAGS+=" -Wwrite-strings -Wswitch-default"
%install
-rm -rf %{buildroot}
%make_install
%post -p /sbin/ldconfig
#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;
*
*/
-#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;
return;
}
-int face_detect_initialize()
+int dcm_face_detect_initialize()
{
int ret = MS_MEDIA_ERR_NONE;
return ret;
}
-int face_detect_finalize()
+int dcm_face_detect_finalize()
{
int ret = MS_MEDIA_ERR_NONE;
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;
*/
#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);
*
*/
-#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
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) {
}
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) {
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
_data->g_scan_cancel = FALSE;
_data->kill_timer_source = NULL;
- face_detect_initialize();
+ dcm_face_detect_initialize();
return MS_MEDIA_ERR_NONE;
}
_dcm_scan_clear_all_items(data);
_dcm_scan_clear_single_item(data);
- face_detect_finalize();
+ dcm_face_detect_finalize();
if (_data != NULL)
free(_data);
}
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;
}
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);
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
-#include <stdbool.h>
#include <string.h>
#include <errno.h>
#include <glib.h>
#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"},
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;
*/
#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
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)
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;
}
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);