summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHyunjun Ko <zzoon.ko@samsung.com>2013-04-18 02:38:34 (GMT)
committerHyunjun Ko <zzoon.ko@samsung.com>2013-04-18 02:38:34 (GMT)
commit48a1a698783941011b472978302c44ab4b23b46f (patch)
treec2d68dd019c8889fa2b4fa91bea19724e9ddbafc
parent26b05feb5117117b1fb53545ef7cbe967beb7fbd (diff)
downloadlibmedia-thumbnail-48a1a698783941011b472978302c44ab4b23b46f.zip
libmedia-thumbnail-48a1a698783941011b472978302c44ab4b23b46f.tar.gz
libmedia-thumbnail-48a1a698783941011b472978302c44ab4b23b46f.tar.bz2
-rw-r--r--CMakeLists.txt1
-rw-r--r--packaging/libmedia-thumbnail.spec2
-rwxr-xr-xserver/thumb-server-internal.c39
-rwxr-xr-xsrc/include/ipc/media-thumb-ipc.h10
-rwxr-xr-xsrc/ipc/media-thumb-ipc.c61
5 files changed, 97 insertions, 16 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index a6ac8c4..14f2635 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -70,6 +70,7 @@ ADD_DEFINITIONS("-DPREFIX=\"${PREFIX}\"")
#ADD_DEFINITIONS("-D_PERFORMANCE_CHECK_")
ADD_DEFINITIONS("-D_USE_NEW_MEDIA_DB_")
ADD_DEFINITIONS("-D_USE_MEDIA_UTIL_")
+ADD_DEFINITIONS("-D_USE_UDS_SOCKET_TCP_")
SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed -Wl,--hash-style=both")
CONFIGURE_FILE(media-thumbnail.pc.in media-thumbnail.pc @ONLY)
diff --git a/packaging/libmedia-thumbnail.spec b/packaging/libmedia-thumbnail.spec
index 945214f..16ad300 100644
--- a/packaging/libmedia-thumbnail.spec
+++ b/packaging/libmedia-thumbnail.spec
@@ -1,6 +1,6 @@
Name: libmedia-thumbnail
Summary: Media thumbnail service library for multimedia applications.
-Version: 0.1.75
+Version: 0.1.77
Release: 1
Group: utils
License: Apache
diff --git a/server/thumb-server-internal.c b/server/thumb-server-internal.c
index 83f3186..0f3a949 100755
--- a/server/thumb-server-internal.c
+++ b/server/thumb-server-internal.c
@@ -297,7 +297,11 @@ gboolean _thumb_server_read_socket(GIOChannel *src,
GIOCondition condition,
gpointer data)
{
+#ifdef _USE_UDS_SOCKET_
+ struct sockaddr_un client_addr;
+#else
struct sockaddr_in client_addr;
+#endif
unsigned int client_addr_len;
#ifndef _USE_MEDIA_UTIL_
int client_sock;
@@ -379,6 +383,9 @@ gboolean _thumb_server_read_socket(GIOChannel *src,
close(client_sock);
#else
+#ifdef _USE_UDS_SOCKET_
+ thumb_dbg("+++++++++++++++++++++%s", client_addr.sun_path);
+#endif
if (sendto(sock, buf, buf_size, 0, (struct sockaddr *)&client_addr, sizeof(client_addr)) != buf_size) {
thumb_err("sendto failed: %s\n", strerror(errno));
SAFE_FREE(buf);
@@ -403,24 +410,31 @@ gboolean _thumb_server_send_msg_to_agent(int msg_type)
{
int sock;
const char *serv_ip = "127.0.0.1";
+#ifdef _USE_UDS_SOCKET_
+ struct sockaddr_un serv_addr;
+#else
struct sockaddr_in serv_addr;
- ms_thumb_server_msg send_msg;
-#if 0
- /* Creaete a UDP socket */
- if (_media_thumb_create_udp_socket(&sock) < 0) {
- thumb_err("_media_thumb_create_udp_socket failed");
- return FALSE;
- }
#endif
+ ms_thumb_server_msg send_msg;
+
+#ifdef _USE_UDS_SOCKET_
+ if (ms_ipc_create_client_socket(MS_PROTOCOL_UDP, MS_TIMEOUT_SEC_10, &sock, MS_THUMB_COMM_PORT) < 0) {
+#else
if (ms_ipc_create_client_socket(MS_PROTOCOL_UDP, MS_TIMEOUT_SEC_10, &sock) < 0) {
+#endif
thumb_err("ms_ipc_create_server_socket failed");
return FALSE;
}
memset(&serv_addr, 0, sizeof(serv_addr));
+#ifdef _USE_UDS_SOCKET_
+ serv_addr.sun_family = AF_UNIX;
+ strcpy(serv_addr.sun_path, "/tmp/media_ipc_thumbcomm.dat");
+#else
serv_addr.sin_family = AF_INET;
serv_addr.sin_addr.s_addr = inet_addr(serv_ip);
serv_addr.sin_port = htons(MS_THUMB_COMM_PORT);
+#endif
send_msg.msg_type = msg_type;
@@ -454,16 +468,13 @@ gboolean _thumb_server_prepare_socket(int *sock_fd)
thumb_err("ms_ipc_create_server_socket failed");
return FALSE;
}
-#if 0
- /* Creaete a UDP socket */
- if (_media_thumb_create_udp_socket(&sock) < 0) {
- thumb_err("_media_thumb_create_udp_socket failed");
- return FALSE;
- }
-#endif
#else
char thumb_path[MAX_PATH_SIZE + 1];
+#ifdef _USE_UDS_SOCKET_
+ struct sockaddr_un serv_addr;
+#else
struct sockaddr_in serv_addr;
+#endif
serv_port = THUMB_DAEMON_PORT;
/* Creaete a TCP socket */
diff --git a/src/include/ipc/media-thumb-ipc.h b/src/include/ipc/media-thumb-ipc.h
index f91925f..ce81c01 100755
--- a/src/include/ipc/media-thumb-ipc.h
+++ b/src/include/ipc/media-thumb-ipc.h
@@ -30,7 +30,12 @@
#include "media-server-ipc.h"
#endif
+#ifdef _USE_UDS_SOCKET_
+#include <sys/un.h>
+#else
#include <sys/socket.h>
+#endif
+
#include <arpa/inet.h>
#include <stdlib.h>
#include <string.h>
@@ -99,8 +104,13 @@ _media_thumb_create_udp_socket(int *sock);
int
_media_thumb_recv_msg(int sock, int header_size, thumbMsg *msg);
+#ifdef _USE_UDS_SOCKET_
+int
+_media_thumb_recv_udp_msg(int sock, int header_size, thumbMsg *msg, struct sockaddr_un *from_addr, unsigned int *from_size);
+#else
int
_media_thumb_recv_udp_msg(int sock, int header_size, thumbMsg *msg, struct sockaddr_in *from_addr, unsigned int *from_size);
+#endif
int
_media_thumb_set_buffer(thumbMsg *req_msg, unsigned char **buf, int *buf_size);
diff --git a/src/ipc/media-thumb-ipc.c b/src/ipc/media-thumb-ipc.c
index 3897c4a..23f9960 100755
--- a/src/ipc/media-thumb-ipc.c
+++ b/src/ipc/media-thumb-ipc.c
@@ -232,12 +232,20 @@ _media_thumb_recv_msg(int sock, int header_size, thumbMsg *msg)
return MEDIA_THUMB_ERROR_NONE;
}
-
+#ifdef _USE_UDS_SOCKET_
+int
+_media_thumb_recv_udp_msg(int sock, int header_size, thumbMsg *msg, struct sockaddr_un *from_addr, unsigned int *from_size)
+#else
int
_media_thumb_recv_udp_msg(int sock, int header_size, thumbMsg *msg, struct sockaddr_in *from_addr, unsigned int *from_size)
+#endif
{
int recv_msg_len = 0;
+#ifdef _USE_UDS_SOCKET_
+ unsigned int from_addr_size = sizeof(struct sockaddr_un);
+#else
unsigned int from_addr_size = sizeof(struct sockaddr_in);
+#endif
unsigned char *buf = NULL;
buf = (unsigned char*)malloc(sizeof(thumbMsg));
@@ -307,8 +315,14 @@ int
_media_thumb_request(int msg_type, media_thumb_type thumb_type, const char *origin_path, char *thumb_path, int max_length, media_thumb_info *thumb_info)
{
int sock;
+#ifdef _USE_UDS_SOCKET_
+ struct sockaddr_un serv_addr;
+#elif defined(_USE_UDS_SOCKET_TCP_)
+ struct sockaddr_un serv_addr;
+#else
const char *serv_ip = "127.0.0.1";
struct sockaddr_in serv_addr;
+#endif
int recv_str_len = 0;
int err;
@@ -316,7 +330,13 @@ _media_thumb_request(int msg_type, media_thumb_type thumb_type, const char *orig
#ifdef _USE_MEDIA_UTIL_
+#ifdef _USE_UDS_SOCKET_
+ if (ms_ipc_create_client_socket(MS_PROTOCOL_TCP, MS_TIMEOUT_SEC_10, &sock, MS_THUMB_CREATOR_PORT) < 0) {
+#elif defined(_USE_UDS_SOCKET_TCP_)
+ if (ms_ipc_create_client_tcp_socket(MS_PROTOCOL_TCP, MS_TIMEOUT_SEC_10, &sock, MS_THUMB_CREATOR_TCP_PORT) < 0) {
+#else
if (ms_ipc_create_client_socket(MS_PROTOCOL_TCP, MS_TIMEOUT_SEC_10, &sock) < 0) {
+#endif
thumb_err("ms_ipc_create_client_socket failed");
return MEDIA_THUMB_ERROR_NETWORK;
}
@@ -329,10 +349,24 @@ _media_thumb_request(int msg_type, media_thumb_type thumb_type, const char *orig
#endif
memset(&serv_addr, 0, sizeof(serv_addr));
+#ifdef _USE_UDS_SOCKET_
+ serv_addr.sun_family = AF_UNIX;
+#elif defined(_USE_UDS_SOCKET_TCP_)
+ serv_addr.sun_family = AF_UNIX;
+#else
serv_addr.sin_family = AF_INET;
serv_addr.sin_addr.s_addr = inet_addr(serv_ip);
+#endif
+
#ifdef _USE_MEDIA_UTIL_
+#ifdef _USE_UDS_SOCKET_
+ strcpy(serv_addr.sun_path, "/tmp/media_ipc_thumbcreator.dat");
+#elif defined(_USE_UDS_SOCKET_TCP_)
+ thumb_dbg("");
+ strcpy(serv_addr.sun_path, "/tmp/media_ipc_thumbcreator.dat");
+#else
serv_addr.sin_port = htons(MS_THUMB_CREATOR_PORT);
+#endif
#else
serv_addr.sin_port = htons(THUMB_DAEMON_PORT);
#endif
@@ -631,8 +665,14 @@ int
_media_thumb_request_async(int msg_type, media_thumb_type thumb_type, const char *origin_path, thumbUserData *userData)
{
int sock;
+#ifdef _USE_UDS_SOCKET_
+ struct sockaddr_un serv_addr;
+#elif defined(_USE_UDS_SOCKET_TCP_)
+ struct sockaddr_un serv_addr;
+#else
const char *serv_ip = "127.0.0.1";
struct sockaddr_in serv_addr;
+#endif
int pid;
@@ -641,7 +681,13 @@ _media_thumb_request_async(int msg_type, media_thumb_type thumb_type, const char
}
#ifdef _USE_MEDIA_UTIL_
+#ifdef _USE_UDS_SOCKET_
+ if (ms_ipc_create_client_socket(MS_PROTOCOL_TCP, MS_TIMEOUT_SEC_10, &sock, MS_THUMB_CREATOR_PORT) < 0) {
+#elif defined(_USE_UDS_SOCKET_TCP_)
+ if (ms_ipc_create_client_tcp_socket(MS_PROTOCOL_TCP, MS_TIMEOUT_SEC_10, &sock, MS_THUMB_CREATOR_TCP_PORT) < 0) {
+#else
if (ms_ipc_create_client_socket(MS_PROTOCOL_TCP, MS_TIMEOUT_SEC_10, &sock) < 0) {
+#endif
thumb_err("ms_ipc_create_client_socket failed");
return MEDIA_THUMB_ERROR_NETWORK;
}
@@ -659,10 +705,23 @@ _media_thumb_request_async(int msg_type, media_thumb_type thumb_type, const char
memset(&serv_addr, 0, sizeof(serv_addr));
+#ifdef _USE_UDS_SOCKET_
+ serv_addr.sun_family = AF_UNIX;
+#elif defined(_USE_UDS_SOCKET_TCP_)
+ serv_addr.sun_family = AF_UNIX;
+#else
serv_addr.sin_family = AF_INET;
serv_addr.sin_addr.s_addr = inet_addr(serv_ip);
+#endif
+
#ifdef _USE_MEDIA_UTIL_
+#ifdef _USE_UDS_SOCKET_
+ strcpy(serv_addr.sun_path, "/tmp/media_ipc_thumbcreator.dat");
+#elif defined(_USE_UDS_SOCKET_TCP_)
+ strcpy(serv_addr.sun_path, "/tmp/media_ipc_thumbcreator.dat");
+#else
serv_addr.sin_port = htons(MS_THUMB_CREATOR_PORT);
+#endif
#else
serv_addr.sin_port = htons(THUMB_DAEMON_PORT);
#endif