diff --git a/linphone/oRTP/include/ortp/port.h b/linphone/oRTP/include/ortp/port.h index 6b28d33ca24930ec3ac5c2c1e8f4481c2872150a..05b2457309d3119d49d4d5cf6df8dc6a2402a50c 100644 --- a/linphone/oRTP/include/ortp/port.h +++ b/linphone/oRTP/include/ortp/port.h @@ -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 diff --git a/linphone/oRTP/src/port.c b/linphone/oRTP/src/port.c index 4b42b1c699011961cd64031c5e867d14250b0c68..470fe304611c76e7342233fff3717ad4f3049dbc 100644 --- a/linphone/oRTP/src/port.c +++ b/linphone/oRTP/src/port.c @@ -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 diff --git a/linphone/oRTP/src/rtpparse.c b/linphone/oRTP/src/rtpparse.c index 1356c7e5570799ac6487703077278fbf252be62e..9a15ab9db92918398ddc061c01c32a58c8031557 100644 --- a/linphone/oRTP/src/rtpparse.c +++ b/linphone/oRTP/src/rtpparse.c @@ -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{