mirror of
https://gitlab.linphone.org/BC/public/linphone-iphone.git
synced 2026-01-26 07:38:09 +00:00
start implementing a named pipe abstraction.
git-svn-id: svn+ssh://svn.savannah.nongnu.org/linphone/trunk@479 3f6dc0c8-ddfe-455d-9043-3cd528dc4637
This commit is contained in:
parent
94e30e4a52
commit
e38e7495cd
3 changed files with 88 additions and 1 deletions
|
|
@ -230,6 +230,19 @@ char *ortp_strndup(const char *str,int n);
|
|||
char *ortp_strdup_printf(const char *fmt,...);
|
||||
char *ortp_strdup_vprintf(const char *fmt, va_list ap);
|
||||
|
||||
/* portable named pipes */
|
||||
ortp_socket_t ortp_server_pipe_create(const char *name);
|
||||
ortp_socket_t ortp_server_pipe_accept_client(ortp_socket_t server);
|
||||
int ortp_server_pipe_close(ortp_socket_t spipe);
|
||||
int ortp_server_pipe_close_client(ortp_socket_t client);
|
||||
|
||||
ortp_socket_t ortp_client_pipe_connect(const char *name);
|
||||
int ortp_client_pipe_close(ortp_socket_t sock);
|
||||
|
||||
int ortp_pipe_read(ortp_socket_t p, uint8_t *buf, int len);
|
||||
int ortp_pipe_write(ortp_socket_t p, const uint8_t *buf, int len);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -334,3 +334,77 @@ char * WSAAPI gai_strerror(int errnum){
|
|||
|
||||
#endif
|
||||
|
||||
#ifndef WIN32
|
||||
|
||||
#include <sys/socket.h>
|
||||
#include <netdb.h>
|
||||
#include <sys/un.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
/* portable named pipes */
|
||||
ortp_socket_t ortp_server_pipe_create(const char *name){
|
||||
struct sockaddr_un sa;
|
||||
ortp_socket_t sock;
|
||||
sock=socket(AF_UNIX,SOCK_STREAM,0);
|
||||
sa.sun_family=AF_UNIX;
|
||||
strncpy(sa.sun_path,name,sizeof(sa.sun_path)-1);
|
||||
unlink(name);/*in case we didn't finished properly previous time */
|
||||
fchmod(sock,S_IRUSR|S_IWUSR);
|
||||
if (bind(sock,(struct sockaddr*)&sa,sizeof(sa))!=0){
|
||||
ortp_error("Failed to bind command unix socket: %s",strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
listen(sock,1);
|
||||
return sock;
|
||||
}
|
||||
|
||||
ortp_socket_t ortp_server_pipe_accept_client(ortp_socket_t server){
|
||||
struct sockaddr_un su;
|
||||
socklen_t ssize=sizeof(su);
|
||||
ortp_socket_t client_sock=accept(server,(struct sockaddr*)&su,&ssize);
|
||||
return client_sock;
|
||||
}
|
||||
|
||||
int ortp_server_pipe_close_client(ortp_socket_t client){
|
||||
return close(client);
|
||||
}
|
||||
|
||||
int ortp_server_pipe_close(ortp_socket_t spipe){
|
||||
return close(spipe);
|
||||
}
|
||||
|
||||
ortp_socket_t ortp_client_pipe_connect(const char *name){
|
||||
struct sockaddr_un sa;
|
||||
ortp_socket_t sock=socket(AF_UNIX,SOCK_STREAM,0);
|
||||
sa.sun_family=AF_UNIX;
|
||||
strncpy(sa.sun_path,name,sizeof(sa.sun_path)-1);
|
||||
if (connect(sock,(struct sockaddr*)&sa,sizeof(sa))!=0){
|
||||
close(sock);
|
||||
return -1;
|
||||
}
|
||||
return sock;
|
||||
}
|
||||
|
||||
int ortp_pipe_read(ortp_socket_t p, uint8_t *buf, int len){
|
||||
return read(p,buf,len);
|
||||
}
|
||||
|
||||
int ortp_pipe_write(ortp_socket_t p, const uint8_t *buf, int len){
|
||||
return write(p,buf,len);
|
||||
}
|
||||
|
||||
int ortp_client_pipe_close(ortp_socket_t sock){
|
||||
return close(sock);
|
||||
}
|
||||
|
||||
#else
|
||||
/* portable named pipes */
|
||||
ortp_socket_t ortp_server_pipe_create(const char *name);
|
||||
ortp_socket_t ortp_server_pipe_accept(ortp_socket_t server);
|
||||
int ortp_server_pipe_close(ortp_socket_t spipe);
|
||||
|
||||
ortp_socket_t ortp_call_pipe(const char *name);
|
||||
|
||||
int ortp_pipe_read(ortp_socket_t p, uint8_t *buf, int len);
|
||||
int ortp_pipe_write(ortp_socket_t p, const uint8_t *buf, int len);
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -145,7 +145,7 @@ void rtp_session_rtp_parse(RtpSession *session, mblk_t *mp, uint32_t local_str_t
|
|||
session->rtp.rem_addrlen=addrlen;
|
||||
}
|
||||
}
|
||||
|
||||
session->rtp.rcv_last_ts = rtp->timestamp;
|
||||
session->rcv.ssrc=rtp->ssrc;
|
||||
rtp_signal_table_emit(&session->on_ssrc_changed);
|
||||
}else{
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue