Commit 4ef1702f authored by johan's avatar johan

Merge remote-tracking branch 'origin/master' into dev_dtls

parents 723deb7e 44c225af
......@@ -2,6 +2,12 @@ dnl Process this file with autoconf to produce a configure script.
AC_INIT([ortp],[0.23.0])
AC_CANONICAL_SYSTEM
case $INSTALL in
*ginstall*)
INSTALL="$INSTALL -C"
;;
esac
dnl Source packaging numbers
ORTP_MAJOR_VERSION=$(echo $PACKAGE_VERSION | cut -d. -f1)
ORTP_MINOR_VERSION=$(echo $PACKAGE_VERSION | cut -d. -f2)
......
......@@ -44,6 +44,7 @@ extern "C"{
#define PAYLOAD_TYPE_USER_FLAG_1 (1<<5)
#define PAYLOAD_TYPE_USER_FLAG_2 (1<<6)
#define PAYLOAD_TYPE_USER_FLAG_3 (1<<7)
#define PAYLOAD_TYPE_USER_FLAG_4 (1<<8)
/* ask for more if you need*/
#define PAYLOAD_AUDIO_CONTINUOUS 0
......@@ -93,7 +94,7 @@ typedef struct _PayloadTypeAvpfParams PayloadTypeAvpfParams;
ORTP_PUBLIC PayloadType *payload_type_new(void);
ORTP_PUBLIC PayloadType *payload_type_clone(PayloadType *payload);
ORTP_PUBLIC PayloadType *payload_type_clone(const PayloadType *payload);
ORTP_PUBLIC char *payload_type_get_rtpmap(PayloadType *pt);
ORTP_PUBLIC void payload_type_destroy(PayloadType *pt);
ORTP_PUBLIC void payload_type_set_recv_fmtp(PayloadType *pt, const char *fmtp);
......
......@@ -359,6 +359,9 @@ ORTP_PUBLIC void ortp_shm_close(void *memory);
#define ORTP_VAR_PUBLIC extern
#endif
#ifndef IN6_IS_ADDR_MULTICAST
#define IN6_IS_ADDR_MULTICAST(i) (((uint8_t *) (i))[0] == 0xff)
#endif
/*define __ios when we are compiling for ios.
The TARGET_OS_IPHONE macro is stupid, it is defined to 0 when compiling on mac os x.
......
......@@ -71,7 +71,7 @@ ORTP_PUBLIC void rtp_profile_set_payload(RtpProfile *prof, int idx, PayloadType
*@param index the payload type number
*@return the payload description (a PayloadType object)
**/
static ORTP_INLINE PayloadType * rtp_profile_get_payload(RtpProfile *prof, int idx){
static ORTP_INLINE PayloadType * rtp_profile_get_payload(const RtpProfile *prof, int idx){
if (idx<0 || idx>=RTP_PROFILE_MAX_PAYLOADS) {
return NULL;
}
......
......@@ -242,6 +242,8 @@ typedef struct _OrtpStream {
int loc_port;
socklen_t rem_addrlen;
struct sockaddr_storage rem_addr;
socklen_t loc_addrlen;
struct sockaddr_storage loc_addr;
struct _RtpTransport *tr;
mblk_t *cached_mp;
struct timeval send_bw_start; /* used for bandwidth estimation */
......@@ -325,7 +327,6 @@ struct _RtpSession
int pt;
unsigned int ssrc;
WaitPoint wp;
int telephone_events_pt; /* the payload type used for telephony events */
} snd,rcv;
unsigned int inc_ssrc_candidate;
int inc_same_ssrc_count;
......
......@@ -60,7 +60,6 @@ extern "C" {
ORTP_PUBLIC int rtp_session_telephone_events_supported(RtpSession *session);
ORTP_PUBLIC int rtp_session_send_telephone_events_supported(RtpSession *session);
ORTP_PUBLIC int rtp_session_recv_telephone_events_supported(RtpSession *session);
ORTP_PUBLIC mblk_t *rtp_session_create_telephone_event_packet(RtpSession *session, int start);
ORTP_PUBLIC int rtp_session_add_telephone_event(RtpSession *session,
......
......@@ -45,7 +45,7 @@ PayloadType *payload_type_new()
}
PayloadType *payload_type_clone(PayloadType *payload)
PayloadType *payload_type_clone(const PayloadType *payload)
{
PayloadType *newpayload=(PayloadType *)ortp_new0(PayloadType,1);
memcpy(newpayload,payload,sizeof(PayloadType));
......
......@@ -270,7 +270,7 @@ void rtp_session_rtp_parse(RtpSession *session, mblk_t *mp, uint32_t local_str_t
}
/* check for possible telephone events */
if (rtp->paytype==session->rcv.telephone_events_pt){
if (rtp_profile_is_telephone_event(session->snd.profile, rtp->paytype)){
queue_packet(&session->rtp.tev_rq,session->rtp.max_rq_size,mp,rtp,&discarded,&duplicate);
stats->discarded+=discarded;
ortp_global_stats.discarded+=discarded;
......@@ -288,7 +288,10 @@ void rtp_session_rtp_parse(RtpSession *session, mblk_t *mp, uint32_t local_str_t
}
/* Drop the packets while the RTP_SESSION_FLUSH flag is set. */
if (session->flags & RTP_SESSION_FLUSH) return;
if (session->flags & RTP_SESSION_FLUSH) {
freemsg(mp);
return;
}
jitter_control_new_packet(&session->rtp.jittctl,rtp->timestamp,local_str_ts);
......
......@@ -245,8 +245,6 @@ rtp_session_init (RtpSession * session, int mode)
rtp_session_set_source_description(session,"unknown@unknown",NULL,NULL,
NULL,NULL,"oRTP-" ORTP_VERSION,NULL);
}
session->snd.telephone_events_pt=-1; /* not defined a priori */
session->rcv.telephone_events_pt=-1; /* not defined a priori */
rtp_session_set_profile (session, &av_profile); /*the default profile to work with */
session->rtp.gs.socket=-1;
session->rtcp.gs.socket=-1;
......@@ -934,8 +932,7 @@ __rtp_session_sendm_with_ts (RtpSession * session, mblk_t *mp, uint32_t packet_t
/* We are probably trying to send a STUN packet so don't change its content. */
} else {
rtp->timestamp=packet_ts;
if (session->snd.telephone_events_pt==rtp->paytype)
{
if (rtp_profile_is_telephone_event(session->snd.profile, rtp->paytype)){
rtp->seq_number = session->rtp.snd_seq;
session->rtp.snd_seq++;
}
......
......@@ -98,7 +98,7 @@ static bool_t try_connect(int fd, const struct sockaddr *dest, socklen_t addrlen
return TRUE;
}
static ortp_socket_t create_and_bind(const char *addr, int *port, int *sock_family, bool_t reuse_addr){
static ortp_socket_t create_and_bind(const char *addr, int *port, int *sock_family, bool_t reuse_addr,struct sockaddr_storage* bound_addr,socklen_t *bound_addr_len){
int err;
int optval = 1;
ortp_socket_t sock=-1;
......@@ -181,6 +181,8 @@ static ortp_socket_t create_and_bind(const char *addr, int *port, int *sock_fami
close_socket (sock);
sock=-1;
continue;
} else {
ortp_message ("RTP socket [%i] has joined address group [%s]",sock, addr);
}
}
break;
......@@ -197,6 +199,8 @@ static ortp_socket_t create_and_bind(const char *addr, int *port, int *sock_fami
close_socket (sock);
sock=-1;
continue;
} else {
ortp_message ("RTP socket 6 [%i] has joined address group [%s]",sock, addr);
}
}
break;
......@@ -204,6 +208,9 @@ static ortp_socket_t create_and_bind(const char *addr, int *port, int *sock_fami
#endif /*hpux*/
break;
}
memcpy(bound_addr,res0->ai_addr,res0->ai_addrlen);
*bound_addr_len=res0->ai_addrlen;
freeaddrinfo(res0);
#if defined(WIN32) || defined(_WIN32_WCE)
......@@ -302,14 +309,14 @@ rtp_session_set_local_addr (RtpSession * session, const char * addr, int rtp_por
}
/* try to bind the rtp port */
sock=create_and_bind(addr,&rtp_port,&sockfamily,session->reuseaddr);
sock=create_and_bind(addr,&rtp_port,&sockfamily,session->reuseaddr,&session->rtp.gs.loc_addr,&session->rtp.gs.loc_addrlen);
if (sock!=-1){
set_socket_sizes(sock,session->rtp.snd_socket_size,session->rtp.rcv_socket_size);
session->rtp.gs.sockfamily=sockfamily;
session->rtp.gs.socket=sock;
session->rtp.gs.loc_port=rtp_port;
/*try to bind rtcp port */
sock=create_and_bind(addr,&rtcp_port,&sockfamily,session->reuseaddr);
sock=create_and_bind(addr,&rtcp_port,&sockfamily,session->reuseaddr,&session->rtcp.gs.loc_addr,&session->rtcp.gs.loc_addrlen);
if (sock!=(ortp_socket_t)-1){
session->rtcp.gs.sockfamily=sockfamily;
session->rtcp.gs.socket=sock;
......
......@@ -83,4 +83,6 @@ void ortp_stream_clear_aux_addresses(OrtpStream *os);
* */
void rtp_session_set_transports(RtpSession *session, RtpTransport *rtptr, RtpTransport *rtcptr);
ORTP_PUBLIC bool_t rtp_profile_is_telephone_event(const RtpProfile *prof, int pt);
#endif
......@@ -44,10 +44,12 @@ PayloadType payload_type_telephone_event={
int rtp_session_telephone_events_supported(RtpSession *session)
{
/* search for a telephony event payload in the current profile */
session->snd.telephone_events_pt=rtp_profile_get_payload_number_from_mime(session->snd.profile,"telephone-event");
session->rcv.telephone_events_pt=rtp_profile_get_payload_number_from_mime(session->rcv.profile,"telephone-event");
/*printf("Telephone event pt is %i\n",session->telephone_events_pt);*/
return session->snd.telephone_events_pt;
return rtp_profile_get_payload_number_from_mime(session->snd.profile,"telephone-event");
}
bool_t rtp_profile_is_telephone_event(const RtpProfile *prof, int pt_num){
PayloadType *pt=rtp_profile_get_payload(prof, pt_num);
return pt && strcasecmp(pt->mime_type,"telephone-event")==0;
}
......@@ -61,9 +63,7 @@ int rtp_session_telephone_events_supported(RtpSession *session)
int rtp_session_send_telephone_events_supported(RtpSession *session)
{
/* search for a telephony event payload in the current profile */
session->snd.telephone_events_pt=rtp_profile_get_payload_number_from_mime(session->snd.profile,"telephone-event");
/*printf("Telephone event pt is %i\n",session->telephone_events_pt);*/
return session->snd.telephone_events_pt;
return rtp_profile_get_payload_number_from_mime(session->snd.profile,"telephone-event");
}
/**
......@@ -75,9 +75,7 @@ int rtp_session_send_telephone_events_supported(RtpSession *session)
**/int rtp_session_recv_telephone_events_supported(RtpSession *session)
{
/* search for a telephony event payload in the current profile */
session->rcv.telephone_events_pt=rtp_profile_get_payload_number_from_mime(session->rcv.profile,"telephone-event");
/*printf("Telephone event pt is %i\n",session->telephone_events_pt);*/
return session->snd.telephone_events_pt;
return rtp_profile_get_payload_number_from_mime(session->rcv.profile,"telephone-event");
}
......@@ -97,8 +95,9 @@ mblk_t *rtp_session_create_telephone_event_packet(RtpSession *session, int start
{
mblk_t *mp;
rtp_header_t *rtp;
return_val_if_fail(session->snd.telephone_events_pt!=-1,NULL);
PayloadType *cur_pt=rtp_profile_get_payload(session->snd.profile, rtp_session_get_send_payload_type(session));
int tev_pt=rtp_profile_find_payload_number(session->snd.profile, "telephone-event", cur_pt ? cur_pt->clock_rate : 8000, 1);
return_val_if_fail(tev_pt!=-1,NULL);
mp=allocb(RTP_FIXED_HEADER_SIZE+TELEPHONY_EVENTS_ALLOCATED_SIZE,BPRI_MED);
if (mp==NULL) return NULL;
......@@ -113,7 +112,7 @@ mblk_t *rtp_session_create_telephone_event_packet(RtpSession *session, int start
/*seq number set later, when packet is sended */
/*set the payload type */
rtp->paytype=session->snd.telephone_events_pt;
rtp->paytype=tev_pt;
/*copy the payload */
mp->b_wptr+=RTP_FIXED_HEADER_SIZE;
......@@ -310,7 +309,7 @@ int rtp_session_read_telephone_event(RtpSession *session,
telephone_event_t *tev;
rtp_header_t *hdr=(rtp_header_t*)packet->b_rptr;
unsigned char *payload;
if (hdr->paytype!=session->rcv.telephone_events_pt) return 0; /* this is not tel ev.*/
if (rtp_profile_is_telephone_event(session->rcv.profile, hdr->paytype)) return 0; /* this is not tel ev.*/
datasize=rtp_get_payload(packet,&payload);
tev=*tab=(telephone_event_t*)payload;
/* convert from network to host order what should be */
......
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