Change from INET tcp to Unix domain socket
[framework/multimedia/media-server.git] / lib / include / media-util-ipc.h
1 /*
2  *  Media Utility
3  *
4  * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
5  *
6  * Contact: Yong Yeon Kim <yy9875.kim@samsung.com>
7  *
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  *
12  * http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  *
20  */
21
22 /**
23  * This file defines api utilities of IPC.
24  *
25  * @file                media-util-ipc.h
26  * @author      Haejeong Kim(backto.kim@samsung.com)
27  * @version     1.0
28  * @brief
29  */
30  #ifndef _MEDIA_UTIL_IPC_H_
31 #define _MEDIA_UTIL_IPC_H_
32
33 #ifdef __cplusplus
34 extern "C" {
35 #endif
36
37 #ifdef _USE_UDS_SOCKET_
38 #include <sys/un.h>
39 #else
40 #include <sys/socket.h>
41 #endif
42
43 #ifdef _USE_UDS_SOCKET_TCP_
44 #include <sys/un.h>
45 #endif
46
47 #include <netinet/in.h>
48 #include <arpa/inet.h>
49
50 #include "media-server-ipc.h"
51
52 #define SERVER_IP                       "127.0.0.1"
53
54 typedef enum {
55         MS_PROTOCOL_UDP,
56         MS_PROTOCOL_TCP
57 } ms_protocol_e;
58
59 #ifdef _USE_UDS_SOCKET_
60 int ms_ipc_create_client_socket(ms_protocol_e protocol, int timeout_sec, int *sock_fd, int port);
61 #else
62 int ms_ipc_create_client_socket(ms_protocol_e protocol, int timeout_sec, int *sock_fd);
63 #endif
64
65 #ifdef _USE_UDS_SOCKET_TCP_
66 int ms_ipc_create_client_tcp_socket(ms_protocol_e protocol, int timeout_sec, int *sock_fd, int port);
67 int ms_ipc_create_server_tcp_socket(ms_protocol_e protocol, int port, int *sock_fd);
68 #endif
69
70 int ms_ipc_create_server_socket(ms_protocol_e protocol, int port, int *sock_fd);
71 #ifdef _USE_UDS_SOCKET_
72 int ms_ipc_send_msg_to_server(int sockfd, int port, ms_comm_msg_s *send_msg, struct sockaddr_un *serv_addr);
73 int ms_ipc_send_msg_to_client(int sockfd, ms_comm_msg_s *send_msg, struct sockaddr_un *client_addr);
74 int ms_ipc_receive_message(int sockfd, void *recv_msg, unsigned int msg_size, struct sockaddr_un *client_addr, unsigned int *size);
75 int ms_ipc_wait_message(int sockfd, void  *recv_msg, unsigned int msg_size, struct sockaddr_un *recv_addr, unsigned int *size);
76 #else
77 int ms_ipc_send_msg_to_server(int sockfd, int port, ms_comm_msg_s *send_msg, struct sockaddr_in *serv_addr);
78 int ms_ipc_send_msg_to_client(int sockfd, ms_comm_msg_s *send_msg, struct sockaddr_in *client_addr);
79 int ms_ipc_receive_message(int sockfd, void *recv_msg, unsigned int msg_size, struct sockaddr_in *client_addr, unsigned int *size);
80 int ms_ipc_wait_message(int sockfd, void  *recv_msg, unsigned int msg_size, struct sockaddr_in *recv_addr, unsigned int *size);
81 #endif
82
83 #ifdef __cplusplus
84 }
85 #endif
86
87 #endif /*_MEDIA_UTIL_IPC_H_*/