Commit 9a90b761 authored by Simon Morlat's avatar Simon Morlat

big cleanup and implement random port selection based on system.

parent dc4197cf
......@@ -60,20 +60,8 @@ AC_ARG_ENABLE(perf,
ORTP_DEFS=
dnl enable ipv6 support
AC_ARG_ENABLE(ipv6,
[AS_HELP_STRING([--enable-ipv6], [Turn on ipv6 support (default=yes)])],
[case "${enableval}" in
yes) ipv6=true;;
no) ipv6=false;;
*) AC_MSG_ERROR(bad value ${enableval} for --enable-ipv6) ;;
esac],
[ipv6=true]
)
if test x$ipv6 = xtrue ; then
ORTP_DEFS="$ORTP_DEFS -DORTP_INET6"
AC_DEFINE(__APPLE_USE_RFC_2292, 1, [ Apple wants you to declare what behavior you want by defining either __APPLE_USE_RFC_2292])
fi
AC_DEFINE(__APPLE_USE_RFC_2292, 1, [ Apple wants you to declare what behavior you want by defining either __APPLE_USE_RFC_2292])
dnl enable timestamp support
AC_ARG_ENABLE(ntp-timestamp,
......
......@@ -31,19 +31,10 @@ typedef enum {
OrtpRTCPSocket
} OrtpSocketType;
typedef struct RtpEndpoint{
#ifdef ORTP_INET6
struct sockaddr_storage addr;
#else
struct sockaddr addr;
#endif
socklen_t addrlen;
}RtpEndpoint;
struct _OrtpEventData{
mblk_t *packet; /* most events are associated to a received packet */
RtpEndpoint *ep;
struct sockaddr_storage source_addr;
socklen_t source_addrlen;
ortpTimeSpec ts;
union {
int telephone_event;
......@@ -66,9 +57,6 @@ typedef struct _OrtpEventData OrtpEventData;
extern "C"{
#endif
ORTP_PUBLIC RtpEndpoint *rtp_endpoint_new(struct sockaddr *addr, socklen_t addrlen);
ORTP_PUBLIC RtpEndpoint *rtp_endpoint_dup(const RtpEndpoint *ep);
ORTP_PUBLIC OrtpEvent * ortp_event_new(OrtpEventType tp);
ORTP_PUBLIC OrtpEventType ortp_event_get_type(const OrtpEvent *ev);
/* type is one of the following*/
......
......@@ -53,9 +53,7 @@
#include <sys/time.h>
#ifdef ORTP_INET6
#include <netdb.h>
#endif
typedef int ortp_socket_t;
typedef pthread_t ortp_thread_t;
......
......@@ -196,11 +196,7 @@ typedef struct _RtpStream
queue_t tev_rq;
mblk_t *cached_mp;
int loc_port;
#ifdef ORTP_INET6
struct sockaddr_storage rem_addr;
#else
struct sockaddr_in rem_addr;
#endif
int rem_addrlen;
void *QoSHandle;
unsigned long QoSFlowID;
......@@ -243,11 +239,7 @@ typedef struct _RtcpStream
struct _RtpTransport *tr;
mblk_t *cached_mp;
int loc_port;
#ifdef ORTP_INET6
struct sockaddr_storage rem_addr;
#else
struct sockaddr_in rem_addr;
#endif
int rem_addrlen;
int interval;
uint32_t last_rtcp_report_snt_r; /* the time of the last rtcp report sent, in recv timestamp unit */
......@@ -373,6 +365,7 @@ ORTP_PUBLIC bool_t rtp_session_adaptive_jitter_compensation_enabled(RtpSession *
ORTP_PUBLIC void rtp_session_set_time_jump_limit(RtpSession *session, int miliseconds);
ORTP_PUBLIC int rtp_session_set_local_addr(RtpSession *session,const char *addr, int rtp_port, int rtcp_port);
ORTP_PUBLIC int rtp_session_get_local_port(const RtpSession *session);
ORTP_PUBLIC int rtp_session_get_local_rtcp_port(const RtpSession *session);
ORTP_PUBLIC int
rtp_session_set_remote_addr_full (RtpSession * session, const char * rtp_addr, int rtp_port, const char * rtcp_addr, int rtcp_port);
......
......@@ -36,7 +36,6 @@ set(SOURCE_FILES
endif(WIN32)
add_definitions(
-DORTP_INET6
-DORTP_EXPORTS
)
......
......@@ -20,26 +20,6 @@
#include "ortp/event.h"
#include "ortp/ortp.h"
RtpEndpoint *rtp_endpoint_new(struct sockaddr *addr, socklen_t addrlen){
RtpEndpoint *ep=ortp_new(RtpEndpoint,1);
if (sizeof(ep->addr)<addrlen){
ortp_free(ep);
ortp_fatal("Bad socklen_t size !");
return NULL;
}
memcpy(&ep->addr,addr,addrlen);
ep->addrlen=addrlen;
return ep;
}
void rtp_endpoint_destroy(RtpEndpoint *ep){
ortp_free(ep);
}
RtpEndpoint *rtp_endpoint_dup(const RtpEndpoint *ep){
return rtp_endpoint_new((struct sockaddr*)&ep->addr,ep->addrlen);
}
OrtpEvent * ortp_event_new(unsigned long type){
OrtpEventData *ed;
const int size=sizeof(OrtpEventType)+sizeof(OrtpEventData);
......@@ -56,7 +36,6 @@ OrtpEvent *ortp_event_dup(OrtpEvent *ev){
OrtpEventData * ed = ortp_event_get_data(ev);
OrtpEventData * edv = ortp_event_get_data(nev);
memcpy(edv,ed,sizeof(OrtpEventData));
if (ed->ep) edv->ep = rtp_endpoint_dup(ed->ep);
if (ed->packet) edv->packet = copymsg(ed->packet);
return nev;
}
......@@ -73,7 +52,6 @@ void ortp_event_destroy(OrtpEvent *ev){
OrtpEventData *d=ortp_event_get_data(ev);
if (ev->b_datap->db_ref==1){
if (d->packet) freemsg(d->packet);
if (d->ep) rtp_endpoint_destroy(d->ep);
}
freemsg(ev);
}
......
......@@ -64,11 +64,8 @@ static mblk_t *simulate_bandwidth_limit(RtpSession *session, mblk_t *input){
int64_t elapsed;
int bits;
mblk_t *output=NULL;
#ifdef ORTP_INET6
int overhead=(session->rtp.sockfamily==AF_INET6) ? IP6_UDP_OVERHEAD : IP_UDP_OVERHEAD;
#else
int overhead=IP_UDP_OVERHEAD;
#endif
ortp_gettimeofday(&current,NULL);
if (sim->last_check.tv_sec==0){
......
......@@ -149,7 +149,8 @@ void rtp_session_rtp_parse(RtpSession *session, mblk_t *mp, uint32_t local_str_t
OrtpEvent *ev=ortp_event_new(ORTP_EVENT_STUN_PACKET_RECEIVED);
OrtpEventData *ed=ortp_event_get_data(ev);
ed->packet=mp;
ed->ep=rtp_endpoint_new(addr,addrlen);
memcpy(&ed->source_addr,addr,addrlen);
ed->source_addrlen=addrlen;
ed->info.socket_type = OrtpRTPSocket;
rtp_session_dispatch_event(session,ev);
return;
......
This diff is collapsed.
......@@ -103,11 +103,7 @@ int main(int argc, char *argv[])
session[i]=rtp_session_new(RTP_SESSION_RECVONLY);
rtp_session_set_scheduling_mode(session[i],1);
rtp_session_set_blocking_mode(session[i],0);
#ifdef ORTP_INET6
rtp_session_set_local_addr(session[i],"::",port,port+1);
#else
rtp_session_set_local_addr(session[i],"0.0.0.0",port,port+1);
#endif
rtp_session_set_payload_type(session[i],0);
rtp_session_set_recv_buf_size(session[i],256);
port+=2;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment